Пример #1
0
def test_exceptions():
    invalid_fomod = "<boopity/>"
    with pytest.raises(TagNotFound):
        lxml.etree.fromstring(invalid_fomod, parser=module_parser)

    with pytest.raises(ParserError):
        import_(os.path.join(os.path.dirname(__file__), "data", "invalid_fomod"))

    with pytest.raises(BaseInstanceException):
        _NodeElement()

    with pytest.raises(BaseInstanceException):
        _PropertyBase("test", [])

    assert (None, None) == import_(os.path.join(os.path.dirname(__file__), "data", "incomplete_fomod"))
    assert (None, None) == import_(os.path.join(os.path.dirname(__file__), "boop"))
Пример #2
0
def test_exceptions():
    invalid_fomod = "<boopity/>"
    with pytest.raises(TagNotFound):
        lxml.etree.fromstring(invalid_fomod, parser=module_parser)

    with pytest.raises(ParserError):
        import_(
            os.path.join(os.path.dirname(__file__), "data", "invalid_fomod"))

    with pytest.raises(BaseInstanceException):
        _NodeElement()

    with pytest.raises(BaseInstanceException):
        _PropertyBase("test", [])

    assert (None, None) == import_(
        os.path.join(os.path.dirname(__file__), "data", "incomplete_fomod"))
    assert (None,
            None) == import_(os.path.join(os.path.dirname(__file__), "boop"))
Пример #3
0
def test_import_export(tmpdir):
    tmpdir = str(tmpdir)

    info_root, config_root = import_(
        os.path.join(os.path.dirname(__file__), "data", "valid_fomod"))
    info_root.sort()
    config_root.sort()
    export(info_root, config_root, tmpdir)

    with open(
            os.path.join(os.path.dirname(__file__), "data", "valid_fomod",
                         "fomod", "Info.xml")) as info_base:
        with open(os.path.join(tmpdir, "fomod", "Info.xml")) as info_exported:
            assert info_base.read() == info_exported.read()
    with open(
            os.path.join(os.path.dirname(__file__), "data", "valid_fomod",
                         "fomod", "ModuleConfig.xml")) as config_base:
        with open(os.path.join(tmpdir, "fomod",
                               "ModuleConfig.xml")) as config_exported:
            assert config_base.read() == config_exported.read()
Пример #4
0
def test_import_export(tmpdir):
    tmpdir = str(tmpdir)

    info_root, config_root = import_(os.path.join(os.path.dirname(__file__), "data", "valid_fomod"))
    info_root.sort()
    config_root.sort()
    export(info_root, config_root, tmpdir)

    with open(os.path.join(os.path.dirname(__file__), "data", "valid_fomod", "fomod", "Info.xml")) as info_base:
        with open(os.path.join(tmpdir, "fomod", "Info.xml")) as info_exported:
            assert info_base.read() == info_exported.read()
    with open(
        os.path.join(
            os.path.dirname(__file__),
            "data",
            "valid_fomod",
            "fomod",
            "ModuleConfig.xml"
        )
    ) as config_base:
        with open(os.path.join(tmpdir, "fomod", "ModuleConfig.xml")) as config_exported:
            assert config_base.read() == config_exported.read()