filename="other_test.pdf",
)
stdout, _ = self.call_command()
- self.assertEqual(stdout, "No matches found\n")
+ self.assertIn("No matches found", stdout)
def test_with_matches(self):
"""
filename="other_test.pdf",
)
stdout, _ = self.call_command("--processes", "1")
- self.assertRegex(stdout, self.MSG_REGEX + "\n")
+ self.assertRegex(stdout, self.MSG_REGEX)
def test_with_3_matches(self):
"""
filename="final_test.pdf",
)
stdout, _ = self.call_command()
- lines = [x.strip() for x in stdout.split("\n") if len(x.strip())]
+ lines = [x.strip() for x in stdout.splitlines() if x.strip()]
self.assertEqual(len(lines), 3)
- self.assertRegex(lines[0], self.MSG_REGEX)
- self.assertRegex(lines[1], self.MSG_REGEX)
- self.assertRegex(lines[2], self.MSG_REGEX)
+ for line in lines:
+ self.assertRegex(line, self.MSG_REGEX)
def test_document_deletion(self):
"""
stdout, _ = self.call_command("--delete")
- lines = [x.strip() for x in stdout.split("\n") if len(x.strip())]
- self.assertEqual(len(lines), 3)
- self.assertEqual(
- lines[0],
+ self.assertIn(
"The command is configured to delete documents. Use with caution",
+ stdout,
)
- self.assertRegex(lines[1], self.MSG_REGEX)
- self.assertEqual(lines[2], "Deleting 1 documents based on ratio matches")
+ self.assertRegex(stdout, self.MSG_REGEX)
+ self.assertIn("Deleting 1 documents based on ratio matches", stdout)
self.assertEqual(Document.objects.count(), 2)
self.assertIsNotNone(Document.objects.get(pk=1))