Skip to content

Commit 85febb4

Browse files
authored
Merge pull request jamesls#305 from jamesls/modernisation
Packaging modernisation
2 parents 03e1eb6 + 1d63e3f commit 85febb4

File tree

9 files changed

+63
-58
lines changed

9 files changed

+63
-58
lines changed

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

fakeredis/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from ._server import FakeServer, FakeRedis, FakeStrictRedis, FakeConnection # noqa: F401
22

33

4-
__version__ = '1.6.0'
4+
__version__ = '1.6.1'

fakeredis/aioredis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import distutils.version
2-
31
import aioredis
2+
import packaging.version
43

54

6-
if aioredis.__version__ >= distutils.version.StrictVersion('2.0.0a1'):
5+
if packaging.version.Version(aioredis.__version__) >= packaging.version.Version('2.0.0a1'):
76
from ._aioredis2 import FakeConnection, FakeRedis # noqa: F401
87
else:
98
from ._aioredis1 import ( # noqa: F401

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel", "setuptools-scm"]

setup.cfg

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
[metadata]
2+
name = fakeredis
3+
version = attr: fakeredis.__version__
4+
description = Fake implementation of redis API for testing purposes.
5+
long_description = file: README.rst
6+
long_description_content_type = test/x-rst
7+
license = BSD
8+
url = https://github.com/jamesls/fakeredis
9+
author = James Saryerwinnie
10+
author_email = [email protected]
11+
maintainer = Bruce Merry
12+
maintainer_email = [email protected]
13+
classifiers =
14+
Development Status :: 5 - Production/Stable
15+
License :: OSI Approved :: BSD License
16+
Programming Language :: Python :: 3
17+
Programming Language :: Python :: 3.6
18+
Programming Language :: Python :: 3.7
19+
Programming Language :: Python :: 3.8
20+
Programming Language :: Python :: 3.9
21+
22+
[options]
23+
packages = fakeredis
24+
install_requires =
25+
packaging
26+
# Minor version updates to redis tend to break fakeredis. If you
27+
# need to use fakeredis with a newer redis, please submit a PR that
28+
# relaxes this restriction and adds it to the Github Actions tests.
29+
redis<3.6.0
30+
six>=1.12
31+
sortedcontainers
32+
python_requires = >=3.5
33+
34+
[options.extras_require]
35+
lua =
36+
lupa
37+
aioredis =
38+
aioredis
39+
40+
# Tool configurations below here
41+
142
[flake8]
243
max-line-length = 119
344

setup.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,4 @@
1-
import os
2-
31
from setuptools import setup
42

53

6-
setup(
7-
name='fakeredis',
8-
version='1.6.0',
9-
description="Fake implementation of redis API for testing purposes.",
10-
long_description=open(os.path.join(os.path.dirname(__file__),
11-
'README.rst')).read(),
12-
license='BSD',
13-
url="https://github.com/jamesls/fakeredis",
14-
author='James Saryerwinnie',
15-
author_email='[email protected]',
16-
maintainer='Bruce Merry',
17-
maintainer_email='[email protected]',
18-
packages=['fakeredis'],
19-
classifiers=[
20-
'Development Status :: 5 - Production/Stable',
21-
'License :: OSI Approved :: BSD License',
22-
'Programming Language :: Python :: 3',
23-
'Programming Language :: Python :: 3.6',
24-
'Programming Language :: Python :: 3.7',
25-
'Programming Language :: Python :: 3.8',
26-
'Programming Language :: Python :: 3.9'
27-
],
28-
python_requires='>=3.5',
29-
install_requires=[
30-
# Minor version updates to redis tend to break fakeredis. If you
31-
# need to use fakeredis with a newer redis, please submit a PR that
32-
# relaxes this restriction and adds it to the Github Actions tests.
33-
'redis<3.6.0', 'six>=1.12', 'sortedcontainers'
34-
],
35-
extras_require={
36-
'lua': ['lupa'],
37-
'aioredis': ['aioredis']
38-
}
39-
)
4+
setup()

test/test_aioredis1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import asyncio
2-
import distutils.version
32

3+
from packaging.version import Version
44
import pytest
55
import aioredis
66
from async_generator import yield_, async_generator
77

88
import fakeredis.aioredis
99

1010

11-
aioredis2 = aioredis.__version__ >= distutils.version.StrictVersion('2.0.0a1')
11+
aioredis2 = Version(aioredis.__version__) >= Version('2.0.0a1')
1212
pytestmark = [
1313
pytest.mark.asyncio,
1414
pytest.mark.skipif(aioredis2, reason="Test is only applicable to aioredis 1.x")

test/test_aioredis2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
2-
import distutils.version
32
import re
43

4+
from packaging.version import Version
55
import pytest
66
import aioredis
77
import async_timeout
@@ -10,7 +10,7 @@
1010
import fakeredis.aioredis
1111

1212

13-
aioredis2 = aioredis.__version__ >= distutils.version.StrictVersion('2.0.0a1')
13+
aioredis2 = Version(aioredis.__version__) >= Version('2.0.0a1')
1414
pytestmark = [
1515
pytest.mark.asyncio,
1616
pytest.mark.skipif(not aioredis2, reason="Test is only applicable to aioredis 2.x")

test/test_fakeredis.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import threading
77
import logging
88
from queue import Queue
9-
import distutils.version
109

1110
import six
11+
from packaging.version import Version
1212
import pytest
1313
import redis
1414
import redis.client
@@ -17,8 +17,8 @@
1717
from datetime import datetime, timedelta
1818

1919

20-
REDIS_VERSION = distutils.version.LooseVersion(redis.__version__)
21-
REDIS3 = REDIS_VERSION >= '3'
20+
REDIS_VERSION = Version(redis.__version__)
21+
REDIS3 = REDIS_VERSION >= Version('3')
2222

2323

2424
redis2_only = pytest.mark.skipif(REDIS3, reason="Test is only applicable to redis-py 2.x")
@@ -99,8 +99,8 @@ def factory(db=0):
9999
min_server_marker = request.node.get_closest_marker('min_server')
100100
if min_server_marker is not None:
101101
server_version = conn.info()['redis_version']
102-
min_version = min_server_marker.args[0]
103-
if distutils.version.LooseVersion(server_version) < min_version:
102+
min_version = Version(min_server_marker.args[0])
103+
if Version(server_version) < min_version:
104104
pytest.skip(
105105
'Redis server {} required but {} found'.format(min_version, server_version)
106106
)
@@ -729,7 +729,7 @@ def test_set_px_using_timedelta(r):
729729
assert r.get('foo') == b'bar'
730730

731731

732-
@pytest.mark.skipif(REDIS_VERSION < '3.5', reason="Test is only applicable to redis-py 3.5+")
732+
@pytest.mark.skipif(REDIS_VERSION < Version('3.5'), reason="Test is only applicable to redis-py 3.5+")
733733
@pytest.mark.min_server('6.0')
734734
def test_set_keepttl(r):
735735
r.set('foo', 'bar', ex=100)
@@ -743,7 +743,7 @@ def test_set_conflicting_expire_options(r):
743743
r.set('foo', 'bar', ex=1, px=1)
744744

745745

746-
@pytest.mark.skipif(REDIS_VERSION < '3.5', reason="Test is only applicable to redis-py 3.5+")
746+
@pytest.mark.skipif(REDIS_VERSION < Version('3.5'), reason="Test is only applicable to redis-py 3.5+")
747747
def test_set_conflicting_expire_options_w_keepttl(r):
748748
with pytest.raises(ResponseError):
749749
r.set('foo', 'bar', ex=1, keepttl=True)
@@ -1682,7 +1682,7 @@ def test_scan_iter_multiple_pages_with_match(r):
16821682
assert actual == set(all_keys)
16831683

16841684

1685-
@pytest.mark.skipif(REDIS_VERSION < '3.5', reason="Test is only applicable to redis-py 3.5+")
1685+
@pytest.mark.skipif(REDIS_VERSION < Version('3.5'), reason="Test is only applicable to redis-py 3.5+")
16861686
@pytest.mark.min_server('6.0')
16871687
def test_scan_iter_multiple_pages_with_type(r):
16881688
all_keys = key_val_dict(size=100)
@@ -2101,7 +2101,7 @@ def test_zadd_with_nx_and_xx(r, ch):
21012101
zadd(r, 'foo', {'four': -4.0, 'three': -3.0}, nx=True, xx=True, ch=ch)
21022102

21032103

2104-
@pytest.mark.skipif(REDIS_VERSION < '3.1', reason="Test is only applicable to redis-py 3.1+")
2104+
@pytest.mark.skipif(REDIS_VERSION < Version('3.1'), reason="Test is only applicable to redis-py 3.1+")
21052105
@pytest.mark.parametrize('ch', [False, True])
21062106
def test_zadd_incr(r, ch):
21072107
zadd(r, 'foo', {'four': 4.0, 'three': 3.0})
@@ -3335,7 +3335,7 @@ def test_pipeline_no_commands(r):
33353335
p = r.pipeline()
33363336
p.watch('foo')
33373337
r.set('foo', '2')
3338-
if REDIS_VERSION >= '3.4':
3338+
if REDIS_VERSION >= Version('3.4'):
33393339
with pytest.raises(redis.WatchError):
33403340
p.execute()
33413341
else:
@@ -3781,7 +3781,7 @@ def test_pubsub_run_in_thread(r):
37813781
pytest.param(
37823782
None,
37833783
marks=pytest.mark.skipif(
3784-
REDIS_VERSION >= "3.2" and REDIS_VERSION < "3.3",
3784+
Version("3.2") <= REDIS_VERSION < Version("3.3"),
37853785
reason="This test is not applicable to redis-py 3.2"
37863786
)
37873787
)
@@ -4694,7 +4694,7 @@ def test_unlink(r):
46944694
assert r.get('foo') is None
46954695

46964696

4697-
@pytest.mark.skipif(REDIS_VERSION < "3.4", reason="Test requires redis-py 3.4+")
4697+
@pytest.mark.skipif(REDIS_VERSION < Version("3.4"), reason="Test requires redis-py 3.4+")
46984698
@pytest.mark.fake
46994699
def test_socket_cleanup_pubsub(fake_server):
47004700
r1 = fakeredis.FakeStrictRedis(server=fake_server)

0 commit comments

Comments
 (0)