MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / outerScope

Function outerScope

tests/python/test_functions_this.py:181–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179 starting_ref_count = []
180
181 def outerScope():
182 def pyFunc():
183 return 42
184
185 ref.append(weakref.ref(pyFunc))
186 starting_ref_count.append(sys.getrefcount(pyFunc))
187 assert 42 == pm.eval("(func) => func()")(pyFunc)
188
189 assert ref[0]() is pyFunc
190 current_ref_count = sys.getrefcount(pyFunc)
191 assert current_ref_count == starting_ref_count[0] + 1
192
193 outerScope()
194 pm.collect() # this should collect the JS proxy to pyFunc, which should decref pyFunc

Callers 1

Calls 2

appendMethod · 0.80
refMethod · 0.80

Tested by

no test coverage detected