-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
57 lines (43 loc) · 1.37 KB
/
noxfile.py
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
53
54
55
56
57
import os
import shutil
from pathlib import Path
import nox
def copy_and_overwrite(from_path, to_path):
if os.path.exists(to_path):
shutil.rmtree(to_path)
shutil.copytree(from_path, to_path)
to_exclude = [
"test_jitted.py",
"test_numpy_compatibility.py", # Pynajax has its own
"test_config.py",
"conftest.py",
]
# nox --no-venv -s linters
# nox --no-venv -s tests
@nox.session(name="linters")
def linters(session):
"""Run linters"""
session.run("ruff", "check", "src", "--ignore", "D")
@nox.session(name="tests")
def tests(session):
"""Run the test suite."""
nap_test_path = Path("../pynapple/tests")
path = Path("tests/")
# Copying test files
tocopy = os.listdir(nap_test_path)
tocopy = list(filter(lambda x: x[0:5] == "test_" and x not in to_exclude, tocopy))
for f in tocopy:
shutil.copy(nap_test_path.joinpath(f), path.joinpath(f))
# Copying nwbfiletest and npzfiletest
copy_and_overwrite(nap_test_path.joinpath("nwbfilestest"), path.joinpath("nwbfilestest"))
try:
session.run("pytest") # , "--pdb", "--pdbcls=IPython.terminal.debugger:Pdb")
finally:
# Remove files
for f in tocopy:
try:
os.remove(path.joinpath(f))
except OSError:
pass
# Remove folders
shutil.rmtree(path.joinpath("nwbfilestest"))