diff --git a/tests/unit/api_test.py b/tests/unit/api_test.py index 7e3e95178..6117991e4 100644 --- a/tests/unit/api_test.py +++ b/tests/unit/api_test.py @@ -480,11 +480,12 @@ class TCPSocketStreamTest(unittest.TestCase): @classmethod def setup_class(cls): cls.server = socketserver.ThreadingTCPServer( - ('', 0), cls.get_handler_class()) + ('127.0.0.1', 0), cls.get_handler_class()) cls.thread = threading.Thread(target=cls.server.serve_forever) cls.thread.daemon = True cls.thread.start() - cls.address = f'http://{socket.gethostname()}:{cls.server.server_address[1]}' + host, port = cls.server.server_address + cls.address = f'http://{host}:{port}' @classmethod def teardown_class(cls): diff --git a/tests/unit/utils_config_test.py b/tests/unit/utils_config_test.py index c87231a99..ece5e7886 100644 --- a/tests/unit/utils_config_test.py +++ b/tests/unit/utils_config_test.py @@ -19,7 +19,9 @@ def tmpdir(self, tmpdir): def test_find_config_fallback(self): 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), 'USERPROFILE': str(tmpdir) + }): assert config.find_config_file() is None def test_find_config_from_explicit_path(self): @@ -43,12 +45,13 @@ def test_find_config_from_home_posix(self): with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): assert config.find_config_file() == str(config_path) - @mark.skipif("sys.platform == 'win32'") def test_find_config_from_home_legacy_name(self): tmpdir = self.mkdir('test_find_config_from_home_legacy_name') config_path = tmpdir.ensure('.dockercfg') - with mock.patch.dict(os.environ, {'HOME': str(tmpdir)}): + with mock.patch.dict(os.environ, { + 'HOME': str(tmpdir), 'USERPROFILE': str(tmpdir) + }): assert config.find_config_file() == str(config_path) @mark.skipif("sys.platform != 'win32'") diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 21da0b58e..633911dec 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -132,6 +132,7 @@ def test_kwargs_from_env_tls_verify_false_no_cert(self): os.environ.update(DOCKER_HOST='tcp://192.168.59.103:2376', HOME=temp_dir, + USERPROFILE=temp_dir, DOCKER_TLS_VERIFY='') os.environ.pop('DOCKER_CERT_PATH', None) kwargs = kwargs_from_env() @@ -144,6 +145,7 @@ def test_kwargs_from_env_no_cert_path(self): shutil.copytree(TEST_CERT_DIR, cert_dir) os.environ.update(HOME=temp_dir, + USERPROFILE=temp_dir, DOCKER_CERT_PATH='', DOCKER_TLS_VERIFY='1')