Commit Graph

70 Commits

Author SHA1 Message Date
Malcolm Tredinnick 0686c6b0ee Add the ability to do unordered comparisons in assertQuerysetEqual.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16654 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-23 03:38:18 +00:00
Russell Keith-Magee 2664fa1896 Fixed #15838 -- Promoted assertFieldOutput to a general test utility. Thanks to Ramiro Morales for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16653 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-23 02:32:37 +00:00
Ramiro Morales 326949e444 Fixed #14503 -- Unified multiple implementations of test cases assert* methods that verify a given exception is raised by a callable throughout the Django test suite.
Replaced them with a new assertRaisesMessage method of a new SimpleTestCase, a lightweight subclass of unittest.TestCase. Both are also available for usage in user tests.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16610 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-13 00:42:08 +00:00
Ramiro Morales cb1f413e4a Fixed #16372 -- Changed strategy implemented in r16369 to fix #14049 to avoid affecting the statistics of test cases ran/skipped kept by unittest. Thanks zimnyx for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16579 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-02 22:30:26 +00:00
Jannis Leidel 9be03fe326 Fixed #16437 -- Removed old code comment from testcases module. Thanks, teraom.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16565 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-07-29 09:40:28 +00:00
Jannis Leidel 24f4764a48 Fixed #16225 -- Removed unused imports. Many thanks to Aymeric Augustin for the work on the patch and Alex for reviewing.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-07-13 09:35:51 +00:00
Ramiro Morales 4ab5a43785 Fixed #14049 -- Made our TestCase subclasses not load database fixtures (nor set up custom URLconfs) for test methods that are going to be skipped. Thanks zimnyx for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16369 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-06-11 15:27:12 +00:00
Jannis Leidel a3a53e0b73 Fixed #15561 -- Extended test setting override code added in r16165 with a decorator and a signal for setting changes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16237 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-05-18 12:08:53 +00:00
Jannis Leidel 0dc6420b3e Added TestCase.settings context manager to easily override settings in test methods.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16165 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-05-06 13:29:24 +00:00
Alex Gaynor e54c0a0c94 Move the Python 2.5 specific tests out of their own special files now that 2.5 is the default. Also add __futre__ import where necessary.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-28 05:58:43 +00:00
Adrian Holovaty 13864703bc Removed a bunch more Python 2.4 workarounds now that we don't support that version. Refs #15702 -- thanks to jonash for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15927 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-28 02:11:19 +00:00
Alex Gaynor 8308ad4f05 Fixed #14774 -- the test client and assertNumQueries didn't work well together. Thanks to Jonas Obrist for the initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15251 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-20 04:47:47 +00:00
Alex Gaynor 5bc0ec4ec4 Removed all usages of deprecated TestCase methods (self.fail*). This removed most of the Warnings emitted (with -Wall) during the test suite.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14803 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-04 07:28:12 +00:00
Luke Plant 02fc6276d7 Fixed #14508 - test suite silences warnings.
Utility functions get_warnings_state and save_warnings_state have been added
to django.test.utils, and methods to django.test.TestCase for convenience.

