Use pytest-httpbin and add a test for default User-Agent

This commit is contained in:
Chih-Hsuan Yen 2019-07-06 13:29:01 +08:00
parent 629e82ac8a
commit 851e141f3d
No known key found for this signature in database
GPG Key ID: 0453A6CA23C56315
3 changed files with 11 additions and 6 deletions

View File

@ -8,7 +8,7 @@ python:
- "3.7"
- "nightly"
- "pypy3.6-7.1.1"
install: pip install -U $DEPS pytest pytest-asyncio flaky structlog
install: pip install -U $DEPS pytest pytest-asyncio pytest-httpbin flaky structlog
script: pytest
env:
global:

View File

@ -28,6 +28,7 @@ setup(
tests_require = [
'pytest',
'pytest-asyncio',
'pytest-httpbin',
'flaky',
],
entry_points = {

View File

@ -4,12 +4,16 @@
import pytest
pytestmark = pytest.mark.asyncio
@pytest.mark.skipif(True,
reason='httpbin is overloaded?')
async def test_regex_httpbin(get_version):
async def test_regex_httpbin_default_user_agent(get_version, httpbin):
assert await get_version("example", {
"url": "https://httpbin.org/get",
"regex": r'"User-Agent": "(\w+)"',
"url": httpbin.url + "/get",
"regex": r'"User-Agent":\s*"([^"]+)"',
}) == "lilydjwg/nvchecker"
async def test_regex_httpbin(get_version, httpbin):
assert await get_version("example", {
"url": httpbin.url + "/get",
"regex": r'"User-Agent":\s*"([^"]+)"',
"user_agent": "Meow",
}) == "Meow"