GitXplorerGitXplorer
k

vscode-fail-example

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
ac83ab5da2591d4e9b7e291b848b3c2826e8605c

Fix formatting

kkam193 committed 2 years ago
Unverified
4bdbb31b51352361aaf5bbd5a194a13e7d2315e2

Add possible solution

kkam193 committed 2 years ago
Unverified
2a231947b73441ca0f9e533a26f08350c161c2c5

Debugging steps

kkam193 committed 2 years ago
Unverified
fa370095f556ffe2dc97b9999adcccd171dfc8ab

Example issue

kkam193 committed 2 years ago
Verified
a5d7205b20fd6b87cabc845c1e08ae068d9509aa

Initial commit

kkam193 committed 2 years ago

README

The README file for this repository.

vscode-fail-example

Example of VSCode Python debugger failing when tests requires custom PWD.

Steps to reproduce:

  1. Use make init to create venv in the venv/ directory.
  2. Configure your VSCode to use it as an interpreter.
  3. At the moment, you cannot find any tests in the Test Explorer. Let's fix it by setting in VSCode python.testing.cwd to the subproject/theproject directory.
  4. Now, you can open test explorer and run tests. It should pass.
  5. Let's try to debug the test. Apparently, you cannot, and in output/Python you see something like: [ERROR...] [object Object] [object Object]

Steps to debug the troubles:

  1. Try run a test debug, then look into Output/Python window, find a line DAP Server launched with command ...

  2. Basing on this path, open the folder pythonFiles in the extension's dir, and first do following:

    • in lib/python/debugpy/adapter/__main__.py find the line about 44, and force the log.log_dir to a chosen writable directory,

    • in visualstudio_py_testlauncher.py look into the main() and in the main try/except block, before the finally add the following:

      except Exception as err:
          errorMessage = traceback.format_exc()
          print(errorMessage)
      
  3. Now run tests once more, and in the selected logs directory, in the debugpy.adapter-xxx.log file, look for "category": "stdout". You will see outputs from the test runner.

  4. Use your magic power and debug, add prints etc. until you discover the issue.

Now, let's try to fix it:

  1. In the lib/python/debugpy/adapter/clients.py let's find the line with parsing cwd (around 375) and change it to the expected testing path (absolute path).
  2. Run the debugging.
  3. It works!