@@ -4013,6 +4013,54 @@ def f(x):
40134013 self .assertIn ('42' , stdout )
40144014 self .assertIn ('return x + 1' , stdout )
40154015
4016+ def test_zipimport (self ):
4017+ with os_helper .temp_dir () as temp_dir :
4018+ os .mkdir (os .path .join (temp_dir , 'source' ))
4019+ zipmodule = textwrap .dedent (
4020+ """
4021+ def bar():
4022+ pass
4023+ """
4024+ )
4025+ script = textwrap .dedent (
4026+ f"""
4027+ import sys; sys.path.insert(0, { repr (os .path .join (temp_dir , 'zipmodule.zip' ))} )
4028+ import foo
4029+ foo.bar()
4030+ """
4031+ )
4032+
4033+ with zipfile .ZipFile (os .path .join (temp_dir , 'zipmodule.zip' ), 'w' ) as zf :
4034+ zf .writestr ('foo.py' , zipmodule )
4035+ with open (os .path .join (temp_dir , 'script.py' ), 'w' ) as f :
4036+ f .write (script )
4037+
4038+ stdout , _ = self ._run_pdb ([os .path .join (temp_dir , 'script.py' )], '\n ' .join ([
4039+ 'n' ,
4040+ 'n' ,
4041+ 'b foo.bar' ,
4042+ 'c' ,
4043+ 'p f"break in {$_frame.f_code.co_name}"' ,
4044+ 'q'
4045+ ]))
4046+ self .assertIn ('break in bar' , stdout )
4047+
4048+ def test_issue_59000 (self ):
4049+ script = """
4050+ def foo():
4051+ pass
4052+
4053+ class C:
4054+ def foo(self):
4055+ pass
4056+ """
4057+ commands = """
4058+ break C.foo
4059+ quit
4060+ """
4061+ stdout , stderr = self .run_pdb_script (script , commands )
4062+ self .assertIn ("The specified object 'C.foo' is not a function" , stdout )
4063+
40164064
40174065class ChecklineTests (unittest .TestCase ):
40184066 def setUp (self ):
0 commit comments