Skip to content
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

Tests: Silence naive datetime warning spam #2415

Closed
JacobCoffee opened this issue Mar 19, 2024 · 2 comments Β· Fixed by #2601
Closed

Tests: Silence naive datetime warning spam #2415

JacobCoffee opened this issue Mar 19, 2024 · 2 comments Β· Fixed by #2601
Labels
tests Relates to the test suite

Comments

@JacobCoffee
Copy link
Member

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.

When running tests we get this:

Tests Example pythondotorg on  4.2 [πŸ“++(1)βœ“] via πŸ‹ colima via πŸ€– v21.6.1 via  pyenv via πŸ’Ž v2.6.10 took 14s βœ— docker-compose run --rm web ./manage.py test events.tests.test_importer.EventsImporterTestCase [+] Creating 2/0 βœ” Container pythondotorg-redis-1 Running 0.0s βœ” Container pythondotorg-postgres-1 Running 0.0s Found 4 test(s). Creating test database for alias 'default'... System check identified no issues (0 silenced). ./usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2015-03-28 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2015-03-29 00:00:00) while time zone support is active. warnings.warn( ./usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-05-16 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-05-18 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-06-18 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-06-20 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-05-13 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-05-17 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-07-26 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-07-27 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-03-14 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-03-14 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-02-01 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-02-02 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-06-13 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-06-15 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-02-07 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-02-09 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-02-21 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-02-23 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-08-01 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-08-05 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-07-06 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-07-12 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-03-29 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2014-03-30 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-02-22 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2014-07-21 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2013-10-17 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-10-20 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2013-10-26 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-10-29 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2013-11-01 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-11-01 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2013-10-03 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-10-04 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-11-02 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2013-11-08 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-11-10 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_start received a naive datetime (2013-08-31 00:00:00) while time zone support is active. warnings.warn( /usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1535: RuntimeWarning: DateTimeField OccurringRule.dt_end received a naive datetime (2013-09-01 00:00:00) while time zone support is active. warnings.warn(

Describe the solution you'd like
A clear and concise description of what you want to happen. Ex. It would be great if [...]

It would be nice to silence these until we can fix them either by settings.py:

import warnings

warnings.filterwarnings(
    "ignore",
    message="DateTimeField .* received a naive datetime",
    category=RuntimeWarning,
    module='django.db.models.fields',
)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

  • we could subclass the testrunner SuppressingSpamyWarningsTestRunner but that seems like a lot of repetition across all tests/ dirs.

Additional context
Add any other context or screenshots about the feature request here.

@JacobCoffee
Copy link
Member Author

Something like

Index: pydotorg/settings/base.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pydotorg/settings/base.py b/pydotorg/settings/base.py
--- a/pydotorg/settings/base.py	(revision 127dcc930ab323d391bc6939a370673c7fae26e8)
+++ b/pydotorg/settings/base.py	(date 1710913519229)
@@ -1,4 +1,6 @@
 import os
+import warnings
+
 from dj_database_url import parse as dj_database_url_parser
 from decouple import config
 
@@ -21,6 +23,14 @@
     'site_descript': 'The official home of the Python Programming Language',
 }
 
+### silence naive DT warning during 2.2 -> 4.2 migration
+warnings.filterwarnings(
+    "ignore",
+    message="DateTimeField .* received a naive datetime",
+    category=RuntimeWarning,
+    module='django.db.models.fields',
+)
+
 ### Databases
 
 DATABASES = {

@miketheman
Copy link
Member

miketheman commented Sep 20, 2024

Instead of silencing, I tried solving it here: #2601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Relates to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants