Skip to content

Commit

Permalink
Added tests for kwarg storage behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Apr 3, 2016
1 parent 4dc9061 commit cd40641
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/mdsynthesis/tests/test_treants.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,25 @@ def test_set_universe_with_kwargs(self, treant):
the Universe in the first place.
"""
# try out a basic, but nonexistent, kwarg
u = mda.Universe(PDB, XTC, something_fake=True)

treant.universe = u

assert treant.udef.kwargs['something_fake'] is True

# try a kwarg with a value that won't be serializable
u2 = mda.Universe(PDB, XTC,
something_else=mda.topology.GROParser.GROParser)

with pytest.raises(ValueError):
treant.universe = u2

# check that we get a warning if a Universe didn't store its kwargs
u3 = mda.Universe(PDB, XTC, something_fake=True)
del u3._kwargs
with pytest.warns(UserWarning):
treant.universe = u3

def test_add_univese_typeerror(self, treant):
"""Test checking of what is passed to setter"""
with pytest.raises(TypeError):
Expand Down
4 changes: 2 additions & 2 deletions src/mdsynthesis/treants.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def universe(self, universe):
try:
self.udef.kwargs = universe._kwargs
except AttributeError:
warnings.warn("Could not store universe keyword arguments; "
"manually set these with ``Sim.udef.kwargs``")
warnings.warn("Universe did not keep keyword arguments; "
"cannot store keyword arguments for Universe.")

# finally, just use this instance
self._universe = universe
Expand Down

0 comments on commit cd40641

Please sign in to comment.