Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/modules/arch/linux/test_001_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 6 additions & 4 deletions test/modules/arch/linux/test_002_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': """
<Location "/server-status">
Expand All @@ -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.

Expand All @@ -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 = {}
Expand Down
3 changes: 2 additions & 1 deletion test/modules/arch/linux/test_003_extended_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/modules/arch/linux/test_004_socket_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/modules/arch/linux/test_005_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/modules/arch/linux/test_006_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/modules/arch/linux/test_007_notify_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_001_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
<Directory "{env.gen_dir}">
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_003_cgi_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
<Directory "{env.gen_dir}">
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_004_ssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
<Directory "{env.gen_dir}">
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_005_userdir_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_006_merge_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_007_cgi_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
<Directory "{env.server_docs_dir}/cgiredir">
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_008_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_009_allow_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_014_cond_precedence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/modules/core/test_015_errdoc_recursive_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
3 changes: 2 additions & 1 deletion test/modules/dav/test_001_propdb_ns_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions test/modules/dav/test_002_options_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/modules/dav/test_004_lock_timeout_overflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
3 changes: 2 additions & 1 deletion test/modules/dav/test_004_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion test/modules/dav/test_005_if_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion test/modules/filters/test_001_substitute_maxlen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]:
Expand Down
21 changes: 11 additions & 10 deletions test/modules/filters/test_003_sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion test/modules/filters/test_004_brotli_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}": """
<Location "/">
Expand Down
7 changes: 4 additions & 3 deletions test/modules/generators/test_001_cgid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -45,8 +46,8 @@ def _class_scope(self, env):
<LocationMatch "^/sleep">
CGIDScriptTimeout 1
</LocationMatch>
""") + 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()
Expand Down
3 changes: 2 additions & 1 deletion test/modules/generators/test_002_autoindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
3 changes: 2 additions & 1 deletion test/modules/http1/test_001_alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/modules/http1/test_003_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion test/modules/http1/test_004_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/modules/http1/test_005_trailers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/modules/http1/test_006_unsafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Loading