Exemplo n.º 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')
Exemplo n.º 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
Exemplo n.º 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')
Exemplo n.º 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.
Exemplo n.º 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