예제 #1
0
def test_summary():
    rock = Component(r)
    s = rock.summary(fmt="My rock: {lithology} ({colour}, {grainsize!u})")
    assert s == 'My rock: sand (grey, VF-F)'

    rock6 = Component(r6)
    s = rock6.summary(fmt="My rock: {lithology}")
    assert s == 'My rock: _'

    empty = Component({})
    d = "String"
    assert not empty  # Should have False value
    assert empty.summary(default=d) == d
예제 #2
0
def test_summary():
    """
    Test ability to generate summaries.
    """
    rock = Component(r)
    s = rock.summary(fmt="My rock: {lithology} ({colour}, {grainsize!u})")
    assert s == 'My rock: sand (grey, VF-F)'

    rock6 = Component(r6)
    s = rock6.summary(fmt="My rock: {lithology}")
    assert s == 'My rock: _'

    empty = Component({})
    d = "String"
    assert not empty  # Should have False value
    assert empty.summary(default=d) == d
예제 #3
0
def test_summary():
    rock = Component(r)
    s = rock.summary(fmt="My rock: {lithology} ({colour}, {GRAINSIZE})")
    assert s == 'My rock: sand (grey, VF-F)'

    rock6 = Component(r6)
    s = rock6.summary(fmt="My rock: {lithology}")
    assert s == 'My rock: '

    empty = Component({})
    d = "String"
    assert not empty  # Should have False value
    assert empty.summary(default=d) == d

    with pytest.raises(ComponentError):
        rock.summary(fmt="My rock: {not there}")