File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1362,7 +1362,7 @@ template <typename Type> class enum_ : public class_<Type> {
1362
1362
1363
1363
constexpr bool is_arithmetic = detail::any_of<std::is_same<arithmetic, Extra>...>::value;
1364
1364
1365
- auto entries = m_entries;
1365
+ dict& entries = m_entries;
1366
1366
def (" __repr__" , [name, entries](Type value) -> pybind11::str {
1367
1367
for (const auto &kv : entries) {
1368
1368
if (pybind11::cast<Type>(kv.second ) == value)
Original file line number Diff line number Diff line change @@ -46,7 +46,18 @@ def test_converstion_enum():
46
46
assert m .test_conversion_enum (m .ConversionEnum .Convert1 ) == "ConversionEnum::Convert1"
47
47
assert m .test_conversion_enum (m .ConversionEnum ("Convert1" )) == "ConversionEnum::Convert1"
48
48
assert m .test_conversion_enum ("Convert1" ) == "ConversionEnum::Convert1"
49
- assert m .test_conversion_enum (m .ConversionEnum .Convert1 ) == "ConversionEnum::Convert1"
49
+
50
+
51
+ def test_conversion_enum_raises ():
52
+ with pytest .raises (ValueError ) as excinfo :
53
+ m .ConversionEnum ("Convert0" )
54
+ assert str (excinfo .value ) == "\" Convert0\" is not a valid value for enum type ConversionEnum"
55
+
56
+
57
+ def test_conversion_enum_raises_implicit ():
58
+ with pytest .raises (ValueError ) as excinfo :
59
+ m .test_conversion_enum ("Convert0" )
60
+ assert str (excinfo .value ) == "\" Convert0\" is not a valid value for enum type ConversionEnum"
50
61
51
62
52
63
def test_scoped_enum ():
You can’t perform that action at this time.
0 commit comments