From e5bf1b99b762eaa39ca78d65d16a9cea10f98f2c Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Mon, 24 Jun 2019 12:54:26 -0700 Subject: [PATCH] tests: fix up mocks for open_auto() use Signed-off-by: Patrick McCarty --- tests/test_build.py | 14 +++++++------- tests/test_buildreq.py | 28 ++++++++++++++-------------- tests/test_check.py | 2 +- tests/test_commitmessage.py | 6 +++--- tests/test_count.py | 2 +- tests/test_specdescription.py | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/test_build.py b/tests/test_build.py index e771fd1..18992b1 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -249,7 +249,7 @@ class TestBuildpattern(unittest.TestCase): call_backup = build.util.call build.util.call = mock_util_call - open_name = 'build.open' + open_name = 'build.util.open_auto' content = "line1\nDEBUG util.py:399: No matching package to install: 'foobar'\nDEBUG util.py:399: No matching package to install: 'foobarbaz'\nline 4" m_open = mock_open(read_data=content) @@ -274,7 +274,7 @@ class TestBuildpattern(unittest.TestCase): call_backup = build.util.call build.util.call = mock_util_call - open_name = 'build.open' + open_name = 'build.util.open_auto' content = "line 1\nline 2\nline 3\nline 4" m_open = mock_open(read_data=content) @@ -300,7 +300,7 @@ class TestBuildpattern(unittest.TestCase): call_backup = build.util.call build.util.call = mock_util_call - open_name = 'build.open' + open_name = 'build.util.open_auto' content = "line 1\nline 2\nline 3\nline 4" m_open = mock_open(read_data=content) @@ -326,7 +326,7 @@ class TestBuildpattern(unittest.TestCase): build.util.call = mock_util_call fm = files.FileManager() - open_name = 'build.open' + open_name = 'build.util.open_auto' content = 'line 1\nwhich: no qmake\nexiting' m_open = mock_open(read_data=content) @@ -352,7 +352,7 @@ class TestBuildpattern(unittest.TestCase): build.util.call = mock_util_call fm = files.FileManager() - open_name = 'build.open' + open_name = 'build.util.open_auto' content = 'line 1\nchecking for Apache test module support\nexiting' m_open = mock_open(read_data=content) @@ -378,7 +378,7 @@ class TestBuildpattern(unittest.TestCase): build.util.call = mock_util_call fm = files.FileManager() - open_name = 'build.open' + open_name = 'build.util.open_auto' content = 'line 1\nImportError: No module named testpkg\nexiting' m_open = mock_open(read_data=content) @@ -402,7 +402,7 @@ class TestBuildpattern(unittest.TestCase): build.util.call = mock_util_call fm = files.FileManager() - open_name = 'build.open' + open_name = 'build.util.open_auto' content = 'line 1\n' \ 'Installed (but unpackaged) file(s) found:\n' \ '/usr/testdir/file\n' \ diff --git a/tests/test_buildreq.py b/tests/test_buildreq.py index bd9a8bb..2bf0c0d 100644 --- a/tests/test_buildreq.py +++ b/tests/test_buildreq.py @@ -129,7 +129,7 @@ class TestBuildreq(unittest.TestCase): Test parse_configure_ac with changing () depths and package requirements """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = 'AC_CHECK_FUNC([tgetent])\n' \ 'XDT_CHECK_PACKAGE(prefix, ' \ '[module = 2 module2 > 9], ' \ @@ -168,7 +168,7 @@ class TestBuildreq(unittest.TestCase): buildreq.os.path.exists = mock_exists buildreq.toml.loads = mock_loads - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = 'does not matter, let us mock' m_open = mock_open(read_data=content) with patch(open_name, m_open, create=True): @@ -216,7 +216,7 @@ class TestBuildreq(unittest.TestCase): """ Test rakefile parsing with both configured gems and unconfigured gems """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "line1\nrequire 'bundler/gem_tasks'\nline3\nrequire 'nope'" m_open = mock_open(read_data=content) with patch(open_name, m_open, create=True): @@ -252,7 +252,7 @@ class TestBuildreq(unittest.TestCase): """ # buildreqs must include the requires also buildreq.buildreqs = set(['req1', 'req2', 'req7']) - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = 'req1 <= 1.2.3\n' \ 'req2 >= 1.55\n' \ 'req7 == 3.3.3\n' @@ -268,7 +268,7 @@ class TestBuildreq(unittest.TestCase): """ # buildreqs must include the requires also buildreq.buildreqs = set(['req1', 'req2', 'req7']) - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = ' req1 <= 1.2.3\n ' \ 'req2 >= 1.55 \n' \ ' req7 == 3.3.3\n ' @@ -283,7 +283,7 @@ class TestBuildreq(unittest.TestCase): Test add_setup_py_requires with a single item in install_requires and setup_requires """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "install_requires=['req1']\n" \ "setup_requires=['req2']" m_open = mock_open(read_data=content) @@ -297,7 +297,7 @@ class TestBuildreq(unittest.TestCase): """ Test add_setup_py_requires with a multiline item in install_requires """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "install_requires=['req1',\n" \ "'req2',\n" \ "'req3']\n" @@ -313,7 +313,7 @@ class TestBuildreq(unittest.TestCase): Test add_setup_py_requires with a multiline item in install_requires with brackets on their own lines. """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "install_requires=[\n " \ "'req1',\n" \ "'req2',\n" \ @@ -331,7 +331,7 @@ class TestBuildreq(unittest.TestCase): Test add_setup_py_requires with multiline item in install_requires that contains a non-literal object. """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "install_requires=[\n" \ "reqvar,\n" \ "'req1',\n" \ @@ -348,7 +348,7 @@ class TestBuildreq(unittest.TestCase): """ Test add_setup_py_requires that contains a non-literal object. """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "install_requires=[reqname, 'req1', 'req2']\n" m_open = mock_open(read_data=content) with patch(open_name, m_open, create=True): @@ -361,7 +361,7 @@ class TestBuildreq(unittest.TestCase): """ Test add_setup_py_requires with a single non-literal object """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = "install_requires=reqname" m_open = mock_open(read_data=content) with patch(open_name, m_open, create=True): @@ -375,7 +375,7 @@ class TestBuildreq(unittest.TestCase): test detection of python version from setup.py classifier """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = """classifiers = [ 'Programming Language :: Python :: 3 :: Only', ]""" @@ -391,7 +391,7 @@ class TestBuildreq(unittest.TestCase): test detection of python version from setup.py classifier """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = """classifiers = [ 'Programming Language :: Python :: 2 :: Only', ]""" @@ -407,7 +407,7 @@ class TestBuildreq(unittest.TestCase): test detection of python version from setup.py classifier """ - open_name = 'buildreq.open' + open_name = 'buildreq.util.open_auto' content = """classifiers = [ 'Programming Language :: Python :: 3', ]""" diff --git a/tests/test_check.py b/tests/test_check.py index 6ea31e2..c5debc4 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -18,7 +18,7 @@ class TestTest(unittest.TestCase): @classmethod def setUpClass(self): - self.open_name = 'check.open' + self.open_name = 'check.util.open_auto' check.config.config_opts['skip_tests'] = False check.config.config_opts['allow_test_failures'] = False check.config.config_opts['32bit'] = False diff --git a/tests/test_commitmessage.py b/tests/test_commitmessage.py index 8f57fef..b4b3b96 100644 --- a/tests/test_commitmessage.py +++ b/tests/test_commitmessage.py @@ -126,7 +126,7 @@ class TestCommitmessage(unittest.TestCase): set(['cve1', 'cve2'])) commitmessage.process_NEWS = mock_process_NEWS - open_name = 'util.open' + open_name = 'util.open_auto' with mock.patch(open_name, create=True) as mock_open: mock_open.return_value = mock.MagicMock() commitmessage.guess_commit_message("") @@ -156,7 +156,7 @@ class TestCommitmessage(unittest.TestCase): commitmessage.process_NEWS = mock_process_NEWS commitmessage.config.cves = set(['CVE-1234-5678']) commitmessage.config.old_version = None # Allow cve title to be set - open_name = 'util.open' + open_name = 'util.open_auto' with mock.patch(open_name, create=True) as mock_open: mock_open.return_value = mock.MagicMock() commitmessage.guess_commit_message("") @@ -187,7 +187,7 @@ class TestCommitmessage(unittest.TestCase): commitmessage.process_NEWS = mock_process_NEWS commitmessage.config.cves = set(['CVE-1234-5678']) commitmessage.config.old_version = None # Allow cve title to be set - open_name = 'util.open' + open_name = 'util.open_auto' with mock.patch(open_name, create=True) as mock_open: mock_open.return_value = mock.MagicMock() commitmessage.guess_commit_message("keyinfo content") diff --git a/tests/test_count.py b/tests/test_count.py index 51ffa0b..d1761b3 100644 --- a/tests/test_count.py +++ b/tests/test_count.py @@ -490,7 +490,7 @@ def test_generator(line, expected): """ content = '+ make check\n' + line m_open = mock_open(read_data=content) - with patch('count.open', m_open, create=True): + with patch('count.util.open_auto', m_open, create=True): count.zero_test_data = mock_zero_test_data count.parse_log('log') count.zero_test_data = backup_zero_test_data diff --git a/tests/test_specdescription.py b/tests/test_specdescription.py index a00a1ee..76fab91 100644 --- a/tests/test_specdescription.py +++ b/tests/test_specdescription.py @@ -7,7 +7,7 @@ class TestSpecdescription(unittest.TestCase): @classmethod def setUpClass(self): - self.open_name = 'specdescription.open' + self.open_name = 'specdescription.util.open_auto' def setUp(self): specdescription.default_description = "No detailed description available"