[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.
This commit is contained in:
Ray Speth 2016-06-24 17:15:14 -04:00
parent c557fa84cd
commit 5fbe2303ca
2 changed files with 12 additions and 8 deletions

View file

@ -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)
]

View file

@ -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)