LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
403 stars 115 forks source link

Test reader groups #202

Closed kurtmckee closed 1 month ago

kurtmckee commented 1 month ago

This PR introduces extensive testing of the readergroups class, and achieves 100% test coverage of the file.

However, readergroups has pathological implementation problems, which are captured in the tests marked with xfail or that use pytest.raises() to capture failures:

There is at least one side effect I've found when readergroups is inherited by the PSCS reader groups subclass, but I haven't added those tests yet.

Now that the problems are captured in the test suite, I intend to work to remove the readergroups class entirely.

coveralls commented 1 month ago

Coverage Status

coverage: 62.194% (+1.2%) from 60.998% when pulling 1d6408f0d46941ff4d4c466c52fa6b3d258b94ab on kurtmckee:test-reader-groups into 62944bc931ddf02bae73f97a15069f3f9493cc63 on LudovicRousseau:master.

LudovicRousseau commented 1 month ago

The low level ReaderGroups PC/SC functions are available only on Windows. On Unix they just return SCARD_E_UNSUPPORTED_FEATURE. See c40ce544d8859211d948704ec33d142184365e6b

What system do you use to run your tests?

kurtmckee commented 1 month ago

I'm currently working on Linux. However, the readergroups tests here are not touching the PCSC reader groups code; they exercise the readergroups class that establishes the API contract that the PCSC reader groups class relies on / overrides.

LudovicRousseau commented 1 month ago

Merged in 0c2c269cc7526ddb9a8fbd4bc5cce0b45c2c5f3e

Thanks

LudovicRousseau commented 1 month ago

pylint reports an error:

pylint test/test_readergroups.py
************* Module test_readergroups
test/test_readergroups.py:57:18: E1135: Value 'reader_group.instance' doesn't support membership test (unsupported-membership-test)
kurtmckee commented 1 month ago

I don't recommend checking the test suite with pylint or mypy -- test suites may exercise invalid types, invalid operations, and other things that those two linters will get upset about unnecessarily.

However, if you want to target the test suite with pylint, that needs to go into tox.ini so it's getting checked consistently, and then I can design around that.

LudovicRousseau commented 1 month ago

Valid point. Ignore my comment.