From 6a55a0b262ce62ca3534d906cef42f60c88fbebe Mon Sep 17 00:00:00 2001 From: Juhani Numminen Date: Sun, 7 Feb 2021 13:32:15 +0200 Subject: [PATCH] Move tests so that standard library unittest discovery finds them --- Makefile | 3 +-- run-tests.pl | 4 +++- scripts/gen_individual_importing_tests.py | 24 ------------------- tests/{lib/pysol_tests => }/__init__.py | 0 tests/tap_unittests.py | 7 ++++++ .../PLACEHOLDER => unit/__init__.py} | 0 .../pysol_tests => unit}/common_mocks1.py | 0 .../acard_unit.py => unit/test_acard.py} | 0 .../test_cardsetparser.py} | 0 .../game_drag.py => unit/test_game_drag.py} | 0 .../pysol_tests/hint.py => unit/test_hint.py} | 0 .../test_import_file1.py} | 4 ++-- .../test_latin1_conv.py} | 0 .../__init__.py => unit/test_ms_deals1.py} | 0 .../test_scorpion_canMove.py} | 4 ++-- 15 files changed, 15 insertions(+), 31 deletions(-) rename tests/{lib/pysol_tests => }/__init__.py (100%) create mode 100755 tests/tap_unittests.py rename tests/{unit-generated/PLACEHOLDER => unit/__init__.py} (100%) rename tests/{lib/pysol_tests => unit}/common_mocks1.py (100%) rename tests/{lib/pysol_tests/acard_unit.py => unit/test_acard.py} (100%) rename tests/{lib/pysol_tests/cardsetparser.py => unit/test_cardsetparser.py} (100%) rename tests/{lib/pysol_tests/game_drag.py => unit/test_game_drag.py} (100%) rename tests/{lib/pysol_tests/hint.py => unit/test_hint.py} (100%) rename tests/{lib/pysol_tests/import_file1.py => unit/test_import_file1.py} (98%) rename tests/{lib/pysol_tests/latin1_conv_unit.py => unit/test_latin1_conv.py} (100%) rename tests/{lib/pysol_tests/ms_deals1/__init__.py => unit/test_ms_deals1.py} (100%) rename tests/{lib/pysol_tests/scorpion_canMove.py => unit/test_scorpion_canMove.py} (97%) diff --git a/Makefile b/Makefile index de80d415..e22e4c38 100644 --- a/Makefile +++ b/Makefile @@ -61,9 +61,8 @@ pretest: python3 scripts/gen_individual_importing_tests.py TEST_ENV_PATH = $(CURDIR)$(path_sep)$(CURDIR)/tests/lib -TEST_FILES = tests/style/*.t tests/unit-generated/*.py tests/individually-importing/*.py +TEST_FILES = tests/tap_unittests.py tests/style/*.t tests/individually-importing/*.py -test runtest: export PYTHONPATH := $(PYTHONPATH)$(path_sep)$(TEST_ENV_PATH) test runtest: export PERL5LIB := $(PERL5LIB)$(path_sep)$(TEST_ENV_PATH) test: pretest diff --git a/run-tests.pl b/run-tests.pl index ed996aef..74ac005c 100644 --- a/run-tests.pl +++ b/run-tests.pl @@ -156,7 +156,9 @@ sub myglob my @tests = sort { ( basename($a) cmp basename($b) ) || ( $a cmp $b ) } - ( myglob("$abs_bindir/tests/*") ); + ( myglob("$abs_bindir/tests/{style,individually-importing}") ); + + push @tests, "$abs_bindir/tests/tap_unittests.py"; if ($IS_WIN) { diff --git a/scripts/gen_individual_importing_tests.py b/scripts/gen_individual_importing_tests.py index a4d529ba..35bbeccf 100644 --- a/scripts/gen_individual_importing_tests.py +++ b/scripts/gen_individual_importing_tests.py @@ -40,27 +40,3 @@ sys.path.insert(0, ".") import %(module_name)s print('ok 1 - imported') ''')) - -for ver in PY_VERS: - for mod in [ - 'pysol_tests.acard_unit', - 'pysol_tests.cardsetparser', - 'pysol_tests.game_drag', - 'pysol_tests.hint', - 'pysol_tests.import_file1', - 'pysol_tests.latin1_conv_unit', - 'pysol_tests.ms_deals1', - 'pysol_tests.scorpion_canMove', - ]: - open(os.path.join(".", "tests", "unit-generated", - 'test__%s__v%d.py' % (mod, ver) - ), 'w').write('''#!/usr/bin/env python%(ver)d -import unittest - -from pycotap import TAPTestRunner - -from %(mod)s import MyTests - -suite = unittest.TestLoader().loadTestsFromTestCase(MyTests) -TAPTestRunner().run(suite) -''' % {'mod': mod, 'ver': ver}) diff --git a/tests/lib/pysol_tests/__init__.py b/tests/__init__.py similarity index 100% rename from tests/lib/pysol_tests/__init__.py rename to tests/__init__.py diff --git a/tests/tap_unittests.py b/tests/tap_unittests.py new file mode 100755 index 00000000..c3fef09d --- /dev/null +++ b/tests/tap_unittests.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +import unittest + +from pycotap import LogMode, TAPTestRunner + +suite = unittest.TestLoader().discover('.') +TAPTestRunner(LogMode.LogToError).run(suite) diff --git a/tests/unit-generated/PLACEHOLDER b/tests/unit/__init__.py similarity index 100% rename from tests/unit-generated/PLACEHOLDER rename to tests/unit/__init__.py diff --git a/tests/lib/pysol_tests/common_mocks1.py b/tests/unit/common_mocks1.py similarity index 100% rename from tests/lib/pysol_tests/common_mocks1.py rename to tests/unit/common_mocks1.py diff --git a/tests/lib/pysol_tests/acard_unit.py b/tests/unit/test_acard.py similarity index 100% rename from tests/lib/pysol_tests/acard_unit.py rename to tests/unit/test_acard.py diff --git a/tests/lib/pysol_tests/cardsetparser.py b/tests/unit/test_cardsetparser.py similarity index 100% rename from tests/lib/pysol_tests/cardsetparser.py rename to tests/unit/test_cardsetparser.py diff --git a/tests/lib/pysol_tests/game_drag.py b/tests/unit/test_game_drag.py similarity index 100% rename from tests/lib/pysol_tests/game_drag.py rename to tests/unit/test_game_drag.py diff --git a/tests/lib/pysol_tests/hint.py b/tests/unit/test_hint.py similarity index 100% rename from tests/lib/pysol_tests/hint.py rename to tests/unit/test_hint.py diff --git a/tests/lib/pysol_tests/import_file1.py b/tests/unit/test_import_file1.py similarity index 98% rename from tests/lib/pysol_tests/import_file1.py rename to tests/unit/test_import_file1.py index 48c3b51d..24d2c3de 100644 --- a/tests/lib/pysol_tests/import_file1.py +++ b/tests/unit/test_import_file1.py @@ -2,11 +2,11 @@ import unittest -from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockTalon - import pysollib.stack from pysollib.hint import FreeCellSolver_Hint, PySolHintLayoutImportError +from .common_mocks1 import MockApp, MockCanvas, MockTalon + class MockGame: def __init__(self): diff --git a/tests/lib/pysol_tests/latin1_conv_unit.py b/tests/unit/test_latin1_conv.py similarity index 100% rename from tests/lib/pysol_tests/latin1_conv_unit.py rename to tests/unit/test_latin1_conv.py diff --git a/tests/lib/pysol_tests/ms_deals1/__init__.py b/tests/unit/test_ms_deals1.py similarity index 100% rename from tests/lib/pysol_tests/ms_deals1/__init__.py rename to tests/unit/test_ms_deals1.py diff --git a/tests/lib/pysol_tests/scorpion_canMove.py b/tests/unit/test_scorpion_canMove.py similarity index 97% rename from tests/lib/pysol_tests/scorpion_canMove.py rename to tests/unit/test_scorpion_canMove.py index f31ab4c7..9a2233b4 100644 --- a/tests/lib/pysol_tests/scorpion_canMove.py +++ b/tests/unit/test_scorpion_canMove.py @@ -2,14 +2,14 @@ import unittest -from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockItem, MockTalon - import pysollib.stack from pysollib.acard import AbstractCard from pysollib.games.spider import ScorpionTail_RowStack from pysollib.games.spider import Scorpion_RowStack from pysollib.games.spider import Spider_RowStack +from .common_mocks1 import MockApp, MockCanvas, MockItem, MockTalon + class MockGame: def __init__(self):