File: test_decorator_params.py

package info (click to toggle)
python-overrides 7.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: python: 1,661; sh: 5; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import Callable, Type
from overrides import override


class SuperClass:
    def method(self) -> int:
        return 2


def my_decorator(name: str) -> Callable:
    def func(cls: Type) -> Type:
        return cls

    return func


class MyClass:
    def __init__(self, name: str):
        self.my_name: str = name


def test_my_func() -> None:
    my_object = MyClass("Name accessed in decorator")

    @my_decorator(my_object.my_name)
    class SubClass(SuperClass):
        @override
        def method(self) -> int:
            return 1