mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 14:50:19 +00:00
Merge pull request #296 from taoufik07/travis_black_check
This commit is contained in:
@@ -10,3 +10,4 @@ install:
|
||||
# command to run the dependencies
|
||||
script:
|
||||
- "pytest"
|
||||
- "black responder tests setup.py --check"
|
||||
|
||||
+3
-5
@@ -251,9 +251,7 @@ class API:
|
||||
cont = True
|
||||
except Exception:
|
||||
self.background(
|
||||
self.default_response,
|
||||
websocket=route.uses_websocket,
|
||||
error=True
|
||||
self.default_response, websocket=route.uses_websocket, error=True
|
||||
)
|
||||
raise
|
||||
|
||||
@@ -658,6 +656,6 @@ class API:
|
||||
spawn()
|
||||
|
||||
def run(self, **kwargs):
|
||||
if 'debug' not in kwargs:
|
||||
kwargs.update({'debug': self.debug})
|
||||
if "debug" not in kwargs:
|
||||
kwargs.update({"debug": self.debug})
|
||||
self.serve(**kwargs)
|
||||
|
||||
+1
-1
@@ -40,4 +40,4 @@ def cli():
|
||||
prop = "api"
|
||||
|
||||
app = __import__(module)
|
||||
getattr(app, prop).run()
|
||||
getattr(app, prop).run()
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ class Route:
|
||||
def _weight(self):
|
||||
params = set(self._param_pattern.findall(self.route))
|
||||
params_count = len(params)
|
||||
w = len(self.route.rsplit('}', 1)[-1].strip('/'))
|
||||
w = len(self.route.rsplit("}", 1)[-1].strip("/"))
|
||||
return params_count != 0, w == 0, -params_count
|
||||
|
||||
@property
|
||||
|
||||
@@ -4,11 +4,11 @@ DEFAULT_SESSION_COOKIE = "Responder-Session"
|
||||
DEFAULT_SECRET_KEY = "NOTASECRET"
|
||||
|
||||
DEFAULT_CORS_PARAMS = {
|
||||
"allow_origins": (),
|
||||
"allow_methods": ("GET",),
|
||||
"allow_headers": (),
|
||||
"allow_credentials": False,
|
||||
"allow_origin_regex": None,
|
||||
"expose_headers": (),
|
||||
"max_age": 600,
|
||||
"allow_origins": (),
|
||||
"allow_methods": ("GET",),
|
||||
"allow_headers": (),
|
||||
"allow_credentials": False,
|
||||
"allow_origin_regex": None,
|
||||
"expose_headers": (),
|
||||
"max_age": 600,
|
||||
}
|
||||
|
||||
+2
-4
@@ -18,10 +18,7 @@ def current_dir():
|
||||
|
||||
@pytest.fixture
|
||||
def api():
|
||||
return responder.API(
|
||||
debug=False,
|
||||
allowed_hosts=[";"]
|
||||
)
|
||||
return responder.API(debug=False, allowed_hosts=[";"])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -49,6 +46,7 @@ def flask():
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def schema():
|
||||
class Query(graphene.ObjectType):
|
||||
|
||||
@@ -479,8 +479,9 @@ def test_500(api):
|
||||
def view(req, resp):
|
||||
raise ValueError
|
||||
|
||||
dumb_client = responder.api.TestClient(api, base_url="http://;",
|
||||
raise_server_exceptions=False)
|
||||
dumb_client = responder.api.TestClient(
|
||||
api, base_url="http://;", raise_server_exceptions=False
|
||||
)
|
||||
r = dumb_client.get(api.url_for(view))
|
||||
assert not r.ok
|
||||
assert r.status_code == responder.status_codes.HTTP_500
|
||||
|
||||
+25
-9
@@ -89,25 +89,41 @@ def test_does_match_with_route(route, match, expected):
|
||||
[
|
||||
pytest.param("/{greetings}", (True, True, -1), id="with one param"),
|
||||
pytest.param(
|
||||
"/{greetings}.{name}", (True, True, -2), id="with 2 params and dot in the middle"
|
||||
"/{greetings}.{name}",
|
||||
(True, True, -2),
|
||||
id="with 2 params and dot in the middle",
|
||||
),
|
||||
pytest.param("/{greetings}/{name}", (True, True, -2), id="with 2 params and subpath"),
|
||||
pytest.param(
|
||||
"/{greetings}/{name}/{hello}", (True, True, -3), id="with 3 params and subpath"
|
||||
"/{greetings}/{name}", (True, True, -2), id="with 2 params and subpath"
|
||||
),
|
||||
pytest.param(
|
||||
"/{greetings}/{name}/{hello}",
|
||||
(True, True, -3),
|
||||
id="with 3 params and subpath",
|
||||
),
|
||||
pytest.param(
|
||||
"/{greetings}_{name}", (True, True, -2), id="with 2 params and underscore"
|
||||
),
|
||||
pytest.param("/{greetings}/test", (True, False, -1), id="with one param"),
|
||||
pytest.param(
|
||||
"/{greetings}.{name}/test", (True, False, -2), id="with 2 params and dot in the middle"
|
||||
),
|
||||
pytest.param("/{greetings}/{name}/test", (True, False, -2), id="with 2 params and subpath"),
|
||||
pytest.param(
|
||||
"/{greetings}/{name}/{hello}/test", (True, False, -3), id="with 3 params and subpath"
|
||||
"/{greetings}.{name}/test",
|
||||
(True, False, -2),
|
||||
id="with 2 params and dot in the middle",
|
||||
),
|
||||
pytest.param(
|
||||
"/{greetings}_{name}/test", (True, False, -2), id="with 2 params and underscore"
|
||||
"/{greetings}/{name}/test",
|
||||
(True, False, -2),
|
||||
id="with 2 params and subpath",
|
||||
),
|
||||
pytest.param(
|
||||
"/{greetings}/{name}/{hello}/test",
|
||||
(True, False, -3),
|
||||
id="with 3 params and subpath",
|
||||
),
|
||||
pytest.param(
|
||||
"/{greetings}_{name}/test",
|
||||
(True, False, -2),
|
||||
id="with 2 params and underscore",
|
||||
),
|
||||
pytest.param("/hello", (False, False, 0), id="without params"),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user