python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.16k stars 335 forks source link

Some unit tests not passed #620

Open buttonfly1000 opened 1 month ago

buttonfly1000 commented 1 month ago

BEFORE LOGGING AN ISSUE

Code

inv test

Repro Steps (if applicable)

  1. In the main branch, run inv test
  2. Not all tests passed.

Expected Behavior

All tests passed.

Actual Behavior

There are 2 tests not passed.

Error Messages/Stack Trace

__________________________________ DatetimeFieldTest.test_rfc822_value[value4-Sat, 01 Jan 2011 22:59:59 -0000] ___________________________________

self = <tests.test_fields.DatetimeFieldTest object at 0x7f554aeafb20>
value = datetime.datetime(2011, 1, 1, 23, 59, 59, tzinfo=<DstTzInfo 'CET' LMT+0:18:00 STD>), expected = 'Sat, 01 Jan 2011 22:59:59 -0000'

    @pytest.mark.parametrize(
        "value,expected",
        [
            (date(2011, 1, 1), "Sat, 01 Jan 2011 00:00:00 -0000"),
            (datetime(2011, 1, 1), "Sat, 01 Jan 2011 00:00:00 -0000"),
            (datetime(2011, 1, 1, 23, 59, 59), "Sat, 01 Jan 2011 23:59:59 -0000"),
            (
                datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc),
                "Sat, 01 Jan 2011 23:59:59 -0000",
            ),
            (
                datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.timezone("CET")),
                "Sat, 01 Jan 2011 22:59:59 -0000",
            ),
        ],
    )
    def test_rfc822_value(self, value, expected):
>       self.assert_field(fields.DateTime(dt_format="rfc822"), value, expected)

tests/test_fields.py:551: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_fields.DatetimeFieldTest object at 0x7f554aeafb20>, field = <flask_restx.fields.DateTime object at 0x7f554a1734c0>
value = datetime.datetime(2011, 1, 1, 23, 59, 59, tzinfo=<DstTzInfo 'CET' LMT+0:18:00 STD>), expected = 'Sat, 01 Jan 2011 22:59:59 -0000'

    def assert_field(self, field, value, expected):
>       assert field.output("foo", {"foo": value}) == expected
E       AssertionError: assert 'Sat, 01 Jan ...3:41:59 -0000' == 'Sat, 01 Jan ...2:59:59 -0000'
E         - Sat, 01 Jan 2011 22:59:59 -0000
E         ?                   ^   ---
E         + Sat, 01 Jan 2011 23:41:59 -0000
E         ?                   ^^^^

tests/test_fields.py:24: AssertionError
_____________________________________ DatetimeFieldTest.test_iso8601_value[value6-2011-01-01T23:59:59+01:00] _____________________________________

self = <tests.test_fields.DatetimeFieldTest object at 0x7f554aeac520>
value = datetime.datetime(2011, 1, 1, 23, 59, 59, tzinfo=<DstTzInfo 'CET' LMT+0:18:00 STD>), expected = '2011-01-01T23:59:59+01:00'

    @pytest.mark.parametrize(
        "value,expected",
        [
            (date(2011, 1, 1), "2011-01-01T00:00:00"),
            (datetime(2011, 1, 1), "2011-01-01T00:00:00"),
            (datetime(2011, 1, 1, 23, 59, 59), "2011-01-01T23:59:59"),
            (datetime(2011, 1, 1, 23, 59, 59, 1000), "2011-01-01T23:59:59.001000"),
            (
                datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc),
                "2011-01-01T23:59:59+00:00",
            ),
            (
                datetime(2011, 1, 1, 23, 59, 59, 1000, tzinfo=pytz.utc),
                "2011-01-01T23:59:59.001000+00:00",
            ),
            (
                datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.timezone("CET")),
                "2011-01-01T23:59:59+01:00",
            ),
        ],
    )
    def test_iso8601_value(self, value, expected):
>       self.assert_field(fields.DateTime(dt_format="iso8601"), value, expected)

tests/test_fields.py:575: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_fields.DatetimeFieldTest object at 0x7f554aeac520>, field = <flask_restx.fields.DateTime object at 0x7f554a0f3af0>
value = datetime.datetime(2011, 1, 1, 23, 59, 59, tzinfo=<DstTzInfo 'CET' LMT+0:18:00 STD>), expected = '2011-01-01T23:59:59+01:00'

    def assert_field(self, field, value, expected):
>       assert field.output("foo", {"foo": value}) == expected
E       AssertionError: assert '2011-01-01T23:59:59+00:18' == '2011-01-01T23:59:59+01:00'
E         - 2011-01-01T23:59:59+01:00
E         ?                       ^^^
E         + 2011-01-01T23:59:59+00:18
E         ?                      ++ ^

tests/test_fields.py:24: AssertionError

Environment

peter-doggart commented 2 weeks ago

@buttonfly1000 Thanks for this. Will try and get this reviewed and merged this week. Not had much time to work on this project lately!