Ticket #5387: ticket-5387.diff
| File ticket-5387.diff, 8.8 KB (added by bartekci, 15 months ago) |
|---|
-
twisted/test/test_defgen.py
175 175 176 176 177 177 178 ## This has to be in a string so the new yield syntax doesn't cause a179 ## syntax error in Python 2.4 and before.180 inlineCallbacksTestsSource = '''181 178 from twisted.internet.defer import inlineCallbacks, returnValue 182 179 183 180 class InlineCallbacksTests(BaseDefgenTests, unittest.TestCase): … … 295 292 296 293 self.assertIn("inlineCallbacks", 297 294 str(self.assertRaises(TypeError, _noYield))) 298 299 '''300 301 if sys.version_info > (2, 5):302 # Load tests303 exec inlineCallbacksTestsSource304 else:305 # Make a placeholder test case306 class InlineCallbacksTests(unittest.TestCase):307 skip = "defer.defgen doesn't run on python < 2.5."308 def test_everything(self):309 pass -
twisted/python/util.py
790 790 Return the id of an object as an unsigned number so that its hex 791 791 representation makes sense. 792 792 793 This is mostly necessary in Python 2.4 which implements L{id} to sometimes 794 return a negative value. Python 2.3 shares this behavior, but also 793 This is mostly necessary in Python 2.4 which implements L{id} to sometimes 794 return a negative value. Python 2.3 shares this behavior, but also 795 795 implements hex and the %x format specifier to represent negative values as 796 though they were positive ones, obscuring the behavior of L{id}. Python 796 though they were positive ones, obscuring the behavior of L{id}. Python 797 797 2.5's implementation of L{id} always returns positive values. 798 798 """ 799 799 rval = _idFunction(obj) -
twisted/trial/test/mockdoctest.py
2 2 # See LICENSE for details. 3 3 4 4 # this module is a trivial class with doctests and a __test__ attribute 5 # to test trial's doctest support with python2.45 # to test trial's doctest support. 6 6 7 7 8 8 class Counter(object): -
twisted/trial/runner.py
11 11 __all__ = [ 12 12 'suiteVisit', 'TestSuite', 13 13 14 'DestructiveTestSuite', 'D ocTestCase', 'DryRunVisitor',14 'DestructiveTestSuite', 'DryRunVisitor', 15 15 'ErrorHolder', 'LoggedSuite', 'PyUnitTestCase', 16 16 'TestHolder', 'TestLoader', 'TrialRunner', 'TrialSuite', 17 17 … … 239 239 240 240 241 241 242 class DocTestCase(PyUnitTestCase):243 """244 DEPRECATED in Twisted 8.0.245 """246 247 def id(self):248 """249 In Python 2.4, doctests have correct id() behaviour. In Python 2.3,250 id() returns 'runit'.251 252 Here we override id() so that at least it will always contain the253 fully qualified Python name of the doctest.254 """255 return self._test.shortDescription()256 257 258 242 class TrialSuite(TestSuite): 259 243 """ 260 244 Suite to wrap around every single test in a C{trial} run. Used internally -
twisted/trial/util.py
208 208 209 209 def profiled(f, outputFile): 210 210 def _(*args, **kwargs): 211 if sys.version_info[0:2] != (2, 4): 212 import profile 213 prof = profile.Profile() 214 try: 215 result = prof.runcall(f, *args, **kwargs) 216 prof.dump_stats(outputFile) 217 except SystemExit: 218 pass 219 prof.print_stats() 220 return result 221 else: # use hotshot, profile is broken in 2.4 222 import hotshot.stats 223 prof = hotshot.Profile(outputFile) 224 try: 225 return prof.runcall(f, *args, **kwargs) 226 finally: 227 stats = hotshot.stats.load(outputFile) 228 stats.strip_dirs() 229 stats.sort_stats('cum') # 'time' 230 stats.print_stats(100) 211 import profile 212 prof = profile.Profile() 213 try: 214 result = prof.runcall(f, *args, **kwargs) 215 prof.dump_stats(outputFile) 216 except SystemExit: 217 pass 218 prof.print_stats() 219 return result 231 220 return _ 232 221 233 222 -
twisted/trial/unittest.py
1392 1392 class TestSuite(pyunit.TestSuite): 1393 1393 """ 1394 1394 Extend the standard library's C{TestSuite} with support for the visitor 1395 pattern and a consistently overrideable C{run} method.1395 pattern. 1396 1396 """ 1397 1397 1398 1398 visit = suiteVisit 1399 1399 1400 def __call__(self, result):1401 return self.run(result)1402 1403 1404 def run(self, result):1405 """1406 Call C{run} on every member of the suite.1407 """1408 # we implement this because Python 2.3 unittest defines this code1409 # in __call__, whereas 2.4 defines the code in run.1410 for test in self._tests:1411 if result.shouldStop:1412 break1413 test(result)1414 return result1415 1416 1417 1400 1418 1401 class TestDecorator(components.proxyForInterface(itrial.ITestCase, 1419 1402 "_originalTest")): -
twisted/web/test/test_xmlrpc.py
575 575 value = None 576 576 577 577 578 try:579 xmlrpclib.loads(xmlrpclib.dumps(({}, {})), use_datetime=True)580 except TypeError:581 _datetimeSupported = False582 else:583 _datetimeSupported = True584 585 586 587 578 class XMLRPCUseDateTimeTestCase(SerializationConfigMixin, unittest.TestCase): 588 579 """ 589 580 Tests for passing a C{datetime.datetime} instance when the C{useDateTime} … … 592 583 flagName = "useDateTime" 593 584 value = datetime.datetime(2000, 12, 28, 3, 45, 59) 594 585 595 if not _datetimeSupported:596 skip = (597 "Available version of xmlrpclib does not support datetime "598 "objects.")599 600 601 602 class XMLRPCDisableUseDateTimeTestCase(unittest.TestCase):603 """604 Tests for the C{useDateTime} flag on Python 2.4.605 """606 if _datetimeSupported:607 skip = (608 "Available version of xmlrpclib supports datetime objects.")609 610 def test_cannotInitializeWithDateTime(self):611 """612 L{XMLRPC} raises L{RuntimeError} if passed C{True} for C{useDateTime}.613 """614 self.assertRaises(RuntimeError, XMLRPC, useDateTime=True)615 self.assertRaises(616 RuntimeError, Proxy, "http://localhost/", useDateTime=True)617 618 619 def test_cannotSetDateTime(self):620 """621 Setting L{XMLRPC.useDateTime} to C{True} after initialization raises622 L{RuntimeError}.623 """624 xmlrpc = XMLRPC(useDateTime=False)625 self.assertRaises(RuntimeError, setattr, xmlrpc, "useDateTime", True)626 proxy = Proxy("http://localhost/", useDateTime=False)627 self.assertRaises(RuntimeError, setattr, proxy, "useDateTime", True)628 629 630 586 631 587 class XMLRPCTestAuthenticated(XMLRPCTestCase): 632 588 """ -
twisted/web/xmlrpc.py
28 28 Boolean = xmlrpclib.Boolean 29 29 DateTime = xmlrpclib.DateTime 30 30 31 # On Python 2.4 and earlier, DateTime.decode returns unicode.32 if sys.version_info[:2] < (2, 5):33 _decode = DateTime.decode34 DateTime.decode = lambda self, value: _decode(self, value.encode('ascii'))35 36 31 37 32 def withRequest(f): 38 33 """ … … 128 123 129 124 130 125 def __setattr__(self, name, value): 131 if name == "useDateTime" and value and sys.version_info[:2] < (2, 5):132 raise RuntimeError("useDateTime requires Python 2.5 or later.")133 126 self.__dict__[name] = value 134 127 135 128 -
twisted/web/client.py
720 720 """ 721 721 implements(IBodyProducer) 722 722 723 # Python 2.4 doesn't have these symbolic constants 724 _SEEK_SET = getattr(os, 'SEEK_SET', 0) 725 _SEEK_END = getattr(os, 'SEEK_END', 2) 723 _SEEK_SET = os.SEEK_SET 724 _SEEK_END = os.SEEK_END 726 725 727 726 def __init__(self, inputFile, cooperator=task, readSize=2 ** 16): 728 727 self._inputFile = inputFile
