From 225e8823221ac724336c1039111964b02d8363a3 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 10 Aug 2017 11:23:10 -0500 Subject: [PATCH] Put test-requirements into an extra named 'test' In bindep files we use a 'test' environment to indicate dependencies that are needed for testing. Make the same thing available for our python dependencies, allowing things like "pip install .[test]" or "pip install shade[test]" to work. Change-Id: If3ad8b6a79a8cab2f7434b73207f35384e8516ba --- pbr/tests/test_util.py | 8 ++++++-- pbr/tests/testpackage/test-requirements.txt | 1 + pbr/util.py | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pbr/tests/test_util.py b/pbr/tests/test_util.py index 048b2b96..370a7dee 100644 --- a/pbr/tests/test_util.py +++ b/pbr/tests/test_util.py @@ -36,8 +36,12 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase): baz>=3.2 foo """, - 'expected_extra_requires': {'first': ['foo', 'bar==1.0'], - 'second': ['baz>=3.2', 'foo']} + 'expected_extra_requires': { + 'first': ['foo', 'bar==1.0'], + 'second': ['baz>=3.2', 'foo'], + 'test': ['requests-mock'], + "test:(python_version=='2.6')": ['ordereddict'], + } }), ('with_markers', { 'config_text': """ diff --git a/pbr/tests/testpackage/test-requirements.txt b/pbr/tests/testpackage/test-requirements.txt index f283aff5..8755eb4c 100644 --- a/pbr/tests/testpackage/test-requirements.txt +++ b/pbr/tests/testpackage/test-requirements.txt @@ -1 +1,2 @@ ordereddict;python_version=='2.6' +requests-mock diff --git a/pbr/util.py b/pbr/util.py index ef4deb01..75fa01cd 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -401,6 +401,13 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): if 'extras' in config: requirement_pattern = '(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$' extras = config['extras'] + # Add contents of test-requirements, if any, into an extra named + # 'test' if one does not already exist. + if 'test' not in extras: + from pbr import packaging + extras['test'] = "\n".join(packaging.parse_requirements( + packaging.TEST_REQUIREMENTS_FILES)).replace(';', ':') + for extra in extras: extra_requirements = [] requirements = split_multiline(extras[extra])