Use portage.os, _content_encoding, and _fs_encoding where appropriate.
authorZac Medico <zmedico@gentoo.org>
Mon, 17 Aug 2009 22:18:02 +0000 (22:18 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 17 Aug 2009 22:18:02 +0000 (22:18 -0000)
svn path=/main/trunk/; revision=14078

pym/portage/tests/bin/setup_env.py
pym/portage/tests/ebuild/test_spawn.py
pym/portage/tests/env/config/test_PackageKeywordsFile.py
pym/portage/tests/env/config/test_PackageMaskFile.py
pym/portage/tests/env/config/test_PackageUseFile.py
pym/portage/tests/env/config/test_PortageModulesFile.py
pym/portage/tests/news/test_NewsItem.py
pym/portage/tests/process/test_poll.py
pym/portage/tests/sets/files/testConfigFileSet.py
pym/portage/tests/sets/files/testStaticFileSet.py
pym/portage/tests/util/test_uniqueArray.py

index 727f02e7b62d49695299c63043c75184f5752f85..aab210ee93916844f3e0d633985ef39ab5dd7530 100644 (file)
@@ -3,15 +3,17 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import os, shutil, sys
-from os.path import dirname, abspath, join
+from portage import os
+from portage import shutil
 from portage.tests import TestCase
 from portage.process import spawn
 from portage.const import PORTAGE_BIN_PATH
 
-bindir = join(dirname(dirname(abspath(__file__))),
+bindir = os.path.join(os.path.dirname(os.path.dirname(
+       os.path.abspath(__file__))),
        "..", "..", "..", "bin", "ebuild-helpers")
-basedir = join(dirname(dirname(abspath(__file__))), "bin", "root")
+basedir = os.path.join(os.path.dirname(os.path.dirname(
+       os.path.abspath(__file__))), "bin", "root")
 os.environ["D"] = os.path.join(basedir, "image")
 os.environ["T"] = os.path.join(basedir, "temp")
 os.environ["S"] = os.path.join(basedir, "workdir")
@@ -52,7 +54,7 @@ def xexists_in_D(path):
 def portage_func(func, args, exit_status=0):
        # we don't care about the output of the programs,
        # just their exit value and the state of $D
-       f = open('/dev/null', 'w')
+       f = open('/dev/null', 'wb')
        fd_pipes = {0:0,1:f.fileno(),2:f.fileno()}
        spawn(func+" "+args, env=os.environ, fd_pipes=fd_pipes)
        f.close()
index 1ba6e58478952043f576f553903498f55055c36c..908fce6061e0e2f91dc1ddcc04161fb8987d44d4 100644 (file)
@@ -2,7 +2,13 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import errno, os, sys
+import codecs
+import errno
+import sys
+from portage import os
+from portage import _content_encoding
+from portage import _fs_encoding
+from portage import _unicode_encode
 from portage.tests import TestCase
 
 class SpawnTestCase(TestCase):
@@ -27,7 +33,9 @@ class SpawnTestCase(TestCase):
                        spawn("echo -n '%s'" % test_string, settings, logfile=logfile,
                                free=1, fd_pipes={0:sys.stdin.fileno(), 1:null_fd, 2:null_fd})
                        os.close(null_fd)
-                       f = open(logfile, 'r')
+                       f = codecs.open(_unicode_encode(logfile,
+                               encoding=_fs_encoding, errors='strict'),
+                               mode='r', encoding=_content_encoding, errors='strict')
                        log_content = f.read()
                        f.close()
                        # When logging passes through a pty, this comparison will fail
index 228ce4a8299b0649ffbeb7e3e23f25c1a6973815..228cf2ecb6004b0d7e53ddf5e75e7b559ddc4886 100644 (file)
@@ -3,10 +3,10 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
+from portage import os
 from portage.tests import TestCase
 from portage.env.config import PackageKeywordsFile
 from tempfile import mkstemp
-import os
 
 class PackageKeywordsFileTestCase(TestCase):
 
@@ -38,5 +38,4 @@ class PackageKeywordsFileTestCase(TestCase):
                f.close()
 
        def NukeFile(self):
-               import os
                os.unlink(self.fname)
index dca8002bced8a1e1d57c5a62c7066404ec8f8e5e..90cdf538772c9118a899336659e5b699b21205f4 100644 (file)
@@ -3,8 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import os
-
+from portage import os
 from portage.env.config import PackageMaskFile
 from portage.tests import TestCase, test_cps
 from tempfile import mkstemp
index aa18364a0a2a1c3e35e1878db132c880431b18de..575ede505df39bcdf1f86723bb467cc82550dab2 100644 (file)
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import os
+from portage import os
 from portage.tests import TestCase
 from portage.env.config import PackageUseFile
 from tempfile import mkstemp
index fb164b4a7adfad6cd482fab7487180151eb9de4c..40472104b8bc24951e47375dd2b703cf2758c264 100644 (file)
@@ -1,9 +1,12 @@
+# Copyright 2006-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
 
+from portage import os
 from portage.tests import TestCase
 from portage.env.config import PortageModulesFile
 from tempfile import mkstemp
 from itertools import izip
-import os
 
 class PortageModulesFileTestCase(TestCase):
 
index f4a0735047aa44a86da64926cf935a5a289ea824..721ab26903f41fb6dd351d01ebd142977d6898e3 100644 (file)
@@ -3,10 +3,9 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import os
+from portage import os
 from portage.tests import TestCase
 from portage.news import NewsItem
-from portage.const import PROFILE_PATH
 from portage.dbapi.virtual import testdbapi
 from tempfile import mkstemp
 # TODO(antarus) Make newsitem use a loader so we can load using a string instead of a tempfile
index 3f4a597b4463cfeae26de4c49aacc2d7bac6fc03..22aa6aa8b6cf32e47d7f5ade40b8cdb3c7ffe44a 100644 (file)
@@ -2,11 +2,8 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import errno, os, sys
-import fcntl
-import termios
-import portage
-from portage.output import get_term_size, set_term_size
+import sys
+from portage import os
 from portage.tests import TestCase
 from _emerge.TaskScheduler import TaskScheduler
 from _emerge.PipeReader import PipeReader
index 7ea17fd1bf9de6dc962b069b86d8233e44ffb11c..95ea4f44a316afd716ad0444e0ce4e30fa8cbe1f 100644 (file)
@@ -3,8 +3,9 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import tempfile, os
+import tempfile
 
+from portage import os
 from portage.tests import TestCase, test_cps
 from portage.sets.files import ConfigFileSet
 
index fff583da12a9546770c49eae8e39c3aa6559cc13..138c99e5e6817ab4c195cf03a2bb499a45cd4dd0 100644 (file)
@@ -3,12 +3,11 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import tempfile, os
+import tempfile
 
+from portage import os
 from portage.tests import TestCase, test_cps
 from portage.sets.files import StaticFileSet
-from portage.env.loaders import TestTextLoader
-from portage.env.config import ConfigLoaderKlass
 
 class StaticFileSetTestCase(TestCase):
        """Simple Test Case for StaticFileSet"""
index e1b9caec87c533304efdf0de85c86ee41f8a07db..e9485b126313352f06b3e0538bbdaefb8bfd4262 100644 (file)
@@ -3,6 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
+from portage import os
 from portage.tests import TestCase
 from portage.util import unique_array
 
@@ -13,8 +14,6 @@ class UniqueArrayTestCase(TestCase):
                test portage.util.uniqueArray()
                """
 
-               import os
-
                tests = [ ( ["a","a","a",os,os,[],[],[]], ['a',os,[]] ), 
                          ( [1,1,1,2,3,4,4] , [1,2,3,4]) ]