sdispater / cachy

Cachy provides a simple yet effective caching library.
MIT License
42 stars 18 forks source link

tests fail #5

Open eli-schwartz opened 5 years ago

eli-schwartz commented 5 years ago

While trying to package cachy for Arch Linux, the testsuite encountered several failures. Also note that it seems to need an old version of fakeredis.

$ git clone https://github.com/sdispater/cachy
$ cd cachy
# I want to test python3.7, and not really old versions of 3.x
$ sed -i 's/envlist = .*/envlist = py27, py37/' tox.ini
$ tox
py27 create: /home/eschwartz/git/cachy/.tox/py27
py27 installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,cachy==0.2.0
py27 run-test-pre: PYTHONHASHSEED='2634951109'
py27 run-test: commands[0] | poetry install --extras memcached -v
Using virtualenv: /home/eschwartz/git/cachy/.tox/py27
Installing dependencies from lock file

Package operations: 20 installs, 0 updates, 0 removals

  - Installing configparser (3.7.4)
  - Installing contextlib2 (0.5.5)
  - Installing zipp (0.5.1)
  - Installing importlib-metadata (0.15)
  - Installing scandir (1.10.0)
  - Installing six (1.12.0)
  - Installing atomicwrites (1.3.0)
  - Installing attrs (19.1.0)
  - Installing funcsigs (1.0.2)
  - Installing more-itertools (5.0.0)
  - Installing pathlib2 (2.3.3)
  - Installing pluggy (0.12.0)
  - Installing py (1.8.0)
  - Installing mock (3.0.5)
  - Installing pytest (3.10.1)
  - Installing redis (2.10.6)
  - Installing fakeredis (0.10.3)
  - Installing flexmock (0.10.4)
  - Installing pytest-mock (1.10.4)
  - Installing python-memcached (1.59)
  - Installing cachy (0.2.0)
py27 run-test: commands[1] | pytest tests/
========================================================================== test session starts ==========================================================================
platform linux2 -- Python 2.7.16, pytest-3.10.1, py-1.8.0, pluggy-0.12.0
rootdir: /home/eschwartz/git/cachy, inifile:
plugins: mock-1.10.4
collected 64 items                                                                                                                                                      

tests/test_cache_manager.py ........                                                                                                                              [ 12%]
tests/test_repository.py ..............                                                                                                                           [ 34%]
tests/test_tagged_cache.py .......                                                                                                                                [ 45%]
tests/stores/test_dict_store.py .......                                                                                                                           [ 56%]
tests/stores/test_file_store.py .........                                                                                                                         [ 70%]
tests/stores/test_memcached_store.py FF..FFFFF                                                                                                                    [ 84%]
tests/stores/test_null_store.py .                                                                                                                                 [ 85%]
tests/stores/test_redis_store.py .........                                                                                                                        [100%]

=============================================================================== FAILURES ================================================================================
___________________________________________________________________ RedisStoreTestCase.test_decrement ___________________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_decrement>

    def test_decrement(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 3, 60)

        self.store.decrement('foo', 2)
>       self.assertEqual(1, mc.get('prefix:foo'))
E       AssertionError: 1 != None

tests/stores/test_memcached_store.py:57: AssertionError
____________________________________________________________________ RedisStoreTestCase.test_forever ____________________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_forever>

    def test_forever(self):
        mc = self.get_memcached()

        self.store.forever('foo', 'bar')

>       self.assertEqual('bar', mc.get('prefix:foo'))
E       AssertionError: 'bar' != None

tests/stores/test_memcached_store.py:64: AssertionError
___________________________________________________________________ RedisStoreTestCase.test_increment ___________________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_increment>

    def test_increment(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 1, 60)

        self.store.increment('foo', 2)
>       self.assertEqual(3, mc.get('prefix:foo'))
E       AssertionError: 3 != None

tests/stores/test_memcached_store.py:50: AssertionError
_______________________________________________________________ RedisStoreTestCase.test_put_numeric_value _______________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_put_numeric_value>

    def test_put_numeric_value(self):
        mc = self.get_memcached()
        self.store.put('foo', 1, 60)

>       self.assertEqual(1, mc.get('prefix:foo'))
E       AssertionError: 1 != None

tests/stores/test_memcached_store.py:43: AssertionError
____________________________________________________________ RedisStoreTestCase.test_put_value_into_memcache ____________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_put_value_into_memcache>

    def test_put_value_into_memcache(self):
        mc = self.get_memcached()
        self.store.put('foo', 'bar', 60)

>       self.assertEqual('bar', mc.get('prefix:foo'))
E       AssertionError: 'bar' != None

tests/stores/test_memcached_store.py:37: AssertionError
_______________________________________________________________ RedisStoreTestCase.test_value_is_returned _______________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_value_is_returned>

    def test_value_is_returned(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 'bar')

>       self.assertEqual('bar', self.store.get('foo'))
E       AssertionError: 'bar' != None

tests/stores/test_memcached_store.py:25: AssertionError
________________________________________________________ RedisStoreTestCase.test_value_is_returned_for_numerics _________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_value_is_returned_for_numerics>

    def test_value_is_returned_for_numerics(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 1)

>       self.assertEqual(1, self.store.get('foo'))
E       AssertionError: 1 != None

