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 issues #383

Open
johnlabarge opened this issue Jan 26, 2024 · 1 comment
Open

Pytest issues #383

johnlabarge opened this issue Jan 26, 2024 · 1 comment

Comments

@johnlabarge
Copy link

Just started a new project and I'm getting all kinds of colorama test failures from pytest:
lib/python3.11/site-packages/pip/_vendor/colorama/tests/ansitowin32_test.py::AnsiToWin32Test::test_native_windows_ansi - AssertionError: expected call not found.
FAILED lib/python3.11/site-packages/pip/_vendor/colorama/tests/ansitowin32_test.py::AnsiToWin32Test::test_osc_codes - AttributeError: 'NoneType' object has no attribute 'set_title'
FAILED lib/python3.11/site-packages/pip/_vendor/colorama/tests/winterm_test.py::WinTermTest::testInit - AttributeError: module 'pip._vendor.colorama.win32' has no attribute 'G...
FAILED lib/python3.11/site-packages/pip/_vendor/colorama/tests/winterm_test.py::WinTermTest::testResetAll - AttributeError: module 'pip._vendor.colorama.win32' has no attribute 'G...
FAILED lib/python3.11/site-packages/pip/_vendor/colorama/tests/winterm_test.py::WinTermTest::testSetConsole - AttributeError: module 'pip._vendor.colorama.win32' has no attribute 'G...
FAILED lib/python3.11/site-packages/pip/_vendor/colorama/tests/winterm_test.py::WinTermTest::testSetConsoleOnStderr - AttributeError: module 'pip._vendor.colorama.win32' has no attribute 'G...

Not sure how to fix these.
Python 3.11.7,
iniconfig==2.0.0
packaging==23.2
pluggy==1.4.0
pytest==7.4.4
PyYAML==6.0.1

@wiggin15
Copy link
Collaborator

This looks like (at least partly) a problem of running the unittests of colorama on the copy of colorama that's bundled with "pip", which is not intended. For example, the tests "mock" some parts of colorama using calls like patch('colorama.ansitowin32.winterm') but in this case the path to colorama is actually pip._vendor.colorama.ansitowin32.winterm.

I suggest trying to avoid calling tests of external packages that are not part of your project, like pip or colorama. You can do this by either making sure your virtualenv (where the dependencies are installed) is located outside of your project root directory, or configuring "pytest" to exclude directories that are not part of your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants