Skip to content

Commit

Permalink
Port tests to pytest
Browse files Browse the repository at this point in the history
Use simple asserts and pytest's powerful introspection to make testing
simpler. This merges the old .py/.ref file pairs into simple .py files
where the expected values are right next to the code being tested.

This commit does not touch the C++ part of the code and replicates the
Python tests exactly like the old .ref-file-based approach.
  • Loading branch information
dean0x7d committed Aug 19, 2016
1 parent 192eb88 commit a0c1ccf
Show file tree
Hide file tree
Showing 103 changed files with 2,410 additions and 2,842 deletions.
7 changes: 3 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ platform:
- x86
- x64
environment:
CTEST_OUTPUT_ON_FAILURE: 1
matrix:
- CONDA: 27
- CONDA: 35
Expand All @@ -16,12 +15,12 @@ install:
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
pip install --disable-pip-version-check --user --upgrade pip wheel
pip install numpy scipy
pip install pytest numpy scipy
} elseif ($env:CONDA) {
if ($env:CONDA -eq "27") { $env:CONDA = "" }
if ($env:PLATFORM -eq "x64") { $env:CONDA = "$env:CONDA-x64" }
$env:PATH = "C:\Miniconda$env:CONDA\;C:\Miniconda$env:CONDA\Scripts\;$env:PATH"
conda install -y -q numpy scipy
conda install -y -q pytest numpy scipy
}
- ps: |
Start-FileDownload 'http://bitbucket.org/eigen/eigen/get/3.2.9.zip'
Expand All @@ -30,4 +29,4 @@ install:
build_script:
- cmake -A "%CMAKE_ARCH%" -DPYBIND11_WERROR=ON
- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- cmake --build . --config Release --target check -- /v:m /logger:%MSBuildLogger%
- cmake --build . --config Release --target pytest -- /v:m /logger:%MSBuildLogger%
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ CMakeFiles
Makefile
cmake_install.cmake
.DS_Store
/example/example*.so
/example/example.cpython*.so
/example/example.pyd
/example/example*.dll
*.so
*.pyd
*.dll
*.sln
*.sdf
*.opensdf
Expand All @@ -32,3 +31,4 @@ MANIFEST
/dist
/build
/cmake/
.cache/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ install:
wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.2.9.tar.gz
tar xzf eigen.tar.gz
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_INCLUDE_PATH=eigen-eigen-dc6cfdf9bcec"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_INCLUDE_PATH=$PWD/eigen-eigen-dc6cfdf9bcec"
script:
- $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS}
-DPYBIND11_PYTHON_VERSION=$PYTHON
-DPYBIND11_CPP_STANDARD=-std=c++$CPP
-DPYBIND11_WERROR=ON
- $SCRIPT_RUN_PREFIX make CTEST_OUTPUT_ON_FAILURE=TRUE check -j 2
- $SCRIPT_RUN_PREFIX make pytest -j 2
after_script:
- if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CMakeLists.txt -- Build system for the pybind11 examples
# CMakeLists.txt -- Build system for the pybind11 modules
#
# Copyright (c) 2015 Wenzel Jakob <[email protected]>
#
Expand All @@ -20,7 +20,7 @@ option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJE
option(PYBIND11_WERROR "Report all warnings as errors" OFF)

# Add a CMake parameter for choosing a desired Python version
set(PYBIND11_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling the example application")
set(PYBIND11_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling modules")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/tools")
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7)
Expand Down Expand Up @@ -146,17 +146,15 @@ function(pybind11_enable_warnings target_name)

if(PYBIND11_WERROR)
if(MSVC)
target_compile_options(${target_name} PRIVATE /WX)
target_compile_options(${target_name} PRIVATE /WX)
else()
target_compile_options(${target_name} PRIVATE -Werror)
target_compile_options(${target_name} PRIVATE -Werror)
endif()
endif()
endfunction()

if (PYBIND11_TEST)
enable_testing()
add_subdirectory(example)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> DEPENDS example)
add_subdirectory(tests)
endif()

if (PYBIND11_INSTALL)
Expand Down
68 changes: 0 additions & 68 deletions example/CMakeLists.txt

This file was deleted.

114 changes: 0 additions & 114 deletions example/eigen.py

This file was deleted.

60 changes: 0 additions & 60 deletions example/eigen.ref

This file was deleted.

53 changes: 0 additions & 53 deletions example/example-arg-keywords-and-defaults.py

This file was deleted.

Loading

0 comments on commit a0c1ccf

Please sign in to comment.