ionelmc / python-redis-lock

Lock context manager implemented via redis SET NX EX and BLPOP.
https://pypi.python.org/pypi/python-redis-lock
BSD 2-Clause "Simplified" License
543 stars 76 forks source link

Failed to make tests working with plain pytest #107

Open mcepl opened 1 year ago

mcepl commented 1 year ago

While packaging python-redis-lock for openSUSE (version 4.0.0) I have still not been able to make the test suite run. I don’t think we can use plain run of tox, because it starts to pull packages from the Internet (even though we have them already installed), and we don’t have any network connection for the building processes. So, I tried to (with help of some resources on the Internet) run tests like this:

%check
# redis-server is in sbin
export PATH=$PATH:%{_sbindir}
export PYTHONPATH=$(pwd)/tests
export DJANGO_SETTINGS_MODULE=test_project.settings
# gh#ionelmc/python-redis-lock#86
%pytest -k 'not test_no_overlap2'

unfortunately it still fails with

[   12s]   File "/home/abuild/rpmbuild/BUILD/python-redis-lock-4.0.0/tests/test_project/settings.py", line 14, in <module>
[   12s]     REDIS_SOCKET = os.environ['REDIS_SOCKET']
[   12s]   File "/usr/lib64/python3.9/os.py", line 679, in __getitem__
[   12s]     raise KeyError(key) from None
[   12s] KeyError: 'REDIS_SOCKET'

(complete log of the whole building and testing process