Skip to content

Commit 3f3c4cc

Browse files
authored
Merge pull request #21 from lbdreyer/add_coveralls
Add pytest + coveralls
2 parents f20c1d9 + ed5c6e8 commit 3f3c4cc

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

.coveragerc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# .coveragerc to control coverage.py
3+
#
4+
5+
[run]
6+
branch = True
7+
include =
8+
stratify/*
9+
omit =
10+
stratify/tests/*
11+
plugins = Cython.Coverage
12+
13+
[report]
14+
exclude_lines =
15+
pragma: no cover
16+
def __repr__
17+
if __name__ == .__main__.:

.travis.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ install:
2121
- rm -rf ${CONDA_INSTALL_LOCN}/pkgs && ln -s ${HOME}/cache/pkgs ${CONDA_INSTALL_LOCN}/pkgs
2222

2323
# Now do the things we need to do to install it.
24-
- conda create -n test_env --file requirements.txt nose python=${PYTHON} ${EXTRA_DEPS} --yes --quiet
24+
- export EXTRA_DEPS='coveralls pip pytest pytest-cov'
25+
- conda create -n test_env --file requirements.txt python=${PYTHON} ${EXTRA_DEPS} --yes --quiet
2526
- source activate test_env
26-
- conda list
27-
- python setup.py build_ext install
28-
- mkdir not_the_source_root && cd not_the_source_root
27+
- conda list
28+
29+
# Enable coverage of cython.
30+
- export CYTHON_COVERAGE=1
31+
32+
# Install python-stratify.
33+
- pip install -e .
2934

3035
script:
31-
- nosetests stratify
36+
- pytest -ra --pyargs stratify --cov
3237

38+
after_success: coveralls
3339

3440
# We store the files that are downloaded from continuum.io, but not the environments that are created.
3541
cache:

setup.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
NAME = 'stratify'
1212
DIR = os.path.abspath(os.path.dirname(__file__))
1313

14+
extension_kwargs = {'include_dirs': [np.get_include()]}
15+
cython_coverage_enabled = os.environ.get('CYTHON_COVERAGE', None)
16+
if cython_coverage_enabled:
17+
extension_kwargs.update({'define_macros': [('CYTHON_TRACE_NOGIL', '1')]})
18+
1419
extensions = [Extension('{}._vinterp'.format(NAME),
1520
[os.path.join(NAME, '_vinterp.pyx')],
16-
include_dirs=[np.get_include()]),
21+
**extension_kwargs),
1722
Extension('{}._conservative'.format(NAME),
1823
[os.path.join(NAME, '_conservative.pyx')],
19-
include_dirs=[np.get_include()])]
20-
24+
**extension_kwargs)]
2125

2226
def extract_version():
2327
version = None
@@ -37,7 +41,8 @@ def extract_version():
3741
'Nd vertical interpolation/stratification of atmospheric '
3842
'and oceanographic datasets'),
3943
version=extract_version(),
40-
ext_modules=cythonize(extensions),
44+
ext_modules=cythonize(extensions, compiler_directives={'linetrace': True,
45+
'binding': True}),
4146
packages=find_packages(),
4247
classifiers=[
4348
'Development Status :: 3 - Alpha',

0 commit comments

Comments
 (0)