예제 #1
0
def test_replace_none_with_default_uses_new_default_constant():
    try:
        default_constants['foo'] = 5.
        value = replace_none_with_default('foo', None)
        assert value == 5.
    finally:  # make sure we restore default_constants after
        default_constants.pop('foo')
예제 #2
0
def test_replace_none_with_default_uses_replaced_default_constant():
    old_value = default_constants['gas_constant_of_dry_air']
    try:
        default_constants['gas_constant_of_dry_air'] = -5.
        value = replace_none_with_default('gas_constant_of_dry_air', None)
        assert value == -5.
    finally:  # make sure we restore default_constants after
        default_constants['gas_constant_of_dry_air'] = old_value
예제 #3
0
def test_replace_none_with_default_raises_keyerror_on_missing_value():
    assert 'arglebargle' not in default_constants
    try:
        value = replace_none_with_default('arglebargle', None)
    except KeyError:
        pass
    except Exception as err:
        raise err
    else:
        raise AssertionError('No error was raised, but expected KeyError')
예제 #4
0
def test_replace_none_with_default_does_not_replace_value():
    value = replace_none_with_default('gas_constant_of_dry_air', -1.)
    assert value == -1.
예제 #5
0
def test_replace_none_with_default_replaces_none():
    value = replace_none_with_default('gas_constant_of_dry_air', None)
    assert value is not None