Fix error when package under test depends directly on unsafe dependencies

Fixes #65
This commit is contained in:
Ethan Paul 2021-10-28 20:09:56 -04:00
parent c322e68371
commit 1f6550e77c
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@ All exceptions should inherit from the common base exception :exc:`ToxPoetryInst
+-- LockedDepNotFoundError
+-- ExtraNotFoundError
+-- LockedDepsRequiredError
+-- RequiresUnsafeDepError
"""
@ -41,3 +42,7 @@ class ExtraNotFoundError(ToxPoetryInstallerException):
class LockedDepsRequiredError(ToxPoetryInstallerException):
"""Environment cannot specify unlocked dependencies when locked dependencies are required"""
class RequiresUnsafeDepError(ToxPoetryInstallerException):
"""Package under test depends on an unsafe dependency and cannot be installed"""

View File

@ -166,6 +166,11 @@ def find_project_deps(
:param extras: Sequence of extra names to include the dependencies of
"""
if any(dep.name in constants.UNSAFE_PACKAGES for dep in poetry.package.requires):
raise exceptions.RequiresUnsafeDepError(
f"Project package requires one or more unsafe dependencies ({', '.join(constants.UNSAFE_PACKAGES)}) which cannot be installed with Poetry"
)
base_deps: List[PoetryPackage] = [
packages[item.name]
for item in poetry.package.requires