Skip to content

Commit d2f8ae1

Browse files
authored
Merge pull request #60 from allanlewis/pep8-typos-etc
Fix some typos and conform to PEP 8
2 parents 7fed6f6 + ea02f13 commit d2f8ae1

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

pytest_flask/fixtures.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import socket
77

88
try:
9-
from urllib2 import urlopen
9+
from urllib2 import URLError, urlopen
1010
except ImportError:
11+
from urllib.error import URLError
1112
from urllib.request import urlopen
1213

1314
from flask import _request_ctx_stack
@@ -34,7 +35,7 @@ def login(self, email, password):
3435
return self.client.post(url_for('login'), data=credentials)
3536
3637
def test_login(self):
37-
assert self.login('vital@example.com', 'pass').status_code == 200
38+
assert self.login('foo@example.com', 'pass').status_code == 200
3839
3940
"""
4041
if request.cls is not None:
@@ -72,7 +73,7 @@ def worker(app, port):
7273
try:
7374
urlopen(self.url())
7475
timeout = 0
75-
except:
76+
except URLError:
7677
timeout -= 1
7778

7879
def url(self, url=''):
@@ -100,7 +101,7 @@ def _rewrite_server_name(server_name, new_port):
100101
def live_server(request, app, monkeypatch):
101102
"""Run application in a separate process.
102103
103-
When the ``live_server`` fixture is applyed, the ``url_for`` function
104+
When the ``live_server`` fixture is applied, the ``url_for`` function
104105
works as expected::
105106
106107
def test_server_is_up_and_running(live_server):

pytest_flask/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_app(app, client):
7979
app = getfixturevalue(request, 'app')
8080

8181
# Get application bound to the live server if ``live_server`` fixture
82-
# is applyed. Live server application has an explicit ``SERVER_NAME``,
82+
# is applied. Live server application has an explicit ``SERVER_NAME``,
8383
# so ``url_for`` function generates a complete URL for endpoint which
8484
# includes application port as well.
8585
if 'live_server' in request.fixturenames:
@@ -119,11 +119,11 @@ def pytest_addoption(parser):
119119
group.addoption('--start-live-server',
120120
action="store_true", dest="start_live_server", default=True,
121121
help="start server automatically when live_server "
122-
"fixture is applyed (enabled by default).")
122+
"fixture is applied (enabled by default).")
123123
group.addoption('--no-start-live-server',
124124
action="store_false", dest="start_live_server",
125125
help="don't start server automatically when live_server "
126-
"fixture is applyed.")
126+
"fixture is applied.")
127127

128128

129129
def pytest_configure(config):

tests/test_fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_request_ctx(self, app, request_ctx):
2323
assert request_ctx.app is app
2424

2525
def test_request_ctx_is_kept_around(self, client):
26-
res = client.get(url_for('index'), headers=[('X-Something', '42')])
26+
client.get(url_for('index'), headers=[('X-Something', '42')])
2727
assert request.headers['X-Something'] == '42'
2828

2929

@@ -37,7 +37,7 @@ def test_dont_rewrite_existing_implementation(self, app, accept_json):
3737
class MyResponse(app.response_class):
3838
@property
3939
def json(self):
40-
'''What is the meaning of life, the universe and everything?'''
40+
"""What is the meaning of life, the universe and everything?"""
4141
return 42
4242

4343
app.response_class = MyResponse

tests/test_live_server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,26 @@ def test_server_is_alive(self, live_server):
1717

1818
def test_server_url(self, live_server):
1919
assert live_server.url() == 'http://localhost:%d' % live_server.port
20-
assert live_server.url('/ping') == 'http://localhost:%d/ping' % live_server.port
20+
assert live_server.url('/ping') == \
21+
'http://localhost:%d/ping' % live_server.port
2122

2223
def test_server_listening(self, live_server):
2324
res = urlopen(live_server.url('/ping'))
2425
assert res.code == 200
2526
assert b'pong' in res.read()
2627

2728
def test_url_for(self, live_server):
28-
assert url_for('ping', _external=True) == 'http://localhost:%s/ping' % live_server.port
29+
assert url_for('ping', _external=True) == \
30+
'http://localhost:%s/ping' % live_server.port
2931

3032
def test_set_application_server_name(self, live_server):
31-
assert live_server.app.config['SERVER_NAME'] == 'localhost:%d' % live_server.port
33+
assert live_server.app.config['SERVER_NAME'] == \
34+
'localhost:%d' % live_server.port
3235

3336
@pytest.mark.options(server_name='example.com:5000')
3437
def test_rewrite_application_server_name(self, live_server):
35-
assert live_server.app.config['SERVER_NAME'] == 'example.com:%d' % live_server.port
38+
assert live_server.app.config['SERVER_NAME'] == \
39+
'example.com:%d' % live_server.port
3640

3741
def test_prevent_starting_live_server(self, appdir):
3842
appdir.create_test_module('''

0 commit comments

Comments
 (0)