Skip to content

Commit

Permalink
Merge pull request MDAnalysis#783 from fiona-naughton/develop
Browse files Browse the repository at this point in the history
added test for exception raise in GROParser (per issue MDAnalysis#597)
  • Loading branch information
jbarnoud committed Mar 21, 2016
2 parents feefee6 + ea126c8 commit c282d66
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
4 changes: 3 additions & 1 deletion testsuite/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ Chronological list of authors
- Balasubramanian
- Abhinav Gupta
- Pedro Reis

- Fiona B. Naughton


External code
-------------

Expand Down
4 changes: 2 additions & 2 deletions testsuite/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Also see https://github.com/MDAnalysis/mdanalysis/wiki/MDAnalysisTests
and https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests

------------------------------------------------------------------------------
21/03/16 orbeckst, jbarnoud, pedrishi

??/??/16 orbeckst, jbarnoud, pedrishi, fiona-naughton
* 0.15.0

- metadata update: link download_url to GitHub releases so that
Expand All @@ -23,6 +22,7 @@ and https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests
- a __version__ variable is now exposed; it is built by setup.py from the
AUTHORS file (Issue #784)
- Removed all bare assert (Issue #724)
- added tests for GRO format

02/28/16 manuel.nuno.melo
* 0.14.0
Expand Down
4 changes: 4 additions & 0 deletions testsuite/MDAnalysisTests/data/empty_atom.gro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Empty atom line for testing exception
1

10.00000 10.00000 10.00000
4 changes: 4 additions & 0 deletions testsuite/MDAnalysisTests/data/missing_atomname.gro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Missing atom name for testing exception raise
1
1RES 1 0.000 0.000 0.000
10.00000 10.00000 10.00000
4 changes: 4 additions & 0 deletions testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@
"COORDINATES_TRR",
"COORDINATES_TOPOLOGY",
"NUCLsel",
"GRO_empty_atom", "GRO_missing_atomname" # for testing GROParser exception raise
]

from pkg_resources import resource_filename

GRO_missing_atomname = resource_filename(__name__, 'data/missing_atomname.gro')
GRO_empty_atom = resource_filename(__name__, 'data/empty_atom.gro')

COORDINATES_XYZ = resource_filename(__name__, 'data/coordinates/test.xyz')
COORDINATES_XYZ_BZ2 = resource_filename(
__name__, 'data/coordinates/test.xyz.bz2')
Expand Down
14 changes: 14 additions & 0 deletions testsuite/MDAnalysisTests/topology/test_gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
#
from numpy.testing import (
assert_,
assert_raises,
)

import MDAnalysis as mda

from MDAnalysisTests.datafiles import (
two_water_gro_widebox,
GRO_empty_atom,
GRO_missing_atomname,
)


Expand All @@ -31,3 +34,14 @@ def test_atoms(self):
with parser(two_water_gro_widebox) as p:
s = p.parse()
assert_(len(s['atoms']) == 6)

def test_parse_empty_atom_IOerror():
parser = mda.topology.GROParser.GROParser
with parser(GRO_empty_atom) as p:
assert_raises(IOError, p.parse)

def test_parse_missing_atomname_IOerror():
parser = mda.topology.GROParser.GROParser
with parser(GRO_missing_atomname) as p:
assert_raises(IOError, p.parse)

0 comments on commit c282d66

Please sign in to comment.