Skip to content

Unit Test "EmailTest.test_invalid_values_check" is failing #602

Closed
@StellaContrail

Description

@StellaContrail

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",
        [
            "[email protected]",
            "me@localhost",
            "[email protected]",
            "[email protected]",
            "me@::1",
            "[email protected]",
            "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[[email protected]] _______________________________

self = <tests.test_inputs.EmailTest object at 0x7f5816d65150>, value = '[email protected]'

    @pytest.mark.parametrize(
        "value",
        [
            "[email protected]",
            "me@localhost",
            "[email protected]",
            "[email protected]",
            "me@::1",
            "[email protected]",
            "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 = '[email protected]'
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions