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():
|
def test_podofo():
|
||||||
import tempfile
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.ebooks.metadata.xmp import metadata_to_xmp_packet
|
from calibre.ebooks.metadata.xmp import metadata_to_xmp_packet
|
||||||
@ -179,19 +178,14 @@ def test_podofo():
|
|||||||
buf = BytesIO()
|
buf = BytesIO()
|
||||||
p.save_to_fileobj(buf)
|
p.save_to_fileobj(buf)
|
||||||
raw = buf.getvalue()
|
raw = buf.getvalue()
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
p = podofo.PDFDoc()
|
||||||
f.write(raw)
|
p.load(raw)
|
||||||
try:
|
if (p.title, p.author) != (mi.title, mi.authors[0]):
|
||||||
p = podofo.PDFDoc()
|
raise ValueError('podofo failed to set title and author in Info dict %s != %s' % (
|
||||||
p.open(f.name)
|
(p.title, p.author), (mi.title, mi.authors[0])))
|
||||||
if (p.title, p.author) != (mi.title, mi.authors[0]):
|
if not p.get_xmp_metadata():
|
||||||
raise ValueError('podofo failed to set title and author in Info dict %s != %s' % (
|
raise ValueError('podofo failed to write XMP packet')
|
||||||
(p.title, p.author), (mi.title, mi.authors[0])))
|
del p
|
||||||
if not p.get_xmp_metadata():
|
|
||||||
raise ValueError('podofo failed to write XMP packet')
|
|
||||||
del p
|
|
||||||
finally:
|
|
||||||
os.remove(f.name)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -43,19 +43,18 @@ static PyObject *
|
|||||||
PDFDoc_load(PDFDoc *self, PyObject *args) {
|
PDFDoc_load(PDFDoc *self, PyObject *args) {
|
||||||
char *buffer; Py_ssize_t size;
|
char *buffer; Py_ssize_t size;
|
||||||
|
|
||||||
if (PyArg_ParseTuple(args, BYTES_FMT, &buffer, &size)) {
|
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;
|
|
||||||
}
|
|
||||||
} else 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;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user