This works:
import unittest
class TestupSomeStuff(unittest.TestCase):
def setUp(self):
pass
def test_fail(self):
x = 2 * 4
self.assertEqual(x,9,"DID NOT MATCH")
print "Passed"
def test_pass(self):
x = 2 * 4
self.assertEqual(x,8,"DID NOT MATCH")
print "Passed"
if __name__ == "__main__":
unittest.main()
This is because if your assert fails then the test is a fail and you go to the next test, however when the test is a success it carries on and returns None!
For example:
import unittest
class TestupSomeStuff(unittest.TestCase):
def setUp(self):
pass
def test_fail(self):
return None
# This is skipped, so test is win
x = 2 * 4
self.assertEqual(x,9,"DID NOT MATCH")
print "FAIL"
def test_pass(self):
x = 2 * 4
self.assertEqual(x,8,"DID NOT MATCH")
# Passed gets printed after the dot for passing the previous test.
print "Passed"
Prints:
.Passed
.
----------------------------------------------------------------------
Ran 2 tests in 0.000s
Hope this helps.