summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests/test_config.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2012-02-04 20:53:07 (GMT)
committerÉric Araujo <merwok@netwok.org>2012-02-04 20:53:07 (GMT)
commit31aefde8760c3d407ffe8dc044e5ae8f5daeb12c (patch)
tree603b62a6b4d6fee4d984dcf112526cd178e4bae1 /Lib/packaging/tests/test_config.py
parent591f6e82bd24361b7628bcb47830e18efb354db2 (diff)
downloadcpython-31aefde8760c3d407ffe8dc044e5ae8f5daeb12c.zip
cpython-31aefde8760c3d407ffe8dc044e5ae8f5daeb12c.tar.gz
cpython-31aefde8760c3d407ffe8dc044e5ae8f5daeb12c.tar.bz2
Allow multiple values for package_data in setup.cfg (#11805).
Even though the resources system obsoletes data_files and package_data (see bug discussion), package_data still exists to allow compatibility with distutils and thus an easier transition. In setup.py, the values are lists of glob patterns, so the setup.cfg syntax needed a way to express multiple values too. Doc for this option will be added later as part of the big packaging doc patches. For now, the test serves as example. Reported by Erik Bray.
Diffstat (limited to 'Lib/packaging/tests/test_config.py')
-rw-r--r--Lib/packaging/tests/test_config.py37
1 files changed, 30 insertions, 7 deletions
diff --git a/Lib/packaging/tests/test_config.py b/Lib/packaging/tests/test_config.py
index 613d493..0d76b29 100644
--- a/Lib/packaging/tests/test_config.py
+++ b/Lib/packaging/tests/test_config.py
@@ -66,11 +66,15 @@ scripts =
bin/taunt
package_data =
- cheese = data/templates/*
+ cheese = data/templates/* doc/*
+ doc/images/*.png
+
extra_files = %(extra-files)s
# Replaces MANIFEST.in
+# FIXME no, it's extra_files
+# (but sdist_extra is a better name, should use it)
sdist_extra =
include THANKS HACKING
recursive-include examples *.txt *.py
@@ -96,6 +100,17 @@ setup_hooks = %(setup-hooks)s
sub_commands = foo
"""
+SETUP_CFG_PKGDATA_BUGGY_1 = """
+[files]
+package_data = foo.*
+"""
+
+SETUP_CFG_PKGDATA_BUGGY_2 = """
+[files]
+package_data =
+ foo.*
+"""
+
# Can not be merged with SETUP_CFG else install_dist
# command will fail when trying to compile C sources
# TODO use a DummyCommand to mock build_ext
@@ -276,13 +291,14 @@ class ConfigTestCase(support.TempdirManager,
self.assertEqual(dist.packages, ['one', 'two', 'three'])
self.assertEqual(dist.py_modules, ['haven'])
- self.assertEqual(dist.package_data, {'cheese': 'data/templates/*'})
- self.assertEqual(
+ self.assertEqual(dist.package_data,
+ {'cheese': ['data/templates/*', 'doc/*',
+ 'doc/images/*.png']})
+ self.assertEqual(dist.data_files,
{'bm/b1.gif': '{icon}/b1.gif',
'bm/b2.gif': '{icon}/b2.gif',
'Cfg/data.CFG': '{config}/baBar/data.CFG',
- 'init_script': '{script}/JunGle/init_script'},
- dist.data_files)
+ 'init_script': '{script}/JunGle/init_script'})
self.assertEqual(dist.package_dir, 'src')
@@ -293,8 +309,8 @@ class ConfigTestCase(support.TempdirManager,
# this file would be __main__.Foo when run as "python test_config.py".
# The name FooBarBazTest should be unique enough to prevent
# collisions.
- self.assertEqual('FooBarBazTest',
- dist.get_command_obj('foo').__class__.__name__)
+ self.assertEqual(dist.get_command_obj('foo').__class__.__name__,
+ 'FooBarBazTest')
# did the README got loaded ?
self.assertEqual(dist.metadata['description'], 'yeah')
@@ -304,6 +320,13 @@ class ConfigTestCase(support.TempdirManager,
d = new_compiler(compiler='d')
self.assertEqual(d.description, 'D Compiler')
+ # check error reporting for invalid package_data value
+ self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_1)
+ self.assertRaises(PackagingOptionError, self.get_dist)
+
+ self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_2)
+ self.assertRaises(PackagingOptionError, self.get_dist)
+
def test_multiple_description_file(self):
self.write_setup({'description-file': 'README CHANGES'})
self.write_file('README', 'yeah')