xref: /trunk/test/aoo-test/tests/odf/conftest.py (revision 2cb6d6f119bbe2f78742f1c5c8538cb0d4e72ede)
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
20"""Parameters shared by the tests that run over the source documents."""
21import pytest
22
23from aootest import documents
24
25PLACEHOLDER = documents.Source("(no office)", None, "odt", None)
26
27
28def pytest_generate_tests(metafunc):
29    """The documents depend on the office named on the command line, so `source` is parametrized here. Without an office there
30    is one placeholder, and the office fixtures skip it with the reason."""
31    if "source" in metafunc.fixturenames:
32        found = documents.from_config(metafunc.config) or [PLACEHOLDER]
33        metafunc.parametrize("source", found, ids=[s.id for s in found])
34
35
36@pytest.fixture
37def saved(odf_runs, need_mode):
38    """saved(mode, source) -> (ModeRun, result of saving `source` in `mode`); skips when the build lacks the mode."""
39    def get(mode, source):
40        need_mode(mode)
41        run = odf_runs(mode)
42        return run, run.saved()[source.id]
43    return get
44