本文整理汇总了Python中Controller.Controller.do_text_save方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.do_text_save方法的具体用法?Python Controller.do_text_save怎么用?Python Controller.do_text_save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller.Controller
的用法示例。
在下文中一共展示了Controller.do_text_save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_TextSave_03
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_text_save [as 别名]
def test_TextSave_03(self, mock_isfile, mock_open):
"""
Add 2 Records, then expect the text save to produce 2 text lines
"""
def doText():
doText.theText = theTextStream.getvalue()
theTextStream = StringIO()
theTextStream.close = Mock(side_effect=doText)
mock_isfile.return_value = False
mock_open.return_value = theTextStream
theController = Controller(TestView.TestView(), None)
self._addSomeRecordsViaController(theController, 2)
TestView.clearLog()
theController.do_text_save("")
# Part 1: Text data
expectedData = "A000 M 0 0 Normal 0\nA001 M 0 0 Normal 0"
actualData = doText.theText
self.assertEqual(expectedData, actualData)
# Part 2: Show
expectedShow = "Saved As Text"
actualShow = TestView.theLog[0]
self.assertEqual(expectedShow, actualShow)
示例2: test_TextSave_02
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_text_save [as 别名]
def test_TextSave_02(self, mock_isfile, mock_open):
"""
Handles IOError
- Because the IOError message is expected to be determined by the
IOError constructor, the message will be randomised
"""
message = str(random.randrange(100))
mock_isfile.return_value = False
mock_open.side_effect = IOError(message)
theController = Controller(TestView.TestView(), None)
TestView.clearLog()
theController.do_text_save("")
expectedShow = "EXCEPTION: {}\n".format(message)
actualShow = TestView.theLog[0]
self.assertEqual(expectedShow, actualShow)
示例3: test_TextSave_01
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_text_save [as 别名]
def test_TextSave_01(self, mock_isfile, mock_open):
"""
Ensure that a text save does not happen when file exists
- isfile will return true
- Ensure open does not get called: If it does an error will be raised
"""
mock_isfile.return_value = True
mock_open.side_effect = AssertionError()
theController = Controller(TestView.TestView(), None)
TestView.clearLog()
theController.do_text_save("")
expectedShow = "Will not overwrite an existing file\nPlease, enter a \
new file when using text_save\n"
actualShow = TestView.theLog[0]
self.assertEqual(expectedShow, actualShow)