diff options
author | mathieui <mathieui@mathieui.net> | 2020-12-05 17:37:50 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-12-05 17:37:50 +0100 |
commit | 73cc2a40082cf936221adb09cfe208bd06cd4b60 (patch) | |
tree | b6460caabba875c04bb5f680aa29954037b8ba09 /run_integration_tests.py | |
parent | aa5d422f38889edf2131d840ca50e3fb8a603420 (diff) | |
parent | 77587a48432901b5a43441f3e41fe26c02aeb8ed (diff) | |
download | slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.tar.gz slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.tar.bz2 slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.tar.xz slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.zip |
Merge branch 'first-integration-tests' into 'master'
First integration tests
See merge request poezio/slixmpp!75
Diffstat (limited to 'run_integration_tests.py')
-rwxr-xr-x | run_integration_tests.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/run_integration_tests.py b/run_integration_tests.py new file mode 100755 index 00000000..9f670b5c --- /dev/null +++ b/run_integration_tests.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 + +import sys +import logging +import unittest + +from argparse import ArgumentParser +from distutils.core import Command +from importlib import import_module +from pathlib import Path + + +def run_tests(filenames=None): + """ + Find and run all tests in the tests/ directory. + + Excludes live tests (tests/live_*). + """ + if sys.version_info < (3, 8): + raise ValueError('Your python version is too old to run these tests') + if not filenames: + filenames = [i for i in Path('itests').glob('test_*')] + else: + filenames = [Path(i) for i in filenames] + + modules = ['.'.join(test.parts[:-1] + (test.stem,)) for test in filenames] + + suites = [] + for filename in modules: + module = import_module(filename) + suites.append(module.suite) + + tests = unittest.TestSuite(suites) + runner = unittest.TextTestRunner(verbosity=2) + + # Disable logging output + logging.basicConfig(level=100) + logging.disable(100) + + result = runner.run(tests) + return result + + +# Add a 'test' command for setup.py + +class TestCommand(Command): + + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + run_tests() + + +if __name__ == '__main__': + parser = ArgumentParser(description='Run unit tests.') + parser.add_argument('tests', metavar='TEST', nargs='*', help='list of tests to run, or nothing to run them all') + args = parser.parse_args() + + result = run_tests(args.tests) + print("<tests %s ran='%s' errors='%s' fails='%s' success='%s'/>" % ( + "xmlns='http//andyet.net/protocol/tests'", + result.testsRun, len(result.errors), + len(result.failures), result.wasSuccessful())) + + sys.exit(not result.wasSuccessful()) |