From ae2fcf05a4d7c033d2a80a6f213fc528c6d20ab4 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 13 Nov 2026 21:42:18 +0000 Subject: [PATCH] Fix the warnings pytest reports for the test suites: * test/modules/*/test_*.py, test/modules/arch/linux/test_*.py: Make class-scoped fixtures class methods. * test/modules/http2/test_800_websockets.py (TestWebSockets.ws_check_alive, TestWebSockets._mkpath, TestWebSockets._rmrf), test/modules/md/test_801_stapling.py (TestStapling.configure_httpd): Make static methods. * test/modules/http2/test_108_goaway.py (TestGoaway.test_h2_108_01_idle_timeout): Don't use an empty usefixtures() mark as the no-op decorator. * test/pytest_suite/tests/t/modules/test_proxy_beacon_input.py: Pass lists to parametrize. * test/pytest_suite/tests/t/apache/test_http_strict.py: Send "@" rather than "\@" in the userinfo request, as the Perl original did. * test/pytest_suite/tests/t/modules/test_access.py: Drop invalid escape from docstring. Co-Authored-By: Claude Fable 5.2 --- test/modules/arch/linux/test_001_notify.py | 3 ++- test/modules/arch/linux/test_002_monitor.py | 10 +++++---- .../arch/linux/test_003_extended_status.py | 3 ++- .../arch/linux/test_004_socket_activation.py | 3 ++- test/modules/arch/linux/test_005_service.py | 3 ++- test/modules/arch/linux/test_006_watchdog.py | 3 ++- .../arch/linux/test_007_notify_reload.py | 3 ++- test/modules/core/test_001_encoding.py | 3 ++- test/modules/core/test_003_cgi_env_vars.py | 3 ++- test/modules/core/test_004_ssi.py | 3 ++- test/modules/core/test_005_userdir_headers.py | 3 ++- test/modules/core/test_006_merge_lang.py | 3 ++- test/modules/core/test_007_cgi_redirect.py | 3 ++- test/modules/core/test_008_restart.py | 3 ++- test/modules/core/test_009_allow_methods.py | 3 ++- test/modules/core/test_014_cond_precedence.py | 3 ++- .../core/test_015_errdoc_recursive_text.py | 3 ++- test/modules/dav/test_001_propdb_ns_limit.py | 3 ++- test/modules/dav/test_002_options_trace.py | 6 ++++-- .../dav/test_004_lock_timeout_overflow.py | 3 ++- test/modules/dav/test_004_operations.py | 3 ++- test/modules/dav/test_005_if_header.py | 3 ++- .../filters/test_001_substitute_maxlen.py | 3 ++- test/modules/filters/test_003_sed.py | 21 ++++++++++--------- .../filters/test_004_brotli_compression.py | 3 ++- test/modules/generators/test_001_cgid.py | 7 ++++--- test/modules/generators/test_002_autoindex.py | 3 ++- test/modules/http1/test_001_alive.py | 3 ++- test/modules/http1/test_003_get.py | 3 ++- test/modules/http1/test_004_post.py | 3 ++- test/modules/http1/test_005_trailers.py | 3 ++- test/modules/http1/test_006_unsafe.py | 3 ++- test/modules/http1/test_007_strict.py | 3 ++- test/modules/http2/test_001_httpd_alive.py | 3 ++- test/modules/http2/test_002_curl_basics.py | 3 ++- test/modules/http2/test_003_get.py | 3 ++- test/modules/http2/test_004_post.py | 3 ++- test/modules/http2/test_005_files.py | 5 +++-- test/modules/http2/test_006_assets.py | 3 ++- test/modules/http2/test_007_ssi.py | 3 ++- test/modules/http2/test_008_ranges.py | 3 ++- test/modules/http2/test_009_timing.py | 3 ++- test/modules/http2/test_100_conn_reuse.py | 3 ++- test/modules/http2/test_101_ssl_reneg.py | 3 ++- test/modules/http2/test_102_require.py | 3 ++- test/modules/http2/test_103_upgrade.py | 3 ++- test/modules/http2/test_104_padding.py | 3 ++- test/modules/http2/test_106_shutdown.py | 3 ++- test/modules/http2/test_107_frame_lengths.py | 5 +++-- test/modules/http2/test_108_goaway.py | 5 +++-- .../http2/test_111_header_limit_log.py | 3 ++- .../http2/test_112_ssl_verify_client_authz.py | 6 ++++-- test/modules/http2/test_200_header_invalid.py | 3 ++- .../http2/test_201_header_conditional.py | 3 ++- test/modules/http2/test_202_trailer.py | 3 ++- test/modules/http2/test_203_rfc9113.py | 3 ++- test/modules/http2/test_300_interim.py | 3 ++- test/modules/http2/test_400_push.py | 3 ++- test/modules/http2/test_401_early_hints.py | 3 ++- test/modules/http2/test_500_proxy.py | 3 ++- .../http2/test_501_proxy_serverheader.py | 3 ++- test/modules/http2/test_502_proxy_port.py | 3 ++- test/modules/http2/test_503_proxy_fwd.py | 1 + .../modules/http2/test_601_h2proxy_twisted.py | 3 ++- test/modules/http2/test_700_load_get.py | 3 ++- .../http2/test_710_load_post_static.py | 3 ++- test/modules/http2/test_711_load_post_cgi.py | 3 ++- test/modules/http2/test_712_buffering.py | 3 ++- test/modules/http2/test_800_websockets.py | 21 ++++++++++++------- test/modules/http3/test_003_access.py | 6 ++++-- test/modules/mappers/test_001_rewrite.py | 9 +++++--- test/modules/md/test_010_store_migrate.py | 3 ++- test/modules/md/test_202_acmev2_regs.py | 3 ++- test/modules/md/test_300_conf_validate.py | 3 ++- test/modules/md/test_310_conf_store.py | 3 ++- test/modules/md/test_502_acmev2_drive.py | 3 ++- test/modules/md/test_602_roundtrip.py | 3 ++- test/modules/md/test_702_auto.py | 3 ++- test/modules/md/test_710_profiles.py | 3 ++- test/modules/md/test_720_wildcard.py | 3 ++- test/modules/md/test_721_dns01.py | 3 ++- test/modules/md/test_730_static.py | 3 ++- test/modules/md/test_740_acme_errors.py | 3 ++- test/modules/md/test_741_setup_errors.py | 3 ++- test/modules/md/test_750_eab.py | 3 ++- test/modules/md/test_751_sectigo.py | 3 ++- test/modules/md/test_752_zerossl.py | 3 ++- test/modules/md/test_790_failover.py | 3 ++- test/modules/md/test_800_must_staple.py | 3 ++- test/modules/md/test_801_stapling.py | 10 +++++---- test/modules/md/test_810_ec.py | 3 ++- test/modules/md/test_820_locks.py | 3 ++- test/modules/md/test_900_notify.py | 3 ++- test/modules/md/test_901_message.py | 3 ++- test/modules/md/test_910_cleanups.py | 3 ++- test/modules/md/test_920_status.py | 3 ++- test/modules/metadata/test_001_mime_magic.py | 3 ++- .../metadata/test_002_mime_libmagic.py | 6 ++++-- .../metadata/test_002_setenvfromfile.py | 9 +++++--- test/modules/metadata/test_003_compare.py | 3 ++- test/modules/proxy/test_01_http.py | 3 ++- test/modules/proxy/test_02_unix.py | 3 ++- test/modules/proxy/test_03_response.py | 3 ++- test/modules/proxy/test_04_ajp.py | 3 ++- test/modules/proxy/test_05_uwsgi.py | 3 ++- test/modules/proxy/test_06_interim_resp.py | 3 ++- test/modules/proxy/test_07_cache_control.py | 3 ++- test/modules/proxy/test_09_hcheck_log_uri.py | 3 ++- .../session/test_001_session_expiry.py | 3 ++- test/modules/ssl/test_001_sni.py | 5 +++-- test/modules/ssl/test_002_tls13.py | 3 ++- .../ssl/test_003_verify_client_perdir.py | 3 ++- test/modules/ssl/test_004_socache_redis.py | 3 ++- test/modules/ssl/test_005_vhost_compat.py | 6 ++++-- .../tests/t/apache/test_http_strict.py | 2 +- .../tests/t/modules/test_access.py | 2 +- .../t/modules/test_proxy_beacon_input.py | 10 ++++----- 117 files changed, 286 insertions(+), 157 deletions(-) diff --git a/test/modules/arch/linux/test_001_notify.py b/test/modules/arch/linux/test_001_notify.py index cb38b29cc5a..b4893cab84c 100644 --- a/test/modules/arch/linux/test_001_notify.py +++ b/test/modules/arch/linux/test_001_notify.py @@ -13,7 +13,8 @@ class TestSystemdNotify: across the server lifecycle.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env) conf.add_vhost_test1() conf.install() diff --git a/test/modules/arch/linux/test_002_monitor.py b/test/modules/arch/linux/test_002_monitor.py index c032f2baa3a..800abfefdd2 100644 --- a/test/modules/arch/linux/test_002_monitor.py +++ b/test/modules/arch/linux/test_002_monitor.py @@ -15,7 +15,8 @@ class TestSystemdMonitor: "systemctl status httpd" shows below the unit description.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ 'base': """ @@ -42,7 +43,8 @@ def wait_report(env, above=-1): return MONITOR_STATUS.match(msg['STATUS']) @pytest.fixture(scope='class') - def reports(self, env, _class_scope): + @classmethod + def reports(cls, env, _class_scope): """Two consecutive reports with requests served between them, and the mod_status report as of the second. @@ -51,11 +53,11 @@ def reports(self, env, _class_scope): below share one pair rather than each waiting for its own. """ env.notify.clear() - first = self.wait_report(env) + first = cls.wait_report(env) for _ in range(10): r = env.curl_get(env.mkurl("http", "test1", "/")) assert r.response['status'] == 200 - second = self.wait_report(env, above=int(first.group('requests'))) + second = cls.wait_report(env, above=int(first.group('requests'))) r = env.curl_get(env.mkurl("http", "test1", "/server-status?auto")) assert r.response['status'] == 200 auto = {} diff --git a/test/modules/arch/linux/test_003_extended_status.py b/test/modules/arch/linux/test_003_extended_status.py index 11d619fe31c..6f8a948c903 100644 --- a/test/modules/arch/linux/test_003_extended_status.py +++ b/test/modules/arch/linux/test_003_extended_status.py @@ -13,7 +13,8 @@ class TestSystemdExtendedStatus: report, which changes what the rest of the server records too.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): yield conf = HttpdConf(env) conf.add_vhost_test1() diff --git a/test/modules/arch/linux/test_004_socket_activation.py b/test/modules/arch/linux/test_004_socket_activation.py index 5c08c4bed1b..27d31a274af 100644 --- a/test/modules/arch/linux/test_004_socket_activation.py +++ b/test/modules/arch/linux/test_004_socket_activation.py @@ -20,7 +20,8 @@ class TestSystemdSocketActivation: """ @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # The activated servers use the same server root; keep the one # started by other tests out of the way. assert env.apache_stop() == 0 diff --git a/test/modules/arch/linux/test_005_service.py b/test/modules/arch/linux/test_005_service.py index abb3a85b087..7dc9d4564a0 100644 --- a/test/modules/arch/linux/test_005_service.py +++ b/test/modules/arch/linux/test_005_service.py @@ -24,7 +24,8 @@ class TestSystemdService: """ @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): assert env.apache_stop() == 0 yield assert env.apache_stop() == 0 diff --git a/test/modules/arch/linux/test_006_watchdog.py b/test/modules/arch/linux/test_006_watchdog.py index a234f849029..c09eea0db04 100644 --- a/test/modules/arch/linux/test_006_watchdog.py +++ b/test/modules/arch/linux/test_006_watchdog.py @@ -42,7 +42,8 @@ class TestSystemdWatchdog: """ @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # These run their own servers on the second port; the shared one # would only add its notifications to the same socket. assert env.apache_stop() == 0 diff --git a/test/modules/arch/linux/test_007_notify_reload.py b/test/modules/arch/linux/test_007_notify_reload.py index 20f7eb40d16..1629506568a 100644 --- a/test/modules/arch/linux/test_007_notify_reload.py +++ b/test/modules/arch/linux/test_007_notify_reload.py @@ -52,7 +52,8 @@ class TestNotifyReload: """ @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): assert env.apache_stop() == 0 yield assert env.apache_stop() == 0 diff --git a/test/modules/core/test_001_encoding.py b/test/modules/core/test_001_encoding.py index 5dff5d813fe..75ca9fdd6c7 100644 --- a/test/modules/core/test_001_encoding.py +++ b/test/modules/core/test_001_encoding.py @@ -7,7 +7,8 @@ class TestEncoding: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ 'base': f""" diff --git a/test/modules/core/test_003_cgi_env_vars.py b/test/modules/core/test_003_cgi_env_vars.py index f82a5c3764e..11f3c7d2170 100644 --- a/test/modules/core/test_003_cgi_env_vars.py +++ b/test/modules/core/test_003_cgi_env_vars.py @@ -5,7 +5,8 @@ class TestCGIEnvVars: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ 'base': f""" diff --git a/test/modules/core/test_004_ssi.py b/test/modules/core/test_004_ssi.py index 672297bee1f..209557759e7 100644 --- a/test/modules/core/test_004_ssi.py +++ b/test/modules/core/test_004_ssi.py @@ -9,7 +9,8 @@ class TestSSIInjection: @pytest.fixture(autouse=True, scope="class") - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ "base": textwrap.dedent(f""" diff --git a/test/modules/core/test_005_userdir_headers.py b/test/modules/core/test_005_userdir_headers.py index 3485c32a9a3..3b3bb6fc07b 100644 --- a/test/modules/core/test_005_userdir_headers.py +++ b/test/modules/core/test_005_userdir_headers.py @@ -7,7 +7,8 @@ class TestUserdirHeaders: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): userdir_base = os.path.join(env.server_dir, "htdocs", "userdir") diff --git a/test/modules/core/test_006_merge_lang.py b/test/modules/core/test_006_merge_lang.py index 885214cac75..d642e4a023a 100644 --- a/test/modules/core/test_006_merge_lang.py +++ b/test/modules/core/test_006_merge_lang.py @@ -7,7 +7,8 @@ class TestMergeLanguage: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # Create a file with two language extensions so mod_mime # populates r->content_languages with nelts == nalloc == 2. doc_dir = os.path.join(env.server_dir, "htdocs", "test1") diff --git a/test/modules/core/test_007_cgi_redirect.py b/test/modules/core/test_007_cgi_redirect.py index b8c623df6db..f90340047ea 100644 --- a/test/modules/core/test_007_cgi_redirect.py +++ b/test/modules/core/test_007_cgi_redirect.py @@ -6,7 +6,8 @@ class TestCGIRedirectHandler: @pytest.fixture(autouse=True, scope="class") - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ "base": textwrap.dedent(f""" diff --git a/test/modules/core/test_008_restart.py b/test/modules/core/test_008_restart.py index f093383d3b2..5c414c61fa5 100644 --- a/test/modules/core/test_008_restart.py +++ b/test/modules/core/test_008_restart.py @@ -15,7 +15,8 @@ class TestRestart: """ @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env) conf.add_vhost_test1() conf.install() diff --git a/test/modules/core/test_009_allow_methods.py b/test/modules/core/test_009_allow_methods.py index 686db00d9ef..58d77fb6a5f 100644 --- a/test/modules/core/test_009_allow_methods.py +++ b/test/modules/core/test_009_allow_methods.py @@ -7,7 +7,8 @@ class TestAllowMethods: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env) conf.add_vhost_test1() conf.install() diff --git a/test/modules/core/test_014_cond_precedence.py b/test/modules/core/test_014_cond_precedence.py index 99e85915028..733fc442a8c 100644 --- a/test/modules/core/test_014_cond_precedence.py +++ b/test/modules/core/test_014_cond_precedence.py @@ -21,7 +21,8 @@ class TestCondPrecedence: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): HttpdConf(env).install() assert env.apache_restart() == 0 diff --git a/test/modules/core/test_015_errdoc_recursive_text.py b/test/modules/core/test_015_errdoc_recursive_text.py index 47ff601df24..f6ece61522d 100644 --- a/test/modules/core/test_015_errdoc_recursive_text.py +++ b/test/modules/core/test_015_errdoc_recursive_text.py @@ -21,7 +21,8 @@ class TestErrdocRecursiveText: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): docs = env.server_docs_dir conf = HttpdConf(env) conf.add([ diff --git a/test/modules/dav/test_001_propdb_ns_limit.py b/test/modules/dav/test_001_propdb_ns_limit.py index 10fd4035c42..0892e25de1e 100644 --- a/test/modules/dav/test_001_propdb_ns_limit.py +++ b/test/modules/dav/test_001_propdb_ns_limit.py @@ -7,7 +7,8 @@ class TestPropdbNsLimit: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): dav_dir = os.path.join(env.gen_dir, 'dav') os.makedirs(dav_dir, exist_ok=True) with open(os.path.join(dav_dir, 'file.txt'), 'w') as fd: diff --git a/test/modules/dav/test_002_options_trace.py b/test/modules/dav/test_002_options_trace.py index 1d22133b08b..9ff5a8e217d 100644 --- a/test/modules/dav/test_002_options_trace.py +++ b/test/modules/dav/test_002_options_trace.py @@ -43,7 +43,8 @@ def _request(env, method, path): class TestOptionsTraceDisabled: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): _setup(env, "off") # TRACE is not offered while the server refuses it @@ -63,7 +64,8 @@ class TestOptionsTraceEnabled: @pytest.fixture(autouse=True, scope='class', params=["on", "extended"]) - def _class_scope(self, env, request): + @classmethod + def _class_scope(cls, env, request): _setup(env, request.param) # unchanged: TRACE is offered and works diff --git a/test/modules/dav/test_004_lock_timeout_overflow.py b/test/modules/dav/test_004_lock_timeout_overflow.py index 600a44b3d31..a2ae104898d 100644 --- a/test/modules/dav/test_004_lock_timeout_overflow.py +++ b/test/modules/dav/test_004_lock_timeout_overflow.py @@ -25,7 +25,8 @@ class TestLockTimeoutOverflow: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): dav_dir = os.path.join(env.gen_dir, 'dav-timeout-overflow') os.makedirs(dav_dir, exist_ok=True) for name in ('file1.txt', 'file2.txt', 'file3.txt'): diff --git a/test/modules/dav/test_004_operations.py b/test/modules/dav/test_004_operations.py index b011042a9dc..ae4d15ee675 100644 --- a/test/modules/dav/test_004_operations.py +++ b/test/modules/dav/test_004_operations.py @@ -10,7 +10,8 @@ class TestDavOperations: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): dav_dir = os.path.join(env.gen_dir, 'dav-ops') if os.path.exists(dav_dir): shutil.rmtree(dav_dir) diff --git a/test/modules/dav/test_005_if_header.py b/test/modules/dav/test_005_if_header.py index 298698b9d39..b4a16bda202 100644 --- a/test/modules/dav/test_005_if_header.py +++ b/test/modules/dav/test_005_if_header.py @@ -11,7 +11,8 @@ class TestDavIfHeader: the malformed header with 400 Bad Request.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): dav_dir = os.path.join(env.gen_dir, 'dav-if') os.makedirs(dav_dir, exist_ok=True) with open(os.path.join(dav_dir, "hello.txt"), "w") as f: diff --git a/test/modules/filters/test_001_substitute_maxlen.py b/test/modules/filters/test_001_substitute_maxlen.py index 5b45415aa84..c4478fb7fa7 100644 --- a/test/modules/filters/test_001_substitute_maxlen.py +++ b/test/modules/filters/test_001_substitute_maxlen.py @@ -26,7 +26,8 @@ class TestSubstituteMaxLineLength: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): doc_dir = os.path.join(env.server_dir, "htdocs", "test1") for name, text in [("over.html", OVER), ("over_mid.html", OVER_MID), ("over_end.html", OVER_END), ("exact.html", EXACT)]: diff --git a/test/modules/filters/test_003_sed.py b/test/modules/filters/test_003_sed.py index 83380fe138b..d97a493d6bb 100644 --- a/test/modules/filters/test_003_sed.py +++ b/test/modules/filters/test_003_sed.py @@ -35,28 +35,29 @@ class TestSed: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): - self.docdir = os.path.join(env.server_dir, "htdocs", "test1") - self.write(env, "sed.html", DOC) + @classmethod + def _class_scope(cls, env): + cls.docdir = os.path.join(env.server_dir, "htdocs", "test1") + cls.write(env, "sed.html", DOC) # Same text with no newline after the last line. - self.write(env, "nonl.html", DOC[:-1]) - self.write(env, "empty.html", "") + cls.write(env, "nonl.html", DOC[:-1]) + cls.write(env, "empty.html", "") # One line per 4 KB, well past MODSED_OUTBUF_SIZE and past the 50 # transient buckets mod_sed flushes at. - self.write(env, "big.html", + cls.write(env, "big.html", "".join(f"line {i:06d} monday {'x' * 4000}\n" for i in range(500))) # A byte from each interesting class for the l command: printable, # tab, DEL and three high-bit bytes. - self.write_bytes(env, "bytes.html", b"a\tb\x7fc\xffd\x80e\xa9f\n") - self.write(env, "insert.txt", "INSERTED\n") + cls.write_bytes(env, "bytes.html", b"a\tb\x7fc\xffd\x80e\xa9f\n") + cls.write(env, "insert.txt", "INSERTED\n") # First line has nothing for \(a*\) to capture, second has "aa". - self.write(env, "backref.html", "b\naab\n") + cls.write(env, "backref.html", "b\naab\n") head = "".join( f"line {i:06d} monday ".ljust(HUGE_LINE_LEN, "y") + "\n" for i in range(HUGE_HEAD_LINES)) assert len(head) == HUGE_HEAD_LEN - self.write(env, "huge.html", head + "z" * HUGE_TAIL_LEN + "\n") + cls.write(env, "huge.html", head + "z" * HUGE_TAIL_LEN + "\n") @staticmethod def write(env, name, text): diff --git a/test/modules/filters/test_004_brotli_compression.py b/test/modules/filters/test_004_brotli_compression.py index f02865f2aad..022bda1d64c 100644 --- a/test/modules/filters/test_004_brotli_compression.py +++ b/test/modules/filters/test_004_brotli_compression.py @@ -8,7 +8,8 @@ class TestBrotliCompression: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ f"test1.{env.http_tld}": """ diff --git a/test/modules/generators/test_001_cgid.py b/test/modules/generators/test_001_cgid.py index d543f15706e..728b6850286 100644 --- a/test/modules/generators/test_001_cgid.py +++ b/test/modules/generators/test_001_cgid.py @@ -18,7 +18,8 @@ class TestCgid: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env.require(env.has_cgid_module, "mod_cgid not built", dep="mod_cgid", detected=f"not found in {env.libexec_dir}") @@ -45,8 +46,8 @@ def _class_scope(self, env): CGIDScriptTimeout 1 - """) + self.setenv_location("/envcount.py/small", 300) - + self.setenv_location("/envcount.py/large", 4200), + """) + cls.setenv_location("/envcount.py/small", 300) + + cls.setenv_location("/envcount.py/large", 4200), }) conf.add_vhost_cgi() conf.install() diff --git a/test/modules/generators/test_002_autoindex.py b/test/modules/generators/test_002_autoindex.py index 14d05bdc3f8..062f54b0d05 100644 --- a/test/modules/generators/test_002_autoindex.py +++ b/test/modules/generators/test_002_autoindex.py @@ -8,7 +8,8 @@ class TestAutoindex: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): domain = f"autoindex.{env.http_tld}" conf = HttpdConf(env, extras={ 'base': textwrap.dedent(f""" diff --git a/test/modules/http1/test_001_alive.py b/test/modules/http1/test_001_alive.py index 0a1de1dc6b8..ac15104fc74 100644 --- a/test/modules/http1/test_001_alive.py +++ b/test/modules/http1/test_001_alive.py @@ -6,7 +6,8 @@ class TestBasicAlive: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H1Conf(env).add_vhost_test1().install() assert env.apache_restart() == 0 diff --git a/test/modules/http1/test_003_get.py b/test/modules/http1/test_003_get.py index 1cd5917de62..68e1a5d0734 100644 --- a/test/modules/http1/test_003_get.py +++ b/test/modules/http1/test_003_get.py @@ -8,7 +8,8 @@ class TestGet: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H1Conf(env).add_vhost_cgi( proxy_self=True ).add_vhost_test1( diff --git a/test/modules/http1/test_004_post.py b/test/modules/http1/test_004_post.py index e4bf43e09a7..8fb4e431869 100644 --- a/test/modules/http1/test_004_post.py +++ b/test/modules/http1/test_004_post.py @@ -16,7 +16,8 @@ class TestPost: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): TestPost._local_dir = os.path.dirname(inspect.getfile(TestPost)) H1Conf(env).add_vhost_cgi().install() assert env.apache_restart() == 0 diff --git a/test/modules/http1/test_005_trailers.py b/test/modules/http1/test_005_trailers.py index 9f99a3862b9..00980fed9ec 100644 --- a/test/modules/http1/test_005_trailers.py +++ b/test/modules/http1/test_005_trailers.py @@ -11,7 +11,8 @@ class TestTrailers: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H1Conf(env).add_vhost_cgi(proxy_self=True).install() assert env.apache_restart() == 0 diff --git a/test/modules/http1/test_006_unsafe.py b/test/modules/http1/test_006_unsafe.py index eb832175139..b9d89db0804 100644 --- a/test/modules/http1/test_006_unsafe.py +++ b/test/modules/http1/test_006_unsafe.py @@ -9,7 +9,8 @@ class TestRequestUnsafe: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H1Conf(env) conf.add([ "HttpProtocolOptions Unsafe", diff --git a/test/modules/http1/test_007_strict.py b/test/modules/http1/test_007_strict.py index 7c52f685a83..b931335e120 100644 --- a/test/modules/http1/test_007_strict.py +++ b/test/modules/http1/test_007_strict.py @@ -10,7 +10,8 @@ class TestRequestStrict: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H1Conf(env) conf.add([ "HttpProtocolOptions Strict", diff --git a/test/modules/http2/test_001_httpd_alive.py b/test/modules/http2/test_001_httpd_alive.py index d81269594c1..8b63f1289de 100644 --- a/test/modules/http2/test_001_httpd_alive.py +++ b/test/modules/http2/test_001_httpd_alive.py @@ -7,7 +7,8 @@ class TestBasicAlive: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_test1().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_002_curl_basics.py b/test/modules/http2/test_002_curl_basics.py index 2c8886ddec4..041e4f8577e 100644 --- a/test/modules/http2/test_002_curl_basics.py +++ b/test/modules/http2/test_002_curl_basics.py @@ -7,7 +7,8 @@ class TestCurlBasics: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env) conf.add_vhost_test1() conf.add_vhost_test2() diff --git a/test/modules/http2/test_003_get.py b/test/modules/http2/test_003_get.py index 5cc8e435a49..19ea7afefbb 100644 --- a/test/modules/http2/test_003_get.py +++ b/test/modules/http2/test_003_get.py @@ -9,7 +9,8 @@ class TestGet: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_cgi( proxy_self=True, h2proxy_self=True ).add_vhost_test1( diff --git a/test/modules/http2/test_004_post.py b/test/modules/http2/test_004_post.py index bc2b83bab21..9ee24e3dba3 100644 --- a/test/modules/http2/test_004_post.py +++ b/test/modules/http2/test_004_post.py @@ -18,7 +18,8 @@ class TestPost: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): TestPost._local_dir = os.path.dirname(inspect.getfile(TestPost)) conf = H2Conf(env, extras={ f'cgi.{env.http_tld}': [ diff --git a/test/modules/http2/test_005_files.py b/test/modules/http2/test_005_files.py index 40abbf659a8..63de29193de 100644 --- a/test/modules/http2/test_005_files.py +++ b/test/modules/http2/test_005_files.py @@ -21,7 +21,8 @@ class TestFiles: URI_PATHS = [] @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): docs_a = os.path.join(env.server_docs_dir, "cgi/files") uris = [] file_count = 32 @@ -32,7 +33,7 @@ def _class_scope(self, env): raise Exception("file sizes?: {0} {1}".format(i, fsize)) fname = "{0}-{1}k.txt".format(i, fsize) mk_text_file(os.path.join(docs_a, fname), 8 * fsize) - self.URI_PATHS.append(f"/files/{fname}") + cls.URI_PATHS.append(f"/files/{fname}") H2Conf(env).add_vhost_cgi( proxy_self=True, h2proxy_self=True diff --git a/test/modules/http2/test_006_assets.py b/test/modules/http2/test_006_assets.py index a0a965984ac..68afc3cb0dd 100644 --- a/test/modules/http2/test_006_assets.py +++ b/test/modules/http2/test_006_assets.py @@ -8,7 +8,8 @@ class TestAssets: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_test1().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_007_ssi.py b/test/modules/http2/test_007_ssi.py index 1da48ff4546..8f202b0f622 100644 --- a/test/modules/http2/test_007_ssi.py +++ b/test/modules/http2/test_007_ssi.py @@ -7,7 +7,8 @@ class TestSSI: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env, extras={ f'cgi.{env.http_tld}': [ 'AddOutputFilter INCLUDES .html', diff --git a/test/modules/http2/test_008_ranges.py b/test/modules/http2/test_008_ranges.py index 013c8c7d892..4cfcccab3ba 100644 --- a/test/modules/http2/test_008_ranges.py +++ b/test/modules/http2/test_008_ranges.py @@ -18,7 +18,8 @@ class TestRanges: LOGFILE = "" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): TestRanges.LOGFILE = os.path.join(env.server_logs_dir, "test_008") TestRanges.SRCDIR = os.path.dirname(inspect.getfile(TestRanges)) if os.path.isfile(TestRanges.LOGFILE): diff --git a/test/modules/http2/test_009_timing.py b/test/modules/http2/test_009_timing.py index 31a0b66fee3..d6352b405ce 100644 --- a/test/modules/http2/test_009_timing.py +++ b/test/modules/http2/test_009_timing.py @@ -13,7 +13,8 @@ class TestTiming: LOGFILE = "" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): TestTiming.LOGFILE = os.path.join(env.server_logs_dir, "test_009") if os.path.isfile(TestTiming.LOGFILE): os.remove(TestTiming.LOGFILE) diff --git a/test/modules/http2/test_100_conn_reuse.py b/test/modules/http2/test_100_conn_reuse.py index ed958eb2849..d0fe3ee2d13 100644 --- a/test/modules/http2/test_100_conn_reuse.py +++ b/test/modules/http2/test_100_conn_reuse.py @@ -7,7 +7,8 @@ class TestConnReuse: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_noh2().add_vhost_test1().add_vhost_cgi().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_101_ssl_reneg.py b/test/modules/http2/test_101_ssl_reneg.py index 70a459fdbec..7c2d550e663 100644 --- a/test/modules/http2/test_101_ssl_reneg.py +++ b/test/modules/http2/test_101_ssl_reneg.py @@ -9,7 +9,8 @@ class TestSslRenegotiation: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): domain = f"ssl.{env.http_tld}" conf = H2Conf(env, extras={ 'base': [ diff --git a/test/modules/http2/test_102_require.py b/test/modules/http2/test_102_require.py index e97fb19ce50..611d0c6ec53 100644 --- a/test/modules/http2/test_102_require.py +++ b/test/modules/http2/test_102_require.py @@ -7,7 +7,8 @@ class TestRequire: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): domain = f"ssl.{env.http_tld}" conf = H2Conf(env) conf.start_vhost(domains=[domain], port=env.https_port) diff --git a/test/modules/http2/test_103_upgrade.py b/test/modules/http2/test_103_upgrade.py index df0bf99fb71..05c7101f363 100644 --- a/test/modules/http2/test_103_upgrade.py +++ b/test/modules/http2/test_103_upgrade.py @@ -8,7 +8,8 @@ class TestUpgrade: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_test1().add_vhost_test2().add_vhost_noh2( ).start_vhost(domains=[f"test3.{env.http_tld}"], port=env.https_port, doc_root="htdocs/test1" ).add( diff --git a/test/modules/http2/test_104_padding.py b/test/modules/http2/test_104_padding.py index b21bce7a59f..b78f5cc8a03 100644 --- a/test/modules/http2/test_104_padding.py +++ b/test/modules/http2/test_104_padding.py @@ -13,7 +13,8 @@ def frame_padding(payload, padbits): class TestPadding: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): def add_echo_handler(conf): conf.add([ "", diff --git a/test/modules/http2/test_106_shutdown.py b/test/modules/http2/test_106_shutdown.py index 8dbecc847ae..8356289399e 100644 --- a/test/modules/http2/test_106_shutdown.py +++ b/test/modules/http2/test_106_shutdown.py @@ -16,7 +16,8 @@ class TestShutdown: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env) conf.add_vhost_cgi() conf.install() diff --git a/test/modules/http2/test_107_frame_lengths.py b/test/modules/http2/test_107_frame_lengths.py index 1956c565ee2..056b04c1e56 100644 --- a/test/modules/http2/test_107_frame_lengths.py +++ b/test/modules/http2/test_107_frame_lengths.py @@ -22,12 +22,13 @@ class TestFrameLengths: URI_PATHS = [] @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): docs_a = os.path.join(env.server_docs_dir, "cgi/files") for fsize in [10, 100]: fname = f'0-{fsize}k.txt' mk_text_file(os.path.join(docs_a, fname), 8 * fsize) - self.URI_PATHS.append(f"/files/{fname}") + cls.URI_PATHS.append(f"/files/{fname}") @pytest.mark.parametrize("data_frame_len", [ 99, 1024, 8192 diff --git a/test/modules/http2/test_108_goaway.py b/test/modules/http2/test_108_goaway.py index 51d16964a92..0c6fa31309c 100644 --- a/test/modules/http2/test_108_goaway.py +++ b/test/modules/http2/test_108_goaway.py @@ -26,7 +26,8 @@ class TestGoaway: ERR_HTTP_1_1_REQUIRED = 0x0d @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env, extras={ 'base': [ "AcceptFilter http none", @@ -88,7 +89,7 @@ def _tls_context(ciphers=None, tls12_only=False): # send that.) @(not_backported("r1939156", "HTTP/2 error codes in GOAWAY") if os.environ.get("MPM") == "worker" or sys.platform == "win32" - else pytest.mark.usefixtures()) + else (lambda f: f)) def test_h2_108_01_idle_timeout(self, env): error = self._goaway_error(env, self._tls_context()) assert error == self.ERR_NO_ERROR, f"GOAWAY error code {error}" diff --git a/test/modules/http2/test_111_header_limit_log.py b/test/modules/http2/test_111_header_limit_log.py index cc6b22ba792..cabbe6243f8 100644 --- a/test/modules/http2/test_111_header_limit_log.py +++ b/test/modules/http2/test_111_header_limit_log.py @@ -21,7 +21,8 @@ class TestHeaderLimitLog: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env, extras={ f"test1.{env.http_tld}": [ f"LimitRequestFields {LIMIT}", diff --git a/test/modules/http2/test_112_ssl_verify_client_authz.py b/test/modules/http2/test_112_ssl_verify_client_authz.py index dcf3c72d9d8..c574b355602 100644 --- a/test/modules/http2/test_112_ssl_verify_client_authz.py +++ b/test/modules/http2/test_112_ssl_verify_client_authz.py @@ -27,7 +27,8 @@ class TestSslVerifyClientAuthz: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): domain = f"ssl.{env.http_tld}" conf = H2Conf(env, extras={ 'base': [ @@ -50,7 +51,8 @@ def _class_scope(self, env): assert env.apache_restart() == 0 @pytest.fixture(scope='class') - def client_creds(self, env): + @classmethod + def client_creds(cls, env): return env.ca.issue_cert( CertificateSpec(name="verify-authz-client", client=True)) diff --git a/test/modules/http2/test_200_header_invalid.py b/test/modules/http2/test_200_header_invalid.py index 8cf82f1f691..32d492c287b 100644 --- a/test/modules/http2/test_200_header_invalid.py +++ b/test/modules/http2/test_200_header_invalid.py @@ -9,7 +9,8 @@ class TestInvalidHeaders: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_cgi().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_201_header_conditional.py b/test/modules/http2/test_201_header_conditional.py index a7dbe7a6dcc..d8b7e5b5d9c 100644 --- a/test/modules/http2/test_201_header_conditional.py +++ b/test/modules/http2/test_201_header_conditional.py @@ -7,7 +7,8 @@ class TestConditionalHeaders: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add( """ KeepAlive on diff --git a/test/modules/http2/test_202_trailer.py b/test/modules/http2/test_202_trailer.py index dc8ae2161a5..300a5d96cd6 100644 --- a/test/modules/http2/test_202_trailer.py +++ b/test/modules/http2/test_202_trailer.py @@ -18,7 +18,8 @@ def setup_data(env): class TestTrailers: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): setup_data(env) conf = H2Conf(env, extras={ f"cgi.{env.http_tld}": [ diff --git a/test/modules/http2/test_203_rfc9113.py b/test/modules/http2/test_203_rfc9113.py index dd9a324e40d..7144fc73753 100644 --- a/test/modules/http2/test_203_rfc9113.py +++ b/test/modules/http2/test_203_rfc9113.py @@ -9,7 +9,8 @@ class TestRfc9113: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_test1().install() assert env.apache_restart() == 0 # test_h2_203_02 sends a response header with an illegal char on diff --git a/test/modules/http2/test_300_interim.py b/test/modules/http2/test_300_interim.py index efe777a258d..cdfac345eef 100644 --- a/test/modules/http2/test_300_interim.py +++ b/test/modules/http2/test_300_interim.py @@ -7,7 +7,8 @@ class TestInterimResponses: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_test1().add_vhost_cgi().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_400_push.py b/test/modules/http2/test_400_push.py index acdc094e45d..ccc906b0e01 100644 --- a/test/modules/http2/test_400_push.py +++ b/test/modules/http2/test_400_push.py @@ -10,7 +10,8 @@ class TestPush: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).start_vhost(domains=[f"push.{env.http_tld}"], port=env.https_port, doc_root="htdocs/test1" ).add(r""" diff --git a/test/modules/http2/test_401_early_hints.py b/test/modules/http2/test_401_early_hints.py index a2a8e3c2a31..dd0e3f835ca 100644 --- a/test/modules/http2/test_401_early_hints.py +++ b/test/modules/http2/test_401_early_hints.py @@ -9,7 +9,8 @@ class TestEarlyHints: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): if not env.httpd_is_at_least('2.4.58'): pytest.skip(f'needs httpd 2.4.58') H2Conf(env).start_vhost(domains=[f"hints.{env.http_tld}"], diff --git a/test/modules/http2/test_500_proxy.py b/test/modules/http2/test_500_proxy.py index 321cc7098a6..5f232a554f1 100644 --- a/test/modules/http2/test_500_proxy.py +++ b/test/modules/http2/test_500_proxy.py @@ -11,7 +11,8 @@ class TestProxy: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_cgi(proxy_self=True).install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_501_proxy_serverheader.py b/test/modules/http2/test_501_proxy_serverheader.py index fab22b90d92..04a7d0cc4c9 100644 --- a/test/modules/http2/test_501_proxy_serverheader.py +++ b/test/modules/http2/test_501_proxy_serverheader.py @@ -7,7 +7,8 @@ class TestProxyServerHeader: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env, extras={ f'cgi.{env.http_tld}': [ "Header unset Server", diff --git a/test/modules/http2/test_502_proxy_port.py b/test/modules/http2/test_502_proxy_port.py index 3bbe75943ae..2abb96e47e9 100644 --- a/test/modules/http2/test_502_proxy_port.py +++ b/test/modules/http2/test_502_proxy_port.py @@ -7,7 +7,8 @@ class TestProxyPort: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env, extras={ 'base': [ f'Listen {env.proxy_port}', diff --git a/test/modules/http2/test_503_proxy_fwd.py b/test/modules/http2/test_503_proxy_fwd.py index 0bf49fd0478..a49bec45746 100644 --- a/test/modules/http2/test_503_proxy_fwd.py +++ b/test/modules/http2/test_503_proxy_fwd.py @@ -28,6 +28,7 @@ def config_fwd_proxy(cls, env, h2_enabled=False): assert env.apache_restart() == 0 @pytest.fixture(autouse=True, scope='class') + @classmethod def _class_scope(cls, env): cls.config_fwd_proxy(env) diff --git a/test/modules/http2/test_601_h2proxy_twisted.py b/test/modules/http2/test_601_h2proxy_twisted.py index 2f6f9ce4ffe..e5779ff243c 100644 --- a/test/modules/http2/test_601_h2proxy_twisted.py +++ b/test/modules/http2/test_601_h2proxy_twisted.py @@ -15,7 +15,8 @@ class TestH2ProxyTwisted: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_cgi(proxy_self=True, h2proxy_self=True).install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_700_load_get.py b/test/modules/http2/test_700_load_get.py index f6e2c2a3d30..bd4e7fac65c 100644 --- a/test/modules/http2/test_700_load_get.py +++ b/test/modules/http2/test_700_load_get.py @@ -8,7 +8,8 @@ class TestLoadGet: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_cgi().add_vhost_test1().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_710_load_post_static.py b/test/modules/http2/test_710_load_post_static.py index 0f715457fe7..2edc05d120b 100644 --- a/test/modules/http2/test_710_load_post_static.py +++ b/test/modules/http2/test_710_load_post_static.py @@ -9,7 +9,8 @@ class TestLoadPostStatic: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_test1().install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_711_load_post_cgi.py b/test/modules/http2/test_711_load_post_cgi.py index 65064b1c8b5..54d1d8c8444 100644 --- a/test/modules/http2/test_711_load_post_cgi.py +++ b/test/modules/http2/test_711_load_post_cgi.py @@ -9,7 +9,8 @@ class TestLoadCgi: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H2Conf(env).add_vhost_cgi(proxy_self=True, h2proxy_self=True).install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_712_buffering.py b/test/modules/http2/test_712_buffering.py index 8922b0d7c65..aa1d6a516db 100644 --- a/test/modules/http2/test_712_buffering.py +++ b/test/modules/http2/test_712_buffering.py @@ -11,7 +11,8 @@ class TestBuffering: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H2Conf(env) conf.add_vhost_cgi(h2proxy_self=True).install() assert env.apache_restart() == 0 diff --git a/test/modules/http2/test_800_websockets.py b/test/modules/http2/test_800_websockets.py index 5d57449b1fa..b8381aafc64 100644 --- a/test/modules/http2/test_800_websockets.py +++ b/test/modules/http2/test_800_websockets.py @@ -107,7 +107,8 @@ def ws_run(env: H2TestEnv, path, authority=None, do_input=None, inbytes=None, class TestWebSockets: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # Apache config that CONNECT proxies a WebSocket server for paths starting # with '/ws/' # The WebSocket server is started in pytest fixture 'ws_server' below. @@ -126,7 +127,8 @@ def _class_scope(self, env): conf.add_vhost_test1(proxy_self=True, h2proxy_self=True).install() assert env.apache_restart() == 0 - def ws_check_alive(self, env, timeout=5): + @staticmethod + def ws_check_alive(env, timeout=5): url = f'http://localhost:{env.ws_port}/' end = datetime.now() + timedelta(seconds=timeout) while datetime.now() < end: @@ -136,11 +138,13 @@ def ws_check_alive(self, env, timeout=5): time.sleep(.1) return False - def _mkpath(self, path): + @staticmethod + def _mkpath(path): if not os.path.exists(path): return os.makedirs(path) - def _rmrf(self, path): + @staticmethod + def _rmrf(path): if os.path.exists(path): return shutil.rmtree(path) @@ -148,20 +152,21 @@ def infos_without_rst(self, infos): return [info for info in infos if info != '[1] RST'] @pytest.fixture(autouse=True, scope='class') - def ws_server(self, env): + @classmethod + def ws_server(cls, env): # Run our python websockets server that has some special behaviour # for the different path to CONNECT to. run_dir = os.path.join(env.gen_dir, 'ws-server') err_file = os.path.join(run_dir, 'stderr') - self._rmrf(run_dir) - self._mkpath(run_dir) + cls._rmrf(run_dir) + cls._mkpath(run_dir) with open(err_file, 'w') as cerr: cmd = os.path.join(os.path.dirname(inspect.getfile(TestWebSockets)), 'ws_server.py') args = ['python3', cmd, '--port', str(env.ws_port)] p = subprocess.Popen(args=args, cwd=run_dir, stderr=cerr, stdout=cerr) - if not self.ws_check_alive(env): + if not cls.ws_check_alive(env): p.kill() p.wait() pytest.fail(f'ws_server did not start. stderr={open(err_file).readlines()}') diff --git a/test/modules/http3/test_003_access.py b/test/modules/http3/test_003_access.py index 93eeb3b0170..829aff1e92c 100644 --- a/test/modules/http3/test_003_access.py +++ b/test/modules/http3/test_003_access.py @@ -6,7 +6,8 @@ class TestAccess: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): H3Conf(env).add_h3_vhosts(test1=[ 'SetEnvIf User-Agent "^blocked-agent$" blocked', '', @@ -43,7 +44,8 @@ def test_h3_003_02(self, env): class TestRequestChecks: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = H3Conf(env) conf.add("StrictHostCheck on") conf.add_h3_vhosts().install() diff --git a/test/modules/mappers/test_001_rewrite.py b/test/modules/mappers/test_001_rewrite.py index c9f0cffbcdd..05ca17b04a3 100644 --- a/test/modules/mappers/test_001_rewrite.py +++ b/test/modules/mappers/test_001_rewrite.py @@ -9,7 +9,8 @@ class TestRewriteRedirect: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env) # VirtualHost that strips "www." prefix and redirects conf.start_vhost( @@ -69,7 +70,8 @@ def test_rewrite_001_02_non_domain_to_domain(self, env): class TestRewriteOpenRedirect: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): doc_dir = os.path.join(env.server_dir, "htdocs", "test1") rhts_dir = os.path.join(doc_dir, "rhts") os.makedirs(rhts_dir, exist_ok=True) @@ -107,7 +109,8 @@ def test_rewrite_002_01_redirect_bad(self, env): class TestRewriteEscapeSequences: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): doc_dir = os.path.join(env.server_dir, "htdocs", "test1") rhts_dir = os.path.join(doc_dir, "rhts2") os.makedirs(rhts_dir, exist_ok=True) diff --git a/test/modules/md/test_010_store_migrate.py b/test/modules/md/test_010_store_migrate.py index 9bf66a81633..de6af103ae5 100644 --- a/test/modules/md/test_010_store_migrate.py +++ b/test/modules/md/test_010_store_migrate.py @@ -13,7 +13,8 @@ class TestStoreMigrate: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): MDConf(env).install() assert env.apache_restart() == 0, f'{env.apachectl_stderr}' diff --git a/test/modules/md/test_202_acmev2_regs.py b/test/modules/md/test_202_acmev2_regs.py index 4a2ff87a239..cae7d8a82a0 100644 --- a/test/modules/md/test_202_acmev2_regs.py +++ b/test/modules/md/test_202_acmev2_regs.py @@ -17,7 +17,8 @@ class TestAcmeAcc: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.APACHE_CONF_SRC = "data/test_drive" diff --git a/test/modules/md/test_300_conf_validate.py b/test/modules/md/test_300_conf_validate.py index c896036cf73..16671b96fb7 100644 --- a/test/modules/md/test_300_conf_validate.py +++ b/test/modules/md/test_300_conf_validate.py @@ -19,7 +19,8 @@ class TestConf: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.purge_store() diff --git a/test/modules/md/test_310_conf_store.py b/test/modules/md/test_310_conf_store.py index cefa49c7ba1..7390b42fa84 100644 --- a/test/modules/md/test_310_conf_store.py +++ b/test/modules/md/test_310_conf_store.py @@ -21,7 +21,8 @@ class TestConf: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.httpd_error_log.add_ignored_lognos(["AH10045", "AH10105"]) diff --git a/test/modules/md/test_502_acmev2_drive.py b/test/modules/md/test_502_acmev2_drive.py index 4420c16896d..dfcb69bc84d 100644 --- a/test/modules/md/test_502_acmev2_drive.py +++ b/test/modules/md/test_502_acmev2_drive.py @@ -23,7 +23,8 @@ class TestDrivev2: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.APACHE_CONF_SRC = "data/test_drive" diff --git a/test/modules/md/test_602_roundtrip.py b/test/modules/md/test_602_roundtrip.py index 7dd497fc1a8..9b6e1faf5e4 100644 --- a/test/modules/md/test_602_roundtrip.py +++ b/test/modules/md/test_602_roundtrip.py @@ -17,7 +17,8 @@ class TestRoundtripv2: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.APACHE_CONF_SRC = "data/test_roundtrip" env.clear_store() diff --git a/test/modules/md/test_702_auto.py b/test/modules/md/test_702_auto.py index 200944ccc6d..688d8d5836c 100644 --- a/test/modules/md/test_702_auto.py +++ b/test/modules/md/test_702_auto.py @@ -19,7 +19,8 @@ class TestAutov2: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_710_profiles.py b/test/modules/md/test_710_profiles.py index 4b66564252e..9320f087574 100644 --- a/test/modules/md/test_710_profiles.py +++ b/test/modules/md/test_710_profiles.py @@ -20,7 +20,8 @@ class TestProfiles: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_720_wildcard.py b/test/modules/md/test_720_wildcard.py index 5efaad5857c..71f07069b92 100644 --- a/test/modules/md/test_720_wildcard.py +++ b/test/modules/md/test_720_wildcard.py @@ -15,7 +15,8 @@ class TestWildcard: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_721_dns01.py b/test/modules/md/test_721_dns01.py index 7bc5771e82a..a8a18d2bd93 100644 --- a/test/modules/md/test_721_dns01.py +++ b/test/modules/md/test_721_dns01.py @@ -16,7 +16,8 @@ class TestDns01: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_730_static.py b/test/modules/md/test_730_static.py index 55a32db56d2..43492c99987 100644 --- a/test/modules/md/test_730_static.py +++ b/test/modules/md/test_730_static.py @@ -16,7 +16,8 @@ class TestStatic: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_740_acme_errors.py b/test/modules/md/test_740_acme_errors.py index d909cc525c3..c8958bf984f 100644 --- a/test/modules/md/test_740_acme_errors.py +++ b/test/modules/md/test_740_acme_errors.py @@ -13,7 +13,8 @@ class TestAcmeErrors: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_741_setup_errors.py b/test/modules/md/test_741_setup_errors.py index 2fbfb38866b..3ac9ee4598d 100644 --- a/test/modules/md/test_741_setup_errors.py +++ b/test/modules/md/test_741_setup_errors.py @@ -15,7 +15,8 @@ class TestSetupErrors: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_750_eab.py b/test/modules/md/test_750_eab.py index 894ac8506ec..ebc405a1fe2 100644 --- a/test/modules/md/test_750_eab.py +++ b/test/modules/md/test_750_eab.py @@ -13,7 +13,8 @@ class TestEab: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='eab') env.check_acme() env.clear_store() diff --git a/test/modules/md/test_751_sectigo.py b/test/modules/md/test_751_sectigo.py index f5a7040c308..9b0ffe80530 100644 --- a/test/modules/md/test_751_sectigo.py +++ b/test/modules/md/test_751_sectigo.py @@ -41,7 +41,8 @@ def missing_tld(): class TestSectigo: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='eab') env.check_acme() env.clear_store() diff --git a/test/modules/md/test_752_zerossl.py b/test/modules/md/test_752_zerossl.py index 70505a3273f..5645ef7971b 100644 --- a/test/modules/md/test_752_zerossl.py +++ b/test/modules/md/test_752_zerossl.py @@ -38,7 +38,8 @@ def get_new_eab(env): class TestZeroSSL: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='eab') env.check_acme() env.clear_store() diff --git a/test/modules/md/test_790_failover.py b/test/modules/md/test_790_failover.py index 9f0d6e2f761..2b5dd53d810 100644 --- a/test/modules/md/test_790_failover.py +++ b/test/modules/md/test_790_failover.py @@ -12,7 +12,8 @@ class TestFailover: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.clear_store() diff --git a/test/modules/md/test_800_must_staple.py b/test/modules/md/test_800_must_staple.py index 3b3ac2471d8..975df037ae7 100644 --- a/test/modules/md/test_800_must_staple.py +++ b/test/modules/md/test_800_must_staple.py @@ -16,7 +16,8 @@ class TestMustStaple: domain = None @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.clear_store() diff --git a/test/modules/md/test_801_stapling.py b/test/modules/md/test_801_stapling.py index e9868a70993..d88047c42e2 100644 --- a/test/modules/md/test_801_stapling.py +++ b/test/modules/md/test_801_stapling.py @@ -18,14 +18,15 @@ class TestStapling: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.clear_store() - domain = env.get_class_domain(self.__class__) + domain = env.get_class_domain(cls) mdA = "a-" + domain mdB = "b-" + domain - self.configure_httpd(env, [mdA, mdB]).install() + cls.configure_httpd(env, [mdA, mdB]).install() env.apache_stop() assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([mdA, mdB]) @@ -40,7 +41,8 @@ def _method_scope(self, env, request): yield env.apache_stop() - def configure_httpd(self, env, domains=None, add_lines="", ssl_stapling=False): + @staticmethod + def configure_httpd(env, domains=None, add_lines="", ssl_stapling=False): if not isinstance(domains, list): domains = [domains] if domains else [] conf = MDConf(env) diff --git a/test/modules/md/test_810_ec.py b/test/modules/md/test_810_ec.py index 87487cdcfe8..fcfc1ef98bb 100644 --- a/test/modules/md/test_810_ec.py +++ b/test/modules/md/test_810_ec.py @@ -15,7 +15,8 @@ class TestAutov2: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_820_locks.py b/test/modules/md/test_820_locks.py index 542e710a71e..a19130ba416 100644 --- a/test/modules/md/test_820_locks.py +++ b/test/modules/md/test_820_locks.py @@ -16,7 +16,8 @@ class TestLocks: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_900_notify.py b/test/modules/md/test_900_notify.py index 4231a0b133f..c467df9f948 100644 --- a/test/modules/md/test_900_notify.py +++ b/test/modules/md/test_900_notify.py @@ -20,7 +20,8 @@ class TestNotify: domain = None @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.clear_store() diff --git a/test/modules/md/test_901_message.py b/test/modules/md/test_901_message.py index 752eeb6c9f7..cd35ae44f4e 100644 --- a/test/modules/md/test_901_message.py +++ b/test/modules/md/test_901_message.py @@ -19,7 +19,8 @@ class TestMessage: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_910_cleanups.py b/test/modules/md/test_910_cleanups.py index a3a5932939a..957aeb27849 100644 --- a/test/modules/md/test_910_cleanups.py +++ b/test/modules/md/test_910_cleanups.py @@ -16,7 +16,8 @@ class TestCleanups: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): env.APACHE_CONF_SRC = "data/test_auto" acme.start(config='default') env.check_acme() diff --git a/test/modules/md/test_920_status.py b/test/modules/md/test_920_status.py index 66a597faf79..078f2458b5b 100644 --- a/test/modules/md/test_920_status.py +++ b/test/modules/md/test_920_status.py @@ -21,7 +21,8 @@ class TestStatus: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, acme): + @classmethod + def _class_scope(cls, env, acme): acme.start(config='default') env.check_acme() env.clear_store() diff --git a/test/modules/metadata/test_001_mime_magic.py b/test/modules/metadata/test_001_mime_magic.py index cff9d9278a7..40222c4c9e5 100644 --- a/test/modules/metadata/test_001_mime_magic.py +++ b/test/modules/metadata/test_001_mime_magic.py @@ -14,7 +14,8 @@ class TestMimeMagic: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # A small magic file: one entry giving both a type and an # encoding, and one with a file(1)-style descriptive note in # place of the encoding. The token-based text detection is left diff --git a/test/modules/metadata/test_002_mime_libmagic.py b/test/modules/metadata/test_002_mime_libmagic.py index a622d1ebb12..01f97c8b674 100644 --- a/test/modules/metadata/test_002_mime_libmagic.py +++ b/test/modules/metadata/test_002_mime_libmagic.py @@ -17,7 +17,8 @@ def get_type(env, path): class TestMimeLibmagic: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env.require(env.has_libmagic_module, "mod_mime_libmagic is not built", dep="mod_libmagic", detected=f"not found in {env.libexec_dir}") @@ -62,7 +63,8 @@ def test_metadata_002_02_extension(self, env): class TestMimeLibmagicCharset: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env.require(env.has_libmagic_module, "mod_mime_libmagic is not built", dep="mod_libmagic", detected=f"not found in {env.libexec_dir}") diff --git a/test/modules/metadata/test_002_setenvfromfile.py b/test/modules/metadata/test_002_setenvfromfile.py index e6ce041bdbb..6c524e7c3e3 100644 --- a/test/modules/metadata/test_002_setenvfromfile.py +++ b/test/modules/metadata/test_002_setenvfromfile.py @@ -22,7 +22,8 @@ class TestSetEnvFromFile: """Parsing behaviour of a well-formed file.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # A plain name=value pair, an explicitly empty value, a line with # no '=' (also empty), a backslash line continuation, and a line # padded with surrounding whitespace that must be stripped. @@ -85,7 +86,8 @@ class TestSetEnvFromFileMalformed: lines are still parsed.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env_file = os.path.join(env.gen_dir, "setenv-malformed.env") with open(env_file, "w") as f: f.write("# a line beginning with '=' has an empty name\n") @@ -145,7 +147,8 @@ class TestSetEnvFromFileHtaccess: even where AllowOverride FileInfo would allow SetEnv itself.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): ht_dir = os.path.join(env.server_dir, "htdocs", "test1", "htaccess") os.makedirs(ht_dir, exist_ok=True) with open(os.path.join(ht_dir, "index.html"), "w") as f: diff --git a/test/modules/metadata/test_003_compare.py b/test/modules/metadata/test_003_compare.py index 93821a95805..32163111a53 100644 --- a/test/modules/metadata/test_003_compare.py +++ b/test/modules/metadata/test_003_compare.py @@ -45,7 +45,8 @@ class TestCompare: mod_mime_libmagic (vhost test2).""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env.require(env.has_libmagic_module, "mod_mime_libmagic is not built", dep="mod_libmagic", detected=f"not found in {env.libexec_dir}") diff --git a/test/modules/proxy/test_01_http.py b/test/modules/proxy/test_01_http.py index 617997f6ae1..a8eb786de79 100644 --- a/test/modules/proxy/test_01_http.py +++ b/test/modules/proxy/test_01_http.py @@ -9,7 +9,8 @@ class TestProxyHttp: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # setup 3 vhosts on https: for reverse, forward and mixed proxying # setup 3 vhosts on http: with different document roots conf = HttpdConf(env) diff --git a/test/modules/proxy/test_02_unix.py b/test/modules/proxy/test_02_unix.py index 6a2fce78bc9..76ff2a76c08 100644 --- a/test/modules/proxy/test_02_unix.py +++ b/test/modules/proxy/test_02_unix.py @@ -56,7 +56,8 @@ def _process(self): class TestProxyUds: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # setup 3 vhosts on https: for reverse, forward and # mixed proxying to a unix: domain socket # We setup a UDSFaker running that returns a fixed response diff --git a/test/modules/proxy/test_03_response.py b/test/modules/proxy/test_03_response.py index 5a51d1d7e8b..7dda44b3ffb 100644 --- a/test/modules/proxy/test_03_response.py +++ b/test/modules/proxy/test_03_response.py @@ -57,7 +57,8 @@ def _make_response(self, data): class TestProxyResponse: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): faker = _ResponseFaker("127.0.0.1", env.http_port2) faker.start() diff --git a/test/modules/proxy/test_04_ajp.py b/test/modules/proxy/test_04_ajp.py index 20e42b3a0a4..a7ddf576da8 100644 --- a/test/modules/proxy/test_04_ajp.py +++ b/test/modules/proxy/test_04_ajp.py @@ -54,7 +54,8 @@ def tiny_body_chunk(data): class TestProxyAjp: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env.require(env.has_shared_module("proxy_ajp"), "mod_proxy_ajp not available", dep="mod_proxy_ajp", detected=f"no mod_proxy_ajp.so in {env.libexec_dir}") diff --git a/test/modules/proxy/test_05_uwsgi.py b/test/modules/proxy/test_05_uwsgi.py index 04bfb12609c..541c47cc341 100644 --- a/test/modules/proxy/test_05_uwsgi.py +++ b/test/modules/proxy/test_05_uwsgi.py @@ -32,7 +32,8 @@ def empty_header(data): class TestProxyUwsgi: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): env.require(env.has_shared_module("proxy_uwsgi"), "mod_proxy_uwsgi not available", dep="mod_proxy_uwsgi", detected=f"no mod_proxy_uwsgi.so in {env.libexec_dir}") diff --git a/test/modules/proxy/test_06_interim_resp.py b/test/modules/proxy/test_06_interim_resp.py index 05e88a84fd8..80ec793a8dc 100644 --- a/test/modules/proxy/test_06_interim_resp.py +++ b/test/modules/proxy/test_06_interim_resp.py @@ -70,7 +70,8 @@ class TestStatusLineCR: """ @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env) conf.start_vhost(domains=[f"test1.{env.http_tld}"], port=env.http_port, doc_root="htdocs", with_ssl=False) diff --git a/test/modules/proxy/test_07_cache_control.py b/test/modules/proxy/test_07_cache_control.py index 92af0bf8fc5..a98485abfab 100644 --- a/test/modules/proxy/test_07_cache_control.py +++ b/test/modules/proxy/test_07_cache_control.py @@ -80,7 +80,8 @@ def _make_response(self, data): class TestCacheControl: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): faker = _CacheFaker("127.0.0.1", env.http_port2, CASES) faker.start() cache_dir = os.path.join(env.gen_dir, "cache-control") diff --git a/test/modules/proxy/test_09_hcheck_log_uri.py b/test/modules/proxy/test_09_hcheck_log_uri.py index 1978ae289fb..0562a200d0c 100644 --- a/test/modules/proxy/test_09_hcheck_log_uri.py +++ b/test/modules/proxy/test_09_hcheck_log_uri.py @@ -19,7 +19,8 @@ class TestHcheckLogUri: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env) conf.add([ '', diff --git a/test/modules/session/test_001_session_expiry.py b/test/modules/session/test_001_session_expiry.py index 0027cbd1207..b043cc304c1 100644 --- a/test/modules/session/test_001_session_expiry.py +++ b/test/modules/session/test_001_session_expiry.py @@ -7,7 +7,8 @@ class TestSessionExpiry: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): cgi_dir = os.path.join(env.server_dir, "htdocs", "test1", "cgi") conf = HttpdConf(env, extras={ f"test1.{env.http_tld}": f""" diff --git a/test/modules/ssl/test_001_sni.py b/test/modules/ssl/test_001_sni.py index 30da915faf5..e16c9729516 100644 --- a/test/modules/ssl/test_001_sni.py +++ b/test/modules/ssl/test_001_sni.py @@ -8,10 +8,11 @@ class TestSNI: LOG_FILE = "test_sni.log" @pytest.fixture(autouse=True, scope="class") - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ "base": - f'CustomLog logs/{self.LOG_FILE} "%{{SSL_TLS_SNI}}x"' + f'CustomLog logs/{cls.LOG_FILE} "%{{SSL_TLS_SNI}}x"' }) conf.add_vhost_test1() conf.install() diff --git a/test/modules/ssl/test_002_tls13.py b/test/modules/ssl/test_002_tls13.py index 3d1a2fc8a43..cdf53df4fcd 100644 --- a/test/modules/ssl/test_002_tls13.py +++ b/test/modules/ssl/test_002_tls13.py @@ -8,7 +8,8 @@ class TestTLS13: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): conf = HttpdConf(env, extras={ f"test1.{env.http_tld}": "SSLProtocol TLSv1.3", }) diff --git a/test/modules/ssl/test_003_verify_client_perdir.py b/test/modules/ssl/test_003_verify_client_perdir.py index 6d082b65bcf..0c79abd6f55 100644 --- a/test/modules/ssl/test_003_verify_client_perdir.py +++ b/test/modules/ssl/test_003_verify_client_perdir.py @@ -24,7 +24,8 @@ class TestVerifyClientPerDir: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): doc_dir = os.path.join(env.server_dir, "htdocs", "test1", "secure") os.makedirs(doc_dir, exist_ok=True) with open(os.path.join(doc_dir, "index.html"), "w") as f: diff --git a/test/modules/ssl/test_004_socache_redis.py b/test/modules/ssl/test_004_socache_redis.py index 6b07fce6e40..82f7bcaa95d 100644 --- a/test/modules/ssl/test_004_socache_redis.py +++ b/test/modules/ssl/test_004_socache_redis.py @@ -51,7 +51,8 @@ def stop(self): class TestSocacheRedis: @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): # storing the session of a TLSv1.2 handshake waits for the redis reply env.httpd_error_log.add_ignored_lognos(["AH03478"]) yield diff --git a/test/modules/ssl/test_005_vhost_compat.py b/test/modules/ssl/test_005_vhost_compat.py index 054baa85678..f7d47320086 100644 --- a/test/modules/ssl/test_005_vhost_compat.py +++ b/test/modules/ssl/test_005_vhost_compat.py @@ -13,7 +13,8 @@ class TestVhostCompatSecure: settings) than the handshake host are rejected with 421.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): + @classmethod + def _class_scope(cls, env): alt_domain = f"test2.{env.http_tld}" alt_creds = env.ca.issue_cert( CertificateSpec(name="ssl005-alt", domains=[alt_domain], @@ -192,7 +193,8 @@ class TestVhostCompatPolicy: way the policy blocks, and is served otherwise.""" @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env, policy): + @classmethod + def _class_scope(cls, env, policy): default_host = f"test1.{env.http_tld}" alt_creds = env.ca.issue_cert( CertificateSpec(name="ssl005-cert", domains=[f"cert.{env.http_tld}"], diff --git a/test/pytest_suite/tests/t/apache/test_http_strict.py b/test/pytest_suite/tests/t/apache/test_http_strict.py index 24acbd52d71..5dcc8dfb6c4 100644 --- a/test/pytest_suite/tests/t/apache/test_http_strict.py +++ b/test/pytest_suite/tests/t/apache/test_http_strict.py @@ -89,7 +89,7 @@ ("GET http://localhost:80x/ HTTP/1.0\r\n\r\n", 400, None, None), ("GET http://localhost:80:80/ HTTP/1.0\r\n\r\n", 400, None, None), ("GET http://localhost::80/ HTTP/1.0\r\n\r\n", 400, None, None), - ("GET http://foo\@localhost:80/ HTTP/1.0\r\n\r\n", 200, 400, None), + ("GET http://foo@localhost:80/ HTTP/1.0\r\n\r\n", 200, 400, None), ("GET http://[::1]/ HTTP/1.0\r\n\r\n", 1, None, None), ("GET http://[::1:2]/ HTTP/1.0\r\n\r\n", 1, None, None), ("GET http://[4712::abcd]/ HTTP/1.0\r\n\r\n", 1, None, None), diff --git a/test/pytest_suite/tests/t/modules/test_access.py b/test/pytest_suite/tests/t/modules/test_access.py index d1d1f33823e..c36cb5c64a0 100644 --- a/test/pytest_suite/tests/t/modules/test_access.py +++ b/test/pytest_suite/tests/t/modules/test_access.py @@ -4,7 +4,7 @@ combination of Order x Allow/Deny clauses and checks whether the index is served (GET_OK, i.e. 200) per the access-control logic. -Perl original gated on ``\&need_access`` (the Order/Allow/Deny directives live +Perl original gated on ``need_access`` (the Order/Allow/Deny directives live in mod_access_compat on 2.4); gated here with @need_module. """ diff --git a/test/pytest_suite/tests/t/modules/test_proxy_beacon_input.py b/test/pytest_suite/tests/t/modules/test_proxy_beacon_input.py index 84cef90fbba..51c86f58c6b 100644 --- a/test/pytest_suite/tests/t/modules/test_proxy_beacon_input.py +++ b/test/pytest_suite/tests/t/modules/test_proxy_beacon_input.py @@ -229,7 +229,7 @@ def test_equivalent_spellings_are_one_member(http): @need -@pytest.mark.parametrize("n,url", enumerate([ +@pytest.mark.parametrize("n,url", list(enumerate([ "http://127.0.0.8:8083/one", # path: would alias /one and /one/two "http://127.0.0.8:8083/one/two", "http://127.0.0.8:8083?x=1", # query @@ -243,7 +243,7 @@ def test_equivalent_spellings_are_one_member(http): "http://127.0.0.8:4294967376", # 2^32 + 80: truncates to port 80 "abcdefghijklmnop://127.0.0.8:8085", # 16 chars: does not fit the worker "http://" + "h" * 256 + ":8086", # host does not fit the worker -])) +]))) def test_non_origin_urls_are_rejected(http, n, url): lines = inject(http, [url], f"http://127.0.0.3:{18100 + n}") assert not [m for m in added_members(lines) if "127.0.0.8" in m], ( @@ -251,11 +251,11 @@ def test_non_origin_urls_are_rejected(http, n, url): @need -@pytest.mark.parametrize("n,url", enumerate([ +@pytest.mark.parametrize("n,url", list(enumerate([ "https://127.0.0.9:8443", "uwsgi://127.0.0.9:3031", # a mod_proxy scheme apr does not know "fcgi://127.0.0.9:9000", -])) +]))) def test_proxy_scheme_origins_are_accepted(http, n, url): lines = inject(http, [url], f"http://127.0.0.3:{18121 + n}") assert url in added_members(lines) @@ -460,7 +460,7 @@ def b(url, ts_part, marker="BEACON", sep=" "): @need -@pytest.mark.parametrize("n,case", enumerate(frame_cases()), +@pytest.mark.parametrize("n,case", list(enumerate(frame_cases())), ids=[c[0] for c in frame_cases()]) def test_malformed_frames_are_dropped(http, n, case): name, build = case