# Path: seaworthy/checks.py
# @contextmanager
# def docker_client():
#     """
#     A context manager that creates and cleans up a Docker API client.
# 
#     In most cases, it's better to use :class:`~seaworthy.helpers.DockerHelper`
#     instead.
#     """
#     client = docker.client.from_env()
#     yield client
#     client.api.close()
# 
# Path: seaworthy/helpers.py
# def fetch_images(client, images):
#     """
#     Fetch images if they aren't already present.
#     """
#     return [fetch_image(client, image) for image in images]
# 
# Path: seaworthy/pytest/checks.py
# def dockertest():
#     """
#     Skip tests that require Docker to be available.
# 
#     This is a function that returns a decorator so that we don't run arbitrary
#     Docker client code on import. Unlike :func:`seaworthy.checks.dockertest`,
#     this implementation doesn't require :class:`unittest.TestCase`. It does,
#     however, require pytest.
#     """
#     return pytest.mark.skipif(
#         not docker_available(), reason='Docker not available.')


from seaworthy.checks import docker_client
from seaworthy.helpers import fetch_images
from seaworthy.pytest.checks import dockertest
        """
        When the fixture is used in a test, and the fixture has a dependent
        fixture, the dependent fixture should be setup.
        """
        testdir.makeconftest("""
            from seaworthy.definitions import (
                ContainerDefinition, VolumeDefinition)

            class Container(ContainerDefinition):
                def __init__(self, volume, *args, **kwargs):
                    super().__init__(*args, **kwargs)
                    self.volume = volume

            volume = VolumeDefinition('foo')
            volume_fixture = volume.pytest_fixture('foo_volume')
            container_fixture = (
                Container(volume, name='test', image='{}').pytest_fixture(
                    'container', dependencies=('foo_volume',)))
        """.format(IMG))

        testdir.makepyfile("""
            def test_create_container(container):
                assert container.inner().status == 'running'
                assert container.volume.created
        """)

        result = testdir.runpytest()
        result.assert_outcomes(passed=1)



# Path: seaworthy/checks.py
# @contextmanager
# def docker_client():
#     """
#     A context manager that creates and cleans up a Docker API client.
# 
#     In most cases, it's better to use :class:`~seaworthy.helpers.DockerHelper`
#     instead.
#     """
#     client = docker.client.from_env()
#     yield client
#     client.api.close()
# 
# Path: seaworthy/helpers.py
# def fetch_images(client, images):
#     """
#     Fetch images if they aren't already present.
#     """
#     return [fetch_image(client, image) for image in images]
# 
# Path: seaworthy/pytest/checks.py
# def dockertest():
#     """
#     Skip tests that require Docker to be available.
# 
#     This is a function that returns a decorator so that we don't run arbitrary
#     Docker client code on import. Unlike :func:`seaworthy.checks.dockertest`,
#     this implementation doesn't require :class:`unittest.TestCase`. It does,
#     however, require pytest.
#     """
#     return pytest.mark.skipif(
#         not docker_available(), reason='Docker not available.')


# Path: seaworthy/tests-pytest/test_fixtures_pytester.py
from seaworthy.checks import docker_client
from seaworthy.helpers import fetch_images
from seaworthy.pytest.checks import dockertest

        """
        When the fixture is used in a test, and the fixture has a dependent
        fixture, the dependent fixture should be setup.
        """
        testdir.makeconftest("""
            from seaworthy.definitions import (
                ContainerDefinition, VolumeDefinition)

            class Container(ContainerDefinition):
                def __init__(self, volume, *args, **kwargs):
                    super().__init__(*args, **kwargs)
                    self.volume = volume

            volume = VolumeDefinition('foo')
            volume_fixture = volume.pytest_fixture('foo_volume')
            container_fixture = (
                Container(volume, name='test', image='{}').pytest_fixture(
                    'container', dependencies=('foo_volume',)))
        """.format(IMG))

        testdir.makepyfile("""
            def test_create_container(container):
                assert container.inner().status == 'running'
                assert container.volume.created
        """)

        result = testdir.runpytest()
        result.assert_outcomes(passed=1)



@dockertest()