Skip to content

Commit

Permalink
Merge pull request #84 from xsnippet/aiohttp-3
Browse files Browse the repository at this point in the history
Use aiohttp_client fixture instead of test_client
  • Loading branch information
malor committed Apr 21, 2018
2 parents 3c8c34c + 5c7409a commit 8306dec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def testdatabase(request, loop, testconf):


@pytest.fixture(scope='function')
async def testapp(request, test_client, testconf, testdatabase):
async def testapp(request, aiohttp_client, testconf, testdatabase):
box = picobox.Box()
box.put('conf', testconf)
box.put('database', testdatabase)
Expand All @@ -46,7 +46,7 @@ async def testapp(request, test_client, testconf, testdatabase):
# This is especially weird as Picobox provides convenient context manager
# and no plain functions, that's why manual triggering is required.
request.addfinalizer(lambda: picobox.pop())
return await test_client(
return await aiohttp_client(
create_app(),

# If 'Content-Type' is not passed to HTTP request, aiohttp client will
Expand Down
4 changes: 2 additions & 2 deletions tests/middlewares/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


@pytest.fixture(scope='function')
async def testapp(test_client):
async def testapp(aiohttp_client):
app = web.Application(middlewares=[
middlewares.auth.auth({'secret': 'SWORDFISH'}),
])
Expand All @@ -35,7 +35,7 @@ async def handler(request):
return web.Response(text='success')
app.router.add_get('/success-no-token', handler)

return await test_client(app)
return await aiohttp_client(app)


@pytest.mark.parametrize('token', [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def post(self):


@pytest.fixture(scope='function')
async def testapp(test_client):
async def testapp(aiohttp_client):
app = web.Application()
app.router.add_route('*', '/test', _TestResource)
app.router.add_route('*', '/test-encoders', _TestEncodersResource)
Expand All @@ -66,7 +66,7 @@ async def testapp(test_client):
# ridiculous because in case of RESTful API this is completely wrong
# and APIs usually have their own defaults. So turn off this feature,
# and do not set 'Content-Type' for us if it wasn't passed.
return await test_client(app, skip_auto_headers={'Content-Type'})
return await aiohttp_client(app, skip_auto_headers={'Content-Type'})


@pytest.mark.parametrize('headers,', [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@pytest.fixture(scope='function')
async def testapp(test_client):
async def testapp(aiohttp_client):
class _TestResource1(web.View):
async def get(self):
return web.Response(text='I am the night!')
Expand All @@ -39,7 +39,7 @@ async def get(self):
default='2',
)
)
return await test_client(app)
return await aiohttp_client(app)


async def test_version_1(testapp):
Expand Down

0 comments on commit 8306dec

Please sign in to comment.