Skip to content

Commit

Permalink
Compat with newer pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Sep 25, 2024
1 parent b7ea0a1 commit c074daf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs-src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
HypoFuzz uses [calendar-based versioning](https://calver.org/), with a
`YY-MM-patch` format.

Fixed compatibility with Pytest 8.1 ([#35](https://github.com/Zac-HD/hypofuzz/issues/35)).

## 24.02.3
Fixed compatibility with Pytest 8.x ([#32](https://github.com/Zac-HD/hypofuzz/issues/32)).
Fixed compatibility with Pytest 8.0 ([#32](https://github.com/Zac-HD/hypofuzz/issues/32)).

## 24.02.2
Fixed a dashboard bug ([#31](https://github.com/Zac-HD/hypofuzz/issues/31)).
Expand Down
12 changes: 9 additions & 3 deletions src/hypofuzz/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import redirect_stdout, suppress
from functools import partial
from inspect import signature
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, get_type_hints

import pytest
import requests
Expand All @@ -21,7 +21,7 @@ class _ItemsCollector:
"""A pytest plugin which grabs all the fuzzable tests at the end of collection."""

def __init__(self) -> None:
self.fuzz_targets: List["FuzzProcess"] = []
self.fuzz_targets: List[FuzzProcess] = []

def pytest_collection_finish(self, session: pytest.Session) -> None:
from .hy import FuzzProcess
Expand All @@ -37,7 +37,13 @@ def pytest_collection_finish(self, session: pytest.Session) -> None:
# until we get full pytest compatibility it's an expedient approximation.
# The relevant internals changed in Pytest 8.0, so handle both cases...
if "ignore_args" in signature(manager.getfixtureclosure).parameters:
all_autouse = set(manager._getautousenames(item.nodeid))
from _pytest.nodes import Node

if get_type_hints(manager._getautousenames).get("node") == Node:
# from pytest 8.3 or thereabouts
all_autouse = set(manager._getautousenames(item))
else:
all_autouse = set(manager._getautousenames(item.nodeid))
else:
_, all_autouse, _ = manager.getfixtureclosure(
tuple(manager._getautousenames(item.nodeid)), item
Expand Down

0 comments on commit c074daf

Please sign in to comment.