1. Matthew Schinckel
  2. werkzeug-main

Commits

Florent Xicluna  committed 618a70c

Fix import_string function and test, after fd6937a2f119

  • Participants
  • Parent commits 4b12b0e
  • Branches default

Comments (0)

Files changed (2)

File tests/test_utils.py

View file
  • Ignore whitespace
     assert import_string(u'cgi.escape') is cgi.escape
     assert import_string(u'werkzeug.debug.DebuggedApplication') is DebuggedApplication
     assert_raises(ImportError, import_string, 'XXXXXXXXXXXXXXXX')
-    assert_raises(AttributeError, import_string, 'cgi.XXXXXXXXXX')
+    assert_raises(ImportError, import_string, 'cgi.XXXXXXXXXX')
 
 
 def test_find_modules():

File werkzeug/utils.py

View file
  • Ignore whitespace
         # if the module is a package
         if isinstance(obj, unicode):
             obj = obj.encode('utf-8')
-        return getattr(__import__(module, None, None, [obj]), obj)
-    except (ImportError, AttributeError):
-        # support importing modules not yet set up by the parent module
-        # (or package for that matter)
         try:
+            return getattr(__import__(module, None, None, [obj]), obj)
+        except (ImportError, AttributeError):
+            # support importing modules not yet set up by the parent module
+            # (or package for that matter)
             modname = module + '.' + obj
             __import__(modname)
             return sys.modules[modname]
-        except ImportError:
-            if not silent:
-                raise
+    except ImportError:
+        if not silent:
+            raise
 
 
 def find_modules(import_path, include_packages=False, recursive=False):