Commit Graph

638 Commits

Author SHA1 Message Date
Josh Soref 93452a70e8 Fixed many spelling mistakes in code, comments, and docs. 2015-12-03 12:48:24 -05:00
Baptiste Mispelon ab33269b00 Fixed #25826 -- Improved help text for the --parallel option
This was overlooked in 81f5d63218.
2015-11-27 23:08:34 +01:00
Tim Graham ce737ac678 Fixed #25647 -- Reverted "Simplified deduplication of test databases."
This reverts commit 49eee84245 as it caused
a regression with test mirrors.
2015-11-14 07:52:21 -05:00
Mattia Larentis 2085d8d5bc Fixed #25170 -- Made assertXMLEqual()/assertXMLNotEqual() ignore leading and trailing whitespace.
Thanks Jacek Bzdak for indepdently contributing a similar fix.
2015-11-09 15:53:30 -05:00
Ville Skyttä 3ee18400ae Fixed #25668 -- Misc spelling errors 2015-11-03 11:58:13 +02:00
Tim Graham 0b5d32faca Fixed #25611 -- Standardized descriptor signatures. 2015-10-26 11:31:16 -04:00
Tim Graham 2a20ebe6a5 Removed deprecated TEMPLATE_* settings per deprecation timeline. 2015-09-23 19:31:11 -04:00
Tim Graham 1392aff440 Refs #21977 -- Removed SimpleTestCase.urls per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham 04ee4059d7 Refs #24022 -- Removed the ssi tag per deprecation timeline. 2015-09-23 19:31:09 -04:00
Travis Jensen 1a09b3c398 Fixed #25424 -- Use force_str for test client URLs.
urlparse() fails with an AttributeError ("'__proxy__' object has no
attribute 'decode'") if reverse_lazy is used to look up the URL
(this is exactly the same problem that caused ticket #18776). The
solution is to use force_str() on the path before handing it to
urlparse().
2015-09-19 15:05:54 +02:00
Aymeric Augustin 2425f6fda0 Prevented --parallel from crashing on Windows.
Since --parallel is documented not to work on Windows, it's better to
ignore it and run without parallelization than to crash. For example
this could simplify cross-platform test scripts.
2015-09-14 22:52:04 +02:00
Dražen Odobašić b1e33ceced Fixed #23395 -- Limited line lengths to 119 characters. 2015-09-12 11:40:50 -04:00
Aymeric Augustin 0cc0e676c0 And fixed merge accident :-( 2015-09-10 18:24:03 +02:00
Aymeric Augustin 613ee39bf8 Adjusted previous commit.
Sigh.
2015-09-10 18:21:56 +02:00
Aymeric Augustin 968b02f8f0 Refs #20461 -- Made tblib optional for a passing test run.
This was the original intent.
2015-09-10 18:21:13 +02:00
Collin Anderson c97b755a1c Refs #20461 -- Fixed parallel test runner on Python 2.7.
textwrap.indent() is new in Python 3.3.
2015-09-10 12:00:42 -04:00
Aymeric Augustin 710b4a7032 Avoided running more test processes than necessary.
This reduces the time spent cloning databases.

Thanks Tim for the suggestion.
2015-09-10 14:37:51 +02:00
Aymeric Augustin 39bb66baad Made it easier to customize the parallel test runner.
Subclass private APIs is marginally better than monkey-patching them,
even if it doesn't make a big difference in practice.
2015-09-09 23:03:52 +02:00
Aymeric Augustin e8b49d4cc4 Propagated database clone settings to new connections. 2015-09-09 23:03:51 +02:00
Aymeric Augustin 073ea9e852 Acknoweldeged a limitation of the parallel test runner.
Notably it will fail to report a Model.DoesNotExist exceptions because
the class itself isn't pickleable. (Django has specific code to make its
instances pickleable.)
2015-09-09 23:03:44 +02:00
Aymeric Augustin ba81386487 Introduced a mixin for serializing tests. 2015-09-09 23:01:17 +02:00
Aymeric Augustin 326bc0955b Allowed a port range for the liveserver by default.
This is required for running tests in parallel.
2015-09-09 23:01:16 +02:00
Aymeric Augustin 0586c061f0 Cloned databases for running tests in parallel. 2015-09-09 23:01:15 +02:00
Aymeric Augustin cd9fcd4e80 Implemented a parallel test runner. 2015-09-09 23:01:10 +02:00
Jakub Gocławski a7901c2e09 Refs #25328 -- Refactored LiveServerTestCase to make it extensible. 2015-09-07 08:48:17 -04:00
Aymeric Augustin 49eee84245 Simplified deduplication of test databases.
Use the same code path for:

- a database that has the same settings as another database
  (as defined by test_db_signature)
- a database this is defined as a mirror of another database

There's no conceptual difference between these two cases.

Thanks Shai for the suggestion.
2015-09-06 10:02:47 +02:00
Aymeric Augustin e8bfc1c747 Stopped returning mirrors from setup_databases.
The return value of setup_databases is only used as an argument for
teardown_databases which doesn't need mirrors.
2015-09-06 09:28:16 +02:00
Aymeric Augustin 79c3f226dd Fixed #25357 -- Database deduplication on Oracle.
In order to reuse another database, Django must use set_as_test_mirror.
2015-09-06 09:18:02 +02:00
Aymeric Augustin 5ace1887f2 Split setup_databases.
It contained two sections separated by comments. It makes more sense to
put each section in its own function.
2015-09-06 09:16:27 +02:00
Aymeric Augustin c4bdf52005 Moved an import to the toplevel. 2015-09-05 22:24:46 +02:00
Maxime Lorant 5153a3bfdc Fixed #25331 -- Removed trailing blank lines in docstrings. 2015-08-31 17:37:21 -04:00
Markus Holtermann e1427cc609 Fixed #24590 -- Cached calls to swappable_setting.
Moved the lookup in Field.swappable_setting to Apps, and added
an lru_cache to cache the results.

Refs #24743

Thanks Marten Kenbeek for the initial work on the patch. Thanks Aymeric
Augustin and Tim Graham for the review.
2015-08-27 17:06:21 +10:00
Tommy Beadle d3fdaf907d Fixed #23727 -- Inhibited the post_migrate signal when using serialized_rollback.
When using a TransactionTestCase with serialized_rollback=True,
after creating the database and running its migrations (along with
emitting the post_migrate signal), the contents of the database
are serialized to _test_serialized_contents.

After the first test case, _fixture_teardown() would flush the
tables but then the post_migrate signal would be emitted and new
rows (with new PKs) would be created in the django_content_type
table. Then in any subsequent test cases in a suite,
_fixture_setup() attempts to deserialize the content of
 _test_serialized_contents, but these rows are identical to the
rows already in the database except for their PKs.  This causes an
IntegrityError due to the unique constraint in the
django_content_type table.

This change made it so that in the above scenario the post_migrate
signal is not emitted after flushing the tables, since it will be
repopulated during fixture_setup().
2015-08-24 08:59:20 -04:00
pscottdevos 7fa1dd8a80 Fixed #25163 -- Fixed exception handling in nested test client requests. 2015-08-11 10:01:24 -04:00
Caio Ariede 62d4074005 Fixed #25191 -- Added string diff to SimpleTestCase.assertXMLEqual() message. 2015-08-04 09:16:34 -04:00
Adam Chainz 0abb06930f Fixed #25176 -- Prevented TestCase.setUpTestData() exception from leaking transaction. 2015-08-01 07:33:22 -04:00
Tim Graham 1c7c782d6e Fixed #25188 -- Improved message raised by SimpleTestCase.assertRaisesMessage().
Thanks Chris Jerdonek for the suggestion and help with the patch.
2015-07-31 09:19:27 -04:00
Tim Graham d27e0f04a6 Fixed #25190 -- Deprecated callable_obj parameter to assertRaisesMessage().
Thanks Aymeric Augustin for review.
2015-07-30 10:12:41 -04:00
Jon Dufresne b44dee16e6 Fixed #20916 -- Added Client.force_login() to bypass authentication. 2015-07-01 13:01:08 -04:00
Tim Graham 7da3923ba0 Sorted imports in __init__.py files. 2015-06-27 11:53:33 -04:00
Tim Graham aaacaeb096 Renamed RemovedInDjangoXYWarnings for new roadmap.
Forwardport of ae1d663b79
from stable/1.8.x plus more.
2015-06-24 16:08:20 -04:00
Moritz Sichert d58573e60d Refs #24965 -- Added changes from accidentally reverted file for last commit. 2015-06-12 18:29:26 -04:00
Erik Romijn 1daae25bdc Fixed #16860 -- Added password validation to django.contrib.auth. 2015-06-07 19:31:20 +02:00
Shai Berger 35291df7f7 Fixed #19542: Made mirroring databases for tests work with Oracle
No tests are provided because there is no sane way to test database
settings within the Django test suite.

Thanks Aymeric Augustin for review.
2015-06-05 12:29:15 +03:00
Andy McKay 4525a0c466 Fixed #24773 -- Added a json() method on test client responses. 2015-05-25 10:42:30 -04:00
Preston Timmons 655f524915 Fixed #17085, #24783 -- Refactored template library registration.
* Converted the ``libraries`` and ``builtins`` globals of
  ``django.template.base`` into properties of the Engine class.
* Added a public API for explicit registration of libraries and builtins.
2015-05-21 09:12:06 -05:00
Simon Charette c15b0c2792 Fixed #24652 -- Disallowed query execution in SimpleTestCase subclasses.
Thanks to Tim and Anssi for the review.
2015-05-20 12:50:41 -04:00
Tim Graham e89c3a4603 Added backwards compatibility for assertRaisesMessage callable_obj param.
This was broken in c2bc1cefdc (refs #23763).
2015-05-18 10:04:18 -04:00
Aymeric Augustin ed83881e64 Fixed #23820 -- Supported per-database time zone.
The primary use case is to interact with a third-party database (not
primarily managed by Django) that doesn't support time zones and where
datetimes are stored in local time when USE_TZ is True.

Configuring a PostgreSQL database with the TIME_ZONE option while USE_TZ
is False used to result in silent data corruption. Now this is an error.
2015-05-17 09:40:28 +02:00
Tim Graham c2bc1cefdc Refs #23763 -- Silenced SimpleTestCase.assertRaisesMessage() deprecation warning on Python 3.5.
Deprecation warning was introduced in https://bugs.python.org/issue24134
2015-05-16 10:42:12 -04:00
Piotr Jakimiak 4157c502a5 Removed unnecessary arguments in .get method calls 2015-05-13 20:51:18 +02:00
Tim Graham 8efea1b8d5 Fixed #24526 -- Combined django.request/security loggers with the root logger.
Thanks Carl Meyer for review.
2015-04-24 11:07:42 -04:00
Simon Charette dc27f3ee0c Fixed #19259 -- Added group by selected primary keys support. 2015-03-29 22:03:30 -04:00
Claude Paroz a0c2eb46dd Fixed #23960 -- Removed http.fix_location_header
Thanks Carl Meyer for the report and Tim Graham for the review.
2015-03-18 18:22:50 +01:00
Bas Peschier 0339844b70 Fixed #24476 -- Added context manager/decorator for overriding script prefix.
Tests were using an undocumented keyword argument for easily overriding
script prefix while reversing. This is now changed into a test utility
which can be used as decorator or context manager.
2015-03-18 13:03:25 -04:00
Claude Paroz 23c612199a Simplified emit_post_migrate from flush command
Follow-up of f4f24d30e0.
2015-02-28 16:10:32 +01:00
Aymeric Augustin 15b711b5ee Deprecated TEMPLATE_DEBUG setting. 2015-02-15 20:47:04 +01:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Tim Graham bbe28496d3 Removed old import aliases. 2015-02-05 19:37:01 -05:00
Aymeric Augustin 146dd7be8d Called parent in SimpleTestCase.setUpClass/tearDownClass. 2015-02-05 21:27:25 +01:00
mlavin 2730dad0d7 Fixed #24197 -- Added clearing of staticfiles caches on settings changes during tests
Cleared caching in staticfiles_storage and get_finder when
relevant settings are changed.
2015-02-04 10:53:04 -05:00
Aymeric Augustin 2133f3157e Fixed #24168 -- Allowed selecting a template engine in a few APIs.
Specifically in rendering shortcuts, template responses, and class-based
views that return template responses.

Also added a test for render_to_response(status=...) which was missing
from fdbfc980.

Thanks Tim and Carl for the review.
2015-02-03 08:29:45 +01:00
Tim Graham 5fb582d952 Removed test.utils.TestTemplateLoader per deprecation timeline. 2015-01-18 14:19:14 -05:00
Marc Tamlyn b5c1a85b50 Fixed #24118 -- Added --debug-sql option for tests.
Added a --debug-sql option for tests and runtests.py which outputs the
SQL logger for failing tests. When combined with --verbosity=2, it also
outputs the SQL for passing tests.

Thanks to Berker, Tim, Markus, Shai, Josh and Anssi for review and
discussion.
2015-01-12 08:16:08 +00:00
Claude Paroz 3bac904607 Removed extraneous super call in LiveServerTestCase
Refs #21281. Thanks Tim Graham and Thomas Chaumeny for investigations.
2015-01-03 10:13:20 +01:00
Claude Paroz 66f9a74b45 Added ignore_warnings decorator
And removed Ignore*DeprecationWarningsMixin, now obsolete.
Thanks Berker Peksag and Tim Graham for the review.
2014-12-30 18:16:25 +01:00
Andriy Sokolovskiy 8c99b7920e Fixed #12118 -- Added shared cache support to SQLite in-memory testing. 2014-12-30 10:14:33 -05:00
Aymeric Augustin 1acfd624d6 Added initial support for loading template engines. 2014-12-28 16:08:31 +01:00
Collin Anderson 5dddd79433 Fixed #20349 -- Moved setting_changed signal to django.core.signals.
This removes the need to load django.test when not testing.
2014-12-24 07:18:43 -05:00
Thomas Chaumeny 994d6137a2 Fixed #23792 -- Added test.utils.freeze_time() context manager. 2014-12-22 07:46:40 -05:00
Thomas Chaumeny 2ca0870b67 Fixed #23992 -- Optimized reorder_suite functions using OrderedSet 2014-12-14 13:38:01 +01:00
Thomas Chaumeny 119154ca7f Refs #20392 -- Load fixtures once within TestCase 2014-12-12 09:16:15 -05:00
Jon Dufresne 4468c08d70 Fixed #23968 -- Replaced list comprehension with generators and dict comprehension 2014-12-08 07:58:23 -05:00
Diego Guimarães 9f427617e4 Refs #23947 -- Worked around a bug in Python that prevents deprecation warnings from appearing in tests. 2014-12-06 14:46:01 -05:00
Aymeric Augustin 4832320e8d Updated obsolete comment. 2014-12-06 20:39:53 +01:00
Thomas Tanner 018d110ef5 Fixed #23911 -- Added support for buffer file uploads in the test client 2014-12-04 07:42:03 -05:00
Thomas Chaumeny da9fe5c717 Fixed #20392 -- Added TestCase.setUpTestData()
Each TestCase is also now wrapped in a class-wide transaction.
2014-12-03 10:37:04 -05:00
Tim Graham 82e4f956e3 Fixed #23289 -- Added mock as a test dependency. 2014-12-01 16:08:25 -05:00
wrwrwr e6f19ec322 Fixed #23933 -- Made override_settings(DATABASE_ROUTERS) affect the master router. 2014-12-01 11:30:50 -05:00
wrwrwr 6dbe979b4d Fixed #23930 -- Added copies of captured_std* managers from CPython's test.support.
StringIO import was adapted for compatibility with Python 2.
2014-11-29 11:21:58 -05:00
wrwrwr 056a3c6c37 Fixed #23682 -- Enhanced circular redirects detection in tests.
When the test client detects a redirect to a URL seen in the
currently followed chain it will now raise a RedirectCycleError
instead of just returning the first repeated response.

It will also complain when a single chain of redirects is longer
than 20, as this often means a redirect loop with varying URLs,
and even if it's not actually one, such long chains are likely
to be treated as loops by browsers.

Thanks Preston Timmons, Berker Peksag, and Tim Graham for reviews.
2014-11-25 10:12:28 -05:00
wrwrwr e22c64dfc0 Fixed #23742 -- Added an option to reverse tests order.
This is useful for debugging side effects affecting tests that
are usually executed before a given test. Full suite and pair
tests sort cases more or less deterministically, thus some test
cross-dependencies are easier to reveal by reversing the order.

Thanks Preston Timmons for the review.
2014-11-24 19:24:11 -05:00
Aymeric Augustin 6294bd3903 Encapsulated TEMPLATE_DEBUG in Engine. 2014-11-23 11:54:17 +01:00
Aymeric Augustin 37505b6397 Encapsulated TEMPLATE_CONTEXT_PROCESSORS in Engine.
Since RequestContext doesn't know its Engine until it's passed to
Template.render() -- and cannot without breaking a widely used public
API -- an elaborate hack is required to apply context processors.
2014-11-23 11:53:18 +01:00
Aymeric Augustin a2dd08666c Removed dependency of template loaders on Django settings. 2014-11-23 11:52:14 +01:00
Aymeric Augustin 29a977ab14 Moved template loaders management in Engine.
Passed the engine instance to loaders. This is a prerequisite for
looking up configuration on the engine instance instead of global
settings.

This is backwards incompatible for custom template loaders that override
__init__. However the documentation doesn't talk about __init__ and the
way to pass arguments to custom template loaders isn't specified. I'm
considering it a private API.
2014-11-23 11:52:12 +01:00
Aymeric Augustin 572cdb4391 Introduced a template engine class.
Moved Django templates loading infrastructure there.
2014-11-23 09:29:53 +01:00
Aymeric Augustin f88ad710fa Simplified caching of template context processors. 2014-11-19 21:35:39 +01:00
Aymeric Augustin a97e72aaab Simplified caching of templatetags modules. 2014-11-19 21:35:39 +01:00
Aymeric Augustin e23240474b Simplified caching of get_default_timezone(). 2014-11-19 21:35:39 +01:00
Aymeric Augustin 9eeb788cfb Refactored getting the list of template loaders.
This provides the opportunity to move utility functions specific to the
Django Template Language outside of django.template.loader.
2014-11-16 21:41:44 +01:00
Aymeric Augustin b503fee7ec Removed override_template_loaders and override_with_test_loader.
They can be replaced with override_settings and that makes the
corresponding tests much more obvious.
2014-11-16 21:40:50 +01:00
Aymeric Augustin d58597a7b8 Refactored listing template subdirectories in apps.
This change has the nice side effect of removing code that ran at import
time and depended on the app registry at module level -- a notorious
cause of AppRegistryNotReady exceptions.
2014-11-16 21:28:43 +01:00
Aymeric Augustin 2577ae6a08 Moved all template loaders under django.template.loaders.
Reformatted the code of base.Loader according to modern standards.

Turned the test template loader into a regular locmem.Loader -- but
didn't document it.

Added a normal deprecation path for BaseLoader which is a public API.

Added an accelerated deprecation path for TestTemplateLoader which is
a private API.
2014-11-16 21:28:26 +01:00
Aymeric Augustin cffa559082 Fixed regression in 4dc4d12e. Refs #21598.
That commit contained a mistake that resulted in the use_cached_loader
option of override_with_test_loader being ignored. As a consequence some
configurations weren't exercised any more by the test suite.
2014-11-16 21:25:09 +01:00
Aymeric Augustin b239c3d27e Fixed negligible formatting error. 2014-11-10 21:41:35 +01:00
Thomas Chaumeny 498ae3a360 Removed legacy code from old transaction system 2014-11-10 18:28:46 +01:00
Davide Ceretti 2d06e3155a Fixed #23300 -- Made assertTemplateUsed throw an error on responses not fetched using the test client.
Thanks zags for the report and bmispelon for the patch.
2014-11-03 14:31:23 -05:00
Thomas Chaumeny d89f56dc4d Fixed #21281 -- Made override_settings act at class level when used as a TestCase decorator. 2014-11-03 14:14:39 -05:00
Rigel Di Scala 28634394f5 Fixed #23606 -- Implemented Client and RequestFactory trace() methods.
Thanks KevinEtienne for the suggestion.
2014-10-28 10:11:12 -04:00