summaryrefslogtreecommitdiff
path: root/tests/testutils
diff options
context:
space:
mode:
authorShahwat Dalal <sdalal29@bloomberg.net>2019-04-23 09:45:21 +0100
committerChandan Singh <chandan@chandansingh.net>2019-05-14 22:50:59 +0000
commitf79351d65c99757ba5f7806e4b0d9c706fca518e (patch)
tree9673b52c754e205619d89138afc6bd99afaa0e11 /tests/testutils
parenteb9f7a8ce0f98a46a32a0a3c41939308e72aaa30 (diff)
downloadbuildstream-f79351d65c99757ba5f7806e4b0d9c706fca518e.tar.gz
tests: Allow `python_repo` to install nested package deps
In order to ensure that pip_source is pulling transitive dependencies, adapted python_repo to use `install_reqiures` in its default setup script.
Diffstat (limited to 'tests/testutils')
-rw-r--r--tests/testutils/python_repo.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/testutils/python_repo.py b/tests/testutils/python_repo.py
index fcaf2d293..c8e5bf343 100644
--- a/tests/testutils/python_repo.py
+++ b/tests/testutils/python_repo.py
@@ -15,6 +15,7 @@ setup(
version='{version}',
description='{name}',
packages=['{pkgdirname}'],
+ install_requires={pkgdeps},
entry_points={{
'console_scripts': [
'{pkgdirname}={pkgdirname}:main'
@@ -56,7 +57,9 @@ HTML_TEMPLATE = '''\
# Returns:
# None
#
-def generate_pip_package(tmpdir, pypi, name, version='0.1'):
+def generate_pip_package(tmpdir, pypi, name, version='0.1', dependencies=None):
+ if dependencies is None:
+ dependencies = []
# check if package already exists in pypi
pypi_package = os.path.join(pypi, re.sub('[^0-9a-zA-Z]+', '-', name))
if os.path.exists(pypi_package):
@@ -77,7 +80,8 @@ def generate_pip_package(tmpdir, pypi, name, version='0.1'):
SETUP_TEMPLATE.format(
name=name,
version=version,
- pkgdirname=pkgdirname
+ pkgdirname=pkgdirname,
+ pkgdeps=dependencies
)
)
os.chmod(setup_file, 0o755)
@@ -125,8 +129,10 @@ def setup_pypi_repo(tmpdir):
return pkgdir
def add_packages(packages, pypi_repo):
- for package in packages:
+ for package, dependencies in packages.items():
pkgdir = create_pkgdir(package)
- generate_pip_package(pkgdir, pypi_repo, package)
+ generate_pip_package(pkgdir, pypi_repo, package, dependencies=list(dependencies.keys()))
+ for dependency, dependency_dependencies in dependencies.items():
+ add_packages({dependency: dependency_dependencies}, pypi_repo)
return add_packages