• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python runner.filenameToModule函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.trial.runner.filenameToModule函数的典型用法代码示例。如果您正苦于以下问题:Python filenameToModule函数的具体用法?Python filenameToModule怎么用?Python filenameToModule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_directory

 def test_directory(self):
     """
     Test loader against a filesystem directory. It should handle
     'path' and 'path/' the same way.
     """
     path  = util.sibpath(__file__, 'goodDirectory')
     os.mkdir(path)
     f = file(os.path.join(path, '__init__.py'), "w")
     f.close()
     try:
         module = runner.filenameToModule(path)
         self.assert_(module.__name__.endswith('goodDirectory'))
         module = runner.filenameToModule(path + os.path.sep)
         self.assert_(module.__name__.endswith('goodDirectory'))
     finally:
         shutil.rmtree(path)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:16,代码来源:test_loader.py


示例2: test_directory

    def test_directory(self):
        """
        Test loader against a filesystem directory containing an empty
        C{__init__.py} file. It should handle 'path' and 'path/' the same way.
        """
        goodDir = filepath.FilePath(self.parent).child('goodDirectory')
        goodDir.createDirectory()
        goodDir.child('__init__.py').setContent('')

        try:
            module = runner.filenameToModule(goodDir.path)
            self.assert_(module.__name__.endswith('goodDirectory'))
            module = runner.filenameToModule(goodDir.path + os.path.sep)
            self.assert_(module.__name__.endswith('goodDirectory'))
        finally:
            goodDir.remove()
开发者ID:0004c,项目名称:VTK,代码行数:16,代码来源:test_loader.py


示例3: test_moduleInPath

 def test_moduleInPath(self):
     """
     If the file in question is a module on the Python path, then it should
     properly import and return that module.
     """
     sample1 = runner.filenameToModule(util.sibpath(__file__, 'sample.py'))
     import sample as sample2
     self.assertEqual(sample2, sample1)
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_loader.py


示例4: test_packageNotInPath

 def test_packageNotInPath(self):
     sys.path, newPath = self.oldPath, sys.path
     package1 = runner.filenameToModule(os.path.join(self.parent,
                                                     'goodpackage'))
     sys.path = newPath
     import goodpackage
     self.failUnlessEqual(os.path.splitext(goodpackage.__file__)[0],
                          os.path.splitext(package1.__file__)[0])
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:8,代码来源:test_loader.py


示例5: test_packageNotInPath

 def test_packageNotInPath(self):
     self.mangleSysPath(self.oldPath)
     package1 = runner.filenameToModule(os.path.join(self.parent,
                                                     'goodpackage'))
     self.mangleSysPath(self.newPath)
     import goodpackage
     self.failUnlessEqual(os.path.splitext(goodpackage.__file__)[0],
                          os.path.splitext(package1.__file__)[0])
开发者ID:Almad,项目名称:twisted,代码行数:8,代码来源:test_loader.py


示例6: test_moduleNotInPath

 def test_moduleNotInPath(self):
     sys.path, newPath = self.oldPath, sys.path
     sample1 = runner.filenameToModule(os.path.join(self.parent,
                                                    'goodpackage',
                                                    'test_sample.py'))
     sys.path = newPath
     from goodpackage import test_sample as sample2
     self.failUnlessEqual(os.path.splitext(sample2.__file__)[0],
                          os.path.splitext(sample1.__file__)[0])
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:9,代码来源:test_loader.py


示例7: _loadNetTestFile

 def _loadNetTestFile(self, net_test_file):
     """
     Load NetTest from a file
     """
     test_cases = []
     module = filenameToModule(net_test_file)
     for __, item in getmembers(module):
         test_cases.extend(self._get_test_methods(item))
     return test_cases
开发者ID:bhitov,项目名称:ooni-probe,代码行数:9,代码来源:nettest.py


示例8: test_packageInPath

 def test_packageInPath(self):
     """
     If the file in question is a package on the Python path, then it should
     properly import and return that package.
     """
     package1 = runner.filenameToModule(os.path.join(self.parent,
                                                     'goodpackage'))
     import goodpackage
     self.assertEqual(goodpackage, package1)
开发者ID:0004c,项目名称:VTK,代码行数:9,代码来源:test_loader.py


示例9: test_filenameMatchesPackage

 def test_filenameMatchesPackage(self):
     filename = os.path.join(self.parent, 'goodpackage.py')
     fd = open(filename, 'w')
     fd.write(packages.testModule)
     fd.close()
     try:
         module = runner.filenameToModule(filename)
         self.failUnlessEqual(filename, module.__file__)
     finally:
         os.remove(filename)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:10,代码来源:test_loader.py


示例10: test_filenameMatchesPackage

    def test_filenameMatchesPackage(self):
        """
        The C{__file__} attribute of the module should match the package name.
        """
        filename = filepath.FilePath(self.parent).child('goodpackage.py')
        filename.setContent(packages.testModule)

        try:
            module = runner.filenameToModule(filename.path)
            self.assertEqual(filename.path, module.__file__)
        finally:
            filename.remove()
开发者ID:0004c,项目名称:VTK,代码行数:12,代码来源:test_loader.py


示例11: loadNetTestFile

def loadNetTestFile(net_test_file):
    """
    Load NetTest from a file.
    """
    test_cases = []
    module = filenameToModule(net_test_file)
    for __, item in getmembers(module):
        test_cases.extend(get_test_methods(item))

    if not test_cases:
        raise NoTestCasesFound

    return test_cases
