test_datetime:test_subclass_time
def test_subclass_time():
# replace() should return a subclass but not call __new__ or __init__.
class MyTime(datetime.time):
forbidden = False
def __new__(cls):
if cls.forbidden: FAIL
return datetime.time.__new__(cls, 1, 2, 3)
def __init__(self, *args):
if self.forbidden: FAIL
d = MyTime()
d.forbidden = True
> d2 = d.replace(hour=5)
../build/extra_tests/test_datetime.py:342:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = extra_tests.test_datetime.test_subclass_time.<locals>.MyTime(1, 2, 3)
hour = 5, minute = 2, second = 3, microsecond = 0, tzinfo = None
def replace(self, hour=None, minute=None, second=None, microsecond=None,
tzinfo=True, *, fold=None):
"""Return a new time with new values for the specified fields."""
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)(hour, minute, second, microsecond, tzinfo, fold=fold)
E TypeError: test_subclass_time.<locals>.MyTime.__new__() got an unexpected keyword argument 'fold'
../build/lib-python/3/_pydatetime.py:1660: TypeError
builder: pypy-c-jit-linux-x86-64 build #11860+
test: test_datetime:test_subclass_time