@@ -66,27 +66,27 @@ def test_hook_decorate():
66
66
def f ():
67
67
raise NotImplementedError
68
68
69
- assert f . _cloudbot_hook ["event" ].types == {
69
+ assert getattr ( f , HOOK_ATTR ) ["event" ].types == {
70
70
EventType .message ,
71
71
EventType .notice ,
72
72
EventType .action ,
73
73
}
74
- assert f . _cloudbot_hook ["command" ].aliases == {"test" }
75
- assert f . _cloudbot_hook ["irc_raw" ].triggers == {"*" , "PRIVMSG" }
76
-
77
- assert "irc_out" in f . _cloudbot_hook
78
- assert "on_start" in f . _cloudbot_hook
79
- assert "on_stop" in f . _cloudbot_hook
80
- assert "regex" in f . _cloudbot_hook
81
- assert "periodic" in f . _cloudbot_hook
82
- assert "perm_check" in f . _cloudbot_hook
83
- assert "post_hook" in f . _cloudbot_hook
84
- assert "on_connect" in f . _cloudbot_hook
85
- assert "on_cap_available" in f . _cloudbot_hook
86
- assert "on_cap_ack" in f . _cloudbot_hook
87
-
88
- assert len (f . _cloudbot_hook ["regex" ].regexes ) == 4
89
- assert f . _cloudbot_hook ["periodic" ].interval == 20
74
+ assert getattr ( f , HOOK_ATTR ) ["command" ].aliases == {"test" }
75
+ assert getattr ( f , HOOK_ATTR ) ["irc_raw" ].triggers == {"*" , "PRIVMSG" }
76
+
77
+ assert "irc_out" in getattr ( f , HOOK_ATTR )
78
+ assert "on_start" in getattr ( f , HOOK_ATTR )
79
+ assert "on_stop" in getattr ( f , HOOK_ATTR )
80
+ assert "regex" in getattr ( f , HOOK_ATTR )
81
+ assert "periodic" in getattr ( f , HOOK_ATTR )
82
+ assert "perm_check" in getattr ( f , HOOK_ATTR )
83
+ assert "post_hook" in getattr ( f , HOOK_ATTR )
84
+ assert "on_connect" in getattr ( f , HOOK_ATTR )
85
+ assert "on_cap_available" in getattr ( f , HOOK_ATTR )
86
+ assert "on_cap_ack" in getattr ( f , HOOK_ATTR )
87
+
88
+ assert len (getattr ( f , HOOK_ATTR ) ["regex" ].regexes ) == 4
89
+ assert getattr ( f , HOOK_ATTR ) ["periodic" ].interval == 20
90
90
91
91
with pytest .raises (ValueError , match = "Invalid command name test 123" ):
92
92
hook .command ("test 123" )(f )
@@ -107,13 +107,13 @@ def f():
107
107
def sieve_func (_bot , _event , _hook ):
108
108
raise NotImplementedError
109
109
110
- assert "sieve" in sieve_func . _cloudbot_hook
110
+ assert "sieve" in getattr ( sieve_func , HOOK_ATTR )
111
111
112
112
@hook .sieve ()
113
113
def sieve_func2 (_bot , _event , _hook ):
114
114
raise NotImplementedError
115
115
116
- assert "sieve" in sieve_func2 . _cloudbot_hook
116
+ assert "sieve" in getattr ( sieve_func2 , HOOK_ATTR )
117
117
118
118
@hook .on_connect ()
119
119
@hook .irc_out ()
@@ -123,7 +123,7 @@ def sieve_func2(_bot, _event, _hook):
123
123
def plain_dec (_bot , _event , _hook ):
124
124
raise NotImplementedError
125
125
126
- assert sorted (plain_dec . _cloudbot_hook .keys ()) == [
126
+ assert sorted (getattr ( plain_dec , HOOK_ATTR ) .keys ()) == [
127
127
"irc_out" ,
128
128
"on_connect" ,
129
129
"on_start" ,
@@ -141,7 +141,7 @@ def test(bot):
141
141
142
142
foo"""
143
143
144
- cmd_hook = test . _cloudbot_hook ["command" ]
144
+ cmd_hook = getattr ( test , HOOK_ATTR ) ["command" ]
145
145
assert cmd_hook .doc == "<arg> - foo bar baz"
146
146
147
147
@hook .command ()
@@ -150,14 +150,14 @@ def test1(bot):
150
150
151
151
foo"""
152
152
153
- cmd_hook = test1 . _cloudbot_hook ["command" ]
153
+ cmd_hook = getattr ( test1 , HOOK_ATTR ) ["command" ]
154
154
assert cmd_hook .doc == "<arg> - foo bar baz"
155
155
156
156
@hook .command ()
157
157
def test2 (bot ):
158
158
"""<arg> - foo bar baz"""
159
159
160
- cmd_hook = test2 . _cloudbot_hook ["command" ]
160
+ cmd_hook = getattr ( test2 , HOOK_ATTR ) ["command" ]
161
161
assert cmd_hook .doc == "<arg> - foo bar baz"
162
162
163
163
@hook .command ()
@@ -166,12 +166,12 @@ def test3(bot):
166
166
<arg> - foo bar baz
167
167
"""
168
168
169
- cmd_hook = test3 . _cloudbot_hook ["command" ]
169
+ cmd_hook = getattr ( test3 , HOOK_ATTR ) ["command" ]
170
170
assert cmd_hook .doc == "<arg> - foo bar baz"
171
171
172
172
@hook .command ()
173
173
def test4 (bot ):
174
174
"""<arg> - foo bar baz"""
175
175
176
- cmd_hook = test4 . _cloudbot_hook ["command" ]
176
+ cmd_hook = getattr ( test4 , HOOK_ATTR ) ["command" ]
177
177
assert cmd_hook .doc == "<arg> - foo bar baz"
0 commit comments