Skip to content

Commit d0caa01

Browse files
committed
Added info on testing.
1 parent cd00c5d commit d0caa01

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,59 @@ Just run the project from `example` directory, head to http://127.0.0.1:8000, lo
9595
- Python 2.7.x: Django 1.7, 1.8, 1.9, 1.10
9696
- Python 3.x: Django 1.8, 1.9, 1.10
9797

98+
# Testing
99+
100+
In order to support multiple Django and Python versions we use:
101+
102+
- `py.test` - test runner
103+
- `tox` - handy tool to test app with different versions of Pythons & libraries
104+
- `selenium`
105+
- `coverage`
106+
107+
Install them via `pip install -r requirements/dev.txt`
108+
109+
To test things in specific environment, run the following commands:
110+
111+
```bash
112+
# Clear previous coverage data.
113+
coverage erase
114+
115+
# This command can be ran multiple times.
116+
tox -e <python_ver>-<django_ver>
117+
# Possible python_ver values: `py27`, `py36`
118+
# Possible django_ver values: `17`, `18`, `19`, `110`
119+
# Values can be comma-seperated, e. g. `-e py27-17,py27-18,py36-18`
120+
# If you omit `-e ...` parameter, all environments will be tests.
121+
# Also - not problems with running this within a virtualenv.
122+
# Check tox.ini for these values.
123+
124+
# Run this once all tests passed on all environment.
125+
coverage combine
126+
127+
# Render HTML with coverage info.
128+
coverage html
129+
# ...or simply display % of covered SLOC for each file.
130+
coverage report
131+
```
132+
133+
To add a new Django version for testing, add it into `tox.ini`, lines 3-4.
134+
135+
Why do we need `tox` and `coverage combine`? Because different versions of Python & libraries lead to different code execution: for example, consider this code:
136+
137+
```python
138+
import sys
139+
if sys.version_info.major == 2:
140+
foo = 'spam' # Not covered in Python 3.x, leads to coverage < 100%
141+
else:
142+
foo = 'eggs' # Not covered in Python 2.x, leads to coverage < 100%
143+
```
144+
145+
Using `tox` and `coverage combine` we're able to "merge" coverage info from across different environments.
146+
98147
# Known issues
99148
100149
- Not tested with empty fields.
150+
- Tests sometimes fail randomly due to some Selenium timeout issue. Weird.
101151
102152
# Contributing
103153

requirements/dev.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage==4.2
2+
pytest==3.0.3
3+
pytest-cov==2.4.0
4+
pytest-django==3.0.0
5+
selenium==3.0.1
6+
tox==2.4.1

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='django-searchable-select',
7-
version='1.4.4-2',
7+
version='1.4.4-3',
88
description='django-searchable-select - a better and faster multiple selection widget with suggestions for Django',
99
long_description="""django-searchable-select
1010
========================
@@ -149,7 +149,7 @@ class TravelerAdmin(admin.ModelAdmin):
149149
license='GPLv2',
150150
packages=['searchableselect'],
151151
include_package_data=True,
152-
install_requires=['setuptools', 'django'],
152+
install_requires=['setuptools'],
153153
zip_safe=False,
154154
classifiers=[
155155
'Development Status :: 5 - Production/Stable',

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
envlist =
3-
py27-{17,18,19,110}
4-
py35-{18,19,110}
3+
py27-{17,18,19,110,111}
4+
py36-{18,19,110,111}
55

66
[testenv]
77
usedevelop = true
@@ -12,6 +12,7 @@ deps =
1212
18: Django >= 1.8, < 1.9
1313
19: Django >= 1.9, < 1.10
1414
110: Django >= 1.10, < 1.11
15+
111: Django >= 1.11, < 1.12
1516
commands =
1617
python example/manage.py collectstatic --noinput -v 0
1718
coverage run -p example/manage.py test example -v 3

0 commit comments

Comments
 (0)