1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Run unittests via a single TAP test

Enable standard unittest discovery by creating __init__.py files
and renaming test modules to test*.py.
This commit is contained in:
Juhani Numminen 2021-02-11 13:49:28 +02:00
parent 1de339fca9
commit 076ee8d11a
16 changed files with 27 additions and 43 deletions

View file

@ -22,11 +22,13 @@ include scripts/create_iss.py scripts/mahjongg_utils.py
include scripts/all_games.py scripts/cardset_viewer.py include scripts/all_games.py scripts/cardset_viewer.py
include scripts/cardconv include scripts/cardconv
include scripts/gen_individual_importing_tests.py include scripts/gen_individual_importing_tests.py
recursive-include tests/ *.pm *.py *.t *.yml
exclude tests/individually-importing/*
include tests/individually-importing/PLACEHOLDER include tests/individually-importing/PLACEHOLDER
recursive-include tests/lib *.pm *.py
recursive-include tests/unit/data * recursive-include tests/unit/data *
include tests/style/*.t
include tests/unit-generated/PLACEHOLDER
include .tidyallrc include .tidyallrc
include android/*.py include android/*.py
include android/mk* include android/mk*

View file

@ -61,9 +61,8 @@ pretest:
python3 scripts/gen_individual_importing_tests.py python3 scripts/gen_individual_importing_tests.py
TEST_ENV_PATH = $(CURDIR)$(path_sep)$(CURDIR)/tests/lib 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/style/*.t tests/t/*.py 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 runtest: export PERL5LIB := $(PERL5LIB)$(path_sep)$(TEST_ENV_PATH)
test: pretest test: pretest

View file

@ -63,8 +63,8 @@ sub run_tests
} }
} }
my $tests_glob = "*.{t.exe,py,t}"; my $tests_glob = "*.{t.exe,py,t}";
my $exclude_re_s; my $exclude_re_s = "__init__";
my @execute; my @execute;
GetOptions( GetOptions(

View file

@ -40,27 +40,3 @@ sys.path.insert(0, ".")
import %(module_name)s import %(module_name)s
print('ok 1 - imported') 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})

0
tests/lib/__init__.py Normal file
View file

View file

@ -5,7 +5,7 @@ import unittest
from pysollib.acard import AbstractCard from pysollib.acard import AbstractCard
class MyTests(unittest.TestCase): class AbstractCardTests(unittest.TestCase):
def test_cards(self): def test_cards(self):
card1 = AbstractCard(1001, 0, 1, 2, 3001) card1 = AbstractCard(1001, 0, 1, 2, 3001)
# TEST # TEST

View file

@ -6,7 +6,7 @@ from pysollib.cardsetparser import parse_cardset_config
from pysollib.resource import CSI, CardsetConfig from pysollib.resource import CSI, CardsetConfig
class MyTests(unittest.TestCase): class CardsetParserTests(unittest.TestCase):
def _assertCcEqual(self, a, b, msg=None): def _assertCcEqual(self, a, b, msg=None):
"""Assert that CardsetConfig objects a and b have equal attributes.""" """Assert that CardsetConfig objects a and b have equal attributes."""

View file

@ -5,7 +5,7 @@ import unittest
from pysollib.game import GameDrag, GameStacks from pysollib.game import GameDrag, GameStacks
class MyTests(unittest.TestCase): class GameDragTests(unittest.TestCase):
def test_shadows(self): def test_shadows(self):
d = GameDrag() d = GameDrag()
d.shadows.append("test") d.shadows.append("test")

View file

@ -6,7 +6,7 @@ from pysollib.acard import AbstractCard
from pysollib.hint import Base_Solver_Hint from pysollib.hint import Base_Solver_Hint
class MyTests(unittest.TestCase): class HintTests(unittest.TestCase):
def test_output(self): def test_output(self):
card = AbstractCard(1001, 0, 3, 7, 3001) card = AbstractCard(1001, 0, 3, 7, 3001)
h = Base_Solver_Hint(None, None, base_rank=0) h = Base_Solver_Hint(None, None, base_rank=0)

View file

@ -2,11 +2,11 @@
import unittest import unittest
from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockTalon
import pysollib.stack import pysollib.stack
from pysollib.hint import FreeCellSolver_Hint, PySolHintLayoutImportError from pysollib.hint import FreeCellSolver_Hint, PySolHintLayoutImportError
from .common_mocks import MockApp, MockCanvas, MockTalon
class MockGame: class MockGame:
def __init__(self): def __init__(self):
@ -38,7 +38,7 @@ class Mock_S_Game: # noqa: N801
pass pass
class MyTests(unittest.TestCase): class ImportFileTests(unittest.TestCase):
def _calc_hint(self, fn): def _calc_hint(self, fn):
"""docstring for _calc_hint""" """docstring for _calc_hint"""
s_game = Mock_S_Game() s_game = Mock_S_Game()

View file

@ -5,6 +5,6 @@ import unittest
from pysollib.mfxutil import latin1_normalize from pysollib.mfxutil import latin1_normalize
class MyTests(unittest.TestCase): class Latin1Tests(unittest.TestCase):
def test_output(self): def test_output(self):
self.assertEqual(latin1_normalize('HELLO%%good'), 'hellogood') self.assertEqual(latin1_normalize('HELLO%%good'), 'hellogood')

View file

@ -73,7 +73,7 @@ from pysollib.pysolrandom import construct_random
ren = CardRenderer(True) ren = CardRenderer(True)
class MyTests(unittest.TestCase): class MsDealsTests(unittest.TestCase):
def _cmp_board(self, got_s, expected_s, blurb): def _cmp_board(self, got_s, expected_s, blurb):
if not self.assertEqual(got_s, expected_s, blurb): if not self.assertEqual(got_s, expected_s, blurb):
return False return False

View file

@ -2,14 +2,14 @@
import unittest import unittest
from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockItem, MockTalon
import pysollib.stack import pysollib.stack
from pysollib.acard import AbstractCard from pysollib.acard import AbstractCard
from pysollib.games.spider import ScorpionTail_RowStack from pysollib.games.spider import ScorpionTail_RowStack
from pysollib.games.spider import Scorpion_RowStack from pysollib.games.spider import Scorpion_RowStack
from pysollib.games.spider import Spider_RowStack from pysollib.games.spider import Spider_RowStack
from .common_mocks import MockApp, MockCanvas, MockItem, MockTalon
class MockGame: class MockGame:
def __init__(self): def __init__(self):
@ -42,7 +42,7 @@ class Mock_S_Game: # noqa: N801
pass pass
class MyTests(unittest.TestCase): class ScorpionTests(unittest.TestCase):
def _calc_scorpion_stack(self, is_scorpion_tail): def _calc_scorpion_stack(self, is_scorpion_tail):
g = MockGame() g = MockGame()
stack = (ScorpionTail_RowStack stack = (ScorpionTail_RowStack

7
tests/t/tap_unittests.py Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env python3
import unittest
from pycotap import LogMode, TAPTestRunner
suite = unittest.TestLoader().discover('.')
TAPTestRunner(LogMode.LogToError).run(suite)