예제 #1
0
 def test__add__tags(self):
     tags1 = Tags(['xx', 'yy'])
     tags2 = Tags(['zz', 'ee', 'XX'])
     new_tags = tags1 + tags2
     assert_true(isinstance(new_tags, Tags))
     assert_equal(list(tags1), ['xx', 'yy'])
     assert_equal(list(tags2), ['ee', 'XX', 'zz'])
     assert_equal(list(new_tags), ['ee', 'xx', 'yy', 'zz'])
예제 #2
0
 def test_getitem_with_slice(self):
     tags = Tags(['2', '0', '1'])
     self._verify_slice(tags[:], ['0', '1', '2'])
     self._verify_slice(tags[1:], ['1', '2'])
     self._verify_slice(tags[1:-1], ['1'])
     self._verify_slice(tags[1:-2], [])
     self._verify_slice(tags[::2], ['0', '2'])
예제 #3
0
 def test_init_with_iterable_and_normalization_and_sorting(self):
     for inp in [['T 1', 't2', 't_3'],
                 ('t2', 'T 1', 't_3'),
                 ('t2', 'T 1', 't_3') + ('t2', 'T 1', 't_3'),
                 ('t2', 'T 2', '__T__2__', 'T 1', 't1', 't_1', 't_3', 't3'),
                 ('', 'T 1', '', 't2', 't_3', 'NONE', 'None')]:
         assert_equal(list(Tags(inp)), ['T 1', 't2', 't_3'])
예제 #4
0
 def test__add__None(self):
     tags = Tags(['xx', 'yy'])
     new_tags = tags + None
     assert_true(isinstance(new_tags, Tags))
     assert_equal(list(tags), ['xx', 'yy'])
     assert_equal(list(new_tags), list(tags))
     assert_true(new_tags is not tags)
예제 #5
0
 def test_truth(self):
     assert_true(not Tags())
     assert_true(not Tags('NONE'))
     assert_true(Tags(['a']))
예제 #6
0
 def test_length(self):
     assert_equal(len(Tags()), 0)
     assert_equal(len(Tags(['a', 'b'])), 2)
예제 #7
0
 def test_contains(self):
     assert_true('a' in Tags(['a', 'b']))
     assert_true('c' not in Tags(['a', 'b']))
     assert_true('AA' in Tags(['a_a', 'b']))
예제 #8
0
 def test_remove_using_pattern(self):
     tags = Tags(['t1', 't2', '1', '1more'])
     tags.remove('?2')
     assert_equal(list(tags), ['1', '1more', 't1'])
     tags.remove('*1*')
     assert_equal(list(tags), [])
예제 #9
0
 def test_remove_non_existing(self):
     tags = Tags(['a'])
     tags.remove('nonex')
     assert_equal(list(tags), ['a'])
예제 #10
0
 def test_add_iterable(self):
     tags = Tags(['A'])
     tags.add(('b b', '', 'a', 'NONE'))
     tags.add(Tags(['BB', 'C']))
     assert_equal(list(tags), ['A', 'b b', 'C'])
예제 #11
0
 def test_init_with_none(self):
     assert_equal(list(Tags(None)), [])
예제 #12
0
 def test__eq__(self):
     assert_equal(Tags(['x']), Tags(['x']))
     assert_equal(Tags(['X']), Tags(['x']))
     assert_equal(Tags(['X']), Tags(('x', )))
     assert_not_equal(Tags(['X']), ['x'])
     assert_not_equal(Tags(['X']), ('x', ))
 def _not_excluded_by_tags(self):
     if self.exclude and isinstance(self.test_case_data.tags, list):
         tags = Tags()
         tags.add(self.test_case_data.tags)
         return not tags.match(self.exclude)
     return True
예제 #14
0
 def test_add_and_remove_none(self):
     tags = Tags(['t'])
     tags.add(None)
     tags.remove(None)
     assert_equal(list(tags), ['t'])
예제 #15
0
 def test_remove_using_pattern(self):
     tags = Tags(['t1', 't2', '1', '1more'])
     tags.remove('?2')
     assert_equal(list(tags), ['1', '1more', 't1'])
     tags.remove('*1*')
     assert_equal(list(tags), [])
예제 #16
0
 def test_remove_iterable(self):
     tags = Tags(['a', 'B B'])
     tags.remove(['nonex', '', 'A'])
     tags.remove(Tags('__B_B__'))
     assert_equal(list(tags), [])
