Skip to content
Minsing Log
Go back

English Edition

Raising an Error with pytest.raise()

Programming & CS

Among the code from Ragchain

def test_ko_strategy_qa_evaluator(strategy_qa_evaluator):
    with pytest.raises(ValueError):
        strategy_qa_evaluator.evaluate(validate_passages=True)

    result = strategy_qa_evaluator.evaluate(validate_passages=False)
    assert len(result.each_results) == 5
    assert result.each_results.iloc[0][
               'question'] == 'Are more people today related to Genghis Khan than Julius Caesar?'

If an exception occurs below with, it raises the error specified by the parameter inside pytest.raises().

Using the code above as an example, if validate_passages in strategy_qa_evaluator.evaluate(validate_passages=True) is False rather than True, it raises the ValueError specified in pytest.raises(ValueError).

Naeiseuhan site

Follow the journey

Get new posts by email.

Short, honest notes on building, startups, learning, failures, and retrospectives, for readers who follow the journey rather than pass through from search.

The newsletter is coming soon. Until then, follow via RSS or email me to get notified.


Share this post:

Comments

Sign in with GitHub to leave a comment.


Previous Post
MRR metric
Next Post
RAGchain Glossary