summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-06-10 22:33:38 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-06-10 22:33:38 (GMT)
commit643cb7345f66f0d9dbc1066567ffb1d519026388 (patch)
treefa095182a816176836bb48d9d0e29dfa96862a98 /Lib/packaging/tests
parent8474f2901b78cc9afe9487ed9236430f43be18b7 (diff)
downloadcpython-643cb7345f66f0d9dbc1066567ffb1d519026388.zip
cpython-643cb7345f66f0d9dbc1066567ffb1d519026388.tar.gz
cpython-643cb7345f66f0d9dbc1066567ffb1d519026388.tar.bz2
Allow multiple setup hooks in packaging’s setup.cfg files (#12240).
Original patch by Erik Bray.
Diffstat (limited to 'Lib/packaging/tests')
-rw-r--r--Lib/packaging/tests/test_config.py36
-rw-r--r--Lib/packaging/tests/test_util.py2
2 files changed, 30 insertions, 8 deletions
diff --git a/Lib/packaging/tests/test_config.py b/Lib/packaging/tests/test_config.py
index 1669862..6be63eb 100644
--- a/Lib/packaging/tests/test_config.py
+++ b/Lib/packaging/tests/test_config.py
@@ -90,7 +90,7 @@ commands =
compilers =
packaging.tests.test_config.DCompiler
-setup_hook = %(setup-hook)s
+setup_hooks = %(setup-hooks)s
@@ -135,8 +135,16 @@ class DCompiler:
pass
-def hook(content):
- content['metadata']['version'] += '.dev1'
+def version_hook(config):
+ config['metadata']['version'] += '.dev1'
+
+
+def first_hook(config):
+ config['files']['modules'] += '\n first'
+
+
+def third_hook(config):
+ config['files']['modules'] += '\n third'
class FooBarBazTest:
@@ -186,7 +194,7 @@ class ConfigTestCase(support.TempdirManager,
def write_setup(self, kwargs=None):
opts = {'description-file': 'README', 'extra-files': '',
- 'setup-hook': 'packaging.tests.test_config.hook'}
+ 'setup-hooks': 'packaging.tests.test_config.version_hook'}
if kwargs:
opts.update(kwargs)
self.write_file('setup.cfg', SETUP_CFG % opts, encoding='utf-8')
@@ -318,13 +326,27 @@ class ConfigTestCase(support.TempdirManager,
self.assertEqual(ext.extra_compile_args, cargs)
self.assertEqual(ext.language, 'cxx')
- def test_missing_setuphook_warns(self):
- self.write_setup({'setup-hook': 'this.does._not.exist'})
+ def test_missing_setup_hook_warns(self):
+ self.write_setup({'setup-hooks': 'this.does._not.exist'})
self.write_file('README', 'yeah')
dist = self.get_dist()
logs = self.get_logs(logging.WARNING)
self.assertEqual(1, len(logs))
- self.assertIn('could not import setup_hook', logs[0])
+ self.assertIn('cannot find setup hook', logs[0])
+
+ def test_multiple_setup_hooks(self):
+ self.write_setup({
+ 'setup-hooks': '\n packaging.tests.test_config.first_hook'
+ '\n packaging.tests.test_config.missing_hook'
+ '\n packaging.tests.test_config.third_hook'
+ })
+ self.write_file('README', 'yeah')
+ dist = self.get_dist()
+
+ self.assertEqual(['haven', 'first', 'third'], dist.py_modules)
+ logs = self.get_logs(logging.WARNING)
+ self.assertEqual(1, len(logs))
+ self.assertIn('cannot find setup hook', logs[0])
def test_metadata_requires_description_files_missing(self):
self.write_setup({'description-file': 'README README2'})
diff --git a/Lib/packaging/tests/test_util.py b/Lib/packaging/tests/test_util.py
index 68ad8eb..f657ab2 100644
--- a/Lib/packaging/tests/test_util.py
+++ b/Lib/packaging/tests/test_util.py
@@ -495,7 +495,7 @@ class UtilTestCase(support.EnvironRestorer,
def test_cfg_to_args(self):
opts = {'description-file': 'README', 'extra-files': '',
- 'setup-hook': 'packaging.tests.test_config.hook'}
+ 'setup-hooks': 'packaging.tests.test_config.version_hook'}
self.write_file('setup.cfg', SETUP_CFG % opts)
self.write_file('README', 'loooong description')