gh-125600: Only show stale code warning on source code display commands (#125601)

This commit is contained in:
Tian Gao 2024-10-17 17:29:11 -07:00 committed by GitHub
parent 7cf2dbc3cb
commit 77cebb1ce9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 4 deletions

View file

@ -3711,6 +3711,25 @@ def bœr():
self.assertIn("WARNING:", stdout)
self.assertIn("was edited", stdout)
def test_file_modified_and_immediately_restarted(self):
script = """
print("hello")
"""
# the time.sleep is needed for low-resolution filesystems like HFS+
commands = """
filename = $_frame.f_code.co_filename
f = open(filename, "w")
f.write("print('goodbye')")
import time; time.sleep(1)
f.close()
restart
"""
stdout, stderr = self.run_pdb_script(script, commands)
self.assertNotIn("WARNING:", stdout)
self.assertNotIn("was edited", stdout)
def test_file_modified_after_execution_with_multiple_instances(self):
# the time.sleep is needed for low-resolution filesystems like HFS+
script = """