tests/stores/test_memcached_store.py:31: AssertionError
================================================================== 7 failed, 57 passed in 0.23 seconds ==================================================================
ERROR: InvocationError for command /home/eschwartz/git/cachy/.tox/py27/bin/pytest tests/ (exited with code 1)
py37 create: /home/eschwartz/git/cachy/.tox/py37
py37 installed: cachy==0.2.0
py37 run-test-pre: PYTHONHASHSEED='2634951109'
py37 run-test: commands[0] | poetry install --extras memcached -v
Using virtualenv: /home/eschwartz/git/cachy/.tox/py37
Installing dependencies from lock file

Package operations: 14 installs, 0 updates, 0 removals

  - Installing zipp (0.5.1)
  - Installing importlib-metadata (0.15)
  - Installing six (1.12.0)
  - Installing atomicwrites (1.3.0)
  - Installing attrs (19.1.0)
  - Installing more-itertools (5.0.0)
  - Installing pluggy (0.12.0)
  - Installing py (1.8.0)
  - Installing pytest (3.10.1)
  - Installing redis (2.10.6)
  - Installing fakeredis (0.10.3)
  - Installing flexmock (0.10.4)
  - Installing pytest-mock (1.10.4)
  - Installing python-memcached (1.59)
  - Installing cachy (0.2.0)
py37 run-test: commands[1] | pytest tests/
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.7.3, pytest-3.10.1, py-1.8.0, pluggy-0.12.0
rootdir: /home/eschwartz/git/cachy, inifile:
plugins: mock-1.10.4
collected 64 items                                                                                                                                                      

tests/test_cache_manager.py ........                                                                                                                              [ 12%]
tests/test_repository.py ..............                                                                                                                           [ 34%]
tests/test_tagged_cache.py .......                                                                                                                                [ 45%]
tests/stores/test_dict_store.py .......                                                                                                                           [ 56%]
tests/stores/test_file_store.py .........                                                                                                                         [ 70%]
tests/stores/test_memcached_store.py FF..FFFFF                                                                                                                    [ 84%]
tests/stores/test_null_store.py .                                                                                                                                 [ 85%]
tests/stores/test_redis_store.py .........                                                                                                                        [100%]

=============================================================================== FAILURES ================================================================================
___________________________________________________________________ RedisStoreTestCase.test_decrement ___________________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_decrement>

    def test_decrement(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 3, 60)

        self.store.decrement('foo', 2)
>       self.assertEqual(1, mc.get('prefix:foo'))
E       AssertionError: 1 != None

tests/stores/test_memcached_store.py:57: AssertionError
____________________________________________________________________ RedisStoreTestCase.test_forever ____________________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_forever>

    def test_forever(self):
        mc = self.get_memcached()

        self.store.forever('foo', 'bar')

>       self.assertEqual('bar', mc.get('prefix:foo'))
E       AssertionError: 'bar' != None

tests/stores/test_memcached_store.py:64: AssertionError
___________________________________________________________________ RedisStoreTestCase.test_increment ___________________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_increment>

    def test_increment(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 1, 60)

        self.store.increment('foo', 2)
>       self.assertEqual(3, mc.get('prefix:foo'))
E       AssertionError: 3 != None

tests/stores/test_memcached_store.py:50: AssertionError
_______________________________________________________________ RedisStoreTestCase.test_put_numeric_value _______________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_put_numeric_value>

    def test_put_numeric_value(self):
        mc = self.get_memcached()
        self.store.put('foo', 1, 60)

>       self.assertEqual(1, mc.get('prefix:foo'))
E       AssertionError: 1 != None

tests/stores/test_memcached_store.py:43: AssertionError
____________________________________________________________ RedisStoreTestCase.test_put_value_into_memcache ____________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_put_value_into_memcache>

    def test_put_value_into_memcache(self):
        mc = self.get_memcached()
        self.store.put('foo', 'bar', 60)

>       self.assertEqual('bar', mc.get('prefix:foo'))
E       AssertionError: 'bar' != None

tests/stores/test_memcached_store.py:37: AssertionError
_______________________________________________________________ RedisStoreTestCase.test_value_is_returned _______________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_value_is_returned>

    def test_value_is_returned(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 'bar')

>       self.assertEqual('bar', self.store.get('foo'))
E       AssertionError: 'bar' != None

tests/stores/test_memcached_store.py:25: AssertionError
________________________________________________________ RedisStoreTestCase.test_value_is_returned_for_numerics _________________________________________________________

self = <tests.stores.test_memcached_store.RedisStoreTestCase testMethod=test_value_is_returned_for_numerics>

    def test_value_is_returned_for_numerics(self):
        mc = self.get_memcached()
        mc.set('prefix:foo', 1)

>       self.assertEqual(1, self.store.get('foo'))
E       AssertionError: 1 != None

tests/stores/test_memcached_store.py:31: AssertionError
=========================================================================== warnings summary ============================================================================
.tox/py37/lib/python3.7/site-packages/fakeredis.py:7
  /home/eschwartz/git/cachy/.tox/py37/lib/python3.7/site-packages/fakeredis.py:7: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import MutableMapping

-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================================================ 7 failed, 57 passed, 1 warnings in 0.28 seconds ============================================================
ERROR: InvocationError for command /home/eschwartz/git/cachy/.tox/py37/bin/pytest tests/ (exited with code 1)
________________________________________________________________________________ summary ________________________________________________________________________________
ERROR:   py27: commands failed
ERROR:   py37: commands failed
eli-schwartz commented 5 years ago

Tests do run okay with pifpaf run memcached --port 11211 -- pytest so that should probably be mentioned somewhere. Seems like the testsuite assumes it is being run in Travis with a running memcached service.

Would also be nice to support a more recent version of fakeredis...