mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Merged revisions 73170 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r73170 | tarek.ziade | 2009-06-03 13:12:08 +0200 (Wed, 03 Jun 2009) | 1 line more cleanup and test coverage for distutils.extension ........
This commit is contained in:
parent
e6ed2f9ea0
commit
68407219b7
2 changed files with 42 additions and 15 deletions
|
@ -1,8 +1,10 @@
|
|||
"""Tests for distutils.extension."""
|
||||
import unittest
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from distutils.extension import read_setup_file
|
||||
from test.support import check_warnings
|
||||
from distutils.extension import read_setup_file, Extension
|
||||
|
||||
class ExtensionTestCase(unittest.TestCase):
|
||||
|
||||
|
@ -28,6 +30,37 @@ class ExtensionTestCase(unittest.TestCase):
|
|||
|
||||
self.assertEquals(names, wanted)
|
||||
|
||||
def test_extension_init(self):
|
||||
# the first argument, which is the name, must be a string
|
||||
self.assertRaises(AssertionError, Extension, 1, [])
|
||||
ext = Extension('name', [])
|
||||
self.assertEquals(ext.name, 'name')
|
||||
|
||||
# the second argument, which is the list of files, must
|
||||
# be a list of strings
|
||||
self.assertRaises(AssertionError, Extension, 'name', 'file')
|
||||
self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
|
||||
ext = Extension('name', ['file1', 'file2'])
|
||||
self.assertEquals(ext.sources, ['file1', 'file2'])
|
||||
|
||||
# others arguments have defaults
|
||||
for attr in ('include_dirs', 'define_macros', 'undef_macros',
|
||||
'library_dirs', 'libraries', 'runtime_library_dirs',
|
||||
'extra_objects', 'extra_compile_args', 'extra_link_args',
|
||||
'export_symbols', 'swig_opts', 'depends'):
|
||||
self.assertEquals(getattr(ext, attr), [])
|
||||
|
||||
self.assertEquals(ext.language, None)
|
||||
self.assertEquals(ext.optional, None)
|
||||
|
||||
# if there are unknown keyword options, warn about them
|
||||
with check_warnings() as w:
|
||||
warnings.simplefilter('always')
|
||||
ext = Extension('name', ['file1', 'file2'], chic=True)
|
||||
|
||||
self.assertEquals(len(w.warnings), 1)
|
||||
self.assertEquals(str(w.warnings[0].message),
|
||||
"Unknown Extension options: 'chic'")
|
||||
|
||||
def test_suite():
|
||||
return unittest.makeSuite(ExtensionTestCase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue