Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pytest features #192

Closed

Conversation

kurtmckee
Copy link
Contributor

@kurtmckee kurtmckee commented Sep 26, 2024

This PR introduces the following changes:

  • Migrate the test suite to use pytest features
  • Address a duplicated test name in test_Exceptions.py: test_ListReadersException.
    The duplicate tests have been merged.

Most of this work was mechanical:

  • Remove unittest.TestCase subclass definition lines
  • De-dent the class methods
  • Remove references to self in the function parameters
  • Use regular expressions to search and replace assertions:
    • self.assertEqual(x, y) -> assert x == y
    • self.assertRaises -> pytest.raises
    • self.assertFalse(x) -> assert x is False
    • self.assertIn(x, y) -> assert x in y

Some long strings were wrapped to prepare for the possibility of using code formatters in the future.

STDOUT capture code was replaced with the pytest capsys fixture, which simplified the code in test_ATR.py.


This PR prepares for the possibility of consolidating the live tests in src/smartcard/test/ together with the overall test suite, and using pytest features to control whether the live tests run or not.

This is only a possibility, not a guarantee, but migrating from unittest code to pytest code helps pave the way.

This also addresses a duplicated test name in `test_Exceptions.py`:
`test_ListReadersException`. The duplicate tests have been merged.
@coveralls
Copy link

coveralls commented Sep 26, 2024

Coverage Status

coverage: 60.337% (+0.3%) from 60.037%
when pulling a9beece on kurtmckee:migrate-to-pytest
into 1baa8ea on LudovicRousseau:master.

@LudovicRousseau
Copy link
Owner

Have you migrated the code by hand?
Or with an automatic tool?

@kurtmckee
Copy link
Contributor Author

This was done by hand (and with some search and replace) unfortunately.

@LudovicRousseau
Copy link
Owner

Merged in 1e3c419

Thanks

@kurtmckee kurtmckee deleted the migrate-to-pytest branch September 27, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants