1################################################################ 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19"""The extended save modes must not get worse: the error kinds against the ODF 1.2 and 1.3 schemas (and the same with foreign 20content removed) are compared with data/baseline/. Regenerate the baseline with --write-kinds after a change that is meant to 21change them, and read the diff of data/baseline/ before committing it.""" 22import pytest 23 24from aootest import documents, kinds 25 26pytestmark = pytest.mark.slow 27 28 29@pytest.mark.parametrize("mode,version", kinds.PAIRS) 30def test_error_kinds_do_not_get_worse(odf_runs, need_mode, pytestconfig, mode, version): 31 need_mode(mode) 32 sources = kinds.stable(documents.from_config(pytestconfig)) 33 run = odf_runs(mode) 34 saved = run.saved() 35 val = run.validation()["val"] 36 if val is None: 37 pytest.skip("needs java, jing and the ODF schemas (python -m aootest.fetch)") 38 covered = {documents.out_name(s) for s in sources if saved[s.id]["out"]} 39 now = kinds.kinds_of(val, version, covered) 40 if pytestconfig.getoption("--write-kinds"): 41 unsaved = [s.id for s in sources if not saved[s.id]["out"]] 42 kinds.write(mode, version, covered, now) 43 pytest.skip("baseline written: %s%s" % (kinds.path(mode, version).name, "; not saved, so not in it: " + ", ".join(unsaved) if unsaved else "")) 44 base = kinds.load(mode, version) 45 if base is None: 46 pytest.skip("no baseline for %s against ODF %s.%s (python3 -m pytest tests/odf/test_kinds.py --write-kinds)" % (mode, version[0], version[1:])) 47 lines, bad = kinds.judge(base, covered, now) 48 assert not bad, "\n".join(lines) 49