UNKNOWN
Project description
Description
Simple py.test fixtures for writing integration tests based on Docker containers. Specify all containers you need and pytest-docker will use Docker Compose to spin them up for the duration of your test suite.
Usage
Here is the basic recipe for writing a test that depends on a service that responds over HTTP:
import pytest import requests from requests.exceptions import ( ConnectionError, ) def is_responsive(url): """Check if something responds to ``url``.""" try: response = requests.get(url) if response.status_code == 200: return True except ConnectionError: return False @pytest.fixture(scope='session') def some_http_service(docker_ip, docker_services): """Ensure that "some service" is up and responsive.""" url = 'http://' % ( docker_ip, docker_services.port_for('abc', 123), ) docker_services.wait_until_responsive( timeout=30.0, pause=0.1, check=lambda: is_responsive(url) ) return url def test_something(some_service): """Sample test.""" response = requests.get(some_service) response.raise_for_status()
Contributing
This py.test plug-in and its source code are made available to your under and MIT license. It is safe to use in commercial and closed-source applications. Read the license for details!
Found a bug? Think a new feature would make this plug-in more practical? No one is paid to support this software, but we welcome pull requests!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pytest-docker-0.1.0.tar.gz
.
File metadata
- Download URL: pytest-docker-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a4aecad78e5e92232a2a4bb22c1019e55d6673307cba10ac6850aea23b65b78 |
|
MD5 | 36a4d25d2aa145126faaa7121342567c |
|
BLAKE2b-256 | 6c33d2dc881fcc9ba601f8e7743f3de2b5f057685320f1faabb452af3a3e3f4d |
File details
Details for the file pytest_docker-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_docker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e2fe0f4ffa167f8a8cf6af4c5e9872ed0124950ec149da0a3e1e570f5eddf00 |
|
MD5 | afe5eae206327547469520ec2e648f86 |
|
BLAKE2b-256 | ea9cba751acf697dd5c0cfb1fdbbfe03161ba5adf6932f04ca998a9a19ba5785 |
File details
Details for the file pytest_docker-0.1.0-py2-none-any.whl
.
File metadata
- Download URL: pytest_docker-0.1.0-py2-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1983a61a228e445697e10245556d423dede643c4a8f8da3a7fb04da1678aeffb |
|
MD5 | 876ae82fa39ee830a88fce04ed327505 |
|
BLAKE2b-256 | 03b51818451f48d9ce3d3bb6ac17ba71737eb4a2bbb405df8ccac0ae3fc6a0a7 |