[gtk-doc] tests: add a test for the previous fix



commit 12fea39be7d21985211aad4e2814787b37f3f4c0
Author: Stefan Sauer <ensonic users sf net>
Date:   Wed May 17 21:12:50 2017 +0200

    tests: add a test for the previous fix

 tests/gtkdoc-common.py |   13 +++++++++++--
 1 files 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):
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]