@@ -804,6 +804,19 @@ def test_decompress_stdin_stdout(self):
804
804
self .assertEqual (err , b'' )
805
805
self .assertEqual (out , self .data )
806
806
807
+ # The following tests use assert_python_failure or assert_python_ok.
808
+ #
809
+ # If the env_vars argument to assert_python_failure or assert_python_ok
810
+ # is empty the test will run in isolated mode (-I) which means that the
811
+ # PYTHONPATH environment variable will be ignored and the test fails
812
+ # because the isal module can not be found, or the test is run usung the
813
+ # system installed version of the module instead of the newly built
814
+ # module that should be tested.
815
+ #
816
+ # By adding a dummy entry to the env_vars argument the isolated mode is
817
+ # not used and the PYTHONPATH environment variable is not ignored and
818
+ # the test works as expected.
819
+
807
820
@create_and_remove_directory (TEMPDIR )
808
821
def test_decompress_infile_outfile (self ):
809
822
gzipname = os .path .join (TEMPDIR , 'testgzip.gz' )
@@ -812,7 +825,7 @@ def test_decompress_infile_outfile(self):
812
825
with gzip .open (gzipname , mode = 'wb' ) as fp :
813
826
fp .write (self .data )
814
827
rc , out , err = assert_python_ok ('-m' , 'zlib_ng.gzip_ng' , '-d' ,
815
- gzipname )
828
+ gzipname , ** { '_dummy' : '1' } )
816
829
817
830
with open (os .path .join (TEMPDIR , "testgzip" ), "rb" ) as gunziped :
818
831
self .assertEqual (gunziped .read (), self .data )
@@ -824,7 +837,7 @@ def test_decompress_infile_outfile(self):
824
837
825
838
def test_decompress_infile_outfile_error (self ):
826
839
rc , out , err = assert_python_failure ('-m' , 'zlib_ng.gzip_ng' , '-d' ,
827
- 'thisisatest.out' )
840
+ 'thisisatest.out' , ** { '_dummy' : '1' } )
828
841
self .assertIn (b"filename doesn't end in .gz: 'thisisatest.out'" ,
829
842
err .strip ())
830
843
self .assertEqual (rc , 1 )
@@ -849,7 +862,7 @@ def test_compress_infile_outfile_default(self):
849
862
fp .write (self .data )
850
863
851
864
rc , out , err = assert_python_ok ('-m' , 'zlib_ng.gzip_ng' ,
852
- local_testgzip )
865
+ local_testgzip , ** { '_dummy' : '1' } )
853
866
854
867
self .assertTrue (os .path .exists (gzipname ))
855
868
self .assertEqual (out , b'' )
@@ -867,7 +880,8 @@ def test_compress_infile_outfile(self):
867
880
fp .write (self .data )
868
881
869
882
rc , out , err = assert_python_ok ('-m' , 'zlib_ng.gzip_ng' ,
870
- compress_level , local_testgzip )
883
+ compress_level , local_testgzip ,
884
+ ** {'_dummy' : '1' })
871
885
872
886
self .assertTrue (os .path .exists (gzipname ))
873
887
self .assertEqual (out , b'' )
@@ -877,15 +891,15 @@ def test_compress_infile_outfile(self):
877
891
878
892
def test_compress_fast_best_are_exclusive (self ):
879
893
rc , out , err = assert_python_failure ('-m' , 'zlib_ng.gzip_ng' , '--fast' ,
880
- '--best' )
894
+ '--best' , ** { '_dummy' : '1' } )
881
895
self .assertIn (
882
896
b"error: argument -9/--best: not allowed with argument -1/--fast" ,
883
897
err )
884
898
self .assertEqual (out , b'' )
885
899
886
900
def test_decompress_cannot_have_flags_compression (self ):
887
901
rc , out , err = assert_python_failure ('-m' , 'zlib_ng.gzip_ng' , '--fast' ,
888
- '-d' )
902
+ '-d' , ** { '_dummy' : '1' } )
889
903
self .assertIn (
890
904
b'error: argument -d/--decompress: not allowed with argument -1/--fast' ,
891
905
err )
0 commit comments