From 5fbe2303ca8737535462bdb66f279dab56ea038b Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 24 Jun 2016 17:15:14 -0400 Subject: [PATCH] [Python] Fix test suite to work with Python 3.2 The u'foo' syntax which can be used in Python 2.7 and 3.3+ does not work with Python 3.2. --- doc/sphinx/conf.py | 12 ++++++------ interfaces/cython/cantera/test/test_thermo.py | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py index 3fc5176a1..41499ffc9 100644 --- a/doc/sphinx/conf.py +++ b/doc/sphinx/conf.py @@ -76,8 +76,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'Cantera' -copyright = u'2016, Cantera Developers' +project = 'Cantera' +copyright = '2016, Cantera Developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -218,8 +218,8 @@ htmlhelp_basename = 'Canteradoc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'Cantera.tex', u'Cantera Documentation', - u'Cantera Developers', 'manual'), + ('index', 'Cantera.tex', 'Cantera Documentation', + 'Cantera Developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -251,6 +251,6 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'cantera', u'Cantera Documentation', - [u'Cantera Developers'], 1) + ('index', 'cantera', 'Cantera Documentation', + ['Cantera Developers'], 1) ] diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 0cbb58cfc..beda40f49 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -27,7 +27,9 @@ class TestThermoPhase(utilities.CanteraTest): def test_n_atoms(self): data = [(1, 'O', 'O'), (2, 'O', 'O2'), (1, b'H', b'OH'), - (2, 'H', 'H2O'), (2, u'O', u'H2O2'), (1, 'Ar', 'AR'), + # disabled to preserve support for Python 3.2 + # (2, 'H', 'H2O'), (2, u'O', u'H2O2'), (1, 'Ar', 'AR'), + (2, 'H', 'H2O'), (2, 'O', 'H2O2'), (1, 'Ar', 'AR'), (0, 'O', 'H'), (0, 'H', 'AR'), (0, 'Ar', 'HO2')] for (n, elem, species) in data: self.assertEqual(self.phase.n_atoms(species, elem), n) @@ -143,7 +145,9 @@ class TestThermoPhase(utilities.CanteraTest): self.assertNear(X[0], 0.25) self.assertNear(X[3], 0.75) - self.phase.Y = {u'H2':1.0, u'O2':3.0} + # Change back to u'xx' syntax when support for Python 3.2 is dropped + #self.phase.Y = {u'H2':1.0, u'O2':3.0} + self.phase.Y = {'H2':1.0, 'O2':3.0} Y = self.phase.Y self.assertNear(Y[0], 0.25) self.assertNear(Y[3], 0.75)