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

test: do not compare sys.path in test executions #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

keszybz
Copy link

@keszybz keszybz commented Jun 10, 2024

That test is fragile and fails in various ways, depending on how the tests are invoked. Instead assume that if the program is started correctly, $PYTHONPATH was set appropriately.

For example:

___ TestCommandLine.test_module_execution_details[pyinstrument_invocation0] ____ ...
E       AssertionError: assert '__name__ __m...n_details_0\n' == '__name__ __m...n_details_0\n'
E           __name__ __main__
E           sys.argv ['/tmp/pytest-of-mockbuild/pytest-1/test_module_execution_details_0/test_module/__main__.py', 'arg1', 'arg2']
E         - sys.path ['/tmp/pytest-of-mockbuild/pytest-1/test_module_execution_details_0',
                      '/builddir/build/BUILD/pyinstrument-4.6.2-build/BUILDROOT/usr/lib64/python3.12/site-packages',
                      '/builddir/build/BUILD/pyinstrument-4.6.2-build/BUILDROOT/usr/lib/python3.12/site-packages',
                      '/usr/lib64/python312.zip', '/usr/lib64/python3.12', '/usr/lib64/python3.12/lib-dynload',
                      '/usr/lib64/python3.12/site-packages', '/usr/lib/python3.12/site-packages']

With this patch, tests pass with the standard Fedora Linux invocation of pytest on the package installed in a temporary installation directory.

That test is fragile and fails in various ways, depending on how the tests are invoked.
Instead assume that if the program is started correctly, $PYTHONPATH was set appropriately.

For example:
___ TestCommandLine.test_module_execution_details[pyinstrument_invocation0] ____
...
E       AssertionError: assert '__name__ __m...n_details_0\n' == '__name__ __m...n_details_0\n'
E           __name__ __main__
E           sys.argv ['/tmp/pytest-of-mockbuild/pytest-1/test_module_execution_details_0/test_module/__main__.py', 'arg1', 'arg2']
E         - sys.path ['/tmp/pytest-of-mockbuild/pytest-1/test_module_execution_details_0',
                      '/builddir/build/BUILD/pyinstrument-4.6.2-build/BUILDROOT/usr/lib64/python3.12/site-packages',
                      '/builddir/build/BUILD/pyinstrument-4.6.2-build/BUILDROOT/usr/lib/python3.12/site-packages',
                      '/usr/lib64/python312.zip', '/usr/lib64/python3.12', '/usr/lib64/python3.12/lib-dynload',
                      '/usr/lib64/python3.12/site-packages', '/usr/lib/python3.12/site-packages']

With this patch, tests pass with the standard Fedora Linux invocation of pytest
on the package installed in a temporary installation directory.
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

Successfully merging this pull request may close these issues.

None yet

1 participant