Skip to content

Commit

Permalink
fix: handle when a provider is not TestProviderAPI subclass during …
Browse files Browse the repository at this point in the history
…ape-test fixture setup (#2424)
  • Loading branch information
antazoey authored Dec 19, 2024
1 parent 2ff21f2 commit b244c30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ape/pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def is_stateful(self, name: str) -> Optional[bool]:
except (NotImplementedError, ProviderNotConnectedError):
# Assume it's on since it can't be turned off.
is_auto_mine = True
except AttributeError:
# If not a test-provider, we don't know.
return None

if not is_auto_mine:
# When auto-mine is disabled, it's unknown.
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ def test_is_stateful(self, fixture_manager, item):
fixture_manager.add_fixture_info("bar", setup_block=1, teardown_block=2)
assert fixture_manager.is_stateful("bar") is True

def test_is_stateful_when_not_using_test_provider(self, networks, fixture_manager, item):
fixture_manager._stateful_fixtures_cache = {}
live_provider = networks.ethereum.sepolia.get_provider("node")
provider = networks.active_provider
networks.active_provider = live_provider
for fixture in ("foo", "bar"):
actual = fixture_manager.is_stateful(fixture)
networks.active_provider = provider
assert actual is None

def test_rebase(self, mocker, fixture_manager, fixture_map, create_fixture_info):
# We must have already started our module-scope isolation.
isolation_manager = IsolationManager(fixture_manager.config_wrapper, mocker.MagicMock())
Expand Down

0 comments on commit b244c30

Please sign in to comment.