pytest integration for ngrok.io
Installation
from PyPi
pip install pytest-ngrok
or from git
pip install -e git+https://githib.com/Apkawa/pytest-ngrok.git#egg=pytest-ngrok
Usage
import pytest
from urllib.error import HTTPError
from urllib.request import urlopen
def test_ngrok(ngrok, httpserver):
httpserver.expect_request("/foobar").respond_with_data("ok")
remote_url = ngrok(httpserver.port)
assert urlopen(remote_url + "/foobar").read() == b'ok'
def test_ngrok_context_manager(ngrok, httpserver):
# example local server
httpserver.expect_request("/foobar").respond_with_data("ok")
with ngrok(httpserver.port) as remote_url:
_test_url = str(remote_url) + '/foobar'
assert urlopen(_test_url).read() == b'ok'
# Connection closes
pytest.raises(HTTPError, urlopen, _test_url)
With pytest-django can use fixture live_server_ngrok
def test_server(live_server_ngrok):
assert live_server_ngrok.url.endswith('ngrok.io')
Contributing
Initialize
python -m venv /tmp/.venv/pytest-ngrok
source /tmp/.venv/pytest-ngrok/activate
pip install -r requirements-dev.txt
Run tests
pytest
tox
Update version
python setup.py bumpversion
Publish pypi
python setup.py publish
Metadata
Release files for pytest-ngrok 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest-ngrok-0.0.4.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_ngrok-0.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / pytest-ngrok-0.0.4.tar.gz
| Download URL | pytest-ngrok-0.0.4.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d472b26d965450ef12e6a884895d8d124233e6315352e877c47aedf7a6233e1f
|
|
BLAKE2b-256 checksum How to use checksums |
b3d826933ac9270fae3d55c7acde8897ae1a39892c1da2f291318e7fb6ef0c36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
|
Release files / pytest_ngrok-0.0.4-py2.py3-none-any.whl
| Download URL | pytest_ngrok-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
63f20da1448c4271fe41671a164d7266928d6be6a2b4360383d8d102c368bbe0
|
|
BLAKE2b-256 checksum How to use checksums |
56470d16d3ad10a22c08259ec79f8ce8f83d4139ed69d34b86503ceea6dd94cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
|