The implementation is based on the catch_warnings context manager from
Python 2.6.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14526 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-11 15:06:20 +00:00
Alex Gaynor 56ae68c92f Removed the use of a deprecated unittest method.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14465 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-06 00:43:20 +00:00
Alex Gaynor 6824c9b796 Ensure that assertNumQueries doesn't swallow exceptions inside the function.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14405 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-31 08:29:07 +00:00
Russell Keith-Magee fffbbe4062 Reordered the shutdown process for tests so that all tests force a connection close. This is required to prevent some cross-test failures. Thanks to Florian Apolloner for the report and help tracking down the problem.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-30 13:03:37 +00:00
Alex Gaynor 9d5d757bda Fixed #14520 -- fixed a memory leak when running the test suite.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14312 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-21 17:36:38 +00:00
Russell Keith-Magee 2db34d2307 Fixed an naming problem with r14258. Thanks to Alex for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14260 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-18 16:08:25 +00:00
Russell Keith-Magee 8cb4bf5ef8 Fixed #14487 -- Prevented unittest from leaking into scope via a 'from django.test.testcases import *' import. Thanks to Jannis for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14258 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-18 15:53:55 +00:00
Russell Keith-Magee 400125d718 Corrected the skipIfDBFeature and skipUnlessDBFeature decorators to actually *run* the tests they decorate. Thanks to Alex for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14243 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-17 04:26:47 +00:00
Alex Gaynor 5506653b77 Fixed #5416 -- Added TestCase.assertNumQueries, which tests that a given function executes the correct number of queries.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14183 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-12 03:33:19 +00:00
Russell Keith-Magee 121d2e3678 Fixed #12991 -- Added unittest2 support. Thanks to PaulM for the draft patch, and to Luke, Karen, Justin, Alex, Łukasz Rekucki, and Chuck Harmston for their help testing and reviewing the final patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14139 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-11 12:55:17 +00:00
Carl Meyer 501546df6f Fixed #12226 -- Deprecated test client Response.template attribute in favor of templates attribute, which is always a list. Thanks Russell for patch review.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-10 02:16:33 +00:00
Alex Gaynor 80aa4432e6 Fixed #12979 -- allowed using savepoints in TestCase (i.e. tests with transactions disabled), convert the GetOrCreate tests to use this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14061 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-09 06:06:24 +00:00
Russell Keith-Magee b7a73cf929 Fixed #14378 -- Made the test client class customizable. Thanks to Ned Batchelder for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14058 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-09 04:50:47 +00:00
Russell Keith-Magee 9767993a24 Fixed #13615 -- Clarified test assertion text to avoid confusion when response content isn't a web page. Thanks to DaNmarner for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13512 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-08-06 16:54:17 +00:00
Russell Keith-Magee 526a4410d7 Fixed #13634 -- Migrated aggregation tests to use unittest. This removes a flush, which speeds up the tests overall.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13309 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-05-28 11:15:36 +00:00
Russell Keith-Magee cc40651f21 Fixed #12825 -- Corrected a missing space in a test case error message. Thanks to timo for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12417 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-02-13 11:59:09 +00:00
Russell Keith-Magee 7ca9d9306c Fixed #10314 -- Added a message prefix argument to Django's test assertions. Thanks to Wes Winham for the original suggestion, and Chistian Oudard for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-22 15:02:02 +00:00
Russell Keith-Magee ff60c5f9de Fixed #1142 -- Added multiple database support.
This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project.
Congratulations to Alex for a job well done.

Big thanks also go to:
 * Justin Bronn for keeping GIS in line with the changes,
 * Karen Tracey and Jani Tiainen for their help testing Oracle support
 * Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback.
 * Malcolm Treddinick for his guidance during the GSoC submission process.
 * Simon Willison for driving the original design process
 * Cal Henderson for complaining about ponies he wanted.

... and everyone else too numerous to mention that helped to bring this feature into fruition.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-22 15:18:51 +00:00
Karen Tracey d463580c1b Fixed #10831 -- Prevented code running under a to-be-rolled-back test from calling commit via transaction.managed(False). Thanks seanl for report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10621 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-22 19:10:28 +00:00
Russell Keith-Magee 366710e636 Fixed #10183 -- Corrected the handling of unicode in assertContains and assertNotContains. Thanks to trbs for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10414 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-07 12:06:05 +00:00
Karen Tracey 78b5c65844 Fixed #10676 -- Make transaction nop routine used during testing accept any args/kwargs it might be called with. Thanks seanl.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10248 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-31 13:04:28 +00:00
Malcolm Tredinnick 420a35b9b7 Python 2.3 fix: assertTrue *still* doesn't exist in Python 2.3
The tests and testing framework should use failUnless() instead.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10100 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-20 01:37:34 +00:00
Russell Keith-Magee e735fe7160 Fixed #4476 -- Added a ``follow`` option to the test client request methods. This implements browser-like behavior for the test client, following redirect chains when a 30X response is received. Thanks to Marc Fargas and Keith Bussell for their work on this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9911 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-02-27 13:14:59 +00:00
Karen Tracey 344f16e220 Fixed #8138 -- Changed django.test.TestCase to rollback tests (when the database supports it) instead of flushing and reloading the database. This can substantially reduce the time it takes to run large test suites.
This change may be slightly backwards incompatible, if existing tests need to test transactional behavior, or if they rely on invalid assumptions or a specific test case ordering.  For the first case, django.test.TransactionTestCase should be used.  TransactionTestCase is also a quick fix to get around test case errors revealed by the new rollback approach, but a better long-term fix is to correct the test case.  See the testing doc for full details.

Many thanks to:
* Marc Remolt for the initial proposal and implementation.
* Luke Plant for initial testing and improving the implementation.
* Ramiro Morales for feedback and help with tracking down a mysterious PostgreSQL issue.
* Eric Holscher for feedback regarding the effect of the change on the Ellington testsuite.
* Russell Keith-Magee for guidance and feedback from beginning to end.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9756 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-16 02:30:22 +00:00
Russell Keith-Magee cc4e4d9aee Fixed #3566 -- Added support for aggregation to the ORM. See the documentation for details on usage.
Many thanks to:
 * Nicolas Lara, who worked on this feature during the 2008 Google Summer of Code.
 * Alex Gaynor for his help debugging and fixing a number of issues.
 * Justin Bronn for his help integrating with contrib.gis.
 * Karen Tracey for her help with cross-platform testing.
 * Ian Kelly for his help testing and fixing Oracle support.
 * Malcolm Tredinnick for his invaluable review notes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-15 11:06:34 +00:00
Russell Keith-Magee 2f49d18071 Fixed #7441 -- Removed some of the shortcuts in the doctest output comparators, and added a wrapper to allow comparison of xml fragments. Thanks to Leo Soto for the report and fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8003 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-20 05:46:41 +00:00
Russell Keith-Magee 0cffff024b Fixed #7441 - Improved the doctest OutputChecker to be more lenient with JSON an XML outputs. This is required so that output ordering that doesn't matter at a semantic level (such as the order of keys in a JSON dictionary, or attributes in an XML element) isn't caught as a test failure. Thanks to Leo Soto for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7981 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-19 14:46:55 +00:00
Russell Keith-Magee 415bd694f9 Fixed #7521 -- Added the ability to customize ROOT_URLCONF for the duration of a TestCase. Thanks to Mark Fargas (telenieko) for his work on this patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-30 12:34:29 +00:00
Russell Keith-Magee 08401959d8 Fixed #7165 -- Added an assertNotContains() method to the test client. Thanks for the suggestion and implementation, J. Pablo Fernandez <pupeno@pupeno.com>.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7578 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-06 13:50:02 +00:00
Malcolm Tredinnick e5f7ed87d4 Fixed #6478 -- Allow tests to be interrupted with system exits and ^C. Thanks,
Bastian Kleineidam.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7056 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-03 01:24:22 +00:00
Gary Wilson Jr 80f5cafbc4 Fixed typo in testcases module.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7032 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-01-28 02:15:00 +00:00
Russell Keith-Magee 12efef0635 Fixed #6031 -- Added error handling for _pre_test in django.test.TestCase; exceptions during pre-test setup are now reported as test failures, rather than crashing the entire test framework. Thanks, Thomas Guttler <hv@tbz-pariv.de>.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7023 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-01-18 13:37:40 +00:00
Russell Keith-Magee dab8503146 Corrected a docstring in django.test.TestCase to match the actual behavior.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6710 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-23 10:51:17 +00:00
Malcolm Tredinnick 30848dfe34 When using assertRedirect(), allow the caller to specify relative URLs and
automatically fill in the hostname and scheme (host can be passed in, if
different from the default).


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6661 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-11 03:54:21 +00:00
Gary Wilson Jr 26ea06b0ab Fixed #3457 -- Allow overridding of error messages for newforms Fields.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6625 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-28 05:40:26 +00:00
Malcolm Tredinnick e70d7e6064 Fixed #987 -- Convert relative URI portions into absolute URIs in HTTP Location headers. Based on a patch from SmileyChris.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-14 05:28:00 +00:00
Gary Wilson Jr 53372fcb07 Cleaned up some imports.
Fixed long lines.
Changed some docstrings to use "action words".


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6044 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-04 00:50:06 +00:00