Commit Graph

859 Commits

Author SHA1 Message Date
Ian Foote 3828879eee Fixed #32220 -- Added durable argument to transaction.atomic(). 2020-11-27 21:43:15 +01:00
Hasan Ramezani 3f7b327562 Fixed #31235 -- Made assertQuerysetEqual() compare querysets directly.
This also replaces assertQuerysetEqual() to
assertSequenceEqual()/assertCountEqual() where appropriate.

Co-authored-by: Peter Inglesby <peter.inglesby@gmail.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-11-06 09:24:50 +01:00
Carlton Gibson ebb08d1942
Fixed #32159 -- Ensured AsyncRequestFactory correctly sets headers. 2020-11-04 11:07:15 +01:00
Patrick Arminio 542b4b3ab4 Fixed #32162 -- Fixed setting Content-Length header in AsyncRequestFactory. 2020-11-03 10:12:40 +01:00
Martin Thoma 302caa40e4 Made small readability improvements. 2020-10-28 20:20:20 +01:00
Carlton Gibson e17ee44688 Fixed #32128 -- Added asgiref 3.3 compatibility.
Thread sensitive parameter is True by default from asgiref v3.3.0.
Added an explicit thread_sensitive=False to previously implicit uses.
2020-10-27 11:24:07 +01:00
Jacob Walls e26a7a8ef4 Fixed #27906 -- Fixed test tools counting of HTML matches for subsets of elements.
Previously examples such as '<a/><b/>' would not match in '<a/><b/><c/>'.
2020-09-24 12:52:41 +02:00
François Freitag 57dadfac3c Fixed #31944 -- Used addCleanup() to register TestContextDecorator cleanups.
Cleanups from addCleanup() are scheduled to happen in reverse order to
the order they are added (LIFO). Ensures each cleanup is executed from
the innermost to the outermost.
2020-09-07 08:07:26 +02:00
Jon Dufresne 0b8871ab67
Fixed #31979 -- Made django.test.utils.setup_databases()'s time_keeper argument optional. 2020-09-03 09:48:40 +02:00
Mads Jensen 3a6fa1d962 Added missing items to django.test.client.__all__ and django.test.utils.__all__. 2020-08-14 11:48:04 +02:00
Mads Jensen 3718bc5c8d Removed unnecessary urlsplit() call from SimpleTestCase.assertRedirects(). 2020-08-14 11:48:04 +02:00
Ahmad A. Hussein 61a0ba43cf Refs #31811 -- Added optional timing outputs to the test runner. 2020-08-13 17:17:15 +02:00
David Smith e74b3d724e Bumped minimum isort version to 5.1.0.
Fixed inner imports per isort 5.
isort 5.0.0 to 5.1.0 was unstable.
2020-07-30 10:58:59 +02:00
Adam Johnson e906ff6fca Fixed #30457 -- Added TestCase.captureOnCommitCallbacks(). 2020-07-13 11:56:46 +02:00
ovkulkarni b7a438c7e2 Fixed #31509 -- Made DiscoverRunner enable faulthandler by default. 2020-07-10 18:55:50 +02:00
Ahmad A. Hussein 7c947f0f5a Fixed #31494 -- Preserved query strings when following HTTP 307/308 redirects in test client. 2020-05-27 10:36:52 +02:00
Simon Charette 3cf80d3fcf Fixed #31395 -- Made setUpTestData enforce in-memory data isolation.
Since it's introduction in Django 1.8 setUpTestData has been suffering
from a documented but confusing caveat due to its sharing of attributes
assigned during its execution with all test instances.

By keeping track of class attributes assigned during the setUpTestData
phase its possible to ensure only deep copies are provided to test
instances on attribute retreival and prevent manual setUp gymnastic to
work around the previous lack of in-memory data isolation.

