View Single Post
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,100
Karma: 2191133
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