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


Python mock.DEFAULT属性代码示例

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


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

示例1: _patch_object

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def _patch_object(
    target,
    attribute,
    new=mock.DEFAULT,
    spec=None,
    create=False,
    mocksignature=False,
    spec_set=None,
    autospec=False,
    new_callable=None,
    **kwargs
):
    getter = lambda: target
    return _make_patch_async(
        getter,
        attribute,
        new,
        spec,
        create,
        mocksignature,
        spec_set,
        autospec,
        new_callable,
        kwargs,
    ) 
开发者ID:quora,项目名称:asynq,代码行数:27,代码来源:mock_.py

示例2: test_processExtendedGcode_excluding_noMatch

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_processExtendedGcode_excluding_noMatch(self):
        """Test processExtendedGcode when excluding and no entry matches."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
            unit,
            extendedExcludeGcodes=mock.DEFAULT,
            _processExtendedGcodeEntry=mock.DEFAULT
        ) as mocks:
            unit.excluding = True
            mocks["extendedExcludeGcodes"].get.return_value = None

            result = unit.processExtendedGcode("G1 X1 Y2", "G1", None)

            mocks["extendedExcludeGcodes"].get.assert_called_with("G1")
            mocks["_processExtendedGcodeEntry"].assert_not_called()
            self.assertIsNone(result, "The return value should be None") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:20,代码来源:test_ExcludeRegionState_processExtendedGcode.py

示例3: test_processExtendedGcode_excluding_matchExists

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_processExtendedGcode_excluding_matchExists(self):
        """Test processExtendedGcode when excluding and a matching entry exists."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
            unit,
            extendedExcludeGcodes=mock.DEFAULT,
            _processExtendedGcodeEntry=mock.DEFAULT
        ) as mocks:
            unit.excluding = True
            mockEntry = mock.Mock(name="entry")
            mockEntry.mode = "expectedMode"
            mocks["extendedExcludeGcodes"].get.return_value = mockEntry
            mocks["_processExtendedGcodeEntry"].return_value = "expectedResult"

            result = unit.processExtendedGcode("G1 X1 Y2", "G1", None)

            mocks["extendedExcludeGcodes"].get.assert_called_with("G1")
            mocks["_processExtendedGcodeEntry"].assert_called_with("expectedMode", "G1 X1 Y2", "G1")
            self.assertEqual(
                result, "expectedResult",
                "The expected result of _processExtendedGcodeEntry should be returned"
            ) 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:26,代码来源:test_ExcludeRegionState_processExtendedGcode.py

示例4: test_processExtendedGcode_notExcluding_matchExists

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_processExtendedGcode_notExcluding_matchExists(self):
        """Test processExtendedGcode when not excluding and a matching entry exists."""
        mockLogger = mock.Mock()
        mockLogger.isEnabledFor.return_value = False  # For coverage of logging condition
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
            unit,
            extendedExcludeGcodes=mock.DEFAULT,
            _processExtendedGcodeEntry=mock.DEFAULT
        ) as mocks:
            unit.excluding = False
            mockEntry = mock.Mock(name="entry")
            mockEntry.mode = "expectedMode"
            mocks["extendedExcludeGcodes"].get.return_value = mockEntry

            result = unit.processExtendedGcode(AnyIn(["G1 X1 Y2", "G1 Y2 X1"]), "G1", None)

            mocks["extendedExcludeGcodes"].get.assert_not_called()
            mocks["_processExtendedGcodeEntry"].assert_not_called()
            self.assertIsNone(result, "The return value should be None") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:23,代码来源:test_ExcludeRegionState_processExtendedGcode.py

示例5: _test_on_event_stopPrinting

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def _test_on_event_stopPrinting(self, eventType, clearRegions):
        """Test the on_event method when an event is received that indicates printing stopped."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            simulate_isActivePrintJob(unit, True)
            unit.clearRegionsAfterPrintFinishes = clearRegions

            mockPayload = mock.Mock()

            result = unit.on_event(eventType, mockPayload)

            self.assertFalse(unit.isActivePrintJob, "isActivePrintJob should report False")
            self.assertIsNone(result, "The result should be None")

            if (clearRegions):
                mocks['state'].resetState.assert_called_with(True)
                mocks['_notifyExcludedRegionsChanged'].assert_called_with()
            else:
                mocks['state'].resetState.assert_not_called()
                mocks['_notifyExcludedRegionsChanged'].assert_not_called() 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:26,代码来源:test_ExcludeRegionPlugin.py

示例6: test_handleAddExcludeRegion_success

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleAddExcludeRegion_success(self):
        """Test _handleAddExcludeRegion when state.addRegion succeeds."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            mockRegion = mock.Mock()

            result = unit._handleAddExcludeRegion(mockRegion)  # pylint: disable=protected-access

            mocks["state"].addRegion.assert_called_with(mockRegion)
            mocks["_notifyExcludedRegionsChanged"].assert_called()

            self.assertIsNone(result, "The result should be None") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:18,代码来源:test_ExcludeRegionPlugin.py

示例7: test_handleAddExcludeRegion_ValueError

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleAddExcludeRegion_ValueError(self):
        """Test _handleAddExcludeRegion when state.addRegion raises a ValueError."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            mocks["state"].addRegion.side_effect = ValueError("ExpectedError")

            mockRegion = mock.Mock()

            result = unit._handleAddExcludeRegion(mockRegion)  # pylint: disable=protected-access

            mocks["state"].addRegion.assert_called_with(mockRegion)
            mocks["_notifyExcludedRegionsChanged"].assert_not_called()

            self.assertEqual(
                result, ("ExpectedError", 409),
                "A 409 error response tuple should be returned"
            ) 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:23,代码来源:test_ExcludeRegionPlugin.py

示例8: test_handleDeleteExcludeRegion_success_deleted

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleDeleteExcludeRegion_success_deleted(self):
        """Test _handleDeleteExcludeRegion when state.deleteRegion returns True."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            mocks["state"].deleteRegion.return_value = True

            result = unit._handleDeleteExcludeRegion("someId")  # pylint: disable=protected-access

            mocks["state"].deleteRegion.assert_called_with("someId")
            mocks["_notifyExcludedRegionsChanged"].assert_called()

            self.assertIsNone(result, "The result should be None") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:18,代码来源:test_ExcludeRegionPlugin.py

示例9: test_handleDeleteExcludeRegion_success_not_found

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleDeleteExcludeRegion_success_not_found(self):
        """Test _handleDeleteExcludeRegion when state.deleteRegion returns False."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            mocks["state"].deleteRegion.return_value = False

            result = unit._handleDeleteExcludeRegion("someId")  # pylint: disable=protected-access

            mocks["state"].deleteRegion.assert_called_with("someId")
            mocks["_notifyExcludedRegionsChanged"].assert_not_called()

            self.assertIsNone(result, "The result should be None") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:18,代码来源:test_ExcludeRegionPlugin.py

示例10: test_handleDeleteExcludeRegion_no_del_while_printing

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleDeleteExcludeRegion_no_del_while_printing(self):
        """Test _handleDeleteExcludeRegion when modification is NOT allowed while printing."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            unit.mayShrinkRegionsWhilePrinting = False
            simulate_isActivePrintJob(unit, True)
            mocks["_notifyExcludedRegionsChanged"] = mock.Mock()

            result = unit._handleDeleteExcludeRegion("someId")  # pylint: disable=protected-access

            mocks["state"].deleteRegion.assert_not_called()
            mocks["_notifyExcludedRegionsChanged"].assert_not_called()

            self.assertEqual(
                result,
                (AnyString(), 409),
                "The result should be a Tuple indicating a 409 error"
            ) 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:24,代码来源:test_ExcludeRegionPlugin.py

示例11: test_handleUpdateExcludeRegion_success

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleUpdateExcludeRegion_success(self):
        """Test _handleUpdateExcludeRegion when state.replaceRegion succeeds."""
        unit = create_plugin_instance()
        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            unit.mayShrinkRegionsWhilePrinting = False
            simulate_isActivePrintJob(unit, False)

            mockRegion = mock.Mock()

            result = unit._handleUpdateExcludeRegion(mockRegion)  # pylint: disable=protected-access

            mocks["state"].replaceRegion.assert_called_with(mockRegion, False)
            mocks["_notifyExcludedRegionsChanged"].assert_called()

            self.assertIsNone(result, "The result should be None") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:21,代码来源:test_ExcludeRegionPlugin.py

