From 88379f18a457f4307b88d1329220cae4ed7ae489 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 17 Feb 2021 20:04:29 +0800 Subject: [PATCH] =?UTF-8?q?unit-test=E9=80=80=E5=87=BA=E6=97=B6=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E6=8E=A7=E5=88=B6=E5=8F=B0=E4=BB=A3=E7=A0=81=E9=A1=B5?= =?UTF-8?q?=EF=BC=9Bpython=20=E5=8A=A0=E5=BC=BA=20StrategyContext.=5F=5Fin?= =?UTF-8?q?it=5F=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu/extend.py | 16 +++++++++++++++- hikyuu_cpp/unit_test/hikyuu/test_main.cpp | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hikyuu/extend.py b/hikyuu/extend.py index e46c7235..100c21ad 100644 --- a/hikyuu/extend.py +++ b/hikyuu/extend.py @@ -446,4 +446,18 @@ def Parameter_to_dict(self): Parameter.__iter__ = Parameter_iter Parameter.keys = Parameter_keys Parameter.items = Parameter_items -Parameter.to_dict = Parameter_to_dict \ No newline at end of file +Parameter.to_dict = Parameter_to_dict + +# ------------------------------------------------------------------ +# 增强 StrategyContext +# ------------------------------------------------------------------ +__old_StrategyContext_init__ = StrategyContext.__init__ + + +def __new_StrategyContext_init__(self, stock_code_list=None): + __old_StrategyContext_init__(self) + if stock_code_list is not None: + self.stock_list = stock_code_list + + +StrategyContext.__init__ = __new_StrategyContext_init__ \ No newline at end of file diff --git a/hikyuu_cpp/unit_test/hikyuu/test_main.cpp b/hikyuu_cpp/unit_test/hikyuu/test_main.cpp index 421eae8b..eacabacd 100644 --- a/hikyuu_cpp/unit_test/hikyuu/test_main.cpp +++ b/hikyuu_cpp/unit_test/hikyuu/test_main.cpp @@ -53,6 +53,7 @@ void init_hikyuu_test() { int main(int argc, char** argv) { #if defined(_WIN32) // Windows 下设置控制台程序输出代码页为 UTF8 + auto old_cp = GetConsoleOutputCP(); SetConsoleOutputCP(CP_UTF8); #endif @@ -86,5 +87,9 @@ int main(int argc, char** argv) { int client_stuff_return_code = 0; // your program - if the testing framework is integrated in your production code +#if defined(_WIN32) + SetConsoleOutputCP(old_cp); +#endif + return res + client_stuff_return_code; // the result from doctest is propagated here as well } \ No newline at end of file