Completed
Push — develop ( 4c6de9...3d5961 )
by Jace
02:26
created

it_always_display_metrics_when_verbose()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
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
Configuration introduced by Jace Browning
The import pytest 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...
9
import scripttest
0 ignored issues
show
Configuration introduced by Jace Browning
The import scripttest 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...
10
from expecter import expect
0 ignored issues
show
Configuration introduced by Jace Browning
The import expecter 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...
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