diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 873a06c7..5af67e6e 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -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: