Skip to content

Commit

Permalink
test_readergroups: allow --iterations=10
Browse files Browse the repository at this point in the history
The readergroup is global so each test must restore the previous state
(empty reader group).

The error was:
$ pytest --iterations=10 test/test_readergroups.py
============================= test session starts ==============================
platform darwin -- Python 3.12.8, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/rousseau/Documents/sc/pyscard/pyscard
configfile: pyproject.toml
plugins: run-parallel-0.3.0
collected 7 items

test/test_readergroups.py .Fxx..F                                        [100%]

=================================== FAILURES ===================================
_______________________ test_reader_groups_method_calls ________________________

    def test_reader_groups_method_calls():
        reader_group = smartcard.reader.ReaderGroups.readergroups()
>       assert len(reader_group.instance) == 0, "No reader groups should be pre-defined"
E       AssertionError: No reader groups should be pre-defined
E       assert 1 == 0
E        +  where 1 = len(['a'])
E        +    where ['a'] = <smartcard.reader.ReaderGroups.readergroups object at 0x10ecbb110>.instance

test/test_readergroups.py:17: AssertionError
____________________ test_demonstrate_getting_is_impossible ____________________

    def test_demonstrate_getting_is_impossible():
        """Demonstrate that `.getreadergroups()` returns hard-coded values."""

        reader_group = smartcard.reader.ReaderGroups.readergroups()
        list.append(reader_group.instance, "a")
>       assert reader_group.instance == ["a"]
E       AssertionError: assert ['a', 'a'] == ['a']
E
E         Left contains one more item: 'a'
E         Use -v to get more diff

test/test_readergroups.py:88: AssertionError
=========================== short test summary info ============================
FAILED test/test_readergroups.py::test_reader_groups_method_calls - AssertionError: No reader groups should be pre-defined
FAILED test/test_readergroups.py::test_demonstrate_getting_is_impossible - AssertionError: assert ['a', 'a'] == ['a']
  • Loading branch information
LudovicRousseau committed Feb 4, 2025
1 parent 2a20c2d commit 4d72f9d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/test_readergroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def test_reader_groups_method_calls():
reader_group.addreadertogroup("no-op", "bogus")
reader_group.removereaderfromgroup("no-op", "bogus")

assert list.pop(reader_group.instance) == "a"
assert len(list(reader_group.instance)) == 0


# ------------------------------------------------------------------------------------
# The tests below this line demonstrate serious behavioral problems with readergroups.
Expand Down Expand Up @@ -87,3 +90,5 @@ def test_demonstrate_getting_is_impossible():
list.append(reader_group.instance, "a")
assert reader_group.instance == ["a"]
assert reader_group.getreadergroups() == []
assert list.pop(reader_group.instance) == "a"
assert len(list(reader_group.instance)) == 0

0 comments on commit 4d72f9d

Please sign in to comment.