Skip to content

Commit c4e62cd

Browse files
authored
Fix generate_metadata_table and add test. (#80)
* Fix generate_metadata_table and add test. * remove python 2.7 from travis.yml
1 parent c3751de commit c4e62cd

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ git:
2727
depth: false
2828

2929
python:
30-
- '2.7'
3130
- '3.6'
3231

3332
sudo: true

essm/variables/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def generate_metadata_table(variables=None, include_header=True, cols=None):
8080
name = str(variable)
8181
doc = variable.__doc__
8282
defn1 = Variable.__expressions__.get(variable, '')
83-
if len(defn1) > 1:
83+
if len(str(defn1)) > 1:
8484
defn = '$' + latex(defn1) + '$'
8585
else:
8686
defn = ''

tests/test_variables.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ def test_markdown():
170170

171171
def test_generate_metadata_table():
172172
"""Check display of table of units."""
173-
assert generate_metadata_table([E_l, lambda_E]) \
173+
assert generate_metadata_table([demo_expression_variable, E_l, lambda_E]) \
174174
== [('Symbol', 'Name', 'Description', 'Definition', 'Default value',
175175
'Units'),
176176
('$\\lambda_E$', 'lambda_E', 'Latent heat of evaporation.', '',
177-
'2450000.0', 'J kg$^{-1}$'), ('$E_l$', 'E_l',
177+
'2450000.0', 'J kg$^{-1}$'),
178+
('$demo_expression_variable$', 'demo_expression_variable',
179+
'Test expression variable.', '$2 demo_variable$', '-', 'm'),
180+
('$E_l$', 'E_l',
178181
'Latent heat flux from leaf.', '', '-', 'J s$^{-1}$ m$^{-2}$')]

0 commit comments

Comments
 (0)