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

Unit Test "EmailTest.test_invalid_values_check" is failing #602

Open
StellaContrail opened this issue Apr 15, 2024 · 1 comment · May be fixed by #603
Open

Unit Test "EmailTest.test_invalid_values_check" is failing #602

StellaContrail opened this issue Apr 15, 2024 · 1 comment · May be fixed by #603
Labels
bug Something isn't working

Comments

@StellaContrail
Copy link

StellaContrail commented Apr 15, 2024

Summary

The unit test case "EmailTest.test_invalid_values_check" fails because the not-found .fr was registered a few weeks ago and doesn't throw a ValueError exception anymore. This affects the CI process. (Tests #2026)

For test cases, reserved domain names should be used instead, as described in RFC 2606.

Code

The EmailTest.test_invalid_values_check testcase expects all the domain names to be invalid although the not-found .fr one is actually valid. (ICANN Lookup)

    @pytest.mark.parametrize(
        "value",
        [
            "coucou@not-found.fr",
            "me@localhost",
            "me@127.0.0.1",
            "me@127.1.2.3",
            "me@::1",
            "me@200.8.9.10",
            "me@2001:db8:85a3::8a2e:370:7334",
        ],
    )
    def test_invalid_values_check(self, value):
        email = inputs.email(check=True)
        self.assert_bad_email(email, value)

Expected Behavior

All unit tests should be passing.

Actual Behavior

The EmailTest.test_invalid_values_check testcase fails.

Error Messages/Stack Trace

Here's a partial result from tox command.

======================================================= FAILURES =======================================================
_______________________________ EmailTest.test_invalid_values_check[coucou@not-found.fr] _______________________________

self = <tests.test_inputs.EmailTest object at 0x7f5816d65150>, value = 'coucou@not-found.fr'

    @pytest.mark.parametrize(
        "value",
        [
            "coucou@not-found.fr",
            "me@localhost",
            "me@127.0.0.1",
            "me@127.1.2.3",
            "me@::1",
            "me@200.8.9.10",
            "me@2001:db8:85a3::8a2e:370:7334",
        ],
    )
    def test_invalid_values_check(self, value):
        email = inputs.email(check=True)
>       self.assert_bad_email(email, value)

tests/test_inputs.py:667:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_inputs.EmailTest object at 0x7f5816d65150>
validator = <flask_restx.inputs.email object at 0x7f5816d648b0>, value = 'coucou@not-found.fr'
msg = '{0} is not a valid email'

    def assert_bad_email(self, validator, value, msg=None):
        msg = msg or "{0} is not a valid email"
>       with pytest.raises(ValueError) as cm:
E       Failed: DID NOT RAISE <class 'ValueError'>

tests/test_inputs.py:605: Failed

Environment

  • Python version: py 3.8 - 3.12, pypy 3.8
  • Flask version: 2, 3
  • Flask-RESTX version: 1.3.0
  • Other installed Flask extensions: none

Additional Context

@StellaContrail StellaContrail added the bug Something isn't working label Apr 15, 2024
@StellaContrail
Copy link
Author

StellaContrail commented Apr 15, 2024

Lint fix also included, so all checks can pass before merging.

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.

1 participant