diff --git a/openssh_wrapper.py b/openssh_wrapper.py index 741da66..a421017 100644 --- a/openssh_wrapper.py +++ b/openssh_wrapper.py @@ -369,7 +369,7 @@ def scp_command(self, files, target): if self.identity_file: cmd += ['-i', self.identity_file] if self.port: - cmd += ['-P', self.port] + cmd += ['-P', str(self.port)] if isinstance(files, (text, bytes)): raise ValueError('"files" argument have to be iterable (list or tuple)') diff --git a/tests.py b/tests.py index b27d02d..b6e01e1 100644 --- a/tests.py +++ b/tests.py @@ -71,6 +71,16 @@ def test_scp(self): self.c.scp((test_file, ), target='/tmp') assert os.path.isfile('/tmp/tests.py') + def test_scp_int_port(self): + c = SSHConnection('localhost', login='root', port=22) + c.scp((test_file, ), target='/tmp') + assert os.path.isfile('/tmp/tests.py') + + def test_scp_str_port(self): + c = SSHConnection('localhost', login='root', port='22') + c.scp((test_file, ), target='/tmp') + assert os.path.isfile('/tmp/tests.py') + def test_scp_to_nonexistent_dir(self): with pytest.raises(SSHError): self.c.scp((test_file, ), target='/abc/def/')