diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2023-06-12 14:16:59 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2023-06-12 14:16:59 +0100 |
commit | ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4 (patch) | |
tree | 818e60eb10d7f2be90f25003b3a2b347314e966f /test/test_routing.py | |
parent | a3b9b49cfb091410ca8f3c8d9df24d1fe184f8e0 (diff) | |
download | unit-ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4.tar.gz unit-ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4.tar.bz2 |
Tests: prerequisites checking reworked.
Prerequisites check moved to the module level to simplify class structure.
Discovery and prerequisites checks functions moved to the separate files.
Introduced "require" fixture to provide per-test requirements check.
Diffstat (limited to 'test/test_routing.py')
-rw-r--r-- | test/test_routing.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/test/test_routing.py b/test/test_routing.py index 41de6f51..715033dd 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -3,10 +3,10 @@ import pytest from unit.applications.lang.python import TestApplicationPython from unit.option import option +prerequisites = {'modules': {'python': 'any'}} -class TestRouting(TestApplicationPython): - prerequisites = {'modules': {'python': 'any'}} +class TestRouting(TestApplicationPython): @pytest.fixture(autouse=True) def setup_method_fixture(self): assert 'success' in self.conf( @@ -232,9 +232,8 @@ class TestRouting(TestApplicationPython): assert self.get(url='/aBCaBbc')['status'] == 200 assert self.get(url='/ABc')['status'] == 404 - def test_routes_empty_regex(self): - if not option.available['modules']['regex']: - pytest.skip('requires regex') + def test_routes_empty_regex(self, require): + require({'modules': {'regex': True}}) self.route_match({"uri": "~"}) assert self.get(url='/')['status'] == 200, 'empty regexp' @@ -244,9 +243,8 @@ class TestRouting(TestApplicationPython): assert self.get(url='/')['status'] == 404, 'empty regexp 2' assert self.get(url='/nothing')['status'] == 404, '/nothing' - def test_routes_bad_regex(self): - if not option.available['modules']['regex']: - pytest.skip('requires regex') + def test_routes_bad_regex(self, require): + require({'modules': {'regex': True}}) assert 'error' in self.route( {"match": {"uri": "~/bl[ah"}, "action": {"return": 200}} @@ -264,9 +262,8 @@ class TestRouting(TestApplicationPython): if 'error' not in status: assert self.get(url='/nothing_z')['status'] == 500, '/nothing_z' - def test_routes_match_regex_case_sensitive(self): - if not option.available['modules']['regex']: - pytest.skip('requires regex') + def test_routes_match_regex_case_sensitive(self, require): + require({'modules': {'regex': True}}) self.route_match({"uri": "~/bl[ah]"}) @@ -275,9 +272,8 @@ class TestRouting(TestApplicationPython): assert self.get(url='/blh')['status'] == 200, '/blh' assert self.get(url='/BLAH')['status'] == 404, '/BLAH' - def test_routes_match_regex_negative_case_sensitive(self): - if not option.available['modules']['regex']: - pytest.skip('requires regex') + def test_routes_match_regex_negative_case_sensitive(self, require): + require({'modules': {'regex': True}}) self.route_match({"uri": "!~/bl[ah]"}) |