Completed
Push — develop ( f586da...fbd670 )
by Jace
02:29
created

when_launched_59_minutes_ago()   A

Complexity

Conditions 1

Size

Total Lines 3

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 3
rs 10
1
# pylint: disable=missing-docstring,unused-variable,unused-argument,expression-not-assigned,singleton-comparison
0 ignored issues
show
introduced by
Bad option value 'singleton-comparison'
Loading history...
2
import time
3
from mock import patch, Mock
0 ignored issues
show
Configuration introduced by
The import mock 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...
4
5
import pytest
0 ignored issues
show
Configuration introduced by
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...
6
from expecter import expect
0 ignored issues
show
Configuration introduced by
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...
7
8
from coveragespace.plugins import get_coverage, cache, _launched_recently
9
10
11
class MockCoverage(Mock):
12
13
    @staticmethod
14
    def report(*args, **kwargs):
15
        return 42.456
16
17
18
def describe_get_coverage():
19
20
    @pytest.fixture
21
    def coveragepy_data(tmpdir):
22
        cwd = tmpdir.chdir()
23
        with open("foobar.py", 'w') as stream:
24
            pass
25
        with open(".coverage", 'w') as stream:
26
            stream.write("""
27
            !coverage.py: This is a private format, don\'t read it directly!
28
            {"arcs":{"foobar.py": [[-1, 3]]}}
29
            """.strip())
30
31
    @patch('coverage.Coverage', MockCoverage)
32
    def it_supports_coveragepy(coveragepy_data):
33
        expect(get_coverage()) == 42.5
34
35
36
def describe_launched_recently():
37
38
    def when_never_launched():
39
        cache.set('mock/path', 0)
40
        expect(_launched_recently('mock/path')) == False
41
42
    def when_just_launched():
43
        cache.set('mock/path', time.time())
44
        expect(_launched_recently('mock/path')) == True
45
46
    def when_launched_59_minutes_ago():
47
        cache.set('mock/path', time.time() - 60 * 59)
48
        expect(_launched_recently('mock/path')) == True
49
50
    def when_launched_61_minutes_ago():
51
        cache.set('mock/path', time.time() - 60 * 61)
52
        expect(_launched_recently('mock/path')) == False
53