xcoll 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +2 -1
- xcoll/beam_elements/__init__.py +7 -1
- xcoll/beam_elements/absorber.py +2 -2
- xcoll/beam_elements/base.py +105 -67
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
- xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
- xcoll/beam_elements/elements_src/blowup.h +42 -0
- xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
- xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +19 -2
- xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
- xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
- xcoll/beam_elements/everest.py +5 -6
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +103 -74
- xcoll/general.py +4 -4
- xcoll/initial_distribution.py +18 -6
- xcoll/install.py +3 -1
- xcoll/interaction_record/interaction_record.py +126 -80
- xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
- xcoll/line_tools.py +8 -9
- xcoll/lossmap.py +48 -38
- xcoll/scattering_routines/everest/amorphous.h +4 -11
- xcoll/scattering_routines/everest/channeling.h +3 -8
- xcoll/scattering_routines/everest/everest.h +4 -1
- xcoll/scattering_routines/everest/jaw.h +4 -3
- xcoll/scattering_routines/everest/materials.py +35 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
- xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
- xcoll/scattering_routines/everest/properties.h +6 -1
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/geant4/collimasim/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
- xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
- xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
- xcoll/scattering_routines/geometry/collimator_geometry.h +9 -10
- xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.4.0.dist-info/RECORD +0 -126
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
# CMakeLists.txt -- Build system for the pybind11 test suite
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
|
|
4
|
+
#
|
|
5
|
+
# All rights reserved. Use of this source code is governed by a
|
|
6
|
+
# BSD-style license that can be found in the LICENSE file.
|
|
7
|
+
|
|
8
|
+
cmake_minimum_required(VERSION 3.4)
|
|
9
|
+
|
|
10
|
+
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
|
|
11
|
+
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
|
12
|
+
# the behavior using the following workaround:
|
|
13
|
+
if(${CMAKE_VERSION} VERSION_LESS 3.21)
|
|
14
|
+
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
|
15
|
+
else()
|
|
16
|
+
cmake_policy(VERSION 3.21)
|
|
17
|
+
endif()
|
|
18
|
+
|
|
19
|
+
# Only needed for CMake < 3.5 support
|
|
20
|
+
include(CMakeParseArguments)
|
|
21
|
+
|
|
22
|
+
# Filter out items; print an optional message if any items filtered
|
|
23
|
+
#
|
|
24
|
+
# Usage:
|
|
25
|
+
# pybind11_filter_tests(LISTNAME file1.cpp file2.cpp ... MESSAGE "")
|
|
26
|
+
#
|
|
27
|
+
macro(pybind11_filter_tests LISTNAME)
|
|
28
|
+
cmake_parse_arguments(ARG "" "MESSAGE" "" ${ARGN})
|
|
29
|
+
set(PYBIND11_FILTER_TESTS_FOUND OFF)
|
|
30
|
+
foreach(filename IN LISTS ARG_UNPARSED_ARGUMENTS)
|
|
31
|
+
list(FIND ${LISTNAME} ${filename} _FILE_FOUND)
|
|
32
|
+
if(_FILE_FOUND GREATER -1)
|
|
33
|
+
list(REMOVE_AT ${LISTNAME} ${_FILE_FOUND})
|
|
34
|
+
set(PYBIND11_FILTER_TESTS_FOUND ON)
|
|
35
|
+
endif()
|
|
36
|
+
endforeach()
|
|
37
|
+
if(PYBIND11_FILTER_TESTS_FOUND AND ARG_MESSAGE)
|
|
38
|
+
message(STATUS "${ARG_MESSAGE}")
|
|
39
|
+
endif()
|
|
40
|
+
endmacro()
|
|
41
|
+
|
|
42
|
+
macro(possibly_uninitialized)
|
|
43
|
+
foreach(VARNAME ${ARGN})
|
|
44
|
+
if(NOT DEFINED "${VARNAME}")
|
|
45
|
+
set("${VARNAME}" "")
|
|
46
|
+
endif()
|
|
47
|
+
endforeach()
|
|
48
|
+
endmacro()
|
|
49
|
+
|
|
50
|
+
# New Python support
|
|
51
|
+
if(DEFINED Python_EXECUTABLE)
|
|
52
|
+
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
|
|
53
|
+
set(PYTHON_VERSION "${Python_VERSION}")
|
|
54
|
+
endif()
|
|
55
|
+
|
|
56
|
+
# There's no harm in including a project in a project
|
|
57
|
+
project(pybind11_tests CXX)
|
|
58
|
+
|
|
59
|
+
# Access FindCatch and more
|
|
60
|
+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tools")
|
|
61
|
+
|
|
62
|
+
option(PYBIND11_WERROR "Report all warnings as errors" OFF)
|
|
63
|
+
option(DOWNLOAD_EIGEN "Download EIGEN (requires CMake 3.11+)" OFF)
|
|
64
|
+
option(PYBIND11_CUDA_TESTS "Enable building CUDA tests (requires CMake 3.12+)" OFF)
|
|
65
|
+
set(PYBIND11_TEST_OVERRIDE
|
|
66
|
+
""
|
|
67
|
+
CACHE STRING "Tests from ;-separated list of *.cpp files will be built instead of all tests")
|
|
68
|
+
set(PYBIND11_TEST_FILTER
|
|
69
|
+
""
|
|
70
|
+
CACHE STRING "Tests from ;-separated list of *.cpp files will be removed from all tests")
|
|
71
|
+
|
|
72
|
+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
73
|
+
# We're being loaded directly, i.e. not via add_subdirectory, so make this
|
|
74
|
+
# work as its own project and load the pybind11Config to get the tools we need
|
|
75
|
+
find_package(pybind11 REQUIRED CONFIG)
|
|
76
|
+
endif()
|
|
77
|
+
|
|
78
|
+
if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
|
79
|
+
message(STATUS "Setting tests build type to MinSizeRel as none was specified")
|
|
80
|
+
set(CMAKE_BUILD_TYPE
|
|
81
|
+
MinSizeRel
|
|
82
|
+
CACHE STRING "Choose the type of build." FORCE)
|
|
83
|
+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel"
|
|
84
|
+
"RelWithDebInfo")
|
|
85
|
+
endif()
|
|
86
|
+
|
|
87
|
+
if(PYBIND11_CUDA_TESTS)
|
|
88
|
+
enable_language(CUDA)
|
|
89
|
+
if(DEFINED CMAKE_CXX_STANDARD)
|
|
90
|
+
set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD})
|
|
91
|
+
endif()
|
|
92
|
+
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
|
|
93
|
+
endif()
|
|
94
|
+
|
|
95
|
+
# Full set of test files (you can override these; see below)
|
|
96
|
+
set(PYBIND11_TEST_FILES
|
|
97
|
+
test_async.cpp
|
|
98
|
+
test_buffers.cpp
|
|
99
|
+
test_builtin_casters.cpp
|
|
100
|
+
test_call_policies.cpp
|
|
101
|
+
test_callbacks.cpp
|
|
102
|
+
test_chrono.cpp
|
|
103
|
+
test_class.cpp
|
|
104
|
+
test_constants_and_functions.cpp
|
|
105
|
+
test_copy_move.cpp
|
|
106
|
+
test_custom_type_casters.cpp
|
|
107
|
+
test_custom_type_setup.cpp
|
|
108
|
+
test_docstring_options.cpp
|
|
109
|
+
test_eigen.cpp
|
|
110
|
+
test_enum.cpp
|
|
111
|
+
test_eval.cpp
|
|
112
|
+
test_exceptions.cpp
|
|
113
|
+
test_factory_constructors.cpp
|
|
114
|
+
test_gil_scoped.cpp
|
|
115
|
+
test_iostream.cpp
|
|
116
|
+
test_kwargs_and_defaults.cpp
|
|
117
|
+
test_local_bindings.cpp
|
|
118
|
+
test_methods_and_attributes.cpp
|
|
119
|
+
test_modules.cpp
|
|
120
|
+
test_multiple_inheritance.cpp
|
|
121
|
+
test_numpy_array.cpp
|
|
122
|
+
test_numpy_dtypes.cpp
|
|
123
|
+
test_numpy_vectorize.cpp
|
|
124
|
+
test_opaque_types.cpp
|
|
125
|
+
test_operator_overloading.cpp
|
|
126
|
+
test_pickling.cpp
|
|
127
|
+
test_pytypes.cpp
|
|
128
|
+
test_sequences_and_iterators.cpp
|
|
129
|
+
test_smart_ptr.cpp
|
|
130
|
+
test_stl.cpp
|
|
131
|
+
test_stl_binders.cpp
|
|
132
|
+
test_tagbased_polymorphic.cpp
|
|
133
|
+
test_thread.cpp
|
|
134
|
+
test_union.cpp
|
|
135
|
+
test_virtual_functions.cpp)
|
|
136
|
+
|
|
137
|
+
# Invoking cmake with something like:
|
|
138
|
+
# cmake -DPYBIND11_TEST_OVERRIDE="test_callbacks.cpp;test_pickling.cpp" ..
|
|
139
|
+
# lets you override the tests that get compiled and run. You can restore to all tests with:
|
|
140
|
+
# cmake -DPYBIND11_TEST_OVERRIDE= ..
|
|
141
|
+
if(PYBIND11_TEST_OVERRIDE)
|
|
142
|
+
set(PYBIND11_TEST_FILES ${PYBIND11_TEST_OVERRIDE})
|
|
143
|
+
endif()
|
|
144
|
+
|
|
145
|
+
# You can also filter tests:
|
|
146
|
+
if(PYBIND11_TEST_FILTER)
|
|
147
|
+
pybind11_filter_tests(PYBIND11_TEST_FILES ${PYBIND11_TEST_FILTER})
|
|
148
|
+
endif()
|
|
149
|
+
|
|
150
|
+
if(PYTHON_VERSION VERSION_LESS 3.5)
|
|
151
|
+
pybind11_filter_tests(PYBIND11_TEST_FILES test_async.cpp MESSAGE
|
|
152
|
+
"Skipping test_async on Python 2")
|
|
153
|
+
endif()
|
|
154
|
+
|
|
155
|
+
# Skip tests for CUDA check:
|
|
156
|
+
# /pybind11/tests/test_constants_and_functions.cpp(125):
|
|
157
|
+
# error: incompatible exception specifications
|
|
158
|
+
if(PYBIND11_CUDA_TESTS)
|
|
159
|
+
pybind11_filter_tests(
|
|
160
|
+
PYBIND11_TEST_FILES test_constants_and_functions.cpp MESSAGE
|
|
161
|
+
"Skipping test_constants_and_functions due to incompatible exception specifications")
|
|
162
|
+
endif()
|
|
163
|
+
|
|
164
|
+
string(REPLACE ".cpp" ".py" PYBIND11_PYTEST_FILES "${PYBIND11_TEST_FILES}")
|
|
165
|
+
|
|
166
|
+
# Contains the set of test files that require pybind11_cross_module_tests to be
|
|
167
|
+
# built; if none of these are built (i.e. because TEST_OVERRIDE is used and
|
|
168
|
+
# doesn't include them) the second module doesn't get built.
|
|
169
|
+
set(PYBIND11_CROSS_MODULE_TESTS test_exceptions.py test_local_bindings.py test_stl.py
|
|
170
|
+
test_stl_binders.py)
|
|
171
|
+
|
|
172
|
+
set(PYBIND11_CROSS_MODULE_GIL_TESTS test_gil_scoped.py)
|
|
173
|
+
|
|
174
|
+
set(PYBIND11_EIGEN_REPO
|
|
175
|
+
"https://gitlab.com/libeigen/eigen.git"
|
|
176
|
+
CACHE STRING "Eigen repository to use for tests")
|
|
177
|
+
# This hash is for 3.4.0, using a hash for security reasons
|
|
178
|
+
set(PYBIND11_EIGEN_VERSION
|
|
179
|
+
"929bc0e191d0927b1735b9a1ddc0e8b77e3a25ec"
|
|
180
|
+
CACHE STRING "Eigen version to use for tests")
|
|
181
|
+
|
|
182
|
+
# Check if Eigen is available; if not, remove from PYBIND11_TEST_FILES (but
|
|
183
|
+
# keep it in PYBIND11_PYTEST_FILES, so that we get the "eigen is not installed"
|
|
184
|
+
# skip message).
|
|
185
|
+
list(FIND PYBIND11_TEST_FILES test_eigen.cpp PYBIND11_TEST_FILES_EIGEN_I)
|
|
186
|
+
if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1)
|
|
187
|
+
# Try loading via newer Eigen's Eigen3Config first (bypassing tools/FindEigen3.cmake).
|
|
188
|
+
# Eigen 3.3.1+ exports a cmake 3.0+ target for handling dependency requirements, but also
|
|
189
|
+
# produces a fatal error if loaded from a pre-3.0 cmake.
|
|
190
|
+
if(DOWNLOAD_EIGEN)
|
|
191
|
+
if(CMAKE_VERSION VERSION_LESS 3.11)
|
|
192
|
+
message(FATAL_ERROR "CMake 3.11+ required when using DOWNLOAD_EIGEN")
|
|
193
|
+
endif()
|
|
194
|
+
|
|
195
|
+
include(FetchContent)
|
|
196
|
+
FetchContent_Declare(
|
|
197
|
+
eigen
|
|
198
|
+
GIT_REPOSITORY "${PYBIND11_EIGEN_REPO}"
|
|
199
|
+
GIT_TAG "${PYBIND11_EIGEN_VERSION}")
|
|
200
|
+
|
|
201
|
+
FetchContent_GetProperties(eigen)
|
|
202
|
+
if(NOT eigen_POPULATED)
|
|
203
|
+
message(STATUS "Downloading Eigen")
|
|
204
|
+
FetchContent_Populate(eigen)
|
|
205
|
+
endif()
|
|
206
|
+
|
|
207
|
+
set(EIGEN3_INCLUDE_DIR ${eigen_SOURCE_DIR})
|
|
208
|
+
set(EIGEN3_FOUND TRUE)
|
|
209
|
+
|
|
210
|
+
else()
|
|
211
|
+
find_package(Eigen3 3.2.7 QUIET CONFIG)
|
|
212
|
+
|
|
213
|
+
if(NOT EIGEN3_FOUND)
|
|
214
|
+
# Couldn't load via target, so fall back to allowing module mode finding, which will pick up
|
|
215
|
+
# tools/FindEigen3.cmake
|
|
216
|
+
find_package(Eigen3 3.2.7 QUIET)
|
|
217
|
+
endif()
|
|
218
|
+
endif()
|
|
219
|
+
|
|
220
|
+
if(EIGEN3_FOUND)
|
|
221
|
+
if(NOT TARGET Eigen3::Eigen)
|
|
222
|
+
add_library(Eigen3::Eigen IMPORTED INTERFACE)
|
|
223
|
+
set_property(TARGET Eigen3::Eigen PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
|
224
|
+
"${EIGEN3_INCLUDE_DIR}")
|
|
225
|
+
endif()
|
|
226
|
+
|
|
227
|
+
# Eigen 3.3.1+ cmake sets EIGEN3_VERSION_STRING (and hard codes the version when installed
|
|
228
|
+
# rather than looking it up in the cmake script); older versions, and the
|
|
229
|
+
# tools/FindEigen3.cmake, set EIGEN3_VERSION instead.
|
|
230
|
+
if(NOT EIGEN3_VERSION AND EIGEN3_VERSION_STRING)
|
|
231
|
+
set(EIGEN3_VERSION ${EIGEN3_VERSION_STRING})
|
|
232
|
+
endif()
|
|
233
|
+
message(STATUS "Building tests with Eigen v${EIGEN3_VERSION}")
|
|
234
|
+
else()
|
|
235
|
+
list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_EIGEN_I})
|
|
236
|
+
message(
|
|
237
|
+
STATUS "Building tests WITHOUT Eigen, use -DDOWNLOAD_EIGEN=ON on CMake 3.11+ to download")
|
|
238
|
+
endif()
|
|
239
|
+
endif()
|
|
240
|
+
|
|
241
|
+
# Optional dependency for some tests (boost::variant is only supported with version >= 1.56)
|
|
242
|
+
find_package(Boost 1.56)
|
|
243
|
+
|
|
244
|
+
if(Boost_FOUND)
|
|
245
|
+
if(NOT TARGET Boost::headers)
|
|
246
|
+
add_library(Boost::headers IMPORTED INTERFACE)
|
|
247
|
+
if(TARGET Boost::boost)
|
|
248
|
+
# Classic FindBoost
|
|
249
|
+
set_property(TARGET Boost::boost PROPERTY INTERFACE_LINK_LIBRARIES Boost::boost)
|
|
250
|
+
else()
|
|
251
|
+
# Very old FindBoost, or newer Boost than CMake in older CMakes
|
|
252
|
+
set_property(TARGET Boost::headers PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
|
253
|
+
${Boost_INCLUDE_DIRS})
|
|
254
|
+
endif()
|
|
255
|
+
endif()
|
|
256
|
+
endif()
|
|
257
|
+
|
|
258
|
+
# Check if we need to add -lstdc++fs or -lc++fs or nothing
|
|
259
|
+
if(MSVC)
|
|
260
|
+
set(STD_FS_NO_LIB_NEEDED TRUE)
|
|
261
|
+
else()
|
|
262
|
+
file(
|
|
263
|
+
WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
|
264
|
+
"#include <filesystem>\nint main(int argc, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}"
|
|
265
|
+
)
|
|
266
|
+
try_compile(
|
|
267
|
+
STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR}
|
|
268
|
+
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
|
269
|
+
COMPILE_DEFINITIONS -std=c++17)
|
|
270
|
+
try_compile(
|
|
271
|
+
STD_FS_NEEDS_STDCXXFS ${CMAKE_CURRENT_BINARY_DIR}
|
|
272
|
+
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
|
273
|
+
COMPILE_DEFINITIONS -std=c++17
|
|
274
|
+
LINK_LIBRARIES stdc++fs)
|
|
275
|
+
try_compile(
|
|
276
|
+
STD_FS_NEEDS_CXXFS ${CMAKE_CURRENT_BINARY_DIR}
|
|
277
|
+
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
|
278
|
+
COMPILE_DEFINITIONS -std=c++17
|
|
279
|
+
LINK_LIBRARIES c++fs)
|
|
280
|
+
endif()
|
|
281
|
+
|
|
282
|
+
if(${STD_FS_NEEDS_STDCXXFS})
|
|
283
|
+
set(STD_FS_LIB stdc++fs)
|
|
284
|
+
elseif(${STD_FS_NEEDS_CXXFS})
|
|
285
|
+
set(STD_FS_LIB c++fs)
|
|
286
|
+
elseif(${STD_FS_NO_LIB_NEEDED})
|
|
287
|
+
set(STD_FS_LIB "")
|
|
288
|
+
else()
|
|
289
|
+
message(WARNING "Unknown compiler - not passing -lstdc++fs")
|
|
290
|
+
set(STD_FS_LIB "")
|
|
291
|
+
endif()
|
|
292
|
+
|
|
293
|
+
# Compile with compiler warnings turned on
|
|
294
|
+
function(pybind11_enable_warnings target_name)
|
|
295
|
+
if(MSVC)
|
|
296
|
+
target_compile_options(${target_name} PRIVATE /W4)
|
|
297
|
+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)" AND NOT PYBIND11_CUDA_TESTS)
|
|
298
|
+
target_compile_options(
|
|
299
|
+
${target_name}
|
|
300
|
+
PRIVATE -Wall
|
|
301
|
+
-Wextra
|
|
302
|
+
-Wconversion
|
|
303
|
+
-Wcast-qual
|
|
304
|
+
-Wdeprecated
|
|
305
|
+
-Wundef
|
|
306
|
+
-Wnon-virtual-dtor)
|
|
307
|
+
endif()
|
|
308
|
+
|
|
309
|
+
if(PYBIND11_WERROR)
|
|
310
|
+
if(MSVC)
|
|
311
|
+
target_compile_options(${target_name} PRIVATE /WX)
|
|
312
|
+
elseif(PYBIND11_CUDA_TESTS)
|
|
313
|
+
target_compile_options(${target_name} PRIVATE "SHELL:-Werror all-warnings")
|
|
314
|
+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang|IntelLLVM)")
|
|
315
|
+
target_compile_options(${target_name} PRIVATE -Werror)
|
|
316
|
+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
|
317
|
+
target_compile_options(
|
|
318
|
+
${target_name}
|
|
319
|
+
PRIVATE
|
|
320
|
+
-Werror-all
|
|
321
|
+
# "Inlining inhibited by limit max-size", "Inlining inhibited by limit max-total-size"
|
|
322
|
+
-diag-disable 11074,11076)
|
|
323
|
+
endif()
|
|
324
|
+
endif()
|
|
325
|
+
|
|
326
|
+
# Needs to be re-added since the ordering requires these to be after the ones above
|
|
327
|
+
if(CMAKE_CXX_STANDARD
|
|
328
|
+
AND CMAKE_CXX_COMPILER_ID MATCHES "Clang"
|
|
329
|
+
AND PYTHON_VERSION VERSION_LESS 3.0)
|
|
330
|
+
if(CMAKE_CXX_STANDARD LESS 17)
|
|
331
|
+
target_compile_options(${target_name} PUBLIC -Wno-deprecated-register)
|
|
332
|
+
else()
|
|
333
|
+
target_compile_options(${target_name} PUBLIC -Wno-register)
|
|
334
|
+
endif()
|
|
335
|
+
endif()
|
|
336
|
+
endfunction()
|
|
337
|
+
|
|
338
|
+
set(test_targets pybind11_tests)
|
|
339
|
+
|
|
340
|
+
# Build pybind11_cross_module_tests if any test_whatever.py are being built that require it
|
|
341
|
+
foreach(t ${PYBIND11_CROSS_MODULE_TESTS})
|
|
342
|
+
list(FIND PYBIND11_PYTEST_FILES ${t} i)
|
|
343
|
+
if(i GREATER -1)
|
|
344
|
+
list(APPEND test_targets pybind11_cross_module_tests)
|
|
345
|
+
break()
|
|
346
|
+
endif()
|
|
347
|
+
endforeach()
|
|
348
|
+
|
|
349
|
+
foreach(t ${PYBIND11_CROSS_MODULE_GIL_TESTS})
|
|
350
|
+
list(FIND PYBIND11_PYTEST_FILES ${t} i)
|
|
351
|
+
if(i GREATER -1)
|
|
352
|
+
list(APPEND test_targets cross_module_gil_utils)
|
|
353
|
+
break()
|
|
354
|
+
endif()
|
|
355
|
+
endforeach()
|
|
356
|
+
|
|
357
|
+
# Support CUDA testing by forcing the target file to compile with NVCC
|
|
358
|
+
if(PYBIND11_CUDA_TESTS)
|
|
359
|
+
set_property(SOURCE ${PYBIND11_TEST_FILES} PROPERTY LANGUAGE CUDA)
|
|
360
|
+
endif()
|
|
361
|
+
|
|
362
|
+
foreach(target ${test_targets})
|
|
363
|
+
set(test_files ${PYBIND11_TEST_FILES})
|
|
364
|
+
if(NOT "${target}" STREQUAL "pybind11_tests")
|
|
365
|
+
set(test_files "")
|
|
366
|
+
endif()
|
|
367
|
+
|
|
368
|
+
# Support CUDA testing by forcing the target file to compile with NVCC
|
|
369
|
+
if(PYBIND11_CUDA_TESTS)
|
|
370
|
+
set_property(SOURCE ${target}.cpp PROPERTY LANGUAGE CUDA)
|
|
371
|
+
endif()
|
|
372
|
+
|
|
373
|
+
# Create the binding library
|
|
374
|
+
pybind11_add_module(${target} THIN_LTO ${target}.cpp ${test_files} ${PYBIND11_HEADERS})
|
|
375
|
+
pybind11_enable_warnings(${target})
|
|
376
|
+
|
|
377
|
+
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
|
378
|
+
get_property(
|
|
379
|
+
suffix
|
|
380
|
+
TARGET ${target}
|
|
381
|
+
PROPERTY SUFFIX)
|
|
382
|
+
set(source_output "${CMAKE_CURRENT_SOURCE_DIR}/${target}${suffix}")
|
|
383
|
+
if(suffix AND EXISTS "${source_output}")
|
|
384
|
+
message(WARNING "Output file also in source directory; "
|
|
385
|
+
"please remove to avoid confusion: ${source_output}")
|
|
386
|
+
endif()
|
|
387
|
+
endif()
|
|
388
|
+
|
|
389
|
+
if(MSVC)
|
|
390
|
+
target_compile_options(${target} PRIVATE /utf-8)
|
|
391
|
+
endif()
|
|
392
|
+
|
|
393
|
+
if(EIGEN3_FOUND)
|
|
394
|
+
target_link_libraries(${target} PRIVATE Eigen3::Eigen)
|
|
395
|
+
target_compile_definitions(${target} PRIVATE -DPYBIND11_TEST_EIGEN)
|
|
396
|
+
endif()
|
|
397
|
+
|
|
398
|
+
if(Boost_FOUND)
|
|
399
|
+
target_link_libraries(${target} PRIVATE Boost::headers)
|
|
400
|
+
target_compile_definitions(${target} PRIVATE -DPYBIND11_TEST_BOOST)
|
|
401
|
+
endif()
|
|
402
|
+
|
|
403
|
+
target_link_libraries(${target} PRIVATE ${STD_FS_LIB})
|
|
404
|
+
|
|
405
|
+
# Always write the output file directly into the 'tests' directory (even on MSVC)
|
|
406
|
+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
|
407
|
+
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY
|
|
408
|
+
"${CMAKE_CURRENT_BINARY_DIR}")
|
|
409
|
+
|
|
410
|
+
if(DEFINED CMAKE_CONFIGURATION_TYPES)
|
|
411
|
+
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
|
412
|
+
string(TOUPPER ${config} config)
|
|
413
|
+
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config}
|
|
414
|
+
"${CMAKE_CURRENT_BINARY_DIR}")
|
|
415
|
+
endforeach()
|
|
416
|
+
endif()
|
|
417
|
+
endif()
|
|
418
|
+
endforeach()
|
|
419
|
+
|
|
420
|
+
# Make sure pytest is found or produce a warning
|
|
421
|
+
pybind11_find_import(pytest VERSION 3.1)
|
|
422
|
+
|
|
423
|
+
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
|
424
|
+
# This is not used later in the build, so it's okay to regenerate each time.
|
|
425
|
+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" "${CMAKE_CURRENT_BINARY_DIR}/pytest.ini"
|
|
426
|
+
COPYONLY)
|
|
427
|
+
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/pytest.ini"
|
|
428
|
+
"\ntestpaths = \"${CMAKE_CURRENT_SOURCE_DIR}\"")
|
|
429
|
+
|
|
430
|
+
endif()
|
|
431
|
+
|
|
432
|
+
# cmake 3.12 added list(transform <list> prepend
|
|
433
|
+
# but we can't use it yet
|
|
434
|
+
string(REPLACE "test_" "${CMAKE_CURRENT_SOURCE_DIR}/test_" PYBIND11_ABS_PYTEST_FILES
|
|
435
|
+
"${PYBIND11_PYTEST_FILES}")
|
|
436
|
+
|
|
437
|
+
set(PYBIND11_TEST_PREFIX_COMMAND
|
|
438
|
+
""
|
|
439
|
+
CACHE STRING "Put this before pytest, use for checkers and such")
|
|
440
|
+
|
|
441
|
+
# A single command to compile and run the tests
|
|
442
|
+
add_custom_target(
|
|
443
|
+
pytest
|
|
444
|
+
COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest
|
|
445
|
+
${PYBIND11_ABS_PYTEST_FILES}
|
|
446
|
+
DEPENDS ${test_targets}
|
|
447
|
+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
448
|
+
USES_TERMINAL)
|
|
449
|
+
|
|
450
|
+
if(PYBIND11_TEST_OVERRIDE)
|
|
451
|
+
add_custom_command(
|
|
452
|
+
TARGET pytest
|
|
453
|
+
POST_BUILD
|
|
454
|
+
COMMAND ${CMAKE_COMMAND} -E echo
|
|
455
|
+
"Note: not all tests run: -DPYBIND11_TEST_OVERRIDE is in effect")
|
|
456
|
+
endif()
|
|
457
|
+
|
|
458
|
+
# cmake-format: off
|
|
459
|
+
add_custom_target(
|
|
460
|
+
memcheck
|
|
461
|
+
COMMAND
|
|
462
|
+
PYTHONMALLOC=malloc
|
|
463
|
+
valgrind
|
|
464
|
+
--leak-check=full
|
|
465
|
+
--show-leak-kinds=definite,indirect
|
|
466
|
+
--errors-for-leak-kinds=definite,indirect
|
|
467
|
+
--error-exitcode=1
|
|
468
|
+
--read-var-info=yes
|
|
469
|
+
--track-origins=yes
|
|
470
|
+
--suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-python.supp"
|
|
471
|
+
--suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-numpy-scipy.supp"
|
|
472
|
+
--gen-suppressions=all
|
|
473
|
+
${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES}
|
|
474
|
+
DEPENDS ${test_targets}
|
|
475
|
+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
476
|
+
USES_TERMINAL)
|
|
477
|
+
# cmake-format: on
|
|
478
|
+
|
|
479
|
+
# Add a check target to run all the tests, starting with pytest (we add dependencies to this below)
|
|
480
|
+
add_custom_target(check DEPENDS pytest)
|
|
481
|
+
|
|
482
|
+
# The remaining tests only apply when being built as part of the pybind11 project, but not if the
|
|
483
|
+
# tests are being built independently.
|
|
484
|
+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
485
|
+
return()
|
|
486
|
+
endif()
|
|
487
|
+
|
|
488
|
+
# Add a post-build comment to show the primary test suite .so size and, if a previous size, compare it:
|
|
489
|
+
add_custom_command(
|
|
490
|
+
TARGET pybind11_tests
|
|
491
|
+
POST_BUILD
|
|
492
|
+
COMMAND
|
|
493
|
+
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../tools/libsize.py
|
|
494
|
+
$<TARGET_FILE:pybind11_tests>
|
|
495
|
+
${CMAKE_CURRENT_BINARY_DIR}/sosize-$<TARGET_FILE_NAME:pybind11_tests>.txt)
|
|
496
|
+
|
|
497
|
+
if(NOT PYBIND11_CUDA_TESTS)
|
|
498
|
+
# Test embedding the interpreter. Provides the `cpptest` target.
|
|
499
|
+
add_subdirectory(test_embed)
|
|
500
|
+
|
|
501
|
+
# Test CMake build using functions and targets from subdirectory or installed location
|
|
502
|
+
add_subdirectory(test_cmake_build)
|
|
503
|
+
endif()
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""pytest configuration
|
|
3
|
+
|
|
4
|
+
Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.
|
|
5
|
+
Adds docstring and exceptions message sanitizers: ignore Python 2 vs 3 differences.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import contextlib
|
|
9
|
+
import difflib
|
|
10
|
+
import gc
|
|
11
|
+
import re
|
|
12
|
+
import textwrap
|
|
13
|
+
|
|
14
|
+
import pytest
|
|
15
|
+
|
|
16
|
+
import env
|
|
17
|
+
|
|
18
|
+
# Early diagnostic for failed imports
|
|
19
|
+
import pybind11_tests # noqa: F401
|
|
20
|
+
|
|
21
|
+
_unicode_marker = re.compile(r"u(\'[^\']*\')")
|
|
22
|
+
_long_marker = re.compile(r"([0-9])L")
|
|
23
|
+
_hexadecimal = re.compile(r"0x[0-9a-fA-F]+")
|
|
24
|
+
|
|
25
|
+
# Avoid collecting Python3 only files
|
|
26
|
+
collect_ignore = []
|
|
27
|
+
if env.PY2:
|
|
28
|
+
collect_ignore.append("test_async.py")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _strip_and_dedent(s):
|
|
32
|
+
"""For triple-quote strings"""
|
|
33
|
+
return textwrap.dedent(s.lstrip("\n").rstrip())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _split_and_sort(s):
|
|
37
|
+
"""For output which does not require specific line order"""
|
|
38
|
+
return sorted(_strip_and_dedent(s).splitlines())
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _make_explanation(a, b):
|
|
42
|
+
"""Explanation for a failed assert -- the a and b arguments are List[str]"""
|
|
43
|
+
return ["--- actual / +++ expected"] + [
|
|
44
|
+
line.strip("\n") for line in difflib.ndiff(a, b)
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Output(object):
|
|
49
|
+
"""Basic output post-processing and comparison"""
|
|
50
|
+
|
|
51
|
+
def __init__(self, string):
|
|
52
|
+
self.string = string
|
|
53
|
+
self.explanation = []
|
|
54
|
+
|
|
55
|
+
def __str__(self):
|
|
56
|
+
return self.string
|
|
57
|
+
|
|
58
|
+
def __eq__(self, other):
|
|
59
|
+
# Ignore constructor/destructor output which is prefixed with "###"
|
|
60
|
+
a = [
|
|
61
|
+
line
|
|
62
|
+
for line in self.string.strip().splitlines()
|
|
63
|
+
if not line.startswith("###")
|
|
64
|
+
]
|
|
65
|
+
b = _strip_and_dedent(other).splitlines()
|
|
66
|
+
if a == b:
|
|
67
|
+
return True
|
|
68
|
+
else:
|
|
69
|
+
self.explanation = _make_explanation(a, b)
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class Unordered(Output):
|
|
74
|
+
"""Custom comparison for output without strict line ordering"""
|
|
75
|
+
|
|
76
|
+
def __eq__(self, other):
|
|
77
|
+
a = _split_and_sort(self.string)
|
|
78
|
+
b = _split_and_sort(other)
|
|
79
|
+
if a == b:
|
|
80
|
+
return True
|
|
81
|
+
else:
|
|
82
|
+
self.explanation = _make_explanation(a, b)
|
|
83
|
+
return False
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class Capture(object):
|
|
87
|
+
def __init__(self, capfd):
|
|
88
|
+
self.capfd = capfd
|
|
89
|
+
self.out = ""
|
|
90
|
+
self.err = ""
|
|
91
|
+
|
|
92
|
+
def __enter__(self):
|
|
93
|
+
self.capfd.readouterr()
|
|
94
|
+
return self
|
|
95
|
+
|
|
96
|
+
def __exit__(self, *args):
|
|
97
|
+
self.out, self.err = self.capfd.readouterr()
|
|
98
|
+
|
|
99
|
+
def __eq__(self, other):
|
|
100
|
+
a = Output(self.out)
|
|
101
|
+
b = other
|
|
102
|
+
if a == b:
|
|
103
|
+
return True
|
|
104
|
+
else:
|
|
105
|
+
self.explanation = a.explanation
|
|
106
|
+
return False
|
|
107
|
+
|
|
108
|
+
def __str__(self):
|
|
109
|
+
return self.out
|
|
110
|
+
|
|
111
|
+
def __contains__(self, item):
|
|
112
|
+
return item in self.out
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def unordered(self):
|
|
116
|
+
return Unordered(self.out)
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def stderr(self):
|
|
120
|
+
return Output(self.err)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@pytest.fixture
|
|
124
|
+
def capture(capsys):
|
|
125
|
+
"""Extended `capsys` with context manager and custom equality operators"""
|
|
126
|
+
return Capture(capsys)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class SanitizedString(object):
|
|
130
|
+
def __init__(self, sanitizer):
|
|
131
|
+
self.sanitizer = sanitizer
|
|
132
|
+
self.string = ""
|
|
133
|
+
self.explanation = []
|
|
134
|
+
|
|
135
|
+
def __call__(self, thing):
|
|
136
|
+
self.string = self.sanitizer(thing)
|
|
137
|
+
return self
|
|
138
|
+
|
|
139
|
+
def __eq__(self, other):
|
|
140
|
+
a = self.string
|
|
141
|
+
b = _strip_and_dedent(other)
|
|
142
|
+
if a == b:
|
|
143
|
+
return True
|
|
144
|
+
else:
|
|
145
|
+
self.explanation = _make_explanation(a.splitlines(), b.splitlines())
|
|
146
|
+
return False
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _sanitize_general(s):
|
|
150
|
+
s = s.strip()
|
|
151
|
+
s = s.replace("pybind11_tests.", "m.")
|
|
152
|
+
s = s.replace("unicode", "str")
|
|
153
|
+
s = _long_marker.sub(r"\1", s)
|
|
154
|
+
s = _unicode_marker.sub(r"\1", s)
|
|
155
|
+
return s
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _sanitize_docstring(thing):
|
|
159
|
+
s = thing.__doc__
|
|
160
|
+
s = _sanitize_general(s)
|
|
161
|
+
return s
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@pytest.fixture
|
|
165
|
+
def doc():
|
|
166
|
+
"""Sanitize docstrings and add custom failure explanation"""
|
|
167
|
+
return SanitizedString(_sanitize_docstring)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _sanitize_message(thing):
|
|
171
|
+
s = str(thing)
|
|
172
|
+
s = _sanitize_general(s)
|
|
173
|
+
s = _hexadecimal.sub("0", s)
|
|
174
|
+
return s
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@pytest.fixture
|
|
178
|
+
def msg():
|
|
179
|
+
"""Sanitize messages and add custom failure explanation"""
|
|
180
|
+
return SanitizedString(_sanitize_message)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# noinspection PyUnusedLocal
|
|
184
|
+
def pytest_assertrepr_compare(op, left, right):
|
|
185
|
+
"""Hook to insert custom failure explanation"""
|
|
186
|
+
if hasattr(left, "explanation"):
|
|
187
|
+
return left.explanation
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@contextlib.contextmanager
|
|
191
|
+
def suppress(exception):
|
|
192
|
+
"""Suppress the desired exception"""
|
|
193
|
+
try:
|
|
194
|
+
yield
|
|
195
|
+
except exception:
|
|
196
|
+
pass
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def gc_collect():
|
|
200
|
+
"""Run the garbage collector twice (needed when running
|
|
201
|
+
reference counting tests with PyPy)"""
|
|
202
|
+
gc.collect()
|
|
203
|
+
gc.collect()
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def pytest_configure():
|
|
207
|
+
pytest.suppress = suppress
|
|
208
|
+
pytest.gc_collect = gc_collect
|