mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
The date class is now properly subclassable. (SF bug #720908)
(This is only the tip of the iceberg; the time and datetime classes need the same treatment.)
This commit is contained in:
parent
4dcdb78c6f
commit
8b7a9a38c6
3 changed files with 16 additions and 5 deletions
|
|
@ -479,6 +479,12 @@ class TestDateOnly(unittest.TestCase):
|
|||
dt2 = dt - delta
|
||||
self.assertEqual(dt2, dt - days)
|
||||
|
||||
def test_subclass_date(self):
|
||||
class C(date):
|
||||
theAnswer = 42
|
||||
dt = C(2003, 4, 14)
|
||||
self.assertEqual(dt.__class__, C)
|
||||
|
||||
class TestDate(HarmlessMixedComparison):
|
||||
# Tests here should pass for both dates and datetimes, except for a
|
||||
# few tests that TestDateTime overrides.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue