From 55c988bb661cee7420f0bb29616cc43322b2efcd Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 29 Jan 2021 12:15:46 -0300 Subject: [PATCH] Added test for KiCad < 5.1.6 --- tests/test_plot/fake_pcbnew/pcbnew.py | 2 ++ tests/test_plot/force_pcbnew_error.py | 12 +++++++++--- tests/test_plot/test_misc.py | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tests/test_plot/fake_pcbnew/pcbnew.py diff --git a/tests/test_plot/fake_pcbnew/pcbnew.py b/tests/test_plot/fake_pcbnew/pcbnew.py new file mode 100644 index 00000000..6df81030 --- /dev/null +++ b/tests/test_plot/fake_pcbnew/pcbnew.py @@ -0,0 +1,2 @@ +def GetKicadConfigPath(): + return 'bogus' diff --git a/tests/test_plot/force_pcbnew_error.py b/tests/test_plot/force_pcbnew_error.py index 52c80d8f..ce1d5ce4 100755 --- a/tests/test_plot/force_pcbnew_error.py +++ b/tests/test_plot/force_pcbnew_error.py @@ -2,11 +2,17 @@ import os import sys # Setup the path to load local kibot module -prev_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +cur_dir = os.path.dirname(os.path.abspath(__file__)) +prev_dir = os.path.dirname(os.path.dirname(cur_dir)) if prev_dir not in sys.path: sys.path.insert(0, prev_dir) -# Force the pcbnew module load to fail -sys.modules['pcbnew'] = None +if len(sys.argv) > 1 and sys.argv[1] == 'fake': + fake_dir = os.path.join(cur_dir, 'fake_pcbnew') + if fake_dir not in sys.path: + sys.path.insert(0, fake_dir) +else: + # Force the pcbnew module load to fail + sys.modules['pcbnew'] = None # Import the module to test from kibot.__main__ import detect_kicad detect_kicad() diff --git a/tests/test_plot/test_misc.py b/tests/test_plot/test_misc.py index feada409..e0864ae4 100644 --- a/tests/test_plot/test_misc.py +++ b/tests/test_plot/test_misc.py @@ -537,6 +537,13 @@ def test_no_pcbnew(): ctx.search_err('PYTHONPATH') +def test_old_pcbnew(): + ctx = context.TestContext('test_old_pcbnew', 'bom', 'bom', '') + cmd = [os.path.abspath(os.path.dirname(os.path.abspath(__file__))+'/force_pcbnew_error.py'), 'fake'] + ctx.do_run(cmd) + ctx.search_err('Unknown KiCad version, please install KiCad 5.1.6 or newer') + + def test_no_yaml(): ctx = context.TestContext('test_no_yaml', 'bom', 'bom', '') cmd = [os.path.abspath(os.path.dirname(os.path.abspath(__file__))+'/force_yaml_error.py')]