Use sys.exit and add some docstrings
Signed-off-by: John Kacur <jkacur(a)redhat.com>
---
bitmasklist_test.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/bitmasklist_test.py b/bitmasklist_test.py
index 2f96e2e82bf4..677c84a9504f 100755
--- a/bitmasklist_test.py
+++ b/bitmasklist_test.py
@@ -1,8 +1,12 @@
#!/usr/bin/python3
+""" Module to test bitmasklist functionality """
+
+import sys
from procfs import bitmasklist
class BitmasklistTest:
+ """ class to run the bitmasklist test """
# Assume true (passed) until proven false
# Many tests can be run, but just one failure is recorded overall here
unit_test_result = 0 # Assume true (passed) until proven false
@@ -15,6 +19,7 @@ class BitmasklistTest:
# A failure in any single test is recorded as an overall failure
def set_unit_test_result(self):
+ """ set unit_test_result to fail if any test fails
"""
if BitmasklistTest.unit_test_result == 1:
return
if self.result == 1:
@@ -23,6 +28,7 @@ class BitmasklistTest:
# This is the function that actually runs the test
def bitmasklist_test(self):
+ """ Run the test """
print("\n##################\n")
cpu = bitmasklist(self.line, self.nr_entries)
print("Converted : ", self.line, "\nto ", cpu)
@@ -65,4 +71,4 @@ t = \
BitmasklistTest("ff,ffffffff,ffffffff", 96, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71])
t.bitmasklist_test()
-exit(BitmasklistTest.unit_test_result)
+sys.exit(BitmasklistTest.unit_test_result)
--
2.37.2