Merge pull request #20318 from Ultimaker/CURA-12386_G-Code-replacement-fails-with-single-line-code

CURA-12386 G-Code replacement fails with single line code
This commit is contained in:
HellAholic 2025-03-03 14:14:19 +01:00 committed by GitHub
commit c86c08bd90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 8 deletions

View file

@ -265,6 +265,10 @@ pycharm_targets:
module_name: Cura
name: pytest in TestSettingVisibilityPresets.py
script_name: tests/Settings/TestSettingVisibilityPresets.py
- jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
module_name: Cura
name: pytest in TestStartEndGCode.py
script_name: tests/Machines/TestStartEndGCode.py
pip_requirements_core:
any_os:

View file

@ -76,7 +76,7 @@ class GcodeStartEndFormatter:
# will be used. Alternatively, if the expression is formatted as "{[expression], [extruder_nr]}",
# then the expression will be evaluated with the extruder stack of the specified extruder_nr.
_instruction_regex = re.compile(r"{(?P<condition>if|else|elif|endif)?\s*(?P<expression>.*?)\s*(?:,\s*(?P<extruder_nr_expr>.*))?\s*}(?P<end_of_line>\n?)")
_instruction_regex = re.compile(r"{(?P<condition>if|else|elif|endif)?\s*(?P<expression>[^{}]*?)\s*(?:,\s*(?P<extruder_nr_expr>[^{}]*))?\s*}(?P<end_of_line>\n?)")
def __init__(self, all_extruder_settings: Dict[str, Dict[str, Any]], default_extruder_nr: int = -1) -> None:
super().__init__()

View file

@ -7,12 +7,6 @@ from unittest.mock import MagicMock
from plugins.CuraEngineBackend.StartSliceJob import GcodeStartEndFormatter
# def createMockedInstanceContainer(container_id):
# result = MagicMock()
# result.getId = MagicMock(return_value=container_id)
# result.getMetaDataEntry = MagicMock(side_effect=getMetadataEntrySideEffect)
# return result
class MockValueProvider:
## Creates a mock value provider.
#
@ -259,7 +253,7 @@ Q2000
''
),
(
(
'Unexpected end character',
None,
'''{if material_temperature > 200, 0}}
@ -270,6 +264,20 @@ S2000
'''S2000
'''
),
(
'Multiple replaces on single line',
None,
'''BT={bed_temperature} IE={initial_extruder}''',
'''BT=50.0 IE=0'''
),
(
'Multiple extruder replaces on single line',
None,
'''MT0={material_temperature, 0} MT1={material_temperature, 1}''',
'''MT0=190.0 MT1=210.0'''
),
]
def pytest_generate_tests(metafunc):