summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index c5f91fb..5b58e99 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -1520,6 +1520,13 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
base = cls(2000, 2, 29)
self.assertRaises(ValueError, base.replace, year=2001)
+ def test_subclass_replace(self):
+ class DateSubclass(self.theclass):
+ pass
+
+ dt = DateSubclass(2012, 1, 1)
+ self.assertIs(type(dt.replace(year=2013)), DateSubclass)
+
def test_subclass_date(self):
class C(self.theclass):
@@ -2626,6 +2633,13 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
self.assertRaises(ValueError, base.replace, second=100)
self.assertRaises(ValueError, base.replace, microsecond=1000000)
+ def test_subclass_replace(self):
+ class TimeSubclass(self.theclass):
+ pass
+
+ ctime = TimeSubclass(12, 30)
+ self.assertIs(type(ctime.replace(hour=10)), TimeSubclass)
+
def test_subclass_time(self):
class C(self.theclass):