Page MenuHomePhabricator

[electrum] automate test discovery
ClosedPublic

Authored by PiRK on Jun 26 2023, 10:19.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCe706f55e52e1: [electrum] automate test discovery
Summary

Remove the need to maintain a list of tests in the various __main__.py files by adding a run_tests.py script to the top level and using unittest.defaultTestLoader.discover.

This could alternatively be done by using pytest, tox or nose, but I would rather avoid a third-party dependency if it can be done in 15 lines of code with standard python libraries.

Test Plan

python electrum/run_tests.py

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jun 26 2023, 10:19
Fabien added a subscriber: Fabien.

This could alternatively be done by using pytest, tox or nose, but I would rather avoid a third-party dependency if it can be done in 15 lines of code with standard python libraries.

Macro likestamp:

electrum/README.rst
95 ↗(On Diff #40993)

nit: everywhere else in the repo this is called test_runner.py

This revision is now accepted and ready to land.Jun 26 2023, 15:22

Note that it works when all the dependencies are installed, but gives very unhelpful error messages when some dependencies are missing. I'm trying to find a solution to this

Traceback (most recent call last):

File "/home/pierre/dev/bitcoin-abc/build/../electrum/run_tests.py", line 14, in <module>
  suite.addTests(test_suite)
File "/home/pierre/.pyenv/versions/3.11.4/lib/python3.11/unittest/suite.py", line 57, in addTests
  for test in tests:

TypeError: '_FailedTest' object is not iterable

This revision was automatically updated to reflect the committed changes.