Exemple #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'])
Exemple #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'])
Exemple #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'])
Exemple #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)
Exemple #5
0
 def test_truth(self):
     assert_true(not Tags())
     assert_true(not Tags('NONE'))
     assert_true(Tags(['a']))
Exemple #6
0
 def test_length(self):
     assert_equal(len(Tags()), 0)
     assert_equal(len(Tags(['a', 'b'])), 2)
Exemple #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']))
Exemple #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), [])
Exemple #9
0
 def test_remove_non_existing(self):
     tags = Tags(['a'])
     tags.remove('nonex')
     assert_equal(list(tags), ['a'])
Exemple #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'])
Exemple #11
0
 def test_init_with_none(self):
     assert_equal(list(Tags(None)), [])
Exemple #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
 def test_add_and_remove_none(self):
     tags = Tags(['t'])
     tags.add(None)
     tags.remove(None)
     assert_equal(list(tags), ['t'])
 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), [])
 def test_remove_iterable(self):
     tags = Tags(['a', 'B B'])
     tags.remove(['nonex', '', 'A'])
     tags.remove(Tags('__B_B__'))
     assert_equal(list(tags), [])
 def test_remove_non_existing(self):
     tags = Tags(['a'])
     tags.remove('nonex')
     assert_equal(list(tags), ['a'])
 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), [])
Exemple #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]')
 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'])
Exemple #21
0
 def test__eq__normalized(self):
     assert_equal(Tags(['Hello world', 'Foo', 'Not_world']),
                  Tags(['nOT WORLD', 'FOO', 'hello world']))
Exemple #22
0
 def test_add_string(self):
     tags = Tags(['Y'])
     tags.add('x')
     assert_equal(list(tags), ['x', 'Y'])
Exemple #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'])
Exemple #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), [])
Exemple #25
0
 def test_init_with_string(self):
     assert_equal(list(Tags('string')), ['string'])
Exemple #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), [])
Exemple #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
Exemple #28
0
 def test_add_and_remove_none(self):
     tags = Tags(['t'])
     tags.add(None)
     tags.remove(None)
     assert_equal(list(tags), ['t'])
Exemple #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')
Exemple #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']))
Exemple #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
Exemple #32
0
 def test_empty_init(self):
     assert_equal(list(Tags()), [])
Exemple #33
0
 def _verify(self, tags, expected):
     assert_equal(list(Tags(tags)), expected)
Exemple #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]')
Exemple #35
0
 def test_init_with_non_strings(self):
     assert_equal(list(Tags([2, True, None])), ['2', 'True'])
Exemple #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)))
 def test_add_string(self):
     tags = Tags(['Y'])
     tags.add('x')
     assert_equal(list(tags), ['x', 'Y'])