Skip to content

Look into test debugging stability/configuration #174

Closed
microsoft/vscode-python
#22903

Description

Activity

  1. added
    bug
    on Jan 3, 2024
  2. added
    triage-needed
    on Jan 3, 2024
  3. removed
    triage-needed
    on Feb 7, 2024
  4. added
    verification-steps-needed
    on Feb 22, 2024
  5. paulacamargo25 commented on Feb 23, 2024

    @paulacamargo25
    ContributorAuthor

    Verification steps:

    1. Install python and python debugger extension
    2. Create a simple unittest
    3. Add launch.json config for testing using type: debugpy, like this one
         {
             "name": "Python: Debug Tests",
             "type": "debugpy",
             "request": "launch",
             "program": "${file}",
             "purpose": ["debug-test"],
             "console": "integratedTerminal",
             "justMyCode": true,
             "env": {
               "PYTHONPATH": "${workspaceFolder}"
             }
         } 
      
    4. Make sure that the test is using the config that you have
  6. added
    verification-needed
    and removed
    verification-steps-needed
    on Feb 23, 2024
  7. rzhao271 commented on Feb 23, 2024

    @rzhao271
    Contributor

    In my workspace, I have tests/test_hello.py with the following

    import unittest
    
    def hello():
    	return 'Here is my test file'
    
    class TestHello(unittest.TestCase):
    	def test_hello(self):
    		self.assertEqual(hello(), 'Here is my test file')
    
    if __name__ == '__main__':
    	unittest.main()

    In .vscode/launch.json, I have the following

    {
    	"name": "Python: Debug Tests",
    	"type": "debugpy",
    	"request": "launch",
    	"program": "${file}",
    	"purpose": ["debug-test"],
    	"console": "integratedTerminal",
    	"justMyCode": true,
    	"env": {
    	  "PYTHONPATH": "${workspaceFolder}"
    	}
    }

    Nothing happens when I press the "Debug using launch.json" option.

  8. rzhao271 commented on Feb 23, 2024

    @rzhao271
    Contributor

    Now, I have tests/test_hello.py with the following

    import unittest
    
    def hello():
    	return 'Here is my test file'
    
    class TestHello(unittest.TestCase):
    	def test_hello(self):
    		self.assertEqual(hello(), 'Here is my test file')
    		for i in range(5):
    			print(i)
    			self.assertEqual(i, i)
    
    if __name__ == '__main__':
    	unittest.main()

    Paula helped me fix my .vscode/launch.json file to the following:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python: Debug Tests",
                "type": "debugpy",
                "request": "launch",
                "program": "${file}",
                "purpose": ["debug-test"],
                "console": "integratedTerminal",
                "justMyCode": true,
                "env": {
                  "PYTHONPATH": "${workspaceFolder}"
                }
            }
        ]
    }

    I was able to verify the issue successfully after that.

  9. added 2 commits that reference this issue on Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions