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


Python Controller.do_text_save方法代码示例

本文整理汇总了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)
开发者ID:acr79,项目名称:BCPR301_LegacySystem,代码行数:29,代码来源:UT_FilerFunctionality.py

示例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)
开发者ID:acr79,项目名称:BCPR301_LegacySystem,代码行数:17,代码来源:UT_FilerFunctionality.py

示例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)
开发者ID:acr79,项目名称:BCPR301_LegacySystem,代码行数:18,代码来源:UT_FilerFunctionality.py


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