X7ROOT File Manager
Current Path:
/opt/alt/python311/lib/python3.11/site-packages/tests/functions
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
tests
/
functions
/
📁
..
📄
__init__.py
(0 B)
📁
__pycache__
📄
test_common_ancestor.py
(1.24 KB)
📄
test_get_args_and_return_type.py
(1.26 KB)
📄
test_get_mro.py
(779 B)
📄
test_get_type.py
(3.42 KB)
📄
test_get_type_hints_of_callable.py
(1.64 KB)
📄
test_instance_of.py
(5.61 KB)
📄
test_is_optional_type.py
(553 B)
📄
test_is_type_annotation.py
(1.03 KB)
📄
test_origin_and_alias.py
(1.97 KB)
📄
test_subclass_of.py
(4.24 KB)
Editing: test_common_ancestor.py
from typing import Type from unittest import TestCase from typish import common_ancestor, common_ancestor_of_types, NoneType class A: pass class B(A): pass class C(B): pass class D(C): pass class E(D): pass class TestCommonAncestor(TestCase): def test_common_ancestor(self): self.assertEqual(C, common_ancestor(E(), C(), D(), E())) self.assertEqual(B, common_ancestor(E(), C(), D(), E(), B())) self.assertEqual(object, common_ancestor(E(), C(), D(), E(), B(), 42)) def test_common_ancestor_of_types(self): self.assertEqual(C, common_ancestor_of_types(E, C, D, E)) self.assertEqual(object, common_ancestor_of_types(int, str)) common_ancestor_of_types(list, tuple) def test_common_ancestor_of_typing_types(self): self.assertEqual(type, common_ancestor_of_types(Type[int], Type[str])) def test_common_acestor_of_collections(self): self.assertEqual(list, common_ancestor([1, 2, 3], ['a', 'b', 'c'])) def test_special_args(self): self.assertEqual(NoneType, common_ancestor(None, None)) self.assertEqual(int, common_ancestor(42)) def test_invalid(self): with self.assertRaises(TypeError): common_ancestor()
Upload File
Create Folder