55import pytest
66from _appmap .test .helpers import DictIncluding
77
8- pytestmark = pytest .mark .skip ( reason = "property instrumentation is broken in Django" )
8+ pytestmark = pytest .mark .appmap_enabled
99
1010@pytest .fixture (autouse = True )
1111def setup (with_data_dir ): # pylint: disable=unused-argument
12- # with_data_dir sets up sys.path so example_class can be imported
12+ # with_data_dir sets up sys.path so properties_class can be imported
1313 pass
1414
1515
1616def test_getter_instrumented (events ):
17- from example_class import ExampleClass
17+ from properties_class import PropertiesClass
1818
19- ec = ExampleClass ()
19+ ec = PropertiesClass ()
2020
21- actual = ExampleClass .read_only .__doc__
21+ actual = PropertiesClass .read_only .__doc__
2222 assert actual == "Read-only"
2323
2424 assert ec .read_only == "read only"
2525
2626 with pytest .raises (AttributeError , match = r".*(has no setter|can't set attribute).*" ):
27- # E AttributeError: can't set attribute
28-
2927 ec .read_only = "not allowed"
3028
3129 with pytest .raises (AttributeError , match = r".*(has no deleter|can't delete attribute).*" ):
3230 del ec .read_only
3331
3432 assert len (events ) == 2
35- assert events [0 ].to_dict () == DictIncluding (
36- {
37- "event" : "call" ,
38- "defined_class" : "example_class.ExampleClass" ,
39- "method_id" : "read_only (get)" ,
40- }
41- )
33+ assert events [0 ].to_dict () == DictIncluding ({
34+ "event" : "call" ,
35+ "defined_class" : "properties_class.PropertiesClass" ,
36+ "method_id" : "read_only (get)" ,
37+ })
4238
4339
4440def test_accessible_instrumented (events ):
45- from example_class import ExampleClass
41+ from properties_class import PropertiesClass
4642
47- ec = ExampleClass ()
48- assert ExampleClass .fully_accessible .__doc__ == "Fully-accessible"
43+ ec = PropertiesClass ()
44+ assert PropertiesClass .fully_accessible .__doc__ == "Fully-accessible"
4945
5046 assert ec .fully_accessible == "fully accessible"
5147
@@ -55,48 +51,61 @@ def test_accessible_instrumented(events):
5551
5652 del ec .fully_accessible
5753
58- # assert len(events) == 6
59- assert events [0 ].to_dict () == DictIncluding (
60- {
61- "event" : "call" ,
62- "defined_class" : "example_class.ExampleClass" ,
63- "method_id" : "fully_accessible (get)" ,
64- }
65- )
66-
67- assert events [2 ].to_dict () == DictIncluding (
68- {
69- "event" : "call" ,
70- "defined_class" : "example_class.ExampleClass" ,
71- "method_id" : "fully_accessible (set)" ,
72- }
73- )
74-
75- assert events [4 ].to_dict () == DictIncluding (
76- {
77- "event" : "call" ,
78- "defined_class" : "example_class.ExampleClass" ,
79- "method_id" : "fully_accessible (del)" ,
80- }
81- )
54+ assert len (events ) == 6
55+ assert events [0 ].to_dict () == DictIncluding ({
56+ "event" : "call" ,
57+ "defined_class" : "properties_class.PropertiesClass" ,
58+ "method_id" : "fully_accessible (get)" ,
59+ })
60+
61+ assert events [2 ].to_dict () == DictIncluding ({
62+ "event" : "call" ,
63+ "defined_class" : "properties_class.PropertiesClass" ,
64+ "method_id" : "fully_accessible (set)" ,
65+ })
66+
67+ assert events [4 ].to_dict () == DictIncluding ({
68+ "event" : "call" ,
69+ "defined_class" : "properties_class.PropertiesClass" ,
70+ "method_id" : "fully_accessible (del)" ,
71+ })
8272
8373
8474def test_writable_instrumented (events ):
85- from example_class import ExampleClass
75+ from properties_class import PropertiesClass
8676
87- ec = ExampleClass ()
88- assert ExampleClass .write_only .__doc__ == "Write-only"
77+ ec = PropertiesClass ()
78+ assert PropertiesClass .write_only .__doc__ == "Write-only"
8979
9080 with pytest .raises (AttributeError , match = r".*(has no getter|unreadable attribute).*" ):
9181 _ = ec .write_only
9282
9383 ec .write_only = "updated example"
9484
9585 assert len (events ) == 2
96- assert events [0 ].to_dict () == DictIncluding (
97- {
98- "event" : "call" ,
99- "defined_class" : "example_class.ExampleClass" ,
100- "method_id" : "set_write_only (set)" ,
101- }
102- )
86+ assert events [0 ].to_dict () == DictIncluding ({
87+ "event" : "call" ,
88+ "defined_class" : "properties_class.PropertiesClass" ,
89+ "method_id" : "set_write_only (set)" ,
90+ })
91+
92+
93+ def test_operator_attrgetter (events ):
94+ from properties_class import PropertiesClass
95+
96+ ec = PropertiesClass ()
97+
98+ assert ec .operator_read_only == "read only"
99+
100+ with pytest .raises (AttributeError , match = r".*(has no setter|can't set attribute).*" ):
101+ ec .operator_read_only = "not allowed"
102+
103+ with pytest .raises (AttributeError , match = r".*(has no deleter|can't delete attribute).*" ):
104+ del ec .operator_read_only
105+
106+ assert len (events ) == 2
107+ assert events [0 ].to_dict () == DictIncluding ({
108+ "event" : "call" ,
109+ "defined_class" : "properties_class.PropertiesClass" ,
110+ "method_id" : "operator_read_only (get)" ,
111+ })
0 commit comments