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

Bytes constructor test change compatible with PR #2380 #2390

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,24 @@ def test_constructors():
assert m.default_constructors() == expected

data = {
"bytes": b'41', # Currently no supported or working conversions.
"str": 42,
"bool": "Not empty",
"int": "42",
"float": "+1e3",
"tuple": range(3),
"list": range(3),
"dict": [("two", 2), ("one", 1), ("three", 3)],
"set": [4, 4, 5, 6, 6, 6],
"memoryview": b'abc'
bytes: b'41', # Currently no supported or working conversions.
str: 42,
bool: "Not empty",
int: "42",
float: "+1e3",
tuple: range(3),
list: range(3),
dict: [("two", 2), ("one", 1), ("three", 3)],
set: [4, 4, 5, 6, 6, 6],
memoryview: b'abc'
}
inputs = {k: v for k, v in data.items()}
expected = {k: eval(k)(v) for k, v in data.items()}
inputs = {k.__name__: v for k, v in data.items()}
expected = {k.__name__: k(v) for k, v in data.items()}
if str is bytes: # Similar to the above. See comments above.
inputs["bytes"] = b'41'
inputs["str"] = 42
expected["bytes"] = b'41'
expected["str"] = u"42"

assert m.converting_constructors(inputs) == expected
assert m.cast_functions(inputs) == expected
Expand Down