예제 #17
0
 def test_remove_non_existing(self):
     tags = Tags(['a'])
     tags.remove('nonex')
     assert_equal(list(tags), ['a'])
예제 #18
0
 def test_remove_string(self):
     tags = Tags(['a', 'B B'])
     tags.remove('a')
     assert_equal(list(tags), ['B B'])
     tags.remove('bb')
     assert_equal(list(tags), [])
예제 #19
0
 def test_str(self):
     assert_equal(str(Tags()), '[]')
     assert_equal(str(Tags(['y', "X'X"])), "[X'X, y]")
     assert_equal(str(Tags([u'\xe4', 'a'])), '[a, \xc3\xa4]')
예제 #20
0
 def test_add_iterable(self):
     tags = Tags(['A'])
     tags.add(('b b', '', 'a', 'NONE'))
     tags.add(Tags(['BB', 'C']))
     assert_equal(list(tags), ['A', 'b b', 'C'])
예제 #21
0
 def test__eq__normalized(self):
     assert_equal(Tags(['Hello world', 'Foo', 'Not_world']),
                  Tags(['nOT WORLD', 'FOO', 'hello world']))
예제 #22
0
 def test_add_string(self):
     tags = Tags(['Y'])
     tags.add('x')
     assert_equal(list(tags), ['x', 'Y'])
예제 #23
0
 def test__add__list(self):
     tags = Tags(['xx', 'yy'])
     new_tags = tags + ['zz', 'ee', 'XX']
     assert_true(isinstance(new_tags, Tags))
     assert_equal(list(tags), ['xx', 'yy'])
     assert_equal(list(new_tags), ['ee', 'xx', 'yy', 'zz'])
예제 #24
0
 def test_remove_string(self):
     tags = Tags(['a', 'B B'])
     tags.remove('a')
     assert_equal(list(tags), ['B B'])
     tags.remove('bb')
     assert_equal(list(tags), [])
예제 #25
0
 def test_init_with_string(self):
     assert_equal(list(Tags('string')), ['string'])
예제 #26
0
 def test_remove_iterable(self):
     tags = Tags(['a', 'B B'])
     tags.remove(['nonex', '', 'A'])
     tags.remove(Tags('__B_B__'))
     assert_equal(list(tags), [])
예제 #27
0
 def _not_excluded_by_tags(self):
     if self.exclude and self.test_case_data.tags:
         tags = Tags()
         tags.add(self.test_case_data.tags)
         return not tags.match(self.exclude)
     return True
예제 #28
0
 def test_add_and_remove_none(self):
     tags = Tags(['t'])
     tags.add(None)
     tags.remove(None)
     assert_equal(list(tags), ['t'])
예제 #29
0
 def test_getitem_with_index(self):
     tags = Tags(['2', '0', '1'])
     assert_equal(tags[0], '0')
     assert_equal(tags[1], '1')
     assert_equal(tags[2], '2')
예제 #30
0
 def test_contains_pattern(self):
     assert_true('a*' in Tags(['a', 'b']))
     assert_true('a*' in Tags(['u2', 'abba']))
     assert_true('a?' not in Tags(['a', 'abba']))
예제 #31
0
 def _included_by_tags(self):
     if self.include:
         tags = Tags()
         tags.add(self.test_case_data.tags)
         return tags.match(self.include)
     return True
예제 #32
0
 def test_empty_init(self):
     assert_equal(list(Tags()), [])
예제 #33
0
 def _verify(self, tags, expected):
     assert_equal(list(Tags(tags)), expected)
예제 #34
0
 def test_unicode(self):
     assert_equal(unicode(Tags()), '[]')
     assert_equal(unicode(Tags(['y', "X'X", 'Y'])), "[X'X, y]")
     assert_equal(unicode(Tags([u'\xe4', 'a'])), u'[a, \xe4]')
예제 #35
0
 def test_init_with_non_strings(self):
     assert_equal(list(Tags([2, True, None])), ['2', 'True'])
예제 #36
0
 def test_repr(self):
     for tags in ([], [u'y', u"X'X"], [u'\xe4', u'a']):
         assert_equal(repr(Tags(tags)), repr(sorted(tags)))
예제 #37
0
 def test_add_string(self):
     tags = Tags(['Y'])
     tags.add('x')
     assert_equal(list(tags), ['x', 'Y'])