diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_client.py | 2 | ||||
-rw-r--r-- | tests/test_pkey.py | 8 | ||||
-rw-r--r-- | tests/test_sftp.py | 21 |
3 files changed, 16 insertions, 15 deletions
diff --git a/tests/test_client.py b/tests/test_client.py index 35756893..53ba53e4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -208,7 +208,7 @@ class SSHClientTest(unittest.TestCase): self._test_connection(key_filename=_support("test_ecdsa_256.key")) def test_client_ed25519(self): - self._test_connection(key_filename=test_path('test_ed25519.key')) + self._test_connection(key_filename=_support('test_ed25519.key')) def test_3_multiple_key_files(self): """ diff --git a/tests/test_pkey.py b/tests/test_pkey.py index ffd68db0..a70671b5 100644 --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -462,15 +462,15 @@ class KeyTest(unittest.TestCase): self.assertEqual(str(key), comparable) def test_ed25519(self): - key1 = Ed25519Key.from_private_key_file(test_path('test_ed25519.key')) + key1 = Ed25519Key.from_private_key_file(_support('test_ed25519.key')) key2 = Ed25519Key.from_private_key_file( - test_path('test_ed25519_password.key'), b'abc123' + _support('test_ed25519_password.key'), b'abc123' ) self.assertNotEqual(key1.asbytes(), key2.asbytes()) def test_ed25519_compare(self): # verify that the private & public keys compare equal - key = Ed25519Key.from_private_key_file(test_path('test_ed25519.key')) + key = Ed25519Key.from_private_key_file(_support('test_ed25519.key')) self.assertEqual(key, key) pub = Ed25519Key(data=key.asbytes()) self.assertTrue(key.can_sign()) @@ -480,7 +480,7 @@ class KeyTest(unittest.TestCase): def test_ed25519_nonbytes_password(self): # https://github.com/paramiko/paramiko/issues/1039 key = Ed25519Key.from_private_key_file( - test_path('test_ed25519_password.key'), + _support('test_ed25519_password.key'), # NOTE: not a bytes. Amusingly, the test above for same key DOES # explicitly cast to bytes...code smell! 'abc123', diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 288541b9..a86fca5d 100644 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -185,34 +185,35 @@ class TestSFTP(object): except: pass - def test_5a_posix_rename(self): + def test_5a_posix_rename(self, sftp): """Test posix-rename@openssh.com protocol extension.""" try: # first check that the normal rename works as specified - with sftp.open(FOLDER + '/a', 'w') as f: + with sftp.open(sftp.FOLDER + '/a', 'w') as f: f.write('one') - sftp.rename(FOLDER + '/a', FOLDER + '/b') - with sftp.open(FOLDER + '/a', 'w') as f: + sftp.rename(sftp.FOLDER + '/a', sftp.FOLDER + '/b') + with sftp.open(sftp.FOLDER + '/a', 'w') as f: f.write('two') try: - sftp.rename(FOLDER + '/a', FOLDER + '/b') + sftp.rename(sftp.FOLDER + '/a', sftp.FOLDER + '/b') self.assertTrue(False, 'no exception when rename-ing onto existing file') except (OSError, IOError): pass # now check with the posix_rename - sftp.posix_rename(FOLDER + '/a', FOLDER + '/b') - with sftp.open(FOLDER + '/b', 'r') as f: + sftp.posix_rename(sftp.FOLDER + '/a', sftp.FOLDER + '/b') + with sftp.open(sftp.FOLDER + '/b', 'r') as f: data = u(f.read()) - self.assertEqual('two', data, "Contents of renamed file not the same as original file") + err = "Contents of renamed file not the same as original file" + assert data == "two", err finally: try: - sftp.remove(FOLDER + '/a') + sftp.remove(sftp.FOLDER + '/a') except: pass try: - sftp.remove(FOLDER + '/b') + sftp.remove(sftp.FOLDER + '/b') except: pass |