Skip to content

feature/capgen: var.get_prop_value is not returning the correct value for optional variable properties are not  #509

@climbfuji

Description

@climbfuji

Description

When querying the value of an optional property from a variable that is set for the variable (therefore assuming the default function or value) and that has a default value (not a default function, these are mutually exclusive), the code returns None instead of the default value. An example is the active attribute, where the default value is .true..

Steps to Reproduce

I've added doctests for this to scripts/metavar.py in PR #508. If you remove the bug fix in (old code) line 499 / (new code) line 505, the doctests fail (cd scripts && python3 -m doctest metavar.py).

Additional Context

n/a

Output

Without the bug fix in line 409 / 505:

$ python3 -m doctest  metavar.py
**********************************************************************
File "/Users/heinzell/work/ccpp-framework/ccpp-framework-feature-capgen-fix-optional-varprop-default-val/scripts/metavar.py", line 123, in metavar.Var
Failed example:
    Var({'local_name' : 'foo', 'standard_name' : 'hi_mom', 'units' : 'm s-1', 'dimensions' : '()', 'type' : 'real', 'intent' : 'in'}, ParseSource('vname', 'DDT', ParseContext()), _MVAR_DUMMY_RUN_ENV).get_prop_value('active')
Expected:
    '.true.'
Got nothing
**********************************************************************
1 items had failures:
   1 of  25 in metavar.Var
***Test Failed*** 1 failures.

Metadata

Metadata

Assignees

Labels

bugFor issues describing bugs, or PRs fixing bugs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions