def _test_enterExcludedRegion_common(self, enteringExcludedRegionGcode):
        """Test common functionality of enterExcludedRegion when exclusion is enabled."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        unit.excluding = False
        unit.excludeStartTime = "oldStartTime"
        unit.numExcludedCommands = 42
        unit.numCommands = 84
        unit.lastPosition = "oldPosition"

        unit.enteringExcludedRegionGcode = enteringExcludedRegionGcode

        result = unit.enterExcludedRegion("G1 X1 Y2")

        self.assertTrue(unit.excluding, "The excluding flag should be True")
        self.assertNotEqual(unit.excludeStartTime, "oldStartTime",
                            "The excludeStartTime should be updated")
        self.assertEqual(unit.numExcludedCommands, 0,
                         "The numExcludedCommands should be reset to 0")
        self.assertEqual(unit.numCommands, 0,
                         "The numCommands should be reset to 0")
        self.assertNotEqual(unit.lastPosition, "oldPosition",
                            "The position should be updated")

        return result
    def test_ignoreGcodeCommand(self):
        """Test the ignoreGcodeCommand method."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)
        unit.numExcludedCommands = 10

        result = unit.ignoreGcodeCommand()

        self.assertEqual(result, IGNORE_GCODE_CMD,
                         "ignoreGcodeCommand should return IGNORE_GCODE_CMD")
        self.assertEqual(
            unit.numExcludedCommands, 11,
            "ignoreGcodeCommand should increment numExcludedCommands")
    def _resetStateSetup():
        """Create and initialize the instance to test the resetState method on."""
        # pylint: disable=protected-access
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        unit.excludedRegions = ["abc"]
        unit.position.X_AXIS.current = 100
        unit.feedRate = 100
        unit.feedRateUnitMultiplier = 1234
        unit._exclusionEnabled = False
        unit.excluding = True
        unit.excludeStartTime = None
        unit.numExcludedCommands = 4321
        unit.numCommands = 6789
        unit.lastRetraction = "abc"
        unit.lastPosition = "123"
        unit.pendingCommands = {"a": 1}

        return unit