No project description provided
Project description
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
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-ngrok-0.0.3.tar.gz
(5.2 kB
view details)
File details
Details for the file pytest-ngrok-0.0.3.tar.gz
.
File metadata
- Download URL: pytest-ngrok-0.0.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cafd0fa0c0418d5e5922aceb2abea3a2d083c9498f727f0d7cdace2f8c5d0d5b |
|
MD5 | 61951cb15718c812b7f79000716b90e0 |
|
BLAKE2b-256 | 43724780ff1e10a45df8a9585136d392ae3e8e8027e5eefec9a99a9c0d3ef6ca |