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
This commit is contained in:
Monty Taylor 2017-08-10 11:23:10 -05:00 committed by Stephen Finucane
parent cd3e4f2949
commit 225e882322
3 changed files with 14 additions and 2 deletions

View File

@ -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': """

View File

@ -1 +1,2 @@
ordereddict;python_version=='2.6'
requests-mock

View File

@ -401,6 +401,13 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
if 'extras' in config:
requirement_pattern = '(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\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])