forked from lucasrla/remarks
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_support.py
41 lines (29 loc) · 1.14 KB
/
test_support.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
import functools
import remarks
def run_once(func):
"""Decorator to run a function only once."""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not wrapper.has_run:
wrapper.has_run = True
return func(*args, **kwargs)
wrapper.has_run = False
return wrapper
def with_remarks(input_name):
"""Decorator to run remarks for a specific input directory."""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
input_dir = input_name
output_dir = "tests/out"
# Run remarks if it hasn't been run for this input directory
if not getattr(with_remarks, f"run_{input_name}", False):
remarks.run_remarks(input_dir, output_dir)
setattr(with_remarks, f"run_{input_name}", True)
return func(*args, **kwargs)
return wrapper
return decorator
class DevelopmentEnvironmentSetupException(Exception):
"""Custom exception related to development environment not being set-up correctly.
Please refer to the project documentation for more information."""
pass