Ticket #4913: 4913-ftp-stor-err-1.diff
| File 4913-ftp-stor-err-1.diff, 2.1 KB (added by adiroiban, 11 months ago) |
|---|
-
twisted/test/test_ftp.py
448 448 d2.addErrback(eb) 449 449 return defer.gatherResults([d1, d2]) 450 450 451 def test_RETRreadError(self): 452 """ 453 Any errors during reading a file inside a RETR should be returned to 454 the client. 455 """ 456 # Make a failing file reading. 457 class FailingFileReader(ftp._FileReader): 458 def send(self, consumer): 459 return defer.fail(ftp.IsADirectoryError("blah")) 451 460 461 def failingRETR(a, b): 462 return defer.succeed(FailingFileReader(None)) 452 463 464 # Monkey patch the shell so it returns a file reader that will 465 # fail. 466 self.patch(ftp.FTPAnonymousShell, 'openForReading', failingRETR) 467 468 def check_response(failure): 469 self.flushLoggedErrors() 470 failure.trap(ftp.CommandFailed) 471 self.assertEqual( 472 failure.value.args[0][0], 473 "125 Data connection already open, starting transfer") 474 self.assertEqual( 475 failure.value.args[0][1], 476 "550 blah: is a directory") 477 478 proto = _BufferingProtocol() 479 d = self.client.retrieveFile('failing_file', proto) 480 d.addErrback(check_response) 481 return d 482 483 453 484 class FTPServerPasvDataConnectionTestCase(FTPServerTestCase): 454 485 def _makeDataConnection(self, ignored=None): 455 486 # Establish a passive data connection (i.e. client connecting to -
twisted/protocols/ftp.py
1068 1068 def ebSent(err): 1069 1069 log.msg("Unexpected error attempting to transmit file to client:") 1070 1070 log.err(err) 1071 if err.check(FTPCmdError): 1072 return err 1071 1073 return (CNX_CLOSED_TXFR_ABORTED,) 1072 1074 1073 1075 def cbOpened(file):
