Skip to content

Commit 148dbe0

Browse files
authored
Made .closed into a public property on sftp file handles. Added tests. Updated changelog (#226)
1 parent cf54041 commit 148dbe0

File tree

7 files changed

+913
-810
lines changed

7 files changed

+913
-810
lines changed

Changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Changes
1111
* Added `ssh2.session.Session.flag` function for enabling/disabling session flags like compression support.
1212
* Added `ssh2.session.userauth_keyboardinteractive_callback` for authentication using Python callback function,
1313
for example for Oauth and other two-factor (2FA) or more factor authentication. Thanks @MattCatz .
14+
* `ssh2.sftp_handle.SFTPHandle.closed` is now a public property indicating whether `ssh2.sftp_handle.SFTPHandle.close`
15+
was called on a `SFTPHandle` or not.
1416

1517

1618
1.1.2

ci/integration_tests/test_sftp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ def test_sftp_read(self):
4545
remote_data = b""
4646
for rc, data in remote_fh:
4747
remote_data += data
48+
self.assertFalse(remote_fh.closed)
4849
self.assertEqual(remote_fh.close(), 0)
50+
self.assertTrue(remote_fh.closed)
4951
self.assertEqual(remote_data, test_file_data)
5052
finally:
5153
os.unlink(remote_filename)
54+
self.assertTrue(remote_fh.closed)
5255

5356
def test_sftp_write(self):
5457
self.assertEqual(self._auth(), 0)
@@ -65,6 +68,8 @@ def test_sftp_write(self):
6568
LIBSSH2_FXF_CREAT | LIBSSH2_FXF_WRITE,
6669
mode) as remote_fh:
6770
remote_fh.write(data)
71+
self.assertFalse(remote_fh.closed)
72+
self.assertTrue(remote_fh.closed)
6873
with open(remote_filename, 'rb') as fh:
6974
written_data = fh.read()
7075
_stat = os.stat(remote_filename)

ssh2/sftp.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)