Skip to content

Commit cab92e8

Browse files
committed
Split tests into separate methods
Also, only show test output if they fail.
1 parent 585dbbb commit cab92e8

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

tests/test_comment_spell_check.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ def setUpClass(self):
1212
def tearDownClass(cls):
1313
print("\nTearing down comment_spell_check tests")
1414

15-
def test_comment_spell_check(self):
16-
print("\nCommand_spell_check simple test")
17-
cwd = os.getcwd()
18-
print(cwd)
15+
def test_basic(self):
16+
print("\nCommand_spell_check: Basic Test")
1917
runresult = subprocess.run(
2018
[
2119
"python",
@@ -26,15 +24,16 @@ def test_comment_spell_check(self):
2624
"--prefix",
2725
"myprefix",
2826
"tests/example.h",
29-
]
27+
],
28+
stdout=subprocess.PIPE,
3029
)
31-
print("Return code:", runresult.returncode)
3230
if runresult.returncode:
33-
self.fail("Simple test: comment_spell_check.py process returned bad code")
31+
self.fail("\nBasic Test: FAIL")
32+
output_string = str(runresult.stdout)
33+
print("\nTest output:", output_string)
3434

35-
print("\nComment_spell_check test on itself")
36-
cwd = os.getcwd()
37-
print(cwd)
35+
def test_codebase(self):
36+
print("\nComment_spell_check: Code Base Test")
3837
runresult = subprocess.run(
3938
[
4039
"python",
@@ -47,15 +46,16 @@ def test_comment_spell_check(self):
4746
"--suffix",
4847
".md",
4948
".",
50-
]
49+
],
50+
stdout=subprocess.PIPE,
5151
)
52-
print("Return code:", runresult.returncode)
5352
if runresult.returncode:
54-
self.fail(
55-
"Self code test: comment_spell_check.py process returned bad code"
56-
)
53+
self.fail("\nCode Base Test: FAIL")
54+
output_string = str(runresult.stdout)
55+
print("\nTest output:", output_string)
5756

58-
print("\nTest version")
57+
def test_version(self):
58+
print("\nComment_spell_check: Version Test")
5959
runresult = subprocess.run(
6060
[
6161
"python",
@@ -64,12 +64,8 @@ def test_comment_spell_check(self):
6464
],
6565
stdout=subprocess.PIPE,
6666
)
67-
print("Return code:", runresult.returncode)
68-
print("Version: ", runresult.stdout)
6967
version_string = str(runresult.stdout)
7068
if runresult.returncode:
71-
self.fail(
72-
"Self code test: comment_spell_check.py process returned bad code"
73-
)
69+
self.fail("Version Test: FAIL")
7470
if "unknown" in version_string:
75-
self.fail("Self code test: version string contains 'unknown'")
71+
self.fail("Version Test: version string contains 'unknown'")

0 commit comments

Comments
 (0)