Skip to content

Commit 9b22b8b

Browse files
committed
Make the tests more pythonic
1 parent 20ac538 commit 9b22b8b

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

tests/test_comment_spell_check.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
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",
@@ -26,13 +26,12 @@ 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(
30+
runresult.returncode, 0, "Basic test FAIL: " + str(runresult.stdout)
31+
)
3332

3433
def test_codebase(self):
35-
print("\nComment_spell_check: Code Base Test")
34+
"""Code base test"""
3635
runresult = subprocess.run(
3736
[
3837
"python",
@@ -48,13 +47,12 @@ def test_codebase(self):
4847
],
4948
stdout=subprocess.PIPE,
5049
)
51-
if runresult.returncode:
52-
self.fail("\nCode Base Test: FAIL")
53-
output_string = str(runresult.stdout)
54-
print("\nTest output:", output_string)
50+
self.assertEqual(
51+
runresult.returncode, 0, "Code test FAIL: " + str(runresult.stdout)
52+
)
5553

5654
def test_version(self):
57-
print("\nComment_spell_check: Version Test")
55+
"""Version test"""
5856
runresult = subprocess.run(
5957
[
6058
"python",
@@ -63,8 +61,9 @@ def test_version(self):
6361
],
6462
stdout=subprocess.PIPE,
6563
)
64+
self.assertEqual(runresult.returncode, 0, "Version test FAIL")
65+
6666
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'")
67+
self.assertNotEqual(
68+
version_string, "unknown", "version string contains 'unknown'"
69+
)

0 commit comments

Comments
 (0)