Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/unit/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/utils_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'")
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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')

Expand Down