Commit Graph

123 Commits

Author SHA1 Message Date
Mariusz Felisiak 1a7d75cf77
Moved remaining SimpleTestCase.assertFormError()/assertFormsetErrors() tests to test_utils.
This also removes redundant tests in test_client_regress.

Follow up to 68144f4049.
2022-04-05 08:37:28 +02:00
Adam Johnson a8c15481f4 Rewrote some references to "master".
Following d9a266d657.
2022-03-08 14:50:06 +01:00
Nick Pope 847f46e9bf
Removed redundant QuerySet.all() calls in docs and tests.
Most QuerySet methods are mapped onto the Manager and, in general,
it isn't necessary to call .all() on the manager.
2022-02-22 10:29:38 +01:00
Baptiste Mispelon f7e0bffa2e Refs #33348 -- Made SimpleTestCase.assertFormError() raise ValueError when "field" is passed without "form_index". 2022-02-15 10:30:20 +01:00
Mariusz Felisiak d4c9dab74b Refs #33348 -- Fixed SimpleTestCase.assertFormError() error message raised for unbound forms. 2022-02-15 10:16:06 +01:00
Baptiste Mispelon d84cd91e90 Refs #33348 -- Improved messages raised by SimpleTestCase.assertFormError()/assertFormsetErrors().
This makes messages use BaseFormSet/BaseForm.__repr__() instead of
context, and adds the _assert_form_error() helper.
2022-02-15 07:15:44 +01:00
Baptiste Mispelon 9bb13def5d Refs #33348 -- Made SimpleTestCase.assertFormsetErrors() raise an error when form_index is too big. 2022-02-14 12:46:46 +01:00
Baptiste Mispelon 7986028e3f Refs #33348 -- Made SimpleTestCase.assertFormError()/assertFormsetErrors() raise an error for unbound forms/formsets. 2022-02-14 08:43:46 +01:00
Mariusz Felisiak 7119f40c98 Refs #33476 -- Refactored code to strictly match 88 characters line length. 2022-02-07 20:37:05 +01:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Mariusz Felisiak c5cd878382
Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g.

def make_random_password(
    self,
    length=10,
    allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):

or

cursor.execute("""
SELECT ...
""",
    [table name],
)
2022-02-03 11:20:46 +01:00
Baptiste Mispelon c67e1cf44f Refs #33348 -- Deprecated passing errors=None to SimpleTestCase.assertFormError()/assertFormsetErrors(). 2022-01-06 17:29:32 +01:00
Petter Friberg bc174e6ea0 Fixed #33410 -- Fixed recursive capturing of callbacks by TestCase.captureOnCommitCallbacks().
Regression in d89f976bdd.
2022-01-06 06:38:17 +01:00
Ad Timmering 806efe912b Fixed #33400 -- Added support for msg_prefix and count arguments to assertTemplateUsed()/assertTemplateNotUsed() used as context managers. 2022-01-05 12:49:42 +01:00
Baptiste Mispelon cb383753c0 Fixed #33346 -- Fixed SimpleTestCase.assertFormsetError() crash on a formset named "form".
Thanks OutOfFocus4 for the report.

Regression in 456466d932.
2021-12-08 20:33:03 +01:00
Baptiste Mispelon 9ac92b1efc Refs #33301 -- Made SimpleTestCase.assertFormError()/assertFormsetErrors() raise ValueError for non test client responses. 2021-11-26 13:10:43 +01:00
Baptiste Mispelon 68144f4049 Added tests for SimpleTestCase.assertFormError()/assertFormsetErrors(). 2021-11-26 12:36:25 +01:00
SwastikTripathi 76f07b4fcf Fixed #33278 -- Improved error for connection/query attempts against disallowed databases in tests. 2021-11-15 11:46:10 +01:00
Pratyush Mittal f38458fe56 Fixed #33236 -- Fixed assertHTMLEqual() error messages for escaped HTML. 2021-10-29 12:09:23 +02:00
Mariusz Felisiak e2be307b3a Refs #31235 -- Made assertQuerysetEqual() not call repr() on a queryset when compared to string values.
Per deprecation timeline.
2021-09-20 21:23:01 +02:00
Eugene Morozov d89f976bdd Fixed #33054 -- Made TestCase.captureOnCommitCallbacks() capture callbacks recursively. 2021-08-30 07:06:22 +02:00
Baptiste Mispelon 41e6b2a3c5 Fixed #32556 -- Fixed handling empty string as non-boolean attributes value by assertHTMLEqual(). 2021-03-19 20:41:57 +01:00
Hasan Ramezani 9bf5e9418f Fixed #32556 -- Fixed assertHTMLEqual() to handle empty string as boolean attributes value. 2021-03-18 16:30:15 +01:00
François Freitag 7ca7f4495b Refs #21429 -- Added SimpleTestCase.assertNoLogs() on Python < 3.10. 2021-03-02 20:35:33 +01:00
Jacob Walls 64a0d1ef6e Fixed typo in assertQuerysetEqual() exception message. 2021-02-26 21:12:11 +01:00
Nick Pope 0e4e35722a Fixed #32469 -- Made assertQuerysetEqual() respect maxDiff when ordered=False. 2021-02-22 09:27:46 +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
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
Jon Dufresne 505fec6bad Capitalized Unicode in docs, strings, and comments. 2020-04-20 12:10:33 +02: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
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
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
Simon Charette 84e7a9f4a7 Switched setUp() to setUpTestData() where possible in Django's tests. 2018-11-27 09:35:17 -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