kondratyev-nv / vscode-python-test-adapter

Python Test Adapter for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=LittleFoxTeam.vscode-python-test-adapter
MIT License
117 stars 27 forks source link

In a workspace, exclude folders without tests #262

Closed GuillaumeDesforges closed 1 year ago

GuillaumeDesforges commented 2 years ago

I work using a workspace in VSCode. Some folders in that workspace use Python, some do not, but I end up with

image please do not mind the mocka error

The error in failing items:

ArgumentError: argument -p/--pattern: expected one argument

but since there is no Python package in those folders, I do not care and want to hide them.

How can I exclude folders in a workspace to not be displayed by this extension? Thanks

kondratyev-nv commented 2 years ago

@GuillaumeDesforges Thank you for the issue. Test discovery is enabled only when any of the properties is set - python.testing.unittestEnabled, python.testing.pyTestEnabled, or pythonTestExplorer.testFramework. If you don't need to discover Python tests in those workspace folders, just make sure these setting are set to default values (false, false, null respectively). Notice that if you haven't set those settings for these folders, it's possible that you've set them globally.

GuillaumeDesforges commented 2 years ago

Hi @kondratyev-nv , thanks for your reply.

I checked that those settings are just set in the appropriate folder with actual Python tests to run, the other ones still appear. I tried setting those settings to false/null in the other folders, but they still appear.

kondratyev-nv commented 2 years ago

@GuillaumeDesforges I've double-checked the issue. In my configuration, I have a workspace with 3 folders for different languages. Python tests are discovered only in a folder with appropriate settings (python.testing.unittestEnabled and python.testing.unittestArgs). No tests or errors from other folders. I can see the similar issue after doing 2 steps:

  1. Add "python.testing.unittestEnabled": true to a folder with no Python tests. (Does not break anything though)
  2. Modifying "python.testing.unittestArgs" to contain invalid -p option. For example,
    "python.testing.unittestArgs": [
    "-v",
    "-s",
    ".",
    "-p"
    ]

    Only in that case do I see ArgumentError: argument -p/--pattern: expected one argument. Which totally makes sense.

You can try sharing some reproducible examples for me to confirm. But right now I assume that there is something wrong with your configuration (either System, User, Workspace, or Folder). You can check all possible options in Settings UI (at the top of the panel). Also, it shouldn't be required, but you can try to restart VSCode after updating those setting.

kondratyev-nv commented 2 years ago

@GuillaumeDesforges Ok, somehow I reproduced this in #266. I think in my case default setting were cached or something. The reason for the error is that the default settings for unittest were broken in the Python extension. I'll see how to fix this, but as a quick fix, I can suggest actually adding "python.testing.unittestArgs": [] to the settings. Let me know if this helps!

GuillaumeDesforges commented 2 years ago

Glad there was an update!

I'm sorry I'm not very available right now to test, I'll come back to it when possible. Thanks for your patience.

GuillaumeDesforges commented 1 year ago

Sorry for the delay, looks good to me. Thanks