summaryrefslogtreecommitdiff
path: root/setuptools/_distutils/tests/test_build_clib.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/_distutils/tests/test_build_clib.py')
-rw-r--r--setuptools/_distutils/tests/test_build_clib.py58
1 files changed, 30 insertions, 28 deletions
diff --git a/setuptools/_distutils/tests/test_build_clib.py b/setuptools/_distutils/tests/test_build_clib.py
index c8fbb5c2..2048e29a 100644
--- a/setuptools/_distutils/tests/test_build_clib.py
+++ b/setuptools/_distutils/tests/test_build_clib.py
@@ -8,40 +8,38 @@ from test.support import missing_compiler_executable
from distutils.command.build_clib import build_clib
from distutils.errors import DistutilsSetupError
from distutils.tests import support
+import pytest
-class BuildCLibTestCase(
- support.TempdirManager, support.LoggingSilencer, unittest.TestCase
-):
+class TestBuildCLib(support.TempdirManager, support.LoggingSilencer):
def test_check_library_dist(self):
pkg_dir, dist = self.create_dist()
cmd = build_clib(dist)
# 'libraries' option must be a list
- self.assertRaises(DistutilsSetupError, cmd.check_library_list, 'foo')
+ with pytest.raises(DistutilsSetupError):
+ cmd.check_library_list('foo')
# each element of 'libraries' must a 2-tuple
- self.assertRaises(DistutilsSetupError, cmd.check_library_list, ['foo1', 'foo2'])
+ with pytest.raises(DistutilsSetupError):
+ cmd.check_library_list(['foo1', 'foo2'])
# first element of each tuple in 'libraries'
# must be a string (the library name)
- self.assertRaises(
- DistutilsSetupError, cmd.check_library_list, [(1, 'foo1'), ('name', 'foo2')]
- )
+ with pytest.raises(DistutilsSetupError):
+ cmd.check_library_list([(1, 'foo1'), ('name', 'foo2')])
# library name may not contain directory separators
- self.assertRaises(
- DistutilsSetupError,
- cmd.check_library_list,
- [('name', 'foo1'), ('another/name', 'foo2')],
- )
+ with pytest.raises(DistutilsSetupError):
+ cmd.check_library_list(
+ [('name', 'foo1'), ('another/name', 'foo2')],
+ )
# second element of each tuple must be a dictionary (build info)
- self.assertRaises(
- DistutilsSetupError,
- cmd.check_library_list,
- [('name', {}), ('another', 'foo2')],
- )
+ with pytest.raises(DistutilsSetupError):
+ cmd.check_library_list(
+ [('name', {}), ('another', 'foo2')],
+ )
# those work
libs = [('name', {}), ('name', {'ok': 'good'})]
@@ -54,22 +52,24 @@ class BuildCLibTestCase(
# "in 'libraries' option 'sources' must be present and must be
# a list of source filenames
cmd.libraries = [('name', {})]
- self.assertRaises(DistutilsSetupError, cmd.get_source_files)
+ with pytest.raises(DistutilsSetupError):
+ cmd.get_source_files()
cmd.libraries = [('name', {'sources': 1})]
- self.assertRaises(DistutilsSetupError, cmd.get_source_files)
+ with pytest.raises(DistutilsSetupError):
+ cmd.get_source_files()
cmd.libraries = [('name', {'sources': ['a', 'b']})]
- self.assertEqual(cmd.get_source_files(), ['a', 'b'])
+ assert cmd.get_source_files() == ['a', 'b']
cmd.libraries = [('name', {'sources': ('a', 'b')})]
- self.assertEqual(cmd.get_source_files(), ['a', 'b'])
+ assert cmd.get_source_files() == ['a', 'b']
cmd.libraries = [
('name', {'sources': ('a', 'b')}),
('name2', {'sources': ['c', 'd']}),
]
- self.assertEqual(cmd.get_source_files(), ['a', 'b', 'c', 'd'])
+ assert cmd.get_source_files() == ['a', 'b', 'c', 'd']
def test_build_libraries(self):
@@ -86,7 +86,8 @@ class BuildCLibTestCase(
# build_libraries is also doing a bit of typo checking
lib = [('name', {'sources': 'notvalid'})]
- self.assertRaises(DistutilsSetupError, cmd.build_libraries, lib)
+ with pytest.raises(DistutilsSetupError):
+ cmd.build_libraries(lib)
lib = [('name', {'sources': list()})]
cmd.build_libraries(lib)
@@ -100,14 +101,15 @@ class BuildCLibTestCase(
cmd.include_dirs = 'one-dir'
cmd.finalize_options()
- self.assertEqual(cmd.include_dirs, ['one-dir'])
+ assert cmd.include_dirs == ['one-dir']
cmd.include_dirs = None
cmd.finalize_options()
- self.assertEqual(cmd.include_dirs, [])
+ assert cmd.include_dirs == []
cmd.distribution.libraries = 'WONTWORK'
- self.assertRaises(DistutilsSetupError, cmd.finalize_options)
+ with pytest.raises(DistutilsSetupError):
+ cmd.finalize_options()
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
def test_run(self):
@@ -133,4 +135,4 @@ class BuildCLibTestCase(
cmd.run()
# let's check the result
- self.assertIn('libfoo.a', os.listdir(build_temp))
+ assert 'libfoo.a' in os.listdir(build_temp)