Commit Graph

82 Commits

Author SHA1 Message Date
Aymeric Augustin 4fe87c370d Removed some Python < 2.6 compatibility code. Refs #17965.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17830 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-30 09:20:04 +00:00
Claude Paroz 9383a2761c Removed with_statement imports, useless in Python >= 2.6. Refs #17965. Thanks jonash for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17828 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-30 08:02:08 +00:00
Adrian Holovaty 6ecadcbdd2 Made a bunch more edits up until [17418]
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17428 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-03 20:45:45 +00:00
Aymeric Augustin ccbadbc5c2 Improved the fix of r17416 so it actually works on all platforms. Refs #17469.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17417 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-01 21:36:18 +00:00
Aymeric Augustin dcbd5eefd6 Fixed #17469 -- Prevented a double URL-to-filesystem path translation in the media handler of LiveServerTestCase, which led to infinite redirection loops under Windows and test failures.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17416 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-01 20:08:10 +00:00
Carl Meyer 844a24bbb9 Fixed #16921 -- Added assertHTMLEqual and assertHTMLNotEqual assertions, and converted Django tests to use them where appropriate. Thanks Greg Müllegger.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17414 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-01-31 20:36:11 +00:00
Carl Meyer a678e9ea65 Fixed #17604 - Added context-manager capability to assertTemplateUsed and assertTemplateNotUsed. Thanks Greg Müllegger.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17412 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-01-31 19:23:09 +00:00
Aymeric Augustin 56b37bf1cf Fixed #17499 -- Ensured assertFieldOutput works for fields that customize the "required" error message. Thanks dpifke for the report and patch, and claudep for the tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17345 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-01-07 10:26:29 +00:00
Julien Phalip 0bf2d33770 Added the ability to specify multiple ports available for the `LiveServerTestCase` WSGI server. This allows multiple processes to run the tests simultaneously and is particularly useful in a continuous integration context. Many thanks to Aymeric Augustin for the suggestions and feedback.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17289 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-29 20:22:13 +00:00
Julien Phalip 2f02a05ffb Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-22 08:33:58 +00:00
Julien Phalip 4f00a2d316 Fixed #15826 -- Made `assertContains` and `assertNotContains` work with `SimpleTemplateResponse` by forcing it to be rendered if it hasn't been rendered yet. Thanks to bmihelac for the report, to mmcnickle for the initial patch and tests, and to Carl Meyer for the guidance.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17025 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-22 09:15:50 +00:00
Julien Phalip 03d4a8d1b6 Fixed #16990 -- Fixed a couple of small docstring typos in the `django/test/testcases.py` module and did some minor cleanup while I was in the area.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16928 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-05 12:50:44 +00:00
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