Skip to content

Instantly share code, notes, and snippets.

@philpep
Created July 29, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philpep/6a8d8c6d5d77275fde0680ccc3532e90 to your computer and use it in GitHub Desktop.
Save philpep/6a8d8c6d5d77275fde0680ccc3532e90 to your computer and use it in GitHub Desktop.
testinfra docker jenkins example
import docker
import pytest
import testinfra
@pytest.fixture(scope="module", name="host")
def docker_host():
client = docker.from_env()
container = client.containers.run("jenkins", detach=True)
yield testinfra.get_host("docker://{}".format(container.id))
container.remove(force=True)
def test_current_user_is_jenkins(host):
assert host.user().name == "jenkins"
assert host.user().group == "jenkins"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment