@@ -107,21 +107,6 @@ def test_repeatable_options(self):
107107 self .assertTrue (test_command [idx3 + 1 ] == 'test_cookie2' )
108108 self .assertTrue (test_command [idx3 + 2 ] == 'cookie_value2' )
109109
110- def test_empty_cookie_value (self ):
111- roptions = {
112- '--page-size' : 'Letter' ,
113- 'cookies' : [
114- ('test_cookie1' ,'' ),
115- ('test_cookie2' ,'cookie_value2' ),
116- ]
117- }
118-
119- r = pdfkit .PDFKit ('html' , 'string' , options = roptions )
120-
121- test_command = r .command ('test' )
122-
123- self .assertTrue (test_command [idx1 + 1 ] == 'Letter' )
124-
125110 def test_custom_configuration (self ):
126111 conf = pdfkit .configuration ()
127112 self .assertEqual ('pdfkit-' , conf .meta_tag_prefix )
@@ -435,5 +420,31 @@ def test_issue_42_encode_file_with_unicode_char(self):
435420 output = r .to_pdf ()
436421 self .assertEqual (output [:4 ].decode ('utf-8' ), '%PDF' )
437422
423+ def test_issue_140_empty_cookie_value (self ):
424+ roptions_bad = {
425+ '--page-size' : 'Letter' ,
426+ 'cookie' : [
427+ ('test_cookie1' ,'' ),
428+ ('test_cookie2' ,'cookie_value2' ),
429+ ]
430+ }
431+
432+ roptions_good = {
433+ '--page-size' : 'Letter' ,
434+ 'cookie' : [
435+ ('test_cookie1' ,'""' ),
436+ ('test_cookie2' ,'cookie_value2' ),
437+ ]
438+ }
439+
440+ r1 = pdfkit .PDFKit ('html' , 'string' , options = roptions_bad )
441+
442+ self .assertRaises (AssertionError , r1 .to_pdf )
443+
444+ r2 = pdfkit .PDFKit ('html' , 'string' , options = roptions_good )
445+ output2 = r2 .to_pdf ()
446+
447+ self .assertEqual (output2 [:4 ].decode ('utf-8' ), '%PDF' )
448+
438449if __name__ == "__main__" :
439450 unittest .main ()
0 commit comments