Commit Graph

119 Commits

Author SHA1 Message Date
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
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
Adam Johnson e906ff6fca Fixed #30457 -- Added TestCase.captureOnCommitCallbacks(). 2020-07-13 11:56:46 +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 505fec6bad Capitalized Unicode in docs, strings, and comments. 2020-04-20 12:10:33 +02:00
Author: Mads Jensen 6461583b6c Removed unused __str__() methods in tests models.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-Authored-By: Hasan Ramezani <hasan.r67@gmail.com>
2020-04-15 20:20:32 +02:00
Mariusz Felisiak b330b918e9
Removed unused and incorrect PossessedCar.__str__() method in test_utils.
PossessedCar doesn't have a color.
2020-02-14 13:16:17 +01:00
yura 54b7af7eb4 Fixed #31250 -- Ignored processing instructions in assertXMLEqual()/assertXMLNotEqual(). 2020-02-13 11:03:54 +01:00
Hasan Ramezani fc4f45ebdc Used assertRaisesMessage() in various tests. 2020-02-07 12:46:23 +01:00
Jon Dufresne 3259983f56 Fixed #31233 -- Closed database connections and cursors after use. 2020-02-06 15:35:23 +01:00
Matthijs Kooijman 2a2ea4ee18 Refs #31117 -- Made various tests properly handle unexpected databases aliases.
- Used selected "databases" instead of django.db.connections.
- Made routers in tests.migrations skip migrations on unexpected
  databases.
- Added DiscoverRunnerGetDatabasesTests.assertSkippedDatabases() hook
  which properly asserts messages about skipped databases.
2020-01-20 14:39:02 +01: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
Pavel Savchenko dc8cd2fefd Refs #27391 -- Added more tests for SimpleTestCase. 2019-10-18 11:11:34 +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
Caio Ariede 753b67c58d Fixed #30497 -- Ignored document type in assertXMLEqual()/assertXMLNotEqual(). 2019-05-24 07:29:42 +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 de6d3afb97 Refs #27804 -- Used subTest() in HTMLEqualTests.test_self_closing_tags. 2019-05-09 17:17:42 +02:00
Jon Dufresne 48235ba807 Refs #30399 -- Made assertHTMLEqual normalize character and entity references. 2019-05-09 15:55:32 +02:00
Jon Dufresne 5627057f63 Refs #26022 -- Used context manager version of assertRaisesMessage in tests.
Follow up to 253adc2b8a.
2019-04-29 08:05:07 +02:00
Jon Dufresne c492fdfd24 Removed default empty content argument from HttpResponse calls. 2019-02-09 16:27:32 -05:00
Himanshu Lakhara 22aab8662f Fixed #30004 -- Changed default FILE_UPLOAD_PERMISSION to 0o644. 2019-02-08 14:53:15 -05:00
Jon Dufresne d15c61cabb Fixed #30121 -- Fixed assertURLEqual() crash with reverse_lazy() URLs.
Regression in 24959e48d9.
2019-01-21 09:31:33 -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 8c775391b7 Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
Tim Graham 043bd70942 Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -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
Simon Charette 84e7a9f4a7 Switched setUp() to setUpTestData() where possible in Django's tests. 2018-11-27 09:35:17 -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 f892781b95 Fixed #28606 -- Deprecated CachedStaticFilesStorage. 2018-10-27 11:58:29 -04:00
Kamil 3d4080f19c Fixed #29024 -- Made TestContextDecorator call disable() if setUp() raises an exception. 2018-08-17 16:30:27 -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
Morgan Aubert 704443acac Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage(). 2018-05-09 11:40:28 -04:00
CHI Cheng 4660ce5a69 Fixed #29375 -- Removed empty action attribute on HTML forms. 2018-05-02 09:20:04 -04:00
Tim Graham cfff2af02b Fixed #27857 -- Dropped support for Python 3.4. 2017-09-25 17:11:03 -04:00
Mads Jensen a51c4de194 Used assertRaisesMessage() to test Django's error messages. 2017-07-29 19:07:23 -04:00
reficul31 92e286498a Fixed #27539 -- Made TransactionTestCase._pre_setup() clear the queries_log so it's less likely to overflow.
TransactionTestCase.assertNumQueries() fails in an overflow situation.
2017-06-16 21:06:13 -04:00
Claude Paroz 43c65e0eb0 Fixed #28180 -- Numbered queries in assertNumQueries failure output
Thanks Tim Graham for the test part.
2017-05-20 15:11:09 +02:00
François Freitag 98b3b14a64 Fixed #28203 -- Ignored connection configuration queries in assertNumQueries(). 2017-05-18 11:48:03 -04:00
Tim Graham 6b4f018b2b Replaced type-specific assertions with assertEqual().
Python docs say, "it's usually not necessary to invoke these methods directly."
2017-03-17 07:51:48 -04:00
Chris Lamb 339d526d55 Fixed #27873 -- Fixed crash in setup_test_environment() if ALLOWED_HOSTS is a tuple.
Regression in 17e661641d
2017-02-24 13:58:56 -05:00
chillaranand d6eaf7c018 Refs #23919 -- Replaced super(ClassName, self) with super(). 2017-01-25 12:23:46 -05:00
Tim Graham 7aba69145d Refs #23919 -- Removed django.test.mock Python 2 compatibility shim. 2017-01-20 08:17:20 -05:00
Tim Graham 4e729feaa6 Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
2017-01-20 08:01:02 -05:00
Tim Graham 109b33f64c Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2. 2017-01-20 08:49:47 +01:00
Claude Paroz 2b281cc35e Refs #23919 -- Removed most of remaining six usage
Thanks Tim Graham for the review.
2017-01-18 21:33:28 +01:00
Claude Paroz 7b2f2e74ad Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz f3c43ad1fd Refs #23919 -- Removed python_2_unicode_compatible decorator usage 2017-01-18 13:44:34 +01:00