def METHOD_NAME(self):
    """ Verify that the engine works correctly with rule contexts. """
    context = TestContext(True)
    self.add_rule(CompoundRule(name="r1", spec="test context",
                               context=context))
    # Test that the rule matches when in-context.
    results = self.recognize_node("test context").words()
    assert results == ["test", "context"]
    # Go out of context and test again.
    # Use the engine's mimic method because recognize_node won't return
    # RecognitionFailure like ElementTester.recognize does.
    context.active = False
    self.process_grammars_context()
    try:
        self.grammar.load()
        self.grammar.set_exclusiveness(True)
        self.assertRaises(MimicFailure, self.engine.mimic, "test context")
    finally:
        self.grammar.set_exclusiveness(False)
        self.grammar.unload()
    # Test again after going back into context.
    context.active = True
    self.process_grammars_context()
    results = self.recognize_node("test context").words()
    assert results == ["test", "context"]