-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathconftest.py
More file actions
39 lines (30 loc) · 1.08 KB
/
conftest.py
File metadata and controls
39 lines (30 loc) · 1.08 KB
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
"""Global configuration."""
import os
import inspect
import shutil
import pytest
import matlab2cpp
from matlab2cpp import collection
@pytest.fixture(scope="session")
def workspace_folder(tmpdir_factory):
"""Create a temporary folder to perform tests from."""
return str(tmpdir_factory.mktemp("workspace"))
@pytest.fixture(scope="function", autouse=True)
def workspace(workspace_folder, doctest_namespace):
"""Fill temporary folder for each test."""
# move data to workspace:
source = os.path.join(os.path.dirname(inspect.stack()[0][1]), "test", "data")
if os.path.isdir(workspace_folder):
shutil.rmtree(workspace_folder)
shutil.copytree(source, workspace_folder)
# add content to doctest namespace:
doctest_namespace["workspace"] = workspace_folder
doctest_namespace["matlab2cpp"] = matlab2cpp
doctest_namespace["collection"] = collection
# change to workspace:
curdir = os.path.abspath(os.path.curdir)
os.chdir(workspace_folder)
yield workspace_folder
# clean up:
os.chdir(curdir)
shutil.rmtree(workspace_folder)