Fixed tests that now needs to initialize global defaults.

This commit is contained in:
Salvador E. Tropea 2021-12-01 15:55:38 -03:00
parent c34ba533e6
commit 130f7b25a3
2 changed files with 12 additions and 1 deletions

View File

@ -26,7 +26,7 @@ from kibot.bom.columnlist import ColumnList
from kibot.bom.units import get_prefix
from kibot.__main__ import detect_kicad
from kibot.kicad.config import KiConf
from kibot.globals import Globals
cov = coverage.Coverage()
mocked_check_output_FNF = True
@ -63,10 +63,17 @@ def patch_functions(m):
m.setattr('kibot.kiplot.exec_with_retry', mocked_call)
def init_globals():
glb = Globals()
glb.set_tree({})
glb.config(None)
def run_compress(ctx, test_import_fail=False):
with context.cover_it(cov):
# Load the plug-ins
load_actions()
init_globals()
# Create a compress object with the dummy file as source
out = RegOutput.get_class_for('compress')()
out.set_tree({'options': {'format': 'RAR', 'files': [{'source': ctx.get_out_path('*')}]}})

View File

@ -19,6 +19,7 @@ if prev_dir not in sys.path:
sys.path.insert(0, prev_dir)
from kibot.misc import (PDF_SCH_PRINT, SVG_SCH_PRINT)
from kibot.kicad.v5_sch import Schematic, SchFileError, DrawPoligon, Pin
from kibot.globals import Globals
# Utils import
from utils import context
@ -65,6 +66,9 @@ def check_l1(ctx):
ctx.run()
o_name = os.path.join(NI_DIR, 'test_v5.sch')
ctx.expect_out_file(o_name)
glb = Globals()
glb.set_tree({})
glb.config(None)
sch = Schematic()
try:
sch.load(ctx.get_out_path(o_name), 'no_project')