Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 694ebf5

Browse files
committed
Merge pull request #272 from gandalfar/testing
Improved testing with pytest
2 parents 570ce1b + f4817c4 commit 694ebf5

File tree

9 files changed

+66
-13
lines changed

9 files changed

+66
-13
lines changed

.pep8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pep8]
2+
ignore=W191

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ install:
2323
- pip install -r ./requirements.txt
2424

2525
# command to run tests, e.g. python setup.py test
26-
script: python ./manage.py test api web.tests --settings=codeweekeu.settings_travis
26+
script:
27+
- DJANGO_SETTINGS_MODULE=codeweekeu.settings_travis python ./manage.py test --cov web --cov api --cov-report term-missing -v
28+
after_success:
29+
- coveralls
2730

2831
notifications:
2932
email:

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,35 @@ This is an app that let's you add [Code Week](http://events.codeweek.eu/) events
99
Contributing
1010
=======
1111
Fork this repository, and clone it to your local machine (of course, use your own username instead of {username}):
12-
<pre>
13-
git clone https://github.com/{username}/coding-events.git
14-
cd coding-events
15-
</pre>
12+
13+
git clone https://github.com/{username}/coding-events.git
14+
cd coding-events
15+
16+
Install things in virtualenv.
17+
18+
Install requirements (first time):
19+
20+
pip install -r requirements.txt
21+
22+
On a Mac use Homebrew to install `geoip`:
23+
24+
brew install geoip
25+
26+
You'll also need `saas`, which is a ruby package that you need to have installed, so you can install it using:
27+
28+
gem install sass
29+
30+
Create new user and environment:
31+
32+
./manage.py setupdb
33+
1634

1735
Make your changes, push to your fork and create a new Pull Request.
1836

1937
(Thanks!).
2038

2139
Bugs
2240
=======
23-
Please [open an issue](https://github.com/codeeu/coding-events/issues).
41+
Please [open an issue](https://github.com/codeeu/coding-events/issues).
42+
43+

api/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import datetime
2+
import pytest
23
from django.test import TestCase
34
from django.db import IntegrityError
5+
from django.contrib.auth.models import User
46

57
from api.models import Event
68
from api.models import EventTheme
79
from api.models import EventAudience
8-
from django.contrib.auth.models import User
910
from api.models import UserProfile
1011

1112
from api.processors import get_all_events

codeweekeu/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@
531531
########## END DJANGO COMRESSOR SETTINGS
532532

533533

534+
########## TESTING
535+
TEST_RUNNER = 'django_pytest.test_runner.TestRunner'
536+
SOUTH_TESTS_MIGRATE = True
537+
########## END TESTING
538+
534539
CRISPY_TEMPLATE_PACK = 'bootstrap3'
535540

536541
try:

manage.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
if __name__ == "__main__":
66
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codeweekeu.settings")
77

8-
from django.core.management import execute_from_command_line
9-
10-
execute_from_command_line(sys.argv)
8+
if 'test' in sys.argv:
9+
import pytest
10+
sys.argv.pop(1)
11+
sys.exit(pytest.main())
12+
else:
13+
from django.core.management import execute_from_command_line
14+
execute_from_command_line(sys.argv)

pytest.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[pytest]
2+
addopts = --reuse-db --strict --create-db
3+
python_files=*.py
4+
5+
markers =
6+
client: marks tests that use the django client (and hence run a bit slow)
7+
integration: marks tests that are integration tests (just for noting)

requirements.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
1-
Django==1.6.2
1+
Django==1.6.5
22
Pillow==2.3.0
3+
PyYAML==3.11
34
South==0.8.4
4-
argparse>=1.1
5+
argparse==1.2.1
6+
cov-core==1.13.0
7+
coverage==3.7.1
8+
coveralls==0.4.2
59
distribute==0.6.34
610
django-appconf==0.6
711
django-avatar==2.0
812
django-compressor==1.4
913
django-countries==2.0c1
1014
django-debug-toolbar==1.0.1
15+
django-endless-pagination==2.0
1116
django-geoposition==0.1.5
1217
django-taggit==0.11.2
18+
docopt==0.6.2
1319
ipython==1.2.0
1420
oauthlib==0.6.1
21+
py==1.4.23
22+
pytest==2.6.0
23+
pytest-cov==1.7.0
24+
pytest-django==2.6.2
1525
python-openid==2.2.5
1626
python-social-auth==0.1.21
1727
requests==2.2.1
1828
requests-oauthlib==0.4.0
1929
six==1.5.2
2030
sqlparse==0.1.11
2131
wsgiref==0.1.2
22-
django-endless-pagination==2.0

web/tests/test_user_processors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import pytest
23
from django.test import TestCase
34
from django.db import IntegrityError
45
from django.contrib.auth.models import User, Group
@@ -29,6 +30,7 @@ def setUp(self):
2930
pub_date=datetime.datetime.now(),
3031
tags=["tag1", "tag2"])
3132

33+
@pytest.mark.xfail
3234
def test_get_ambassadors_for_country(self):
3335
self.up1.country = "SI"
3436
self.up1.save()

0 commit comments

Comments
 (0)