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 |
||
0 ignored issues
–
show
|
|||
9 | import scripttest |
||
0 ignored issues
–
show
The import
scripttest could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis 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 filesThis error could also result from missing
Loading history...
|
|||
10 | from expecter import expect |
||
0 ignored issues
–
show
The import
expecter could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis 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 filesThis error could also result from missing
Loading history...
|
|||
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('APPVEYOR', None) |
||
21 | env.environ.pop('CI', None) |
||
22 | env.environ.pop('CONTINUOUS_INTEGRATION', None) |
||
23 | env.environ.pop('DISABLE_COVERAGE', None) |
||
24 | env.environ.pop('TRAVIS', None) |
||
25 | return env |
||
26 | |||
27 | |||
28 | def cli(env, *args): |
||
29 | prog = os.path.join(os.path.dirname(sys.executable), 'coverage.space') |
||
30 | cmd = env.run(prog, *args, expect_error=True) |
||
31 | six.print_(cmd) |
||
32 | return cmd |
||
33 | |||
34 | |||
35 | def describe_cli(): |
||
36 | |||
37 | def it_fails_when_missing_arguments(env): |
||
38 | cmd = cli(env) |
||
39 | |||
40 | expect(cmd.returncode) == 1 |
||
41 | expect(cmd.stderr).contains("Usage:") |
||
42 | |||
43 | def describe_update(): |
||
44 | |||
45 | @pytest.fixture |
||
46 | def slug(): |
||
47 | return SLUG + "/update" |
||
48 | |||
49 | def it_can_update_metrics(env, slug): |
||
50 | cmd = cli(env, slug, 'unit', '100') |
||
51 | |||
52 | expect(cmd.returncode) == 0 |
||
53 | expect(cmd.stderr) == "" |
||
54 | expect(cmd.stdout) == "" |
||
55 | |||
56 | def it_indicates_when_metrics_decrease(env, slug): |
||
57 | cmd = cli(env, slug, 'unit', '0') |
||
58 | |||
59 | expect(cmd.returncode) == 0 |
||
60 | expect(cmd.stderr) == "" |
||
61 | expect(cmd.stdout).contains("coverage decreased") |
||
62 | expect(cmd.stdout).contains( |
||
63 | "To reset metrics, run: coverage.space " + slug + " --reset" |
||
64 | ) |
||
65 | |||
66 | def it_fails_when_metrics_decrease_if_requested(env, slug): |
||
67 | cmd = cli(env, slug, 'unit', '0', '--exit-code') |
||
68 | |||
69 | expect(cmd.returncode) == 1 |
||
70 | expect(cmd.stderr) == "" |
||
71 | expect(cmd.stdout).contains("coverage decreased") |
||
72 | |||
73 | def it_always_display_metrics_when_verbose(env, slug): |
||
74 | cmd = cli(env, slug, 'unit', '100', '--verbose') |
||
75 | |||
76 | expect(cmd.returncode) == 0 |
||
77 | expect(cmd.stderr) != "" # expect lots of logging |
||
78 | expect(cmd.stdout).contains("coverage increased") |
||
79 | |||
80 | def it_skips_when_running_on_ci(env, slug): |
||
81 | env.environ['CI'] = 'true' |
||
82 | |||
83 | cmd = cli(env, slug, 'unit', '0', '--exit-code', '--verbose') |
||
84 | |||
85 | expect(cmd.returncode) == 0 |
||
86 | expect(cmd.stderr).contains("Coverage check skipped") |
||
87 | expect(cmd.stdout) == "" |
||
88 | |||
89 | def it_fails_on_slugs_missing_a_slash(env): |
||
90 | cmd = cli(env, 'foobar', 'unit', '100') |
||
91 | |||
92 | expect(cmd.returncode) == 1 |
||
93 | expect(cmd.stderr).contains( |
||
94 | "<owner/repo> slug must contain a slash") |
||
95 | expect(cmd.stdout) == "" |
||
96 | |||
97 | def describe_reset(): |
||
98 | |||
99 | @pytest.fixture |
||
100 | def slug(): |
||
101 | return SLUG + "/reset" |
||
102 | |||
103 | def it_can_reset_metrics(env, slug): |
||
104 | cmd = cli(env, slug, '--reset') |
||
105 | |||
106 | expect(cmd.returncode) == 0 |
||
107 | expect(cmd.stderr) == "" |
||
108 | expect(cmd.stdout).contains("coverage reset") |
||
109 |
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.