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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file pytest_simplehttpserver-0.1.2.tar.gz.

File metadata

  • Download URL: pytest_simplehttpserver-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

File hashes

Hashes for pytest_simplehttpserver-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bb749abee8b224a910b87af33d0c815f3b4f350137841c851634c617cc1b0516
MD5 cffcfb463e344e7689a1ac97a9849e02
BLAKE2b-256 bfe35f79d269a969e7ba657a09aea391c6b973a52d0263035f64843f7deb283b

See more details on using hashes here.

File details

Details for the file pytest_simplehttpserver-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pytest_simplehttpserver-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

File hashes

Hashes for pytest_simplehttpserver-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b6eff57e2d57a64db0269b939a34bdf97dcd6321b418af761ea5f9685fffd61a
MD5 a0b7270da564d18cd0f32a837a64024b
BLAKE2b-256 a291c765cae8581a9ccb4d60c645c5ec7c305e033b9e4dac1e405d2cdfa03c49

See more details on using hashes here.

Supported by

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