unit-test退出时恢复控制台代码页;python 加强 StrategyContext.__init__

This commit is contained in:
fasiondog 2021-02-17 20:04:29 +08:00
parent 2d392565e4
commit 88379f18a4
2 changed files with 20 additions and 1 deletions

View File

@ -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
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__

View File

@ -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
}