From 4ceefe71e176b38d333cc54597bc9427ea842f75 Mon Sep 17 00:00:00 2001 From: Emile Anclin Date: Tue, 21 Sep 2010 15:25:09 +0200 Subject: [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 --- test/unittest_shellutils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/unittest_shellutils.py') 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)) -- cgit v1.2.1