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

Method _super_method_call_error

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

Source from the content-addressed store, hash-verified

1933 self.check_events(opt_func, recorders=self.RECORDERS, expected=opt_expected)
1934
1935 def _super_method_call_error(self, optimized=False):
1936 codestr = """
1937 class A:
1938 def method(self, x):
1939 return x
1940
1941 class B(A):
1942 def method(self, x):
1943 return super(
1944 x,
1945 self,
1946 ).method(
1947 x
1948 )
1949
1950 b = B()
1951 def f():
1952 try:
1953 return b.method(1)
1954 except TypeError:
1955 pass
1956 else:
1957 assert False, "should have raised TypeError"
1958 """
1959 d = self._exec_super(codestr, optimized)
1960 expected = [
1961 ('line', 'get_events', 10),
1962 ('call', 'f', sys.monitoring.MISSING),
1963 ('line', 'f', 1),
1964 ('line', 'f', 2),
1965 ('call', 'method', d["b"]),
1966 ('line', 'method', 1),
1967 ('line', 'method', 2),
1968 ('line', 'method', 3),
1969 ('line', 'method', 1),
1970 ('call', 'super', 1),
1971 ('C raise', 'super', 1),
1972 ('line', 'f', 3),
1973 ('line', 'f', 4),
1974 ('line', 'get_events', 11),
1975 ('call', 'set_events', 2),
1976 ]
1977 return d["f"], expected
1978
1979 def test_method_call_error(self):
1980 nonopt_func, nonopt_expected = self._super_method_call_error(optimized=False)

Callers 1

Calls 1

_exec_superMethod · 0.95

Tested by

no test coverage detected