Issues (118)

gdm/test/conftest.py (2 issues)

1
"""Unit test configuration."""
2
3
import os
4
import logging
5
6
import pytest
7
import yorm
0 ignored issues
show
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):
0 ignored issues
show
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
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