File: test_schema.py

package info (click to toggle)
osinfo-db 0.20250606-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,856 kB
  • sloc: python: 2,161; sh: 357; makefile: 94
file content (26 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.

import lxml.etree as ET
import pytest

from . import util


@pytest.fixture(scope="module")
def schema():
    schema = ET.RelaxNG(ET.parse(util.DataFiles.schema.open("r")))
    return schema


@pytest.mark.parametrize("path", util.DataFiles.xmls())
def test_schema(path, schema):
    if not schema.validate(ET.parse(path.open("r"))):
        # pylint: disable=no-member
        raise AssertionError(str(schema.error_log.last_error))


@pytest.mark.parametrize("path", util.SourceFiles.xmls(), ids=lambda p: p.name)
def test_translations_in_source_files(path):
    xml = ET.parse(path.open("r"))
    assert xml.xpath("//*[@xml:lang]") == []