Simple pytest fixture to spin up an HTTP server
Project description
pytest-simplehttpserver
Simple fixture to spin up a simple HTTP server to serve static files for testing.
Can be used for testing web scrapers, etc.
Features
- The fixture spins up a HTTP server that serves static files on port 8000.
Usage
When running your tests you need to point pytest-simplehttpserver to root directory with the static files you want to serve:
$ pytest --simplehttpserver-directory /home/user/mock_website/
In your code, just pass the fixture to your tests:
import requests
def mytest(simplehttpserver):
response = requests.get('http://localhost:8000/')
assert response.status_code == 200
Installation
You can install "pytest-simplehttpserver" via pip from PyPI:
$ pip install pytest-simplehttpserver
Contributing
Contributions are very welcome. Tests can be run with pytest, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the MIT license, "pytest-simplehttpserver" is free and open source software
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 Distribution
Hashes for pytest_simplehttpserver-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb749abee8b224a910b87af33d0c815f3b4f350137841c851634c617cc1b0516 |
|
MD5 | cffcfb463e344e7689a1ac97a9849e02 |
|
BLAKE2b-256 | bfe35f79d269a969e7ba657a09aea391c6b973a52d0263035f64843f7deb283b |
Hashes for pytest_simplehttpserver-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6eff57e2d57a64db0269b939a34bdf97dcd6321b418af761ea5f9685fffd61a |
|
MD5 | a0b7270da564d18cd0f32a837a64024b |
|
BLAKE2b-256 | a291c765cae8581a9ccb4d60c645c5ec7c305e033b9e4dac1e405d2cdfa03c49 |