Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_simplehttpserver-0.1.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

pytest_simplehttpserver-0.1.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page