Beispiel #1
0
    def test_equality(self):
        tags = Tags([WordTag.THIRD_PERSON, WordTag.DEFINITE])
        equal_tags = Tags(
            [WordTag.DEFINITE, WordTag.THIRD_PERSON, WordTag.THIRD_PERSON])
        self.assertEqual(tags.to_list(), equal_tags.to_list())
        self.assertEqual(tags, equal_tags)

        self.assertNotEqual(
            tags, Tags([WordTag.THIRD_PERSON, WordTag.DEFINITE, WordTag.PAST]))
Beispiel #2
0
    def test_init_no_repeat_values(self):
        one_tag = Tags([WordTag.PAST])
        repeat = Tags([WordTag.PAST, WordTag.PAST])

        self.assertEqual(one_tag.to_list(), [WordTag.PAST])
        self.assertEqual(repeat.to_list(), [WordTag.PAST])

        self.assertEqual(one_tag, repeat)

        self.assertEqual(repr(repeat), 'Tags([WordTag.PAST])')
Beispiel #3
0
    def test_to_list_is_sorted(self):
        all_tags = sorted(WordTag.__members__.values())
        shuffled = all_tags[:]
        random.shuffle(shuffled)

        test = Tags(shuffled)
        self.assertEqual(test.to_list(), all_tags)
Beispiel #4
0
    def test_add_element_not_present(self):
        tags = Tags()
        new_tags = tags.add(WordTag.PAST)

        self.assertEqual(tags.to_list(), [])
        self.assertEqual(new_tags.to_list(), [WordTag.PAST])

        new_tags = new_tags.add(WordTag.DEFINITE)

        self.assertEqual(new_tags.to_list(), [WordTag.DEFINITE, WordTag.PAST])
Beispiel #5
0
 def test_init_empty(self):
     test = Tags()
     self.assertEqual(test.to_list(), [])
Beispiel #6
0
 def test_remove_element_present(self):
     tags = Tags([WordTag.PAST])
     new = tags.remove(WordTag.PAST)
     self.assertEqual(tags.to_list(), [WordTag.PAST])
     self.assertEqual(new.to_list(), [])
Beispiel #7
0
    def test_init_initial_list_is_not_pointed_to(self):
        tag_list = [WordTag.PAST, WordTag.DEFINITE]
        tags = Tags(tag_list)
        tag_list[0] = 'oops'

        self.assertEqual(tags.to_list(), [WordTag.DEFINITE, WordTag.PAST])