Django Packages: Testing Tools
Open Source Testing
Link Checker
django-testtools - A helper for writting Django's tests.
Link Checker
django-testtools - A helper for writting Django's tests.
- assertRecipients
- assertQuerySetEqual
- assertErrorsInForm
- login_as_admin
- ...
- assert_file_exists
- assert_key_exists
- assert_has_attr
- ...
- assert_mail
- assert_latest
- assert_model_changes
from autofixture import AutoFixture
fixture = AutoFixture(Entry)
entries = fixture.create(10)
django-test-utils
- Django Testmaker
- Django Crawler
- Django Test Runner
- Twill Runner
- Persistent Database Test Runner
+
- makefixtures command
./manage.py makefixture proposals.Proposal[:10] --indent=4 > proposal_with_related_items.json
factory_boy - A test fixtures replacement for Python based on thoughtbot's factory_girl for Ruby
import factory
from models import User
class UserFactory(factory.Factory):
FACTORY_FOR = User
first_name = 'John'
last_name = 'Doe'
admin = False
# Returns a User instance that's not saved
user = UserFactory.build()
# Returns a saved User instance
user = UserFactory.create()
# Returns a dict of attributes that can be used to build a User instance
attributes = UserFactory.attributes()
# Returns an object with all defined attributes stubbed out:
stub = UserFactory.stub()
rebar - Rebar makes your Forms stronger
from rebar.testing import flatten_to_dict
form_data = flatten_to_dict(ContactForm())
form_data.update({
'name': 'X' * 300,
})
form = ContactForm(data=form_data)
assert(not form.is_valid())
The same for formsets
from rebar.testing import flatten_to_dict, empty_form_data
formset = ContactFormSet()
form_data = flatten_to_dict(formset)
form_data.update(
empty_form_data(formset, len(formset))
)
No comments:
Post a Comment