/usr/share/cagefs-skeleton/opt/cloudlinux/venv/lib/python3.11/site-packages/setuptools/tests
import random from unittest import mock import pytest from setuptools.command.build_clib import build_clib from setuptools.dist import Distribution from distutils.errors import DistutilsSetupError class TestBuildCLib: @mock.patch('setuptools.command.build_clib.newer_pairwise_group') def test_build_libraries(self, mock_newer): dist = Distribution() cmd = build_clib(dist) # this will be a long section, just making sure all # exceptions are properly raised libs = [('example', {'sources': 'broken.c'})] with pytest.raises(DistutilsSetupError): cmd.build_libraries(libs) obj_deps = 'some_string' libs = [('example', {'sources': ['source.c'], 'obj_deps': obj_deps})] with pytest.raises(DistutilsSetupError): cmd.build_libraries(libs) obj_deps = {'': ''} libs = [('example', {'sources': ['source.c'], 'obj_deps': obj_deps})] with pytest.raises(DistutilsSetupError): cmd.build_libraries(libs) obj_deps = {'source.c': ''} libs = [('example', {'sources': ['source.c'], 'obj_deps': obj_deps})] with pytest.raises(DistutilsSetupError): cmd.build_libraries(libs) # with that out of the way, let's see if the crude dependency # system works cmd.compiler = mock.MagicMock(spec=cmd.compiler) mock_newer.return_value = ([], []) obj_deps = {'': ('global.h',), 'example.c': ('example.h',)} libs = [('example', {'sources': ['example.c'], 'obj_deps': obj_deps})] cmd.build_libraries(libs) assert [['example.c', 'global.h', 'example.h']] in mock_newer.call_args[0] assert not cmd.compiler.compile.called assert cmd.compiler.create_static_lib.call_count == 1 # reset the call numbers so we can test again cmd.compiler.reset_mock() mock_newer.return_value = '' # anything as long as it's not ([],[]) cmd.build_libraries(libs) assert cmd.compiler.compile.call_count == 1 assert cmd.compiler.create_static_lib.call_count == 1 @mock.patch('setuptools.command.build_clib.newer_pairwise_group') def test_build_libraries_reproducible(self, mock_newer): dist = Distribution() cmd = build_clib(dist) # with that out of the way, let's see if the crude dependency # system works cmd.compiler = mock.MagicMock(spec=cmd.compiler) mock_newer.return_value = ([], []) original_sources = ['a-example.c', 'example.c'] sources = original_sources obj_deps = {'': ('global.h',), 'example.c': ('example.h',)} libs = [('example', {'sources': sources, 'obj_deps': obj_deps})] cmd.build_libraries(libs) computed_call_args = mock_newer.call_args[0] while sources == original_sources: sources = random.sample(original_sources, len(original_sources)) libs = [('example', {'sources': sources, 'obj_deps': obj_deps})] cmd.build_libraries(libs) assert computed_call_args == mock_newer.call_args[0]
.
Edit
..
Edit
__init__.py
Edit
__pycache__
Edit
compat
Edit
config
Edit
contexts.py
Edit
environment.py
Edit
fixtures.py
Edit
indexes
Edit
integration
Edit
mod_with_constant.py
Edit
namespaces.py
Edit
script-with-bom.py
Edit
server.py
Edit
test_archive_util.py
Edit
test_bdist_deprecations.py
Edit
test_bdist_egg.py
Edit
test_bdist_wheel.py
Edit
test_build.py
Edit
test_build_clib.py
Edit
test_build_ext.py
Edit
test_build_meta.py
Edit
test_build_py.py
Edit
test_config_discovery.py
Edit
test_core_metadata.py
Edit
test_depends.py
Edit
test_develop.py
Edit
test_dist.py
Edit
test_dist_info.py
Edit
test_distutils_adoption.py
Edit
test_easy_install.py
Edit
test_editable_install.py
Edit
test_egg_info.py
Edit
test_extern.py
Edit
test_find_packages.py
Edit
test_find_py_modules.py
Edit
test_glob.py
Edit
test_install_scripts.py
Edit
test_logging.py
Edit
test_manifest.py
Edit
test_namespaces.py
Edit
test_packageindex.py
Edit
test_sandbox.py
Edit
test_sdist.py
Edit
test_setopt.py
Edit
test_setuptools.py
Edit
test_shutil_wrapper.py
Edit
test_unicode_utils.py
Edit
test_virtualenv.py
Edit
test_warnings.py
Edit
test_wheel.py
Edit
test_windows_wrappers.py
Edit
text.py
Edit
textwrap.py
Edit