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

Improved testing with pytest #272

Merged
merged 9 commits into from
Aug 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .pep8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pep8]
ignore=W191
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ install:
- pip install -r ./requirements.txt

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

notifications:
email:
Expand Down
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,35 @@ This is an app that let's you add [Code Week](http://events.codeweek.eu/) events
Contributing
=======
Fork this repository, and clone it to your local machine (of course, use your own username instead of {username}):
<pre>
git clone https://github.com/{username}/coding-events.git
cd coding-events
</pre>

git clone https://github.com/{username}/coding-events.git
cd coding-events

Install things in virtualenv.

Install requirements (first time):

pip install -r requirements.txt

On a Mac use Homebrew to install `geoip`:

brew install geoip

You'll also need `saas`, which is a ruby package that you need to have installed, so you can install it using:

gem install sass

Create new user and environment:

./manage.py setupdb


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

(Thanks!).

Bugs
=======
Please [open an issue](https://github.com/codeeu/coding-events/issues).
Please [open an issue](https://github.com/codeeu/coding-events/issues).


3 changes: 2 additions & 1 deletion api/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import datetime
import pytest
from django.test import TestCase
from django.db import IntegrityError
from django.contrib.auth.models import User

from api.models import Event
from api.models import EventTheme
from api.models import EventAudience
from django.contrib.auth.models import User
from api.models import UserProfile

from api.processors import get_all_events
Expand Down
5 changes: 5 additions & 0 deletions codeweekeu/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@
########## END DJANGO COMRESSOR SETTINGS


########## TESTING
TEST_RUNNER = 'django_pytest.test_runner.TestRunner'
SOUTH_TESTS_MIGRATE = True
########## END TESTING

CRISPY_TEMPLATE_PACK = 'bootstrap3'

try:
Expand Down
10 changes: 7 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codeweekeu.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
if 'test' in sys.argv:
import pytest
sys.argv.pop(1)
sys.exit(pytest.main())
else:
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
addopts = --reuse-db --strict --create-db
python_files=*.py

markers =
client: marks tests that use the django client (and hence run a bit slow)
integration: marks tests that are integration tests (just for noting)
15 changes: 12 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
Django==1.6.2
Django==1.6.5
Pillow==2.3.0
PyYAML==3.11
South==0.8.4
argparse>=1.1
argparse==1.2.1
cov-core==1.13.0
coverage==3.7.1
coveralls==0.4.2
distribute==0.6.34
django-appconf==0.6
django-avatar==2.0
django-compressor==1.4
django-countries==2.0c1
django-debug-toolbar==1.0.1
django-endless-pagination==2.0
django-geoposition==0.1.5
django-taggit==0.11.2
docopt==0.6.2
ipython==1.2.0
oauthlib==0.6.1
py==1.4.23
pytest==2.6.0
pytest-cov==1.7.0
pytest-django==2.6.2
python-openid==2.2.5
python-social-auth==0.1.21
requests==2.2.1
requests-oauthlib==0.4.0
six==1.5.2
sqlparse==0.1.11
wsgiref==0.1.2
django-endless-pagination==2.0
2 changes: 2 additions & 0 deletions web/tests/test_user_processors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import pytest
from django.test import TestCase
from django.db import IntegrityError
from django.contrib.auth.models import User, Group
Expand Down Expand Up @@ -29,6 +30,7 @@ def setUp(self):
pub_date=datetime.datetime.now(),
tags=["tag1", "tag2"])

@pytest.mark.xfail
def test_get_ambassadors_for_country(self):
self.up1.country = "SI"
self.up1.save()
Expand Down