Completed
Push — develop ( 1118ed...cc51a4 )
by Jace
02:37
created

pytest_configure()   A

Complexity

Conditions 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 20
rs 9.4285

1 Method

Rating   Name   Duplication   Size   Complexity  
A QuietReporter.__init__() 0 5 1
1
"""Unit test configuration."""
2
3
import os
4
import logging
5
6
import pytest
7
import yorm
0 ignored issues
show
Configuration introduced by
The import yorm could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
8
9
10
ENV = 'TEST_INTEGRATION'  # environment variable to enable integration tests
11
REASON = "'{0}' variable not set".format(ENV)
12
13
ROOT = os.path.dirname(__file__)
14
FILES = os.path.join(ROOT, 'files')
15
16
17
def pytest_configure(config):
18
    """Conigure logging and silence verbose test runner output."""
19
    logging.basicConfig(
20
        level=logging.DEBUG,
21
        format="[%(levelname)-8s] (%(name)s @%(lineno)4d) %(message)s",
22
    )
23
    logging.getLogger('yorm').setLevel(logging.WARNING)
24
    logging.getLogger('sh').setLevel(logging.WARNING)
25
26
    terminal = config.pluginmanager.getplugin('terminal')
27
28
    class QuietReporter(terminal.TerminalReporter):
29
30
        def __init__(self, *args, **kwargs):
31
            super().__init__(*args, **kwargs)
32
            self.verbosity = 0
33
            self.showlongtestinfo = False
34
            self.showfspath = False
35
36
    terminal.TerminalReporter = QuietReporter
37
38
39
def pytest_runtest_setup(item):
40
    """Disable YORM file storage during unit tests."""
41
    if 'integration' in item.keywords:
42
        if not os.getenv(ENV):
43
            pytest.skip(REASON)
44
        else:
45
            yorm.settings.fake = False
46
    else:
47
        yorm.settings.fake = True
48