parametrize some tests (#3786)

This commit is contained in:
Paul Sanders 2020-10-11 22:16:17 -04:00 committed by GitHub
parent bdf7083cfd
commit 8c6baeedab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: