Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 05-13-2020, 10:54 AM   #1
jgoguen
Generally Awesome Person
jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.jgoguen ought to be getting tired of karma fortunes by now.
 
Posts: 1,061
Karma: 2178845
Join Date: Jan 2013
Location: /dev/kmem
Device: Kobo Clara HD, Kindle Oasis
Unit testing calibre plugins

I just realized I can run arbitrary Python scripts through calibre-debug, which is finally allowing me to start writing some proper tests. There's a couple things I'm wondering about though. I'll be running everything on a Linux machine which I hope makes it all easier.



  • Is there some way I can tell calibre-debug to add extra paths to sys.path? Or do I need to append to sys.path in my Python unittest scripts? To mock objects in Python 2 I need to include extra ZIP files in sys.path and calibre-debug doesn't respect PYTHONPATH.
  • Is there a way I can change the language and encoding calibre uses? I need to run at least some tests using different languages and encodings, I run en_CA.UTF-8 but I want to also run tests in other languages (at least one with accented characters and one with a non-Latin alphabet, like Russian or Arabic) and encodings (US-ASCII, CP1252, possibly others).
  • Related to the above, is there a way I can tell calibre-debug to use a different location for its config and library directories for tests so I don't risk breaking my current configs and library by having calibre rapidly swap languages and encodings? Is it enough to set XDG_CONFIG_HOME to a temporary location and write out a minimal global.py.json setting library_path to a temporary directory?
  • Is there a way to tell calibre to load local versions of my plugin ZIPs instead of the ones in my config plugins directory? Does that just need me to write a minimal customize.py.json alongside global.py.json to reference my local build instead?
jgoguen is offline   Reply With Quote
Old 05-13-2020, 11:47 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,994
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
1) You append to sys.path

2, 3) See the various environment variables calibre uses, including controlling interface language and config directory
https://manual.calibre-ebook.com/cus...ment-variables
Note that binary builds of calibre from the python 3 betas onward always use UTF-8 regardless of environment variables.
For python 2 calibre things are more complicated, since there python's internal encoding selection mechanics are used.

4) Just create your own empyt config dir and tell calibre to use it via the env var above and then use calibre-customize -b to install your plugin into that config dir.
kovidgoyal is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre-server systemd socket unit example davidreads Server 1 01-10-2020 04:38 PM
Beta testing calibre 4 kovidgoyal Calibre 385 10-17-2019 03:15 AM
Calibre Companion connecting unit / computer jayp2013mobile Calibre Companion 23 03-03-2016 02:07 PM
Calibre Portable like the Calibre on PC (espec. settings and plugins)? manawydan Devices 6 01-23-2013 06:45 AM
Calibre has no choice on font size unit in css? naisren ePub 6 09-30-2012 09:41 AM


All times are GMT -4. The time now is 07:33 AM.


MobileRead.com is a privately owned, operated and funded community.