##// END OF EJS Templates
- Make ipdoctest a little cleaner by giving it separate option names....
- Make ipdoctest a little cleaner by giving it separate option names. This is in an attempt at better isolating it from the rest of nose, because we are seeing intermittent Twisted errors when it is enabled. However, I still see them sometimes. - Also, make the reference counting tests a little less verbose.

File last commit:

r1853:b8f5152c
r1910:8bc770ab
Show More
FakeModule.py
42 lines | 1.4 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
"""
Class which mimics a module.
Needed to allow pickle to correctly resolve namespaces during IPython
sessions.
"""
#*****************************************************************************
# Copyright (C) 2002-2004 Fernando Perez. <fperez@colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#*****************************************************************************
import types
class FakeModule(types.ModuleType):
"""Simple class with attribute access to fake a module.
This is not meant to replace a module, but to allow inserting a fake
module in sys.modules so that systems which rely on run-time module
importing (like shelve and pickle) work correctly in interactive IPython
sessions.
Do NOT use this code for anything other than this IPython private hack."""
def __init__(self,adict=None):
# tmp to force __dict__ instance creation, else self.__dict__ fails
self.__iptmp = None
# It seems pydoc (and perhaps others) needs any module instance to
# implement a __nonzero__ method, so we add it if missing:
self.__dict__.setdefault('__nonzero__',lambda : True)
self.__dict__.setdefault('__file__',__file__)
# cleanup our temp trick
del self.__iptmp
if adict is not None:
self.__dict__.update(adict)