Thanks Adam Johnson for the extensive review.
2020-05-15 20:22:52 +02:00
Jon Dufresne d6aff369ad Refs #30116 -- Simplified regex match group access with Match.__getitem__().
The method has been available since Python 3.6. The shorter syntax is
also marginally faster.
2020-05-11 12:01:28 +02:00
Andrew Godwin fc0fa72ff4 Fixed #31224 -- Added support for asynchronous views and middleware.
This implements support for asynchronous views, asynchronous tests,
asynchronous middleware, and an asynchronous test client.
2020-03-18 19:59:12 +01:00
Andrew Godwin 17009e9105 Refs #31224 -- Added autoconversion of test async methods. 2020-03-05 14:29:21 +01:00
Jon Dufresne 769cee5252 Fixed #31327 -- Deprecated providing_args argument for Signal. 2020-03-05 09:38:52 +01:00
yura 54b7af7eb4 Fixed #31250 -- Ignored processing instructions in assertXMLEqual()/assertXMLNotEqual(). 2020-02-13 11:03:54 +01:00
Simon Charette 430e796980 Refs #31055 -- Made DiscoverRunner skip running system checks on unused test databases. 2020-02-07 11:01:31 +01:00
Jon Dufresne 9cc743d0c8
Closed caches in clear_cache_handlers() signal handler.
This also fixes ResourceWarnings about unclosed sockets emitted in
cache.tests.
2020-02-07 08:03:25 +01:00
Baptiste Mispelon 9e565386d3 Fixed #27430 -- Added -b/--buffer option to DiscoverRunner. 2019-12-09 13:47:12 +01:00
Jon Dufresne 2540c5f08c Removed unnecessary dict.get() call in favor of direct indexing.
The 'TEST' key is always set to a dictionary in ConnectionHandler.
2019-12-04 11:34:06 +01:00
Jon Dufresne aa12cf07c9 Removed unnecessary numeric indexes in format strings. 2019-11-19 08:29:47 +01:00
Hasan Ramezani e3d0b4d550 Fixed #30899 -- Lazily compiled import time regular expressions. 2019-10-29 09:22:26 +01:00
André Ericson 3120490912 Fixed #30876 -- Moved classproperty() decorator to the django.utils.functional. 2019-10-21 09:57:39 +02:00
Pavel Savchenko 1711c509fa Fixed #27391 -- Implemented SimpleTestCase.debug().
debug() should bubbled up exceptions if occurring in test, but behave
the same as run() when no exceptions occurred.
2019-10-18 12:22:51 +02:00
Patrick Jenkins 46e74a5256 Fixed #28337 -- Preserved extra headers of requests made with django.test.Client in assertRedirects().
Co-Authored-By: Hasan Ramezani <hasan.r67@gmail.com>
2019-10-18 08:42:51 +02:00
Mariusz Felisiak b61ea56789 Refs #28478 -- Removed support for TestCase's allow_database_queries and multi_db per deprecation timeline. 2019-09-10 12:01:00 +02:00
Mariusz Felisiak 3d716467a9 Refs #29817 -- Removed settings.FILE_CHARSET per deprecation timeline. 2019-09-10 12:01:00 +02:00
swatantra 73ac9e3f04 Fixed #30677 -- Improved error message for urlencode() and Client when None is passed as data. 2019-08-11 20:15:23 +02:00
Andrew Godwin 052388aba4 Fixed #30676 -- Added --pdb option to test runner. 2019-08-07 08:16:31 +02:00
Andrew Godwin a415ce70be Fixed #30451 -- Added ASGI handler and coroutine-safety.
This adds an ASGI handler, asgi.py file for the default project layout,
a few async utilities and adds async-safety to many parts of Django.
2019-06-20 12:29:43 +02:00
Min ho Kim 6e8303d49b Fixed typos in FakePayload docstring and SimplifiedURLTests test name. 2019-06-17 12:38:04 +02:00
Jon Dufresne d6ea4898c4 Fixed #30550 -- Fixed decoding of non-UTF-8 bytes objects in response.json(). 2019-06-07 06:40:15 +02:00
Caio Ariede 753b67c58d Fixed #30497 -- Ignored document type in assertXMLEqual()/assertXMLNotEqual(). 2019-05-24 07:29:42 +02:00
Johannes Hoppe 8d010f3986 Fixed #30220 -- Added support for headless mode in selenium tests. 2019-05-17 08:14:54 +02:00
Jon Dufresne 7c3732a1b4 Fixed #30470 -- Added assertHTMLEqual() support for all self closing tags.
Support for the following tags was added: area, embed, param, track, and
wbr.

The full list of self closing tags is documented at:

https://html.spec.whatwg.org/#void-elements
2019-05-10 12:04:07 +02:00
Jon Dufresne b7a33ee4f0 Fixed #30468 -- Fixed assertHTMLEqual() to handle all ASCII whitespace in a class attribute. 2019-05-09 17:18:18 +02:00
Jon Dufresne 48235ba807 Refs #30399 -- Made assertHTMLEqual normalize character and entity references. 2019-05-09 15:55:32 +02:00
François Freitag 568eed9e79 Fixed #30245 -- Added -k option to DiscoverRunner. 2019-04-30 16:20:51 +02:00
Jon Dufresne 8b3f1c35dd Removed unnecessary assignments in various code. 2019-04-24 13:09:29 +02:00
Ramiro Morales aed89adad5 Fixed #30367 -- Changed "pip install" to "python -m pip install" in docs, comments and hints. 2019-04-18 14:41:15 +02:00
Jon Dufresne 45dfb3641a Minimized try block in Client.request(). 2019-03-11 10:39:59 -04:00
Jon Dufresne ff09add274 Refs #18807 -- Removed unused exception handler from Client.request().
Unused since 8bd7b598b6.
2019-03-10 18:10:51 -07:00
Jon Dufresne 7feddd878c Fixed #18707 -- Added support for the test client to return 500 responses. 2019-02-20 12:16:10 +01:00
Jon Dufresne 76990cbbda Fixed #30171 -- Fixed DatabaseError in servers tests.
Made DatabaseWrapper thread sharing logic reentrant. Used a reference
counting like scheme to allow nested uses.

