Esempio n. 1
0
def test_validate_context_wrong():
    """A context that is wrong in various ways has a custom message."""
    with pytest.raises(ValueError) as exc:
        adventurelib._validate_context(".foo.bar.")
    err = str(exc.value)
    assert err == "Context '.foo.bar.' may not start with . or end with ."
Esempio n. 2
0
def test_validate_context_double_dot():
    """A context that contains .. is invalid."""
    with pytest.raises(ValueError) as exc:
        adventurelib._validate_context("foo..bar")
    assert str(exc.value) == "Context 'foo..bar' may not contain .."
Esempio n. 3
0
def test_validate_context_end_dot():
    """A context that ends with . is invalid."""
    with pytest.raises(ValueError) as exc:
        adventurelib._validate_context("foo.bar.")
    assert str(exc.value) == "Context 'foo.bar.' may not end with ."
Esempio n. 4
0
def test_validate_context_start_dot():
    """A context that starts with . is invalid."""
    with pytest.raises(ValueError) as exc:
        adventurelib._validate_context(".foo")
    assert str(exc.value) == "Context '.foo' may not start with ."
Esempio n. 5
0
def test_validate_context_empty():
    """An empty string is not a valid context."""
    with pytest.raises(ValueError) as exc:
        adventurelib._validate_context("")
    assert str(exc.value) == "Context '' may not be empty"
Esempio n. 6
0
def test_validate_context(context):
    """We can validate valid contexts."""
    adventurelib._validate_context(context)