Skip to content

Commit

Permalink
Optimize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Aug 22, 2019
1 parent 3b001e7 commit 0eb52f6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import bddrest
import pytest

from nanohttp import Application


@pytest.fixture
def app():
return Application()


@pytest.fixture
def session():
Expand Down
23 changes: 8 additions & 15 deletions tests/test_application.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
from bddrest import status, response

from nanohttp import Application

def test_pipeline(app, session, when):
@app.route('/foos')
def get():
return 'foo1, foo2, foo3'

app = Application()
@app.route('/')
def get():
app.response.headers.add('x-foo', 'a', 'b')
return 'index'


@app.route('/foos')
def get():
return 'foo1, foo2, foo3'


@app.route('/')
def get():
app.response.headers.add('x-foo', 'a', 'b')
return 'index'


def test_pipeline(session, when):
with session(app):
assert status == 200
assert response == 'index'
Expand Down
5 changes: 2 additions & 3 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from bddrest import status, response

from nanohttp import Application, statuses
from nanohttp import statuses


def test_httpstatus(session):
app = Application()
def test_httpstatus(app, session):

@app.route('/')
def get():
Expand Down
6 changes: 1 addition & 5 deletions tests/test_responseheaders.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from bddrest import status, response

from nanohttp import Application


def test_responseheader(session):
app = Application()
def test_responseheader(app, session):

@app.route()
def get():
app.response.headers.add('x-foo', 'a', 'b')
return 'index'


with session(app):
assert status == 200
assert response.headers['x-foo'] == 'a; b'
Expand Down
8 changes: 2 additions & 6 deletions tests/test_routing.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from bddrest import status, response

from nanohttp import Application


def test_routing_basic(session, when):
app = Application()
def test_routing_basic(app, session, when):

@app.route()
def get():
Expand All @@ -29,8 +26,7 @@ def post():
assert status == 404


def test_routing_argument(session, when):
app = Application()
def test_routing_argument(app, session, when):

@app.route(r'/(\d+)')
def get(id):
Expand Down

0 comments on commit 0eb52f6

Please sign in to comment.