Skip to content

Commit 741dffd

Browse files
committed
feat(Lib/unittest): main
1 parent b2f29b1 commit 741dffd

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/pylib/Lib/unittest.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

2-
import ./unittest/case_py
3-
export case_py
2+
import ../private/trans_imp
3+
impExp unittest,
4+
case_py, main_impl
5+

src/pylib/Lib/unittest/main_impl.nim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import std/macros
3+
import std/macrocache
4+
import ./case_py/[
5+
types,
6+
]
7+
const TestCaseSubclasses = CacheSeq"TestCaseSubclasses"
8+
9+
macro init_subclass*[T: TestCase](cls: typedesc[T]) =
10+
TestCaseSubclasses.add cls
11+
12+
macro main*() =
13+
result = newStmtList()
14+
for c in TestCaseSubclasses:
15+
result.add newCall(
16+
newDotExpr(
17+
#ident("new" & c.strVal)
18+
newCall c
19+
,
20+
ident"run")
21+
)
22+
23+

0 commit comments

Comments
 (0)