mirror of
https://github.com/logos-storage/asynctest.git
synced 2026-01-04 05:53:10 +00:00
Fix BareExcept warnings when using stdlib unittest with chronos v4
This commit is contained in:
parent
17fb5ab4b7
commit
7bcc20b93f
@ -4,7 +4,14 @@ import pkg/chronos/config
|
|||||||
when compiles(config.chronosHandleException): # detect chronos v4
|
when compiles(config.chronosHandleException): # detect chronos v4
|
||||||
|
|
||||||
template runAsync*(body): untyped =
|
template runAsync*(body): untyped =
|
||||||
let asyncProc = proc {.async: (raises: [Exception]).} = body
|
# The unittest module from stdlib can still raise a bare Exception,
|
||||||
|
# so we allow chronos to convert it to an AsyncExceptionError, and
|
||||||
|
# we disable the ensuing BareExcept warning.
|
||||||
|
{.push warning[BareExcept]:off.}
|
||||||
|
let asyncProc =
|
||||||
|
proc {.async: (handleException: true, raises: [AsyncExceptionError]).} =
|
||||||
|
body
|
||||||
|
{.pop.}
|
||||||
waitFor asyncProc()
|
waitFor asyncProc()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user