Skip to content

Commit

Permalink
Make utils.getPackageDir raise correct exception
Browse files Browse the repository at this point in the history
assertRaises with isInstance test of correct exception, and note about why
it looks strange.
  • Loading branch information
parejkoj committed May 4, 2017
1 parent 3dc9fc1 commit 317e7a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/lsst/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#
from __future__ import absolute_import

import lsst.pex.exceptions

from .raDecStr import *
from .demangle import *
from .utils import *
Expand Down
7 changes: 6 additions & 1 deletion tests/testGetPackageDir.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def testBasics(self):
utilsPath = getPackageDir("utils")
self.assertTrue(os.path.isfile(os.path.join(utilsPath, "tests", "testGetPackageDir.py")))

self.assertRaises(Exception, getPackageDir, "nameOfNonexistendPackage2234q?#!")
# NOTE: one goal of this test is to confirm that the correct exception
# is raised even if we haven't explicitly imported pex.exceptions.
# Hence the odd structure of this assert block.
with self.assertRaises(Exception) as cm:
getPackageDir("nameOfNonexistendPackage2234q?#!")
self.assertIsInstance(cm.exception, lsst.pex.exceptions.NotFoundError)

def testUnicodeBasics(self):
utilsPath = getPackageDir(u"utils")
Expand Down

0 comments on commit 317e7a3

Please sign in to comment.