Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some unit tests not passed #620

Open
buttonfly1000 opened this issue Oct 2, 2024 · 1 comment · May be fixed by #621
Open

Some unit tests not passed #620

buttonfly1000 opened this issue Oct 2, 2024 · 1 comment · May be fixed by #621
Labels
bug Something isn't working

Comments

@buttonfly1000
Copy link

***** 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 buttonfly1000 added the bug Something isn't working label Oct 2, 2024
buttonfly1000 added a commit to buttonfly1000/flask-restx that referenced this issue Oct 2, 2024
As per the document https://pythonhosted.org/pytz/ :
`Unfortunately using the tzinfo argument of the standard datetime constructors 'does not work' with pytz for many timezones`.

This fixes python-restx#620
@peter-doggart
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants