Ejemplo n.º 1
0
def test_kicad_conf_no_instance():
    """ Check we can't create a KiConf instance """
    with context.cover_it(cov):
        with pytest.raises(AssertionError) as pytest_wrapped_e:
            o = KiConf()  # noqa: F841
    assert pytest_wrapped_e.type == AssertionError
    assert str(pytest_wrapped_e.value
               ) == 'KiConf is fully static, no instances allowed'
Ejemplo n.º 2
0
def test_kicad_conf_local_conf(caplog, monkeypatch):
    """ Test if we can use the 'posix_user' """
    global _real_posix_prefix
    _real_posix_prefix = sysconfig.get_path('data', 'posix_prefix')
    with monkeypatch.context() as m:
        m.setattr("sysconfig.get_path", mocked_get_path_1)
        with context.cover_it(cov):
            assert KiConf.guess_symbol_dir() == '/usr/share/kicad/library'
Ejemplo n.º 3
0
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()  # noqa: F841
    cov.stop()
    cov.save()
    assert pytest_wrapped_e.type == AssertionError
    assert str(pytest_wrapped_e.value) == 'KiConf is fully static, no instances allowed'
def check_load_conf(caplog,
                    dir='kicad',
                    fail=False,
                    catch_conf_error=False,
                    no_conf_path=False):
    caplog.set_level(logging.DEBUG)
    kiconf_de_init()
    import pcbnew
    GS.kicad_conf_path = None if no_conf_path else pcbnew.GetKicadConfigPath()
    cov.load()
    cov.start()
    if catch_conf_error:
        with pytest.raises(KiConfError) as err:
            KiConf.init(
                os.path.join(context.BOARDS_DIR, 'v5_errors/kibom-test.sch'))
    else:
        KiConf.init(
            os.path.join(context.BOARDS_DIR, 'v5_errors/kibom-test.sch'))
        # Check we can call it again and nothing is done
        KiConf.init('bogus')
        err = None
    cov.stop()
    cov.save()
    ref = 'Reading KiCad config from `tests/data/' + dir + '/kicad_common`'
    if fail:
        ref = 'Unable to find KiCad configuration file'
    assert ref in caplog.text, caplog.text
    return err