diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e73f1ecb3d4..931895d8df0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,6 +18,7 @@ env: CARGO_ARGS: --no-default-features --features stdlib,zlib,importlib,encodings,ssl # Skip additional tests on Windows. They are checked on Linux and MacOS. WINDOWS_SKIPS: >- + test_datetime test_glob test_importlib test_io diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 55e061950ff..e1d1f3b14da 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -196,6 +196,8 @@ def test_normal(self): self.assertEqual(fo.tzname(dt), "Three") self.assertEqual(fo.dst(dt), timedelta(minutes=42)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_pickling_base(self): # There's no point to pickling tzinfo objects on their own (they # carry no data), but they need to be picklable anyway else @@ -207,6 +209,8 @@ def test_pickling_base(self): derived = unpickler.loads(green) self.assertIs(type(derived), tzinfo) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_pickling_subclass(self): # Make sure we can pickle/unpickle an instance of a subclass. offset = timedelta(minutes=-300) @@ -385,6 +389,8 @@ def test_aware_datetime(self): self.assertEqual(tz.dst(t), t.replace(tzinfo=tz).dst()) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_pickle(self): for tz in self.ACDT, self.EST, timezone.min, timezone.max: for pickler, unpickler, proto in pickle_choices: @@ -395,6 +401,8 @@ def test_pickle(self): tz_copy = unpickler.loads(pickler.dumps(tz, proto)) self.assertIs(tz_copy, tz) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_copy(self): for tz in self.ACDT, self.EST, timezone.min, timezone.max: tz_copy = copy.copy(tz) @@ -403,6 +411,8 @@ def test_copy(self): tz_copy = copy.copy(tz) self.assertIs(tz_copy, tz) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_deepcopy(self): for tz in self.ACDT, self.EST, timezone.min, timezone.max: tz_copy = copy.deepcopy(tz) @@ -1498,6 +1508,8 @@ def test_strftime(self): # bpo-41260: The parameter was named "fmt" in the pure python impl. t.strftime(format="%f") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_strftime_trailing_percent(self): # bpo-35066: Make sure trailing '%' doesn't cause datetime's strftime to # complain. Different libcs have different handling of trailing @@ -1598,6 +1610,8 @@ def test_pickling(self): self.assertEqual(orig, derived) self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_compat_unpickle(self): tests = [ b"cdatetime\ndate\n(S'\\x07\\xdf\\x0b\\x1b'\ntR.", @@ -2365,6 +2379,8 @@ def test_pickling_subclass_datetime(self): self.assertEqual(orig, derived) self.assertTrue(isinstance(derived, SubclassDatetime)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_compat_unpickle(self): tests = [ b'cdatetime\ndatetime\n(' @@ -2937,6 +2953,8 @@ def newmeth(self, start): self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month + dt1.second - 7) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_subclass_alternate_constructors_datetime(self): # Test that alternate constructors call the constructor class DateTimeSubclass(self.theclass): @@ -3635,6 +3653,8 @@ def test_pickling_subclass_time(self): self.assertEqual(orig, derived) self.assertTrue(isinstance(derived, SubclassTime)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_compat_unpickle(self): tests = [ (b"cdatetime\ntime\n(S'\\x14;\\x10\\x00\\x10\\x00'\ntR.", @@ -4007,6 +4027,8 @@ def test_hash_edge_cases(self): t2 = self.theclass(23, 48, 6, 100, tzinfo=FixedOffset(-1010, "")) self.assertEqual(hash(t1), hash(t2)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_pickling(self): # Try one without a tzinfo. args = 20, 59, 16, 64**2 @@ -4029,6 +4051,8 @@ def test_pickling(self): self.assertEqual(derived.tzname(), 'cookie') self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_compat_unpickle(self): tests = [ b"cdatetime\ntime\n(S'\\x05\\x06\\x07\\x01\\xe2@'\n" @@ -4458,6 +4482,8 @@ def utcoffset(self, dt): t2 = self.theclass(2, 2, 2, tzinfo=FixedOffset(0, "")) self.assertRaises(ValueError, lambda: t1 == t2) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_pickling(self): # Try one without a tzinfo. args = 6, 7, 23, 20, 59, 1, 64**2 @@ -4481,6 +4507,8 @@ def test_pickling(self): self.assertEqual(derived.tzname(), 'cookie') self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2)) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_compat_unpickle(self): tests = [ b'cdatetime\ndatetime\n' @@ -5443,6 +5471,8 @@ def test_bug_1028306(self): self.assertEqual(as_datetime, datetime_sc) self.assertEqual(datetime_sc, as_datetime) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_extra_attributes(self): with self.assertWarns(DeprecationWarning): utcnow = datetime.utcnow() diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index 3859733a4fe..ead211bec37 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -20,8 +20,14 @@ def load_tests(loader, tests, pattern): for modname in ['datetime', '_datetime', '_strptime']: sys.modules.pop(modname, None) - test_modules = [pure_tests, fast_tests] - test_suffixes = ["_Pure", "_Fast"] + test_modules = [ + pure_tests, + # fast_tests # XXX: RUSTPYTHON; not supported yet + ] + test_suffixes = [ + "_Pure", + # "_Fast" # XXX: RUSTPYTHON; not supported yet + ] # XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might # not believe this, but in spite of all the sys.modules trickery running a _Pure # test last will leave a mix of pure and native datetime stuff lying around. diff --git a/vm/src/stdlib/time.rs b/vm/src/stdlib/time.rs index 71c4fb5f98a..4f807b77346 100644 --- a/vm/src/stdlib/time.rs +++ b/vm/src/stdlib/time.rs @@ -2,10 +2,19 @@ // See also: // https://docs.python.org/3/library/time.html -pub use time::*; +use crate::{builtins::PyModule, VirtualMachine, PyRef}; + +pub use decl::time; + +pub(crate) fn make_module(vm: &VirtualMachine) -> PyRef { + let module = decl::make_module(vm); + #[cfg(not(target_env = "msvc"))] + unsafe { decl::tz::tzset() }; + module +} #[pymodule(name = "time", with(platform))] -mod time { +mod decl { use crate::{ builtins::{tuple::IntoPyTuple, PyStrRef, PyTupleRef, PyTypeRef}, function::{Either, FuncArgs, OptionalArg}, @@ -416,7 +425,7 @@ mod time { #[pymodule(sub)] mod platform { #[allow(unused_imports)] - use super::{SEC_TO_NS, US_TO_NS}; + use super::decl::{SEC_TO_NS, US_TO_NS}; #[cfg_attr(target_os = "macos", allow(unused_imports))] use crate::{ builtins::{PyNamespace, PyStrRef},