Skip to content

Commit

Permalink
Fix backward compatibility
Browse files Browse the repository at this point in the history
The previous solution was breaking backward compatibility when for
instance `docken_compose_file` was returning a `py.path` path (used by
pytest internally, e.g. for `pytestconfig.rootdir`).

This makes it more conservative and more backward compatible.
  • Loading branch information
gdetrez committed Aug 7, 2017
1 parent 31eee04 commit e898132
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pytest_docker/__init__.py
Expand Up @@ -102,11 +102,10 @@ def wait_until_responsive(self, check, timeout, pause,
)


def str_to_list(x):
if isinstance(x, str):
return [x]
else:
return x
def str_to_list(arg):
if isinstance(arg, (list, tuple)):
return arg
return [arg]


@attr.s(frozen=True)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_dockercomposeexecutor.py
Expand Up @@ -2,6 +2,8 @@
import mock
import subprocess

import py

from pytest_docker import DockerComposeExecutor


Expand All @@ -17,6 +19,20 @@ def test_execute():
]


def test_pypath_compose_files():
compose_file = py.path.local('/tmp/docker-compose.yml')
docker_compose = DockerComposeExecutor(compose_file, "pytest123")
with mock.patch('subprocess.check_output') as check_output:
docker_compose.execute("up")
assert check_output.call_args_list == [
mock.call(
'docker-compose -f "/tmp/docker-compose.yml"'
' -p "pytest123" up',
shell=True, stderr=subprocess.STDOUT,
),
]


def test_multiple_compose_files():
docker_compose = DockerComposeExecutor(
["docker-compose.yml", "other-compose.yml"], "pytest123")
Expand Down

0 comments on commit e898132

Please sign in to comment.