From 278d215bb02ee1b399946deb13b04bb762af4b1e Mon Sep 17 00:00:00 2001 From: milde Date: Fri, 23 Jun 2017 09:34:28 +0000 Subject: [PATCH] Add test for __version_info__, fix output of optional __version_details__. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8126 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/docutils/core.py | 6 ++++-- docutils/docutils/frontend.py | 6 ++++-- docutils/test/test__init__.py | 10 ++++++++++ docutils/tools/quicktest.py | 9 +++++---- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/docutils/docutils/core.py b/docutils/docutils/core.py index 7ba37706b..9199bc455 100644 --- a/docutils/docutils/core.py +++ b/docutils/docutils/core.py @@ -279,9 +279,11 @@ class Publisher: print >>self._stderr, ("""\ Exiting due to error. Use "--traceback" to diagnose. Please report errors to . -Include "--traceback" output, Docutils version (%s [%s]), +Include "--traceback" output, Docutils version (%s%s), Python version (%s), your OS type & version, and the -command line used.""" % (__version__, __version_details__, +command line used.""" % (__version__, + docutils.__version_details__ and + ' [%s]'%docutils.__version_details__ or '', sys.version.split()[0])) def report_SystemMessage(self, error): diff --git a/docutils/docutils/frontend.py b/docutils/docutils/frontend.py index 4036b3ba9..f5f7046cb 100644 --- a/docutils/docutils/frontend.py +++ b/docutils/docutils/frontend.py @@ -570,8 +570,10 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec): config_section = 'general' - version_template = ('%%prog (Docutils %s [%s], Python %s, on %s)' - % (docutils.__version__, docutils.__version_details__, + version_template = ('%%prog (Docutils %s%s, Python %s, on %s)' + % (docutils.__version__, + docutils.__version_details__ and + ' [%s]'%docutils.__version_details__ or '', sys.version.split()[0], sys.platform)) """Default version message.""" diff --git a/docutils/test/test__init__.py b/docutils/test/test__init__.py index 31c344340..78ac2ff7f 100644 --- a/docutils/test/test__init__.py +++ b/docutils/test/test__init__.py @@ -23,6 +23,16 @@ class ApplicationErrorTests(unittest.TestCase): err = docutils.ApplicationError(u'\u0169') self.assertEqual(unicode(err), u'\u0169') +class VersionInfoTests(unittest.TestCase): + + def test_version_info(self): + self.assertEqual(len(docutils.__version_info__), 6) + # self.assertEqual(type(docutils.__version_info__.major), int) + # self.assertEqual(type(docutils.__version_info__.minor), int) + # self.assertEqual(type(docutils.__version_info__.micro), int) + # self.assertEqual(type(docutils.__version_info__.releaselevel), str) + # self.assertEqual(type(docutils.__version_info__.serial), int) + # self.assertEqual(type(docutils.__version_info__.release), bool) if __name__ == '__main__': unittest.main() diff --git a/docutils/tools/quicktest.py b/docutils/tools/quicktest.py index 70df51ca4..527ceab10 100755 --- a/docutils/tools/quicktest.py +++ b/docutils/tools/quicktest.py @@ -142,9 +142,10 @@ def posixGetArgs(argv): usage() sys.exit() elif o in ['-V', '--version']: - sys.stderr.write('quicktest.py (Docutils %s [%s])\n' % - (docutils.__version__, - docutils.__version_details__)) + sys.stderr.write('quicktest.py (Docutils %s%s)\n' % + (docutils.__version__, + docutils.__version_details__ and + ' [%s]'%docutils.__version_details__ or '')) sys.exit() elif o in ['-r', '--rawxml']: outputFormat = 'rawxml' @@ -180,7 +181,7 @@ def macGetArgs(): EasyDialogs.Message("""\ Use the next dialog to build a command line: -1. Choose an output format from the [Option] list +1. Choose an output format from the [Option] list 2. Click [Add] 3. Choose an input file: [Add existing file...] 4. Save the output: [Add new file...] -- 2.11.4.GIT