python-restx/flask-restx

Some unit tests not passed

Opened this issue · 1 comments

***** BEFORE LOGGING AN ISSUE *****

  • Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.
  • Please check if a similar issue already exists or has been closed before. Seriously, nobody here is getting paid. Help us out and take five minutes to make sure you aren't submitting a duplicate.
  • Please review the guidelines for contributing

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

  • Python 3.10.15
  • Flask 3.0.3
  • Flask-RESTX main branch f1eeaa0
  • pytest-flask 1.3.0
  • pytz 2024.2

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