Test discovery fails with pytest-libfaketime
See original GitHub issueEnvironment data
VS Code Version: 1.54.2 Commit: fd6f3bce6709b121a895d042d343d71f317d74e7 Date: 2021-03-11T00:56:09.783Z (4 days ago) Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Darwin x64 19.6.0
-
Extension version (available under the Extensions sidebar): v2021.2.636928669
-
Python version (& distribution if applicable, e.g. Anaconda): 3.9.2
-
Type of virtual environment used: pipenv
-
Value of the
python.languageServer
setting: Jedi
Expected behaviour
Tests are correctly discoverd
Actual behaviour
Test discovery fails with when pytest-libfaketime is installed
Steps to reproduce:
I created a small repo to easily reproduce the issue: https://github.com/giallu/vscodetest
- clone the repo and create the virtual env with
pipenv install
- Discover tests using
pytest
and root set to.
oranimals
- open the project in vscode: tests discovery and test running works
- install pytest-libfaketime with
pipenv install pytest-libfaketime
- test discovery fails like this:
Test Discovery failed:
SyntaxError: Unexpected end of JSON input
Logs
I am attaching here the Python Test Log window content; I tried in sequence: discover tests, run tests (install pytest-libfaketime), discover tests, run tests.
Interestingly, tests are a success before and after the library installation, it’s only the discovery phase that is failing.
python /Users/giallu/.vscode/extensions/ms-python.python-2021.2.636928669/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/giallu/vscodetest -s --cache-clear .
============================= test session starts ==============================
platform darwin -- Python 3.9.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
django: settings: vscodetest.settings (from ini)
rootdir: /Users/giallu/vscodetest, configfile: pytest.ini
plugins: django-4.1.0
collected 1 item
animal/tests.py . [100%]
- generated xml file: /var/folders/j8/_m5rss0s475_92j2207sdhxh0000gn/T/tmp-23058OVmOvk3C0G3U.xml -
============================== 1 passed in 0.52s ===============================
python /Users/giallu/.vscode/extensions/ms-python.python-2021.2.636928669/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/giallu/vscodetest -s --cache-clear .
Test Discovery failed:
SyntaxError: Unexpected end of JSON input
python /Users/giallu/.vscode/extensions/ms-python.python-2021.2.636928669/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/giallu/vscodetest -s .
Test Discovery failed:
SyntaxError: Unexpected end of JSON input
re-exec with libfaketime dependencies
============================= test session starts ==============================
platform darwin -- Python 3.9.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
django: settings: vscodetest.settings (from env)
rootdir: /Users/giallu/vscodetest, configfile: pytest.ini
plugins: libfaketime-0.1.2, django-4.1.0
collected 1 item
animal/tests.py . [100%]
- generated xml file: /var/folders/j8/_m5rss0s475_92j2207sdhxh0000gn/T/tmp-230583iuiT9nNMlnD.xml -
============================== 1 passed in 0.55s ===============================
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top GitHub Comments
No there is nothing for you to do, don’t worry I haven’t forgotten about you 🙂
Thank you. In the meanwhile I did exactly what you suggested and changed to https://github.com/adamchainz/time-machine that does not seem to suffer for the same issue.