for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
# pylint: disable=missing-docstring,unused-variable,unused-argument,expression-not-assigned,singleton-comparison
import os
import pytest
pytest
This can be caused by one of the following:
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
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.
__init__.py
from expecter import expect
expecter
from coveragespace.cache import Cache
def describe_cache():
@pytest.fixture
def cache():
return Cache()
def cache_empty(cache):
# pylint: disable=protected-access
cache._data.clear()
return cache
def cache_missing(cache_empty):
try:
os.remove(Cache.PATH)
except OSError:
pass
return cache_empty
def cache_corrupt(cache):
cache._data = "corrupt"
cache._store()
def describe_init():
def it_loads_previous_results(cache_empty):
cache_empty.set(("url", {}), "previous")
cache = Cache()
expect(cache.get(("url", {}))) == "previous"
def it_handles_missing_cache_files(cache_missing):
expect(Cache().get(("url", {}))) == None
def it_handles_corrupt_cache_files(cache_corrupt):
def describe_get():
def it_hits_with_existing_data(cache_empty):
cache = cache_empty
cache.set(("url", {}), "existing")
expect(cache.get(("url", {}))) == "existing"
def it_misses_with_no_data(cache_empty):
expect(cache_empty.get(("url", {}))) == None
def it_returns_the_default_on_miss(cache_empty):
expect(cache_empty.get("foo", 42)) == 42