OXIESEC PANEL
- Current Dir:
/
/
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
tests
/
decorators
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/08/2024 06:43:38 PM
rwxr-xr-x
📄
__init__.py
0 bytes
05/08/2024 06:42:59 PM
rw-r--r--
📁
__pycache__
-
05/08/2024 06:42:59 PM
rwxr-xr-x
📄
test_hintable.py
1.57 KB
05/08/2024 06:42:59 PM
rw-r--r--
Editing: test_hintable.py
Close
import sys from typing import Type from unittest import TestCase from typish import hintable, T if sys.version_info.major * 10 + sys.version_info.minor > 35: # All Python 3.5+ specific tests are moved to a separate module. from test_resources.hintable import TestHintable as Base else: Base = TestCase @hintable def some_func(hint: Type[T]) -> Type[T]: """Some docstring""" return hint class TestHintable(Base): def test_hintable_without_any_hint(self): # Test that when a hintable function is called without hint, it # receives None. x = some_func() self.assertEqual(None, x) def test_hintable_class(self): # Test that decorating a class raises an error. with self.assertRaises(TypeError): @hintable class DecoratedClass: ... def test_meta_data(self): # Test that any meta data is copied properly. self.assertEqual('Some docstring', some_func.__doc__) def test_hintable_with_flawed_function(self): with self.assertRaises(TypeError): @hintable def some_flawed_func(): ... def test_hintable_with_flawed_custom_param_name(self): # Test that when a custom param name is used, it is checked if a # parameter with that name is accepted by the decorated function. with self.assertRaises(TypeError): @hintable(param='cls') def some_func_with_flawed_custom_param_name(hint): return hint