From 12fea39be7d21985211aad4e2814787b37f3f4c0 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 17 May 2017 21:12:50 +0200 Subject: [PATCH] tests: add a test for the previous fix --- tests/gtkdoc-common.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/gtkdoc-common.py b/tests/gtkdoc-common.py index 6f5969a..448873a 100755 --- a/tests/gtkdoc-common.py +++ b/tests/gtkdoc-common.py @@ -12,10 +12,19 @@ class TestUpdateFileIfChanged(unittest.TestCase): @mock.patch('os.rename') def test_NoOldFile(self, os_rename, os_path_exists): os_path_exists.return_value = False - res = common.UpdateFileIfChanged('/foo', '/bar', False) - os_rename.assert_called_with('/bar', '/foo') + res = common.UpdateFileIfChanged('/old', '/new', False) + os_rename.assert_called_with('/new', '/old') self.assertTrue(res) + @mock.patch('os.path.exists') + @mock.patch('__builtin__.open', mock.mock_open(read_data='bar')) + @mock.patch('os.unlink') + def test_FilesAreTheSame(self, os_unlink, os_path_exists): + os_path_exists.return_value = True + res = common.UpdateFileIfChanged('/old', '/new', False) + os_unlink.assert_called_with('/new') + self.assertFalse(res) + class TestGetModuleDocDir(unittest.TestCase): -- 2.11.4.GIT