def test_dictable_namedtuple_plus_invalid(self): """(dictable_namedtuples) Test :func:`.is_namedtuple` returns ``False`` when some arguments are NOT namedtuple's""" john, dave, aaron = self.dict_persons self.assertTrue(is_namedtuple(john)) self.assertFalse(is_namedtuple(john, ['hello', 'world'])) self.assertFalse(is_namedtuple(dave, dict(hello='world'))) self.assertFalse(is_namedtuple(dave, aaron, 12345))
def test_not_namedtuple_class(self): """Test that classes and instances of classes are not namedtuple's""" class ExampleClass: pass self.assertFalse(is_namedtuple(ExampleClass)) self.assertFalse(is_namedtuple(ExampleClass()))
def test_dictable_namedtuple(self): """Test :func:`.is_namedtuple` returns ``True`` when all arguments are valid dictable_namedtuple's""" john, dave, aaron = self.dict_persons self.assertTrue(is_namedtuple(john)) self.assertTrue(is_namedtuple(dave)) self.assertTrue(is_namedtuple(aaron)) self.assertTrue(is_namedtuple(john, dave, aaron))
def test_dictable_plus_normal_namedtuple(self): """Test :func:`.is_namedtuple` returns ``True`` when arguments are a mix of namedtuple + dictable_namedtuple's""" john, dave, aaron = self.named_persons d_john, d_dave, d_aaron = self.dict_persons self.assertTrue(is_namedtuple(john, d_dave)) self.assertTrue(is_namedtuple(d_john, aaron)) self.assertTrue( is_namedtuple(john, d_john, d_dave, dave, aaron, d_aaron))
def test_not_namedtuple_float(self): """Test that float's are not namedtuple's""" self.assertFalse(is_namedtuple(12.3))
def test_not_namedtuple_int(self): """Test that int's are not namedtuple's""" self.assertFalse(is_namedtuple(123))
def test_not_namedtuple_tuple(self): """Test that tuple's are not namedtuple's""" self.assertFalse(is_namedtuple(( 'hello', 'world', )))
def test_not_namedtuple_list(self): """Test that list's are not namedtuple's""" self.assertFalse(is_namedtuple(['hello', 'world']))
def test_not_namedtuple_dict(self): """Test that dictionaries are not namedtuple's""" self.assertFalse(is_namedtuple(dict(hello='world')))