]> git.apps.os.sepia.ceph.com Git - s3-tests.git/commitdiff
website: use pytest parametrize for test_routing_generator()
authorCasey Bodley <cbodley@redhat.com>
Wed, 4 Jun 2025 16:31:44 +0000 (12:31 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 4 Jun 2025 22:42:04 +0000 (18:42 -0400)
resolves error with recent pytest:

==================================== ERRORS ====================================
____________ ERROR collecting s3tests/functional/test_s3_website.py ____________
'yield' keyword is allowed in fixtures, but not in tests (test_routing_generator)

use https://docs.pytest.org/en/7.1.x/example/parametrize.html instead to
generate a test_routing_generator() for each entry in ROUTING_RULES_TESTS

Signed-off-by: Casey Bodley <cbodley@redhat.com>
s3tests/functional/test_s3_website.py

index 641cd716b117fd572c0469f737fadd2b14b2d8ac..7831796eee438da08a8f939fb5e9045353e44463 100644 (file)
@@ -1077,8 +1077,8 @@ def routing_check(*args, **kwargs):
 @pytest.mark.s3website_routing_rules
 @pytest.mark.s3website
 @pytest.mark.fails_on_dbstore
-def test_routing_generator():
-    for t in ROUTING_RULES_TESTS:
-        if 'xml' in t and 'RoutingRules' in t['xml'] and len(t['xml']['RoutingRules']) > 0:
-            t['xml']['RoutingRules'] = common.trim_xml(t['xml']['RoutingRules'])
-        yield routing_check, t
+@pytest.mark.parametrize('t', ROUTING_RULES_TESTS)
+def test_routing_generator(t):
+    if 'xml' in t and 'RoutingRules' in t['xml'] and len(t['xml']['RoutingRules']) > 0:
+        t['xml']['RoutingRules'] = common.trim_xml(t['xml']['RoutingRules'])
+    routing_check(t)