<s> import unittest <EOL> import sys , os <EOL> import imp <EOL> class TestImportHooks ( unittest . TestCase ) : <EOL> def make_module ( self , name , ** args ) : <EOL> mod = sys . modules . setdefault ( name , imp . new_module ( name ) ) <EOL> mod . __file__ = '<STR_LIT>' % name <EOL> mod . __dict__ . update ( ** args ) <EOL> return mod <EOL> def test_direkt_import ( self ) : <EOL> mod = self . make_module ( '<STR_LIT>' ) <EOL> import bottle . ext . test <EOL> self . assertEqual ( bottle . ext . test , mod ) <EOL> def test_from_import ( self ) : <EOL> mod = self . make_module ( '<STR_LIT>' ) <EOL> from bottle . ext import test <EOL> self . assertEqual ( test , mod ) <EOL> def test_data_import ( self ) : <EOL> mod = self . make_module ( '<STR_LIT>' , item = '<STR_LIT:value>' ) <EOL> from bottle . ext . test import item <EOL> self . assertEqual ( item , '<STR_LIT:value>' ) <EOL> def test_import_fail ( self ) : <EOL> '''<STR_LIT>''' <EOL> def test ( ) : <EOL> import bottle . ext . doesnotexist <EOL> self . assertRaises ( ImportError , test ) <EOL> def test_ext_isfile ( self ) : <EOL> '''<STR_LIT>''' <EOL> from bottle import ext <EOL> self . assertTrue ( os . path . isfile ( ext . __file__ ) ) </s>
