Debian Codegraph @

behave4cmd0/failing_steps.py

raw
1 # -*- coding: utf-8 -*-
2 """
3 Generic failing steps.
4 Often needed in examples.
5
6 EXAMPLES:
7
8 Given a step fails
9 When another step fails
10 Then a step fails
11
12 Given ...
13 When ...
14 Then it should fail because "the person is unknown".
15 """
16
17 from __future__ import absolute_import
18 from behave import step, then
19
20 # -----------------------------------------------------------------------------
21 # STEPS FOR: failing
22 # -----------------------------------------------------------------------------
23 @step(u'{word:w} step fails')
24 def step_fails(context, word):
25 """Step that always fails, mostly needed in examples."""
26 assert False, "EXPECT: Failing step"
27
28 @step(u'{word:w} step fails with "{message}"')
29 def step_fails_with_message(context, word, message):
30 """Step that always fails, mostly needed in examples."""
31 assert False, "FAILED: %s" % message
32
33 @step(u'{word:w} step fails with')
34 def step_fails_with_text(context, word):
35 """Step that always fails, mostly needed in examples."""
36 assert context.text is not None, "REQUIRE: text"
37 step_fails_with_message(context, word, context.text)
38
39 @then(u'it should fail because "{reason}"')
40 def then_it_should_fail_because(context, reason):
41 """Self documenting step that indicates why this step should fail."""
42 assert False, "FAILED: %s" % reason
43
44 # @step(u'an error should fail because "{reason}"')
45 # def then_it_should_fail_because(context, reason):
46 # """
47 # Self documenting step that indicates why this step should fail.
48 # """
49 # assert False, reason