update test code and workflow

This commit is contained in:
sunhailin 2024-10-18 15:52:29 +08:00
parent f37241a768
commit 86369543f6
2 changed files with 14 additions and 1 deletions

View File

@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
exclude: # Python < v3.8 does not support Apple Silicon ARM64.
- python-version: "3.7"
os: macos-latest

View File

@ -55,3 +55,16 @@ class TestEngine(unittest.TestCase):
# importlib.reload(collections.abc) # 重新加载模块以应用补丁
assert collections.abc.Iterable.__module__ == "collections.abc"
def test_iterable_import(self):
# 尝试从 collections.abc 导入 Iterable
try:
from collections.abc import Iterable
self.assertTrue(True) # 如果成功导入,测试通过
except ImportError:
# 如果从 collections.abc 导入失败,则尝试从 collections 导入
try:
from collections import Iterable
self.assertTrue(True) # 如果这里成功导入,测试通过
except ImportError:
self.fail("Failed to import Iterable from both collections.abc and collections") # 如果两者都失败,则测试不通过