diff options
author | Robey Pointer <robey@lag.net> | 2006-04-06 11:18:21 -0700 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2006-04-06 11:18:21 -0700 |
commit | ccc1046a5c3f39c195e2fceae01ced155d8a8778 (patch) | |
tree | 8b0bc73d7a743d4d090751a4d3e2d062ab3d5b04 /tests/test_sftp.py | |
parent | d7b28ac257caf5daa2bd673efff9350bf547de38 (diff) |
[project @ robey@lag.net-20060406181821-68f9bc13b3580d37]
some fixes for win32: potential fix for lockup during failed tests; don't try chmod/chown or symlinks; fix canonicalize to convert dos-style path separators to '/'; open local files in binary mode; close a file before erasing it
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-x | tests/test_sftp.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 34690aba..6172a0dc 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -289,7 +289,11 @@ class SFTPTest (unittest.TestCase): stat = sftp.stat(FOLDER + '/special') sftp.chmod(FOLDER + '/special', (stat.st_mode & ~0777) | 0600) stat = sftp.stat(FOLDER + '/special') - self.assertEqual(stat.st_mode & 0777, 0600) + expected_mode = 0600 + if sys.platform == 'win32': + # chmod not really functional on windows + expected_mode = 0666 + self.assertEqual(stat.st_mode & 0777, expected_mode) self.assertEqual(stat.st_size, 1024) mtime = stat.st_mtime - 3600 @@ -321,7 +325,12 @@ class SFTPTest (unittest.TestCase): stat = f.stat() f.chmod((stat.st_mode & ~0777) | 0600) stat = f.stat() - self.assertEqual(stat.st_mode & 0777, 0600) + + expected_mode = 0600 + if sys.platform == 'win32': + # chmod not really functional on windows + expected_mode = 0666 + self.assertEqual(stat.st_mode & 0777, expected_mode) self.assertEqual(stat.st_size, 1024) mtime = stat.st_mtime - 3600 @@ -394,6 +403,10 @@ class SFTPTest (unittest.TestCase): """ create a symlink and then check that lstat doesn't follow it. """ + if not hasattr(os, "symlink"): + # skip symlink tests on windows + return + f = sftp.open(FOLDER + '/original.txt', 'w') try: f.write('original\n') @@ -535,7 +548,7 @@ class SFTPTest (unittest.TestCase): localname = os.tempnam() text = 'All I wanted was a plastic bunny rabbit.\n' - f = open(localname, 'w') + f = open(localname, 'wb') f.write(text) f.close() sftp.put(localname, FOLDER + '/bunny.txt') @@ -548,7 +561,7 @@ class SFTPTest (unittest.TestCase): localname = os.tempnam() sftp.get(FOLDER + '/bunny.txt', localname) - f = open(localname, 'r') + f = open(localname, 'rb') self.assertEquals(text, f.read(128)) f.close() @@ -574,6 +587,7 @@ class SFTPTest (unittest.TestCase): sum = f.check('md5', 0, 0, 510) self.assertEquals('EB3B45B8CD55A0707D99B177544A319F373183D241432BB2157AB9E46358C4AC90370B5CADE5D90336FC1716F90B36D6', paramiko.util.hexify(sum)) + f.close() finally: sftp.unlink(FOLDER + '/kitty.txt') |