Skip to content

Commit

Permalink
Pytest added for testing python scripts mentioned in issue openworm#53;…
Browse files Browse the repository at this point in the history
… travis.yml modified to call pytest
  • Loading branch information
brijeshmodi12 committed Jun 3, 2016
1 parent 8b58752 commit 795b187
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 3 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/CElegansNeuroML.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ script:

# Test readers
- cd CElegans/pythonScripts
- python SpreadsheetDataReader.py

#Testing RegenerateConnectome.py, SpreadsheetDataReader.py, OpenWormReader.py via py.test
- py.test python_script_tester.py
# - python SpreadsheetDataReader.py

# Test regenerate connectome
- python RegenerateConnectome.py
# - python RegenerateConnectome.py

# Install PyOpenWorm
- git clone https://github.com/openworm/PyOpenWorm.git
Expand Down
26 changes: 26 additions & 0 deletions CElegans/pythonScripts/python_script_tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import subprocess as sp

def get_file_list():
#Add the name of the python scripts to the list that needs to be tested
file_list = ['RegenerateConnectome.py', 'SpreadsheetDataReader.py', 'OpenWormReader.py']
return file_list


def test_python_scripts(file_list = get_file_list()):
'''
Executes the desired python scripts and check whether they exit correctly(code 0) or not.
:param file_list: contains files that are to be tested
:return: none
'''

#stores returncode of each file.
returncode_list = []

for each_script in file_list:
exit_code = sp.call("python "+each_script, shell=True)
returncode_list.append(exit_code)

for i in range(len(file_list)):
assert(returncode_list[i] == 0),"Test Failed for " + file_list[i]
print("Test passed for " + file_list[i])

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-


from setuptools import setup
from setuptools.command.install import install as _install
Expand Down

0 comments on commit 795b187

Please sign in to comment.