Author: dsommers
Date: 2010-05-20 09:45:46 +0000 (Thu, 20 May 2010)
New Revision: 510
Modified:
trunk/tests/info/info.py
trunk/v7/command.py
trunk/v7/hal.py
trunk/v7/redhatrelease.py
Log:
Added unit-test features to a few modules
Signed-off-by: David Sommerseth <davids(a)redhat.com>
Modified: trunk/tests/info/info.py
===================================================================
--- trunk/tests/info/info.py 2010-05-20 09:45:36 UTC (rev 509)
+++ trunk/tests/info/info.py 2010-05-20 09:45:46 UTC (rev 510)
@@ -374,10 +374,12 @@
return 1
+def unit_test():
+ test = InfoTest()
+ return test.do(sys.argv)
+
if __name__ == "__main__":
- test = InfoTest()
- returnValue = test.do(sys.argv)
- sys.exit(returnValue)
+ sys.exit(unit_test())
Modified: trunk/v7/command.py
===================================================================
--- trunk/v7/command.py 2010-05-20 09:45:36 UTC (rev 509)
+++ trunk/v7/command.py 2010-05-20 09:45:46 UTC (rev 510)
@@ -245,8 +245,7 @@
-if __name__ == "__main__":
-
+def unit_test():
try:
# positive test: run
command = Command("ls -a")
@@ -309,4 +308,5 @@
except V7CommandException, e:
print e
-
+if __name__ == "__main__":
+ unit_test()
Modified: trunk/v7/hal.py
===================================================================
--- trunk/v7/hal.py 2010-05-20 09:45:36 UTC (rev 509)
+++ trunk/v7/hal.py 2010-05-20 09:45:46 UTC (rev 510)
@@ -10,6 +10,7 @@
import dbus
import re
import string
+import sys
from v7.device import HalDevice
from v7.deviceDetector import DeviceDetector
@@ -112,6 +113,14 @@
return device.getProperty('info.product')
+def unit_test():
+ try:
+ h=Hal()
+ print h.dumpall()
+ return 0
+ except Exception, e:
+ print str(e)
+ return 1
+
if __name__ == "__main__":
- h=Hal()
- print h.dumpall()
+ sys.exit(unit_test())
Modified: trunk/v7/redhatrelease.py
===================================================================
--- trunk/v7/redhatrelease.py 2010-05-20 09:45:36 UTC (rev 509)
+++ trunk/v7/redhatrelease.py 2010-05-20 09:45:46 UTC (rev 510)
@@ -178,7 +178,7 @@
if not self.isValid():
print "Not Valid"
-if __name__ == "__main__":
+def unit_test():
PASSED = 0
FAILED = 1
result = PASSED
@@ -236,9 +236,9 @@
print "FAILED"
else:
print "PASSED"
- exit(result)
-
+ return result
-
-
-
\ No newline at end of file
+
+if __name__ == "__main__":
+ exit(unit_test())
+
Show replies by date