parametrize some tests (#3786)
This commit is contained in:
parent
bdf7083cfd
commit
8c6baeedab
1 changed files with 15 additions and 15 deletions
|
|
@ -895,9 +895,9 @@ class TestStreaming:
|
||||||
|
|
||||||
|
|
||||||
class TestSafeJoin:
|
class TestSafeJoin:
|
||||||
def test_safe_join(self):
|
@pytest.mark.parametrize(
|
||||||
# Valid combinations of *args and expected joined paths.
|
"args, expected",
|
||||||
passing = (
|
(
|
||||||
(("a/b/c",), "a/b/c"),
|
(("a/b/c",), "a/b/c"),
|
||||||
(("/", "a/", "b/", "c/"), "/a/b/c"),
|
(("/", "a/", "b/", "c/"), "/a/b/c"),
|
||||||
(("a", "b", "c"), "a/b/c"),
|
(("a", "b", "c"), "a/b/c"),
|
||||||
|
|
@ -912,14 +912,14 @@ class TestSafeJoin:
|
||||||
# Base directory is always considered safe
|
# Base directory is always considered safe
|
||||||
(("../", "a/b/c"), "../a/b/c"),
|
(("../", "a/b/c"), "../a/b/c"),
|
||||||
(("/..",), "/.."),
|
(("/..",), "/.."),
|
||||||
)
|
),
|
||||||
|
)
|
||||||
|
def test_safe_join(self, args, expected):
|
||||||
|
assert flask.safe_join(*args) == expected
|
||||||
|
|
||||||
for args, expected in passing:
|
@pytest.mark.parametrize(
|
||||||
assert flask.safe_join(*args) == expected
|
"args",
|
||||||
|
(
|
||||||
def test_safe_join_exceptions(self):
|
|
||||||
# Should raise werkzeug.exceptions.NotFound on unsafe joins.
|
|
||||||
failing = (
|
|
||||||
# path.isabs and ``..'' checks
|
# path.isabs and ``..'' checks
|
||||||
("/a", "b", "/c"),
|
("/a", "b", "/c"),
|
||||||
("/a", "../b/c"),
|
("/a", "../b/c"),
|
||||||
|
|
@ -928,11 +928,11 @@ class TestSafeJoin:
|
||||||
("/a", "b/../b/../../c"),
|
("/a", "b/../b/../../c"),
|
||||||
("/a", "b", "c/../.."),
|
("/a", "b", "c/../.."),
|
||||||
("/a", "b/../../c"),
|
("/a", "b/../../c"),
|
||||||
)
|
),
|
||||||
|
)
|
||||||
for args in failing:
|
def test_safe_join_exceptions(self, args):
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
print(flask.safe_join(*args))
|
print(flask.safe_join(*args))
|
||||||
|
|
||||||
|
|
||||||
class TestHelpers:
|
class TestHelpers:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue