mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
See if not using a temp file fixes the weird test failure on travis
This commit is contained in:
parent
b4a8771232
commit
470e6b56fe
@ -163,7 +163,6 @@ def test_save_to(src, dest):
|
||||
|
||||
|
||||
def test_podofo():
|
||||
import tempfile
|
||||
from io import BytesIO
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.ebooks.metadata.xmp import metadata_to_xmp_packet
|
||||
@ -179,19 +178,14 @@ def test_podofo():
|
||||
buf = BytesIO()
|
||||
p.save_to_fileobj(buf)
|
||||
raw = buf.getvalue()
|
||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||
f.write(raw)
|
||||
try:
|
||||
p = podofo.PDFDoc()
|
||||
p.open(f.name)
|
||||
if (p.title, p.author) != (mi.title, mi.authors[0]):
|
||||
raise ValueError('podofo failed to set title and author in Info dict %s != %s' % (
|
||||
(p.title, p.author), (mi.title, mi.authors[0])))
|
||||
if not p.get_xmp_metadata():
|
||||
raise ValueError('podofo failed to write XMP packet')
|
||||
del p
|
||||
finally:
|
||||
os.remove(f.name)
|
||||
p = podofo.PDFDoc()
|
||||
p.load(raw)
|
||||
if (p.title, p.author) != (mi.title, mi.authors[0]):
|
||||
raise ValueError('podofo failed to set title and author in Info dict %s != %s' % (
|
||||
(p.title, p.author), (mi.title, mi.authors[0])))
|
||||
if not p.get_xmp_metadata():
|
||||
raise ValueError('podofo failed to write XMP packet')
|
||||
del p
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -43,19 +43,18 @@ static PyObject *
|
||||
PDFDoc_load(PDFDoc *self, PyObject *args) {
|
||||
char *buffer; Py_ssize_t size;
|
||||
|
||||
if (PyArg_ParseTuple(args, BYTES_FMT, &buffer, &size)) {
|
||||
try {
|
||||
#if PODOFO_VERSION <= 0x000905
|
||||
self->doc->Load(buffer, (long)size);
|
||||
#else
|
||||
self->doc->LoadFromBuffer(buffer, (long)size);
|
||||
#endif
|
||||
} catch(const PdfError & err) {
|
||||
podofo_set_exception(err);
|
||||
return NULL;
|
||||
}
|
||||
} else return NULL;
|
||||
if (!PyArg_ParseTuple(args, BYTES_FMT, &buffer, &size)) return NULL;
|
||||
|
||||
try {
|
||||
#if PODOFO_VERSION <= 0x000905
|
||||
self->doc->Load(buffer, (long)size);
|
||||
#else
|
||||
self->doc->LoadFromBuffer(buffer, (long)size);
|
||||
#endif
|
||||
} catch(const PdfError & err) {
|
||||
podofo_set_exception(err);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user