Home - Summaries: (main) : (py3.11) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

test_datetime:test_subclass_date

def test_subclass_date():
        # replace() should return a subclass but not call __new__ or __init__.
        class MyDate(datetime.date):
            forbidden = False
            def __new__(cls):
                if cls.forbidden: FAIL
                return datetime.date.__new__(cls, 2016, 2, 3)
            def __init__(self, *args):
                if self.forbidden: FAIL
        d = MyDate()
        d.forbidden = True
>       d2 = d.replace(day=5)

../build/extra_tests/test_datetime.py:327: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = extra_tests.test_datetime.test_subclass_date.<locals>.MyDate(2016, 2, 3)
year = 2016, month = 2, day = 5

    def replace(self, year=None, month=None, day=None):
        """Return a new date 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
>       return type(self)(year, month, day)
E       TypeError: test_subclass_date.<locals>.MyDate.__new__() takes 1 positional argument but 4 were given

../build/lib-python/3/_pydatetime.py:1125: TypeError
builder: pypy-c-jit-linux-x86-64 build #11860+
test: test_datetime:test_subclass_date