Skip to content

Commit dbbaad3

Browse files
gagernsqla-tester
authored andcommitted
Restore unit tests in classes starting with Test
7e52b60 changed tests from `unittest.TestCase` to pytest collection. But since then only classes *ending* in the word `Test` were considered to be tests; classes *starting* in `Test` were not. This disabled some existing tests, and while renaming these would be a viable way to restore coverage, extending the list of test class names avoids accidentally missing similar classes in the future. The loop test classes make use of the `setUp` method, so in their current form they need to inherit from `unittest` again. Changing to pytest fixtures would be a possible future modification. This commit adds 33 tests that had been missing before: * 25 methods in 4 classes from `test_loop.py` * 2 methods in `TestTemplateAPI` from `test_template.py` * 6 methods in `TestTGPlugin` from `test_tgplugin.py` Closes: #365 Pull-request: #365 Pull-request-sha: 6b5ff13 Change-Id: I744b8c6f28cf485c07cd30a11c328ea7391c7d3b
1 parent 7c5b28a commit dbbaad3

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ tag_build = dev
7575
[tool:pytest]
7676
addopts= --tb native -v -r fxX -p warnings
7777
python_files=test/*test_*.py
78-
python_classes=*Test
78+
python_classes=*Test Test*
7979
filterwarnings =
8080
error::DeprecationWarning:test
8181
error::DeprecationWarning:mako

test/test_loop.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import unittest
23

34
from mako import exceptions
45
from mako.codegen import _FOR_LOOP
@@ -11,7 +12,7 @@
1112
from mako.testing.helpers import flatten_result
1213

1314

14-
class TestLoop:
15+
class TestLoop(unittest.TestCase):
1516
def test__FOR_LOOP(self):
1617
for statement, target_list, expression_list in (
1718
("for x in y:", "x", "y"),
@@ -136,7 +137,7 @@ def test_out_of_context_access(self):
136137
)
137138

138139

139-
class TestLoopStack:
140+
class TestLoopStack(unittest.TestCase):
140141
def setUp(self):
141142
self.stack = LoopStack()
142143
self.bottom = "spam"
@@ -179,7 +180,7 @@ def test_exit(self):
179180
assert before == (after + 1), "Exiting a context pops the stack"
180181

181182

182-
class TestLoopContext:
183+
class TestLoopContext(unittest.TestCase):
183184
def setUp(self):
184185
self.iterable = [1, 2, 3]
185186
self.ctx = LoopContext(self.iterable)

0 commit comments

Comments
 (0)