Skip to content

Commit a848001

Browse files
committed
update test for issue 140
1 parent ee1a7bc commit a848001

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

tests/pdfkit-tests.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
438449
if __name__ == "__main__":
439450
unittest.main()

0 commit comments

Comments
 (0)