示例12: test_handleUpdateExcludeRegion_ValueError

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handleUpdateExcludeRegion_ValueError(self):
        """Test _handleUpdateExcludeRegion when a ValueError is raised."""
        unit = create_plugin_instance()

        with mock.patch.multiple(
            unit,
            state=mock.DEFAULT,
            _notifyExcludedRegionsChanged=mock.DEFAULT
        ) as mocks:
            unit.mayShrinkRegionsWhilePrinting = False
            simulate_isActivePrintJob(unit, True)
            mocks["state"].replaceRegion.side_effect = ValueError("ExpectedError")

            mockRegion = mock.Mock()

            result = unit._handleUpdateExcludeRegion(mockRegion)  # pylint: disable=protected-access

            mocks["state"].replaceRegion.assert_called_with(mockRegion, True)
            mocks["_notifyExcludedRegionsChanged"].assert_not_called()

            self.assertEqual(
                result, ("ExpectedError", 409),
                "A 409 error response tuple should be returned"
            ) 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:26,代码来源:test_ExcludeRegionPlugin.py

示例13: test_handle_G2_radiusTrumpsOffsets

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handle_G2_radiusTrumpsOffsets(self):
        """Test the _handle_G2 method to ensure offsets (I, J) are ignored if a radius is given."""
        unit = self._createInstance()

        with mock.patch.multiple(
            unit,
            computeArcCenterOffsets=mock.DEFAULT,
            planArc=mock.DEFAULT
        ) as mocks:
            expectedResult = ["Command1"]
            unit.state.processLinearMoves.return_value = expectedResult
            mocks["computeArcCenterOffsets"].return_value = (12, 13)
            mocks["planArc"].return_value = [0, 1, 2, 3]

            result = unit._handle_G2(  # pylint: disable=protected-access
                "G2 R20 I8 J9 X10 Y0",
                "G2",
                None
            )

            mocks["computeArcCenterOffsets"].assert_called_with(10, 0, 20, True)
            mocks["planArc"].assert_called_with(10, 0, 12, 13, True)

            self.assertEqual(result, expectedResult, "A list of one command should be returned") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:26,代码来源:test_GcodeHandlers.py

示例14: test_handle_G2_offsetMode_paramParsing

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_handle_G2_offsetMode_paramParsing(self):
        """Test _handle_G2 parameter parsing when center point offsets are provided."""
        unit = self._createInstance()

        unit.state.position.X_AXIS.nativeToLogical.return_value = 0
        unit.state.position.X_AXIS.nativeToLogical.return_value = 1

        expectedResult = ["Command1", "Command2"]
        unit.state.processLinearMoves.return_value = expectedResult

        with mock.patch.multiple(
            unit,
            computeArcCenterOffsets=mock.DEFAULT,
            planArc=mock.DEFAULT
        ) as mocks:
            mocks["planArc"].return_value = [4, 5]

            cmd = "G2 I6.1 J6.2 X7 Y8 Z9 E10 F11"
            result = unit._handle_G2(cmd, "G2", None)  # pylint: disable=protected-access

            mocks["computeArcCenterOffsets"].assert_not_called()
            mocks["planArc"].assert_called_with(7, 8, 6.1, 6.2, True)
            unit.state.processLinearMoves.assert_called_with(cmd, 10, 11, 9, 4, 5)

            self.assertEqual(result, expectedResult, "A list of two commands should be returned") 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:27,代码来源:test_GcodeHandlers.py

示例15: test_processNonMove_deltaE_zero_notExcluding

# 需要导入模块: import mock [as 别名]
# 或者: from mock import DEFAULT [as 别名]
def test_processNonMove_deltaE_zero_notExcluding(self):
        """Test _processNonMove when deltaE is 0 and not excluding."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
            unit,
            recordRetraction=mock.DEFAULT,
            recoverRetractionIfNeeded=mock.DEFAULT
        ) as mocks:
            unit.excluding = False
            unit.feedRate = 100

            result = unit._processNonMove("G0 E0 F100", 0)  # pylint: disable=protected-access

            mocks["recordRetraction"].assert_not_called()
            mocks["recoverRetractionIfNeeded"].assert_not_called()
            self.assertEqual(
                result, ["G0 E0 F100"],
                "The result should be a list containing the command"
            ) 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:23,代码来源:test_ExcludeRegionState.py


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