-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from vasole/test
Add tests
- Loading branch information
Showing
8 changed files
with
343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
language: python | ||
|
||
git: | ||
depth: 1 | ||
|
||
matrix: | ||
include: | ||
- language: generic | ||
os: osx | ||
env: BUILD_COMMAND=bdist_wheel | ||
|
||
cache: | ||
apt: true | ||
|
||
install: | ||
# Mac OS X specific bootstrap | ||
- source ./ci/travis_osx.sh | ||
- travis_osx_install_begin | ||
|
||
# Upgrade distribution modules | ||
- pip install --upgrade setuptools | ||
- python -m pip install --upgrade pip | ||
|
||
# Install build dependencies | ||
- pip install --upgrade wheel | ||
#- pip install --trusted-host www.silx.org --find-links http://www.silx.org/pub/wheelhouse/ h5py --no-index | ||
|
||
# Print Python info | ||
- python ./ci/info_platform.py | ||
- pip list | ||
|
||
# Generate source package or wheel | ||
- python setup.py $BUILD_COMMAND | ||
- ls dist | ||
|
||
# Mac OS X specific cleanup | ||
- travis_osx_install_end | ||
|
||
script: | ||
# Mac OS X specific bootstrap | ||
- travis_osx_run_begin | ||
|
||
# Upgrade distribution modules | ||
- pip install --upgrade setuptools | ||
- python -m pip install --upgrade pip | ||
|
||
# Install h5py for tests | ||
- pip install --pre --find-links dist/ --trusted-host www.silx.org --find-links http://www.silx.org/pub/wheelhouse/ h5py | ||
|
||
# Install built package | ||
# Make sure it does not come from cache or pypi | ||
# At this point all install_requires dependencies MUST be installed | ||
# as this is installing only from dist | ||
- pip install --pre --find-links dist/ --no-cache-dir --no-index hdf5plugin | ||
|
||
# Print Python info | ||
- python ci/info_platform.py | ||
- pip list | ||
|
||
# Run the tests | ||
- python test/test.py | ||
|
||
# Mac OS X specific cleanup | ||
- travis_osx_run_end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
os: | ||
- Visual Studio 2015 | ||
|
||
cache: | ||
- '%LOCALAPPDATA%\pip\Cache' | ||
|
||
# fetch repository as zip archive | ||
shallow_clone: true | ||
|
||
environment: | ||
global: | ||
WIN_SDK_ROOT: "C:\\Program Files\\Microsoft SDKs\\Windows" | ||
VENV_BUILD_DIR: "venv_build" | ||
VENV_TEST_DIR: "venv_test" | ||
|
||
matrix: | ||
# Python 3.5 | ||
- PYTHON_DIR: "C:\\Python35-x64" | ||
|
||
# Python 2.7 | ||
- PYTHON_DIR: "C:\\Python27-x64" | ||
|
||
install: | ||
# Add Python to PATH | ||
- "SET PATH=%PYTHON_DIR%;%PYTHON_DIR%\\Scripts;%PATH%" | ||
|
||
# Upgrade distribution modules | ||
- "pip install --upgrade setuptools" | ||
- "python -m pip install --upgrade pip" | ||
|
||
# Install virtualenv | ||
- "pip install virtualenv" | ||
- "virtualenv --version" | ||
|
||
build_script: | ||
# Create build virtualenv | ||
- "virtualenv --clear %VENV_BUILD_DIR%" | ||
- "%VENV_BUILD_DIR%\\Scripts\\activate.bat" | ||
|
||
# Install build dependencies (should I try to install cython?) | ||
- "pip install --upgrade wheel" | ||
- "pip install --trusted-host www.silx.org --find-links http://www.silx.org/pub/wheelhouse/ --upgrade h5py" | ||
|
||
# Print Python info | ||
- "python ci\\info_platform.py" | ||
- "pip freeze" | ||
|
||
# Build | ||
- "python setup.py bdist_wheel bdist_msi" | ||
- ps: "ls dist" | ||
|
||
# Leave build virtualenv | ||
- "%VENV_BUILD_DIR%\\Scripts\\deactivate.bat" | ||
- "rmdir %VENV_BUILD_DIR% /s /q" | ||
|
||
test_script: | ||
# Create test virtualenv | ||
- "virtualenv --clear %VENV_TEST_DIR%" | ||
- "%VENV_TEST_DIR%\\Scripts\\activate.bat" | ||
|
||
# Install h5py for tests | ||
- "pip install --trusted-host www.silx.org --find-links http://www.silx.org/pub/wheelhouse/ --upgrade h5py" | ||
|
||
# Install the generated wheel package to test it | ||
# Make sure silx does not come from cache or pypi | ||
# At this point all install_requires dependencies MUST be installed | ||
# as this is installing only from dist/ | ||
- "pip install --pre --find-links dist/ --no-cache-dir --no-index hdf5plugin" | ||
|
||
# Print Python info | ||
- "python ci\\info_platform.py" | ||
- "pip list" | ||
|
||
- "python test\\test.py" | ||
|
||
# Leave test virtualenv | ||
- "%VENV_TEST_DIR%\\Scripts\\deactivate.bat" | ||
- "rmdir %VENV_TEST_DIR% /s /q" | ||
|
||
artifacts: | ||
# Archive the generated wheel package in the ci.appveyor.com build report. | ||
- path: dist\* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
"""Print information about python.""" | ||
|
||
__authors__ = ["Jérôme Kieffer"] | ||
__date__ = "08/12/2015" | ||
__license__ = "MIT" | ||
|
||
|
||
import sys | ||
|
||
print("Python %s bits" % (tuple.__itemsize__ * 8)) | ||
print(" maxsize: %s\t maxunicode: %s" % (sys.maxsize, sys.maxunicode)) | ||
print(sys.version) | ||
print(" ") | ||
|
||
try: | ||
from distutils.sysconfig import get_config_vars | ||
except ImportError: | ||
from sysconfig import get_config_vars | ||
print("Config: " + str(get_config_vars("CONFIG_ARGS"))) | ||
print("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
# Script for travis-CI Mac OS X specific setup. | ||
# | ||
# It provides 4 functions: | ||
# - travis_osx_install_begin: Install pip and setup a virtualenv for the build | ||
# - travis_osx_install_end: Deactivate the build virtualenv | ||
# - travis_osx_run_begin: Setup a virtualenv for the tests | ||
# - travis_osx_run_end: Deactivate test virtualenv | ||
# | ||
# On Linux, those functions do nothing. | ||
|
||
# Directory where to create build virtualenv | ||
VENV_BUILD_DIR=./venv_build | ||
|
||
# Directory qhere to create test virtualenv | ||
VENV_TEST_DIR=./venv_test | ||
|
||
|
||
if [ "$TRAVIS_OS_NAME" != "osx" ]; then | ||
function travis_osx_install_begin { | ||
echo NoOp | ||
} | ||
function travis_osx_install_end { | ||
echo NoOp | ||
} | ||
function travis_osx_run_begin { | ||
echo NoOp | ||
} | ||
function travis_osx_run_end { | ||
echo NoOp | ||
} | ||
|
||
else | ||
function travis_osx_install_begin { | ||
echo Mac OS X install begin: Install pip and setup build venv | ||
set -x # echo on | ||
curl -O https://bootstrap.pypa.io/get-pip.py | ||
python get-pip.py --user | ||
|
||
pip install virtualenv --user | ||
virtualenv --version | ||
|
||
virtualenv --clear $VENV_BUILD_DIR | ||
|
||
set +x # echo off | ||
echo "Activate virtualenv $VENV_BUILD_DIR" | ||
source $VENV_BUILD_DIR/bin/activate | ||
} | ||
|
||
function travis_osx_install_end { | ||
echo Mac OS X install end: Deactivate and delete virtualenv | ||
echo deactivate | ||
deactivate | ||
set -x # echo on | ||
rm -rf $VENV_BUILD_DIR | ||
set +x # echo off | ||
} | ||
|
||
|
||
function travis_osx_run_begin { | ||
echo Mac OS X run begin: Setup test venv | ||
|
||
set -x # echo on | ||
virtualenv --clear $VENV_TEST_DIR | ||
set +x # echo off | ||
echo "Activate virtualenv $VENV_TEST_DIR" | ||
source $VENV_TEST_DIR/bin/activate | ||
} | ||
|
||
function travis_osx_run_end { | ||
echo Mac OS X run end: Deactivate and delete virtualenv | ||
echo deactivate | ||
deactivate | ||
set -x # echo on | ||
rm -rf $VENV_TEST_DIR | ||
set +x # echo off | ||
} | ||
|
||
fi |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# coding: utf-8 | ||
# /*########################################################################## | ||
# | ||
# Copyright (c) 2016 European Synchrotron Radiation Facility | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
# ###########################################################################*/ | ||
__authors__ = ["V.A. Sole"] | ||
__license__ = "MIT" | ||
__date__ = "25/08/2016" | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
class TestHDF5Plugin(unittest.TestCase): | ||
def setUp(self): | ||
if "hdf5plugin" not in sys.modules: | ||
self.assertFalse("h5py" in sys.modules) | ||
import hdf5plugin | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def testHDF5PluginImport(self): | ||
# this test is at setUp | ||
pass | ||
|
||
def testLZ4(self): | ||
import h5py | ||
dirname = os.path.abspath(os.path.dirname(__file__)) | ||
fname = os.path.join(dirname, "lz4.h5") | ||
self.assertTrue(os.path.exists(fname), | ||
"Cannot find %s file" % fname) | ||
h5 = h5py.File(fname, "r") | ||
data = h5["/entry/data"][:] | ||
h5.close() | ||
expected_shape = (50, 2167, 2070) | ||
self.assertTrue(data.shape[0] == 50, "Incorrect shape") | ||
self.assertTrue(data.shape[1] == 2167, "Incorrect shape") | ||
self.assertTrue(data.shape[2] == 2070, "Incorrect shape") | ||
self.assertTrue(data[21, 1911, 1549] == 3141, "Incorrect value") | ||
|
||
def testBitshuffle(self): | ||
import h5py | ||
dirname = os.path.abspath(os.path.dirname(__file__)) | ||
fname = os.path.join(dirname, "bitshuffle.h5") | ||
self.assertTrue(os.path.exists(fname), | ||
"Cannot find %s file" % fname) | ||
h5 = h5py.File(fname, "r") | ||
data = h5["/entry/data/data"][:] | ||
h5.close() | ||
expected_shape = (1, 2167, 2070) | ||
self.assertTrue(data.shape[0] == 1, "Incorrect shape") | ||
self.assertTrue(data.shape[1] == 2167, "Incorrect shape") | ||
self.assertTrue(data.shape[2] == 2070, "Incorrect shape") | ||
self.assertTrue(data[0, 1372, 613] == 922, "Incorrect value") | ||
|
||
def getSuite(auto=True): | ||
testSuite = unittest.TestSuite() | ||
if auto: | ||
testSuite.addTest(\ | ||
unittest.TestLoader().loadTestsFromTestCase(TestHDF5Plugin)) | ||
else: | ||
# use a predefined order | ||
testSuite.addTest(TestHDF5Plugin("testHDF5PluginImport")) | ||
testSuite.addTest(TestHDF5Plugin("testLZ4")) | ||
testSuite.addTest(TestHDF5Plugin("testBitshuffle")) | ||
return testSuite | ||
|
||
def test(auto=False): | ||
unittest.TextTestRunner(verbosity=2).run(getSuite(auto=auto)) | ||
|
||
if __name__ == "__main__": | ||
test() |