本文整理汇总了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()
示例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()