Skip to content

Commit

Permalink
correct fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Dec 20, 2023
1 parent f0a5dea commit 143141a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions anndata/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ def check_error_or_notes_match(e: pytest.ExceptionInfo, pattern: str | re.Patter
import traceback

message = "".join(traceback.format_exception_only(e.type, e.value))
# To match pytest semantics, this must be `match`, not `search`.
assert re.match(
assert re.search(
pattern, message
), f"Could not find pattern: '{pattern}' in error:\n\n{message}\n"

Expand Down
6 changes: 3 additions & 3 deletions anndata/tests/test_io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def read_attr(_):
group["X"] = [1, 2, 3]
group.create_group("group")

with pytest_8_raises(NotImplementedError, match=r"/X"):
with pytest_8_raises(NotImplementedError, match=r".*/X$"):
read_attr(group["X"])

with pytest_8_raises(NotImplementedError, match=r"/group"):
with pytest_8_raises(NotImplementedError, match=r".*/group$"):
read_attr(group["group"])


Expand Down Expand Up @@ -91,7 +91,7 @@ class Foo:
# (?!...) is a negative lookahead
# (?s) enables the dot to match newlines
# https://stackoverflow.com/a/406408/130164 <- copilot suggested lol
pattern = r"(?s)((?!Error raised while writing key '/?a').)*$"
pattern = r"(?s)^((?!Error raised while writing key '/?a').)*$"

with pytest_8_raises(IORegistryError, match=pattern):
write_elem(group, "/", {"a": {"b": Foo()}})
Expand Down

0 comments on commit 143141a

Please sign in to comment.