def test_check_str(self): types = [None, True, 1, "", "string", [], (), {}] # pass: string for element in [t for t in types if isinstance(t, str)]: self.assertIsNone(PXML.check_str(element)) # fail: non-string for element in [t for t in types if not isinstance(t, str)]: with self.assertRaises(TypeError): PXML.check_str(element)