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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | df69999f5b4aa2e5792ed0e83c32d5f7052e5be675777dbbb5a4f5ca83a8fba5 |
|
MD5 | f59067bc37af5025460fe543a9190078 |
|
BLAKE2b-256 | a3dd2c8855ccd2081194a69cf09945e6b42143dff82ac58cbe7de1c728fdbefb |
Hashes for pytest_simplehttpserver-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbc6d56629b9d06f82762388f2653112bbb4ed81d85bd045083a30c8b9755d0c |
|
MD5 | 8b4cb65d5209f95f8a97b580220088dc |
|
BLAKE2b-256 | a3ddafb62be3920dcde166d8fd062a26374a598ead711d32371f8e58f3641713 |