Skip to content

Commit

Permalink
Use pytest-httpbin and add a test for default User-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Chih-Hsuan Yen committed Jul 6, 2019
1 parent 8b9e346 commit 3d5ab61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
tests_require = [
'pytest',
'pytest-asyncio',
'pytest-httpbin',
'flaky',
],
entry_points = {
Expand Down
14 changes: 9 additions & 5 deletions tests/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*"(\w+)"',
"user_agent": "Meow",
}) == "Meow"

Expand Down

0 comments on commit 3d5ab61

Please sign in to comment.