Skip to content

Commit

Permalink
Minor test improvements
Browse files Browse the repository at this point in the history
test_object.py was trying to call methods that were no longer
publicly available. This passed because it was checking for
errors (just not the ones being raised).
Improve test_channel.py and test_normMap.py to test for a
more explicit exception when using assertRaises.
I checked the usage in other tests and concluded it was best
to leave them as is because in some cases it wasn't clear which
C++ exception would be mapped to the Python exception that was
raised, and in others it was unclear if AST or C++ code would
catch the problem, thus which Python exception would be raised.
  • Loading branch information
r-owen committed Mar 22, 2017
1 parent e95b183 commit 384f04f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_ChannelFileStream(self):
nobj = outchan.write(zoommap)
self.assertEqual(nobj, 1)

with self.assertRaises(Exception):
with self.assertRaises(RuntimeError):
obj = outchan.read()

instream = astshim.FileStream(path1, False)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_normMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_NormMapFrame(self):

def testNormMapMap(self):
"""Check that NormMap(Mapping) is an error"""
with self.assertRaises(Exception):
with self.assertRaises(TypeError):
astshim.NormMap(astshim.UnitMap(1))

def test_NormMapSkyFrame(self):
Expand Down
17 changes: 0 additions & 17 deletions tests/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@ def test_attributes(self):
self.assertEqual(obj.getIdent(), "")
self.assertEqual(obj.getUseDefs(), True)

def test_unknown_attributes(self):
"""Test accessing unknown attributes"""
obj = astshim.ZoomMap(2, 1.3)

self.assertFalse(obj.hasAttribute("NonExistentAttribute"))

with self.assertRaises(Exception):
obj.getC("NonExistentAttribute")
with self.assertRaises(Exception):
obj.getF("NonExistentAttribute")
with self.assertRaises(Exception):
obj.getD("NonExistentAttribute")
with self.assertRaises(Exception):
obj.getI("NonExistentAttribute")
with self.assertRaises(Exception):
obj.getL("NonExistentAttribute")

def test_clear_and_test(self):
"""Test Object.clear and Object.test"""
obj = astshim.ZoomMap(2, 1.3)
Expand Down

0 comments on commit 384f04f

Please sign in to comment.