当前位置: 首页>>代码示例>>Python>>正文


Python support.modules_cleanup方法代码示例

本文整理汇总了Python中test.support.modules_cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python support.modules_cleanup方法的具体用法?Python support.modules_cleanup怎么用?Python support.modules_cleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.support的用法示例。


在下文中一共展示了support.modules_cleanup方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: modules_cleanup

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import modules_cleanup [as 别名]
def modules_cleanup(oldmodules):
        # Encoders/decoders are registered permanently within the internal
        # codec cache. If we destroy the corresponding modules their
        # globals will be set to None which will trip up the cached functions.
        encodings = [(k, v) for k, v in sys.modules.items()
                     if k.startswith('encodings.')]
        sys.modules.clear()
        sys.modules.update(encodings)
        # XXX: This kind of problem can affect more than just encodings. In
        # particular extension modules (such as _ssl) don't cope with reloading
        # properly.  Really, test modules should be cleaning out the test
        # specific modules they know they added (ala test_runpy) rather than
        # relying on this function (as test_importhooks and test_pkg do
        # currently).  Implicitly imported *real* modules should be left alone
        # (see issue 10556).
        sys.modules.update(oldmodules) 
开发者ID:pypa,项目名称:pipenv,代码行数:18,代码来源:util.py

示例2: setUp

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import modules_cleanup [as 别名]
def setUp(self):
        modules = modules_setup()
        self.addCleanup(modules_cleanup, *modules) 
开发者ID:pypa,项目名称:pipenv,代码行数:5,代码来源:util.py

示例3: tearDown

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import modules_cleanup [as 别名]
def tearDown(self):
        sys.path[:] = self.syspath
        support.modules_cleanup(*self.modules_before)
        if self.root: # Only clean if the test was actually run
            cleanout(self.root)

        # delete all modules concerning the tested hierarchy
        if self.pkgname:
            modules = [name for name in sys.modules
                       if self.pkgname in name.split('.')]
            for name in modules:
                del sys.modules[name] 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:test_pkg.py

示例4: tearDown

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import modules_cleanup [as 别名]
def tearDown(self):
        sys.path[:] = self.path
        sys.meta_path[:] = self.meta_path
        sys.path_hooks[:] = self.path_hooks
        sys.path_importer_cache.clear()
        support.modules_cleanup(*self.modules_before) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_zipimport.py

示例5: test_sundry

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import modules_cleanup [as 别名]
def test_sundry(self):
        old_modules = support.modules_setup()
        try:
            for fn in os.listdir(scriptsdir):
                if not fn.endswith('.py'):
                    continue

                name = fn[:-3]
                if name in self.skiplist:
                    continue

                import_tool(name)
        finally:
            # Unload all modules loaded in this test
            support.modules_cleanup(*old_modules) 
开发者ID:bkerler,项目名称:android_universal,代码行数:17,代码来源:test_sundry.py


注:本文中的test.support.modules_cleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。