|
2 | 2 | # See LICENSE for details. |
3 | 3 |
|
4 | 4 | """ |
5 | | -Tests for L{twisted.test.proto_helpers}. |
| 5 | +Tests for L{twisted.internet.testing}. |
6 | 6 | """ |
7 | 7 |
|
8 | 8 | from zope.interface.verify import verifyObject |
9 | 9 |
|
10 | | -from twisted.internet.interfaces import (ITransport, IPushProducer, IConsumer, |
11 | | - IReactorTCP, IReactorSSL, IReactorUNIX, IAddress, IListeningPort, |
12 | | - IConnector) |
| 10 | +from twisted.internet.interfaces import ( |
| 11 | + ITransport, |
| 12 | + IPushProducer, |
| 13 | + IConsumer, |
| 14 | + IReactorTCP, |
| 15 | + IReactorSSL, |
| 16 | + IReactorUNIX, |
| 17 | + IAddress, |
| 18 | + IListeningPort, |
| 19 | + IConnector |
| 20 | +) |
13 | 21 | from twisted.internet.address import IPv4Address |
14 | 22 | from twisted.trial.unittest import TestCase |
15 | | -from twisted.test.proto_helpers import (StringTransport, MemoryReactor, |
16 | | - RaisingMemoryReactor, NonStreamingProducer) |
| 23 | +from twisted.internet.testing import ( |
| 24 | + StringTransport, |
| 25 | + MemoryReactor, |
| 26 | + RaisingMemoryReactor, |
| 27 | + NonStreamingProducer |
| 28 | +) |
17 | 29 | from twisted.internet.protocol import ClientFactory, Factory |
| 30 | +from twisted.python.reflect import namedAny |
| 31 | + |
18 | 32 |
|
19 | 33 |
|
20 | 34 | class StringTransportTests(TestCase): |
21 | 35 | """ |
22 | | - Tests for L{twisted.test.proto_helpers.StringTransport}. |
| 36 | + Tests for L{twisted.internet.testing.StringTransport}. |
23 | 37 | """ |
24 | 38 | def setUp(self): |
25 | 39 | self.transport = StringTransport() |
@@ -399,3 +413,103 @@ def test_cannotPauseProduction(self): |
399 | 413 | producer.resumeProducing() |
400 | 414 |
|
401 | 415 | self.assertRaises(RuntimeError, producer.pauseProducing) |
| 416 | + |
| 417 | + |
| 418 | + |
| 419 | +class DeprecationTests(TestCase): |
| 420 | + """ |
| 421 | + Deprecations in L{twisted.test.proto_helpers}. |
| 422 | + """ |
| 423 | + def helper(self, test, obj): |
| 424 | + new_path = 'twisted.internet.testing.{}'.format(obj.__name__) |
| 425 | + warnings = self.flushWarnings( |
| 426 | + [test]) |
| 427 | + self.assertEqual(DeprecationWarning, warnings[0]['category']) |
| 428 | + self.assertEqual(1, len(warnings)) |
| 429 | + self.assertIn(new_path, warnings[0]['message']) |
| 430 | + self.assertIs(obj, namedAny(new_path)) |
| 431 | + |
| 432 | + def test_accumulatingProtocol(self): |
| 433 | + from twisted.test.proto_helpers import AccumulatingProtocol |
| 434 | + self.helper(self.test_accumulatingProtocol, |
| 435 | + AccumulatingProtocol) |
| 436 | + |
| 437 | + |
| 438 | + def test_lineSendingProtocol(self): |
| 439 | + from twisted.test.proto_helpers import LineSendingProtocol |
| 440 | + self.helper(self.test_lineSendingProtocol, |
| 441 | + LineSendingProtocol) |
| 442 | + |
| 443 | + |
| 444 | + def test_fakeDatagramTransport(self): |
| 445 | + from twisted.test.proto_helpers import FakeDatagramTransport |
| 446 | + self.helper(self.test_fakeDatagramTransport, |
| 447 | + FakeDatagramTransport) |
| 448 | + |
| 449 | + |
| 450 | + def test_stringTransport(self): |
| 451 | + from twisted.test.proto_helpers import StringTransport |
| 452 | + self.helper(self.test_stringTransport, |
| 453 | + StringTransport) |
| 454 | + |
| 455 | + |
| 456 | + def test_stringTransportWithDisconnection(self): |
| 457 | + from twisted.test.proto_helpers import ( |
| 458 | + StringTransportWithDisconnection) |
| 459 | + self.helper(self.test_stringTransportWithDisconnection, |
| 460 | + StringTransportWithDisconnection) |
| 461 | + |
| 462 | + |
| 463 | + def test_stringIOWithoutClosing(self): |
| 464 | + from twisted.test.proto_helpers import StringIOWithoutClosing |
| 465 | + self.helper(self.test_stringIOWithoutClosing, |
| 466 | + StringIOWithoutClosing) |
| 467 | + |
| 468 | + |
| 469 | + def test__fakeConnector(self): |
| 470 | + from twisted.test.proto_helpers import _FakeConnector |
| 471 | + self.helper(self.test__fakeConnector, |
| 472 | + _FakeConnector) |
| 473 | + |
| 474 | + |
| 475 | + def test__fakePort(self): |
| 476 | + from twisted.test.proto_helpers import _FakePort |
| 477 | + self.helper(self.test__fakePort, |
| 478 | + _FakePort) |
| 479 | + |
| 480 | + |
| 481 | + def test_memoryReactor(self): |
| 482 | + from twisted.test.proto_helpers import MemoryReactor |
| 483 | + self.helper(self.test_memoryReactor, |
| 484 | + MemoryReactor) |
| 485 | + |
| 486 | + |
| 487 | + def test_memoryReactorClock(self): |
| 488 | + from twisted.test.proto_helpers import MemoryReactorClock |
| 489 | + self.helper(self.test_memoryReactorClock, |
| 490 | + MemoryReactorClock) |
| 491 | + |
| 492 | + |
| 493 | + def test_raisingMemoryReactor(self): |
| 494 | + from twisted.test.proto_helpers import RaisingMemoryReactor |
| 495 | + self.helper(self.test_raisingMemoryReactor, |
| 496 | + RaisingMemoryReactor) |
| 497 | + |
| 498 | + |
| 499 | + def test_nonStreamingProducer(self): |
| 500 | + from twisted.test.proto_helpers import NonStreamingProducer |
| 501 | + self.helper(self.test_nonStreamingProducer, |
| 502 | + NonStreamingProducer) |
| 503 | + |
| 504 | + |
| 505 | + def test_waitUntilAllDisconnected(self): |
| 506 | + from twisted.test.proto_helpers import ( |
| 507 | + waitUntilAllDisconnected) |
| 508 | + self.helper(self.test_waitUntilAllDisconnected, |
| 509 | + waitUntilAllDisconnected) |
| 510 | + |
| 511 | + |
| 512 | + def test_eventLoggingObserver(self): |
| 513 | + from twisted.test.proto_helpers import EventLoggingObserver |
| 514 | + self.helper(self.test_eventLoggingObserver, |
| 515 | + EventLoggingObserver) |
0 commit comments