Lines Matching refs:self
26 def __init__(self, input):
27 self.input = input
29 def __enter__(self):
30 self.real_stdin = sys.stdin
31 sys.stdin = _FakeInput(self.input)
32 self.orig_trace = sys.gettrace() if hasattr(sys, 'gettrace') else None
34 def __exit__(self, *exc):
35 sys.stdin = self.real_stdin
36 if self.orig_trace:
37 sys.settrace(self.orig_trace)
410 ... def __repr__(self):
543 ... def mymethod(self):
631 ... def __init__(self):
632 ... self.attr1 = 10
633 ... self.attr2 = 'str'
634 ... def method(self):
644 ... 'alias ps pi self',
654 (Pdb) alias ps pi self
661 -> def method(self):
663 self.attr1 = 10
664 self.attr2 = str
1704 def tearDown(self):
1709 def _run_pdb(self, pdb_args, commands, expected_returncode=0):
1710 self.addCleanup(os_helper.rmtree, '__pycache__')
1722 self.assertEqual(
1729 def run_pdb_script(self, script, commands, expected_returncode=0):
1734 self.addCleanup(os_helper.unlink, filename)
1735 return self._run_pdb([filename], commands, expected_returncode)
1737 def run_pdb_module(self, script, commands):
1739 self.module_name = 't_main'
1740 os_helper.rmtree(self.module_name)
1741 main_file = self.module_name + '/__main__.py'
1742 init_file = self.module_name + '/__init__.py'
1743 os.mkdir(self.module_name)
1748 self.addCleanup(os_helper.rmtree, self.module_name)
1749 return self._run_pdb(['-m', self.module_name], commands)
1751 def _assert_find_function(self, file_content, func_name, expected):
1757 self.assertEqual(
1760 def test_find_function_empty_file(self):
1761 self._assert_find_function(b'', 'foo', None)
1763 def test_find_function_found(self):
1764 self._assert_find_function(
1779 def test_find_function_found_with_encoding_cookie(self):
1780 self._assert_find_function(
1796 def test_find_function_found_with_bom(self):
1797 self._assert_find_function(
1806 def test_issue7964(self):
1816 self.addCleanup(proc.stdout.close)
1818 self.assertNotIn(b'SyntaxError', stdout,
1821 def test_issue46434(self):
1825 def do_testcmdwithnodocs(self, arg):
1835 stdout, stderr = self.run_pdb_script(script, commands)
1837 self.assertNotIn('AttributeError', output,
1839 self.assertIn("*** No help for 'testcmdwithnodocs'; __doc__ string missing", output,
1842 def test_issue13183(self):
1872 self.addCleanup(os_helper.unlink, 'bar.py')
1873 stdout, stderr = self.run_pdb_script(script, commands)
1874 self.assertTrue(
1878 def test_issue13120(self):
1901 self.addCleanup(proc.stdout.close)
1903 self.assertNotIn(b'Error', stdout,
1906 def test_issue36250(self):
1931 self.addCleanup(proc.stdout.close)
1933 self.assertNotIn(b'Error', stdout,
1936 def test_issue16180(self):
1941 stdout, stderr = self.run_pdb_script(
1944 self.assertIn(expected, stdout,
1949 def test_issue26053(self):
1958 stdout, stderr = self.run_pdb_script(script, commands)
1960 self.assertRegex(res, "Restarting .* with arguments:\na b c")
1961 self.assertRegex(res, "Restarting .* with arguments:\nd e f")
1963 def test_readrc_kwarg(self):
1988 self.assertNotIn(b"NameError: name 'invalid' is not defined",
1995 def test_readrc_homedir(self):
2003 self.assertEqual(pdb.Pdb().rcLines[0], "invalid")
2008 def test_read_pdbrc_with_ascii_encoding(self):
2035 self.assertIn(b"UnicodeEncodeError: \'ascii\' codec can\'t encode character "
2042 def test_header(self):
2049 self.assertEqual(stdout.getvalue(), header + '\n')
2051 def test_run_module(self):
2057 stdout, stderr = self.run_pdb_module(script, commands)
2058 self.assertTrue(any("SUCCESS" in l for l in stdout.splitlines()), stdout)
2060 def test_module_is_run_as_main(self):
2069 stdout, stderr = self.run_pdb_module(script, commands)
2070 self.assertTrue(any("SUCCESS" in l for l in stdout.splitlines()), stdout)
2072 def test_breakpoint(self):
2083 stdout, stderr = self.run_pdb_module(script, commands)
2084 self.assertTrue(any("Breakpoint 1 at" in l for l in stdout.splitlines()), stdout)
2085 self.assertTrue(all("SUCCESS" not in l for l in stdout.splitlines()), stdout)
2087 def test_run_pdb_with_pdb(self):
2092 stdout, stderr = self._run_pdb(["-m", "pdb"], commands)
2093 self.assertIn(
2098 def test_module_without_a_main(self):
2105 self.addCleanup(os_helper.rmtree, module_name)
2106 stdout, stderr = self._run_pdb(
2109 self.assertIn("ImportError: No module named t_main.__main__",
2112 def test_package_without_a_main(self):
2120 self.addCleanup(os_helper.rmtree, pkg_name)
2121 stdout, stderr = self._run_pdb(
2124 self.assertIn(
2128 def test_blocks_at_first_code_line(self):
2137 stdout, stderr = self.run_pdb_module(script, commands)
2138 self.assertTrue(any("__main__.py(4)<module>()"
2141 def test_relative_imports(self):
2142 self.module_name = 't_main'
2143 os_helper.rmtree(self.module_name)
2144 main_file = self.module_name + '/__main__.py'
2145 init_file = self.module_name + '/__init__.py'
2146 module_file = self.module_name + '/module.py'
2147 self.addCleanup(os_helper.rmtree, self.module_name)
2148 os.mkdir(self.module_name)
2173 stdout, _ = self._run_pdb(['-m', self.module_name], commands)
2174 self.assertTrue(any("VAR from module" in l for l in stdout.splitlines()), stdout)
2175 self.assertTrue(any("VAR from top" in l for l in stdout.splitlines()))
2176 self.assertTrue(any("second var" in l for l in stdout.splitlines()))
2178 def test_relative_imports_on_plain_module(self):
2180 self.module_name = 't_main'
2181 os_helper.rmtree(self.module_name)
2182 main_file = self.module_name + '/runme.py'
2183 init_file = self.module_name + '/__init__.py'
2184 module_file = self.module_name + '/module.py'
2185 self.addCleanup(os_helper.rmtree, self.module_name)
2186 os.mkdir(self.module_name)
2206 stdout, _ = self._run_pdb(['-m', self.module_name + '.runme'], commands)
2207 self.assertTrue(any("VAR from module" in l for l in stdout.splitlines()), stdout)
2209 def test_errors_in_command(self):
2216 stdout, _ = self.run_pdb_script('pass', commands + '\n')
2218 self.assertEqual(stdout.splitlines()[1:], [
2233 def test_issue34266(self):
2240 stdout, _ = self.run_pdb_script('pass', commands + '\n')
2241 self.assertEqual(stdout.splitlines()[1:], [
2249 def test_issue42384(self):
2260 stdout, stderr = self.run_pdb_script(script, commands)
2262 self.assertEqual(stdout.split('\n')[2].rstrip('\r'), expected)
2265 def test_issue42384_symlink(self):
2285 stdout, stderr = self._run_pdb([os.path.join('dir_two', 'foo.py')], commands)
2287 self.assertEqual(stdout.split('\n')[2].rstrip('\r'), expected)
2289 def test_issue42383(self):
2308 stdout, stderr = self._run_pdb(['foo.py'], 'c\nc\nq')
2310 self.assertEqual(stdout.split('\n')[6].rstrip('\r'), expected)
2312 def test_gh_94215_crash(self):
2328 stdout, stderr = self.run_pdb_script(script, commands)
2329 self.assertFalse(stderr)
2331 def test_gh_93696_frozen_list(self):
2371 self.addCleanup(os_helper.unlink, 'gh93696.py')
2372 self.addCleanup(os_helper.unlink, 'gh93696_host.py')
2373 stdout, stderr = self._run_pdb(["gh93696_host.py"], commands)
2375 self.assertIn('x = "Sentinel string for gh-93696"', stdout, "Sentinel statement not found")
2377 def test_non_utf8_encoding(self):
2381 self._run_pdb([os.path.join(script_dir, filename)], 'q')
2384 def setUp(self):
2387 def tearDown(self):
2390 def test_checkline_before_debugging(self):
2394 self.assertEqual(db.checkline(os_helper.TESTFN, 1), 1)
2396 def test_checkline_after_reset(self):
2401 self.assertEqual(db.checkline(os_helper.TESTFN, 1), 1)
2403 def test_checkline_is_not_executable(self):
2417 self.assertFalse(db.checkline(os_helper.TESTFN, lineno))