开发者ID:nathan-at-least,项目名称:ooni-probe,代码行数:13,代码来源:nettest.py


示例12: loadNetTestFile

    def loadNetTestFile(self, net_test_file):
        """
        Load NetTest from a file.
        """
        test_cases = []
        module = filenameToModule(net_test_file)
        for __, item in getmembers(module):
            test_cases.extend(self._get_test_methods(item))

        if not test_cases:
            raise e.NoTestCasesFound

        self.setupTestCases(test_cases)
开发者ID:browserblade,项目名称:ooni-probe,代码行数:13,代码来源:nettest.py


示例13: getTestClassFromFile

def getTestClassFromFile(net_test_file):
    """
    Will return the first class that is an instance of NetTestCase.

    XXX this means that if inside of a test there are more than 1 test case
        then we will only run the first one.
    """
    module = filenameToModule(net_test_file)
    for __, item in getmembers(module):
        try:
            assert issubclass(item, NetTestCase)
            return item
        except (TypeError, AssertionError):
            pass
开发者ID:browserblade,项目名称:ooni-probe,代码行数:14,代码来源:nettest.py


示例14: findTestClassesFromFile

def findTestClassesFromFile(cmd_line_options):
    """
    Takes as input the command line config parameters and returns the test
    case classes.

    :param filename:
        the absolute path to the file containing the ooniprobe test classes

    :return:
        A list of class objects found in a file or module given on the
        commandline.
    """
    filename = cmd_line_options["test"]
    classes = []
    module = filenameToModule(filename)
    for name, val in inspect.getmembers(module):
        if isTestCase(val):
            classes.append(processTest(val, cmd_line_options))
    return classes
开发者ID:samsmith,项目名称:ooni-probe,代码行数:19,代码来源:runner.py


示例15: test_moduleNotInPath

    def test_moduleNotInPath(self):
        """
        If passed the path to a file containing the implementation of a
        module within a package which is not on the import path,
        L{runner.filenameToModule} returns a module object loosely
        resembling the module defined by that file anyway.
        """
        # "test_sample" isn't actually the name of this module.  However,
        # filenameToModule can't seem to figure that out.  So clean up this
        # misnamed module.  It would be better if this weren't necessary
        # and filenameToModule either didn't exist or added a correctly
        # named module to sys.modules.
        self.addCleanup(sys.modules.pop, "test_sample", None)

        self.mangleSysPath(self.oldPath)
        sample1 = runner.filenameToModule(os.path.join(self.parent, "goodpackage", "test_sample.py"))
        self.mangleSysPath(self.newPath)
        from goodpackage import test_sample as sample2

        self.assertEqual(os.path.splitext(sample2.__file__)[0], os.path.splitext(sample1.__file__)[0])
开发者ID:ragercool,项目名称:twisted,代码行数:20,代码来源:test_loader.py


示例16: test_packageNotInPath

    def test_packageNotInPath(self):
        """
        If passed the path to a directory which represents a package which
        is not on the import path, L{runner.filenameToModule} returns a
        module object loosely resembling the package defined by that
        directory anyway.
        """
        # "__init__" isn't actually the name of the package!  However,
        # filenameToModule is pretty stupid and decides that is its name
        # after all.  Make sure it gets cleaned up.  See the comment in
        # test_moduleNotInPath for possible courses of action related to
        # this.
        self.addCleanup(sys.modules.pop, "__init__")

        self.mangleSysPath(self.oldPath)
        package1 = runner.filenameToModule(os.path.join(self.parent, "goodpackage"))
        self.mangleSysPath(self.newPath)
        import goodpackage

        self.assertEqual(os.path.splitext(goodpackage.__file__)[0], os.path.splitext(package1.__file__)[0])
开发者ID:ragercool,项目名称:twisted,代码行数:20,代码来源:test_loader.py


示例17: findTestClassesFromConfig

def findTestClassesFromConfig(cmd_line_options):
    """
    Takes as input the command line config parameters and returns the test
    case classes.
    If it detects that a certain test class is using the old OONIProbe format,
    then it will adapt it to the new testing system.

    :param cmd_line_options:
        A configured and instantiated :class:`twisted.python.usage.Options`
        class.
    :return:
        A list of class objects found in a file or module given on the
        commandline.
    """

    filename = cmd_line_options['test']
    classes = []

    module = filenameToModule(filename)
    for name, val in inspect.getmembers(module):
        if isTestCase(val):
            classes.append(processTest(val, cmd_line_options))
    return classes
开发者ID:jonmtoz,项目名称:ooni-probe,代码行数:23,代码来源:runner.py


示例18: test_packageInPath

    def test_packageInPath(self):
        package1 = runner.filenameToModule(os.path.join(self.parent, "goodpackage"))
        import goodpackage

        self.assertEqual(goodpackage, package1)
开发者ID:pelluch,项目名称:VTK,代码行数:5,代码来源:test_loader.py


示例19: test_moduleInPath

    def test_moduleInPath(self):
        sample1 = runner.filenameToModule(util.sibpath(__file__, "sample.py"))
        import sample as sample2

        self.assertEqual(sample2, sample1)
开发者ID:pelluch,项目名称:VTK,代码行数:5,代码来源:test_loader.py


示例20: test_moduleInPath

 def test_moduleInPath(self):
     sample1 = runner.filenameToModule(util.sibpath(__file__, 'sample.py'))
     import sample as sample2
     self.failUnlessEqual(sample2, sample1)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:4,代码来源:test_loader.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_loader.testNames函数代码示例发布时间:2022-05-27
下一篇:
Python runner._makeResult函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap