tests/functional2: fixes prerequisite to ruff upgrade to 0.11.10
Most of these are simple fixes and clarifications. One set of fixes will come in the commit that actually upgrades nixpkgs and hence ruff as it will otherwise cause errors here. Change-Id: Ie857da0f6cf728478700ec2d24cf518f8c7b7815
This commit is contained in:
@@ -43,7 +43,7 @@ INVALID_TESTER_NAME = (
|
||||
Base message for invalid runner, to use across collection
|
||||
"""
|
||||
|
||||
SUFFIX_REGEX = re.compile("-[\\w-]+?").pattern
|
||||
SUFFIX_REGEX = r"-[\w-]+?"
|
||||
NAMING_PATTERN_LANG_TEST = re.compile(
|
||||
rf"{LangTestRunner.as_regex_selector()}(?P<suffix>{SUFFIX_REGEX})?"
|
||||
)
|
||||
@@ -262,7 +262,7 @@ def _collect_all_tests() -> tuple[list[LangTest], list[InvalidLangTest]]:
|
||||
|
||||
# ignore test groups, which have a py file, as those are set up fully custom
|
||||
# and expected to be collected by pytest and not by us
|
||||
if len(list(node.glob("*.py"))):
|
||||
if list(node.glob("*.py")):
|
||||
logger.info("skipping %s as it contains a py file, assuming custom tests", node)
|
||||
continue
|
||||
t, i = _collect_test_group(node)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "functional2"
|
||||
version = "2"
|
||||
requires-python = ">=3.11"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-p no:xonsh"
|
||||
|
||||
@@ -119,7 +119,7 @@ def dev_main():
|
||||
app.add_routes([web.get("/", root)])
|
||||
|
||||
with http_server(app) as httpd:
|
||||
logging.info("Listening on http://[::1]:%d", httpd.port)
|
||||
logger.info("Listening on http://[::1]:%d", httpd.port)
|
||||
time.sleep(3600)
|
||||
|
||||
|
||||
|
||||
@@ -272,7 +272,8 @@ def test_merge_fd_throws_on_conflict():
|
||||
fd2 = {"a": File("a")}
|
||||
|
||||
with pytest.raises(
|
||||
ValueError, match="('Cannot merge files; got two different values for the same path', 'a')"
|
||||
ValueError,
|
||||
match=r"\('Cannot merge files; got two different values for the same path', 'a'\)",
|
||||
):
|
||||
merge_file_declaration(fd1, fd2)
|
||||
|
||||
@@ -283,6 +284,6 @@ def test_merge_fd_throws_on_conflict_with_full_path():
|
||||
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="('Cannot merge files; got two different values for the same path', 'a/b/c/d')",
|
||||
match=r"\('Cannot merge files; got two different values for the same path', 'a/b/c/d'\)",
|
||||
):
|
||||
merge_file_declaration(fd1, fd2)
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_nix_settings_ser_fails_bad_top_level_type():
|
||||
settings = NixSettings(nix_store_dir=Path("/store/nix"))
|
||||
settings.experimental_features = {"a": "b"} # type: ignore we are testing the types here
|
||||
|
||||
with pytest.raises(ValueError, match="Value is unsupported in nix config: {'a': 'b'}"):
|
||||
with pytest.raises(ValueError, match=r"Value is unsupported in nix config: {'a': 'b'}"):
|
||||
settings.to_config()
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ def test_nix_settings_ser_fails_bad_sub_type():
|
||||
settings = NixSettings(nix_store_dir=Path("/store/nix"))
|
||||
settings.experimental_features = [["a", "b"], "c"] # type: ignore we are testing the types here
|
||||
|
||||
with pytest.raises(ValueError, match="Value is unsupported in nix config: .+"):
|
||||
with pytest.raises(ValueError, match=r"Value is unsupported in nix config: .+"):
|
||||
settings.to_config()
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ def test_nix_settings_fails_without_store_and_store_dir():
|
||||
|
||||
with pytest.raises(
|
||||
AssertionError,
|
||||
match="Failing to set either nix_store_dir or store will cause accidental use of the system store.",
|
||||
match=r"Failing to set either nix_store_dir or store will cause accidental use of the system store.",
|
||||
):
|
||||
settings.to_config()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ See "The Purely Functional Software Deployment Model", fig. 5.2 [1].
|
||||
from abc import ABCMeta, abstractmethod
|
||||
import dataclasses
|
||||
import struct
|
||||
from typing import Protocol
|
||||
from typing import Protocol, ClassVar
|
||||
|
||||
|
||||
class Writable(Protocol):
|
||||
@@ -56,7 +56,7 @@ class NarItem(metaclass=ABCMeta):
|
||||
class Regular(NarItem):
|
||||
executable: bool
|
||||
contents: bytes
|
||||
type_ = b"regular"
|
||||
type_: ClassVar[bytes] = b"regular"
|
||||
|
||||
def serialize_type(self, out: NarListener):
|
||||
if self.executable:
|
||||
@@ -70,7 +70,7 @@ class Regular(NarItem):
|
||||
class DirectoryUnordered(NarItem):
|
||||
entries: list[tuple[bytes, NarItem]]
|
||||
"""Entries in the directory, not required to be in order because this nar is evil"""
|
||||
type_ = b"directory"
|
||||
type_: ClassVar[bytes] = b"directory"
|
||||
|
||||
@staticmethod
|
||||
def entry(out: NarListener, name: bytes, item: "NarItem"):
|
||||
@@ -102,7 +102,7 @@ class Directory(NarItem):
|
||||
@dataclasses.dataclass
|
||||
class Symlink(NarItem):
|
||||
target: bytes
|
||||
type_ = b"symlink"
|
||||
type_: ClassVar[bytes] = b"symlink"
|
||||
|
||||
def serialize_type(self, out: NarListener):
|
||||
out.str_(b"target")
|
||||
|
||||
@@ -43,15 +43,15 @@ def test_type_doesnt_allow_generator():
|
||||
def foo():
|
||||
yield 1
|
||||
|
||||
with pytest.raises(ValueError, match="Unsupported expected_type.+"):
|
||||
with pytest.raises(ValueError, match=r"Unsupported expected_type.+"):
|
||||
is_value_of_type(foo, Generator[int, None, None])
|
||||
|
||||
|
||||
def test_type_doesnt_allow_callable():
|
||||
def foo(a): # noqa: ANN001, ANN202: dummy stuff within testing, nothing external
|
||||
def foo(a): # noqa: ANN001, ANN202 # dummy stuff within testing, nothing external
|
||||
return "a" + str(a)
|
||||
|
||||
with pytest.raises(ValueError, match="Unsupported expected_type.+"):
|
||||
with pytest.raises(ValueError, match=r"Unsupported expected_type.+"):
|
||||
is_value_of_type(foo, Callable[[int], str])
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ def test_type_allows_none():
|
||||
def test_doesnt_allow_generic():
|
||||
class X[T]: ...
|
||||
|
||||
with pytest.raises(ValueError, match="Unsupported expected_type.+"):
|
||||
with pytest.raises(ValueError, match=r"Unsupported expected_type.+"):
|
||||
is_value_of_type(0, X[int])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user