repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
tqdm
tests/tests_contrib.py
.py
""" Tests for `tqdm.contrib`. """ import pytest from tqdm import tqdm from tqdm.contrib import tenumerate, tmap, tzip from .tests_tqdm import StringIO, closing, importorskip def incr(x): """Dummy function""" return x + 1 @pytest.mark.parametrize("tqdm_kwargs", [{}, {"tqdm_class": tqdm}]) def test_enumerat...
62
1,930
tqdm
tests/tests_concurrent.py
.py
""" Tests for `tqdm.contrib.concurrent`. """ import sys from pytest import warns from tqdm.contrib.concurrent import interpreter_map, process_map, thread_map from .tests_tqdm import StringIO, TqdmWarning, closing, importorskip, mark, skip def incr(x): """Dummy function""" return x + 1 def test_thread_map...
112
3,528
tqdm
tests/tests_notebook.py
.py
from tqdm.notebook import tqdm as tqdm_notebook def test_notebook_disabled_description(): """Test that set_description works for disabled tqdm_notebook""" with tqdm_notebook(1, disable=True) as t: t.set_description("description")
8
248
tqdm
tests/tests_gui.py
.py
"""Test `tqdm.gui`.""" from .tests_tqdm import importorskip def test_gui_import(): """Test `tqdm.gui` import""" importorskip('tqdm.gui')
8
147
tqdm
tests/tests_utils.py
.py
from ast import literal_eval from collections import defaultdict from typing import Union # py<3.10 import pytest from tqdm.utils import envwrap def test_envwrap_deprecated(monkeypatch): """Test @envwrap (basic)""" monkeypatch.setenv('FUNC_A', "42") monkeypatch.setenv('FUNC_TyPe_HiNt', "1337") monk...
69
1,863
tqdm
tests/tests_version.py
.py
"""Test `tqdm.__version__`.""" import re from ast import literal_eval def test_version(): """Test version string""" from tqdm import __version__ version_parts = re.split('[.-]', __version__) if __version__ != "UNKNOWN": assert 3 <= len(version_parts), "must have at least Major.minor.patch" ...
15
467
tqdm
tests/tests_dask.py
.py
from time import sleep from .tests_tqdm import importorskip, mark pytestmark = mark.slow def test_dask(capsys): """Test tqdm.dask.TqdmCallback""" ProgressBar = importorskip('tqdm.dask').TqdmCallback dask = importorskip('dask') schedule = [dask.delayed(sleep)(i / 10) for i in range(5)] with Prog...
19
467
tqdm
tests/tests_perf.py
.py
import sys from contextlib import contextmanager from functools import wraps from time import sleep, time # Use relative/cpu timer to have reliable timings when there is a sudden load try: from time import process_time except ImportError: from time import clock process_time = clock from tqdm import tqdm, ...
316
9,308
tqdm
tests/tests_rlock.py
.py
from .tests_tqdm import StringIO, closing, importorskip, mark, skip @mark.slow def test_rlock_creation(): """Test that importing tqdm does not create multiprocessing objects.""" mp = importorskip('multiprocessing') if not hasattr(mp, 'get_context'): skip("missing multiprocessing.get_context") ...
39
1,520
tqdm
tests/tests_synchronisation.py
.py
import atexit from functools import wraps from threading import Event, RLock, Thread, current_thread from time import sleep, time from tqdm import TMonitor, tqdm, trange from .tests_tqdm import StringIO, closing, importorskip, patch_lock, skip class Time: """Fake time class providing an offset""" offset = 0...
291
10,066
tqdm
tests/tests_main.py
.py
"""Test CLI usage.""" import logging import subprocess # nosec import sys from functools import wraps from os import linesep from tqdm.cli import TqdmKeyError, TqdmTypeError, main from tqdm.utils import IS_WIN from .tests_tqdm import BytesIO, closing, mark, raises def restore_sys(func): """Decorates `func(caps...
245
8,023
tqdm
tests/tests_keras.py
.py
from .tests_tqdm import importorskip, mark pytestmark = mark.slow @mark.filterwarnings("ignore:.*:DeprecationWarning") def test_keras(capsys): """Test tqdm.keras.TqdmCallback""" TqdmCallback = importorskip('tqdm.keras').TqdmCallback np = importorskip('numpy') try: import keras as K except...
92
2,573
tqdm
tests/tests_rich.py
.py
"""Test `tqdm.rich`.""" from pytest import importorskip, mark @mark.filterwarnings("ignore:rich is experimental/alpha:" "tqdm.std.TqdmExperimentalWarning") def test_rich_no_total(capsys): """Test `tqdm.rich` on an iterable without a length, e.g. a generator""" rich = importorskip('tqdm.ri...
33
912
tqdm
tests/tests_tqdm.py
.py
# Advice: use repr(our_file.read()) to print the full output of tqdm # (else '\r' will replace the previous lines and you'll see only the latest. import csv import os import re import sys from contextlib import contextmanager from functools import wraps from warnings import catch_warnings, simplefilter from pytest imp...
1,986
67,858
tqdm
tests/conftest.py
.py
"""Shared pytest config.""" import sys from pytest import fixture from tqdm import tqdm @fixture(autouse=True) def pretest_posttest(): """Fixture for all tests ensuring environment cleanup""" try: sys.setswitchinterval(1) except AttributeError: sys.setcheckinterval(100) # deprecated ...
28
739
tqdm
examples/coroutine_pipe.py
.py
""" Inserting `tqdm` as a "pipe" in a chain of coroutines. Not to be confused with `asyncio.coroutine`. """ from functools import wraps from tqdm.auto import tqdm def autonext(func): @wraps(func) def inner(*args, **kwargs): res = func(*args, **kwargs) next(res) return res return i...
70
1,256
tqdm
examples/parallel_bars.py
.py
from concurrent.futures import ThreadPoolExecutor from functools import partial from multiprocessing import Pool, RLock, freeze_support from random import random from threading import RLock as TRLock from time import sleep from tqdm.auto import tqdm, trange from tqdm.contrib.concurrent import process_map, thread_map ...
54
1,906
tqdm
examples/wrapping_generators.py
.py
import numpy as np from tqdm.contrib import tenumerate, tmap, tzip for _ in tenumerate(range(int(1e6)), desc="builtin enumerate"): pass for _ in tenumerate(np.random.random((999, 999)), desc="numpy.ndenumerate"): pass for _ in tzip(np.arange(1e6), np.arange(1e6) + 1, desc="builtin zip"): pass mapped = ...
16
428
tqdm
examples/7zx.py
.py
"""Usage: 7zx.py [--help | options] <zipfiles>... Options: -h, --help Print this help and exit -v, --version Print version and exit -c, --compressed Use compressed (instead of uncompressed) file sizes -s, --silent Do not print one row per zip file -y, --yes Assume yes to all queries (for ...
118
4,455
tqdm
examples/include_no_requirements.py
.py
# How to import tqdm in any frontend without enforcing it as a dependency try: from tqdm.auto import tqdm except ImportError: def tqdm(*args, **kwargs): if args: return args[0] return kwargs.get('iterable', None) __all__ = ['tqdm']
12
270
tqdm
examples/tqdm_requests.py
.py
"""An example of wrapping manual tqdm updates for `requests.get`. See also: tqdm_wget.py. Usage: tqdm_requests.py [options] Options: -h, --help Print this help message and exit -u URL, --url URL : string, optional The url to fetch. [default: https://cgi.cdcl.ml/matryoshka.zip] -o FILE, --output FILE ...
50
1,462
tqdm
examples/tqdm_wget.py
.py
"""An example of wrapping manual tqdm updates for `urllib` reporthook. See also: tqdm_requests.py. # `urllib.urlretrieve` documentation > If present, the hook function will be called once > on establishment of the network connection and once after each block read > thereafter. The hook will be passed three arguments; ...
111
3,543
tqdm
examples/redirect_print.py
.py
"""Redirecting writing If using a library that can print messages to the console, editing the library by replacing `print()` with `tqdm.write()` may not be desirable. In that case, redirecting `sys.stdout` to `tqdm.write()` is an option. To redirect `sys.stdout`, create a file-like class that will write any input st...
51
1,484
tqdm
examples/async_coroutines.py
.py
"""Asynchronous examples using `asyncio`, `async` and `await`.""" import asyncio from tqdm.asyncio import tqdm, trange def count(start=0, step=1): i = start while True: new_start = yield i if new_start is None: i += step else: i = new_start async def main(): ...
37
944
tqdm
examples/simple_examples.py
.py
""" # Simple tqdm examples and profiling # Benchmark for i in range(int(1e8)): pass # Basic demo import tqdm for i in tqdm.trange(int(1e8)): pass # Some decorations import tqdm for i in tqdm.trange(int(1e8), miniters=int(1e6), ascii=True, desc="cool", dynamic_ncols=True): pass # Nes...
65
1,352
TradingAgents-CN
main.py
.py
from tradingagents.graph.trading_graph import TradingAgentsGraph from tradingagents.default_config import DEFAULT_CONFIG # 导入日志模块 from tradingagents.utils.logging_manager import get_logger logger = get_logger('default') # Create a custom config config = DEFAULT_CONFIG.copy() config["llm_provider"] = "google" # Use ...
27
980
TradingAgents-CN
docs/LLM_ADAPTER_TEMPLATE.py
.py
""" LLM 适配器模板 - 适用于 OpenAI 兼容提供商 使用方式:复制本文件为 tradingagents/llm_adapters/{provider}_adapter.py, 并根据目标提供商修改 provider_name、base_url、API Key 环境变量等信息。 """ from typing import Any, Dict import os import logging from tradingagents.llm_adapters.openai_compatible_base import OpenAICompatibleBase logger = logging.getLogger(__...
46
1,511
TradingAgents-CN
tests/test_reports_fix.py
.py
#!/usr/bin/env python3 """ 测试reports和analysts字段修复 """ import requests import time import json from pymongo import MongoClient def test_reports_and_analysts_fix(): """测试reports和analysts字段修复""" print("🔍 测试reports和analysts字段修复") print("=" * 60) # API基础URL base_url = "http://localhost:8000" ...
191
7,228
TradingAgents-CN
tests/test_async_analysis.py
.py
#!/usr/bin/env python3 """ 测试新的异步分析实现 验证 BackgroundTasks + 内存状态管理 + WebSocket 的完整流程 """ import asyncio import aiohttp import websockets import json import time from datetime import datetime async def test_async_analysis(): """测试异步分析功能""" base_url = "http://localhost:8000" ws_url = "ws://localhost:800...
233
9,530
TradingAgents-CN
tests/test_dashscope_tool_call_fix.py
.py
#!/usr/bin/env python3 """ 测试DashScope工具调用失败检测和补救机制 这个脚本测试新闻分析师在DashScope模型不调用工具时的补救机制。 """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from datetime import datetime import logging # 设置日志 logging.basicConfig(level=logging.INFO, format='%(asctime)s | %(levelname)s | %(message)s')...
182
7,704
TradingAgents-CN
tests/test_decision_data.py
.py
#!/usr/bin/env python3 """ 测试decision数据是否正确保存和获取 """ import requests import json from datetime import datetime def test_decision_data(): """测试decision数据的完整流程""" base_url = "http://localhost:8000" # 登录获取token login_data = { "username": "admin", "password": "admin123" } ...
193
7,220
TradingAgents-CN
tests/test_real_estate_api.py
.py
#!/usr/bin/env python3 """ 测试房地产相关的API调用 """ import requests import json # 配置 BASE_URL = "http://localhost:8000" def test_real_estate_screening(): """测试房地产筛选""" print("🏠 测试房地产相关筛选") print("=" * 50) # 1. 获取访问令牌 print("\n1. 获取访问令牌...") auth_response = requests.post(f"{BASE_URL}/api/auth/l...
111
4,174
TradingAgents-CN
tests/test_analysis.py
.py
#!/usr/bin/env python3 """ 简化的分析测试脚本 用于验证TradingAgents核心功能是否正常工作 """ import os import sys from pathlib import Path from dotenv import load_dotenv # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv(project_root / ".env", override=True) def test_basic_im...
124
3,739
TradingAgents-CN
tests/analyze_akshare_data.py
.py
#!/usr/bin/env python3 """ 检查AKShare财务数据结构 """ import sys import os import logging # 设置日志级别 logging.basicConfig(level=logging.INFO, format='%(asctime)s | %(levelname)-8s | %(message)s') # 添加项目路径 sys.path.append(os.path.dirname(os.path.abspath(__file__))) from tradingagents.dataflows.akshare_utils import AKShareProv...
124
4,665
TradingAgents-CN
tests/test_sanitize_real_data.py
.py
""" 测试真实导出数据的脱敏功能 """ import json from app.services.database.backups import _sanitize_document def test_sanitize_real_export_file(): """测试对真实导出文件的脱敏""" # 读取真实导出文件 with open("install/database_export_config_2025-10-25.json", "r", encoding="utf-8") as f: export_data = json.load(f) # 对 data 部...
53
2,218
TradingAgents-CN
tests/test_final_verification.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 最终验证脚本:测试优化后的数据深度级别是否产生不同详细程度的基本面分析报告 """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from tradingagents.agents.utils.agent_utils import Toolkit import time def test_analysis_depth_differences(): """测试不同深度级别产生的报告差异""" pri...
140
5,077
TradingAgents-CN
tests/test_raw_data_display.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 原始数据显示测试脚本 直接调用底层数据接口,显示原始的财务数据 """ import sys import os import json from datetime import datetime, timedelta # 添加项目根目录到路径 sys.path.append(os.path.dirname(os.path.abspath(__file__))) def test_raw_data_display(): """测试并显示原始的基本面数据""" print("=" * 80) p...
156
5,539
TradingAgents-CN
tests/test_stock_codes.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 测试从通达信获取股票代码和名称 """ import pytest pytest.importorskip("enhanced_stock_list_fetcher") pytestmark = pytest.mark.integration from enhanced_stock_list_fetcher import enhanced_fetch_stock_list def test_get_stock_codes(): """ 测试获取股票代码和名称 """ print("=" * 60...
69
2,506
TradingAgents-CN
tests/test_system_simple.py
.py
#!/usr/bin/env python3 """ 简单的系统测试 - 验证配置和缓存系统 """ import sys import os from pathlib import Path def test_basic_system(): """测试基本系统功能""" print("🔧 TradingAgents 基本系统测试") print("=" * 40) # 1. 检查配置文件 print("\n📁 检查配置文件...") config_file = Path("config/database_config.json") if config_fil...
177
5,939
TradingAgents-CN
tests/test_signal_processor_fix.py
.py
#!/usr/bin/env python3 """ 测试SignalProcessor修复后的功能 """ import sys import os from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) from dotenv import load_dotenv load_dotenv(project_root / ".env", override=True) def test_signal_processor_currenc...
168
5,308
TradingAgents-CN
tests/test_industries_api.py
.py
#!/usr/bin/env python3 """ 测试新的行业API """ import requests import json # 配置 BASE_URL = "http://localhost:8000" def test_industries_api(): """测试行业API""" print("🧪 测试行业API") print("=" * 50) # 1. 获取访问令牌 print("\n1. 获取访问令牌...") auth_response = requests.post(f"{BASE_URL}/api/auth/login", json={...
100
3,146
TradingAgents-CN
tests/test_duplicate_progress_fix.py
.py
#!/usr/bin/env python3 """ 测试重复进度提示修复效果 验证分析师完成提示不会重复显示 """ import os import sys # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) def test_duplicate_prevention(): """测试重复提示防止机制""" print("🔧 测试重复提示防止机制") print("=" * 60) try: fro...
305
10,824
TradingAgents-CN
tests/simple_akshare_test.py
.py
#!/usr/bin/env python3 """ 简单的AKShare测试 验证修复后的导入是否正常 """ import sys import os # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) def test_basic_imports(): """测试基本导入""" print("🔍 测试基本导入") print("=" * 40) try: # 测试...
151
4,622
TradingAgents-CN
tests/test_tool_binding_fix.py
.py
#!/usr/bin/env python3 """ 测试统一新闻工具的LangChain绑定修复 """ from tradingagents.agents.utils.agent_utils import Toolkit from tradingagents.tools.unified_news_tool import create_unified_news_tool from langchain_core.utils.function_calling import convert_to_openai_tool def test_tool_binding(): """测试工具绑定是否修复""" print("...
66
2,206
TradingAgents-CN
tests/test_unified_fundamentals.py
.py
#!/usr/bin/env python3 """ 测试统一基本面分析工具 验证新的统一工具方案是否有效 """ import os import sys def test_unified_tool_directly(): """直接测试统一基本面分析工具""" print("🔧 直接测试统一基本面分析工具...") try: from tradingagents.agents.utils.agent_utils import Toolkit from tradingagents.default_config import DEFAULT_CONFIG ...
232
7,803
TradingAgents-CN
tests/test_db_requirements_fix.py
.py
#!/usr/bin/env python3 """ 测试数据库依赖包兼容性修复 验证requirements_db.txt的兼容性改进 """ import os import sys import subprocess import tempfile import shutil # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) def test_python_version_check(): """测试Pytho...
269
8,325
TradingAgents-CN
tests/test_akshare_hk.py
.py
""" 测试AKShare港股功能 """ import sys import os # 添加项目根目录到路径 project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) def test_akshare_hk_basic(): """测试AKShare港股基本功能""" print("🧪 测试AKShare港股基本功能...") try: from tradingagents.dataflows.akshare_utils import get_aksh...
210
7,207
TradingAgents-CN
tests/test_data_config_cli.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 测试数据目录配置CLI功能 Test Data Directory Configuration CLI Features """ import os import sys import tempfile import shutil from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) from tradingagents.config.confi...
161
6,510
TradingAgents-CN
tests/test_akshare_functionality.py
.py
#!/usr/bin/env python3 """ AKShare功能检查测试 检查当前分支中AKShare的可用性和功能完整性 """ import sys import os import traceback from typing import Dict, Any, List def test_akshare_import(): """测试AKShare库导入""" print("🔍 测试AKShare库导入...") try: import akshare as ak print(f"✅ AKShare导入成功,版本: {ak.__version__}") ...
336
11,272
TradingAgents-CN
tests/test_frontend_backend_integration.py
.py
#!/usr/bin/env python3 """ 测试前后端集成 验证任务提交和状态查询的完整流程 """ import requests import time import json def test_frontend_backend_integration(): """测试前后端集成""" base_url = "http://localhost:8000" print("🧪 测试前后端集成") print("=" * 40) # 1. 登录 print("🔐 登录中...") try: login_respons...
188
6,459
TradingAgents-CN
tests/test_baostock_quick.py
.py
#!/usr/bin/env python3 """ 快速测试BaoStock数据源 """ import sys import os # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) def test_baostock_import(): """测试BaoStock导入""" print("🔍 测试BaoStock导入...") try: import baostock as bs ...
158
4,847
TradingAgents-CN
tests/quick_akshare_check.py
.py
#!/usr/bin/env python3 """ 快速AKShare功能检查 """ def check_akshare_import(): """检查AKShare导入""" try: import akshare as ak print(f"✅ AKShare导入成功,版本: {ak.__version__}") return True except ImportError as e: print(f"❌ AKShare导入失败: {e}") print("💡 请安装AKShare: pip install aksha...
101
2,944
TradingAgents-CN
tests/test_fundamentals_debug.py
.py
#!/usr/bin/env python3 """ 调试基本面分析师的工具选择问题 """ import os import sys def test_fundamentals_analyst_directly(): """直接测试基本面分析师函数""" print("🔧 直接测试基本面分析师...") try: from tradingagents.agents.analysts.fundamentals_analyst import create_fundamentals_analyst from tradingagents.agents.utils.ag...
192
5,538
TradingAgents-CN
tests/test_timezone_fix.py
.py
#!/usr/bin/env python3 """ 测试时区修复 """ import asyncio import sys import os import datetime # 添加项目根目录到Python路径 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from app.core.database import init_db, get_mongo_db from app.services.operation_log_service import log_operation from app.models.operation_log im...
113
3,925
TradingAgents-CN
tests/test_dataframe_fix.py
.py
#!/usr/bin/env python3 """ 测试DataFrame Arrow转换修复 """ import sys import os from pathlib import Path from datetime import datetime # 添加项目根目录到路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) def test_safe_dataframe(): """测试安全DataFrame函数""" try: from web.components.ana...
209
6,334
TradingAgents-CN
tests/test_optimized_fundamentals_simple.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 简化测试:直接测试优化后的基本面分析数据获取逻辑 """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from datetime import datetime, timedelta def test_optimized_fundamentals_logic(): """直接测试优化后的基本面分析逻辑""" print("=" * 80) print("🧪 测试优化后的基本面分析数据获...
104
4,440
TradingAgents-CN
tests/test_finnhub_news_fix.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 测试Finnhub新闻数据路径修复 这个脚本用于验证: 1. 数据目录路径配置是否正确 2. 新闻数据文件路径是否存在 3. 错误处理是否正常工作 """ import os import sys from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) from tradingagents.dataflows.config impo...
188
5,986
TradingAgents-CN
tests/test_improved_hk_utils.py
.py
#!/usr/bin/env python3 """ 测试改进的港股工具 """ import os import sys # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) def test_improved_hk_provider(): """测试改进的港股提供器""" print("\n🇭🇰 测试改进的港股提供器") print("=" * 80) try: from tradingagents...
221
7,223
TradingAgents-CN
tests/verify_mongodb_data.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ MongoDB数据验证脚本 验证A股股票基础信息是否正确同步到MongoDB """ import os from typing import Dict, Any, List from datetime import datetime try: from pymongo import MongoClient MONGODB_AVAILABLE = True except ImportError: MONGODB_AVAILABLE = False print("❌ pymongo未安装,请运行: ...
196
5,942
TradingAgents-CN
tests/debug_deepseek_cost_issue.py
.py
#!/usr/bin/env python3 """ 调试DeepSeek成本计算问题 """ import os import sys from pathlib import Path from dotenv import load_dotenv # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv() def debug_config_manager(): """调试配置管理器""" print("🔧 调试配置管理器...
277
9,526
TradingAgents-CN
tests/test_redis_performance.py
.py
#!/usr/bin/env python3 """ Redis连接和性能测试脚本 """ import redis import time import statistics import argparse from concurrent.futures import ThreadPoolExecutor, as_completed import json class RedisPerformanceTester: """Redis性能测试器""" def __init__(self, host=None, port=None, password=None, db=None): # 从...
345
13,466
TradingAgents-CN
tests/test_web_config_page.py
.py
#!/usr/bin/env python3 """ 测试Web配置管理页面 """ import sys from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) def test_config_page_import(): """测试配置页面导入""" print("🧪 测试配置管理页面导入") print("=" * 50) try: from web.pages.con...
115
3,463
TradingAgents-CN
tests/test_stock_info_debug.py
.py
#!/usr/bin/env python3 """ 股票信息获取调试测试 专门诊断为什么某些股票显示"未知公司" """ import os import sys # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) def test_stock_code_normalization(): """测试股票代码标准化""" print("\n🔧 测试股票代码标准化") print("=" * 60) ...
249
8,042
TradingAgents-CN
tests/test_fix.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from web.utils.analysis_runner import run_stock_analysis def test_analysis_fix(): """测试基本面分析师修复是否有效""" try: # 运行股票分析 result = run_stock_analysis( stock_symbol='000001', analysis_date=1, analysts=['market', 'fund...
48
1,634
TradingAgents-CN
tests/test_real_volume_issue.py
.py
#!/usr/bin/env python3 """ 测试真实的volume映射问题 验证现有代码是否真的存在KeyError: 'volume'问题 """ import os import sys # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) # 加载.env文件 try: from dotenv import load_dotenv load_dotenv(os.path.join(project_r...
294
10,914
TradingAgents-CN
tests/test_akshare_debug.py
.py
#!/usr/bin/env python3 """ AKShare财务数据获取调试脚本 """ import sys import os import logging # 设置日志级别为DEBUG以查看详细信息 logging.basicConfig(level=logging.DEBUG, format='%(asctime)s | %(name)-20s | %(levelname)-8s | %(message)s') # 添加项目路径 sys.path.append(os.path.dirname(os.path.abspath(__file__))) from tradingagents.dataflows.ak...
76
2,442
TradingAgents-CN
tests/test_volume_mapping_issue.py
.py
#!/usr/bin/env python3 """ 测试现有代码中的volume映射问题 验证是否存在 KeyError: 'volume' 问题 """ import os import sys import pandas as pd import numpy as np # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) def test_tushare_adapter_volume_mapping(): """测...
310
11,394
TradingAgents-CN
tests/test_valuation_simple.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 简化的估值指标测试 """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from tradingagents.agents.utils.agent_utils import Toolkit from tradingagents.default_config import DEFAULT_CONFIG def test_valuation_simple(): """简化的估值指标测试""" pr...
53
1,596
TradingAgents-CN
tests/test_dashscope_agent_friendly.py
.py
#!/usr/bin/env python3 """ 阿里百炼工具调用测试 - Agent友好版本 专门为agent执行优化,避免闪退问题 """ import os import sys import time import traceback # 强制刷新输出 def flush_print(msg): """强制刷新输出""" print(msg) sys.stdout.flush() time.sleep(0.1) # 给agent时间捕获输出 def main(): """主测试函数""" flush_print("🔬 阿里百炼工具调用测试 - Agent友好版本"...
205
7,520
TradingAgents-CN
tests/test_cli_progress_display.py
.py
#!/usr/bin/env python3 """ 测试CLI进度显示效果 模拟分析流程,验证用户体验 """ import os import sys import time # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) def test_cli_ui_manager(): """测试CLI用户界面管理器""" print("🎨 测试CLI用户界面管理器") print("=" * 60) try: ...
282
9,319
TradingAgents-CN
tests/test_notification_removal.py
.py
#!/usr/bin/env python3 """ 验证通知功能移除 检查前端代码中是否还有通知相关的代码 """ import os import re def check_notification_code(): """检查前端代码中的通知相关代码""" print("=" * 60) print("🔍 检查通知功能移除情况") print("=" * 60) frontend_dir = "frontend/src" notification_patterns = [ r'showDesktopNotification', r'te...
199
6,784
TradingAgents-CN
tests/test_cache_optimization.py
.py
#!/usr/bin/env python3 """ 缓存优化功能测试 测试美股和A股数据的缓存策略和性能 """ import os import sys import time from datetime import datetime, timedelta # 添加项目根目录到路径 project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.insert(0, project_root) def test_cache_manager(): """测试缓存管理器基本功能""" print("🧪...
270
9,118
TradingAgents-CN
tests/test_valuation_check.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 测试估值指标计算结果 """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from tradingagents.agents.utils.agent_utils import Toolkit from tradingagents.default_config import DEFAULT_CONFIG def test_valuation_indicators(): """测试估值指标计算""" ...
56
1,566
TradingAgents-CN
tests/test_sync_history_fix.py
.py
#!/usr/bin/env python3 """ 测试同步历史修复 验证: 1. 每次同步创建新的历史记录 2. 时区显示正确 """ import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import asyncio import logging from datetime import datetime # 设置日志 logging.basicConfig( level=logging.INFO, format='%(asctime)s | %(levelname)...
216
8,148
TradingAgents-CN
tests/test_amount_fix.py
.py
""" 测试成交额单位修复 验证 Tushare 数据的成交额单位转换是否正确 """ import sys import os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import asyncio from app.database import get_mongo_db from tradingagents.dataflows.providers.china.tushare import get_tushare_provider async def test_amount_fix(): """测试成交额单位修复""" pri...
108
3,700
TradingAgents-CN
tests/test_env_compatibility.py
.py
#!/usr/bin/env python3 """ 测试.env文件兼容性 """ import sys import os from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) def test_env_loading(): """测试.env文件加载""" print("🧪 测试.env文件加载") print("=" * 50) try: from tradinga...
182
5,912
TradingAgents-CN
tests/test_stock_code_tracking.py
.py
#!/usr/bin/env python3 """ 股票代码追踪测试脚本 专门用于调试股票代码在基本面分析中的误判问题 """ import os import sys # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) def test_stock_code_tracking(): """测试股票代码在整个流程中的传递""" print("\n🔍 股票代码追踪测试") print("=" * 80) # 测试分众传...
121
4,124
TradingAgents-CN
tests/test_llm_tool_calling_comparison.py
.py
#!/usr/bin/env python3 """ 测试不同LLM模型在工具调用和技术分析方面的行为差异 """ import os import sys from pathlib import Path from dotenv import load_dotenv import json # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv() def test_deepseek_tool_calling(): """测试De...
271
9,492
TradingAgents-CN
tests/test_financial_data_validation.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 测试财务数据验证逻辑 验证毛利率、净利率、ROE、ROA 等指标的范围检查 """ import sys import os # 添加项目根目录到 Python 路径 sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from tradingagents.dataflows.optimized_china_data import OptimizedChinaDataFlow def test_financial...
106
3,114
TradingAgents-CN
tests/test_existing_results.py
.py
#!/usr/bin/env python3 """ 测试已有的分析结果 """ import requests import json from pymongo import MongoClient import os from dotenv import load_dotenv def get_existing_task_ids(): """从MongoDB获取已有的任务ID""" try: # 加载环境变量 load_dotenv() # 从环境变量获取MongoDB配置 mongodb_host = os.getenv("M...
218
8,063
TradingAgents-CN
tests/test_embedding_models.py
.py
#!/usr/bin/env python3 """ 测试不同嵌入模型的使用场景 """ import os import sys from pathlib import Path from dotenv import load_dotenv # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv(project_root / ".env", override=True) def test_embedding_selection(): """测试...
182
6,546
TradingAgents-CN
tests/test_gemini_simple.py
.py
#!/usr/bin/env python3 """ 简化的Gemini测试(禁用内存功能) """ import os import sys from pathlib import Path from dotenv import load_dotenv # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv(project_root / ".env", override=True) def test_gemini_simple_analysis(): ...
220
7,844
TradingAgents-CN
tests/test_full_fundamentals_flow.py
.py
#!/usr/bin/env python3 """ 完整基本面分析流程测试 """ import os import sys # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) def test_full_fundamentals_flow(): """测试完整的基本面分析流程""" print("\n🔍 完整基本面分析流程测试") print("=" * 80) # 测试分众传媒 002027 test_t...
137
5,169
TradingAgents-CN
tests/test_target_price.py
.py
#!/usr/bin/env python3 """ 测试优化后的目标价生成系统 """ import sys import os from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) def test_signal_processor(): """测试信号处理器的价格提取功能""" print("🧪 测试信号处理器价格提取功能...") try: from tradingagents.agen...
153
5,065
TradingAgents-CN
tests/test_asyncio_thread_pool_fix.py
.py
""" 测试异步事件循环在线程池中的修复 问题:在线程池中调用 asyncio.get_event_loop() 会抛出 RuntimeError 解决:使用 asyncio.new_event_loop() 创建新的事件循环 """ import asyncio import pytest from concurrent.futures import ThreadPoolExecutor from tradingagents.dataflows.data_source_manager import DataSourceManager def test_asyncio_in_thread_pool(): """测试在...
124
4,268
TradingAgents-CN
tests/test_ticker_symbol_handling.py
.py
import unittest from cli.utils import normalize_ticker_symbol class TickerSymbolHandlingTests(unittest.TestCase): def test_normalize_ticker_symbol_preserves_exchange_suffix(self): self.assertEqual(normalize_ticker_symbol(" cnc.to "), "CNC.TO") def test_normalize_ticker_symbol_keeps_hk_suffix_upperca...
19
591
TradingAgents-CN
tests/test_tool_removal.py
.py
#!/usr/bin/env python3 """ 测试旧工具移除 验证LLM只能调用统一工具 """ def test_available_tools(): """测试可用工具列表""" print("🔧 测试可用工具列表...") try: from tradingagents.agents.utils.agent_utils import Toolkit from tradingagents.default_config import DEFAULT_CONFIG # 创建工具包 config = DEFA...
232
7,671
TradingAgents-CN
tests/test_tradingagents_runtime_settings.py
.py
import os import pytest from fastapi import FastAPI from fastapi.testclient import TestClient # Routers from app.routers import config as config_router from app.routers.auth_db import get_current_user def _admin_user(): return {"id": "u1", "is_admin": True} @pytest.fixture() def app_client_config(): app = ...
74
2,493
TradingAgents-CN
tests/test_all_apis.py
.py
#!/usr/bin/env python3 """ 测试所有API密钥功能 包括Google API和Reddit API """ import os import sys from pathlib import Path from dotenv import load_dotenv # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv(project_root / ".env", override=True) def check_all_api_k...
216
6,816
TradingAgents-CN
tests/test_market_analyst_lookback.py
.py
#!/usr/bin/env python3 """ 测试脚本:验证 MARKET_ANALYST_LOOKBACK_DAYS 配置是否生效 功能: 1. 读取配置文件中的 MARKET_ANALYST_LOOKBACK_DAYS 值 2. 模拟市场分析师调用数据接口 3. 验证实际获取的数据天数是否符合配置 4. 输出详细的验证报告 使用方法: python scripts/validation/test_market_analyst_lookback.py """ import os import sys from datetime import datetime, timedelta # 添加项目根目录到路径 ...
262
8,992
TradingAgents-CN
tests/test_analysis_result.py
.py
#!/usr/bin/env python3 """ 测试分析结果数据结构 """ import requests import json from datetime import datetime def test_analysis_result(): """测试分析结果的数据结构""" base_url = "http://localhost:8000" # 登录获取token login_data = { "username": "admin", "password": "admin123" } response = requ...
177
6,753
TradingAgents-CN
tests/test_app_error_logging.py
.py
#!/usr/bin/env python3 """ 测试 app 目录的错误日志配置 验证 app/core/logging_config.py 中的错误日志处理器是否正确配置 """ import sys import logging from pathlib import Path # 添加项目根目录到 Python 路径 sys.path.insert(0, str(Path(__file__).parent.parent)) from app.core.logging_config import setup_logging def test_error_logging_toml_config(): """...
187
6,332
TradingAgents-CN
tests/test_mongodb_save.py
.py
#!/usr/bin/env python3 """ 测试MongoDB保存功能 """ import requests import time import json from pymongo import MongoClient def check_mongodb_before_after(): """检查MongoDB保存前后的数据""" print("🔍 测试MongoDB保存功能") print("=" * 60) # 连接MongoDB try: client = MongoClient('mongodb://localhost:27017/') ...
164
5,616
TradingAgents-CN
tests/test_mongodb_connection.py
.py
#!/usr/bin/env python3 """ 测试MongoDB连接和现有用户 """ from pymongo import MongoClient from pymongo.errors import OperationFailure, ServerSelectionTimeoutError def test_connections(): """测试不同的MongoDB连接""" # 测试连接配置 test_configs = [ { "name": "Docker配置 (admin/tradingagents123)", ...
72
2,422
TradingAgents-CN
tests/test_detailed_data_display.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 详细数据显示测试脚本 完整显示基本面分析获取的所有数据内容 """ import sys import os import json from datetime import datetime, timedelta # 添加项目根目录到路径 sys.path.append(os.path.dirname(os.path.abspath(__file__))) from tradingagents.agents.utils.agent_utils import Toolkit def test_detailed_data_di...
113
3,889
TradingAgents-CN
tests/test_file_loading_debug.py
.py
#!/usr/bin/env python3 """ 调试文件加载问题 """ import os import sys from pathlib import Path from dotenv import load_dotenv # 添加项目根目录到Python路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) # 加载环境变量 load_dotenv() def test_file_loading(): """测试文件加载""" print("🔬 文件加载调试") print(...
77
2,142
TradingAgents-CN
tests/test_llm_technical_analysis_debug.py
.py
#!/usr/bin/env python3 """ LLM技术面分析调试测试 专门诊断阿里百炼vs DeepSeek在技术面分析中的差异 """ import os import sys from datetime import datetime # 添加项目根目录到Python路径 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) def test_dashscope_technical_analysis(): """测试阿里百炼的技术面分析""" ...
323
10,711
TradingAgents-CN
tests/test_dashscope_token_tracking.py
.py
#!/usr/bin/env python3 """ 测试DashScope适配器的token统计功能 """ import os import sys import time from datetime import datetime # 添加项目根目录到Python路径 sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from tradingagents.llm_adapters.dashscope_adapter import ChatDashScope from tradingagents.config.config_manager i...
187
6,342
TradingAgents-CN
tests/test_code_normalization.py
.py
""" 测试股票代码标准化逻辑(模拟 AKShare 两个接口可能返回的各种格式) """ import sys from pathlib import Path # 添加项目根目录到 Python 路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) def normalize_code_akshare_style(code_raw): """ 模拟 AKShareAdapter.get_realtime_quotes() 中的代码标准化逻辑 """ if not code_ra...
150
5,562
TradingAgents-CN
tests/test_baostock_stock_filter.py
.py
#!/usr/bin/env python3 """ 测试BaoStock股票过滤功能 """ import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import logging from datetime import datetime, timedelta # 设置日志 logging.basicConfig( level=logging.INFO, format='%(asctime)s | %(levelname)-8s | %(message)s' ) def ...
193
7,062