test_datetime:test_subclass_datetime
def test_subclass_datetime():
# replace() should return a subclass but not call __new__ or __init__.
class MyDatetime(datetime.datetime):
forbidden = False
def __new__(cls):
if cls.forbidden: FAIL
return datetime.datetime.__new__(cls, 2016, 4, 5, 1, 2, 3)
def __init__(self, *args):
if self.forbidden: FAIL
d = MyDatetime()
d.forbidden = True
> d2 = d.replace(hour=7)
../build/extra_tests/test_datetime.py:357:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = extra_tests.test_datetime.test_subclass_datetime.<locals>.MyDatetime(2016, 4, 5, 1, 2, 3)
year = 2016, month = 4, day = 5, hour = 7, minute = 2, second = 3
microsecond = 0, tzinfo = None
def replace(self, year=None, month=None, day=None, hour=None,
minute=None, second=None, microsecond=None, tzinfo=True,
*, fold=None):
"""Return a new datetime with new values for the specified fields."""
if year is None:
year = self.year
if month is None:
month = self.month
if day is None:
day = self.day
if hour is None:
hour = self.hour
if minute is None:
minute = self.minute
if second is None:
second = self.second
if microsecond is None:
microsecond = self.microsecond
if tzinfo is True:
tzinfo = self.tzinfo
if fold is None:
fold = self.fold
> return type(self)(year, month, day, hour, minute, second,
microsecond, tzinfo, fold=fold)
E TypeError: test_subclass_datetime.<locals>.MyDatetime.__new__() got an unexpected keyword argument 'fold'
../build/lib-python/3/_pydatetime.py:2009: TypeError
builder: pypy-c-jit-linux-x86-32 build #8380+
test: test_datetime:test_subclass_datetime