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

Bug in enum test cases: schema can't handle int #213

Closed
RunOrVeith opened this issue Apr 30, 2020 · 0 comments · Fixed by #214
Closed

Bug in enum test cases: schema can't handle int #213

RunOrVeith opened this issue Apr 30, 2020 · 0 comments · Fixed by #214

Comments

@RunOrVeith
Copy link
Contributor

The tests inside test_enum.TestValidator have relied on a wrong operator binding order and thus
two cases that are actually not valid marshmallow were tested to be valid.

The issue is the following line:

assert not res == is_valid

res here is the output of schema.validate(), which returns a dict of validation errors.

However, not as lower precedence than == (see here), so the statement was treated as

assert not (res == is_valid)

which was Trueno matter what, since we compared a dict to a bool.

After fixing the precedence, two test cases fail: TestValidator.test_data_with_enum (1, True) and (1.23, True), because marshmallow does in fact not allow int enum values (there is a marshmallow_enum in the ecosystem here).

I will enclose a pull request that tests that these cases are actually False.
I found this while implementing a feature that allows enums as dict keys, which I will also link.
@lidatong

This was referenced Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant