Skip to content

Commit c1c14cd

Browse files
bugfix: maintain paths when tests are run inside a project subfolder
1 parent 5046636 commit c1c14cd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

brownie/test/managers/base.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
from hashlib import sha1
5-
from pathlib import Path
65

76
from brownie._config import ARGV, CONFIG
87
from brownie.project.scripts import _get_ast_hash
@@ -21,8 +20,9 @@ def __init__(self, config, project):
2120
self.node_map = {}
2221
self.isolated = {}
2322
self.skip = {}
24-
build = self.project._build
25-
self.contracts = dict((k, v["bytecodeSha1"]) for k, v in build.items() if v["bytecode"])
23+
self.contracts = dict(
24+
(k, v["bytecodeSha1"]) for k, v in project._build.items() if v["bytecode"]
25+
)
2626

2727
glob = self.project_path.glob("tests/**/conftest.py")
2828
self.conf_hashes = dict((self._path(i.parent), _get_ast_hash(i)) for i in glob)
@@ -35,7 +35,7 @@ def __init__(self, config, project):
3535
self.tests = dict(
3636
(k, v)
3737
for k, v in hashes["tests"].items()
38-
if Path(k).exists() and self._get_hash(k) == v["sha1"]
38+
if self.project_path.joinpath(k).exists() and self._get_hash(k) == v["sha1"]
3939
)
4040

4141
changed_contracts = set(
@@ -57,14 +57,14 @@ def __init__(self, config, project):
5757
coverage._add_cached_transaction(txhash, coverage_eval)
5858

5959
def _path(self, path):
60-
return Path(path).absolute().relative_to(self.project_path).as_posix()
60+
return self.project_path.joinpath(path).relative_to(self.project_path).as_posix()
6161

6262
def _test_id(self, nodeid):
6363
path, test_id = nodeid.split("::", maxsplit=1)
6464
return self._path(path), test_id
6565

6666
def _get_hash(self, path):
67-
hash_ = _get_ast_hash(path)
67+
hash_ = _get_ast_hash(self.project_path.joinpath(path))
6868
for confpath in filter(lambda k: k in path, sorted(self.conf_hashes)):
6969
hash_ += self.conf_hashes[confpath]
7070
return sha1(hash_.encode()).hexdigest()

0 commit comments

Comments
 (0)