本文整理汇总了Python中unittest.mock.Mock.start方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.start方法的具体用法?Python Mock.start怎么用?Python Mock.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.Mock
的用法示例。
在下文中一共展示了Mock.start方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_positive
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_make_positive(self):
seq_len = 8
mrna = Mrna(start=1, end=7, strand='-')
cds = Mock()
cds.start = 1
cds.end = 7
cds.strand = '-'
exon = Mock()
exon.start = 1
exon.end = 7
cds.strand = '-'
mrna.children = {'cds':[cds], 'exon':[exon]}
mrna.make_positive(seq_len)
self.assertEqual(mrna.start, 2)
self.assertEqual(mrna.end, 8)
self.assertEqual(mrna.strand, '+')
self.assertEqual(cds.start, 2)
self.assertEqual(cds.end, 8)
self.assertEqual(cds.strand, '+')
self.assertEqual(exon.start, 2)
self.assertEqual(exon.end, 8)
self.assertEqual(exon.strand, '+')
示例2: test_match_cds_and_exon_end_does_nothing_if_stop_codon_present
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_match_cds_and_exon_end_does_nothing_if_stop_codon_present(self):
mrna = Mrna()
cds = Mock()
cds.start = 1
cds.end = 5
exon = Mock()
exon.start = 1
exon.end = 6
mrna.children = {'cds':[cds], 'exon':[exon], 'stop_codon':[Mock()]}
mrna.match_cds_and_exon_end()
self.assertEquals(cds.end, 5)
示例3: test_match_cds_and_exon_end
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_match_cds_and_exon_end(self):
mrna = Mrna()
cds = Mock()
cds.start = 1
cds.end = 5
exon = Mock()
exon.start = 1
exon.end = 6
mrna.children = {'cds':[cds], 'exon':[exon]}
mrna.match_cds_and_exon_end()
self.assertEquals(cds.end, 6)
示例4: test_add_two
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_add_two(self):
connection.create = Mock(side_effect=[1, 2, 3, 4])
way1 = Mock()
way1.start = Mock()
way2 = Mock()
way2.start = Mock()
route.create = Mock(side_effect=[way1, way2])
registry = Registry(self.config)
self.assertIsNone(registry.add({'host': "127.0.0.2", 'port': 80}))
self.assertIsNone(registry.add({'host': "127.0.0.3", 'port': 81}))
calls = [call("127.0.0.2", 80), call("127.0.0.1", 12345),
call("127.0.0.3", 81), call("127.0.0.1", 12345)]
connection.create.assert_has_calls(calls)
calls_way = [call(1, 2), call(3, 4)]
route.create.assert_has_calls(calls_way)
way1.start.assert_called_once_with()
way2.start.assert_called_once_with()
示例5: test_add_incorect_address
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_add_incorect_address(self):
connection.create = Mock()
way = Mock()
way.start = Mock()
route.create = Mock(return_value=way)
registry = Registry(self.config)
self.assertIsNone(registry.add({'host': "127.0.0.2", 'port': "abc"}))
route.create.assert_not_called()
way.start.assert_not_called()
示例6: test_add
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_add(self):
connection.create = Mock(side_effect=[1, 2])
way = Mock()
way.start = Mock()
route.create = Mock(return_value=way)
registry = Registry(self.config)
self.assertIsNone(registry.add({'host': "127.0.0.2", 'port': 80}))
calls = [call("127.0.0.2", 80), call("127.0.0.1", 12345)]
connection.create.assert_has_calls(calls)
route.create.assert_called_once_with(1, 2)
way.start.assert_called_once_with()
示例7: test_create_starts_and_stops_creates_a_start_reverse_complement
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_create_starts_and_stops_creates_a_start_reverse_complement(self):
mrna = Mrna()
cds = Mock()
cds.start = 1
cds.end = 6
cds.strand = '-'
mrna.children = {'cds':[cds]}
mrna.attributes = {'ID':'m.1234'}
mrna.create_starts_and_stops('NNNCAT')
self.assertTrue('start_codon' in mrna)
示例8: test_create_starts_and_stops_creates_a_stop
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
def test_create_starts_and_stops_creates_a_stop(self):
mrna = Mrna()
cds = Mock()
cds.start = 1
cds.end = 6
cds.strand = '+'
mrna.children = {'cds':[cds]}
mrna.attributes = {'ID':'m.1234'}
mrna.create_starts_and_stops('NNNTAG')
self.assertTrue('stop_codon' in mrna)
示例9: TestCollage
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import start [as 别名]
class TestCollage(unittest.TestCase):
def setUp(self):
self.p1 = Mock()
self.p2 = Mock()
def force_cell_position(self, pos):
"""Disable random in placing cells"""
self.p1.stop()
self.p1 = patch("random.choice",
new=Mock(side_effect=lambda x: x[pos]))
self.p1.start()
def prevent_cell_extension(self):
self.p2.stop()
self.p2 = patch("random.random", new=Mock(side_effect=lambda: 0.0))
self.p2.start()
def force_cell_extension(self):
self.p2.stop()
self.p2 = patch("random.random", new=Mock(side_effect=lambda: 1.0))
self.p2.start()
def test_next_free_col(self):
self.force_cell_position(0)
self.prevent_cell_extension()
page = Page(100, 0.6, 4)
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
wanted = "[25 25] [25 25] "
self.assertEqual(repr(page), wanted)
page = Page(40, 0.6, 4)
page.add_cell(Photo("img", 10, 20))
page.add_cell(Photo("img", 10, 15))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 22))
wanted = ("[10 20] [10 15] [10 10] [10 10]\n"
" [10 22] [10 10] [10 10]")
self.assertEqual(repr(page), wanted)
page = Page(50, 0.6, 5)
self.force_cell_extension()
page.add_cell(Photo("img", 10, 15))
page.add_cell(Photo("img", 10, 10))
self.prevent_cell_extension()
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 50))
wanted = ("[20 30-- ------] [20 20-- ------] [10 10]\n"
" [10 50]")
self.assertEqual(repr(page), wanted)
def test_remove_empty_cols(self):
page = Page(1, 0.6, 100)
self.prevent_cell_extension()
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
page.remove_empty_cols()
self.assertEqual(len(page.cols), 5)
def test_bottom_hole_A1(self):
"""
----------------------
| | | |
| |-------------|
|------| |
| |--------------
| | |
---------------
"""
page = Page(30, 0.6, 3)
self.force_cell_position(0)
self.prevent_cell_extension()
page.add_cell(Photo("img", 10, 15))
page.add_cell(Photo("img", 10, 10))
page.add_cell(Photo("img", 10, 10))
self.force_cell_extension()
page.add_cell(Photo("img", 10, 5))
self.prevent_cell_extension()
page.add_cell(Photo("img", 10, 15))
page.add_cell(Photo("img", 10, 10))
wanted = ("[10 15] [10 10] [10 10]\n"
"[10 15] [20 10-- ------]\n"
" [10 10] ")
self.assertEqual(repr(page), wanted)
page.remove_bottom_holes()
wanted = ("[10 15] [10 10] [10 10]\n"
"[10 15] [20 10-- ------]\n"
" [20 10-- ------]")
self.assertEqual(repr(page), wanted)
def test_bottom_hole_A2(self):
#.........这里部分代码省略.........