Skip to content

Commit c1609e7

Browse files
authored
Merge pull request #52 from dave3d/MakeTestsPythonic
Make the tests more pythonic
2 parents 20ac538 + 80311c3 commit c1609e7

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

tests/test_comment_spell_check.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
class TestCommentSpellCheck(unittest.TestCase):
66
@classmethod
77
def setUpClass(self):
8-
print("\nSetting up comment_spell_check tests")
8+
"""Setting up comment_spell_check tests"""
99

1010
@classmethod
1111
def tearDownClass(cls):
12-
print("\nTearing down comment_spell_check tests")
12+
"""Tearing down comment_spell_check tests"""
1313

1414
def test_basic(self):
15-
print("\nCommand_spell_check: Basic Test")
15+
"""Basic test"""
1616
runresult = subprocess.run(
1717
[
1818
"python",
1919
"comment_spell_check.py",
20-
"--verbose",
20+
"--miss",
2121
"--dict",
2222
"tests/dict.txt",
2323
"--prefix",
@@ -26,18 +26,15 @@ def test_basic(self):
2626
],
2727
stdout=subprocess.PIPE,
2828
)
29-
if runresult.returncode:
30-
self.fail("\nBasic Test: FAIL")
31-
output_string = str(runresult.stdout)
32-
print("\nTest output:", output_string)
29+
self.assertEqual(runresult.returncode, 0, runresult.stdout)
3330

3431
def test_codebase(self):
35-
print("\nComment_spell_check: Code Base Test")
32+
"""Code base test"""
3633
runresult = subprocess.run(
3734
[
3835
"python",
3936
"comment_spell_check.py",
40-
"--verbose",
37+
"--miss",
4138
"--prefix",
4239
"myprefix",
4340
"--suffix",
@@ -48,13 +45,10 @@ def test_codebase(self):
4845
],
4946
stdout=subprocess.PIPE,
5047
)
51-
if runresult.returncode:
52-
self.fail("\nCode Base Test: FAIL")
53-
output_string = str(runresult.stdout)
54-
print("\nTest output:", output_string)
48+
self.assertEqual(runresult.returncode, 0, runresult.stdout)
5549

5650
def test_version(self):
57-
print("\nComment_spell_check: Version Test")
51+
"""Version test"""
5852
runresult = subprocess.run(
5953
[
6054
"python",
@@ -63,8 +57,9 @@ def test_version(self):
6357
],
6458
stdout=subprocess.PIPE,
6559
)
60+
self.assertEqual(runresult.returncode, 0)
61+
6662
version_string = str(runresult.stdout)
67-
if runresult.returncode:
68-
self.fail("Version Test: FAIL")
69-
if "unknown" in version_string:
70-
self.fail("Version Test: version string contains 'unknown'")
63+
self.assertNotEqual(
64+
version_string, "unknown", "version string contains 'unknown'"
65+
)

0 commit comments

Comments
 (0)