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:
|
||||
def test_safe_join(self):
|
||||
# Valid combinations of *args and expected joined paths.
|
||||
passing = (
|
||||
@pytest.mark.parametrize(
|
||||
"args, expected",
|
||||
(
|
||||
(("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
|
||||
(("../", "a/b/c"), "../a/b/c"),
|
||||
(("/..",), "/.."),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_safe_join(self, args, expected):
|
||||
assert flask.safe_join(*args) == expected
|
||||
|
||||
for args, expected in passing:
|
||||
assert flask.safe_join(*args) == expected
|
||||
|
||||
def test_safe_join_exceptions(self):
|
||||
# Should raise werkzeug.exceptions.NotFound on unsafe joins.
|
||||
failing = (
|
||||
@pytest.mark.parametrize(
|
||||
"args",
|
||||
(
|
||||
# path.isabs and ``..'' checks
|
||||
("/a", "b", "/c"),
|
||||
("/a", "../b/c"),
|
||||
|
|
@ -928,11 +928,11 @@ class TestSafeJoin:
|
|||
("/a", "b/../b/../../c"),
|
||||
("/a", "b", "c/../.."),
|
||||
("/a", "b/../../c"),
|
||||
)
|
||||
|
||||
for args in failing:
|
||||
with pytest.raises(NotFound):
|
||||
print(flask.safe_join(*args))
|
||||
),
|
||||
)
|
||||
def test_safe_join_exceptions(self, args):
|
||||
with pytest.raises(NotFound):
|
||||
print(flask.safe_join(*args))
|
||||
|
||||
|
||||
class TestHelpers:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue