Skip to content

Commit

Permalink
Setting up testing infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Jan 21, 2018
1 parent c46d4d0 commit 41ad756
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
@@ -0,0 +1,6 @@
[run]
omit =
*__init__*
test/*
setup.py
run_script.py
29 changes: 29 additions & 0 deletions .travis.yml
@@ -0,0 +1,29 @@
sudo: false

language: python

python:
- "3.5"
- "3.6"

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"

install:
- conda install --yes python=$TRAVIS_PYTHON_VERSION --file conda_requirements.txt
- pip install -r test_requirements.txt
- pip install -r pip_requirements.txt
- python setup.py install

script:
- ./bin/test pep8 cov

after_success:
- codecov

notifications:
email: false
17 changes: 17 additions & 0 deletions bin/test
@@ -0,0 +1,17 @@
#!/usr/bin/env python3

import sys
import pytest

args = ['-v']

if 'pep8' in sys.argv:
args.append('--pep8')

if 'cov' in sys.argv:
args.extend(['--cov-report=term-missing',
'--cov=OpenPNM',
'--cov-config=.coveragerc'])

exit_code = pytest.main(args)
exit(exit_code)
24 changes: 24 additions & 0 deletions codecov.yml
@@ -0,0 +1,24 @@
codecov:
branch: master

coverage:
precision: 2
round: down
range: "50...100"

status:
project:
default:
target: auto
threshold: null
branches: null

patch:
default:
target: auto
branches: null

comment:
layout: "header, diff, changes, sunburst, uncovered"
branches: null
behavior: default
1 change: 1 addition & 0 deletions pip_requirements.txt
@@ -0,0 +1 @@
pyyaml
7 changes: 7 additions & 0 deletions test_requirements.txt
@@ -0,0 +1,7 @@
codecov
coverage
pep8
pytest
pytest-cache
pytest-cov
pytest-pep8
14 changes: 8 additions & 6 deletions tests/unit/core/BaseTest.py
Expand Up @@ -6,6 +6,8 @@
class BaseTest:

def setup_class(self):
ws = op.Workspace()
ws.settings['local_data'] = True
self.net = op.network.Cubic(shape=[3, 3, 3])
self.geo = op.geometry.GenericGeometry(network=self.net,
pores=self.net.Ps,
Expand Down Expand Up @@ -686,9 +688,9 @@ def test_interleave_data_bool_missing_geometry(self):
if __name__ == '__main__':

t = BaseTest()
t.setup_class()
for item in t.__dir__():
if item.startswith('test'):
print('running test: '+item)
t.__getattribute__(item)()
self = t
# t.setup_class()
# for item in t.__dir__():
# if item.startswith('test'):
# print('running test: '+item)
# t.__getattribute__(item)()
# self = t
12 changes: 6 additions & 6 deletions tests/unit/network/GenericNetworkTest.py
Expand Up @@ -166,29 +166,29 @@ def test_num_neighbors_throats_not_flattened(self):
op.topotools.trim(network=self.net, throats=self.net.Ts[-2:])

def test_find_nearby_pores_distance_1(self):
a = self.net.find_nearby_pores(pores=[0, 1], distance=1)
a = self.net.find_nearby_pores(pores=[0, 1], r=1)
b = self.net.find_neighbor_pores(pores=[0, 1], flatten=False)
assert sp.all([sp.all(a[i] == b[i]) for i in range(0, len(a))])

def test_find_nearby_pores_distance_2(self):
a = self.net.find_nearby_pores(pores=[0, 1], distance=2)
a = self.net.find_nearby_pores(pores=[0, 1], r=2)
assert sp.all([sp.size(a[i]) for i in [0, 1]] == [10, 14])

def test_find_nearby_pores_distance_0(self):
a = self.net.find_nearby_pores(pores=[0, 1], distance=0)
a = self.net.find_nearby_pores(pores=[0, 1], r=0)
assert sp.shape(a) == (2, 0)

def test_find_nearby_pores_distance_1_flattened(self):
a = self.net.find_nearby_pores(pores=[0, 1], distance=1, flatten=True)
a = self.net.find_nearby_pores(pores=[0, 1], r=1, flatten=True)
b = self.net.find_neighbor_pores(pores=[0, 1])
assert sp.all(a == b)

def test_find_nearby_pores_distance_2_flattened(self):
a = self.net.find_nearby_pores(pores=[0, 1], distance=2, flatten=True)
a = self.net.find_nearby_pores(pores=[0, 1], r=2, flatten=True)
assert sp.size(a) == 15

def test_find_nearby_pores_distance_2_flattened_inclself(self):
a = self.net.find_nearby_pores(pores=[0, 1], distance=2,
a = self.net.find_nearby_pores(pores=[0, 1], r=2,
flatten=True, excl_self=False)
assert sp.size(a) == 17
assert sp.all(sp.in1d([0, 1], a))
Expand Down

0 comments on commit 41ad756

Please sign in to comment.