File: plugin_import.py

package info (click to toggle)
bst-external 0.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 656 kB
  • sloc: python: 3,943; makefile: 53
file content (31 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (2)
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
import os
import pytest
import shutil

@pytest.fixture()
def plugin_import(datafiles):
    project = str(datafiles)
    owndir = os.path.dirname(os.path.realpath(__file__))
    topdir = os.path.realpath(os.path.join(owndir, "..", ".."))
    plugins_dir = os.path.join(project, "plugins")
    elements_src = os.path.join(topdir, "bst_external", "elements")
    elements_dst = os.path.join(plugins_dir, "elements")
    sources_src = os.path.join(topdir, "bst_external", "sources")
    sources_dst = os.path.join(plugins_dir, "sources")
    os.makedirs(elements_dst, exist_ok=True)
    for f in os.listdir(elements_src):
        if f != "__init__.py" and (f.endswith(".py") or f.endswith(".yaml")):
            fsrc = os.path.join(elements_src, f)
            fdst = os.path.join(elements_dst ,f)
            shutil.copyfile(fsrc, fdst)

    os.makedirs(sources_dst, exist_ok=True)
    for f in os.listdir(sources_src):
        if f != "__init__.py" and (f.endswith(".py") or f.endswith(".yaml")):
            fsrc = os.path.join(sources_src, f)
            fdst = os.path.join(sources_dst ,f)
            shutil.copyfile(fsrc, fdst)

    yield plugins_dir

    shutil.rmtree(plugins_dir)