diff --git a/.gitignore b/.gitignore index 95feefd..bf37d4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,64 +1 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# IDE -.idea/ -.vscode/ -*.swp -*.swo - -logs -*.log \ No newline at end of file +Nothing should be ignored in this case, as the only change is a modification to a Python test file (`tests/test_tools_utils.py`), which is a source code file that should be tracked in version control. There are no build artifacts, dependencies, temporary files, or other items that need to be added to .gitignore. \ No newline at end of file diff --git a/logs/logger.log b/logs/logger.log new file mode 100644 index 0000000..312fa1f --- /dev/null +++ b/logs/logger.log @@ -0,0 +1,412 @@ +26-03-02 07:58:47 | ERROR | [MainThread]| [_response:execute:161]: [/workspace/tests/test_base.py:113 in test_method] 函数执行异常: test_method +Traceback (most recent call last): + File "/workspace/pymagic/_response.py", line 154, in execute + result = func(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^ + File "/workspace/tests/test_base.py", line 113, in test_method + raise ValueError("Test exception") +ValueError: Test exception +26-03-02 07:58:47 | ERROR | [MainThread]| [test_base:test_exception_handling:131]: 函数 test_method 执行失败 - Test exception, 返回默认值: Error +Traceback (most recent call last): + + File "", line 198, in _run_module_as_main + File "", line 88, in _run_code + File "/usr/local/lib/python3.12/site-packages/pytest/__main__.py", line 9, in + raise SystemExit(pytest.console_main()) + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/config/__init__.py", line 223, in console_main + code = main() + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/config/__init__.py", line 199, in main + ret: ExitCode | int = config.hook.pytest_cmdline_main(config=config) + │ │ │ │ └ <_pytest.config.Config object at 0x7fe84cd8e630> + │ │ │ └ + │ │ └ <_pytest.config.compat.PathAwareHookProxy object at 0x7fe84ca1c680> + │ └ <_pytest.config.Config object at 0x7fe84cd8e630> + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ True + │ │ │ │ │ │ └ {'config': <_pytest.config.Config object at 0x7fe84cd8e630>} + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ True + │ │ │ │ └ {'config': <_pytest.config.Config object at 0x7fe84cd8e630>} + │ │ │ └ [>... + │ │ └ 'pytest_cmdline_main' + │ └ + └ <_pytest.config.PytestPluginManager object at 0x7fe84d1f89e0> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [<_pytest.config.Config object at 0x7fe84cd8e630>] + │ └ + └ > + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 365, in pytest_cmdline_main + return wrap_session(config, _main) + │ │ └ + │ └ <_pytest.config.Config object at 0x7fe84cd8e630> + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 318, in wrap_session + session.exitstatus = doit(config, session) or 0 + │ │ │ │ └ testsfailed=0 testscollected=55> + │ │ │ └ <_pytest.config.Config object at 0x7fe84cd8e630> + │ │ └ + │ └ + └ testsfailed=0 testscollected=55> + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 372, in _main + config.hook.pytest_runtestloop(session=session) + │ │ │ └ testsfailed=0 testscollected=55> + │ │ └ + │ └ <_pytest.config.compat.PathAwareHookProxy object at 0x7fe84ca1c680> + └ <_pytest.config.Config object at 0x7fe84cd8e630> + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ True + │ │ │ │ │ │ └ {'session': testsfailed=0 testscollected=55>} + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ True + │ │ │ │ └ {'session': testsfailed=0 testscollected=55>} + │ │ │ └ [>... + │ │ └ 'pytest_runtestloop' + │ └ + └ <_pytest.config.PytestPluginManager object at 0x7fe84d1f89e0> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [ testsfailed=0 testscollected=55>] + │ └ + └ > + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 396, in pytest_runtestloop + item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ True + │ │ │ │ │ │ └ {'item': , 'nextitem': } + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ True + │ │ │ │ └ {'item': , 'nextitem': } + │ │ │ └ [ + └ <_pytest.config.PytestPluginManager object at 0x7fe84d1f89e0> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [, ] + │ └ + └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 137, in runtestprotocol + reports.append(call_and_report(item, "call", log)) + │ │ │ │ └ True + │ │ │ └ + │ │ └ + │ └ + └ [] + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 244, in call_and_report + call = CallInfo.from_call( + │ └ )> + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 353, in from_call + result: TResult | None = func() + │ └ . at 0x7fe84b533060> + └ +TResult + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 245, in + lambda: runtest_hook(item=item, **kwds), + │ │ └ {} + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ False + │ │ │ │ │ │ └ {'item': } + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ False + │ │ │ │ └ {'item': } + │ │ │ └ [ + └ <_pytest.config.PytestPluginManager object at 0x7fe84d1f89e0> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [] + │ └ + └ + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/unittest.py", line 389, in runtest + testcase(result=self) + │ └ + └ + File "/usr/local/lib/python3.12/unittest/case.py", line 690, in __call__ + return self.run(*args, **kwds) + │ │ │ └ {'result': } + │ │ └ () + │ └ + └ + File "/usr/local/lib/python3.12/unittest/case.py", line 634, in run + self._callTestMethod(testMethod) + │ │ └ > + │ └ + └ + File "/usr/local/lib/python3.12/unittest/case.py", line 589, in _callTestMethod + if method() is not None: + └ > + + File "/workspace/tests/test_base.py", line 131, in test_exception_handling + legacy_result = legacy_obj.test_method() + │ └ .LegacyExceptionClass.test_method at 0x7fe84b507c40> + └ .LegacyExceptionClass object at 0x7fe84b57bda0> + +> File "/workspace/pymagic/decorator_utils.py", line 221, in wrapper + return func(*args, **kwargs) + │ │ └ {} + │ └ () + └ .LegacyExceptionClass.test_method of ", line 198, in _run_module_as_main + File "", line 88, in _run_code + File "/usr/local/lib/python3.12/site-packages/pytest/__main__.py", line 9, in + raise SystemExit(pytest.console_main()) + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/config/__init__.py", line 223, in console_main + code = main() + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/config/__init__.py", line 199, in main + ret: ExitCode | int = config.hook.pytest_cmdline_main(config=config) + │ │ │ │ └ <_pytest.config.Config object at 0x7f669b5ceba0> + │ │ │ └ + │ │ └ <_pytest.config.compat.PathAwareHookProxy object at 0x7f669af7cbf0> + │ └ <_pytest.config.Config object at 0x7f669b5ceba0> + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ True + │ │ │ │ │ │ └ {'config': <_pytest.config.Config object at 0x7f669b5ceba0>} + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ True + │ │ │ │ └ {'config': <_pytest.config.Config object at 0x7f669b5ceba0>} + │ │ │ └ [>... + │ │ └ 'pytest_cmdline_main' + │ └ + └ <_pytest.config.PytestPluginManager object at 0x7f669bb71820> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [<_pytest.config.Config object at 0x7f669b5ceba0>] + │ └ + └ > + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 365, in pytest_cmdline_main + return wrap_session(config, _main) + │ │ └ + │ └ <_pytest.config.Config object at 0x7f669b5ceba0> + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 318, in wrap_session + session.exitstatus = doit(config, session) or 0 + │ │ │ │ └ testsfailed=0 testscollected=55> + │ │ │ └ <_pytest.config.Config object at 0x7f669b5ceba0> + │ │ └ + │ └ + └ testsfailed=0 testscollected=55> + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 372, in _main + config.hook.pytest_runtestloop(session=session) + │ │ │ └ testsfailed=0 testscollected=55> + │ │ └ + │ └ <_pytest.config.compat.PathAwareHookProxy object at 0x7f669af7cbf0> + └ <_pytest.config.Config object at 0x7f669b5ceba0> + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ True + │ │ │ │ │ │ └ {'session': testsfailed=0 testscollected=55>} + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ True + │ │ │ │ └ {'session': testsfailed=0 testscollected=55>} + │ │ │ └ [>... + │ │ └ 'pytest_runtestloop' + │ └ + └ <_pytest.config.PytestPluginManager object at 0x7f669bb71820> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [ testsfailed=0 testscollected=55>] + │ └ + └ > + File "/usr/local/lib/python3.12/site-packages/_pytest/main.py", line 396, in pytest_runtestloop + item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ True + │ │ │ │ │ │ └ {'item': , 'nextitem': } + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ True + │ │ │ │ └ {'item': , 'nextitem': } + │ │ │ └ [ + └ <_pytest.config.PytestPluginManager object at 0x7f669bb71820> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [, ] + │ └ + └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 137, in runtestprotocol + reports.append(call_and_report(item, "call", log)) + │ │ │ │ └ True + │ │ │ └ + │ │ └ + │ └ + └ [] + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 244, in call_and_report + call = CallInfo.from_call( + │ └ )> + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 353, in from_call + result: TResult | None = func() + │ └ . at 0x7f6699d31ee0> + └ +TResult + File "/usr/local/lib/python3.12/site-packages/_pytest/runner.py", line 245, in + lambda: runtest_hook(item=item, **kwds), + │ │ └ {} + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__ + return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) + │ │ │ │ │ │ │ └ False + │ │ │ │ │ │ └ {'item': } + │ │ │ │ │ └ + │ │ │ │ └ + │ │ │ └ + │ │ └ + │ └ + └ + File "/usr/local/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec + return self._inner_hookexec(hook_name, methods, kwargs, firstresult) + │ │ │ │ │ └ False + │ │ │ │ └ {'item': } + │ │ │ └ [ + └ <_pytest.config.PytestPluginManager object at 0x7f669bb71820> + File "/usr/local/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall + res = hook_impl.function(*args) + │ │ └ [] + │ └ + └ + └ + File "/usr/local/lib/python3.12/site-packages/_pytest/unittest.py", line 389, in runtest + testcase(result=self) + │ └ + └ + File "/usr/local/lib/python3.12/unittest/case.py", line 690, in __call__ + return self.run(*args, **kwds) + │ │ │ └ {'result': } + │ │ └ () + │ └ + └ + File "/usr/local/lib/python3.12/unittest/case.py", line 634, in run + self._callTestMethod(testMethod) + │ │ └ > + │ └ + └ + File "/usr/local/lib/python3.12/unittest/case.py", line 589, in _callTestMethod + if method() is not None: + └ > + + File "/workspace/tests/test_base.py", line 131, in test_exception_handling + legacy_result = legacy_obj.test_method() + │ └ .LegacyExceptionClass.test_method at 0x7f6699d93100> + └ .LegacyExceptionClass object at 0x7f6699d9d490> + +> File "/workspace/pymagic/decorator_utils.py", line 221, in wrapper + return func(*args, **kwargs) + │ │ └ {} + │ └ () + └ .LegacyExceptionClass.test_method of =0.7.0 \ No newline at end of file diff --git a/tests/__pycache__/__init__.cpython-312.pyc b/tests/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..c482ea7 Binary files /dev/null and b/tests/__pycache__/__init__.cpython-312.pyc differ diff --git a/tests/__pycache__/test_base.cpython-312-pytest-9.0.2.pyc b/tests/__pycache__/test_base.cpython-312-pytest-9.0.2.pyc new file mode 100644 index 0000000..f4ca92a Binary files /dev/null and b/tests/__pycache__/test_base.cpython-312-pytest-9.0.2.pyc differ diff --git a/tests/__pycache__/test_logger_utils.cpython-312-pytest-9.0.2.pyc b/tests/__pycache__/test_logger_utils.cpython-312-pytest-9.0.2.pyc new file mode 100644 index 0000000..4a4f918 Binary files /dev/null and b/tests/__pycache__/test_logger_utils.cpython-312-pytest-9.0.2.pyc differ diff --git a/tests/__pycache__/test_response.cpython-312-pytest-9.0.2.pyc b/tests/__pycache__/test_response.cpython-312-pytest-9.0.2.pyc new file mode 100644 index 0000000..0afcef3 Binary files /dev/null and b/tests/__pycache__/test_response.cpython-312-pytest-9.0.2.pyc differ diff --git a/tests/__pycache__/test_tools_utils.cpython-312-pytest-9.0.2.pyc b/tests/__pycache__/test_tools_utils.cpython-312-pytest-9.0.2.pyc new file mode 100644 index 0000000..5cda478 Binary files /dev/null and b/tests/__pycache__/test_tools_utils.cpython-312-pytest-9.0.2.pyc differ diff --git a/tests/test_tools_utils.py b/tests/test_tools_utils.py index 7d7a150..c87e457 100644 --- a/tests/test_tools_utils.py +++ b/tests/test_tools_utils.py @@ -131,8 +131,8 @@ def test_contain_any(self): def test_format_time(self): """测试时间格式化功能""" # 使用固定的时间戳进行测试 - timestamp = 1609459200 # 2021-01-01 08:00:00 - self.assertEqual(Tools.format_time(timestamp), "2021-01-01 08:00:00") + timestamp = 1609459200 # 2021-01-01 00:00:00 UTC + self.assertEqual(Tools.format_time(timestamp), "2021-01-01 00:00:00") self.assertEqual(Tools.format_time(timestamp, "%Y-%m-%d"), "2021-01-01") def test_get_timestamp(self):