Ejemplo n.º 1
0
def test_option_lines_check_is_option_subset_of_bad_key():
    outer_text = "weather :: fine | rain | showers"
    inner_text = "foo :: bar"
    opt_lines_outer = OptionLines(outer_text)
    opt_lines_inner = OptionLines(inner_text)
    with pytest.raises(OptionSubsetError) as exc:
        opt_lines_inner.check_is_option_subset_of(opt_lines_outer)
    assert exc.value.message.startswith('"foo" not found as option key')
Ejemplo n.º 2
0
def test_option_lines_check_is_option_subset_of_bad_option():
    outer_text = "weather :: fine | rain | showers"
    inner_text = "weather :: cloudy"
    opt_lines_outer = OptionLines(outer_text)
    opt_lines_inner = OptionLines(inner_text)
    with pytest.raises(OptionSubsetError) as exc:
        opt_lines_inner.check_is_option_subset_of(opt_lines_outer)
    assert exc.value.message.startswith("['cloudy'] not found in \"weather\" options")
Ejemplo n.º 3
0
def test_options_set_in_parse_text():
    source_text = """\
status      :: queued | started | nearly-done | finished | on-hold
supermarket :: morrisons | sainsburys | tesco
"""
    option_lines = OptionLines("# This will be overwritten")
    option_lines.parse_text(source_text)
    assert "started" in option_lines.option_keys["status"].options
    assert len(option_lines.option_keys["status"].options) == 5
    assert len(option_lines.all_options) == 8
Ejemplo n.º 4
0
def test_option_lines_check_is_option_subset_of():
    outer_text = """\
# environment, listing all possibilities.
availability :: am | eve | pm
internet     :: connected | offline
weather      :: fine | rain | showers"""
    inner_text = """\
internet     :: connected
weather      :: rain | showers"""
    opt_lines_outer = OptionLines(outer_text)
    opt_lines_inner = OptionLines(inner_text)
    # Raises exception if not subset
    opt_lines_inner.check_is_option_subset_of(opt_lines_outer)