Skip to content

Commit 346980f

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 346980f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ def test_decompress_infile_outfile(self):
847847

848848
def test_decompress_infile_outfile_error(self):
849849
rc, out, err = assert_python_failure('-m', 'isal.igzip', '-d',
850-
'thisisatest.out')
850+
'thisisatest.out',
851+
**{'_dummy': '1'})
851852
self.assertEqual(b"filename doesn't end in .gz: 'thisisatest.out'. "
852853
b"Cannot determine output filename.",
853854
err.strip())
@@ -872,7 +873,8 @@ def test_compress_infile_outfile_default(self):
872873
with open(local_testigzip, 'wb') as fp:
873874
fp.write(self.data)
874875

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

877879
self.assertTrue(os.path.exists(igzipname))
878880
self.assertEqual(out, b'')
@@ -891,7 +893,8 @@ def test_compress_infile_outfile(self):
891893

892894
rc, out, err = assert_python_ok('-m', 'isal.igzip',
893895
compress_level,
894-
local_testigzip)
896+
local_testigzip,
897+
**{'_dummy': '1'})
895898

896899
self.assertTrue(os.path.exists(igzipname))
897900
self.assertEqual(out, b'')
@@ -901,15 +904,15 @@ def test_compress_infile_outfile(self):
901904

902905
def test_compress_fast_best_are_exclusive(self):
903906
rc, out, err = assert_python_failure('-m', 'isal.igzip', '--fast',
904-
'--best')
907+
'--best', **{'_dummy': '1'})
905908
self.assertIn(
906909
b"error: argument -3/--best: not allowed with argument -0/--fast",
907910
err)
908911
self.assertEqual(out, b'')
909912

910913
def test_decompress_cannot_have_flags_compression(self):
911914
rc, out, err = assert_python_failure('-m', 'isal.igzip', '--fast',
912-
'-d')
915+
'-d', **{'_dummy': '1'})
913916
self.assertIn(
914917
b'error: argument -d/--decompress: not allowed with argument '
915918
b'-0/--fast',

0 commit comments

Comments
 (0)