Skip to content

Commit 17bd8b1

Browse files
committed
Rolling back PR pybind#2340 change to tests/test_pytypes.py (only this one file).
The two other files changed with PR pybind#2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR pybind#2380.
1 parent f83a24b commit 17bd8b1

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

tests/test_pytypes.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,29 +188,23 @@ def func(self, x, *args):
188188

189189
def test_constructors():
190190
"""C++ default and converting constructors are equivalent to type calls in Python"""
191-
types = [bytes, str, bool, int, float, tuple, list, dict, set]
191+
types = [str, bool, int, float, tuple, list, dict, set]
192192
expected = {t.__name__: t() for t in types}
193-
if str is bytes: # Python 2.
194-
# Note that bytes.__name__ == 'str' in Python 2.
195-
# pybind11::str is unicode even under Python 2.
196-
expected["bytes"] = bytes()
197-
expected["str"] = u"" # flake8 complains about unicode().
198193
assert m.default_constructors() == expected
199194

200195
data = {
201-
"bytes": b'41', # Currently no supported or working conversions.
202-
"str": 42,
203-
"bool": "Not empty",
204-
"int": "42",
205-
"float": "+1e3",
206-
"tuple": range(3),
207-
"list": range(3),
208-
"dict": [("two", 2), ("one", 1), ("three", 3)],
209-
"set": [4, 4, 5, 6, 6, 6],
210-
"memoryview": b'abc'
196+
str: 42,
197+
bool: "Not empty",
198+
int: "42",
199+
float: "+1e3",
200+
tuple: range(3),
201+
list: range(3),
202+
dict: [("two", 2), ("one", 1), ("three", 3)],
203+
set: [4, 4, 5, 6, 6, 6],
204+
memoryview: b'abc'
211205
}
212-
inputs = {k: v for k, v in data.items()}
213-
expected = {k: eval(k)(v) for k, v in data.items()}
206+
inputs = {k.__name__: v for k, v in data.items()}
207+
expected = {k.__name__: k(v) for k, v in data.items()}
214208

215209
assert m.converting_constructors(inputs) == expected
216210
assert m.cast_functions(inputs) == expected

0 commit comments

Comments
 (0)