Azure / azure-cli-dev-tools

Developer utilities for Azure CLI command module and extension developers.
MIT License
80 stars 113 forks source link

When I try to run tests I get `C:\Python310\python.exe: No module named pytest` #474

Closed juliusl closed 1 month ago

juliusl commented 1 month ago

Title

juliusl commented 1 month ago

Got past this but now I get,

ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n auto
  inifile: None
  rootdir: d:\py\azure-cli\src\azure-cli
adrianmo commented 1 month ago

I have also been impacted by this issue when running azdev test <extension_dir> --series as part of a GitHub workflow.

This only happened after upgrading to azdev to v0.1.79 and on Windows runners. Mac and Linux were fine. Downgrading to v0.1.77 fixed the issue, so I guess there must be something on the recent changes...

Based on the logs below, I can see that azdev is trying to use the global Python interpreter at C:\hostedtoolcache\windows\Python\3.11.9\x64\python.exe instead of the one in the virtual environment, which is properly activated before running the command.

=============
| Run Tests |
=============

=====================
| Discovering Tests |
=====================

test index created: C:\Users\runneradmin\.azdev\env_config\a\...\env\test_index\latest.json

Test on modules: <extension_name>

The tests are set to run against current profile "latest"
C:\hostedtoolcache\windows\Python\3.11.9\x64\python.exe: No module named pytest
Error: Process completed with exit code 1.

Please feel free to re-open this issue if this is affecting others too.