Skip to content

Commit

Permalink
Merge pull request #954 from skoudoro/enable-pytest
Browse files Browse the repository at this point in the history
RF: Enable Test for v2 branch
  • Loading branch information
maharshi-gor authored Dec 20, 2024
2 parents f595400 + e73b5cd commit 3520c65
Show file tree
Hide file tree
Showing 30 changed files with 956 additions and 745 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ jobs:
else
ci/run_tests.sh
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: ${{ matrix.coverage }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: for_testing
files: coverage.xml
fail_ci_if_error: true
env_vars: ${{ matrix.os }}, PYTHON_VERSION
flags: unittests
name: codecov-umbrella
verbose: true
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# iff: {{ matrix.coverage }}
# with:
# token: {{ secrets.CODECOV_TOKEN }}
# directory: for_testing
# files: coverage.xml
# fail_ci_if_error: true
# env_vars: {{ matrix.os }}, PYTHON_VERSION
# flags: unittests
# name: codecov-umbrella
# verbose: true
51 changes: 51 additions & 0 deletions ci/install_opengl.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Sample script to install Python and pip under Windows
# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/

# Adapted from VisPy

$MESA_GL_URL = "https://github.com/vispy/demo-data/raw/main/mesa/"

# Mesa DLLs found linked from:
# http://qt-project.org/wiki/Cross-compiling-Mesa-for-Windows
# to:
# http://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/mingw-w64-x86_64-mesa-10.2.4-1-any.pkg.tar.xz/download

function DownloadMesaOpenGL ($architecture) {
[Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls11, Tls12'
$webclient = New-Object System.Net.WebClient
# Download and retry up to 3 times in case of network transient errors.
$url = $MESA_GL_URL + "opengl32_mingw_" + $architecture + ".dll"
if ($architecture -eq "32") {
$filepath = "C:\Windows\SysWOW64\opengl32.dll"
} else {
$filepath = "C:\Windows\system32\opengl32.dll"
}
takeown /F $filepath /A
icacls $filepath /grant "${env:ComputerName}\${env:UserName}:F"
Remove-item -LiteralPath $filepath
Write-Output "Downloading" $url
$retry_attempts = 2
for($i=0; $i -lt $retry_attempts; $i++){
try {
$webclient.DownloadFile($url, $filepath)
break
}
Catch [Exception]{
Start-Sleep 1
}
}
if (Test-Path $filepath) {
Write-Output "File saved at" $filepath
} else {
# Retry once to get the error message if any at the last try
$webclient.DownloadFile($url, $filepath)
}
}


function main () {
DownloadMesaOpenGL "64"
}

main
23 changes: 2 additions & 21 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,13 @@ if [ "$COVERAGE" == "1" ] || [ "$COVERAGE" == true ]; then
cp ../.coveragerc .;
cp ../.codecov.yml .;
# Run the tests and check for test coverage.
# coverage run -m pytest -svv --verbose --durations=10 --pyargs fury # Need to --doctest-modules flag
for file in `find ../fury -name 'test_*.py' -print`;
do
coverage run -m -p pytest -svv $file;
retVal=$?
if [ $retVal -ne 0 ]; then
echo "THE CURRENT ERROR CODE IS $retVal";
error_code=1
fi
done
coverage combine .
coverage run -m pytest -svv --verbose --durations=10 --pyargs fury # Need to --doctest-modules flag
coverage report -m # Generate test coverage report.
coverage xml # Generate coverage report in xml format for codecov.
# codecov # Upload the report to codecov.
else
# Threads issue so we run test on individual file
# pytest -svv --verbose --durations=10 --pyargs fury # Need to --doctest-modules flag
for file in `find ../fury -name 'test_*.py' -print`;
do
pytest -svv $file;
retVal=$?
if [ $retVal -ne 0 ]; then
echo "THE CURRENT ERROR CODE IS $retVal";
error_code=1
fi
done
pytest -svv --verbose --durations=10 --pyargs fury # Need to --doctest-modules flag
fi

cd ..
Expand Down
2 changes: 1 addition & 1 deletion ci/setup_headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ "$RUNNER_OS" == "Linux" ]; then
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
elif [ "$RUNNER_OS" == "Windows" ]; then
powershell ./ci/windows/install_opengl.ps1
powershell ./ci/install_opengl.ps1
elif [ "$RUNNER_OS" == "macOS" ]; then
echo 'Install Xquartz package for headless'
brew install --cask xquartz
Expand Down
3 changes: 1 addition & 2 deletions fury/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def get_info(verbose=False):

import numpy
import scipy
import vtkmodules.vtkCommonCore as ccvtk

from fury.optpkg import optional_package

Expand All @@ -53,7 +52,7 @@ def get_info(verbose=False):
"sys_platform": sys.platform,
"numpy_version": numpy.__version__,
"scipy_version": scipy.__version__,
"vtk_version": ccvtk.vtkVersion.GetVTKVersion(),
# TODO: add pygfx version
}

d_mpl = {"matplotlib_version": mpl.__version__} if have_mpl else {}
Expand Down
4 changes: 2 additions & 2 deletions fury/animation/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = [
"Animation",
"CameraAnimation",
# "Timeline",
"Timeline",
"euclidean_distances",
"get_next_timestamp",
"get_previous_timestamp",
Expand Down Expand Up @@ -48,4 +48,4 @@ from .interpolator import (
tan_cubic_spline_interpolator,
xyz_color_interpolator,
)
# from .timeline import Timeline
from .timeline import Timeline
8 changes: 8 additions & 0 deletions fury/animation/tests/test_animation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import numpy.testing as npt
import pytest

from fury import actor
from fury.animation import Animation, CameraAnimation
Expand All @@ -12,6 +13,13 @@
)
from fury.lib import Camera

##############################################################################
# Temporary variable until we fix the tests and module import

# skip all the test in this module
pytest.skip(allow_module_level=True)
##############################################################################


def assert_not_equal(x, y):
npt.assert_equal(np.any(np.not_equal(x, y)), True)
Expand Down
13 changes: 11 additions & 2 deletions fury/animation/tests/test_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

import numpy as np
import numpy.testing as npt
import pytest

from fury.animation import Animation, Timeline
import fury.testing as ft
from fury.ui import PlaybackPanel

# from fury.ui import PlaybackPanel
##############################################################################
# Temporary variable until we fix the tests and module import
PlaybackPanel = None

# skip all the test in this module
pytest.skip(allow_module_level=True)
##############################################################################


def assert_not_equal(x, y):
Expand All @@ -16,7 +25,7 @@ def test_timeline():
tl = Timeline(playback_panel=True)

# test playback panel
ft.assert_true(isinstance(tl.playback_panel, PlaybackPanel))
# ft.assert_true(isinstance(tl.playback_panel, PlaybackPanel))

for t in [-10, 0, 2.2, 7, 100]:
tl.seek(t)
Expand Down
Loading

0 comments on commit 3520c65

Please sign in to comment.