Skip to content

Commit 09f12f2

Browse files
committed
Fix B005 (probably an actual bug too)
Signed-off-by: Aarni Koskela <akx@iki.fi>
1 parent 6aec90a commit 09f12f2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docker/context/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ def get_context_host(path=None, tls=False):
7777
host = utils.parse_host(path, IS_WINDOWS_PLATFORM, tls)
7878
if host == DEFAULT_UNIX_SOCKET:
7979
# remove http+ from default docker socket url
80-
return host.strip("http+")
80+
if host.startswith("http+"):
81+
host = host[5:]
8182
return host

tests/unit/context_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BaseContextTest(unittest.TestCase):
1313
)
1414
def test_url_compatibility_on_linux(self):
1515
c = Context("test")
16-
assert c.Host == DEFAULT_UNIX_SOCKET.strip("http+")
16+
assert c.Host == DEFAULT_UNIX_SOCKET[5:]
1717

1818
@pytest.mark.skipif(
1919
not IS_WINDOWS_PLATFORM, reason='Windows specific path check'
@@ -45,5 +45,7 @@ def test_context_inspect_without_params(self):
4545
ctx = ContextAPI.inspect_context()
4646
assert ctx["Name"] == "default"
4747
assert ctx["Metadata"]["StackOrchestrator"] == "swarm"
48-
assert ctx["Endpoints"]["docker"]["Host"] in [
49-
DEFAULT_NPIPE, DEFAULT_UNIX_SOCKET.strip("http+")]
48+
assert ctx["Endpoints"]["docker"]["Host"] in (
49+
DEFAULT_NPIPE,
50+
DEFAULT_UNIX_SOCKET[5:],
51+
)

0 commit comments

Comments
 (0)