Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest.skip reporting error #438

Closed
Dr-Irv opened this issue Sep 30, 2020 · 12 comments
Closed

pytest.skip reporting error #438

Dr-Irv opened this issue Sep 30, 2020 · 12 comments
Labels
needs investigation Could be an issue - needs investigation

Comments

@Dr-Irv
Copy link

Dr-Irv commented Sep 30, 2020

Environment data

  • Language Server version: 2020.9.6
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7.5

Expected behaviour

No error

Actual behaviour

## Environment data

-   Language Server version: 2020.9.6
-   OS and version: Windows 10
-   Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7.5

reports

"skip" is not a known member of module

In another case, (can't reproduce with a small sample), I get the following:

Could not bind method "skip" because "_WithException[(msg: str = "", */, allow_module_level: bool = False) -> NoReturn, Type[Skipped]]" is not assignable to parameter "msg"
  "_WithException[(msg: str = "", */, allow_module_level: bool = False) -> NoReturn, Type[Skipped]]" is incompatible with "str"
@erictraut
Copy link
Contributor

Can you provide some sample code that demonstrates this problem? Or if that's not feasible, could you point to a file within a public repo? Without additional details, there's not much we can do with this.

@Dr-Irv
Copy link
Author

Dr-Irv commented Oct 1, 2020

Sorry, forgot to include the example:

import sys
import pytest

if not sys.platform.startswith("win"):
    pytest.skip("skipping windows-only tests", allow_module_level=True)

That produces the first error.

For the second error, if I put the file in a project by itself, I get the first error. Can't figure out what causes the second error.

@judej judej added the needs investigation Could be an issue - needs investigation label Oct 1, 2020
@github-actions github-actions bot removed the triage label Oct 1, 2020
@judej
Copy link
Contributor

judej commented Jan 13, 2021

@Dr-Irv, tried this and am able to get info on the skip symbol on the currently shipping version. Are you still seeing the problem?

image

@judej judej added waiting for user response Requires more information from user and removed needs investigation Could be an issue - needs investigation labels Jan 13, 2021
@Dr-Irv
Copy link
Author

Dr-Irv commented Jan 14, 2021

@judej with pylance 2021.1.1 I am still seeing the error where it reports:

"skip" is not a known member of module

@judej
Copy link
Contributor

judej commented Jan 14, 2021

Irv, I am using pytest 6.2.1 that I pip installed. Which version of pytest do you have?

@Dr-Irv
Copy link
Author

Dr-Irv commented Jan 14, 2021

@judej I have pytest 6.2.1 as well, installed via conda. Error occurs in environments with python 3.7 and python 3.8

@jakebailey jakebailey added needs investigation Could be an issue - needs investigation and removed waiting for user response Requires more information from user labels Jan 14, 2021
@judej
Copy link
Contributor

judej commented Jan 19, 2021

@Dr-Irv, could you please add the trace logs? Wondering if we are not looking at the right place for the conda provided libs.

@Dr-Irv
Copy link
Author

Dr-Irv commented Jan 19, 2021

Here's that output:

[Info  - 2:42:32 PM] Pylance language server 2021.1.1 (pyright 6a970b45) starting
[Info  - 2:42:32 PM] Server root directory: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist
[Error - 2:42:32 PM] stubPath c:\Code\Misc\pytypes\typings is not a valid directory.
[Info  - 2:43:20 PM] No configuration file found.
[Info  - 2:43:20 PM] Setting pythonPath for service "pytypes": "C:\Anaconda3\envs\base38\python.exe"
Search paths found for configured python interpreter:
  C:\Anaconda3\envs\base38\DLLs
  C:\Anaconda3\envs\base38\lib
  C:\Anaconda3\envs\base38
  C:\Anaconda3\envs\base38\lib\site-packages
  C:\Anaconda3\envs\base38\lib\site-packages\win32
  C:\Anaconda3\envs\base38\lib\site-packages\win32\lib
  C:\Anaconda3\envs\base38\lib\site-packages\Pythonwin
[Error - 2:43:20 PM] stubPath c:\Code\Misc\pytypes\typings is not a valid directory.
[Info  - 2:43:20 PM] Assuming Python version 3.8
[Info  - 2:43:20 PM] Assuming Python platform Windows
[Info  - 2:43:20 PM] Searching for source files
[Info  - 2:43:20 PM] Found 430 source files
Background analysis message: setConfigOptions
Background analysis message: setTrackedFiles
Background analysis message: markAllFilesDirty
Background analysis message: getSemanticTokens
[BG(1)] parsing: c:\Code\Misc\pytypes\pytest.py (14ms)
[BG(1)] parsing: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\builtins.pyi [fs read 1ms] (71ms)
[BG(1)] binding: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\builtins.pyi (21ms)
[BG(1)] binding: c:\Code\Misc\pytypes\pytest.py (1ms)
[BG(1)] parsing: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\sys.pyi [fs read 0ms] (8ms)
[BG(1)] binding: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\sys.pyi (3ms)
[BG(1)] parsing: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi [fs read 0ms] (11ms)
[BG(1)] binding: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (1ms)
[BG(1)] parsing: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\third_party\2and3\typing_extensions.pyi [fs read 0ms] (5ms)
[BG(1)] binding: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\third_party\2and3\typing_extensions.pyi (0ms)
[BG(1)] parsing: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\typing.pyi [fs read 1ms] (21ms)
[BG(1)] binding: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\typing.pyi (6ms)
Background analysis message: analyze
[BG(1)] analyzing: c:\Code\Misc\pytypes\pytest.py ...
[BG(1)]   checking: c:\Code\Misc\pytypes\pytest.py (2ms)
[BG(1)] analyzing: c:\Code\Misc\pytypes\pytest.py (2ms)
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
[FG] parsing: c:\Code\Misc\pytypes\pytest.py (17ms)
[FG] parsing: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\builtins.pyi [fs read 2ms] (186ms)
[FG] binding: c:\Users\irv\.vscode\extensions\ms-python.vscode-pylance-2021.1.1\dist\typeshed-fallback\stdlib\3\builtins.pyi (34ms)
[FG] binding: c:\Code\Misc\pytypes\pytest.py (0ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: setFileClosed
Background analysis message: analyze
Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
[FG] parsing: c:\Code\Misc\pytypes\pytest.py (0ms)
[FG] binding: c:\Code\Misc\pytypes\pytest.py (1ms)
Background analysis message: getSemanticTokens
[BG(1)] parsing: c:\Code\Misc\pytypes\pytest.py (0ms)
[BG(1)] binding: c:\Code\Misc\pytypes\pytest.py (0ms)
Background analysis message: analyze
[BG(1)] analyzing: c:\Code\Misc\pytypes\pytest.py ...
[BG(1)]   checking: c:\Code\Misc\pytypes\pytest.py (0ms)
[BG(1)] analyzing: c:\Code\Misc\pytypes\pytest.py (0ms)
Background analysis message: resumeAnalysis
Background analysis message: setFileClosed
Background analysis message: analyze
Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
[FG] parsing: c:\Code\Misc\pytypes\pytest.py (0ms)
[FG] binding: c:\Code\Misc\pytypes\pytest.py (1ms)
Background analysis message: getSemanticTokens
[BG(1)] parsing: c:\Code\Misc\pytypes\pytest.py (0ms)
[BG(1)] binding: c:\Code\Misc\pytypes\pytest.py (0ms)
Background analysis message: analyze
[BG(1)] analyzing: c:\Code\Misc\pytypes\pytest.py ...
[BG(1)]   checking: c:\Code\Misc\pytypes\pytest.py (0ms)
[BG(1)] analyzing: c:\Code\Misc\pytypes\pytest.py (0ms)
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange

@jakebailey
Copy link
Member

Weird, it's not looking for pytest at all. Now that I read the output, the name of your file is the same as the name of the pytest module itself, and in an import would be picked up first (as the workspace is an import root before any others). If you rename the file to something else (may need a reload), do things change?

@Dr-Irv
Copy link
Author

Dr-Irv commented Jan 19, 2021

Renaming it made the problem go away. But I guess that is a bug to be fixed?

@jakebailey
Copy link
Member

jakebailey commented Jan 19, 2021

I don't really see that as a bug... If the module name is pytest, then we're going to see that as the module pytest as it effectively appears in sys.path by nature of it being an import root. The same thing could happen to any module, and we've seen in the past people get bitten by this by naming a module "random.py" or similar and getting odd behavior.

Does the code you write run? Does a module like this actually exist somewhere, or was it a cut down example for testing?

(Moderately related is #253; we effectively assume everything is a module as it's difficult to say that any one file will be a script and will be treated differently.)

@Dr-Irv
Copy link
Author

Dr-Irv commented Jan 19, 2021

It was a cut down example for testing. But I'm pretty sure that the original code that I had used (from a client - I don't have access any more to it) was showing the same error. Glad we have resolved it.

@judej judej closed this as completed Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Could be an issue - needs investigation
Projects
None yet
Development

No branches or pull requests

4 participants