Changeset 1817:bb81569fff7e


Ignore:
Timestamp:
Jun 18, 2019, 7:32:47 PM (2 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
amend_source:
351adade1761003978a43f3697a516b492b8ebaf
Message:
Raise exception from `result` argument

If a `Call` constructor had the `result` argument set to an exception,
this exception (class or instance) should be raised when the call is
"executed". The previous code didn't handle the possibility that an
exception could be raised.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/scripted_session.py

    r1796 r1817  
    159159        # object also solely specifies the path as `args`.
    160160        script_call.check_call("dir", (path,), None)
    161         for line in script_call.result.splitlines():
     161        # Give `dir` the chance to raise an exception if one was specified in
     162        # the `Call`'s `result` argument.
     163        call_result = script_call()
     164        for line in call_result.splitlines():
    162165            callback(line)
    163166
     
    173176        script_call = self._next_script_call("ntransfercmd")
    174177        script_call.check_call("ntransfercmd", (cmd, rest), None)
     178        # Give `ntransfercmd` the chance to raise an exception if one was
     179        # specified in the `Call`'s `result` argument.
     180        call_result = script_call()
    175181        mock_socket = unittest.mock.Mock(name="socket")
    176         mock_socket.makefile.return_value = script_call.result
     182        mock_socket.makefile.return_value = call_result
    177183        # Return `None` for size. The docstring of `ftplib.FTP.ntransfercmd`
    178184        # says that's a possibility.
     
    190196        script_call = self._next_script_call("transfercmd")
    191197        script_call.check_call("transfercmd", (cmd, rest), None)
     198        # Give `transfercmd` the chance to raise an exception if one was
     199        # specified in the `Call`'s `result` argument.
     200        call_result = script_call()
    192201        mock_socket = unittest.mock.Mock(name="socket")
    193         mock_socket.makefile.return_value = script_call.result
     202        mock_socket.makefile.return_value = call_result
    194203        return mock_socket
    195204
Note: See TracChangeset for help on using the changeset viewer.