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 ."
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 .."
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 ."
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 ."
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"
def test_validate_context(context): """We can validate valid contexts.""" adventurelib._validate_context(context)