File: issue0143.feature

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (54 lines) | stat: -rw-r--r-- 1,794 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@issue
Feature: Issue #143: Logging starts with a StreamHandler way too early

  . This verifies that some imported library or other item has not made a
  . call to logging too soon, which would add a StreamHandler.


  @setup
  Scenario: Feature Setup
    Given a new working directory
    And a file named "features/steps/steps.py" with:
        """
        import logging
        from behave import given, when, then, step

        @step('I create {count:n} log records')
        def step_create_log_records(context, count):
            for i in range(count):
                logging.debug('Some debug logging')
        """
    And a file named "features/issue0143_example.feature" with:
        """
        Feature: Logging should not be output unless there is a failure

            Scenario: A passing test
                Given I create 4 log records
        """

  Scenario: Ensure that no log-ouput occurs with enabled log-capture
    Given an empty file named "features/environment.py"
    When I run "behave -f plain --logcapture features/issue0143_example.feature"
    Then it should pass
    And the command output should not contain:
        """
        DEBUG:root:Some debug logging
        """


  Scenario: Ensure that log-ouput occurs with disabled log-capture
    Given a file named "features/environment.py" with:
        """
        import logging

        def before_all(context):
            # -- basicConfig() will not set level if setup is already done.
            logging.basicConfig()
            logging.getLogger().setLevel(logging.DEBUG)
        """
    When I run "behave -f plain --no-logcapture features/issue0143_example.feature"
    Then it should pass
    And the command output should contain:
        """
        DEBUG:root:Some debug logging
        """