From 995b6990aa83a941ef09876193a1bb54428cba20 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 8 Jul 2020 23:16:04 -0300 Subject: [PATCH] Added HPGL and PS autoscaling tests. Added test for example in a dir that must be created. Removed code not used in docstring trim. --- kiplot/config_reader.py | 4 +-- tests/test_plot/test_hpgl.py | 14 +++++++++++ tests/test_plot/test_misc.py | 15 +++++++++--- tests/test_plot/test_ps.py | 2 +- tests/yaml_samples/hpgl.kiplot.yaml | 2 +- tests/yaml_samples/hpgl_auto.kiplot.yaml | 31 ++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 tests/yaml_samples/hpgl_auto.kiplot.yaml diff --git a/kiplot/config_reader.py b/kiplot/config_reader.py index 38edd1f7..7c4303bc 100644 --- a/kiplot/config_reader.py +++ b/kiplot/config_reader.py @@ -164,8 +164,8 @@ def trim(docstring): for line in lines[1:]: trimmed.append(line[indent:].rstrip()) # Strip off trailing and leading blank lines: - while trimmed and not trimmed[-1]: - trimmed.pop() + # while trimmed and not trimmed[-1]: + # trimmed.pop() while trimmed and not trimmed[0]: trimmed.pop(0) # Return a single string: diff --git a/tests/test_plot/test_hpgl.py b/tests/test_plot/test_hpgl.py index 5c742bf1..6fd9f5a2 100644 --- a/tests/test_plot/test_hpgl.py +++ b/tests/test_plot/test_hpgl.py @@ -30,3 +30,17 @@ def test_hpgl(): ctx.dont_expect_out_file(ctx.get_gerber_job_filename()) ctx.clean_up() + + +def test_hpgl_auto(): + prj = 'simple_2layer' + ctx = context.TestContext('HPGLAuto', prj, 'hpgl_auto', PS_DIR) + ctx.run() + + f_cu = ctx.get_gerber_filename('F_Cu', '.plt') + f_silk = ctx.get_gerber_filename('B_Silks', '.plt') + ctx.expect_out_file(f_cu) + ctx.expect_out_file(f_silk) + ctx.dont_expect_out_file(ctx.get_gerber_job_filename()) + + ctx.clean_up() diff --git a/tests/test_plot/test_misc.py b/tests/test_plot/test_misc.py index e372cd0f..a358a837 100644 --- a/tests/test_plot/test_misc.py +++ b/tests/test_plot/test_misc.py @@ -325,6 +325,13 @@ def test_help_output(): ctx.clean_up() +def test_help_output_unk(): + ctx = context.TestContext('HelpOutputUnk', '3Rs', 'pre_and_position', POS_DIR) + ctx.run(EXIT_BAD_ARGS, extra=['--help-output', 'bogus'], no_verbose=True, no_out_dir=True, no_yaml_file=True, no_board_file=True) + assert ctx.search_err('Unknown output type') + ctx.clean_up() + + def test_help_outputs(): ctx = context.TestContext('HelpOutputs', '3Rs', 'pre_and_position', POS_DIR) ctx.run(extra=['--help-outputs'], no_verbose=True, no_out_dir=True, no_yaml_file=True, no_board_file=True) @@ -379,9 +386,11 @@ def test_example_4(): def test_example_5(): """ Copy setting from PCB """ ctx = context.TestContext('Example5', 'good-project', 'pre_and_position', '') - ctx.run(extra=['--example', '-p'], no_verbose=True, no_yaml_file=True) - assert ctx.expect_out_file(EXAMPLE_CFG) - ctx.search_in_file(EXAMPLE_CFG, ['layers: selected', 'pen_width: 35.0']) + output_dir = os.path.join(ctx.output_dir, 'pp') + ctx.run(extra=['--example', '-p', '-d', output_dir], no_verbose=True, no_yaml_file=True, no_out_dir=True) + file = os.path.join('pp', EXAMPLE_CFG) + assert ctx.expect_out_file(file) + ctx.search_in_file(file, ['layers: selected', 'pen_width: 35.0']) ctx.clean_up() diff --git a/tests/test_plot/test_ps.py b/tests/test_plot/test_ps.py index b90bb8e3..8c42b7ec 100644 --- a/tests/test_plot/test_ps.py +++ b/tests/test_plot/test_ps.py @@ -34,7 +34,7 @@ def test_ps(): def test_ps_auto(): prj = 'simple_2layer' - ctx = context.TestContext('Postscript', prj, 'ps_auto', PS_DIR) + ctx = context.TestContext('PostscriptAuto', prj, 'ps_auto', PS_DIR) ctx.run() f_cu = ctx.get_gerber_filename('F_Cu', '.ps') diff --git a/tests/yaml_samples/hpgl.kiplot.yaml b/tests/yaml_samples/hpgl.kiplot.yaml index 13087bcd..cff28506 100644 --- a/tests/yaml_samples/hpgl.kiplot.yaml +++ b/tests/yaml_samples/hpgl.kiplot.yaml @@ -19,7 +19,7 @@ outputs: drill_marks: full mirror_plot: true sketch_plot: false - scaling: 0 # auto + scaling: 1 pen_number: 2 pen_speed: 50 pen_width: 0.5 diff --git a/tests/yaml_samples/hpgl_auto.kiplot.yaml b/tests/yaml_samples/hpgl_auto.kiplot.yaml new file mode 100644 index 00000000..13087bcd --- /dev/null +++ b/tests/yaml_samples/hpgl_auto.kiplot.yaml @@ -0,0 +1,31 @@ +kiplot: + version: 1 + +outputs: + - name: HPGL + comment: "HPGL files" + type: hpgl + dir: HPGL + options: + exclude_edge_layer: false + exclude_pads_from_silkscreen: false + plot_sheet_reference: false + plot_footprint_refs: true + plot_footprint_values: true + force_plot_invisible_refs_vals: false + tent_vias: true + + # HPGL options + drill_marks: full + mirror_plot: true + sketch_plot: false + scaling: 0 # auto + pen_number: 2 + pen_speed: 50 + pen_width: 0.5 + layers: + - layer: F.Cu + suffix: F_Cu + - layer: B.SilkS + suffix: B_Silks +