Ejemplo n.º 1
0
 def test_ignore_all(self):
     tokens = list(self.file.tokens())
     ignored_index = winnowing.CompareIndex(k=2)
     ignored_index.include(self.file, tokens=tokens)
     relevant_token_lists = ignored_index.unignored_tokens(self.file,
                                                           tokens=tokens)
     self.assertEqual(relevant_token_lists, [])
Ejemplo n.º 2
0
 def test_no_ignore(self):
     tokens = list(self.file.tokens())
     ignored_index = winnowing.CompareIndex(k=2)
     relevant_token_lists = ignored_index.unignored_tokens(self.file,
                                                           tokens=tokens)
     self.assertEqual(len(relevant_token_lists), 1)
     self.assertEqual(relevant_token_lists[0], tokens)
Ejemplo n.º 3
0
    def test_ignore_half(self):
        ignore_content = self.content.split("\n")[0]
        with open("ignore.py", "w") as f:
            f.write(ignore_content)
        ignored_file = data.Submission(".", ["ignore.py"]).files[0]
        ignored_index = winnowing.CompareIndex(k=2)
        ignored_index.include(ignored_file)

        relevant_token_lists = ignored_index.unignored_tokens(self.file)

        end = list(ignored_file.tokens())[-1].end
        expected_tokens = [t for t in self.file.tokens() if t.start >= end]

        self.assertEqual(len(relevant_token_lists), 1)
        self.assertEqual(relevant_token_lists[0], expected_tokens)