feature_framework_unit_tests.py raw
1 #!/usr/bin/env python3
2 # Copyright (c) 2017-present The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Framework unit tests
6
7 Unit tests for the test framework.
8 """
9
10 import sys
11 import unittest
12
13 from test_framework.test_framework import TEST_EXIT_PASSED, TEST_EXIT_FAILED
14
15 # List of framework modules containing unit tests. Should be kept in sync with
16 # the output of `git grep unittest.TestCase ./test/functional/test_framework`
17 TEST_FRAMEWORK_MODULES = [
18 "address",
19 "crypto.bip324_cipher",
20 "blocktools",
21 "compressor",
22 "crypto.chacha20",
23 "crypto.ellswift",
24 "extendedkey",
25 "key",
26 "messages",
27 "crypto.muhash",
28 "crypto.poly1305",
29 "crypto.ripemd160",
30 "crypto.secp256k1",
31 "script",
32 "script_util",
33 "segwit_addr",
34 "wallet_util",
35 ]
36
37
38 def run_unit_tests():
39 test_framework_tests = unittest.TestSuite()
40 for module in TEST_FRAMEWORK_MODULES:
41 test_framework_tests.addTest(
42 unittest.TestLoader().loadTestsFromName(f"test_framework.{module}")
43 )
44 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=1, failfast=True).run(
45 test_framework_tests
46 )
47 if not result.wasSuccessful():
48 sys.exit(TEST_EXIT_FAILED)
49 sys.exit(TEST_EXIT_PASSED)
50
51
52 if __name__ == "__main__":
53 run_unit_tests()
54
55