Kaydet (Commit) ad4f5f9d authored tarafından Corentin Henry's avatar Corentin Henry Kaydeden (comit) Joffrey F

tests: fix failure due to pytest deprecation

Signed-off-by: 's avatarCorentin Henry <corentinhenry@gmail.com>
üst cafb802c
...@@ -4,8 +4,8 @@ import shutil ...@@ -4,8 +4,8 @@ import shutil
import tempfile import tempfile
import json import json
from py.test import ensuretemp from pytest import mark, fixture
from pytest import mark
from docker.utils import config from docker.utils import config
try: try:
...@@ -15,25 +15,25 @@ except ImportError: ...@@ -15,25 +15,25 @@ except ImportError:
class FindConfigFileTest(unittest.TestCase): class FindConfigFileTest(unittest.TestCase):
def tmpdir(self, name):
tmpdir = ensuretemp(name) @fixture(autouse=True)
self.addCleanup(tmpdir.remove) def tmpdir(self, tmpdir):
return tmpdir self.mkdir = tmpdir.mkdir
def test_find_config_fallback(self): 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)}): with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}):
assert config.find_config_file() is None assert config.find_config_file() is None
def test_find_config_from_explicit_path(self): 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') config_path = tmpdir.ensure('my-config-file.json')
assert config.find_config_file(str(config_path)) == str(config_path) assert config.find_config_file(str(config_path)) == str(config_path)
def test_find_config_from_environment(self): 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') config_path = tmpdir.ensure('config.json')
with mock.patch.dict(os.environ, {'DOCKER_CONFIG': str(tmpdir)}): with mock.patch.dict(os.environ, {'DOCKER_CONFIG': str(tmpdir)}):
...@@ -41,7 +41,7 @@ class FindConfigFileTest(unittest.TestCase): ...@@ -41,7 +41,7 @@ class FindConfigFileTest(unittest.TestCase):
@mark.skipif("sys.platform == 'win32'") @mark.skipif("sys.platform == 'win32'")
def test_find_config_from_home_posix(self): 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') config_path = tmpdir.ensure('.docker', 'config.json')
with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}):
...@@ -49,7 +49,7 @@ class FindConfigFileTest(unittest.TestCase): ...@@ -49,7 +49,7 @@ class FindConfigFileTest(unittest.TestCase):
@mark.skipif("sys.platform == 'win32'") @mark.skipif("sys.platform == 'win32'")
def test_find_config_from_home_legacy_name(self): 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') config_path = tmpdir.ensure('.dockercfg')
with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}):
...@@ -57,7 +57,7 @@ class FindConfigFileTest(unittest.TestCase): ...@@ -57,7 +57,7 @@ class FindConfigFileTest(unittest.TestCase):
@mark.skipif("sys.platform != 'win32'") @mark.skipif("sys.platform != 'win32'")
def test_find_config_from_home_windows(self): 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') config_path = tmpdir.ensure('.docker', 'config.json')
with mock.patch.dict(os.environ, {'USERPROFILE': str(tmpdir)}): with mock.patch.dict(os.environ, {'USERPROFILE': str(tmpdir)}):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment