summaryrefslogtreecommitdiff
path: root/django/test
AgeCommit message (Collapse)Author
2013-07-13[1.6.x] Fixed #20681 -- Prevented teardown_databases from attempting to tear ↵Tim Graham
down aliases Thanks simonpercivall. Backport of d9c580306c from master
2013-07-04[1.6.x] Fixed #19940 -- Made test.runner.setup_databases properly handle ↵Tim Graham
aliases for default db. Thanks simonpercivall. Backport of 2cbd579efe from master.
2013-06-24Fixed #20636 -- Stopped stuffing values in the settings.Aymeric Augustin
In Django < 1.6, override_settings restores the settings module that was active when the override_settings call was executed, not when it was run. This can make a difference when override_settings is applied to a class, since it's executed when the module is imported, not when the test case is run. In addition, if the settings module for tests is stored alongside the tests themselves, importing the settings module can trigger an import of the tests. Since the settings module isn't fully imported yet, class-level override_settings statements may store a reference to an incorrect settings module. Eventually this will result in a crash during test teardown because the settings module restored by override_settings won't the one that was active during test setup. While Django should prevent this situation in the future by failing loudly in such dubious import sequences, that change won't be backported to 1.5 and 1.4. However, these versions received the "allowed hosts" patch and they're prone to "AttributeError: 'Settings' object has no attribute '_original_allowed_hosts'". To mitigate this regression, this commits stuffs _original_allowed_hosts on a random module instead of the settings module. This problem shouldn't occur in Django 1.6, see #20290, but this patch will be forward-ported for extra safety. Also tweaked backup variable names for consistency. Forward port of 0261922 from stable/1.5.x. Conflicts: django/test/utils.py
2013-06-21Fixed #20290 -- Allow override_settings to be nestedOliver Beattie
Refactored override_settings to store the underlying settings._wrapped value seen at runtime, not instantiation time.
2013-06-14Merge pull request #1270 from ↵Marc Tamlyn
tomchristie/remove-incorrect-content-type-test-client Remove incorrect CONTENT_TYPE header from GET and HEAD requests
2013-06-14Remove incorrect CONTENT_TYPE header from GET and HEAD requestsTom Christie
2013-06-12Fixed #20579 -- Improved TransactionTestCase.available_apps.Aymeric Augustin
Also moved its documentation to the 'advanced' section. It doesn't belong to the 'overview'. Same for TransactionTestCase.reset_sequences. When available_apps is set, after a TransactionTestCase, the database is now totally empty. post_syncdb is fired at the beginning of the next TransactionTestCase. Refs #20483.
2013-06-10Added TransactionTestCase.available_apps.Aymeric Augustin
This can be used to make Django's test suite significantly faster by reducing the number of models for which content types and permissions must be created and tables must be flushed in each non-transactional test. It's documented for Django contributors and committers but it's branded as a private API to preserve our freedom to change it in the future. Most of the credit goes to Anssi. He got the idea and did the research. Fixed #20483.
2013-06-04Fixed #18924 -- Made test.Client.logout send user_logged_out signal.Tim Graham
Thanks awsum for the suggestion and Pavel Ponomarev and Florian Hahn for the patch.
2013-06-01Fixed #20404 -- Added a keys() method to ContextList.Chris Wilson
It's useful to be able to list all the (flattened) keys of a ContextList, to help you figure out why the variable that's supposed to be there is not. No .values() or .items() added as the definition for those aren't clear. The patch is Chris Wilson's patch from pull request 1065 with some modifications by committer.
2013-05-27Fixed #20503 - Moved doctest utilities in with the rest of the deprecated ↵Carl Meyer
test code. The ``DocTestRunner`` and ``OutputChecker`` were formerly in ``django.test.testcases``, now they are in ``django.test.simple``. This avoids triggering the ``django.test._doctest`` deprecation message with any import from ``django.test``. Since these utility classes are undocumented internal API, they can be moved without a separate deprecation process. Also removed the deprecation warnings specific to these classes, as they are now covered by the module-level warning in ``django.test.simple``. Thanks Anssi for the report. Refs #17365.
2013-05-27Fixed #11603 - Added django.test.SimpleTestCase.assertFormsetErrorTim Graham
Thank-you Martin Green for the patch.
2013-05-25Fixed #19866 -- Added security logger and return 400 for SuspiciousOperation.Preston Holmes
SuspiciousOperations have been differentiated into subclasses, and are now logged to a 'django.security.*' logger. SuspiciousOperations that reach django.core.handlers.base.BaseHandler will now return a 400 instead of a 500. Thanks to tiwoc for the report, and Carl Meyer and Donald Stufft for review.
2013-05-18Fixed #20004 -- Moved non DB-related assertions to SimpleTestCase.Ramiro Morales
Thanks zalew for the suggestion and work on a patch. Also updated, tweaked and fixed testing documentation.
2013-05-18Fixed #20142 -- Added error handling for fixture setupFilipa Andrade
TestCase._fixture_setup disables transactions so, in case of an error, cleanup is needed to re-enable transactions, otherwise following TransactionTestCase would fail.
2013-05-18Moved IgnorePendingDeprecationWarningsMixin in django.test.utils.Aymeric Augustin
This mixin is useful whenever deprecating a large part of Django.
2013-05-10Fixed #17365, #17366, #18727 -- Switched to discovery test runner.Carl Meyer
Thanks to Preston Timmons for the bulk of the work on the patch, especially updating Django's own test suite to comply with the requirements of the new runner. Thanks also to Jannis Leidel and Mahdi Yusuf for earlier work on the patch and the discovery runner. Refs #11077, #17032, and #18670.
2013-05-04Systematically imported wraps from functoolsClaude Paroz
2013-04-12Modified test_utils to work with unittest2 discovery.Preston Timmons
2013-04-12Fixed #20237 (again) Allowed binary parameter to assertContainsClaude Paroz
2013-04-11Fixed #20237 -- Reenabled assertContains with binary parameterClaude Paroz
Thanks Baptiste Mispelon for the review.
2013-03-30Removed site cache clearing in TestCase._fixture_setupClaude Paroz
The test suite doesn't seem to suffer from this removal. Tests should probably take care themselves to clear caches if they depend on it.
2013-03-28Fixed spelling errorsGavin Wahl
2013-03-24Fixed #18985 -- ensure module level deprecations are displayedPreston Holmes
Also don't compete with -W CLI option. Thanks to Aymeric Augustin for the catch, and Claude Paroz for the patch.
2013-03-25Fixed #19541 -- Fixed BaseHandler to enable reversing URLs in response ↵Loic Bistuer
middlewares and streamed responses with respect to per-request urlconf.
2013-03-19Fixed #18003 -- Preserved tracebacks when re-raising errors.konarkmodi
Thanks jrothenbuhler for draft patch, Konark Modi for updates.
2013-03-17Stopped using non-standard __globals__ and __code__ attributes.Aymeric Augustin
Some alternative implementations don't have them. Closes #19944.
2013-03-17Fixed memory leak in testsAnssi Kääriäinen
The AssertNumQueriesContext didn't reset connection's use_debug_cursor in case there was an exception. This resulted in leaking query strings into connection.queries. Maximum memory use pre-patch was around 700MB, post-patch it is around 200MB for Django's test suite.
2013-03-11Abused atomic for transaction handling in TestCase.Aymeric Augustin
It isn't necessary to disable set_autocommit since its use is prohibited inside an atomic block. It's still necessary to disable the legacy transaction management methods for backwards compatibility, until they're removed.
2013-03-11Deprecated transaction.commit/rollback_unless_managed.Aymeric Augustin
Since "unless managed" now means "if database-level autocommit", committing or rolling back doesn't have any effect. Restored transactional integrity in a few places that relied on automatically-started transactions with a transitory API.
2013-03-11Added an API to control database-level autocommit.Aymeric Augustin
2013-03-11Made transaction.managed a no-op and deprecated it.Aymeric Augustin
enter_transaction_management() was nearly always followed by managed(). In three places it wasn't, but they will all be refactored eventually. The "forced" keyword argument avoids introducing behavior changes until then. This is mostly backwards-compatible, except, of course, for managed itself. There's a minor difference in _enter_transaction_management: the top self.transaction_state now contains the new 'managed' state rather than the previous one. Django doesn't access self.transaction_state in _enter_transaction_management.
2013-03-07Fixed #19997 -- Added custom EMPTY_VALUES to form fieldsClaude Paroz
Thanks Loic Bistuer for the report and the patch.
2013-03-02Added a context manager to capture queries while testing.Simon Charette
Also made some import cleanups while I was there. Refs #10399.
2013-02-28Implemented persistent database connections.Aymeric Augustin
Thanks Anssi Kääriäinen and Karen Tracey for their inputs.
2013-02-25Fixed #19634 -- Added proper __hash__ methods.Aymeric Augustin
Classes overriding __eq__ need a __hash__ such that equal objects have the same hash. Thanks akaariai for the report and regebro for the patch.
2013-02-19Added a new required ALLOWED_HOSTS setting for HTTP host header validation.Carl Meyer
This is a security fix; disclosure and advisory coming shortly.
2013-02-16Fixed #19833 -- Fixed import parameter encoding in get_runnerClaude Paroz
Thanks Danilo Bargen for the report.
2013-02-13Fixed #18558 -- Added url property to HttpResponseRedirect*Hiroki Kiyohara
Thanks coolRR for the report.
2013-02-10Fixed #19707 -- Reset transaction state after requestsAnssi Kääriäinen
2013-02-02Fixed #17797 -- Enabled support for PATCH requests in the dummy test client. ↵Julien Phalip
Thanks to pfarmer for the suggestion and initial patch.
2013-01-31Merge pull request #690 from rafales/ticket_19711Aymeric Augustin
Fixed #19711 -- Typo in django.test.simple.__all__
2013-01-31Fixed #19711 -- Typo in __all__ declaration in django/test/simple.pyRafal Stozek
2013-01-31Deprecated undocumented warnings manipulation testing tools.Ramiro Morales
2013-01-09Fixed #19546 - ensure that deprecation warnings are shown during testsPreston Holmes
refs #18985
2013-01-01Fixed #19519 again -- Regression in LiveServerTestCase after fd1279a4.Aymeric Augustin
2012-12-31Fixed #19519 -- Fired request_finished in the WSGI iterable's close().Aymeric Augustin
2012-12-24Fixed HTML comparisons of class="foo bar" and class="bar foo" in testsLuke Plant
Refs #17758
2012-12-24Add assertJSONEqual method to TestCaseIan Clelland
2012-12-24Add assertInHTML method to TestCaseIan Clelland