diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-09-21 15:25:09 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-09-21 15:25:09 +0200 |
commit | 4ceefe71e176b38d333cc54597bc9427ea842f75 (patch) | |
tree | 960eceedad69ecd3e1df9f9c709acba42cb979ee /test/unittest_shellutils.py | |
parent | 4619682b0138bf6cff28530a8a0af29f2bcc8749 (diff) | |
download | logilab-common-4ceefe71e176b38d333cc54597bc9427ea842f75.tar.gz |
[py3k] compat: add str_to_bytes and str_encode
In py3k, things are different: we will sometimes need to convert str to bytes
if we want to write data into a file;
and on other times we don't need to encode str to something
Diffstat (limited to 'test/unittest_shellutils.py')
-rw-r--r-- | test/unittest_shellutils.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py index 2d0507c..d748205 100644 --- a/test/unittest_shellutils.py +++ b/test/unittest_shellutils.py @@ -20,15 +20,15 @@ import sys, os, tempfile, shutil from os.path import join import datetime, time +from StringIO import StringIO from logilab.common.testlib import TestCase, unittest_main from logilab.common.shellutils import (globfind, find, ProgressBar, acquire_lock, release_lock, RawInput, confirm) - +from logilab.common.compat import str_to_bytes from logilab.common.proc import NoSuchProcess -from StringIO import StringIO DATA_DIR = join('data','find_test') @@ -165,14 +165,14 @@ class AcquireLockTC(TestCase): def test_wrong_process(self): fd = os.open(self.lock, os.O_EXCL | os.O_RDWR | os.O_CREAT) - os.write(fd, '1111111111') + os.write(fd, str_to_bytes('1111111111')) os.close(fd) self.assertTrue(os.path.exists(self.lock)) self.assertRaises(Exception, acquire_lock, self.lock, 1, 1) def test_wrong_process_and_continue(self): fd = os.open(self.lock, os.O_EXCL | os.O_RDWR | os.O_CREAT) - os.write(fd, '1111111111') + os.write(fd, str_to_bytes('1111111111')) os.close(fd) self.assertTrue(os.path.exists(self.lock)) self.assertTrue(acquire_lock(self.lock)) |