Created
April 19, 2011 21:51
-
-
Save RobSpectre/929801 to your computer and use it in GitHub Desktop.
assertRaises WTF?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Unit test that is failing. | |
class Test_BuildApp(unittest.TestCase): | |
def test_isNotApp(self): | |
build_fail = build.BuildApp(self.test_app_fail_path) | |
self.assertRaises(build.BuildAppException, build_fail.isApp()) | |
# Code it is testing (in build.py) | |
class BuildApp: | |
def isApp(self): | |
if "/" in self.path: | |
self.app_dir = self.path.split("/").pop() | |
else: | |
self.app_dir = self.path | |
for root, dirs, files in os.walk(self.path): | |
if "descriptor.xml" in files: | |
return True | |
raise BuildAppException("Could not find descriptor.xml in path: %s" % (self.path), "BuildError") | |
# Exception it is raising (in build.py) | |
class BuildAppException(Exception): | |
def __init__(self, message, e): | |
Exception.__init__(self, message) | |
self.log = logging.getLogger("Exception") | |
self.log.addHandler(log_handler) | |
self.logError(message, e) | |
def logError(self, e, message): | |
return self.log.critical("%s! %s" % (str(e), message)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem child is line 5 - build_fail isApp() should be "build_fail.isApp". assertRaises takes a callable, not a method.