]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
test: replace __builtin__ with module path for py3
authorKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Fri, 13 Dec 2019 12:13:14 +0000 (13:13 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Fri, 13 Dec 2019 16:49:38 +0000 (17:49 +0100)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
teuthology/test/test_ls.py
teuthology/test/test_misc.py
teuthology/test/test_report.py

index 6046c8619e2011e540fd7a5a3d55eb5cd8eadc3b..48ff1ce4d6f166a28d05cff16997463742c031eb 100644 (file)
@@ -23,7 +23,7 @@ class TestLs(object):
         m_safe_load_all.return_value = [{"failure_reason": "reasons"}]
         ls.ls("some/archive/div", True)
 
-    @patch("__builtin__.open")
+    @patch("teuthology.ls.open")
     @patch("teuthology.ls.get_jobs")
     def test_ls_ioerror(self, m_get_jobs, m_open):
         m_get_jobs.return_value = ["1", "2"]
@@ -31,7 +31,7 @@ class TestLs(object):
         with pytest.raises(IOError):
             ls.ls("some/archive/dir", True)
 
-    @patch("__builtin__.open")
+    @patch("teuthology.ls.open")
     @patch("os.popen")
     @patch("os.path.isdir")
     @patch("os.path.isfile")
@@ -40,6 +40,9 @@ class TestLs(object):
         m_isdir.return_value = True
         m_popen.return_value = Mock()
         cmdline = Mock()
-        cmdline.find.return_value = True
-        m_open.return_value = cmdline
+        cmdline.find = Mock(return_value=0)
+        m1 = Mock()
+        m2 = Mock()
+        m2.read = Mock(return_value=cmdline)
+        m_open.side_effect = [m1, m2]
         ls.print_debug_info("the_job", "job/dir", "some/archive/dir")
index b0b6b8772ed4aa3f1875ee5de8ae49f53ae8ccd5..bb4e67d90e80751e97352bcc6047a56c065ae20c 100644 (file)
@@ -298,7 +298,7 @@ class TestMergeConfigs(object):
 
     @patch("os.path.exists")
     @patch("yaml.safe_load")
-    @patch("__builtin__.open")
+    @patch("teuthology.misc.open")
     def test_merge_configs(self, m_open, m_safe_load, m_exists):
         """ Only tests with one yaml file being passed, mainly just to test
             the loop logic.  The actual merge will be tested in subsequent
index 2d13b7d97ac2f4b96c9d85edd08b854f4b935461..1a33b12b4b5ff975ba57ad394da80a4413f28c6c 100644 (file)
@@ -1,6 +1,6 @@
 import yaml
 import json
-import fake_archive
+from teuthology.test import fake_archive
 from teuthology import report