Added test for no KiConf instances and loading config from env
Also moved the KiCad config tests to a separated file.
This commit is contained in:
parent
487021357b
commit
d277bbbc0b
|
|
@ -0,0 +1,22 @@
|
|||
UseIconsInMenus=1
|
||||
IconScale=-1
|
||||
MousewheelPAN=0
|
||||
ZoomNoCenter=0
|
||||
AutoPAN=1
|
||||
OpenGLAntialiasingMode=2
|
||||
CairoAntialiasingMode=0
|
||||
WorkingDir=/home/salvador/0Data/Eccosur/kiplot.INTI-CMNB
|
||||
ShowEnvVarWarningDialog=1
|
||||
AutoSaveInterval=600
|
||||
FileHistorySize=9
|
||||
CanvasScale=0
|
||||
Editor=
|
||||
PdfBrowserName=
|
||||
UseSystemBrowser=1
|
||||
[EnvironmentVariables]
|
||||
KICAD_SYMBOL_DIR=/usr/share/kicad/library
|
||||
KICAD_TEMPLATE_DIR=/usr/share/kicad/template
|
||||
KICAD_USER_TEMPLATE_DIR=/home/salvador/kicad/template
|
||||
KIGITHUB=https://github.com/KiCad
|
||||
KISYS3DMOD=/usr/share/kicad/modules/packages3d/
|
||||
KISYSMOD=/usr/share/kicad/modules
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
"""
|
||||
Tests for KiCad configuration load
|
||||
|
||||
|
||||
For debug information use:
|
||||
pytest-3 --log-cli-level debug
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pytest
|
||||
import coverage
|
||||
import logging
|
||||
# Look for the 'utils' module from where the script is running
|
||||
prev_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, os.path.dirname(prev_dir))
|
||||
# Utils import
|
||||
from utils import context
|
||||
sys.path.insert(0, os.path.dirname(prev_dir))
|
||||
from kiplot.misc import EXIT_BAD_CONFIG
|
||||
from kiplot.kicad.config import KiConf
|
||||
|
||||
|
||||
cov = coverage.Coverage()
|
||||
|
||||
|
||||
def test_kicad_conf_bad_sym_lib_table():
|
||||
""" Check various problems in the sym-lib-table file """
|
||||
sch = 'sym-lib-table_errors/kibom-test'
|
||||
test = 'test_kicad_conf_bad_sym_lib_table'
|
||||
ctx = context.TestContextSCH(test, sch, 'int_bom_simple_csv', None)
|
||||
ctx.run(EXIT_BAD_CONFIG, extra_debug=True)
|
||||
ctx.search_err('Malformed lib entry')
|
||||
ctx.search_err(r'Unable to expand .?BOGUS.? in')
|
||||
ctx.search_err(r'unnamed LibAlias')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_kicad_conf_no_instance():
|
||||
""" Check we can't create a KiConf instance """
|
||||
cov.load()
|
||||
cov.start()
|
||||
with pytest.raises(AssertionError) as pytest_wrapped_e:
|
||||
o = KiConf()
|
||||
cov.stop()
|
||||
cov.save()
|
||||
assert pytest_wrapped_e.type == AssertionError
|
||||
assert str(pytest_wrapped_e.value) == 'KiConf is fully static, no instances allowed'
|
||||
|
||||
|
||||
def test_kicad_conf_user(caplog):
|
||||
""" Check we can load the KiCad configuration from $KICAD_CONFIG_HOME """
|
||||
ctx = context.TestContextSCH('test_kicad_conf_user', 'v5_errors/kibom-test', 'int_bom_simple_csv', None)
|
||||
os.environ['KICAD_CONFIG_HOME'] = 'tests/data/kicad_1'
|
||||
cov.load()
|
||||
cov.start()
|
||||
KiConf.init(ctx.sch_file)
|
||||
cov.stop()
|
||||
cov.save()
|
||||
assert 'Reading KiCad config from `tests/data/kicad_1/kicad_common`' in caplog.text
|
||||
|
|
@ -14,7 +14,7 @@ sys.path.insert(0, os.path.dirname(prev_dir))
|
|||
# Utils import
|
||||
from utils import context
|
||||
sys.path.insert(0, os.path.dirname(prev_dir))
|
||||
from kiplot.misc import CORRUPTED_SCH, EXIT_BAD_CONFIG
|
||||
from kiplot.misc import CORRUPTED_SCH
|
||||
|
||||
|
||||
def setup_ctx(test, error):
|
||||
|
|
@ -245,14 +245,3 @@ def test_sch_errors_bad_snum():
|
|||
|
||||
def test_sch_errors_bad_tbentry():
|
||||
setup_ctx('bad_tbentry', 'Wrong entry in title block')
|
||||
|
||||
|
||||
def test_sch_errors_bad_sym_lib_table():
|
||||
sch = 'sym-lib-table_errors/kibom-test'
|
||||
test = 'test_sch_errors_bad_sym_lib_table'
|
||||
ctx = context.TestContextSCH(test, sch, 'int_bom_simple_csv', None)
|
||||
ctx.run(EXIT_BAD_CONFIG, extra_debug=True)
|
||||
ctx.search_err('Malformed lib entry')
|
||||
ctx.search_err(r'Unable to expand .?BOGUS.? in')
|
||||
ctx.search_err(r'unnamed LibAlias')
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
Loading…
Reference in New Issue