Skip to content

Commit

Permalink
fix: create data dir in clean method (ApeWorX#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jul 2, 2024
1 parent e43fcc3 commit bd53c7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ape_node/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def __init__(
self._data_dir = data_dir
self._hostname = hostname
self._port = port
self._data_dir.mkdir(exist_ok=True, parents=True)
self.is_running = False
self._auto_disconnect = auto_disconnect

Expand Down Expand Up @@ -140,7 +139,6 @@ def __init__(
bal_dict = {"balance": str(initial_balance)}
alloc = {a: bal_dict for a in addresses}
genesis = create_genesis_data(alloc, chain_id)
self._data_dir.mkdir(parents=True, exist_ok=True)
initialize_chain(genesis, self.data_dir)
super().__init__(geth_kwargs)

Expand Down Expand Up @@ -209,6 +207,9 @@ def _clean(self):
if self._data_dir.is_dir():
shutil.rmtree(self._data_dir)

# dir must exist when initializing chain.
self._data_dir.mkdir(parents=True, exist_ok=True)

def wait(self, *args, **kwargs):
if self.proc is None:
return
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,10 @@ def clean():
):
actual = pm.sources.lookup(closest)
expected = nested_source_b
assert actual == expected, f"Failed to lookup {closest}"

# Using stem in case it returns `Contract.__mock__`, which is
# added / removed as part of other tests (running x-dist).
assert actual.stem == expected.stem, f"Failed to lookup {closest}"

finally:
clean()
Expand Down

0 comments on commit bd53c7a

Please sign in to comment.