From e897bad50672753882f1ee609c89a88935a074a6 Mon Sep 17 00:00:00 2001 From: Art_Sakura <1754798088@qq.com> Date: Wed, 28 Oct 2026 09:49:06 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20#=20=E8=BF=98=E6=98=AF=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DCI=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_asset_bundle.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_asset_bundle.py b/tests/test_asset_bundle.py index 02a0df1..4981d20 100644 --- a/tests/test_asset_bundle.py +++ b/tests/test_asset_bundle.py @@ -209,7 +209,8 @@ class BundleTests(unittest.TestCase): terminal = StringIO() terminal.isatty = lambda: True - with patch.object(bundle.sys, 'stderr', terminal), \ + with patch.dict('os.environ', {'TERM': 'xterm-256color'}), \ + patch.object(bundle.sys, 'stderr', terminal), \ patch('rich.console.Console', side_effect=lambda **kwargs: Console(**kwargs, force_terminal=True, force_interactive=True, legacy_windows=False, @@ -218,8 +219,10 @@ class BundleTests(unittest.TestCase): self.assertLogs(bundle.logger, level='INFO') as captured: with self.assertRaises(OSError): bundle._copy_remote('https://farm.example/a', BytesIO(), 10) - self.assertTrue(terminal.getvalue().endswith('\n')) - self.assertNotIn('100.0%', terminal.getvalue()) + raw = terminal.getvalue() + progress = re.sub(r'\x1b\[[0-9;?]*[a-zA-Z]', '', raw) + self.assertTrue(progress.endswith('\n'), repr(raw)) + self.assertNotIn('100.0%', progress) self.assertNotIn('下载完成', '\n'.join(captured.output)) def test_progress_display_failure_does_not_abort_download(self):