Electrum: How to run unittests

Created on 26 Aug 2020  路  3Comments  路  Source: spesmilo/electrum

How do I run the test suites? I have a working copy of (github source code of) Electrum and would like to run the tests. It would be good to have documentation how this is done.

All 3 comments

I agree, some contribution guidelines would be great. I'll try to collect my notes somewhere.
You should be able to run the bulk of the tests by something like:

git clone https://github.com/spesmilo/electrum
cd electrum
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -e .
python3 -m pip install pycryptodomex
sudo apt install libsecp256k1-0
python3 -m unittest discover

There may be some tests with other dependencies that fail.

You can also find more about testing in https://github.com/spesmilo/electrum/blob/master/.travis.yml .

You can do this if it's a unit test.

~/electrum$ pytest electrum/tests -v
============================================================================= test session starts =============================================================================
platform linux -- Python 3.6.9, pytest-4.6.3, py-1.8.0, pluggy-0.12.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/wakiyamap/electrum
collected 491 items                                                                                                                                                           

electrum/tests/test_bitcoin.py::Test_bitcoin::test_add_number_to_script PASSED                                                                                          [  0%]
electrum/tests/test_bitcoin.py::Test_bitcoin::test_address_to_script PASSED                                                                                             [  0%]
.........

and......

~/electrum$ pytest electrum/tests/test_bitcoin.py::Test_bitcoin::test_add_number_to_script
============================================================================= test session starts =============================================================================
platform linux -- Python 3.6.9, pytest-4.6.3, py-1.8.0, pluggy-0.12.0
rootdir: /home/wakiyamap/electrum
collected 1 item                                                                                                                                                              

electrum/tests/test_bitcoin.py .                                                                                                                                        [100%]

========================================================================== 1 passed in 0.57 seconds ===========================================================================

For myself when running the test, I get a failure about KIVY. It does tell me where I can go download it but you might want to add that to the instructions for running unit-tests anyway.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juniorjp picture juniorjp  路  5Comments

dl3br picture dl3br  路  4Comments

Moredread picture Moredread  路  3Comments

GuestInCorle picture GuestInCorle  路  3Comments

LightSunChen picture LightSunChen  路  4Comments