I have a test case like so:
class TokenGeneratorTestCase(unittest.TestCase):
def test_genToken(self):
"""
Test if genToken returns a UUID, if not, then -1
"""
tg = TokenGenerator()
result = tg.genToken()
self.assertIn(type(result), [ uuid.UUID, int ])
if type(result) == int:
self.assertEqual(result, -1)
I want to test if genToken() returns either a uuid.UUID or -1. Is it possible to do it with a single assert* ?
PS: I am new to both Python and Unit Testing, so forgive my ignorance :)
getToken()works completely randomly? Or generated value depends on some condition?