Esempio n. 1
0
 def test_has_len_works_with_empty_lists(self):
     assert_that(list(), has_len(0))
Esempio n. 2
0
 def test_has_len_works_with_generators(self):
     assert_that((i for i in [1, 2, 3]), has_len(3))
Esempio n. 3
0
 def test_has_len_works_with_iterables(self):
     assert_that(iter([1, 2, 3]), has_len(3))
Esempio n. 4
0
 def test_has_len_works_with_dicts(self):
     assert_that({1: 1, 2: 2, 3: 3}, has_len(3))
Esempio n. 5
0
    def test_has_len_works_with_any_enumerable_object(self):
        class Collection(object):
            def __len__(self):
                return 3

        assert_that(Collection(), has_len(3))
Esempio n. 6
0
 def test_has_len_works_with_sets(self):
     assert_that(set([1, 2, 3]), has_len(3))
Esempio n. 7
0
 def test_has_len_works_with_tuples(self):
     assert_that((1, 2, 3), has_len(3))
Esempio n. 8
0
 def test_has_len_works_with_lists(self):
     assert_that([1, 2, 3], has_len(3))
Esempio n. 9
0
 def test_has_len_works_with_empty_iterables(self):
     assert_that(iter([]), has_len(0))
Esempio n. 10
0
 def test_has_len_works_with_empty_generators(self):
     assert_that((i for i in []), has_len(0))
Esempio n. 11
0
 def test_has_len_works_with_empty_dicts(self):
     assert_that(dict(), has_len(0))
Esempio n. 12
0
 def test_has_len_works_with_empty_tuples(self):
     assert_that(tuple(), has_len(0))