Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert scp port to str #13

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openssh_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand Down
10 changes: 10 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down