Пример #1
0
 def test_strings_should_not_be_considered_a_collection(self):
     instance = create_instance(Collection(type=str, container=tuple))
     with self.assertRaises(TypeError):
         instance.attr = b'123'
Пример #2
0
 def test_collection_with_string(self):
     instance = create_instance(Collection(type=int, container=frozenset))
     with self.assertRaises(TypeError):
         instance.attr = '123'
Пример #3
0
 def test_collection_with_wrong_type(self):
     instance = create_instance(Collection(type=int, container=frozenset))
     with self.assertRaises(TypeError):
         instance.attr = [1, '2', 3]
Пример #4
0
 def test_collection_gets_stored_in_container(self):
     instance = create_instance(Collection(type=int, container=frozenset))
     instance.attr = [1, 2, 3]
     self.assertEqual(frozenset([1, 2, 3]), instance.attr)
Пример #5
0
 def test_empty_collection(self):
     instance = create_instance(Collection(type=int, container=frozenset))
     instance.attr = []
     self.assertEqual(frozenset(), instance.attr)
Пример #6
0
 def test_container_instance_is_default(self):
     instance = create_instance(Collection(type=int, container=frozenset))
     self.assertEqual(frozenset(), instance.attr)