The error appeared after 8c775391b7.
2019-02-14 10:04:55 -05:00
Sergey Fedoseev 1933e56eca Removed uneeded generator expressions and list comprehensions. 2019-02-09 09:18:48 -05:00
Nick Pope 24b82cd201 Fixed #30159 -- Removed unneeded use of OrderedDict.
Dicts preserve order since Python 3.6.
2019-02-06 13:48:39 -05:00
Tim Graham 6d2ae49f25 Refs #27753 -- Removed django.test.utils.patch_logger() and str_prefix(). 2019-02-05 12:52:07 -05:00
Jon Dufresne ac956dae1d Fixed grammar in FakePayload exception message. 2019-01-25 08:43:21 -08:00
Jon Dufresne d15c61cabb Fixed #30121 -- Fixed assertURLEqual() crash with reverse_lazy() URLs.
Regression in 24959e48d9.
2019-01-21 09:31:33 -05:00
Jon Dufresne ad7aa02c1d Removed unnecessary string formatting of strings. 2019-01-14 21:04:00 -05:00
Simon Charette b181aba7dd Refs #28478 -- Prevented database feature based skipping on tests disallowing queries.
Database features may require a connection to be established to determine
whether or not they are enabled.
2019-01-14 16:16:30 -05:00
Simon Charette f5b635086a Refs #28478 -- Prevented connection attempts against disallowed databases in tests.
Mocking connect as well as cursor methods makes sure an appropriate error
message is surfaced when running a subset of test attempting to access a
a disallowed database.
2019-01-14 16:05:00 -05:00
Simon Charette 41e73de39d Fixed #28478 -- Make DiscoverRunner skip creating unused test databases.
SimpleTestCase.databases makes it possible to determine the set of
databases required to run the discovered tests.
2019-01-10 19:11:21 -05:00
Simon Charette 8c775391b7 Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
Jon Dufresne 6fe9c45b72 Fixed #30024 -- Made urlencode() and Client raise TypeError when None is passed as data. 2018-12-27 11:19:55 -05:00
Tim Graham 4c7c608a1d Reverted "Fixed #25251 -- Made data migrations available in TransactionTestCase when using --keepdb."
This reverts commits b3b1d3d45f and
9fa0d3786f due to reverse build failures
for which a solution isn't forthcoming.
2018-12-05 15:30:23 -05:00
romgar 9fa0d3786f Refs #25251 -- Filtered out skipped tests when processing the test suite to set _next_serialized_rollback. 2018-11-29 11:20:27 -05:00
takaaki shimbo 6275b50ac2 Fixed typo in patch_logger() docstring. 2018-11-25 14:43:26 -05:00
romgar b3b1d3d45f Fixed #25251 -- Made data migrations available in TransactionTestCase when using --keepdb.
Data loaded in migrations were restored at the beginning of each
TransactionTestCase and all the tables are truncated at the end of
these test cases. If there was a TransactionTestCase at the end of
the test suite, the migrated data weren't restored in the database
(especially unexpected when using --keepdb). Now data is restored
at the end of each TransactionTestCase.
2018-11-06 16:57:50 -05:00
Tim Graham 1c948e544e Refs #29883 -- Removed runtests.py's dependency on selenium.
Regression in d207ac1568.
2018-11-03 19:02:31 -04:00
Tom Forbes d207ac1568 Fixed #29883 -- Added selenium hub support to runtests.py. 2018-11-03 09:56:14 -04:00
Jayden Kneller 916aecd29d Fixed #29866 -- Made DiscoverRunner do tests tear down if running checks or tests raises an exception. 2018-10-30 12:01:48 -04:00
Jon Dufresne e90af8bad4 Capitalized "Python" in docs and comments. 2018-10-09 09:26:07 -04:00
Sergey Fedoseev 8ef8bc0f64 Refs #28909 -- Simplifed code using unpacking generalizations. 2018-09-28 09:57:12 -04:00
Jon Dufresne 82f286cf6f Refs #29784 -- Switched to https:// links where available. 2018-09-26 08:48:47 +02:00
Dan Palmer e181666973 Fixed #29687 -- Allowed the test client to serialize list/tuple as JSON. 2018-08-25 10:57:05 -04:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) 233c70f047 Fixed #29658 -- Registered model lookups in tests with a context manager. 2018-08-21 12:17:46 -04:00
Kamil 3d4080f19c Fixed #29024 -- Made TestContextDecorator call disable() if setUp() raises an exception. 2018-08-17 16:30:27 -04:00
Marnanel Thurman 7cc52250f0 Fixed #29662 -- Allowed test client to accept structured suffix JSON content types. 2018-08-15 10:27:45 -04:00
Sławek Ehlert c6238bf02b Fixed #29467 -- Made override_settings handle errors in setting_changed signal receivers. 2018-07-30 15:59:37 -04:00
Thng Kai Yuan 71a739f3d7 Fixed #29576 -- Corrected the test client's HTTP_COOKIE header. 2018-07-21 18:14:39 -04:00
Mariusz Felisiak a73cf8110e Removed duplicate words in various comments. 2018-07-18 11:54:15 -04:00
Tim Graham 5bea8d256d
Fixed #29553 -- Made test client set Content-Length header to a string rather than integer. 2018-07-09 11:44:49 -04:00
Claude Paroz eac9ab7ebb Removed parser.add_arguments() arguments that match the defaults. 2018-07-02 17:54:57 -04:00
Tim Graham 9294110a57 Fixed #29520 -- Fixed test client crash when posting bytes.
Regression in b8a41a2872.
2018-06-27 14:50:03 -04:00
Jan Pieter Waagmeester 24959e48d9 Fixed #27398 -- Added an assertion to compare URLs, ignoring the order of their query strings. 2018-06-20 13:26:12 -04:00
Jon Dufresne 8dcd43ce06 Restored django.test.utils.patch_logger() for backwards compatibility.
Added back after 607970f31c.
2018-06-12 11:33:16 -04:00
Morgan Aubert 704443acac Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage(). 2018-05-09 11:40:28 -04:00
Claude Paroz 607970f31c Replaced django.test.utils.patch_logger() with assertLogs().
Thanks Tim Graham for the review.
2018-05-07 09:34:00 -04:00
Chris Lamb 84ad721bd9 Fixed #29275 -- Made assertFormError() output "(actual errors: none)" instead of "(actual errors: )". 2018-03-31 18:35:45 -04:00
Mariusz Felisiak 362813d628
Fixed hanging indentation in various code. 2018-03-16 10:54:34 +01:00
Sanyam Khurana 5a669ae2f4 Fixed #29106 -- Made DiscoverRunner display selected test tags. 2018-02-13 12:56:31 -05:00
Tim Graham b8a41a2872 Refs #27795 -- Removed force_bytes() in django.test.client where possible. 2018-02-12 11:03:11 -05:00
Jon Dufresne 919d59811f Refs #27795 -- Removed force_text() usage in django/test/testcases.py. 2018-02-10 11:44:39 -05:00
Nick Sarbicki 47268242b0 Fixed #29082 -- Allowed the test client to encode JSON request data. 2018-02-06 18:29:04 -05:00
Tom 272f685794 Fixed #27999 -- Added test client support for HTTP 307 and 308 redirects. 2018-02-06 09:03:43 -05:00
Jon Dufresne ff05de760c Fixed #29038 -- Removed closing slash from HTML void tags. 2018-01-21 02:09:10 -05:00
Will Ayd 09530e61a0 Fixed #28869 -- Made tagged test classes and methods inherit tags from parents. 2018-01-08 20:57:33 -05:00
Дилян Палаузов d7b2aa24f7 Fixed #28982 -- Simplified code with and/or. 2018-01-03 20:12:23 -05:00
Tim Graham acc8dd4142
Fixed #28984 -- Made assorted code simplifications. 2018-01-03 13:24:02 -05:00
Дилян Палаузов d79cf1e9e2 Fixed #28985 -- Removed unneeded None checks before hasattr(). 2018-01-03 11:37:06 -05:00
Дилян Палаузов 4c599ece57 Fixed #28930 -- Simplified code with any() and all(). 2017-12-26 17:11:15 -05:00
Nick Pope f3a98224e6 Refs #28909 -- Simplifed code using unpacking generalizations. 2017-12-21 21:05:23 -05:00
Nick Pope d13a9e44de Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking. 2017-12-11 07:08:45 -05:00