Skip to content

Commit 68989a3

Browse files
committed
Add a dummy non-empty environment when using assert_python_{failure,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.
1 parent 5e320f5 commit 68989a3

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Changelog
88
.. that users understand how the changes affect the new version.
99
1010
11+
version 1.7.3
12+
-----------------
13+
+ Fix an issue where some tests failed because they ignored PYTHONPATH.
14+
1115
version 1.7.2
1216
-----------------
1317
+ Use upstream ISA-L version 2.31.1 which includes patches to make

tests/test_gzip_compliance.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,23 @@ def test_decompress_infile_outfile(self):
845845

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

848+
# The following tests use assert_python_failure or assert_python_ok.
849+
#
850+
# If the env_vars argument to assert_python_failure or assert_python_ok
851+
# is empty the test will run in isolated mode (-I) which means that the
852+
# PYTHONPATH environment variable will be ignored and the test fails
853+
# because the isal module can not be found, or the test is run usung the
854+
# system installed version of the module instead of the newly built
855+
# module that should be tested.
856+
#
857+
# By adding a dummy entry to the env_vars argument the isolated mode is
858+
# not used and the PYTHONPATH environment variable is not ignored and
859+
# the test works as expected.
860+
848861
def test_decompress_infile_outfile_error(self):
849862
rc, out, err = assert_python_failure('-m', 'isal.igzip', '-d',
850-
'thisisatest.out')
863+
'thisisatest.out',
864+
**{'_dummy': '1'})
851865
self.assertEqual(b"filename doesn't end in .gz: 'thisisatest.out'. "
852866
b"Cannot determine output filename.",
853867
err.strip())
@@ -872,7 +886,8 @@ def test_compress_infile_outfile_default(self):
872886
with open(local_testigzip, 'wb') as fp:
873887
fp.write(self.data)
874888

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

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

892907
rc, out, err = assert_python_ok('-m', 'isal.igzip',
893908
compress_level,
894-
local_testigzip)
909+
local_testigzip,
910+
**{'_dummy': '1'})
895911

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

902918
def test_compress_fast_best_are_exclusive(self):
903919
rc, out, err = assert_python_failure('-m', 'isal.igzip', '--fast',
904-
'--best')
920+
'--best', **{'_dummy': '1'})
905921
self.assertIn(
906922
b"error: argument -3/--best: not allowed with argument -0/--fast",
907923
err)
908924
self.assertEqual(out, b'')
909925

910926
def test_decompress_cannot_have_flags_compression(self):
911927
rc, out, err = assert_python_failure('-m', 'isal.igzip', '--fast',
912-
'-d')
928+
'-d', **{'_dummy': '1'})
913929
self.assertIn(
914930
b'error: argument -d/--decompress: not allowed with argument '
915931
b'-0/--fast',

0 commit comments

Comments
 (0)