From 17bd8b1b6fc8daa1f8598797605a8d1742fa7376 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 12 Aug 2020 16:26:38 -0700 Subject: [PATCH] Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. --- tests/test_pytypes.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index c115edc5e83..1c7b1dd1f23 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -188,29 +188,23 @@ def func(self, x, *args): def test_constructors(): """C++ default and converting constructors are equivalent to type calls in Python""" - types = [bytes, str, bool, int, float, tuple, list, dict, set] + types = [str, bool, int, float, tuple, list, dict, set] expected = {t.__name__: t() for t in types} - if str is bytes: # Python 2. - # Note that bytes.__name__ == 'str' in Python 2. - # pybind11::str is unicode even under Python 2. - expected["bytes"] = bytes() - expected["str"] = u"" # flake8 complains about unicode(). 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' + 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()} assert m.converting_constructors(inputs) == expected assert m.cast_functions(inputs) == expected