Exemplo n.º 1
0
def test_parameters_features():
    par0 = Parameters({})
    par1 = Parameters({'olaf': 'schneemann'})

    assert len(par0) == 0
    assert len(par1) == 1

    assert not par0
    assert par1

    assert 'olaf' not in par0
    assert 'olaf' in par1

    assert par0.get('olaf') is None
    assert par1.get('olaf') == 'schneemann'

    with pytest.raises(KeyError):
        _ = par0['olaf']
    assert par1['olaf'] == 'schneemann'

    assert list(par0) == list(par0.keys()) == list(par0.values()) == list(
        par0.items()) == []
    assert list(par1) == list(par1.keys()) == ['olaf']
    assert list(par1.values()) == ['schneemann']
    assert list(par1.items()) == [('olaf', 'schneemann')]
Exemplo n.º 2
0
def test_paramters_invalid(data):
    with pytest.raises(TypeError, match="expected dict"):
        _ = Parameters(data)