-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Deprecated twisted.internet.defer.TimeoutError in favor of twisted.internet.error.TimeoutError #261
Changes from all commits
bcde3ef
b60f521
296f350
013b01f
a2a8e69
f5172b0
10bc7c4
8a7d903
c2d5045
1604b86
ae02805
e75623a
8a22bd8
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 |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
|
|
||
| from twisted.python import failure, log | ||
| from twisted.python.compat import _PY3 | ||
| from twisted.internet import defer, reactor | ||
| from twisted.internet import defer, reactor, error | ||
| from twisted.internet.task import Clock | ||
| from twisted.trial import unittest | ||
|
|
||
|
|
@@ -2344,7 +2344,7 @@ def test_waitUntilLockedWithTimeoutLocked(self): | |
| self.assertTrue(self.lock.lock()) | ||
|
|
||
| d = self.lock.deferUntilLocked(timeout=5.5) | ||
| self.assertFailure(d, defer.TimeoutError) | ||
| self.assertFailure(d, error.TimeoutError) | ||
|
|
||
| self.clock.pump([1] * 10) | ||
|
|
||
|
|
@@ -2357,7 +2357,7 @@ def test_waitUntilLockedWithTimeoutUnlocked(self): | |
| but the lock is unlocked before our timeout. | ||
| """ | ||
| def onTimeout(f): | ||
| f.trap(defer.TimeoutError) | ||
| f.trap(error.TimeoutError) | ||
|
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. here is a missing coverage which will block the merge :( 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. How do I test that? That code is inside a test that is supposed to be testing a condition that is never supposed to happen. 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 question :) I would say that we should have a ... but first, let's talk about it over the mailing list. I will start the conversation :) Thanks! |
||
| self.fail("Should not have timed out") | ||
|
|
||
| self.assertTrue(self.lock.lock()) | ||
|
|
@@ -2446,3 +2446,36 @@ def test_cancelDeferUntilLockedWithTimeout(self): | |
| self.assertFalse(timeoutCall.active()) | ||
| self.assertIsNone(self.lock._timeoutCall) | ||
| self.failureResultOf(deferred, defer.CancelledError) | ||
|
|
||
|
|
||
|
|
||
| class TimeoutErrorTests(unittest.TestCase, ImmediateFailureMixin): | ||
| def test_deprecatedTimeout(self): | ||
| """ | ||
| L{twisted.internet.defer.timeout} is deprecated. | ||
| """ | ||
| deferred = defer.Deferred() | ||
| defer.timeout(deferred) | ||
| self.assertFailure(deferred, error.TimeoutError) | ||
| warningsShown = self.flushWarnings([self.test_deprecatedTimeout]) | ||
| self.assertEqual(len(warningsShown), 1) | ||
| self.assertIdentical(warningsShown[0]['category'], DeprecationWarning) | ||
| self.assertEqual( | ||
| warningsShown[0]['message'], | ||
| 'twisted.internet.defer.timeout was deprecated in ' | ||
| 'Twisted 16.3.0') | ||
|
|
||
|
|
||
| def test_deprecatedTimeoutError(self): | ||
| """ | ||
| L{twisted.internet.defer.TimeoutError} is deprecated. | ||
| """ | ||
| defer.TimeoutError | ||
| warningsShown = self.flushWarnings([self.test_deprecatedTimeoutError]) | ||
| self.assertEqual(len(warningsShown), 1) | ||
| self.assertIdentical(warningsShown[0]['category'], DeprecationWarning) | ||
| self.assertEqual( | ||
| warningsShown[0]['message'], | ||
| 'twisted.internet.defer.TimeoutError was deprecated in ' | ||
| 'Twisted 16.3.0: Use twisted.internet.error.' | ||
| 'TimeoutError instead') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| twisted.internet.defer.TimeoutError is deprecated in favor of twisted.internet.error.TimeoutError |
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.
another missing coverage which will block the merge
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.
This method was added in e0b4d6a
setTimeout() was deleted in in https://github.com/twisted/commit/0d2674cb7567e33ae8bdfca67ab9e4847643696e
at that time timeout() was not deleted, but it should have been.
I think that the best way forward is to deprecate this method as well and write a deprecation test for 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.
True. Let's deprecate it and the deprecation test should handle the coverage:)
It can be deprecated in this branch as it is somehow related to defer.TimeoutError