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


Python Mocker.generate方法代码示例

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


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

示例1: test_close

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import generate [as 别名]
def test_close():
    from editxt.util import KVOList
    proj = Project.create()
    m = Mocker()
    proj._documents = m.mock(KVOList)
    docs = []
    for i in xrange(2):
        dv = m.mock(TextDocumentView)
        docs.append(dv)
        dv.close()
    iter(proj._documents); m.generate(docs)
    #proj._documents.__length_hint__ >> len(docs)
    #proj._documents.setItems_([])
    with m:
        proj.close()
开发者ID:youngrok,项目名称:editxt,代码行数:17,代码来源:test_project.py

示例2: TestBuildJunctionDict

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import generate [as 别名]
class TestBuildJunctionDict(TestCase):
    def setUp(self):
        self.mocker = Mocker()
        self.junctions = self.mocker.mock()
        self.junction1 = self.mocker.mock()
        self.junction2 = self.mocker.mock()
        self.junction3 = self.mocker.mock()

        self.junction1.start
        self.mocker.result(100)
        self.mocker.count(0, None)

        self.junction1.end
        self.mocker.result(200)
        self.mocker.count(0, None)

        self.junction1.chrom
        self.mocker.result("chr1")
        self.mocker.count(0, None)

        self.junction2.start
        self.mocker.result(100)
        self.mocker.count(0, None)

        self.junction2.end
        self.mocker.result(300)
        self.mocker.count(0, None)

        self.junction2.chrom
        self.mocker.result("chr1")
        self.mocker.count(0, None)

        self.junction3.start
        self.mocker.result(200)
        self.mocker.count(0, None)

        self.junction3.end
        self.mocker.result(300)
        self.mocker.count(0, None)

        self.junction3.chrom
        self.mocker.result("chr1")
        self.mocker.count(0, None)

    def test_no_overlaps(self):

        self.junctions.iteritems()
        self.mocker.generate([("chr1:100-200", self.junction1)])

        self.mocker.replay()

        self.container = jc.buildJunctionDict(self.junctions)
        self.assertEqual(self.container["chr1:100"], [200])
        self.assertEqual(len(self.container), 1)

        self.mocker.restore()
        self.mocker.verify()

    def test_overlaps(self):

        self.junctions.iteritems()
        self.mocker.generate([("chr1:100-200", self.junction1), ("chr1:100-300", self.junction2)])

        self.mocker.replay()
        self.container = jc.buildJunctionDict(self.junctions)
        self.assertEqual(self.container["chr1:100"], [200, 300])
        self.assertEqual(len(self.container), 1)

        self.mocker.restore()
        self.mocker.verify()

    def test_multiple_junctions_with_overlaps(self):
        self.junctions.iteritems()
        self.mocker.generate(
            [("chr1:100-200", self.junction1), ("chr1:100-300", self.junction2), ("chr1:200-300", self.junction3)]
        )

        self.mocker.replay()
        self.container = jc.buildJunctionDict(self.junctions)
        self.assertEqual(self.container["chr1:100"], [200, 300])
        self.assertEqual(self.container["chr1:200"], [300])
        self.assertEqual(len(self.container), 2)

        self.mocker.restore()
        self.mocker.verify()
开发者ID:bjventers,项目名称:python-codes-for-RNAseq,代码行数:87,代码来源:test_junction_comp.py


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