summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-22 09:28:56 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-22 09:28:56 -0400
commit2c86f67fa234406ee0007a3f77cc1aa9f45ed746 (patch)
tree37b8c68fea766a9b90f79982d5ed70702b6d5895
parent6a65863eea6b51e8cc40a2f120c1e923fccd0540 (diff)
downloadbcfg2-2c86f67fa234406ee0007a3f77cc1aa9f45ed746.tar.gz
bcfg2-2c86f67fa234406ee0007a3f77cc1aa9f45ed746.tar.bz2
bcfg2-2c86f67fa234406ee0007a3f77cc1aa9f45ed746.zip
made test of POSIXFile._diff() much much faster
-rw-r--r--testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py
index 50573051c..a793513f5 100644
--- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py
+++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py
@@ -399,9 +399,17 @@ class TestPOSIXFile(TestPOSIXTool):
mock_rename.assert_called_with(newfile, entry)
mock_install.assert_called_with(self.ptool, entry)
- def test_diff(self):
+ @patch("time.time")
+ def test_diff(self, mock_time):
content1 = "line1\nline2"
content2 = "line3"
+
+ self.now = 1345640723
+ def time_rv():
+ self.now += 1
+ return self.now
+ mock_time.side_effect = time_rv
+
rv = ["line1", "line2", "line3"]
func = Mock()
func.return_value = rv
@@ -409,9 +417,14 @@ class TestPOSIXFile(TestPOSIXTool):
func.assert_called_with(["line1", "line2"], ["line3"])
func.reset_mock()
+ mock_time.reset_mock()
+ def time_rv():
+ self.now += 5
+ return self.now
+ mock_time.side_effect = time_rv
+
def slow_diff(content1, content2):
for i in range(1, 10):
- time.sleep(5)
yield "line%s" % i
func.side_effect = slow_diff
self.assertFalse(self.ptool._diff(content1, content2, func), rv)