From 84e8477b90a03ad5137450913fe39b1ccf7fa799 Mon Sep 17 00:00:00 2001 From: cooldome Date: Tue, 28 Jan 2020 14:16:03 +0000 Subject: [PATCH] unittest add resetOutputFormatters proc (#13267) * add resetOutputFormatters * remove space * resolve comments --- changelog.md | 2 +- lib/pure/unittest.nim | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 8fac8dab6898d..3e498e7f83951 100644 --- a/changelog.md +++ b/changelog.md @@ -52,8 +52,8 @@ This simplifies code by reducing need for if-else branches around intermediate maybe nil values. Eg: `echo ?.n.typ.kind` - Added `minIndex` and `maxIndex` to the `sequtils` module - - Added `os.isRelativeTo` to tell whether a path is relative to another +- Added `resetOutputFormatters` to `unittest` ## Library changes diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index c3e3a8876be37..c50ef0b1b5a09 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -96,6 +96,8 @@ import macros, strutils, streams, times, sets, sequtils +include "system/inclrtl" + when declared(stdout): import os @@ -186,6 +188,9 @@ proc delOutputFormatter*(formatter: OutputFormatter) = keepIf(formatters, proc (x: OutputFormatter): bool = x != formatter) +proc resetOutputFormatters* {.since: (1, 1).} = + formatters = @[] + proc newConsoleOutputFormatter*(outputLevel: OutputLevel = OutputLevel.PRINT_ALL, colorOutput = true): ConsoleOutputFormatter = ConsoleOutputFormatter(