|
16 | 16 | _T = TypeVar("_T")
|
17 | 17 |
|
18 | 18 |
|
19 |
| -def target_test( |
20 |
| - timeout_time=None, |
21 |
| - timeout_unit="step", |
22 |
| - expect_fail=False, |
23 |
| - expect_error=(), |
24 |
| - skip=False, |
25 |
| - stage=0, |
26 |
| -): |
| 19 | +class target_test(cocotb.test): |
27 | 20 | """
|
28 | 21 | Custom decorator wrapping cocotb.test to automatically skip test when its run without
|
29 | 22 | I3C target support configured.
|
30 | 23 | Has an effect only when test suite is executed within nox session.
|
31 | 24 | """
|
32 |
| - if os.getenv("NOX_SESSION", False): |
33 |
| - skip = any([skip, "TargetSupport" not in cocotb.plusargs]) |
34 |
| - |
35 |
| - def wrapper(func): |
36 |
| - @cocotb.test( |
37 |
| - timeout_time=timeout_time, |
38 |
| - timeout_unit=timeout_unit, |
39 |
| - expect_fail=expect_fail, |
40 |
| - expect_error=expect_error, |
41 |
| - skip=skip, |
42 |
| - stage=stage, |
| 25 | + def __init__( |
| 26 | + self, |
| 27 | + f, |
| 28 | + timeout_time=None, |
| 29 | + timeout_unit="step", |
| 30 | + expect_fail=False, |
| 31 | + expect_error=(), |
| 32 | + skip=False, |
| 33 | + stage=0, |
| 34 | + ): |
| 35 | + if os.getenv("NOX_SESSION", False): |
| 36 | + skip = any([skip, "TargetSupport" not in cocotb.plusargs]) |
| 37 | + |
| 38 | + super().__init__( |
| 39 | + f, |
| 40 | + timeout_time, |
| 41 | + timeout_unit, |
| 42 | + expect_fail, |
| 43 | + expect_error, |
| 44 | + skip, |
| 45 | + stage |
43 | 46 | )
|
44 |
| - @functools.wraps(func) |
45 |
| - async def run(*args, **kwargs): |
46 |
| - await func(*args, **kwargs) |
47 |
| - |
48 |
| - return run |
49 |
| - |
50 |
| - return wrapper |
51 | 47 |
|
52 | 48 |
|
53 |
| -def controller_test( |
54 |
| - timeout_time=None, |
55 |
| - timeout_unit="step", |
56 |
| - expect_fail=False, |
57 |
| - expect_error=(), |
58 |
| - skip=False, |
59 |
| - stage=0, |
60 |
| -): |
| 49 | +class controller_test(cocotb.test): |
61 | 50 | """
|
62 | 51 | Custom decorator wrapping cocotb.test to automatically skip test when its run without
|
63 | 52 | I3C controller support configured.
|
64 | 53 | Has an effect only when test suite is executed within nox session.
|
65 | 54 | """
|
66 |
| - if os.getenv("NOX_SESSION", False): |
67 |
| - skip = any([skip, "ControllerSupport" not in cocotb.plusargs]) |
68 |
| - |
69 |
| - def wrapper(func): |
70 |
| - @cocotb.test( |
71 |
| - timeout_time=timeout_time, |
72 |
| - timeout_unit=timeout_unit, |
73 |
| - expect_fail=expect_fail, |
74 |
| - expect_error=expect_error, |
75 |
| - skip=skip, |
76 |
| - stage=stage, |
| 55 | + def __init__( |
| 56 | + self, |
| 57 | + f, |
| 58 | + timeout_time=None, |
| 59 | + timeout_unit="step", |
| 60 | + expect_fail=False, |
| 61 | + expect_error=(), |
| 62 | + skip=False, |
| 63 | + stage=0, |
| 64 | + ): |
| 65 | + if os.getenv("NOX_SESSION", False): |
| 66 | + skip = any([skip, "ControllerSupport" not in cocotb.plusargs]) |
| 67 | + |
| 68 | + super().__init__( |
| 69 | + f, |
| 70 | + timeout_time, |
| 71 | + timeout_unit, |
| 72 | + expect_fail, |
| 73 | + expect_error, |
| 74 | + skip, |
| 75 | + stage |
77 | 76 | )
|
78 |
| - @functools.wraps(func) |
79 |
| - async def run(*args, **kwargs): |
80 |
| - await func(*args, **kwargs) |
81 |
| - |
82 |
| - return run |
83 |
| - |
84 |
| - return wrapper |
85 | 77 |
|
86 | 78 |
|
87 | 79 | def get_current_time_ns():
|
|
0 commit comments