From 0583befe6a5b604ee5e0c31090218acef313e73d Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 10 Jun 2022 08:47:58 -0300 Subject: [PATCH] Adapted tests to the new drill_marks validation - Also removed the setter helper, no longer needed as validation is done by Optionable --- kibot/drill_marks.py | 9 +-------- kibot/out_any_pcb_print.py | 4 ++-- kibot/out_pcb_print.py | 4 ++-- tests/test_plot/test_yaml_errors.py | 9 +-------- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/kibot/drill_marks.py b/kibot/drill_marks.py index edf4ff6d..b7f3b2fe 100644 --- a/kibot/drill_marks.py +++ b/kibot/drill_marks.py @@ -4,7 +4,6 @@ # License: GPL-3.0 # Project: KiBot (formerly KiPlot) from pcbnew import PCB_PLOT_PARAMS -from .error import KiPlotConfigurationError from .out_any_layer import AnyLayerOptions from . import log @@ -25,12 +24,6 @@ DRILL_MARKS_REV_MAP = { DRILL_MARKS_HELP = "[none,small,full] What to use to indicate the drill places, can be none, small or full (for real scale)" -def drill_marks_setter(val): - if val not in DRILL_MARKS_MAP: - raise KiPlotConfigurationError("Unknown drill mark type: {}".format(val)) - return val - - def drill_marks_help(self): self._drill_marks = 'full' self.set_doc('drill_marks', " [string='full'] "+DRILL_MARKS_HELP) @@ -49,7 +42,7 @@ class DrillMarks(AnyLayerOptions): @drill_marks.setter def drill_marks(self, val): - self._drill_marks = drill_marks_setter(val) + self._drill_marks = val def config(self, parent): super().config(parent) diff --git a/kibot/out_any_pcb_print.py b/kibot/out_any_pcb_print.py index 63d0e974..eeb37b76 100644 --- a/kibot/out_any_pcb_print.py +++ b/kibot/out_any_pcb_print.py @@ -12,7 +12,7 @@ from .misc import CMD_PCBNEW_PRINT_LAYERS, URL_PCBNEW_PRINT_LAYERS, PDF_PCB_PRIN from .out_base import VariantOptions from .registrable import RegDependency from .macros import macros, document, output_class # noqa: F401 -from .drill_marks import drill_marks_help, drill_marks_setter, DRILL_MARKS_MAP +from .drill_marks import drill_marks_help, DRILL_MARKS_MAP from .layer import Layer from . import log @@ -60,7 +60,7 @@ class Any_PCB_PrintOptions(VariantOptions): @drill_marks.setter def drill_marks(self, val): - self._drill_marks = drill_marks_setter(val) + self._drill_marks = val def config(self, parent): super().config(parent) diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 7887fc39..2ea00b77 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -28,7 +28,7 @@ from .kiplot import check_script, exec_with_retry, add_extra_options from .registrable import RegDependency from .create_pdf import create_pdf_from_pages from .macros import macros, document, output_class # noqa: F401 -from .drill_marks import DRILL_MARKS_MAP, drill_marks_setter, drill_marks_help +from .drill_marks import DRILL_MARKS_MAP, drill_marks_help from .layer import Layer, get_priority from . import __version__ from . import log @@ -303,7 +303,7 @@ class PCB_PrintOptions(VariantOptions): @drill_marks.setter def drill_marks(self, val): - self._drill_marks = drill_marks_setter(val) + self._drill_marks = val def config(self, parent): super().config(parent) diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index 04e56174..a920633d 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -449,14 +449,7 @@ def test_error_gerber_precision(test_dir): def test_error_wrong_drill_marks_1(test_dir): ctx = context.TestContext(test_dir, 'test_error_wrong_drill_marks_1', PRJ, 'error_wrong_drill_marks', '') ctx.run(EXIT_BAD_CONFIG) - assert ctx.search_err("Unknown drill mark type: bogus") - ctx.clean_up() - - -def test_error_wrong_drill_marks_2(test_dir): - ctx = context.TestContext(test_dir, 'test_error_wrong_drill_marks_2', PRJ, 'error_wrong_drill_marks_2', '') - ctx.run(EXIT_BAD_CONFIG) - assert ctx.search_err("Unknown drill mark type: bogus") + assert ctx.search_err(r"Option `drill_marks` must be any of \['none', 'small', 'full'\] not `bogus`") ctx.clean_up()