Skip to content

Commit d9599ae

Browse files
Add support for Python 3.5
1 parent 9ba193e commit d9599ae

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ dist: xenial
22
language: python
33

44
python:
5+
- "3.5"
56
- "3.6"
67
- "3.7"
8+
- "pypy3.5"
79

810
install:
9-
- pip install pytest coverage pytest-cov flake8 black
11+
- pip install -r requirements-dev.txt
1012
- pip install -e ./
1113

1214
script:
13-
- flake8 cons
14-
- flake8 tests
15-
- black --check cons
16-
- black --check tests
15+
- flake8 cons tests
16+
- if [[ `command -v black` ]]; then
17+
black --check cons tests;
18+
fi
1719
- pytest -v tests/ --cov=cons/
1820

1921
after_success:

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pytest-cov
2+
pytest>=3.6
3+
coverage
4+
flake8
5+
black; python_version >= '3.6'

setup.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env python
2+
from os.path import exists
23
from setuptools import find_packages, setup
34

45
setup(
56
name="cons",
6-
version="0.1.0",
7+
version="0.1.2",
78
install_requires=[
89
'toolz',
910
'multipledispatch',
@@ -15,19 +16,27 @@
1516
],
1617
author="Brandon T. Willard",
1718
author_email="brandonwillard+cons@gmail.com",
18-
long_description="""An implementation of Lisp/Scheme-like cons in Python.""",
19+
description="""An implementation of Lisp/Scheme-like cons in Python.""",
20+
long_description=open('README.md').read() if exists("README.md") else "",
21+
long_description_content_type='text/markdown',
1922
license="LGPL-3",
2023
url="https://github.com/brandonwillard/python-cons",
2124
platforms=['any'],
22-
python_requires='>=3.6',
25+
python_requires='>=3.5',
2326
classifiers=[
2427
"Development Status :: 3 - Alpha",
2528
"Intended Audience :: Science/Research",
2629
"Intended Audience :: Developers",
2730
"License :: DFSG approved",
2831
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
2932
"Operating System :: OS Independent",
33+
"Programming Language :: Python",
34+
"Programming Language :: Python :: 3",
35+
"Programming Language :: Python :: 3.5",
3036
"Programming Language :: Python :: 3.6",
37+
"Programming Language :: Python :: 3.7",
38+
"Programming Language :: Python :: Implementation :: CPython",
39+
"Programming Language :: Python :: Implementation :: PyPy",
3140
"Topic :: Software Development :: Libraries",
3241
]
3342
)

tests/test_cons.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_car_cdr():
163163
assert cdr(cons("a", ["b"])) == ["b"]
164164
assert car(OrderedDict([(1, 2), (3, 4)])) == (1, 2)
165165
assert cdr(OrderedDict([(1, 2), (3, 4)])) == [(3, 4)]
166-
assert cdr(OrderedDict({(1): 2})) == []
166+
assert cdr(OrderedDict({1: 2})) == []
167167

168168
assert car(cons(1, cons("a", "b"))) == 1
169169
assert cdr(cons(1, cons("a", "b"))) == cons("a", "b")
@@ -173,29 +173,34 @@ def test_unification():
173173
car_lv, cdr_lv = var(), var()
174174

175175
res = unify([1, 2], cons(car_lv, cdr_lv), {})
176-
assert res == {car_lv: 1, cdr_lv: [2]}
176+
assert res[car_lv] == 1
177+
assert res[cdr_lv] == [2]
177178

178179
res = unify([], cons(car_lv, cdr_lv), {})
179180
assert res is False
180181

181182
res = unify([1], cons(car_lv, cdr_lv), {})
182-
assert res == {car_lv: 1, cdr_lv: []}
183+
assert res[car_lv] == 1
184+
assert res[cdr_lv] == []
183185

184186
res = unify((1, 2), cons(car_lv, cdr_lv), {})
185-
assert res == {car_lv: 1, cdr_lv: (2,)}
187+
assert res[car_lv] == 1
188+
assert res[cdr_lv] == (2,)
186189

187190
res = unify((), cons(car_lv, cdr_lv), {})
188191
assert res is False
189192

190193
res = unify((1,), cons(car_lv, cdr_lv), {})
191-
assert res == {car_lv: 1, cdr_lv: ()}
194+
assert res[car_lv] == 1
195+
assert res[cdr_lv] == ()
192196

193197
res = unify(iter([1]), cons(car_lv, cdr_lv), {})
194198
assert res[car_lv] == 1
195199
assert list(res[cdr_lv]) == []
196200

197-
res = unify(OrderedDict({"a": 1, "b": 2}), cons(car_lv, cdr_lv), {})
198-
assert res == {car_lv: ("a", 1), cdr_lv: [("b", 2)]}
201+
res = unify(OrderedDict([("a", 1), ("b", 2)]), cons(car_lv, cdr_lv), {})
202+
assert res[car_lv] == ("a", 1)
203+
assert res[cdr_lv] == [("b", 2)]
199204

200205
res = unify(OrderedDict(), cons(car_lv, cdr_lv), {})
201206
assert res is False
@@ -215,7 +220,8 @@ def test_unification():
215220
assert res is False
216221

217222
res = unify(OrderedDict({"a": 1}), cons(car_lv, cdr_lv), {})
218-
assert res == {car_lv: ("a", 1), cdr_lv: []}
223+
assert res[car_lv] == ("a", 1)
224+
assert res[cdr_lv] == []
219225

220226
res = reify(cons(1, cdr_lv), {cdr_lv: [2, 3]})
221227
assert res == [1, 2, 3]

0 commit comments

Comments
 (0)