~sschwarzer/ftputil

266a8beef77208a9ee419c7ab7f0502a719b9cad — Stefan Schwarzer 1 year, 8 months ago 2780951
Use `super` for base class constructor call

I don't know why this didn't work before. Maybe I had mocked
`ftplib.FTP` instead of `ftplib.FTP.__init__`?

ticket: 145
2 files changed, 2 insertions(+), 4 deletions(-)

M ftputil/host.py
M test/test_host.py
M ftputil/host.py => ftputil/host.py +1 -3
@@ 49,9 49,7 @@ if ftputil.path_encoding.RUNNING_UNDER_PY39_AND_UP:
            # an encoding.
            if "encoding" not in kwargs:
                kwargs["encoding"] = ftputil.path_encoding.DEFAULT_ENCODING
            # Use a "classic" base class call. If using a `super` call, this is
            # much more tricky to test with the current mocking approach.
            ftplib.FTP.__init__(self, *args, **kwargs)
            super().__init__(*args, **kwargs)


else:

M test/test_host.py => test/test_host.py +1 -1
@@ 91,7 91,7 @@ class TestDefaultSessionFactory:
            assert (
                # Don't compare the `self` argument. It changes for every test
                # run.
                ftp_mock.call_args.args[1:]
                ftp_mock.call_args.args
                == ("localhost", "ftptest", "dummy") + args
            )
            assert ftp_mock.call_args.kwargs == expected_kwargs