1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00
django/tests
Shai Berger 72ebe85a26 Fixed #27910 -- Added enumeration helpers for use in Field.choices.
These classes can serve as a base class for user enums, supporting
translatable human-readable names, or names automatically inferred
from the enum member name.

Additional properties make it easy to access the list of names, values
and display labels.

Thanks to the following for ideas and reviews:

Carlton Gibson, Fran Hrženjak, Ian Foote, Mariusz Felisiak, Shai Berger.

Co-authored-by: Shai Berger <shai@platonix.com>
Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-09-04 14:42:49 +02:00
..
absolute_url_overrides
admin_autodiscover
admin_changelist Fixed #30064 -- Added form to validate admin search fields query input. 2019-08-22 14:09:49 +02:00
admin_checks Fixed #30312 -- Relaxed admin check from django.contrib.sessions to SessionMiddleware subclasses. 2019-04-26 11:31:06 +02:00
admin_custom_urls Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
admin_default_site
admin_docs Fixed #30731 -- Fixed handling trailing groups in simplify_regex(). 2019-08-30 12:43:39 +02:00
admin_filters Refs #30449 -- Made RelatedOnlyFieldListFilter respect ModelAdmin.ordering. 2019-08-15 10:29:10 +02:00
admin_inlines Fixed #30520 -- Fixed crash of admin model inlines on custom fields without labels. 2019-06-04 10:27:12 +02:00
admin_ordering
admin_registration Fixed #27360 -- Added app or ModelAdmin details for AreadyRegistered exceptions. 2019-03-25 17:34:53 -04:00
admin_scripts Replaced subprocess commands by run() wherever possible. 2019-08-23 10:53:36 +02:00
admin_utils Fixed #30400 -- Improved typography of user facing strings. 2019-06-28 16:46:18 +02:00
admin_views Fixed #30722 -- Added default rate-limiting requests to admin's Select2 widget. 2019-08-27 13:47:36 +02:00
admin_widgets Fixed #30722 -- Added default rate-limiting requests to admin's Select2 widget. 2019-08-27 13:47:36 +02:00
aggregation Fixed #30665 -- Added support for distinct argument to Avg() and Sum(). 2019-07-31 11:22:50 +02:00
aggregation_regress Fixed typos in test names and a comment. 2019-08-23 10:46:43 +02:00
annotations Fixed #28289 -- Fixed crash of RawSQL annotations on inherited model fields. 2019-07-11 08:27:15 +02:00
app_loading
apps Fixed #27685 -- Added watchman support to the autoreloader. 2019-01-13 20:33:47 -05:00
asgi Refs #30451 -- Added more tests for ASGIRequest and ASGIHandler. 2019-06-20 12:29:58 +02:00
async Fixed #30451 -- Added ASGI handler and coroutine-safety. 2019-06-20 12:29:43 +02:00
auth_tests Fixed #18763 -- Added ModelBackend/UserManager.with_perm() methods. 2019-08-29 19:32:12 +02:00
backends Refs #30593 -- Fixed introspection of check constraints columns on MariaDB. 2019-07-30 16:32:13 +02:00
base
bash_completion
basic Fixed #29260 -- Skipped an UPDATE when adding a model instance with primary key that has a default. 2019-08-19 13:28:35 +02:00
builtin_server Fixed typos in test names and a comment. 2019-08-23 10:46:43 +02:00
bulk_create Refs #29444 -- Renamed DatabaseFeatures.can_return_id* to be generic for other columns. 2019-01-30 15:31:56 -05:00
cache Fixed #30701 -- Updated patch_vary_headers() to handle an asterisk according to RFC 7231. 2019-08-16 15:25:42 +02:00
check_framework Fixed #30673 -- Relaxed system check for db_table collision when database routers are installed by turning the error into a warning. 2019-08-08 21:14:06 +02:00
conditional_processing Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
constraints Refs #11964 -- Made constraint support check respect required_db_features. 2019-08-12 06:44:37 +02:00
contenttypes_tests Fixed #29706 -- Made RenameContentType._rename() save to the correct database. 2019-06-06 12:09:01 +02:00
context_processors Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
csrf_tests Fixed #30137 -- Replaced OSError aliases with the canonical OSError. 2019-01-28 11:15:06 -05:00
custom_columns Followed style guide for model attribute ordering. 2018-12-27 19:34:14 -05:00
custom_lookups Removed unnecessary type() calls for class methods. 2019-02-06 22:00:32 -05:00
custom_managers
custom_methods
custom_migration_operations
custom_pk
datatypes
dates Refs #26022 -- Used context manager version of assertRaisesMessage in tests. 2019-04-29 08:05:07 +02:00
datetimes
db_functions Fixed #30661 -- Added models.SmallAutoField. 2019-08-02 11:39:01 +02:00
db_typecasts
db_utils Fixed #30071 -- Fixed error message when a 'default' database isn't provided. 2019-01-09 10:58:37 -05:00
dbshell Fixed broken OracleDbshellTests tests after 9386586f31. 2019-08-23 21:25:21 +02:00
decorators Fixed #30594 -- Added 'private' Cache-Control directive to never_cache() decorator. 2019-06-26 09:25:24 +02:00
defer Fixed typos in comments and a test name. 2019-07-19 18:24:06 +02:00
defer_regress
delete Fixed #30436 -- Added check that on_delete is callable in ForeignKey and OneToOneField. 2019-05-13 07:25:42 +02:00
delete_regress
deprecation
dispatch
distinct_on_fields
empty
empty_models Fixed #30595 -- Added error message when no objects found to sql* management commands. 2019-07-01 13:47:54 +02:00
expressions Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude(). 2019-08-29 09:45:29 +02:00
expressions_case Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude(). 2019-08-29 09:45:29 +02:00
expressions_window Fixed #30668 -- Made QuerySet.filter() raise NotSupportedError if any of source expressions is not filterable. 2019-08-02 15:06:00 +02:00
extra_regress Fixed #30159 -- Removed unneeded use of OrderedDict. 2019-02-06 13:48:39 -05:00
field_deconstruction
field_defaults
field_subclassing Fixed #30657 -- Allowed customizing Field's descriptors with a descriptor_class attribute. 2019-07-25 08:15:20 +02:00
file_storage Refs #28428 -- Made FileField.upload_to support pathlib.Path. 2019-08-18 20:34:58 +02:00
file_uploads Cleaned up exception message checking in some tests. 2019-03-15 19:27:57 -04:00
files Fixed #30137 -- Replaced OSError aliases with the canonical OSError. 2019-01-28 11:15:06 -05:00
filtered_relation Fixed #30349 -- Fixed QuerySet.exclude() on FilteredRelation. 2019-05-07 14:47:50 +02:00
fixtures Renamed camelCaseTestMethods to snake_case_test_methods 2019-04-14 16:14:14 +02:00
fixtures_model_package Renamed camelCaseTestMethods to snake_case_test_methods 2019-04-14 16:14:14 +02:00
fixtures_regress Followed style guide for model attribute ordering. 2018-12-27 19:34:14 -05:00
flatpages_tests Fixed #30400 -- Improved typography of user facing strings. 2019-06-28 16:46:18 +02:00
force_insert_update
foreign_object
forms_tests Corrected several typos in string literals and test names. 2019-08-07 11:23:14 +02:00
from_db_value Refs #28370 -- Removed support for the context arg of Field.from_db_value() and Expression.convert_value(). 2019-01-17 10:52:19 -05:00
generic_inline_admin Fixed #27755 -- Added ModelAdmin.get_inlines() hook. 2019-04-17 07:16:04 +02:00
generic_relations Fixed #30493 -- Fixed prefetch_related() for GenericRelation with different content types. 2019-05-31 18:11:55 +02:00
generic_relations_regress
generic_views Fixed typo in tests/generic_views/test_base.py. 2019-06-04 20:09:07 -04:00
get_earliest_or_latest Refs #11557 -- Removed the field_name keyword argument to QuerySet.earliest() and latest(). 2019-01-17 10:52:19 -05:00
get_object_or_404
get_or_create
gis_tests Fixed #29955 -- Added support for distance expression to the dwithin lookup. 2019-08-23 21:28:28 +02:00
handlers Fixed #30070, CVE-2019-3498 -- Fixed content spoofing possiblity in the default 404 page. 2019-01-03 21:21:55 -05:00
httpwrappers Fixed #30294 -- Allowed HttpResponse to accept memoryview content. 2019-03-29 09:43:49 -04:00
humanize_tests Refs #27804 -- Used subTest() in filesizeformat tests and HumanizeTests. 2019-06-10 08:46:11 +02:00
i18n Replaced subprocess commands by run() wherever possible. 2019-08-23 10:53:36 +02:00
import_error_package
indexes Fixed #30108 -- Allowed adding foreign key constraints in the same statement that adds a field. 2019-01-29 15:42:57 -05:00
inline_formsets
inspectdb Used re.Pattern.findall() instead of re.findall() in inspectdb.tests. 2019-05-24 09:04:27 +02:00
introspection Refs #30591 -- Fixed introspection of check and unique column constraints on MariaDB. 2019-08-26 09:15:37 +02:00
invalid_models_tests Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin and refactored AutoFields. 2019-08-20 09:22:25 +02:00
known_related_objects
logging_tests Fixed #29714 -- Allowed using ExceptionReporter subclass with AdminEmailHandler. 2019-09-04 08:40:46 +02:00
lookup Fixed #29545 -- Fixed using filter lookups againts nested subquery expressions. 2019-08-17 11:24:35 +02:00
m2m_and_m2o Followed style guide for model attribute ordering. 2018-12-27 19:34:14 -05:00
m2m_intermediary Corrected several typos in string literals and test names. 2019-08-07 11:23:14 +02:00
m2m_multiple
m2m_recursive Fixed #30421 -- Allowed symmetrical intermediate table for self-referential ManyToManyField. 2019-06-21 15:03:17 +02:00
m2m_regress Refs #26022 -- Used context manager version of assertRaisesMessage in tests. 2019-04-29 08:05:07 +02:00
m2m_signals
m2m_through Fixed #30421 -- Allowed symmetrical intermediate table for self-referential ManyToManyField. 2019-06-21 15:03:17 +02:00
m2m_through_regress Fixed #9475 -- Allowed RelatedManager.add(), create(), etc. for m2m with a through model. 2019-01-15 11:12:17 -05:00
m2o_recursive
mail Fixed #30608 -- Fixed non-unicode EmailMessage crash when domain name for localhost is non-ASCII. 2019-07-03 10:49:03 +02:00
managers_regress
many_to_many Refs #26678 -- Added tests for using the field the relation points to with RelatedManager.add()/remove()/set(). 2019-05-07 09:02:06 +02:00
many_to_one Fixed #30661 -- Added models.SmallAutoField. 2019-08-02 11:39:01 +02:00
many_to_one_null
max_lengths Fixed #30295 -- Fixed max_lengths.tests.MaxLengthORMTests when run in isolation. 2019-03-28 10:18:30 +01:00
messages_tests Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
middleware Fixed #30604 -- Made mail_admins()/mail_managers() raise ValueError if ADMINS/MANAGERS is set incorrectly. 2019-07-02 07:34:07 +02:00
middleware_exceptions Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
migrate_signals
migration_test_data_persistence
migrations Fixed #27910 -- Added enumeration helpers for use in Field.choices. 2019-09-04 14:42:49 +02:00
migrations2
model_enums Fixed #27910 -- Added enumeration helpers for use in Field.choices. 2019-09-04 14:42:49 +02:00
model_fields Fixed #27910 -- Added enumeration helpers for use in Field.choices. 2019-09-04 14:42:49 +02:00
model_forms Fixed #30400 -- Improved typography of user facing strings. 2019-06-28 16:46:18 +02:00
model_formsets Followed style guide for model attribute ordering. 2018-12-27 19:34:14 -05:00
model_formsets_regress Used 4 space hanging indent for dictionaries. 2019-01-02 18:18:19 -05:00
model_indexes Fixed #30397 -- Added app_label/class interpolation for names of indexes and constraints. 2019-07-08 14:57:56 +02:00
model_inheritance Fixed #30116 -- Dropped support for Python 3.5. 2019-01-30 10:19:48 -05:00
model_inheritance_regress
model_meta Merged isinstance() calls. 2019-03-02 12:19:21 +01:00
model_options Fixed #30023 -- Prevented SQLite schema alterations while foreign key checks are enabled. 2018-12-15 18:51:59 -05:00
model_package
model_regress Moved choices inside of a test model per coding style. 2019-03-20 11:05:26 -04:00
modeladmin Fixed #30543 -- Fixed checks of ModelAdmin.list_display for fields accessible only via instance. 2019-07-10 10:37:34 +02:00
multiple_database Fixed #16027 -- Added app_label to ContentType.__str__(). 2019-02-07 19:56:47 -05:00
mutually_referential
nested_foreign_keys
no_models
null_fk
null_fk_ordering Followed style guide for model attribute ordering. 2018-12-27 19:34:14 -05:00
null_queries
one_to_one Refs #28147 -- Fixed setting of OneToOne and Foreign Key fields to None when using attnames. 2019-07-27 12:04:56 +02:00
or_lookups
order_with_respect_to Tested Model.set_FOO_order() with an unrelated object. 2019-01-21 17:02:15 -05:00
ordering Refs #30557 -- Fixed crash of ordering by ptr fields when Meta.ordering contains F() expressions. 2019-07-11 13:40:36 +02:00
pagination Improved error message when index in __getitem__() is invalid. 2019-07-23 20:12:08 +02:00
postgres_tests Fixed #30715 -- Fixed crash of ArrayField lookups on ArrayAgg annotations over AutoField. 2019-08-23 10:43:08 +02:00
prefetch_related Fixed typo in tests/prefetch_related/tests.py comment. 2019-08-26 08:14:29 +02:00
project_template Refs #30426 -- Changed default SECURE_CONTENT_TYPE_NOSNIFF to True. 2019-08-18 13:17:49 +02:00
properties
proxy_model_inheritance
proxy_models Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
queries Fixed #30739 -- Fixed exclusion of multi-valued lookup against outer rhs. 2019-09-02 10:52:36 +02:00
queryset_pickle Fixed #30727 -- Made Subquery pickle without evaluating their QuerySet. 2019-08-27 13:05:20 +02:00
raw_query
redirects_tests Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
requests Fixed typos in test names and a comment. 2019-08-23 10:46:43 +02:00
requirements Refs #30451 -- Added asgiref to the tests requirements. 2019-06-24 08:10:23 +02:00
reserved_names
resolve_url Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
responses Fixed #30565 -- Closed HttpResponse when wsgi.file_wrapper closes file-like object. 2019-06-20 11:48:49 +02:00
reverse_lookup
save_delete_hooks
schema Fixed typos in test names and a comment. 2019-08-23 10:46:43 +02:00
select_for_update Fixed Python PendingDeprecationWarning in select_for_update.tests. 2019-04-29 08:47:33 +02:00
select_related
select_related_onetoone
select_related_regress
serializers Corrected several typos in string literals and test names. 2019-08-07 11:23:14 +02:00
servers Fixed #30619 -- Made runserver --nothreading use single threaded WSGIServer. 2019-07-10 13:22:17 +02:00
sessions_tests Fixed #28763 -- Allowed overriding the session cookie age with SessionStore.get_session_cookie_age(). 2019-05-21 08:50:09 +02:00
settings_tests Switched to use HTTP_X_FORWARDED_PROTO custom header in tests. 2019-08-12 12:51:26 +02:00
shell
shortcuts Refs #25978 -- Removed shortcuts.render_to_response() per deprecation timeline. 2019-01-17 10:50:25 -05:00
signals
signed_cookies_tests
signing
sitemaps_tests Fixed #30159 -- Removed unneeded use of OrderedDict. 2019-02-06 13:48:39 -05:00
sites_framework
sites_tests Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
staticfiles_tests Fixed #30599 -- Prevented ManifestFilesMixin.read_manifest() from silencing errors other than FileNotFoundError. 2019-08-02 08:35:28 +02:00
str
string_lookup
swappable_models Refs #27790 -- Reverted "Removed available_apps on TestCase subclasses." 2017-01-28 10:01:13 -05:00
syndication_tests Fixed #29352 -- Allowed specifying a Feed language. 2019-05-06 15:10:54 +02:00
template_backends
template_loader
template_tests Fixed CVE-2019-14232 -- Adjusted regex to avoid backtracking issues when truncating HTML. 2019-08-01 09:24:54 +02:00
templates
test_client Fixed #30677 -- Improved error message for urlencode() and Client when None is passed as data. 2019-08-11 20:15:23 +02:00
test_client_regress Fixed #30550 -- Fixed decoding of non-UTF-8 bytes objects in response.json(). 2019-06-07 06:40:15 +02:00
test_exceptions
test_runner Corrected several typos in string literals and test names. 2019-08-07 11:23:14 +02:00
test_runner_apps Fixed #30245 -- Added -k option to DiscoverRunner. 2019-04-30 16:20:51 +02:00
test_utils Fixed #30497 -- Ignored document type in assertXMLEqual()/assertXMLNotEqual(). 2019-05-24 07:29:42 +02:00
timezones Fixed #30400 -- Improved typography of user facing strings. 2019-06-28 16:46:18 +02:00
transaction_hooks
transactions Fixed #30116 -- Dropped support for Python 3.5. 2019-01-30 10:19:48 -05:00
unmanaged_models
update Fixed #28408 -- Added error message when updating with annotated expressions on joined fields. 2019-06-28 07:55:32 +02:00
update_only_fields
urlpatterns Fixed #29667 -- Prohibited whitespaces in path() URLs. 2019-08-20 11:53:10 +02:00
urlpatterns_reverse Added tests for terminated path with optional arguments in django.urls.reverse(). 2019-06-24 11:30:26 +02:00
user_commands Fixed #30584 -- Fixed management command when using subparsers with dest parameter. 2019-06-28 12:51:26 +02:00
utils_tests Fixed #30747 -- Renamed is_safe_url() to url_has_allowed_host_and_scheme(). 2019-09-02 15:32:23 +02:00
validation Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin and refactored AutoFields. 2019-08-20 09:22:25 +02:00
validators
version
view_tests Fixed #29008 -- Fixed crash of 404 debug page when URL path converter raises Http404. 2019-08-09 22:48:08 +02:00
wsgi Fixed #30567 -- Made WSGIHandler pass FileResponse.block_size to wsgi.file_wrapper. 2019-07-26 07:31:51 +02:00
.coveragerc
README.rst Fixed #30367 -- Changed "pip install" to "python -m pip install" in docs, comments and hints. 2019-04-18 14:41:15 +02:00
runtests.py Replaced subprocess commands by run() wherever possible. 2019-08-23 10:53:36 +02:00
test_sqlite.py
urls.py

To run the test suite, first, create and activate a virtual environment. Then
install some requirements and run the tests::

    $ cd tests
    $ python -m pip install -e ..
    $ python -m pip install -r requirements/py3.txt
    $ ./runtests.py

For more information about the test suite, see
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/.