Skip to content

Commit 717784d

Browse files
committed
Fix test_calendar tests
1 parent f98a381 commit 717784d

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pylib = { package = "rustpython-pylib", path = "vm/pylib-crate", version = "0.1.
3535
dirs = { package = "dirs-next", version = "1.0" }
3636
num-traits = "0.2.8"
3737
cfg-if = "0.1"
38+
libc = "0.2"
3839

3940
flame = { version = "0.2", optional = true }
4041
flamescope = { version = "0.1", optional = true }

‎Lib/_codecs.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,8 @@ def PyUnicode_DecodeUTF16Stateful(s, size, errors, byteorder='native', final=Tru
10061006
# have any nested variables.
10071007

10081008
def STORECHAR(CH, byteorder):
1009-
hi = chr(((CH) >> 8) & 0xff)
1010-
lo = chr((CH) & 0xff)
1009+
hi = (CH >> 8) & 0xff
1010+
lo = CH & 0xff
10111011
if byteorder == 'little':
10121012
return [lo, hi]
10131013
else:

‎Lib/test/test_calendar.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -817,18 +817,14 @@ def test_output_current_year(self):
817817
self.assertIn(b'January', stdout)
818818
self.assertIn(b'Mo Tu We Th Fr Sa Su', stdout)
819819

820-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
821820
def test_output_year(self):
822821
stdout = self.run_ok('2004')
823822
self.assertEqual(stdout, conv(result_2004_text))
824823

825-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
826824
def test_output_month(self):
827825
stdout = self.run_ok('2004', '1')
828826
self.assertEqual(stdout, conv(result_2004_01_text))
829827

830-
# TODO: RUSTPYTHON
831-
@unittest.expectedFailure
832828
def test_option_encoding(self):
833829
self.assertFailure('-e')
834830
self.assertFailure('--encoding')
@@ -860,7 +856,6 @@ def test_option_width(self):
860856
stdout = self.run_ok('--width', '3', '2004')
861857
self.assertIn(b'Mon Tue Wed Thu Fri Sat Sun', stdout)
862858

863-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
864859
def test_option_lines(self):
865860
self.assertFailure('-l')
866861
self.assertFailure('--lines')
@@ -875,15 +870,13 @@ def test_option_spacing(self):
875870
stdout = self.run_ok('--spacing', '8', '2004')
876871
self.assertIn(b'Su Mo', stdout)
877872

878-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
879873
def test_option_months(self):
880874
self.assertFailure('-m')
881875
self.assertFailure('--month')
882876
self.assertFailure('-m', 'spam')
883877
stdout = self.run_ok('--months', '1', '2004')
884878
self.assertIn(conv('\nMo Tu We Th Fr Sa Su\n'), stdout)
885879

886-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
887880
def test_option_type(self):
888881
self.assertFailure('-t')
889882
self.assertFailure('--type')

‎src/main.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ fn main() {
3636
settings.initialization_parameter = InitParameter::InitializeInternal;
3737
}
3838

39+
// don't translate newlines (\r\n <=> \n)
40+
#[cfg(windows)]
41+
{
42+
extern "C" {
43+
fn _setmode(fd: i32, flags: i32) -> i32;
44+
}
45+
unsafe {
46+
_setmode(0, libc::O_BINARY);
47+
_setmode(1, libc::O_BINARY);
48+
_setmode(2, libc::O_BINARY);
49+
}
50+
}
51+
3952
let vm = VirtualMachine::new(settings);
4053

4154
let res = run_rustpython(&vm, &matches);

0 commit comments

Comments
 (0)