Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the tests more pythonic #52

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions tests/test_comment_spell_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
class TestCommentSpellCheck(unittest.TestCase):
@classmethod
def setUpClass(self):
print("\nSetting up comment_spell_check tests")
"""Setting up comment_spell_check tests"""

@classmethod
def tearDownClass(cls):
print("\nTearing down comment_spell_check tests")
"""Tearing down comment_spell_check tests"""

def test_basic(self):
print("\nCommand_spell_check: Basic Test")
"""Basic test"""
runresult = subprocess.run(
[
"python",
"comment_spell_check.py",
"--verbose",
"--miss",
"--dict",
"tests/dict.txt",
"--prefix",
Expand All @@ -26,18 +26,15 @@ def test_basic(self):
],
stdout=subprocess.PIPE,
)
if runresult.returncode:
self.fail("\nBasic Test: FAIL")
output_string = str(runresult.stdout)
print("\nTest output:", output_string)
self.assertEqual(runresult.returncode, 0, runresult.stdout)

def test_codebase(self):
print("\nComment_spell_check: Code Base Test")
"""Code base test"""
runresult = subprocess.run(
[
"python",
"comment_spell_check.py",
"--verbose",
"--miss",
"--prefix",
"myprefix",
"--suffix",
Expand All @@ -48,13 +45,10 @@ def test_codebase(self):
],
stdout=subprocess.PIPE,
)
if runresult.returncode:
self.fail("\nCode Base Test: FAIL")
output_string = str(runresult.stdout)
print("\nTest output:", output_string)
self.assertEqual(runresult.returncode, 0, runresult.stdout)

def test_version(self):
print("\nComment_spell_check: Version Test")
"""Version test"""
runresult = subprocess.run(
[
"python",
Expand All @@ -63,8 +57,9 @@ def test_version(self):
],
stdout=subprocess.PIPE,
)
self.assertEqual(runresult.returncode, 0)

version_string = str(runresult.stdout)
if runresult.returncode:
self.fail("Version Test: FAIL")
if "unknown" in version_string:
self.fail("Version Test: version string contains 'unknown'")
self.assertNotEqual(
version_string, "unknown", "version string contains 'unknown'"
)