@@ -350,8 +350,9 @@ def test_metadata(self):
350350 self .assertEqual (cmByte , b'\x08 ' ) # deflate
351351
352352 try :
353- expectedname = self .filename .encode ('Latin-1' ) + b'\x00 '
354- expectedflags = b'\x08 ' # only the FNAME flag is set
353+ expectedname = os .path .basename (self .filename ).encode (
354+ 'Latin-1' ) + b'\x00 '
355+ expectedflags = b'\x08 ' # only the FNAME flag is set
355356 except UnicodeEncodeError :
356357 expectedname = b''
357358 expectedflags = b'\x00 '
@@ -778,7 +779,7 @@ def create_and_remove_directory(directory):
778779 def decorator (function ):
779780 @functools .wraps (function )
780781 def wrapper (* args , ** kwargs ):
781- os .makedirs (directory )
782+ os .makedirs (directory , exist_ok = True )
782783 try :
783784 return function (* args , ** kwargs )
784785 finally :
@@ -795,7 +796,7 @@ def test_decompress_stdin_stdout(self):
795796 with gzip .GzipFile (fileobj = bytes_io , mode = 'wb' ) as gzip_file :
796797 gzip_file .write (self .data )
797798
798- args = sys .executable , '-m' , 'gzip ' , '-d'
799+ args = sys .executable , '-m' , 'zlib_ng.gzip_ng ' , '-d'
799800 with Popen (args , stdin = PIPE , stdout = PIPE , stderr = PIPE ) as proc :
800801 out , err = proc .communicate (bytes_io .getvalue ())
801802
@@ -809,7 +810,7 @@ def test_decompress_infile_outfile(self):
809810
810811 with gzip .open (gzipname , mode = 'wb' ) as fp :
811812 fp .write (self .data )
812- rc , out , err = assert_python_ok ('-m' , 'gzip ' , '-d' , gzipname )
813+ rc , out , err = assert_python_ok ('-m' , 'zlib_ng.gzip_ng ' , '-d' , gzipname )
813814
814815 with open (os .path .join (TEMPDIR , "testgzip" ), "rb" ) as gunziped :
815816 self .assertEqual (gunziped .read (), self .data )
@@ -820,14 +821,14 @@ def test_decompress_infile_outfile(self):
820821 self .assertEqual (err , b'' )
821822
822823 def test_decompress_infile_outfile_error (self ):
823- rc , out , err = assert_python_failure ('-m' , 'gzip ' , '-d' , 'thisisatest.out' )
824- self .assertEqual (b"filename doesn't end in .gz: 'thisisatest.out'" , err .strip ())
824+ rc , out , err = assert_python_failure ('-m' , 'zlib_ng.gzip_ng ' , '-d' , 'thisisatest.out' )
825+ self .assertIn (b"filename doesn't end in .gz: 'thisisatest.out'" , err .strip ())
825826 self .assertEqual (rc , 1 )
826827 self .assertEqual (out , b'' )
827828
828829 @create_and_remove_directory (TEMPDIR )
829830 def test_compress_stdin_outfile (self ):
830- args = sys .executable , '-m' , 'gzip '
831+ args = sys .executable , '-m' , 'zlib_ng.gzip_ng '
831832 with Popen (args , stdin = PIPE , stdout = PIPE , stderr = PIPE ) as proc :
832833 out , err = proc .communicate (self .data )
833834
@@ -843,7 +844,7 @@ def test_compress_infile_outfile_default(self):
843844 with open (local_testgzip , 'wb' ) as fp :
844845 fp .write (self .data )
845846
846- rc , out , err = assert_python_ok ('-m' , 'gzip ' , local_testgzip )
847+ rc , out , err = assert_python_ok ('-m' , 'zlib_ng.gzip_ng ' , local_testgzip )
847848
848849 self .assertTrue (os .path .exists (gzipname ))
849850 self .assertEqual (out , b'' )
@@ -860,7 +861,7 @@ def test_compress_infile_outfile(self):
860861 with open (local_testgzip , 'wb' ) as fp :
861862 fp .write (self .data )
862863
863- rc , out , err = assert_python_ok ('-m' , 'gzip ' , compress_level , local_testgzip )
864+ rc , out , err = assert_python_ok ('-m' , 'zlib_ng.gzip_ng ' , compress_level , local_testgzip )
864865
865866 self .assertTrue (os .path .exists (gzipname ))
866867 self .assertEqual (out , b'' )
@@ -869,13 +870,13 @@ def test_compress_infile_outfile(self):
869870 self .assertFalse (os .path .exists (gzipname ))
870871
871872 def test_compress_fast_best_are_exclusive (self ):
872- rc , out , err = assert_python_failure ('-m' , 'gzip ' , '--fast' , '--best' )
873- self .assertIn (b"error: argument -- best: not allowed with argument --fast" , err )
873+ rc , out , err = assert_python_failure ('-m' , 'zlib_ng.gzip_ng ' , '--fast' , '--best' )
874+ self .assertIn (b"error: argument -9/-- best: not allowed with argument -1/ --fast" , err )
874875 self .assertEqual (out , b'' )
875876
876877 def test_decompress_cannot_have_flags_compression (self ):
877- rc , out , err = assert_python_failure ('-m' , 'gzip ' , '--fast' , '-d' )
878- self .assertIn (b'error: argument -d/--decompress: not allowed with argument --fast' , err )
878+ rc , out , err = assert_python_failure ('-m' , 'zlib_ng.gzip_ng ' , '--fast' , '-d' )
879+ self .assertIn (b'error: argument -d/--decompress: not allowed with argument -1/- -fast' , err )
879880 self .assertEqual (out , b'' )
880881
881882
0 commit comments