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
|
|
|
SLUG = "jacebrowning/coverage-space-cli-demo" |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
@pytest.fixture |
17
|
|
|
def env(tmpdir): |
18
|
|
|
path = str(tmpdir.join('test')) |
19
|
|
|
return scripttest.TestFileEnvironment(path) |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
def cli(env, *args): |
23
|
|
|
prog = os.path.join(os.path.dirname(sys.executable), 'coverage.space') |
24
|
|
|
cmd = env.run(prog, *args, expect_error=True) |
25
|
|
|
six.print_(cmd) |
26
|
|
|
return cmd |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
def describe_cli(): |
30
|
|
|
|
31
|
|
|
def it_fails_when_missing_arguments(env): |
32
|
|
|
cmd = cli(env) |
33
|
|
|
|
34
|
|
|
expect(cmd.returncode) == 1 |
35
|
|
|
expect(cmd.stderr).contains("Usage:") |
36
|
|
|
|
37
|
|
|
def it_can_update_metrics(env): |
38
|
|
|
cmd = cli(env, SLUG, 'unit', '100') |
39
|
|
|
|
40
|
|
|
expect(cmd.returncode) == 0 |
41
|
|
|
expect(cmd.stderr) == "" |
42
|
|
|
expect(cmd.stdout) == "" |
43
|
|
|
|
44
|
|
|
def it_indicates_when_metrics_decrease(env): |
45
|
|
|
cmd = cli(env, SLUG, 'unit', '0') |
46
|
|
|
|
47
|
|
|
expect(cmd.returncode) == 0 |
48
|
|
|
expect(cmd.stderr) == "" |
49
|
|
|
expect(cmd.stdout).contains("coverage decreased") |
50
|
|
|
|
51
|
|
|
def it_fails_when_metrics_decrease_if_requested(env): |
52
|
|
|
cmd = cli(env, SLUG, 'unit', '0', '--exit-code') |
53
|
|
|
|
54
|
|
|
expect(cmd.returncode) == 1 |
55
|
|
|
expect(cmd.stderr) == "" |
56
|
|
|
expect(cmd.stdout).contains("coverage decreased") |
57
|
|
|
|
58
|
|
|
def it_always_display_metrics_when_verbose(env): |
59
|
|
|
cmd = cli(env, SLUG, 'unit', '100', '--verbose') |
60
|
|
|
|
61
|
|
|
expect(cmd.returncode) == 0 |
62
|
|
|
expect(cmd.stderr) == "" |
63
|
|
|
expect(cmd.stdout).contains("coverage increased") |
64
|
|
|
|
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.