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
|
|
|
env = scripttest.TestFileEnvironment(path) |
20
|
|
|
env.environ.pop('TRAVIS', None) |
21
|
|
|
env.environ.pop('APPVEYOR', None) |
22
|
|
|
return env |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
def cli(env, *args): |
26
|
|
|
prog = os.path.join(os.path.dirname(sys.executable), 'coverage.space') |
27
|
|
|
cmd = env.run(prog, *args, expect_error=True) |
28
|
|
|
six.print_(cmd) |
29
|
|
|
return cmd |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
def describe_cli(): |
33
|
|
|
|
34
|
|
|
def it_fails_when_missing_arguments(env): |
35
|
|
|
cmd = cli(env) |
36
|
|
|
|
37
|
|
|
expect(cmd.returncode) == 1 |
38
|
|
|
expect(cmd.stderr).contains("Usage:") |
39
|
|
|
|
40
|
|
|
def it_can_update_metrics(env): |
41
|
|
|
cmd = cli(env, SLUG, 'unit', '100') |
42
|
|
|
|
43
|
|
|
expect(cmd.returncode) == 0 |
44
|
|
|
expect(cmd.stderr) == "" |
45
|
|
|
expect(cmd.stdout) == "" |
46
|
|
|
|
47
|
|
|
def it_indicates_when_metrics_decrease(env): |
48
|
|
|
cmd = cli(env, SLUG, 'unit', '0') |
49
|
|
|
|
50
|
|
|
expect(cmd.returncode) == 0 |
51
|
|
|
expect(cmd.stderr) == "" |
52
|
|
|
expect(cmd.stdout).contains("coverage decreased") |
53
|
|
|
|
54
|
|
|
def it_fails_when_metrics_decrease_if_requested(env): |
55
|
|
|
cmd = cli(env, SLUG, 'unit', '0', '--exit-code') |
56
|
|
|
|
57
|
|
|
expect(cmd.returncode) == 1 |
58
|
|
|
expect(cmd.stderr) == "" |
59
|
|
|
expect(cmd.stdout).contains("coverage decreased") |
60
|
|
|
|
61
|
|
|
def it_always_display_metrics_when_verbose(env): |
62
|
|
|
cmd = cli(env, SLUG, 'unit', '100', '--verbose') |
63
|
|
|
|
64
|
|
|
expect(cmd.returncode) == 0 |
65
|
|
|
expect(cmd.stderr) != "" # expect lots of logging |
66
|
|
|
expect(cmd.stdout).contains("coverage increased") |
67
|
|
|
|
68
|
|
|
def it_skips_when_running_on_ci(env): |
69
|
|
|
env.environ['CIRCLECI'] = 'true' |
70
|
|
|
|
71
|
|
|
cmd = cli(env, SLUG, 'unit', '0', '--exit-code') |
72
|
|
|
|
73
|
|
|
expect(cmd.returncode) == 0 |
74
|
|
|
expect(cmd.stderr).contains("Command skipped") |
75
|
|
|
expect(cmd.stdout) == "" |
76
|
|
|
|
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.