From 47c10aa383b87e0cb47904bd912839c13d902924 Mon Sep 17 00:00:00 2001 From: Corentin Henry Date: Wed, 21 Nov 2018 17:12:01 -0800 Subject: [PATCH 1/2] tests: fix failure due to pytest deprecation Signed-off-by: Corentin Henry --- tests/unit/utils_config_test.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/unit/utils_config_test.py b/tests/unit/utils_config_test.py index 50ba3831db..b0934f9568 100644 --- a/tests/unit/utils_config_test.py +++ b/tests/unit/utils_config_test.py @@ -4,8 +4,8 @@ import tempfile import json -from py.test import ensuretemp -from pytest import mark +from pytest import mark, fixture + from docker.utils import config try: @@ -15,25 +15,25 @@ class FindConfigFileTest(unittest.TestCase): - def tmpdir(self, name): - tmpdir = ensuretemp(name) - self.addCleanup(tmpdir.remove) - return tmpdir + + @fixture(autouse=True) + def tmpdir(self, tmpdir): + self.mkdir = tmpdir.mkdir def test_find_config_fallback(self): - tmpdir = self.tmpdir('test_find_config_fallback') + tmpdir = self.mkdir('test_find_config_fallback') with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): assert config.find_config_file() is None def test_find_config_from_explicit_path(self): - tmpdir = self.tmpdir('test_find_config_from_explicit_path') + tmpdir = self.mkdir('test_find_config_from_explicit_path') config_path = tmpdir.ensure('my-config-file.json') assert config.find_config_file(str(config_path)) == str(config_path) def test_find_config_from_environment(self): - tmpdir = self.tmpdir('test_find_config_from_environment') + tmpdir = self.mkdir('test_find_config_from_environment') config_path = tmpdir.ensure('config.json') with mock.patch.dict(os.environ, {'DOCKER_CONFIG': str(tmpdir)}): @@ -41,7 +41,7 @@ def test_find_config_from_environment(self): @mark.skipif("sys.platform == 'win32'") def test_find_config_from_home_posix(self): - tmpdir = self.tmpdir('test_find_config_from_home_posix') + tmpdir = self.mkdir('test_find_config_from_home_posix') config_path = tmpdir.ensure('.docker', 'config.json') with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): @@ -49,7 +49,7 @@ def test_find_config_from_home_posix(self): @mark.skipif("sys.platform == 'win32'") def test_find_config_from_home_legacy_name(self): - tmpdir = self.tmpdir('test_find_config_from_home_legacy_name') + tmpdir = self.mkdir('test_find_config_from_home_legacy_name') config_path = tmpdir.ensure('.dockercfg') with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): @@ -57,7 +57,7 @@ def test_find_config_from_home_legacy_name(self): @mark.skipif("sys.platform != 'win32'") def test_find_config_from_home_windows(self): - tmpdir = self.tmpdir('test_find_config_from_home_windows') + tmpdir = self.mkdir('test_find_config_from_home_windows') config_path = tmpdir.ensure('.docker', 'config.json') with mock.patch.dict(os.environ, {'USERPROFILE': str(tmpdir)}): From 493d7f0f3041eb6f7170fa1edce2e8aa2740bd41 Mon Sep 17 00:00:00 2001 From: Corentin Henry Date: Wed, 21 Nov 2018 17:52:35 -0800 Subject: [PATCH 2/2] tests: bump pytest-timeout Signed-off-by: Corentin Henry pytest-timeout 1.2.1 seems to be incompatible with pytest 3.6.3: INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/main.py", line 185, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/main.py", line 225, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/hooks.py", line 284, in __call__ INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/manager.py", line 67, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/manager.py", line 61, in INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/callers.py", line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/callers.py", line 81, in get_result INTERNALERROR> _reraise(*ex) # noqa INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/callers.py", line 187, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/main.py", line 246, in pytest_runtestloop INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/hooks.py", line 284, in __call__ INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/manager.py", line 67, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/manager.py", line 61, in INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/callers.py", line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/callers.py", line 81, in get_result INTERNALERROR> _reraise(*ex) # noqa INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pluggy/callers.py", line 182, in _multicall INTERNALERROR> next(gen) # first yield INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pytest_timeout.py", line 76, in pytest_runtest_protocol INTERNALERROR> timeout_setup(item) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pytest_timeout.py", line 104, in timeout_setup INTERNALERROR> timeout, method = get_params(item) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pytest_timeout.py", line 162, in get_params INTERNALERROR> timeout, method = _parse_marker(item.keywords['timeout']) INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/pytest_timeout.py", line 178, in _parse_marker INTERNALERROR> if not marker.args and not marker.kwargs: INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/mark/structures.py", line 25, in warned INTERNALERROR> warnings.warn(warning, stacklevel=2) INTERNALERROR> RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly. INTERNALERROR> Please use node.get_closest_marker(name) or node.iter_markers(name). INTERNALERROR> Docs: https://docs.pytest.org/en/latest/mark.html#updating-code --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 9ad59cc664..07e1a900db 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,4 +4,4 @@ mock==1.0.1 pytest==2.9.1; python_version == '3.3' pytest==3.6.3; python_version > '3.3' pytest-cov==2.1.0 -pytest-timeout==1.2.1 +pytest-timeout==1.3.3