本文整理汇总了Python中dirigible.sheet.worksheet.Worksheet.to_location方法的典型用法代码示例。如果您正苦于以下问题:Python Worksheet.to_location方法的具体用法?Python Worksheet.to_location怎么用?Python Worksheet.to_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dirigible.sheet.worksheet.Worksheet
的用法示例。
在下文中一共展示了Worksheet.to_location方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_location
# 需要导入模块: from dirigible.sheet.worksheet import Worksheet [as 别名]
# 或者: from dirigible.sheet.worksheet.Worksheet import to_location [as 别名]
def test_to_location(self):
ws = Worksheet()
self.assertEquals( ws.to_location((1, 2)), (1, 2) )
self.assertEquals( ws.to_location((1L, 2L)), (1L, 2L) )
self.assertEquals( ws.to_location(('a', 2)), (1, 2) )
self.assertEquals( ws.to_location(('A', 2)), (1, 2) )
self.assertEquals( ws.to_location('a2'), (1, 2) )
self.assertEquals( ws.to_location('A2'), (1, 2) )
self.assertEquals( ws.to_location('A'), None )
self.assertEquals( ws.to_location('1A'), None )
self.assertEquals( ws.to_location((1, 'A')), None )
self.assertEquals( ws.to_location(123), None )
self.assertEquals( ws.to_location(object()), None )
示例2: test_setitem_on_locations_should_reject_non_cell_instances
# 需要导入模块: from dirigible.sheet.worksheet import Worksheet [as 别名]
# 或者: from dirigible.sheet.worksheet.Worksheet import to_location [as 别名]
def test_setitem_on_locations_should_reject_non_cell_instances(self):
ws = Worksheet()
ws.to_location = Mock(return_value=(1, 2))
expected_message_re = "^Worksheet locations must be Cell objects"
with self.assertRaisesRegexp(TypeError, expected_message_re):
ws[3, 4] = 123
self.assertEquals(ws.to_location.call_args_list, [(((3, 4),), {})])
示例3: test_getitem_should_use_original_key_if_to_location_gives_none
# 需要导入模块: from dirigible.sheet.worksheet import Worksheet [as 别名]
# 或者: from dirigible.sheet.worksheet.Worksheet import to_location [as 别名]
def test_getitem_should_use_original_key_if_to_location_gives_none(self):
ws = Worksheet()
ws.to_location = Mock(return_value=(3, 4))
ws[3, 4].formula = "hello"
self.assertEquals(ws.to_location.call_args_list, [(((3, 4),), {})])
self.assertEquals(ws.keys(), [(3, 4)])
self.assertEquals(ws.values()[0].formula, "hello")
示例4: test_getitem_should_use_to_location_result_if_it_is_not_none
# 需要导入模块: from dirigible.sheet.worksheet import Worksheet [as 别名]
# 或者: from dirigible.sheet.worksheet.Worksheet import to_location [as 别名]
def test_getitem_should_use_to_location_result_if_it_is_not_none(self):
ws = Worksheet()
ws.to_location = Mock(return_value=(1, 2))
ws[3, 4].formula = "hello"
self.assertEquals(ws.to_location.call_args_list, [(((3, 4),), {})])
self.assertEquals(ws.keys(), [(1, 2)])
self.assertEquals(ws.values()[0].formula, "hello")
示例5: test_setitem_on_locations_should_accept_cell_instances
# 需要导入模块: from dirigible.sheet.worksheet import Worksheet [as 别名]
# 或者: from dirigible.sheet.worksheet.Worksheet import to_location [as 别名]
def test_setitem_on_locations_should_accept_cell_instances(self):
ws = Worksheet()
ws.to_location = Mock(return_value=(1, 2))
cell = Cell()
ws[3, 4] = cell
self.assertEquals(ws.to_location.call_args_list, [(((3, 4),), {})])
self.assertEquals(ws.keys(), [(1, 2)])
示例6: test_setitem_on_non_locations_raises_keyerror
# 需要导入模块: from dirigible.sheet.worksheet import Worksheet [as 别名]
# 或者: from dirigible.sheet.worksheet.Worksheet import to_location [as 别名]
def test_setitem_on_non_locations_raises_keyerror(self):
ws = Worksheet()
ws.to_location = Mock(return_value=None)
with self.assertRaisesRegexp(InvalidKeyError, "^'random key' is not a valid cell location$"):
ws['random key'] = 'sausages'