Initial tests for PEP 517 backend calls

This commit is contained in:
Paul Moore 2018-08-01 15:51:17 +01:00
parent bb4688cb8f
commit 873bae7b44
3 changed files with 31 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,27 @@
from pip._internal.build_env import BuildEnvironment
from pip._internal.download import PipSession
from pip._internal.index import PackageFinder
from pip._internal.req import InstallRequirement
from pip._vendor import pytoml
def make_project(tmpdir, requires=[], backend=None):
buildsys = {'requires': requires}
if backend:
buildsys['build-backend'] = backend
data = pytoml.dumps({'build-system': buildsys})
tmpdir.join('pyproject.toml').write(data)
return tmpdir
def test_backend(tmpdir, data):
"""Can we call a requirement's backend successfully?"""
project = make_project(tmpdir, backend="dummy_backend")
req = InstallRequirement(None, None, source_dir=project)
env = BuildEnvironment()
finder = PackageFinder([data.backends], [], session=PipSession())
env.install_requirements(finder, ["dummy_backend"], "Installing")
assert hasattr(req.pep517_backend, 'build_wheel')
with env:
assert req.pep517_backend.build_wheel("dir") == "Backend called"

View File

@ -128,6 +128,10 @@ class TestData(object):
def find_links3(self):
return path_to_url(self.packages3)
@property
def backends(self):
return path_to_url(self.root.join("backends"))
def index_url(self, index="simple"):
return path_to_url(self.root.join("indexes", index))