Skip to content

Commit

Permalink
test: incease test verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Nov 8, 2024
1 parent cb4c04d commit 4c33075
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
hooks:
- id: clang-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.7.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ ban-relative-imports = "all"

[tool.pytest.ini_options]
verbosity_assertions = 3
faulthandler_timeout = 60
filterwarnings = [
"error",
"always",
Expand Down
46 changes: 25 additions & 21 deletions tests/test_treespec.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,27 +465,31 @@ def test_treespec_pickle_missing_registration():
treespec = optree.tree_structure(Foo(0, 1), namespace='foo')
serialized = pickle.dumps(treespec)

error = subprocess.check_output(
[
sys.executable,
'-c',
textwrap.dedent(
f"""
import pickle
import sys
try:
treespec = pickle.loads({serialized!r})
except Exception as ex:
print(ex)
else:
sys.exit(1)
""",
).strip(),
],
stderr=subprocess.STDOUT,
text=True,
).strip()
try:
error = subprocess.check_output(
[
sys.executable,
'-c',
textwrap.dedent(
f"""
import pickle
import sys
try:
treespec = pickle.loads({serialized!r})
except Exception as ex:
print(ex)
else:
sys.exit(1)
""",
).strip(),
],
stderr=subprocess.STDOUT,
text=True,
).strip()
except subprocess.CalledProcessError as ex:
raise RuntimeError(ex.stdout) from ex

assert re.match(
r"^Unknown custom type in pickled PyTreeSpec: <class '.*'> in namespace 'foo'\.$",
string=error,
Expand Down

0 comments on commit 4c33075

Please sign in to comment.