def test_diff_meta(self): a, b = "test1", "test2" expect_diff = [ "--- <class 'str'>", "+++ <class 'str'>", "@@ -1 +1 @@", "-test1", "+test2" ] self.assertEqual(cct.diff(a, b, meta=True), expect_diff)
def test_diff_files(self): a = os.path.join(project_dir, "tests", "testfile") b = os.path.join(project_dir, "tests", "testfile2") expect_diff = [ "-This file should not changed", "+This file should not changed too" ] self.assertEqual(cct.diff(a, b), expect_diff)
def test_diff_force_str(self): a = os.path.join(project_dir, "tests", "testfile") b = os.path.join(project_dir, "tests", "testfile2") self.assertTrue("-{}".format(a) in cct.diff(a, b, force_str=True))
def test_diff_context(self): a, b = ["a", "c"], ["b", "c"] expect_diff = ["-a", "+b", " c"] self.assertEqual(cct.diff(a, b, context=1), expect_diff)
def test_diff_list(self): a, b = ["a", "c"], ["b", "c"] expect_diff = ["-a", "+b"] self.assertEqual(cct.diff(a, b), expect_diff)
def test_diff_str(self): a, b = "test1", "test2" expect_diff = ["-test1", "+test2"] self.assertEqual(cct.diff(a, b), expect_diff)
def test_diff_same(self): diffs = cct.diff("test", "test") self.assertFalse(diffs)