Skip to content

Add a dummy non-empty environment when using assert_python_{failure,ok} #227

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

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Changelog
.. that users understand how the changes affect the new version.


version 1.7.3
-----------------
+ Fix an issue where some tests failed because they ignored PYTHONPATH.

version 1.7.2
-----------------
+ Use upstream ISA-L version 2.31.1 which includes patches to make
Expand Down
26 changes: 21 additions & 5 deletions tests/test_gzip_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,23 @@ def test_decompress_infile_outfile(self):

self.assertTrue(os.path.exists(igzipname))

# The following tests use assert_python_failure or assert_python_ok.
#
# If the env_vars argument to assert_python_failure or assert_python_ok
# is empty the test will run in isolated mode (-I) which means that the
# PYTHONPATH environment variable will be ignored and the test fails
# because the isal module can not be found, or the test is run usung the
# system installed version of the module instead of the newly built
# module that should be tested.
#
# By adding a dummy entry to the env_vars argument the isolated mode is
# not used and the PYTHONPATH environment variable is not ignored and
# the test works as expected.

def test_decompress_infile_outfile_error(self):
rc, out, err = assert_python_failure('-m', 'isal.igzip', '-d',
'thisisatest.out')
'thisisatest.out',
**{'_dummy': '1'})
self.assertEqual(b"filename doesn't end in .gz: 'thisisatest.out'. "
b"Cannot determine output filename.",
err.strip())
Expand All @@ -872,7 +886,8 @@ def test_compress_infile_outfile_default(self):
with open(local_testigzip, 'wb') as fp:
fp.write(self.data)

rc, out, err = assert_python_ok('-m', 'isal.igzip', local_testigzip)
rc, out, err = assert_python_ok('-m', 'isal.igzip', local_testigzip,
**{'_dummy': '1'})

self.assertTrue(os.path.exists(igzipname))
self.assertEqual(out, b'')
Expand All @@ -891,7 +906,8 @@ def test_compress_infile_outfile(self):

rc, out, err = assert_python_ok('-m', 'isal.igzip',
compress_level,
local_testigzip)
local_testigzip,
**{'_dummy': '1'})

self.assertTrue(os.path.exists(igzipname))
self.assertEqual(out, b'')
Expand All @@ -901,15 +917,15 @@ def test_compress_infile_outfile(self):

def test_compress_fast_best_are_exclusive(self):
rc, out, err = assert_python_failure('-m', 'isal.igzip', '--fast',
'--best')
'--best', **{'_dummy': '1'})
self.assertIn(
b"error: argument -3/--best: not allowed with argument -0/--fast",
err)
self.assertEqual(out, b'')

def test_decompress_cannot_have_flags_compression(self):
rc, out, err = assert_python_failure('-m', 'isal.igzip', '--fast',
'-d')
'-d', **{'_dummy': '1'})
self.assertIn(
b'error: argument -d/--decompress: not allowed with argument '
b'-0/--fast',
Expand Down