summaryrefslogtreecommitdiff
path: root/django/test
AgeCommit message (Collapse)Author
2013-10-22[1.6.x] Fixed #21307 -- Moved TransRealMixin to django.test.utils.Ramiro Morales
51d2e1fb23 from master.
2013-10-01[1.6.x] Factorized requires_tz_support decorator in test utilsClaude Paroz
Thanks Aymeric Augustin for the suggestion. Refs #21165. Backport of c1c44b2506 from master.
2013-09-22[1.6.x] Fixed "Address already in use" from liveserver.Florian Apolloner
Our WSGIServer rewrapped the socket errors from server_bind into WSGIServerExceptions, which is used later on to provide nicer error messages in runserver and used by the liveserver to see if the port is already in use. But wrapping server_bind isn't enough since it only binds to the socket, socket.listen (which is called from server_activate) could also raise "Address already in use". Instead of overriding server_activate too I chose to just catch socket errors, which seems to make more sense anyways and should be more robust against changes in wsgiref. Backport of 2ca00faa913754cd5860f6e1f23c8da2529c691a from master.
2013-09-17[1.6.x] Final attempt to solve sporadic test failures.Florian Apolloner
tearDownClass is not called if setUpClass throws an exception, in our case this means that LiveServerTestCase leaks LiveServerThread sockets if the test happens to be skipped later on, and AdminSeleniumWebDriverTestCase doesn't close it's already open browser window. To prevent this leakage we catch errors where needed and manually call _tearDownClassInternal. _tearDownClassInternal should be written as defensively as possible since it is not allowed to make any assumptions on how far setUpClass got. This patch should fix the sporadic "Address already in use"-errors on jenkins and also the "This code isn't under transaction management"-error for sqlite (also just on jenkins). After discussion with koniiiik, jezdez, kmtracey, tos9, lifeless, nedbat and voidspace it was decided that this is the safest approach (thanks to everyone for their comments and help). Manually calling tearDownClass was shut down cause we don't know how our users override our classes. This is a private and very specialized API on purpose and should not be used without a strong reason! This patch partially reverts the earlier attempts to fix those issues, namely: 2fa0dd73b18f55d0fdd1c1d54b1d18031bfcf1ed and 3c5775d36f7e431d9691829a78580873111cb714 Final note: If this patch breaks in a later version of Django, please be very careful on how you fix it, you might not see test failures locally. That said, this patch hopefully doesn't produce even more failures. Backport of 73a610d2a81bc3bf2d3834786b2458bc85953ed0 from master.
2013-09-10[1.6.x] Took advantage of django.utils.six.moves.urllib.*.Aymeric Augustin
Backport of 6a6428a36 from master.
2013-09-07[1.6.x] Fixed 9244447c -- incomplete backport.Aymeric Augustin
The test client had been refactored in the mean time. This commit de-factors the fix. Refs #20530.
2013-09-07[1.6.x] Fixed an encoding issue in the test client.Aymeric Augustin
Refs #20530. Backport of 7bb62793 and 476b0764 from master. Conflicts: django/test/client.py
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