MCPcopy Index your code
hub / github.com/python/cpython / _super_method_call

Method _super_method_call

Lib/test/test_monitoring.py:1891–1926  ·  view source on GitHub ↗
(self, optimized=False)

Source from the content-addressed store, hash-verified

1889 return has
1890
1891 def _super_method_call(self, optimized=False):
1892 codestr = """
1893 class A:
1894 def method(self, x):
1895 return x
1896
1897 class B(A):
1898 def method(self, x):
1899 return super(
1900 ).method(
1901 x
1902 )
1903
1904 b = B()
1905 def f():
1906 return b.method(1)
1907 """
1908 d = self._exec_super(codestr, optimized)
1909 expected = [
1910 ('line', 'get_events', 10),
1911 ('call', 'f', sys.monitoring.MISSING),
1912 ('line', 'f', 1),
1913 ('call', 'method', d["b"]),
1914 ('line', 'method', 1),
1915 ('call', 'super', sys.monitoring.MISSING),
1916 ('C return', 'super', sys.monitoring.MISSING),
1917 ('line', 'method', 2),
1918 ('line', 'method', 3),
1919 ('line', 'method', 2),
1920 ('call', 'method', d["b"]),
1921 ('line', 'method', 1),
1922 ('line', 'method', 1),
1923 ('line', 'get_events', 11),
1924 ('call', 'set_events', 2),
1925 ]
1926 return d["f"], expected
1927
1928 def test_method_call(self):
1929 nonopt_func, nonopt_expected = self._super_method_call(optimized=False)

Callers 1

test_method_callMethod · 0.95

Calls 1

_exec_superMethod · 0.95

Tested by

no test coverage detected