Skip to content

Commit

Permalink
remove obsolete test and add explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Sep 25, 2023
1 parent d698a0e commit b57a37c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 47 deletions.
9 changes: 9 additions & 0 deletions src/superqt/combobox/_enum_combobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ def _get_name(enum_value: Enum):
f"Expected Flag instance, got {enum_value}"
) # pragma: no cover
if sys.version_info >= (3, 11):
# There is a bug in some releases of Python 3.11 (for example 3.11.3)
# that leads to wrong evaluation of or operation on Flag members
# and produces numeric value without proper set name property.
return f"{enum_value.value}"

Check warning on line 34 in src/superqt/combobox/_enum_combobox.py

View check run for this annotation

Codecov / codecov/patch

src/superqt/combobox/_enum_combobox.py#L34

Added line #L34 was not covered by tests

# Before python 3.11 there is no smart name set during
# the creation of Flag members.
# We needs to decompose the value to get the name.
# It is under if condition because it uses private API.

from enum import _decompose

members, not_covered = _decompose(enum_value.__class__, enum_value.value)
Expand Down
47 changes: 0 additions & 47 deletions tests/test_enum_comb_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,53 +197,6 @@ def test_enum_flag_create_collision(qtbot):
assert [enum.itemText(i) for i in range(enum.count())] == ["a", "b", "c"]


@pytest.mark.skipif(
sys.version_info < (3, 11), reason="different representation in 3.11"
)
def test_enum_flag_create_collision_not_covered_py311(qtbot):
enum = QEnumComboBox(enum_class=Flag2)
qtbot.addWidget(enum)
assert [enum.itemText(i) for i in range(enum.count())] == [
"a",
"b",
"c",
"a|b",
"a|b|4",
]


@pytest.mark.skipif(
sys.version_info >= (3, 11), reason="different representation in 3.11"
)
def test_enum_flag_create_collision_not_covered(qtbot):
enum = QEnumComboBox(enum_class=Flag2)
qtbot.addWidget(enum)
assert [enum.itemText(i) for i in range(enum.count())] == [
"a",
"b",
"c",
"a|b",
"a|b|c",
]


@pytest.mark.skipif(
sys.version_info < (3, 11), reason="different representation in 3.11"
)
def test_enum_flag_create_collision_evaluated_to_seven_py311(qtbot):
enum = QEnumComboBox(enum_class=FlagOrNum)
qtbot.addWidget(enum)
assert [enum.itemText(i) for i in range(enum.count())] == [
"a",
"b",
"c",
"7",
"c|3",
"c|5",
"c|7",
]


@pytest.mark.skipif(
sys.version_info >= (3, 11), reason="different representation in 3.11"
)
Expand Down

0 comments on commit b57a37c

Please sign in to comment.