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


Python Controller.do_serial_save方法代码示例

本文整理汇总了Python中Controller.Controller.do_serial_save方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.do_serial_save方法的具体用法?Python Controller.do_serial_save怎么用?Python Controller.do_serial_save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Controller.Controller的用法示例。


在下文中一共展示了Controller.do_serial_save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_SerialSave_01

# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_serial_save [as 别名]
    def test_SerialSave_01(self, mock_isfile, mock_open):
        """
        Saving a RecordCollection with 10 Records
        """
        def doDump():
            doDump.theDump = theDumpStream.getvalue()

        theDumpStream = BytesIO()
        theDumpStream.close = Mock(side_effect=doDump)

        # So that it is know that file does not exist
        mock_isfile.return_value = False
        mock_open.return_value = theDumpStream
        theController = Controller(TestView.TestView(), None)
        # add 10 Records, reset view log, then serial save
        self._addSomeRecordsViaController(theController, 10)
        TestView.clearLog()
        theController.do_serial_save("")

        # Part 1: Check contents of theDumpStream
        # theDump = theDumpStream.getvalue()
        expectedRecords = 10
        fromDump = pickle.load(BytesIO(doDump.theDump))
        actualRecords = len(fromDump.getAllRecords())
        self.assertEqual(expectedRecords, actualRecords)

        # Part 2: Check no show() messages on theLog
        expectedLog = 0
        actualLog = len(TestView.theLog)
        self.assertEqual(expectedLog, actualLog)
开发者ID:acr79,项目名称:BCPR301_LegacySystem,代码行数:32,代码来源:UT_FilerFunctionality.py

示例2: test_SerialSave_03

# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_serial_save [as 别名]
 def test_SerialSave_03(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_serial_save("")
     expectedShow = "EXCEPTION: {}\n".format(message)
     actualShow = TestView.theLog[0]
     self.assertEqual(expectedShow, actualShow)
开发者ID:acr79,项目名称:BCPR301_LegacySystem,代码行数:17,代码来源:UT_FilerFunctionality.py

示例3: test_SerialSave_02

# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_serial_save [as 别名]
    def test_SerialSave_02(self, mock_isfile, mock_open):
        """
        Ensure that a serial 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_serial_save("")
        expectedShow = "Will not overwrite an existing file\nPlease, enter a \
new file when using serial_save\n"
        actualShow = TestView.theLog[0]
        self.assertEqual(expectedShow, actualShow)
开发者ID:acr79,项目名称:BCPR301_LegacySystem,代码行数:18,代码来源:UT_FilerFunctionality.py


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