@@ -191,21 +191,15 @@ def _py_test_hack(modpath, attrname, importerror_alternative):
191
191
return importerror_alternative
192
192
193
193
194
- def _alias_mod_repr (modname , modpath , attrname , importerror_alternative ):
194
+ def _alias_mod_repr (modname , modpath , attrname ):
195
195
x = modpath
196
196
if attrname :
197
197
x += "." + attrname
198
- if importerror_alternative is not ImportError :
199
- return "<AliasModule {!r} for {!r} alternative {!r}>" .format (
200
- modname , x , importerror_alternative
201
- )
202
- else :
203
- return "<AliasModule {!r} for {!r}>" .format (modname , x )
198
+ return "<AliasModule {!r} for {!r}>" .format (modname , x )
204
199
205
200
206
- def AliasModule (modname , modpath , attrname = None , importerror_alternative = ImportError ):
201
+ def AliasModule (modname , modpath , attrname = None ):
207
202
mod = []
208
- importerror_alternative = _py_test_hack (modpath , attrname , importerror_alternative )
209
203
210
204
def getmod ():
211
205
if not mod :
@@ -215,7 +209,7 @@ def getmod():
215
209
mod .append (x )
216
210
return mod [0 ]
217
211
218
- repr_result = _alias_mod_repr (modname , modpath , attrname , importerror_alternative )
212
+ repr_result = _alias_mod_repr (modname , modpath , attrname )
219
213
220
214
class AliasModule (ModuleType ):
221
215
def __repr__ (self ):
@@ -225,10 +219,11 @@ def __getattribute__(self, name):
225
219
try :
226
220
return getattr (getmod (), name )
227
221
except ImportError :
228
- if importerror_alternative is ImportError :
229
- raise
222
+ if modpath == "pytest" and attrname is None :
223
+ # hack for pylibs py.test
224
+ return None
230
225
else :
231
- return importerror_alternative
226
+ raise
232
227
233
228
def __setattr__ (self , name , value ):
234
229
setattr (getmod (), name , value )
0 commit comments