comparison roundup/configuration.py @ 6363:08e209a7f22b

Use OptionValueError for indexer_language error, add configuration tests Added more tests for configuration.py. This is the last of the easy to do tests for the module. While doing that figured out how to get the proper arguments to generate OptionValueError if indexer_language is invalid. Changed implementation to generate same and updated test.
author John Rouillard <rouilj@ieee.org>
date Tue, 30 Mar 2021 18:03:37 -0400
parents 42db48c30d31
children 1f2f7c0b8968
comparison
equal deleted inserted replaced
6362:5f0463897afc 6363:08e209a7f22b
1879 import textwrap 1879 import textwrap
1880 lang_avail = b2s(xapian.Stem.get_available_languages()) 1880 lang_avail = b2s(xapian.Stem.get_available_languages())
1881 languages = textwrap.fill(_("Valid languages: ") + 1881 languages = textwrap.fill(_("Valid languages: ") +
1882 lang_avail, 75, 1882 lang_avail, 75,
1883 subsequent_indent=" ") 1883 subsequent_indent=" ")
1884 raise ValueError( 1884 raise OptionValueError( options["INDEXER_LANGUAGE"],
1885 _("Invalid indexer_language '%(lang)s' in config.ini for xapian indexer\n\n" 1885 lang, languages)
1886 "%(valid)s") % {
1887 "lang": lang,
1888 "valid": languages
1889 }
1890 )
1891 1886
1892 def load(self, home_dir): 1887 def load(self, home_dir):
1893 """Load configuration from path designated by home_dir argument""" 1888 """Load configuration from path designated by home_dir argument"""
1894 if os.path.isfile(os.path.join(home_dir, self.INI_FILE)): 1889 if os.path.isfile(os.path.join(home_dir, self.INI_FILE)):
1895 self.load_ini(home_dir) 1890 self.load_ini(home_dir)

Roundup Issue Tracker: http://roundup-tracker.org/