-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-90535: Warn of deprecation of intervals other than 1 with when='MIDNIGHT'
#98099
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5755,6 +5755,16 @@ def test_compute_rollover_daily_attime(self): | |
finally: | ||
rh.close() | ||
|
||
def test_midnight_interval(self): | ||
with warnings.catch_warnings(record=True) as w: | ||
rh = logging.handlers.TimedRotatingFileHandler( | ||
self.fn, encoding="utf-8", when='MIDNIGHT', interval=2, backupCount=0, | ||
utc=True) | ||
rh.close() | ||
if w: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want the test to pass if no warning is raised? If not then in the above I would force deprecations on as exceptions via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Thanks for the review, Brett. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use |
||
self.assertIs(w[0].category, DeprecationWarning) | ||
self.assertIn('An interval of 2 is incompatible ', str(w[0].message)) | ||
|
||
#@unittest.skipIf(True, 'Temporarily skipped while failures investigated.') | ||
def test_compute_rollover_weekly_attime(self): | ||
currentTime = int(time.time()) | ||
|
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 is better to defer the
warnings
module import until it is needed (which never happen in normal case).