1
|
|
|
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned |
2
|
|
|
|
3
|
|
|
from __future__ import unicode_literals |
4
|
|
|
|
5
|
|
|
import os |
6
|
|
|
import sys |
7
|
|
|
|
8
|
|
|
import pytest |
|
|
|
|
9
|
|
|
import scripttest |
|
|
|
|
10
|
|
|
from expecter import expect |
|
|
|
|
11
|
|
|
import six |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
@pytest.fixture |
15
|
|
|
def env(tmpdir): |
16
|
|
|
path = str(tmpdir.join('test')) |
17
|
|
|
return scripttest.TestFileEnvironment(path) |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
def cli(env, *args): |
21
|
|
|
prog = os.path.join(os.path.dirname(sys.executable), 'coverage.space') |
22
|
|
|
cmd = env.run(prog, *args, expect_error=True) |
23
|
|
|
six.print_(cmd) |
24
|
|
|
return cmd |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
def describe_cli(): |
28
|
|
|
|
29
|
|
|
def it_fails_when_missing_arguments(env): |
30
|
|
|
cmd = cli(env) |
31
|
|
|
|
32
|
|
|
expect(cmd.returncode) == 1 |
33
|
|
|
expect(cmd.stderr).contains("Usage:") |
34
|
|
|
|
35
|
|
|
def it_can_update_metrics(env): |
36
|
|
|
cmd = cli(env, 'foo/bar', 'unit', '100') |
37
|
|
|
|
38
|
|
|
expect(cmd.returncode) == 0 |
39
|
|
|
expect(cmd.stderr) == "" |
40
|
|
|
expect(cmd.stdout) == "" |
41
|
|
|
|
42
|
|
|
def it_indicates_when_metrics_decrease(env): |
43
|
|
|
cmd = cli(env, 'foo/bar', 'unit', '0') |
44
|
|
|
|
45
|
|
|
expect(cmd.returncode) == 0 |
46
|
|
|
expect(cmd.stderr) == "" |
47
|
|
|
expect(cmd.stdout).contains("coverage decreased") |
48
|
|
|
|
49
|
|
|
def it_fails_when_metrics_decrease_if_requested(env): |
50
|
|
|
cmd = cli(env, 'foo/bar', 'unit', '0', '--exit-code') |
51
|
|
|
|
52
|
|
|
expect(cmd.returncode) == 1 |
53
|
|
|
expect(cmd.stderr) == "" |
54
|
|
|
expect(cmd.stdout).contains("coverage decreased") |
55
|
|
|
|
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.
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.