File: conftest.py

package info (click to toggle)
inkscape-textext 1.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,836 kB
  • sloc: python: 3,471; sh: 26; makefile: 25
file content (52 lines) | stat: -rw-r--r-- 2,164 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
This file is part of TexText, an extension for the vector
illustration program Inkscape.

Copyright (c) 2006-2025 TexText developers.

TexText is released under the 3-Clause BSD license. See
file LICENSE.txt or go to https://github.com/textext/textext
for full license details.
"""
import glob
import os

# List of specific test cases to be run, e.g. ["07", "08"].
# To run all tests set to empty list []
SPECIFIC_TESTS = []


def pytest_generate_tests(metafunc):
    if (
            "root" in metafunc.fixturenames and
            "inkscape_version" in metafunc.fixturenames and
            "textext_version" in metafunc.fixturenames and
            "converter" in metafunc.fixturenames and
            "test_case" in metafunc.fixturenames):
        path_to_snippets = "snippets"
        inkscape_versions = glob.glob(os.path.join(path_to_snippets, "inkscape-*.*"))

        args = []
        ids = []
        for inkscape_version in inkscape_versions:
            for folder, _, files in os.walk(inkscape_version):
                test_case = os.path.basename(folder)
                if len(SPECIFIC_TESTS) == 0 or test_case in SPECIFIC_TESTS:
                    if "config.json" in files and \
                            "original.svg" in files and \
                            "modified.svg" in files:
                        textext_version = os.path.dirname(os.path.dirname(folder))
                        converter = os.path.dirname(folder)
                        args.append([path_to_snippets,
                                     os.path.basename(inkscape_version),
                                     os.path.basename(textext_version),
                                     os.path.basename(converter),
                                     test_case
                                     ])
                        ids.append(os.path.relpath(folder, path_to_snippets))

        assert (len(ids) > 0), "No valid test case(s) defined"

        args_with_ids = sorted(list(zip(args,ids)))
        args, ids = zip(*args_with_ids)
        metafunc.parametrize(["root", "inkscape_version", "textext_version", "converter", "test_case"], args, ids=ids)