-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #25415 -- Made DiscoverRunner run system checks. #6294
Conversation
@timgraham I've fixed all but the "CommaSeparatedIntegerField has been deprecated." warnings. Is there a recommended way of fixing them? We could just ignore the warning in the tests, or we could subclass it to ignore the warning and use that subclass throughout the test suite |
Can we use |
Although some instances are testing behaviour that might be dfiferent for Silencing across the entire test suite is potentially dangerous as it might prevent problems in future tests. Ideally we'd be able to silence for specific instances of warnings, though that sounds like a big yak shave... |
The idea of silencing specific warnings has come up before. It would be a nice to have, but as you said, not quite sure of the best implementation and how much work it would be. I don't see foresee any problems with silencing the warnings for |
5e3a4d2
to
778b584
Compare
Updated to use |
1eab279
to
5db2f8b
Compare
Added a release note, turned into two commits - one to fix discoverrunner, one to fix the errors 👍 |
There are some problems with the MySQL and MySQL GIS builds. |
5db2f8b
to
781367d
Compare
Both seem unrelated MySQL:
MySQL GIS:
Just rebased on master to retrigger builds, GIS error seems to have happened again. |
In the first case, I think the problem is that the checks are run on GIS models when a GIS backend isn't in use. |
Ah, that would do it |
Looks like you'll need to skip these checks if |
781367d
to
cf70c22
Compare
@@ -9,7 +9,6 @@ class AbstractArticle(models.Model): | |||
title = models.CharField(max_length=50) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it might be but wasn't sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created ticket: https://code.djangoproject.com/ticket/27073#ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested it and I can confirm that this is no longer needed after applying #7115.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @loic
beae876
to
b6365e3
Compare
@@ -203,8 +203,6 @@ def test_ticket_17477(self): | |||
|
|||
class Sqlite3InMemoryTestDbs(TestCase): | |||
|
|||
available_apps = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is related to any check errors, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the exception if it's removed:
======================================================================
ERROR: test_transaction_support (test_runner.tests.Sqlite3InMemoryTestDbs)
Ticket #16329: sqlite3 in-memory test databases
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/apps/registry.py", line 148, in get_app_config
return self.app_configs[app_label]
KeyError: 'auth'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tim/code/django/tests/test_runner/tests.py", line 227, in test_transaction_support
DiscoverRunner(verbosity=0).setup_databases()
File "/home/tim/code/django/django/test/runner.py", line 537, in setup_databases
self.parallel, **kwargs
File "/home/tim/code/django/django/test/utils.py", line 205, in setup_databases
call_command('check')
File "/home/tim/code/django/django/core/management/__init__.py", line 130, in call_command
return command.execute(*args, **defaults)
File "/home/tim/code/django/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/tim/code/django/django/core/management/commands/check.py", line 68, in handle
fail_level=getattr(checks, options['fail_level']),
File "/home/tim/code/django/django/core/management/base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "/home/tim/code/django/django/core/management/base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "/home/tim/code/django/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/tim/code/django/django/contrib/auth/checks.py", line 16, in check_user_model
cls = apps.get_model(settings.AUTH_USER_MODEL)
File "/home/tim/code/django/django/apps/registry.py", line 195, in get_model
return self.get_app_config(app_label).get_model(model_name.lower())
File "/home/tim/code/django/django/apps/registry.py", line 155, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'auth'.
We should check if this is the proper fix or if this reveals some other problem, I'm not sure offhand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried running the tests without it but they fail (only on Windows for some reason)
Afaict it was added just as an optimization. Starting a new DiscoverRunner inside the test suite re-runs the checks, one of which has been registered from auth
and fails because auth
is no longer in INSTALLED_APPS
. So I think just removing the available_apps
line is legit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamchainz, did you investigate this?
To address the new clashing table errors, I think we should modify that check to ignore unmanaged models. The patched I attached to https://code.djangoproject.com/ticket/27204 fixes the check errors that popped up in model_options and unmanaged_models. |
Some additional output capturing might be needed. I see several "System check identified no issues (21 silenced)." in the test output. |
@timgraham , Model (and fields) checks must not be run if all not all required db features are available on all connections. We should make |
@timgraham, that's what I had in mind: #7227. |
@@ -200,6 +201,9 @@ def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, paral | |||
for alias in connections: | |||
connections[alias].force_debug_cursor = True | |||
|
|||
# Now run the system checks. They aren't run until now since some checks require database access. | |||
call_command('check') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the verbosity
argument here.
62fb973
to
986da7a
Compare
41d2189
to
b70375e
Compare
I've merged in something similar to #7227 but only for the failing models. In the process I also found and removed some import hacks from the GIS tests which were missed when making GDAL a required dependency. Tests are green, ready for re-review 🎉 |
482d0dd
to
b4fb194
Compare
from django.db import connections | ||
|
||
|
||
class SkipChecksIfNotDBFeaturesMixin(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this could be useful in other tests at some point. Rather than burying it here, it might be useful to put it somewhere more reusable/discoverable (even if it's not public API at this point). Maybe django.core.checks.tests.py
? Any opinion @charettes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it's a bit specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a comment I wrote during DUTH github didn't post because the new review UI is unclear
b4fb194
to
fc65b7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySQL fails with:
django/contrib/gis/db/models/fields.py", line 123, in db_type
return connection.ops.geo_db_type(self)
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
|
||
class SkipChecksIfNotDBFeaturesMixin(object): | ||
""" | ||
Required because we make the models but then skip the tests for them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say, "Skip system checks on models that don't have all the required_db_features."
@@ -200,6 +201,9 @@ def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, paral | |||
for alias in connections: | |||
connections[alias].force_debug_cursor = True | |||
|
|||
# Now run the system checks. They aren't run until now since some checks require database access. | |||
call_command('check', verbosity=verbosity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the best place for this -- doesn't seem like "running system checks" is related to "setting up databases". Anyway, this function is documented in topics/testing/advanced.txt and the docs should be updated if this change happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason I put it here is because this is where it was implicitly being run in 1.7, as part of migrate
. Will try put it later in the flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember - another reason I did this was so that nose
, my test runner at the time, would automatically run them, because it calls setup_databases
. I now use pytest
which also has this behaviour, but I'm making pytest-django
run the checks itself in pytest-dev/pytest-django#414 .
@@ -397,6 +397,8 @@ Tests | |||
* Added support for :meth:`python:unittest.TestCase.subTest`’s when using the | |||
:option:`test --parallel` option. | |||
|
|||
* Tests now run checks at the start of the test run, as they did in Django 1.7. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "as they did in Django 1.7" needn't be mentioned at this point. For third-party test runners, it's probably also useful to mention exactly where the check are run from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
@@ -200,6 +201,9 @@ def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, paral | |||
for alias in connections: | |||
connections[alias].force_debug_cursor = True | |||
|
|||
# Now run the system checks. They aren't run until now since some checks require database access. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap comments at 79 characters.
@@ -8,6 +8,7 @@ | |||
class Command(BaseCommand): | |||
help = 'Discover and run tests in the specified modules or the current directory.' | |||
|
|||
# Tests do run the checks, but only after databases have been set up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use periods
Will fix MySQL failure. That's annoying, tests were passing before my rebase yesterday. |
8e53c42
to
5bf7ece
Compare
I found that there were more problem models in other parts of |
5bf7ece
to
84d1125
Compare
More check failures following 7cddd8a 😄 :
|
@adamchainz hopefully we can ship this before introducing yet another failing check 😄 |
84d1125
to
4ef20b2
Compare
@@ -402,6 +402,8 @@ Tests | |||
* Added support for :meth:`python:unittest.TestCase.subTest`’s when using the | |||
:option:`test --parallel` option. | |||
|
|||
* Tests now run checks at the start of the test run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain that it's DiscoverRunner
that does this. Perhaps the docs for DiscoverRunner
should also be updated.
@@ -8,6 +8,7 @@ | |||
class Command(BaseCommand): | |||
help = 'Discover and run tests in the specified modules or the current directory.' | |||
|
|||
# Tests do run the checks, but only after databases have been set up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DiscoverRunner runs checks after databases are set up.
4ef20b2
to
c3f3199
Compare
c3f3199
to
594458b
Compare
Revival of #5293.
Ticket 25415