Author: olliemath
Branch: py3.6
Changeset: r98307:5a886620335c
Date: 2019-12-17 15:24 +0000
http://bitbucket.org/pypy/pypy/changeset/5a886620335c/

Log:    Move normalize datetime tests to extra_tests

diff --git a/extra_tests/test_datetime.py b/extra_tests/test_datetime.py
--- a/extra_tests/test_datetime.py
+++ b/extra_tests/test_datetime.py
@@ -350,3 +350,31 @@
     d2 = d.replace(hour=7)
     assert type(d2) is MyDatetime
     assert d2 == datetime.datetime(2016, 4, 5, 7, 2, 3)
+
+def test_normalize_pair():
+    normalize = datetime._normalize_pair
+
+    assert normalize(1, 59, 60) == (1, 59)
+    assert normalize(1, 60, 60) == (2, 0)
+    assert normalize(1, 95, 60) == (2, 35)
+
+def test_normalize_date():
+    normalize = datetime._normalize_date
+
+    # Huge year is caught correctly
+    with pytest.raises(OverflowError):
+        normalize(1000 * 1000, 1, 1)
+    # Normal dates should be unchanged
+    assert normalize(3000, 1, 1) == (3000, 1, 1)
+    # Month overflows year boundary
+    assert normalize(2001, 24, 1) == (2002, 12, 1)
+    # Day overflows month boundary
+    assert normalize(2001, 14, 31) == (2002, 3, 3)
+    # Leap years? :S
+    assert normalize(2001, 1, 61) == (2001, 3, 2)
+    assert normalize(2000, 1, 61) == (2000, 3, 1)
+
+def test_normalize_datetime():
+    normalize = datetime._normalize_datetime
+    abnormal = (2002, 13, 35, 30, 95, 75, 1000001)
+    assert normalize(*abnormal) == (2003, 2, 5, 7, 36, 16, 1)
diff --git a/lib-python/3/test/datetimetester.py 
b/lib-python/3/test/datetimetester.py
--- a/lib-python/3/test/datetimetester.py
+++ b/lib-python/3/test/datetimetester.py
@@ -100,34 +100,6 @@
         self.assertEqual(dar(6, -4), -2)
         self.assertEqual(dar(-6, -4), 2)
 
-    def test_normalize_pair(self):
-        normalize = datetime_module._normalize_pair
-
-        self.assertEqual(normalize(1, 59, 60), (1, 59))
-        self.assertEqual(normalize(1, 60, 60), (2, 0))
-        self.assertEqual(normalize(1, 95, 60), (2, 35))
-
-    def test_normalize_date(self):
-        normalize = datetime_module._normalize_date
-
-        # Huge year is caught correctly
-        with self.assertRaises(OverflowError):
-            normalize(1000 * 1000, 1, 1)
-        # Normal dates should be unchanged
-        self.assertEqual(normalize(3000, 1, 1), (3000, 1, 1))
-        # Month overflows year boundary
-        self.assertEqual(normalize(2001, 24, 1), (2002, 12, 1))
-        # Day overflows month boundary
-        self.assertEqual(normalize(2001, 14, 31), (2002, 3, 3))
-        # Leap years? :S
-        self.assertEqual(normalize(2001, 1, 61), (2001, 3, 2))
-        self.assertEqual(normalize(2000, 1, 61), (2000, 3, 1))
-
-    def test_normalize_datetime(self):
-        normalize = datetime_module._normalize_datetime
-        abnormal = (2002, 13, 35, 30, 95, 75, 1000001)
-        self.assertEqual(normalize(*abnormal), (2003, 2, 5, 7, 36, 16, 1))
-
 
 #############################################################################
 # tzinfo tests
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to