From c9b989cb56f2c24a258b42073dee1d2c3a058eea Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 6 Jul 2022 21:43:15 +0900 Subject: [PATCH] Add test for __set_name__ --- test/testSetName.krk | 13 +++++++++++++ test/testSetName.krk.expect | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 test/testSetName.krk create mode 100644 test/testSetName.krk.expect diff --git a/test/testSetName.krk b/test/testSetName.krk new file mode 100644 index 0000000..4f420c9 --- /dev/null +++ b/test/testSetName.krk @@ -0,0 +1,13 @@ +class Foo(): + def __init__(self,v): + self.v = v + def __set_name__(self, owner, name): + print(f'{owner.__name__} setting "{name}" to Foo({self.v})') + +class Bar(): + a = Foo('1') + b = Foo('2') + c = Foo('3') + +class Baz(Bar): + d = Foo('4') diff --git a/test/testSetName.krk.expect b/test/testSetName.krk.expect new file mode 100644 index 0000000..9d0f7e0 --- /dev/null +++ b/test/testSetName.krk.expect @@ -0,0 +1,4 @@ +Bar setting "a" to Foo(1) +Bar setting "b" to Foo(2) +Bar setting "c" to Foo(3) +Baz setting "d" to Foo(4)