tests: Strip trailing slash for webserver paths.

This commit is contained in:
Florian Bruhin 2015-11-25 10:36:27 +01:00
parent 24a71e5c2e
commit 7cfea665ff
2 changed files with 6 additions and 1 deletions

View File

@ -53,6 +53,9 @@ def test_httpbin(httpbin, qtbot, path, content, expected):
@pytest.mark.parametrize('line, verb, path, equal', [ @pytest.mark.parametrize('line, verb, path, equal', [
('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET / HTTP/1.1" 200 -', ('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET / HTTP/1.1" 200 -',
'GET', '/', True), 'GET', '/', True),
('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET /foo/ HTTP/1.1" 200 -',
'GET', '/foo', True),
('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET / HTTP/1.1" 200 -', ('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET / HTTP/1.1" 200 -',
'GET', '/foo', False), 'GET', '/foo', False),
('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET / HTTP/1.1" 200 -', ('127.0.0.1 - - [01/Jan/1990 00:00:00] "GET / HTTP/1.1" 200 -',

View File

@ -73,7 +73,9 @@ class Request(testprocess.Line):
assert match.group('protocol') == 'HTTP/1.1' assert match.group('protocol') == 'HTTP/1.1'
assert self.verb == 'GET' assert self.verb == 'GET'
self.path = match.group('path') path = match.group('path')
self.path = '/' if path == '/' else path.rstrip('/')
self.status = int(match.group('status')) self.status = int(match.group('status'))
missing_paths = ['/favicon.ico', '/does-not-exist'] missing_paths = ['/favicon.ico', '/does-not-exist']