Skip to content

Commit 7ce673b

Browse files
Fix bug when running tests from outside of the installed package
1 parent cd338a9 commit 7ce673b

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

tests/test_latest.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@
1414
from rad import resources
1515
from rad._parser import archive_schema, super_schema
1616

17-
DIRECT_URL = json.loads(Distribution.from_name("rad").read_text("direct_url.json"))
18-
# Needs to be a bit complicated because tox still creates a wheel, it just does it a bit differently
19-
# to preserve editable installs
20-
IS_EDITABLE = DIRECT_URL["dir_info"].get("editable", False) if "dir_info" in DIRECT_URL else "editable" in DIRECT_URL["url"]
17+
_DIRECT_URL = Distribution.from_name("rad").read_text("direct_url.json")
18+
19+
# If no text is found, then you maybe running from a directory with a `rad` subdirectory
20+
# Distribution will then search for `rad` within that subdirectory, so we assume not editable
21+
if _DIRECT_URL is None:
22+
IS_EDITABLE = False
23+
else:
24+
_DIRECT_URL_JSON = json.loads(_DIRECT_URL)
25+
# Needs to be a bit complicated because tox still creates a wheel, it just does it a bit differently
26+
# to preserve editable installs
27+
IS_EDITABLE = (
28+
_DIRECT_URL_JSON["dir_info"].get("editable", False)
29+
if "dir_info" in _DIRECT_URL_JSON
30+
else "editable" in _DIRECT_URL_JSON["url"]
31+
)
2132

2233

2334
class TestLastestResources:

0 commit comments

Comments
 (0)