Skip to content

Commit

Permalink
Coverage tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed May 7, 2018
1 parent ae31a57 commit 44150be
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
36 changes: 19 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ language: python
cache: pip
sudo: false
python:
- "pypy2.7-5.9.0"
- "pypy3.5-5.9.0"
- "2.7"
- "3.6"
- "3.5"
- "3.4"
- "nightly"
- pypy2.7-5.9.0
- pypy3.5-5.9.0
- '2.7'
- '3.6'
- '3.5'
- '3.4'
- nightly
services:
- memcached
- redis-server
# command to install dependencies
- memcached
- redis-server
install:
- "pip install --upgrade pip"
- "pip install flake8 pytest-cov '.[tests]'"
# command to run tests
- pip install --upgrade pip
- pip install flake8 pytest-cov '.[tests]'
script:
- "flake8 --ignore=E501,E999 ring tests setup.py"
- "py.test --cov=ring -vv tests/"
- flake8 --ignore=E501,E999 ring tests setup.py
- py.test --cov=ring -vv tests/
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
matrix:
allow_failures:
- python: "nightly"
- python: nightly
notifications:
slack:
rooms:
secure: OzONLO9u8Xc+ExLlD0J7t64yWLvaiov3dszvth9K2SKF9wyKM+Xx/CTra3cTu4NypQ5dBSreVqn/g7uszahaaperOdJaH1uiACWkqZlrEm4tPabkSrqDnBJwZ0J66LwwAsn6rLvRtIla12Z2g5ZUkqMU7j1uDb/okbrTH3HLVTxHWQXg9DTetrJVlRWsCodcpuVCh63SBpCd7EBxoWse9/fiT6940isHq3UBfSjfpRXqj9cqXEZdjcCIQIekAc6bPTVcJ1oPz1CjcqHbMvZLvZ8OQCoGA5CFuSp7T4grXjTz244eLpI6DDO5NnneWfknE69vV0lhWvSxwyP9xak8mB676CV5l98bJxDP2WTv+5/UJJqwfagBxHzltHiYLnkV0uqXIVgB/Yr9etUnqfk4y4sFoiNanR2Owgza4gYflGaaaNCpZSm5bgVVeiUvGjX0A9qwLNIf68Xt9IXtNhL4IKwioBtSGkG9ghGAsdkqQZQaVfvgDDKT8J/fVQuS+MdL7lDp0YiaIlb/ld11j/aoLW8wTN7dwxgwqXiVXsIUJPXkTUuMvD29BT3r5HWc66MAFSOv2oiDci8PySe/FUPq+QKjg3jXi/Skft1uHbYsuoGMHQG/zvuwtI7h1tBkJM0KfooFC+MH/sDe/PllIj5UFSH1x43fE2Se/IfUeOOYp8A=
4 changes: 2 additions & 2 deletions ring/coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
@six.add_metaclass(abc.ABCMeta)
class Coder(object):
@abc.abstractmethod
def encode(self):
def encode(self): # pragma: no cover
pass

@abc.abstractmethod
def decode(self):
def decode(self): # pragma: no cover
pass


Expand Down
7 changes: 7 additions & 0 deletions ring/func_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import abc
import functools
import six
try:
from functools import lru_cache
except ImportError: # for py2
Expand Down Expand Up @@ -196,21 +198,26 @@ class NotFound(Exception):
pass


@six.add_metaclass(abc.ABCMeta)
class StorageImplementation(object):

@abc.abstractmethod
def get_value(self, obj, key): # pragma: no cover
raise NotImplementedError

@abc.abstractmethod
def set_value(self, obj, key, value, expire): # pragma: no cover
raise NotImplementedError

@abc.abstractmethod
def del_value(self, obj, key): # pragma: no cover
raise NotImplementedError

def touch_value(self, obj, key, expire):
raise NotImplementedError


@six.add_metaclass(abc.ABCMeta)
class BaseInterface(object):

def _key(self, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions tests/_test_func_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def f(a, b):
assert r3 == ((yield from f.update(1, 2))) # immediate update

yield from f.touch(1, 2) # just a running test
yield from f.touch(0, 0) # illegal access

yield from f.set(b'RANDOMVALUE', 1, 2)
rset = yield from f.get(1, 2)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ def f():
def test_coderize(raw_coder):
assert raw_coder
assert isinstance(coderize(raw_coder), Coder)


def test_invalid_coderize():
with pytest.raises(TypeError):
coderize(1)
2 changes: 2 additions & 0 deletions tests/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ def f(a):
assert f.get(10) == 1000
caches['default'].delete(raw_key)
assert f(10) == 500
f.delete(10)
assert caches['default'].get(raw_key) is None
10 changes: 7 additions & 3 deletions tests/test_func_sync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import sys
import ring
import pymemcache.client
import memcache
Expand Down Expand Up @@ -36,9 +36,9 @@ def storage_dict():

@pytest.fixture(scope='session', ids=['python-memcached', 'pymemcache', 'pylibmc'], params=[
# client, binary, has_touch
(pythonmemcache_client, False, False),
(pythonmemcache_client, False, sys.version_info[0] == 2),
(pymemcache_client, True, True),
(pylibmc_client, True, False), # actually has_touch but not in travis
(pylibmc_client, True, None), # actually has_touch but not in travis
])
def memcache_client(request):
client, is_binary, has_touch = request.param
Expand Down Expand Up @@ -179,6 +179,10 @@ def test_common(function, storage):

if storage.has_touch:
function.touch(1, 2) # just a running test
function.touch(0, 0) # illegal touch
elif storage.has_touch is not None: # None means unknown
with pytest.raises((AttributeError, NotImplementedError)):
function.touch(1, 2)

function.set(b'RANDOMVALUE', 1, 2)
assert function.get(1, 2) == b'RANDOMVALUE'
Expand Down

0 comments on commit 44150be

Please sign in to comment.