diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2021-03-15 19:08:56 +0000 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2021-04-22 10:00:38 +0100 |
commit | f40c41d28fadcbbfd4f3325e0358f36468563f17 (patch) | |
tree | 0a2cfbe2eec507290890673286193e9135a21d4a | |
parent | 16a8553e9f7630951b5a21b74a1d39063ccb9689 (diff) | |
download | pbr-f40c41d28fadcbbfd4f3325e0358f36468563f17.tar.gz |
Add test for cfg -> py transformation
Change-Id: I176dc6a2c6d8f37717e1e17ba41ee72bef9536fb
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r-- | pbr/tests/test_util.py | 105 | ||||
-rw-r--r-- | pbr/util.py | 2 |
2 files changed, 104 insertions, 3 deletions
diff --git a/pbr/tests/test_util.py b/pbr/tests/test_util.py index 0a02fc1..f372d65 100644 --- a/pbr/tests/test_util.py +++ b/pbr/tests/test_util.py @@ -38,6 +38,108 @@ def config_from_ini(ini): return config +class TestBasics(base.BaseTestCase): + + def test_basics(self): + self.maxDiff = None + config_text = """ + [metadata] + name = foo + version = 1.0 + author = John Doe + author_email = jd@example.com + maintainer = Jim Burke + maintainer_email = jb@example.com + home_page = http://example.com + summary = A foobar project. + description = Hello, world. This is a long description. + download_url = http://opendev.org/x/pbr + classifier = + Development Status :: 5 - Production/Stable + Programming Language :: Python + platform = + any + license = Apache 2.0 + requires_dist = + Sphinx + requests + setup_requires_dist = + docutils + python_requires = >=3.6 + provides_dist = + bax + provides_extras = + bar + obsoletes_dist = + baz + + [files] + packages_root = src + packages = + foo + package_data = + "" = *.txt, *.rst + foo = *.msg + namespace_packages = + hello + data_files = + bitmaps = + bm/b1.gif + bm/b2.gif + config = + cfg/data.cfg + scripts = + scripts/hello-world.py + modules = + mod1 + """ + expected = { + 'name': u'foo', + 'version': u'1.0', + 'author': u'John Doe', + 'author_email': u'jd@example.com', + 'maintainer': u'Jim Burke', + 'maintainer_email': u'jb@example.com', + 'url': u'http://example.com', + 'description': u'A foobar project.', + 'long_description': u'Hello, world. This is a long description.', + 'download_url': u'http://opendev.org/x/pbr', + 'classifiers': [ + u'Development Status :: 5 - Production/Stable', + u'Programming Language :: Python', + ], + 'platforms': [u'any'], + 'license': u'Apache 2.0', + 'install_requires': [ + u'Sphinx', + u'requests', + ], + 'setup_requires': [u'docutils'], + 'python_requires': u'>=3.6', + 'provides': [u'bax'], + 'provides_extras': [u'bar'], + 'obsoletes': [u'baz'], + 'extras_require': {}, + + 'package_dir': {'': u'src'}, + 'packages': [u'foo'], + 'package_data': { + '': ['*.txt,', '*.rst'], + 'foo': ['*.msg'], + }, + 'namespace_packages': [u'hello'], + 'data_files': [ + ('bitmaps', ['bm/b1.gif', 'bm/b2.gif']), + ('config', ['cfg/data.cfg']), + ], + 'scripts': [u'scripts/hello-world.py'], + 'py_modules': [u'mod1'], + } + config = config_from_ini(config_text) + actual = util.setup_cfg_to_setup_kwargs(config) + self.assertDictEqual(expected, actual) + + class TestExtrasRequireParsingScenarios(base.BaseTestCase): scenarios = [ @@ -197,8 +299,7 @@ class TestDataFilesParsing(base.BaseTestCase): config = config_from_ini(self.config_text) kwargs = util.setup_cfg_to_setup_kwargs(config) - self.assertEqual(self.data_files, - list(kwargs['data_files'])) + self.assertEqual(self.data_files, kwargs['data_files']) class TestUTF8DescriptionFile(base.BaseTestCase): diff --git a/pbr/util.py b/pbr/util.py index 44b6a6e..a985c0e 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -406,7 +406,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): if arg == 'data_files': # the data_files value is a pointlessly different structure # from the package_data value - data_files = data_files.items() + data_files = sorted(data_files.items()) in_cfg_value = data_files elif arg == 'cmdclass': cmdclass = {} |