Debian Codegraph @

issue.features/issue0143.feature

raw
1 @issue
2 Feature: Issue #143: Logging starts with a StreamHandler way too early
3
4 . This verifies that some imported library or other item has not made a
5 . call to logging too soon, which would add a StreamHandler.
6
7
8 @setup
9 Scenario: Feature Setup
10 Given a new working directory
11 And a file named "features/steps/steps.py" with:
12 """
13 import logging
14 from behave import given, when, then, step
15
16 @step('I create {count:n} log records')
17 def step_create_log_records(context, count):
18 for i in range(count):
19 logging.debug('Some debug logging')
20 """
21 And a file named "features/issue0143_example.feature" with:
22 """
23 Feature: Logging should not be output unless there is a failure
24
25 Scenario: A passing test
26 Given I create 4 log records
27 """
28
29 Scenario: Ensure that no log-ouput occurs with enabled log-capture
30 Given an empty file named "features/environment.py"
31 When I run "behave -f plain --logcapture features/issue0143_example.feature"
32 Then it should pass
33 And the command output should not contain:
34 """
35 DEBUG:root:Some debug logging
36 """
37
38
39 Scenario: Ensure that log-ouput occurs with disabled log-capture
40 Given a file named "features/environment.py" with:
41 """
42 import logging
43
44 def before_all(context):
45 # -- basicConfig() will not set level if setup is already done.
46 logging.basicConfig()
47 logging.getLogger().setLevel(logging.DEBUG)
48 """
49 When I run "behave -f plain --no-logcapture features/issue0143_example.feature"
50 Then it should pass
51 And the command output should contain:
52 """
53 DEBUG:root:Some debug logging
54 """