jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 260 forks source link

Setting elpy-test-compilation-function to 'pdb breaks test at point #1896

Open Paethon opened 3 years ago

Paethon commented 3 years ago

Summary

When I set elpy-test-compilation-function to 'pdb, I can't test single unit tests anymore (having point on a test and using C-c C-t. I get the following error (Running all tests of a file works):

Current directory is /home/paethon/git/autonlu/autonlu/tests/short_tests/
========================================================== test session starts ==========================================================
platform linux -- Python 3.9.2, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/paethon/git/autonlu
plugins: anyio-2.0.2, cov-2.11.1
collected 0 items                                                                                                                       

========================================================= no tests ran in 0.01s =========================================================
ERROR: file or directory not found: /home/paethon/git/autonlu/autonlu/tests/short_tests/test_snorkel.py\:\:test_SnorkelLabeler

Debugger exited abnormally with code 4

Having set it to 'compile, it works without a problem:

-*- mode: compilation; default-directory: "~/git/autonlu/autonlu/tests/short_tests/" -*-
Compilation started at Tue Mar  2 13:23:35

py.test --pdb --disable-warnings /home/paethon/git/autonlu/autonlu/tests/short_tests/test_snorkel.py\:\:test_SnorkelLabeler
========================================================== test session starts ==========================================================
platform linux -- Python 3.9.2, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/paethon/git/autonlu
plugins: anyio-2.0.2, cov-2.11.1
collected 1 item                                                                                                                        

Steps to reproduce

Set elpy-test-compilation-function to 'pdb and try to run a test at point.

My configuration

OS

Arch Linux

Result of (elpy-config)

Emacs.............: 27.1
Elpy..............: 1.35.0
Virtualenv........: py39env (/home/paethon/git/py39env/)
Interactive Python: ipython 7.19.0 (/home/paethon/git/py39env/bin/ipython)
RPC virtualenv....: system (/usr)
 Python...........: python 3.9.2 (/usr/bin/python)
 Jedi.............: 0.17.2 (0.18.0 available)
 Rope.............: 0.18.0
 Autopep8.........: 1.5.5
 Yapf.............: 0.30.0
 Black............: 20.8b1
Syntax checker....: pylint (/home/paethon/git/py39env/bin/pylint)

Elpy configuration in my init.el

(elpy-enable)
(setq elpy-rpc-backend "jedi")
(setq elpy-test-pytest-runner-command '("py.test" "--pdb" "--disable-warnings"))
(setq elpy-test-compilation-function 'pdb)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
Paethon commented 3 years ago

OK, I did a bit of debugging. The problem seems to be the shell-quote-argument here:

https://github.com/jorgenschaefer/elpy/blob/c31cd91325595573c489b92ad58e492a839d2dec/elpy.el#L2108-L2110

Replacing it with identity solves the problem ...