Browse Source

Add test to catch imports at Flask instantiation.

pull/379/head
Ron DuPlain 13 years ago
parent
commit
26a9c2079d
  1. 11
      flask/testsuite/helpers.py
  2. 2
      flask/testsuite/test_apps/importerror.py

11
flask/testsuite/helpers.py

@ -331,10 +331,21 @@ class LoggingTestCase(FlaskTestCase):
'/myview/create') '/myview/create')
class NoImportsTestCase(FlaskTestCase):
"Test Flasks are created without __import__."
def test_name_with_import_error(self):
try:
flask.Flask('importerror')
except NotImplementedError:
self.fail('Flask(import_name) is importing import_name.')
def suite(): def suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
if flask.json_available: if flask.json_available:
suite.addTest(unittest.makeSuite(JSONTestCase)) suite.addTest(unittest.makeSuite(JSONTestCase))
suite.addTest(unittest.makeSuite(SendfileTestCase)) suite.addTest(unittest.makeSuite(SendfileTestCase))
suite.addTest(unittest.makeSuite(LoggingTestCase)) suite.addTest(unittest.makeSuite(LoggingTestCase))
suite.addTest(unittest.makeSuite(NoImportsTestCase))
return suite return suite

2
flask/testsuite/test_apps/importerror.py

@ -0,0 +1,2 @@
# NoImportsTestCase
raise NotImplementedError
Loading…
Cancel
Save