1def is_interesting_method(obj, method_name):
2 try:
3 method = getattr(obj, method_name)
4 if callable(method):
5 if len(method_name) == 1:
6 if method_name.isalnum():
7 result = method(2) if isinstance(method(2), int) else None
8 if isinstance(result, int):
9 return False
10 try:
11 method('left', 'right')
12 except TypeError:
13 return True
14 except BaseException:
15 return True
16 except AttributeError:
17 pass
18 return False
19
20def methodify():
21 import secret
22
23 def find_interesting_methods(obj):
24 interesting_methods = set()
25
26 for attr_name in dir(obj):
27 attr = getattr(obj, attr_name)
28 if "clue" in attr_name and hasattr(attr, '__dict__'):
29 for method_name in dir(attr):
30 if is_interesting_method(attr, method_name):
31 interesting_methods.add(method_name)
32
33 interesting_methods.update(find_interesting_methods(attr))
34
35 return interesting_methods
36
37 interesting_methods = find_interesting_methods(secret)
38
39 return tuple(interesting_methods)
E
======================================================================
ERROR: test_metodify (test.TestMethodify)
Test metodify function.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 12, in test_metodify
self.assertIn(methodify(), _RESULTS.keys())
File "/tmp/solution.py", line 37, in methodify
interesting_methods = find_interesting_methods(secret)
File "/tmp/solution.py", line 30, in find_interesting_methods
if is_interesting_method(attr, method_name):
File "/tmp/solution.py", line 7, in is_interesting_method
result = method(2) if isinstance(method(2), int) else None
TypeError: decoy_2() takes 0 positional arguments but 1 was given
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)