Ticket #2375: proper-epytext-2375.patch
| File proper-epytext-2375.patch, 39.6 KB (added by thijs, 5 years ago) |
|---|
-
twisted/python/test/test_util.py
67 67 68 68 def testNameToLabel(self): 69 69 """ 70 Test the various kinds of inputs L{nameToLabel} supports.70 Test the various kinds of inputs C{nameToLabel} supports. 71 71 """ 72 72 nameData = [ 73 73 ('f', 'F'), … … 85 85 86 86 def test_uidFromNumericString(self): 87 87 """ 88 When L{uidFromString} is called with a base-ten string representation88 When C{uidFromString} is called with a base-ten string representation 89 89 of an integer, it returns the integer. 90 90 """ 91 91 self.assertEqual(util.uidFromString("100"), 100) … … 93 93 94 94 def test_uidFromUsernameString(self): 95 95 """ 96 When L{uidFromString} is called with a base-ten string representation96 When C{uidFromString} is called with a base-ten string representation 97 97 of an integer, it returns the integer. 98 98 """ 99 99 pwent = pwd.getpwuid(os.getuid()) … … 105 105 106 106 def test_gidFromNumericString(self): 107 107 """ 108 When L{gidFromString} is called with a base-ten string representation108 When C{gidFromString} is called with a base-ten string representation 109 109 of an integer, it returns the integer. 110 110 """ 111 111 self.assertEqual(util.gidFromString("100"), 100) … … 113 113 114 114 def test_gidFromGroupnameString(self): 115 115 """ 116 When L{gidFromString} is called with a base-ten string representation116 When C{gidFromString} is called with a base-ten string representation 117 117 of an integer, it returns the integer. 118 118 """ 119 119 grent = grp.getgrgid(os.getgid()) … … 126 126 127 127 class TestMergeFunctionMetadata(unittest.TestCase): 128 128 """ 129 Tests for L{mergeFunctionMetadata}.129 Tests for C{mergeFunctionMetadata}. 130 130 """ 131 131 132 132 def test_mergedFunctionBehavesLikeMergeTarget(self): … … 280 280 281 281 class PasswordTestingProcessProtocol(ProcessProtocol): 282 282 """ 283 Write the string C{"secret\ n"} to a subprocess and then collect all of283 Write the string C{"secret\\n"} to a subprocess and then collect all of 284 284 its output and fire a Deferred with it when the process ends. 285 285 """ 286 286 def connectionMade(self): … … 438 438 439 439 class Record(util.FancyEqMixin): 440 440 """ 441 Trivial user of L{FancyEqMixin} used by tests.441 Trivial user of C{FancyEqMixin} used by tests. 442 442 """ 443 443 compareAttributes = ('a', 'b') 444 444 … … 450 450 451 451 class DifferentRecord(util.FancyEqMixin): 452 452 """ 453 Trivial user of L{FancyEqMixin} which is not related to L{Record}.453 Trivial user of C{FancyEqMixin} which is not related to L{Record}. 454 454 """ 455 455 compareAttributes = ('a', 'b') 456 456 … … 458 458 self.a = a 459 459 self.b = b 460 460 461 462 463 461 class DerivedRecord(Record): 464 462 """ 465 463 A class with an inheritance relationship to L{Record}. … … 495 493 496 494 class EqualityTests(unittest.TestCase): 497 495 """ 498 Tests for L{FancyEqMixin}.496 Tests for C{FancyEqMixin}. 499 497 """ 500 498 def test_identity(self): 501 499 """ 502 Instances of a class which mixes in L{FancyEqMixin} but which500 Instances of a class which mixes in C{FancyEqMixin} but which 503 501 defines no comparison attributes compare by identity. 504 502 """ 505 503 class Empty(util.FancyEqMixin): … … 514 512 515 513 def test_equality(self): 516 514 """ 517 Instances of a class which mixes in L{FancyEqMixin} should compare 518 equal if all of their attributes compare equal. They should not 519 compare equal if any of their attributes do not compare equal. 515 Instances of a class which mixes in C{FancyEqMixin} should 516 compare equal if all of their attributes compare equal. They 517 should not compare equal if any of their attributes do not 518 compare equal. 520 519 """ 521 520 self.assertTrue(Record(1, 2) == Record(1, 2)) 522 521 self.assertFalse(Record(1, 2) == Record(1, 3)) … … 526 525 527 526 def test_unequality(self): 528 527 """ 529 Unequality between instances of a particular L{record} should be528 Unequality between instances of a particular C{record} should be 530 529 defined as the negation of equality. 531 530 """ 532 531 self.assertFalse(Record(1, 2) != Record(1, 2)) … … 537 536 538 537 def test_differentClassesEquality(self): 539 538 """ 540 Instances of different classes which mix in L{FancyEqMixin} should not541 compare equal.539 Instances of different classes which mix in C{FancyEqMixin} 540 should not compare equal. 542 541 """ 543 542 self.assertFalse(Record(1, 2) == DifferentRecord(1, 2)) 544 543 545 544 546 545 def test_differentClassesInequality(self): 547 546 """ 548 Instances of different classes which mix in L{FancyEqMixin} should549 compare unequal.547 Instances of different classes which mix in C{FancyEqMixin} 548 should compare unequal. 550 549 """ 551 550 self.assertTrue(Record(1, 2) != DifferentRecord(1, 2)) 552 551 … … 554 553 def test_inheritedClassesEquality(self): 555 554 """ 556 555 An instance of a class which derives from a class which mixes in 557 L{FancyEqMixin} should compare equal to an instance of the base class558 if and only if all of their attributes compare equal.556 C{FancyEqMixin} should compare equal to an instance of the 557 base class if and only if all of their attributes compare equal. 559 558 """ 560 559 self.assertTrue(Record(1, 2) == DerivedRecord(1, 2)) 561 560 self.assertFalse(Record(1, 2) == DerivedRecord(1, 3)) … … 566 565 def test_inheritedClassesInequality(self): 567 566 """ 568 567 An instance of a class which derives from a class which mixes in 569 L{FancyEqMixin} should compare unequal to an instance of the base570 class if any of their attributes compare unequal.568 C{FancyEqMixin} should compare unequal to an instance of 569 the base class if any of their attributes compare unequal. 571 570 """ 572 571 self.assertFalse(Record(1, 2) != DerivedRecord(1, 2)) 573 572 self.assertTrue(Record(1, 2) != DerivedRecord(1, 3)) … … 579 578 """ 580 579 The right-hand argument to the equality operator is given a chance 581 580 to determine the result of the operation if it is of a type 582 unrelated to the L{FancyEqMixin}-based instance on the left-hand583 side.581 unrelated to the C{FancyEqMixin}-based instance on the 582 left-hand side. 584 583 """ 585 584 self.assertTrue(Record(1, 2) == EqualToEverything()) 586 585 self.assertFalse(Record(1, 2) == EqualToNothing()) … … 590 589 """ 591 590 The right-hand argument to the non-equality operator is given a 592 591 chance to determine the result of the operation if it is of a type 593 unrelated to the L{FancyEqMixin}-based instance on the left-hand594 side.592 unrelated to the C{FancyEqMixin}-based instance on the 593 left-hand side. 595 594 """ 596 595 self.assertFalse(Record(1, 2) != EqualToEverything()) 597 596 self.assertTrue(Record(1, 2) != EqualToNothing()) -
twisted/python/test/test_release.py
2 2 # See LICENSE for details. 3 3 4 4 """ 5 Tests for L{twisted.python.release} and L{twisted.python._release}.5 Tests for C{twisted.python.release} and C{twisted.python._release}. 6 6 """ 7 7 8 8 import warnings … … 134 134 Make a Twisted-style project in the given base directory. 135 135 136 136 @param baseDirectory: The directory to create files in 137 (as a L{FilePath ).137 (as a L{FilePath}). 138 138 @param version: The version information for the project. 139 139 @return: L{Project} pointing to the created project. 140 140 """ … … 475 475 def setUp(self): 476 476 """ 477 477 Set up a few instance variables that will be useful. 478 479 @ivar builder: A plain L{DocBuilder}.480 @ivar docCounter: An integer to be used as a counter by the481 C{getArbitrary...} methods.482 @ivar howtoDir: A L{FilePath} representing a directory to be used for483 containing Lore documents.484 @ivar templateFile: A L{FilePath} representing a file with485 C{self.template} as its content.486 478 """ 487 479 BuilderTestsMixin.setUp(self) 488 480 self.builder = DocBuilder() 481 """ 482 @ivar: A plain L{DocBuilder}. 483 """ 489 484 self.howtoDir = FilePath(self.mktemp()) 485 """ 486 @ivar: A L{FilePath} representing a directory to be used for 487 containing Lore documents. 488 """ 490 489 self.howtoDir.createDirectory() 491 490 self.templateFile = self.howtoDir.child("template.tpl") 491 """ 492 @ivar: A L{FilePath} representing a file with 493 C{self.template} as its content. 494 """ 492 495 self.templateFile.setContent(self.template) 493 496 494 497 … … 573 576 574 577 def test_deleteInput(self): 575 578 """ 576 L{DocBuilder.build} can be instructed to delete the input files after579 C{DocBuilder.build} can be instructed to delete the input files after 577 580 generating the output based on them. 578 581 """ 579 582 input1 = self.getArbitraryLoreInput(0) … … 647 650 648 651 def test_build(self): 649 652 """ 650 L{APIBuilder.build} writes an index file which includes the name of the653 C{APIBuilder.build} writes an index file which includes the name of the 651 654 project specified. 652 655 """ 653 656 stdout = StringIO() … … 714 717 def setUp(self): 715 718 """ 716 719 Set up a few instance variables that will be useful. 717 718 @ivar builder: A plain L{ManBuilder}.719 @ivar manDir: A L{FilePath} representing a directory to be used for720 containing man pages.721 720 """ 722 721 BuilderTestsMixin.setUp(self) 723 722 self.builder = ManBuilder() 723 """ 724 @ivar: A plain L{ManBuilder}. 725 """ 724 726 self.manDir = FilePath(self.mktemp()) 727 """ 728 @ivar: A L{FilePath} representing a directory to be used for 729 containing man pages. 730 """ 725 731 self.manDir.createDirectory() 726 732 727 733 728 734 def test_noDocumentsFound(self): 729 735 """ 730 L{ManBuilder.build} raises L{NoDocumentsFound} if there are no736 C{ManBuilder.build} raises L{NoDocumentsFound} if there are no 731 737 .1 files in the given directory. 732 738 """ 733 739 self.assertRaises(NoDocumentsFound, self.builder.build, self.manDir) … … 735 741 736 742 def test_build(self): 737 743 """ 738 Check that L{ManBuilder.build} find the man page in the directory, and744 Check that C{ManBuilder.build} find the man page in the directory, and 739 745 successfully produce a Lore content. 740 746 """ 741 747 manContent = self.getArbitraryManInput() … … 751 757 def test_toHTML(self): 752 758 """ 753 759 Check that the content output by C{build} is compatible as input of 754 L{DocBuilder.build}.760 C{DocBuilder.build}. 755 761 """ 756 762 manContent = self.getArbitraryManInput() 757 763 self.manDir.child('test1.1').setContent(manContent) … … 815 821 816 822 def test_runSuccess(self): 817 823 """ 818 L{BookBuilder.run} executes the command it is passed and returns a824 C{BookBuilder.run} executes the command it is passed and returns a 819 825 string giving the stdout and stderr of the command if it completes 820 826 successfully. 821 827 """ … … 825 831 826 832 def test_runFailed(self): 827 833 """ 828 L{BookBuilder.run} executes the command it is passed and raises834 C{BookBuilder.run} executes the command it is passed and raises 829 835 L{CommandFailed} if it completes unsuccessfully. 830 836 """ 831 837 builder = BookBuilder() … … 836 842 837 843 def test_runSignaled(self): 838 844 """ 839 L{BookBuilder.run} executes the command it is passed and raises845 C{BookBuilder.run} executes the command it is passed and raises 840 846 L{CommandFailed} if it exits due to a signal. 841 847 """ 842 848 builder = BookBuilder() … … 850 856 851 857 def test_buildTeX(self): 852 858 """ 853 L{BookBuilder.buildTeX} writes intermediate TeX files for all lore859 C{BookBuilder.buildTeX} writes intermediate TeX files for all lore 854 860 input files in a directory. 855 861 """ 856 862 version = "3.2.1" … … 870 876 871 877 def test_buildTeXRejectsInvalidDirectory(self): 872 878 """ 873 L{BookBuilder.buildTeX} raises L{ValueError} if passed a directory879 C{BookBuilder.buildTeX} raises L{ValueError} if passed a directory 874 880 which does not exist. 875 881 """ 876 882 builder = BookBuilder() … … 880 886 881 887 def test_buildTeXOnlyBuildsXHTML(self): 882 888 """ 883 L{BookBuilder.buildTeX} ignores files which which don't end with889 C{BookBuilder.buildTeX} ignores files which which don't end with 884 890 ".xhtml". 885 891 """ 886 892 # Hopefully ">" is always a parse error from microdom! … … 890 896 891 897 def test_stdout(self): 892 898 """ 893 L{BookBuilder.buildTeX} does not write to stdout.899 C{BookBuilder.buildTeX} does not write to stdout. 894 900 """ 895 901 stdout = StringIO() 896 902 self.patch(sys, 'stdout', stdout) … … 904 910 905 911 def test_buildPDFRejectsInvalidBookFilename(self): 906 912 """ 907 L{BookBuilder.buildPDF} raises L{ValueError} if the book filename does913 C{BookBuilder.buildPDF} raises L{ValueError} if the book filename does 908 914 not end with ".tex". 909 915 """ 910 916 builder = BookBuilder() … … 941 947 942 948 def test_buildPDF(self): 943 949 """ 944 L{BookBuilder.buildPDF} creates a PDF given an index tex file and a950 C{BookBuilder.buildPDF} creates a PDF given an index tex file and a 945 951 directory containing .tex files. 946 952 """ 947 953 bookPath = self._setupTeXFiles() … … 955 961 956 962 def test_buildPDFLongPath(self): 957 963 """ 958 L{BookBuilder.buildPDF} succeeds even if the paths it is operating on964 C{BookBuilder.buildPDF} succeeds even if the paths it is operating on 959 965 are very long. 960 966 961 967 C{ps2pdf13} seems to have problems when path names are long. This test … … 978 984 979 985 def test_buildPDFRunsLaTeXThreeTimes(self): 980 986 """ 981 L{BookBuilder.buildPDF} runs C{latex} three times.987 C{BookBuilder.buildPDF} runs C{latex} three times. 982 988 """ 983 989 class InspectableBookBuilder(BookBuilder): 984 990 def __init__(self): … … 1024 1030 def test_noSideEffects(self): 1025 1031 """ 1026 1032 The working directory is the same before and after a call to 1027 L{BookBuilder.buildPDF}. Also the contents of the directory containing1033 C{BookBuilder.buildPDF}. Also the contents of the directory containing 1028 1034 the input book are the same before and after the call. 1029 1035 """ 1030 1036 startDir = os.getcwd() … … 1042 1048 1043 1049 def test_failedCommandProvidesOutput(self): 1044 1050 """ 1045 If a subprocess fails, L{BookBuilder.buildPDF} raises L{CommandFailed}1051 If a subprocess fails, C{BookBuilder.buildPDF} raises L{CommandFailed} 1046 1052 with the subprocess's output and leaves the temporary directory as a 1047 1053 sibling of the book path. 1048 1054 """ … … 1064 1070 1065 1071 def test_build(self): 1066 1072 """ 1067 L{BookBuilder.build} generates a pdf book file from some lore input1073 C{BookBuilder.build} generates a pdf book file from some lore input 1068 1074 files. 1069 1075 """ 1070 1076 sections = range(1, 4) … … 1082 1088 1083 1089 def test_buildRemovesTemporaryLaTeXFiles(self): 1084 1090 """ 1085 L{BookBuilder.build} removes the intermediate LaTeX files it creates.1091 C{BookBuilder.build} removes the intermediate LaTeX files it creates. 1086 1092 """ 1087 1093 sections = range(1, 4) 1088 1094 for sectionNumber in sections: … … 1339 1345 """ 1340 1346 The subproject tarball includes files like so: 1341 1347 1342 1. twisted/<subproject>/topfiles defines the files that will be in the1343 top level in the tarball, except LICENSE, which comes from the real1344 top-level directory.1345 2. twisted/<subproject> is included, but without the topfiles entry1346 in that directory. No other twisted subpackages are included.1347 3. twisted/plugins/twisted_<subproject>.py is included, but nothing1348 else in plugins is.1348 1. twisted/<subproject>/topfiles defines the files that will be in the 1349 top level in the tarball, except LICENSE, which comes from the real 1350 top-level directory. 1351 2. twisted/<subproject> is included, but without the topfiles entry 1352 in that directory. No other twisted subpackages are included. 1353 3. twisted/plugins/twisted_<subproject>.py is included, but nothing 1354 else in plugins is. 1349 1355 """ 1350 1356 structure = { 1351 1357 "README": "HI!@", … … 1440 1446 The core tarball looks a lot like a subproject tarball, except it 1441 1447 doesn't include: 1442 1448 1443 - Python packages from other subprojects1444 - plugins from other subprojects1445 - scripts from other subprojects1449 - Python packages from other subprojects 1450 - plugins from other subprojects 1451 - scripts from other subprojects 1446 1452 """ 1447 1453 indexInput, indexOutput = self.getArbitraryLoreInputAndOutput( 1448 1454 "8.0.0", prefix="howto/") -
twisted/protocols/ftp.py
2216 2216 Retrieves a file or listing generated by the given command, 2217 2217 feeding it to the given protocol. 2218 2218 2219 @param command : list of strings of FTP commands to execute then receive2219 @param commands: list of strings of FTP commands to execute then receive 2220 2220 the results of (e.g. LIST, RETR) 2221 @param protocol: A L{Protocol} *instance*e.g. an2221 @param protocol: A L{Protocol} B{instance} e.g. an 2222 2222 L{FTPFileListProtocol}, or something that can be adapted to one. 2223 2223 Typically this will be an L{IConsumer} implemenation. 2224 2224 -
twisted/conch/test/test_conch.py
70 70 """ 71 71 Called when the process has ended. 72 72 73 @param reason: a Failuregiving the reason for the process' end.73 @param reason: a C{Failure} giving the reason for the process' end. 74 74 """ 75 75 if reason.value.exitCode != 0: 76 76 self._getDeferred().errback( … … 104 104 (it is assumed that the server is running on localhost). 105 105 106 106 @type data: C{str} 107 @param data: This is sent to the third-party server. Must end with '\ n'107 @param data: This is sent to the third-party server. Must end with '\\n' 108 108 in order to trigger a disconnect. 109 109 """ 110 110 self.port = port … … 179 179 def __init__(self, protocol, data): 180 180 """ 181 181 @type protocol: L{ConchTestForwardingProcess} 182 @param protocol: The L{ProcessProtocol} which made this connection.182 @param protocol: The C{ProcessProtocol} which made this connection. 183 183 184 184 @type data: str 185 185 @param data: The data to be sent to the third-party server. … … 306 306 protocols over SSH. 307 307 308 308 These tests are integration tests, not unit tests. They launch a Conch 309 server, a custom TCP server (just an L{EchoProtocol}) and then call310 L{execute}.309 server, a custom TCP server (just an C{EchoProtocol}) and then call 310 C{execute}. 311 311 312 L{execute} is implemented by subclasses of L{ForwardingTestBase}. It should312 C{execute} is implemented by subclasses of L{ForwardingTestBase}. It should 313 313 cause an SSH client to connect to the Conch server, asking it to forward 314 314 data to the custom TCP server. 315 315 """ … … 342 342 def _makeConchFactory(self): 343 343 """ 344 344 Make a L{ConchTestServerFactory}, which allows us to start a 345 L{ConchTestServer} -- i.e. an actually listening conch.345 C{ConchTestServer} -- i.e. an actually listening conch. 346 346 """ 347 347 realm = ConchTestRealm() 348 348 p = portal.Portal(realm) … … 429 429 @type sshArgs: str 430 430 @param sshArgs: Arguments to pass to the 'ssh' process. 431 431 432 @return: L{defer.Deferred}432 @return: C{defer.Deferred} 433 433 """ 434 434 process.deferred = defer.Deferred() 435 435 cmdline = ('ssh -2 -l testuser -p %i ' … … 554 554 def execute(self, remoteCommand, process, sshArgs=''): 555 555 """ 556 556 Connect to the forwarding process using the 'unix' client found in 557 L{twisted.conch.client.unix.connect}.See557 C{twisted.conch.client.unix.connect}.See 558 558 L{OpenSSHClientTestCase.execute}. 559 559 """ 560 560 process.deferred = defer.Deferred() … … 575 575 def test_noHome(self): 576 576 """ 577 577 When setting the HOME environment variable to a path that doesn't 578 exist, L{connect.connect} should forward the failure, and the created578 exist, C{connect.connect} should forward the failure, and the created 579 579 process should fail with a L{ConchError}. 580 580 """ 581 581 path = self.mktemp() -
twisted/conch/test/test_insults.py
370 370 """ 371 371 def test_nextLine(self): 372 372 """ 373 L{ServerProtocol.nextLine} writes C{"\ r\n"} to its transport.373 L{ServerProtocol.nextLine} writes C{"\\r\\n"} to its transport. 374 374 """ 375 375 # Why doesn't it write ESC E? Because ESC E is poorly supported. For 376 376 # example, gnome-terminal (many different versions) fails to scroll if -
twisted/conch/test/test_helper.py
38 38 39 39 def test_carriageReturn(self): 40 40 """ 41 C{"\ r"} moves the cursor to the first column in the current row.41 C{"\\r"} moves the cursor to the first column in the current row. 42 42 """ 43 43 self.term.cursorForward(5) 44 44 self.term.cursorDown(3) … … 49 49 50 50 def test_linefeed(self): 51 51 """ 52 C{"\ n"} moves the cursor to the next row without changing the column.52 C{"\\n"} moves the cursor to the next row without changing the column. 53 53 """ 54 54 self.term.cursorForward(5) 55 55 self.assertEqual(self.term.reportCursorPosition(), (5, 0)) … … 59 59 60 60 def test_newline(self): 61 61 """ 62 C{write} transforms C{"\ n"} into C{"\r\n"}.62 C{write} transforms C{"\\n"} into C{"\\r\\n"}. 63 63 """ 64 64 self.term.cursorForward(5) 65 65 self.term.cursorDown(3) … … 70 70 71 71 def test_setPrivateModes(self): 72 72 """ 73 Verify that L{helper.TerminalBuffer.setPrivateModes} changes the Set73 Verify that C{helper.TerminalBuffer.setPrivateModes} changes the Set 74 74 Mode (SM) state to "set" for the private modes it is passed. 75 75 """ 76 76 expected = self.term.privateModes.copy() … … 82 82 83 83 def test_resetPrivateModes(self): 84 84 """ 85 Verify that L{helper.TerminalBuffer.resetPrivateModes} changes the Set85 Verify that C{helper.TerminalBuffer.resetPrivateModes} changes the Set 86 86 Mode (SM) state to "reset" for the private modes it is passed. 87 87 """ 88 88 expected = self.term.privateModes.copy() -
twisted/web2/test/test_vhost.py
22 22 self.root.addHost('foo', HostResource()) 23 23 24 24 def testNameVirtualHost(self): 25 """ Test basic Name Virtual Host behavior 26 1) NameVirtualHost.default is defined, so an undefined NVH (localhost) 27 gets handled by NameVirtualHost.default 25 """ 26 Test basic Name Virtual Host behavior 27 1. NameVirtualHost.default is defined, so an undefined NVH (localhost) 28 gets handled by NameVirtualHost.default 28 29 29 2)A defined NVH gets passed the proper host header and is handled by the proper resource30 2. A defined NVH gets passed the proper host header and is handled by the proper resource 30 31 """ 31 32 32 33 self.assertResponse( … … 46 47 (404, {}, None)) 47 48 48 49 def testNameVirtualHostWithChildren(self): 49 """ Test that children of a defined NVH are handled appropriately50 50 """ 51 Test that children of a defined NVH are handled appropriately 52 """ 51 53 52 54 self.assertResponse( 53 55 (self.root, 'http://foo/bar/'), 54 56 (200, {}, 'foo')) 55 57 56 58 def testNameVirtualHostWithNesting(self): 57 """ Test that an unknown virtual host gets handled by the domain parent58 and passed on to the parent's resource.59 59 """ 60 Test that an unknown virtual host gets handled by the domain parent 61 and passed on to the parent's resource. 62 """ 60 63 61 64 nested = vhost.NameVirtualHost() 62 65 nested.addHost('is.nested', HostResource()) -
twisted/web2/test/test_wsgi.py
23 23 24 24 def flushErrors(self, result, error): 25 25 """ 26 Flush the specified C{error ]and forward C{result}.26 Flush the specified C{error} and forward C{result}. 27 27 """ 28 28 self.flushLoggedErrors(error) 29 29 return result -
twisted/flow/test/test_flow.py
16 16 from time import sleep 17 17 18 18 class slowlist: 19 """ this is a generator based list 19 """ 20 This is a generator based list:: 20 21 21 22 def slowlist(list): 22 23 list = list[:] … … 40 41 _onetwothree = ['one','two',flow.Cooperate(),'three'] 41 42 42 43 class producer: 43 """ iterator version of the following generator... 44 """ 45 iterator version of the following generator...:: 44 46 45 47 def producer(): 46 48 lst = flow.wrap(slowlist([1,2,3])) … … 67 69 return (self.lst.next(), self.nam.next()) 68 70 69 71 class consumer: 70 """ iterator version of the following generator... 72 """ 73 iterator version of the following generator...:: 71 74 72 75 def consumer(): 73 76 title = flow.wrap(['Title']) … … 99 102 100 103 101 104 class badgen: 102 """ a bad generator... 105 """ 106 A bad generator...:: 103 107 104 def badgen():105 yield 'x'106 err = 3/ 0108 def badgen(): 109 yield 'x' 110 err = 3/ 0 107 111 """ 108 112 def __iter__(self): 109 113 self.next = self.yield_x … … 116 120 raise StopIteration 117 121 118 122 class buildlist: 119 """ building a list 123 """ 124 Building a list:: 120 125 121 126 def buildlist(src): 122 127 out = [] … … 146 151 raise StopIteration 147 152 148 153 class testconcur: 149 """ interweving two concurrent stages 154 """ 155 Interweving two concurrent stages:: 150 156 151 157 def testconcur(*stages): 152 158 both = flow.Concurrent(*stages) … … 169 175 return (stage.name, stage.next()) 170 176 171 177 class echoServer: 172 """ a simple echo protocol, server side 178 """ 179 A simple echo protocol, server side:: 173 180 174 181 def echoServer(conn): 175 182 yield conn … … 190 197 return self.conn.next() 191 198 192 199 class echoClient: 193 """ a simple echo client tester 200 """ 201 A simple echo client tester:: 194 202 195 203 def echoClient(conn): 196 204 yield "testing" … … 461 469 462 470 def testThreadedImmediate(self): 463 471 """ 464 The goal of this test is to test the callback mechanism with465 regard to threads, namely to assure that results can be466 accumulated before they are needed; and that left-over results467 are immediately made available on the next round (even though468 the producing thread has shut down). This is a very tough thing469 to test due to the timing issues. So it may fail on some470 platforms, I'm not sure.472 The goal of this test is to test the callback mechanism with 473 regard to threads, namely to assure that results can be 474 accumulated before they are needed; and that left-over results 475 are immediately made available on the next round (even though 476 the producing thread has shut down). This is a very tough thing 477 to test due to the timing issues. So it may fail on some 478 platforms, I'm not sure. 471 479 """ 472 480 expect = [5,4,3,2,1] 473 481 result = [] -
twisted/web/test/test_xml.py
688 688 """ 689 689 Tests for when microdom encounters very bad HTML and C{beExtremelyLenient} 690 690 is enabled. These tests are inspired by some HTML generated in by a mailer, 691 which breaks up very long lines by splitting them with '!\ n '. The expected691 which breaks up very long lines by splitting them with '!\\n '. The expected 692 692 behaviour is loosely modelled on the way Firefox treats very bad HTML. 693 693 """ 694 694 -
twisted/web/test/test_httpauth.py
366 366 Format all given keyword arguments and their values suitably for use as 367 367 the value of an HTTP header. 368 368 369 @types quotes: C{bool}370 369 @param quotes: A flag indicating whether to quote the values of each 371 370 field in the response. 372 373 @param **kw: Keywords and C{str} values which will be treated as field 371 @type quotes: C{bool} 372 373 @param kw: Keywords and C{str} values which will be treated as field 374 374 name/value pairs to include in the result. 375 375 376 376 @rtype: C{str} -
twisted/test/test_reflect.py
187 187 """ 188 188 Passing a name which isn't a fully-qualified Python name to L{namedAny} 189 189 should result in one of the following exceptions: 190 - L{InvalidName}: the name is not a dot-separated list of Python objects 191 - L{ObjectNotFound}: the object doesn't exist 192 - L{ModuleNotFound}: the object doesn't exist and there is only one 193 component in the name 190 191 - L{InvalidName}: the name is not a dot-separated list of Python objects 192 - L{ObjectNotFound}: the object doesn't exist 193 - L{ModuleNotFound}: the object doesn't exist and there is only one 194 component in the name 194 195 """ 195 196 err = self.assertRaises(reflect.ModuleNotFound, reflect.namedAny, 196 197 'nosuchmoduleintheworld') -
twisted/test/test_ftp.py
910 910 """ 911 911 Try a RETR, but disconnect during the transfer. 912 912 L{ftp.FTPClient.retrieveFile} should return a Deferred which 913 errbacks with L{ftp.ConnectionLost )913 errbacks with L{ftp.ConnectionLost}. 914 914 """ 915 915 self.client.passive = False 916 916 -
twisted/test/test_process.py
1181 1181 @type actions: C{list} of C{str} 1182 1182 1183 1183 @ivar closed: keep track of the file descriptor closed. 1184 @ paramclosed: C{list} of C{int}1184 @type closed: C{list} of C{int} 1185 1185 1186 1186 @ivar child: whether fork return for the child or the parent. 1187 1187 @type child: C{bool} … … 1531 1531 The garbage collector should be enabled when L{reactor.spawnProcess} 1532 1532 returns if it was initially enabled. 1533 1533 1534 @see L{_mockForkInParentTest}1534 @see: L{_mockForkInParentTest} 1535 1535 """ 1536 1536 gc.enable() 1537 1537 self._mockForkInParentTest() … … 1543 1543 The garbage collector should be disabled when L{reactor.spawnProcess} 1544 1544 returns if it was initially disabled. 1545 1545 1546 @see L{_mockForkInParentTest}1546 @see: L{_mockForkInParentTest} 1547 1547 """ 1548 1548 gc.disable() 1549 1549 self._mockForkInParentTest() -
twisted/test/test_amp.py
398 398 class FakeSender: 399 399 """ 400 400 This is a fake implementation of the 'box sender' interface implied by 401 L{ AMP}.401 L{amp.AMP}. 402 402 """ 403 403 def __init__(self): 404 404 """ … … 699 699 def test_receiveBoxStateMachine(self): 700 700 """ 701 701 When a binary box protocol receives: 702 *a key703 *a value704 *an empty string702 - a key 703 - a value 704 - an empty string 705 705 it should emit a box and send it to its boxReceiver. 706 706 """ 707 707 a = amp.BinaryBoxProtocol(self) -
twisted/test/test_internet.py
658 658 L{twisted.internet.reactor.seconds} should return something 659 659 like a number. 660 660 661 1. This test specifically does not assert any relation to the662 "system time" as returned by L{time.time} or663 L{twisted.python.runtime.seconds}, because at some point we664 may find a better option for scheduling calls than665 wallclock-time.666 2. This test *also*does not assert anything about the type of667 the result, because operations may not return ints or668 floats: For example, datetime-datetime == timedelta(0).661 1. This test specifically does not assert any relation to the 662 "system time" as returned by L{time.time} or 663 L{twisted.python.runtime.seconds}, because at some point we 664 may find a better option for scheduling calls than 665 wallclock-time. 666 2. This test B{also} does not assert anything about the type of 667 the result, because operations may not return ints or 668 floats: For example, C{datetime-datetime == timedelta(0)}. 669 669 """ 670 670 now = reactor.seconds() 671 671 self.assertEquals(now-now+now, now) -
twisted/mail/test/test_pop3.py
2 2 # See LICENSE for details. 3 3 4 4 """ 5 Test cases for L twisted.mail.pop3} module.5 Test cases for L{twisted.mail.pop3} module. 6 6 """ 7 7 8 8 import StringIO -
twisted/internet/test/test_iocp.py
50 50 """ 51 51 This test checks transport read state! There are three bits 52 52 of it: 53 1) The transport producer is paused -- transport.reading 53 54 1. The transport producer is paused -- transport.reading 54 55 is False) 55 2) The transport is about to schedule an OS read, on the next 56 reactor iteration -- transport._readScheduled 57 3) The OS has a pending asynchronous read on our behalf -- 58 transport._readScheduledInOS 59 if 3) is not implemented, it is possible to trick IOCPReactor into 60 scheduling an OS read before the previous one finishes 56 2. The transport is about to schedule an OS read, on the next 57 reactor iteration -- C{transport._readScheduled} 58 3. The OS has a pending asynchronous read on our behalf -- 59 C{transport._readScheduledInOS} 60 61 If 3 is not implemented, it is possible to trick C{IOCPReactor} 62 into scheduling an OS read before the previous one finishes 61 63 """ 62 64 sf = ServerFactory() 63 65 sf.protocol = StopStartReadingProtocol -
twisted/trial/test/test_reporter.py
329 329 indicating how many tests ran, how many failed etc. 330 330 331 331 The numbers represents: 332 *the run time of the tests333 *the number of tests run, printed 2 times for legacy reasons334 *the number of errors335 *the number of failures336 *the number of skips332 - the run time of the tests 333 - the number of tests run, printed 2 times for legacy reasons 334 - the number of errors 335 - the number of failures 336 - the number of skips 337 337 """ 338 338 result = reporter.MinimalReporter(self.stream) 339 339 self.test.run(result) -
twisted/trial/reporter.py
105 105 self.failures.append((test, self._getFailure(fail))) 106 106 107 107 def addError(self, test, error): 108 """Report an error that occurred while running the given test. 108 """ 109 Report an error that occurred while running the given test. 109 110 110 111 @type test: L{pyunit.TestCase} 111 @type fail: L{Failure} or L{tuple}112 @type error: L{Failure} or L{tuple} 112 113 """ 113 114 self.errors.append((test, self._getFailure(error))) 114 115 … … 294 295 """ 295 296 A basic L{TestResult} with support for writing to a stream. 296 297 297 @ param_startTime: The time when the first test was started. It defaults to298 @ivar _startTime: The time when the first test was started. It defaults to 298 299 C{None}, which means that no test was actually launched. 299 300 @type _startTime: C{float} or C{NoneType} 300 301 """ … … 378 379 Safely write to the reporter's stream. 379 380 380 381 @param format: A format string to write. 381 @param *args: The arguments for the format string.382 @param args: The arguments for the format string. 382 383 """ 383 384 s = str(format) 384 385 assert isinstance(s, type('')) … … 401 402 the format string. 402 403 403 404 @param format: A format string to write. 404 @param *args: The arguments for the format string.405 @param args: The arguments for the format string. 405 406 """ 406 407 self._write(format, *args) 407 408 self._write('\n')
