From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1R7LOY-0006fj-Vo for garchives@archives.gentoo.org; Sat, 24 Sep 2011 06:07:27 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A9A0B21C16E; Sat, 24 Sep 2011 06:07:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 59BC021C16E for ; Sat, 24 Sep 2011 06:07:13 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1F53F1B4017 for ; Sat, 24 Sep 2011 06:07:09 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2D2BE8004F for ; Sat, 24 Sep 2011 06:07:08 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <25ae8b28da0632ed33935e32071c9aa683814da2.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/, layman/tests/ X-VCS-Repository: proj/layman X-VCS-Files: layman/api.py layman/db.py layman/dbbase.py layman/makeconf.py layman/overlays/tar.py layman/tests/external.py X-VCS-Directories: layman/overlays/ layman/ layman/tests/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 25ae8b28da0632ed33935e32071c9aa683814da2 Date: Sat, 24 Sep 2011 06:07:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 00ce61146560cf8cb9211bf9edf56aa8 commit: 25ae8b28da0632ed33935e32071c9aa683814da2 Author: dol-sen gmail com> AuthorDate: Sat Sep 24 06:03:26 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sat Sep 24 06:03:26 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3D25ae8b28 make the tests more py3 compatibile. --- layman/api.py | 6 +++++- layman/db.py | 33 ++++++++++++++++++++------------- layman/dbbase.py | 5 ++++- layman/makeconf.py | 24 ++++++++++++++++++++---- layman/overlays/tar.py | 4 ++-- layman/tests/external.py | 2 +- 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/layman/api.py b/layman/api.py index c1a0e97..3005c3f 100755 --- a/layman/api.py +++ b/layman/api.py @@ -396,7 +396,9 @@ class LaymanAPI(object): =20 >>> import os >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> cache =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> cache =3D os.path.join(tmpdir, 'cache') >>> from layman.config import OptionConfig >>> opts =3D {'overlays' : ... ['file://' + here + '/tests/testfiles/global-overl= ays.xml'], @@ -440,6 +442,8 @@ class LaymanAPI(object): #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}} =20 >>> os.unlink(filename) + >>> import shutil + >>> shutil.rmtree(tmpdir) """ =20 try: diff --git a/layman/db.py b/layman/db.py index 807a740..cca257b 100644 --- a/layman/db.py +++ b/layman/db.py @@ -104,16 +104,17 @@ class DB(DbBase): ''' Add an overlay to the local list of overlays. =20 - >>> write =3D os.tmpnam() - >>> write2 =3D os.tmpnam() - >>> write3 =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> write =3D os.path.join(tmpdir, 'installed.xml') + >>> write2 =3D os.path.join(tmpdir, 'make.conf') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> from layman.config import OptionConfig >>> myoptions =3D {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : write2, ... 'nocheck' : 'yes', - ... 'storage' : write3} + ... 'storage' : tmpdir} =20 >>> config =3D OptionConfig(myoptions) >>> config.set_option('quietness', 3) @@ -143,8 +144,8 @@ class DB(DbBase): # >>> os.unlink(write) >>> os.unlink(write2) =20 - #>>> import shutil - # >>> shutil.rmtree(write3) + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' =20 if overlay.name not in self.overlays.keys(): @@ -183,16 +184,17 @@ class DB(DbBase): ''' Add an overlay to the local list of overlays. =20 - >>> write =3D os.tmpnam() - >>> write2 =3D os.tmpnam() - >>> write3 =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> write =3D os.path.join(tmpdir, 'installed.xml') + >>> write2 =3D os.path.join(tmpdir, 'make.conf') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> from layman.config import OptionConfig >>> myoptions =3D {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : write2, ... 'nocheck' : 'yes', - ... 'storage' : write3} + ... 'storage' : tmpdir} =20 >>> config =3D OptionConfig(myoptions) >>> config.set_option('quietness', 3) @@ -230,8 +232,8 @@ class DB(DbBase): # >>> os.unlink(write) >>> os.unlink(write2) =20 - #>>> import shutil - # >>> shutil.rmtree(write3) + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' =20 if overlay.name in self.overlays.keys(): @@ -303,8 +305,10 @@ class RemoteDB(DbBase): ''' Copy the remote overlay list to the local cache. =20 + >>> import tempfile >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> cache =3D os.tmpnam() + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> cache =3D os.path.join(tmpdir, 'cache') >>> myoptions =3D {'overlays' : ... ['file://' + here + '/tests/testfiles/global-overl= ays.xml'], ... 'cache' : cache, @@ -325,6 +329,9 @@ class RemoteDB(DbBase): =20 >>> a.overlays.keys() [u'wrobel', u'wrobel-stable'] + + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' has_updates =3D False # succeeded reset when a failure is detected diff --git a/layman/dbbase.py b/layman/dbbase.py index 149988b..461038b 100644 --- a/layman/dbbase.py +++ b/layman/dbbase.py @@ -195,7 +195,9 @@ class DbBase(object): ''' Write the list of overlays to a file. =20 - >>> write =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> write =3D os.path.join(tmpdir, 'test.xml') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> from layman.config import BareConfig >>> config =3D BareConfig() @@ -209,6 +211,7 @@ class DbBase(object): [u'wrobel-stable'] =20 >>> os.unlink(write) + >>> os.rmdir(tmpdir) ''' =20 tree =3D ET.Element('repositories', version=3D"1.0") diff --git a/layman/makeconf.py b/layman/makeconf.py index 9836a1a..7eca2cd 100644 --- a/layman/makeconf.py +++ b/layman/makeconf.py @@ -34,7 +34,9 @@ class MakeConf: Check that an add/remove cycle does not modify the make.conf: =20 >>> import hashlib - >>> write =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> write =3D os.path.join(tmpdir, 'make.conf') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> config =3D {'installed' : ... here + '/tests/testfiles/global-overlays.xml', @@ -63,6 +65,8 @@ class MakeConf: >>> o_md5 =3D=3D n_md5 True >>> os.unlink(write) + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' =20 my_re =3D re.compile('PORTDIR_OVERLAY\s*=3D\s*"([^"]*)"') @@ -84,7 +88,9 @@ class MakeConf: ''' Add an overlay to make.conf. =20 - >>> write =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> write =3D os.path.join(tmpdir, 'make.conf') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> config =3D {'installed' : ... here + '/tests/testfiles/global-overlays.xml', @@ -104,6 +110,8 @@ class MakeConf: [u'/usr/local/portage/ebuilds/testing', u'/usr/local/portage/ebu= ilds/stable', u'/usr/local/portage/kolab2', u'/usr/local/portage/gentoo-w= ebapps-overlay/experimental', u'/usr/local/portage/gentoo-webapps-overlay= /production-ready'] =20 >>> os.unlink(write) + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' self.overlays.append(overlay) return self.write() @@ -112,7 +120,9 @@ class MakeConf: ''' Delete an overlay from make.conf. =20 - >>> write =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> write =3D os.path.join(tmpdir, 'make.conf') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> config =3D {'installed' : ... here + '/tests/testfiles/global-overlays.xml', @@ -132,6 +142,8 @@ class MakeConf: [u'/usr/local/portage/ebuilds/testing', u'/usr/local/portage/ebu= ilds/stable', u'/usr/local/portage/kolab2', u'/usr/local/portage/gentoo-w= ebapps-overlay/experimental', u'/usr/local/portage/gentoo-webapps-overlay= /production-ready'] =20 >>> os.unlink(write) + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' self.overlays =3D [i for i in self.overlays @@ -201,7 +213,9 @@ class MakeConf: ''' Write the list of registered overlays to /etc/make.conf. =20 - >>> write =3D os.tmpnam() + >>> import tempfile + >>> tmpdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") + >>> os.path.join(tmpdir, 'make.conf') >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> config =3D {'installed' : ... here + '/tests/testfiles/global-overlays.xml', @@ -221,6 +235,8 @@ class MakeConf: [u'/usr/local/portage/ebuilds/testing', u'/usr/local/portage/ebu= ilds/stable', u'/usr/local/portage/kolab2', u'/usr/local/portage/gentoo-w= ebapps-overlay/experimental', u'/usr/local/portage/gentoo-webapps-overlay= /production-ready'] =20 >>> os.unlink(write) + >>> import shutil + >>> shutil.rmtree(tmpdir) ''' def prio_sort(a, b): '''Sort by priority.''' diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py index 546c134..5d66acc 100644 --- a/layman/overlays/tar.py +++ b/layman/overlays/tar.py @@ -59,8 +59,8 @@ class TarOverlay(OverlaySource): >>> repo[:] =3D [repo_name, desc, owner, source, subpath] >>> from layman.config import BareConfig >>> config =3D BareConfig() - >>> testdir =3D os.tmpnam() - >>> os.mkdir(testdir) + >>> import tempfile + >>> testdir =3D tempfile.mkdtemp(prefix=3D"laymantmp_") >>> from layman.overlays.overlay import Overlay >>> a =3D Overlay(config, repo) >>> config['output'].set_colorize(False) diff --git a/layman/tests/external.py b/layman/tests/external.py index e5e8c4e..00e4a82 100755 --- a/layman/tests/external.py +++ b/layman/tests/external.py @@ -54,7 +54,7 @@ class FormatSubpathCategory(unittest.TestCase): =20 # Read, write, re-read, compare os1 =3D DbBase(config, [filename1]) - filename2 =3D os.tmpnam() + filename2 =3D tempfile.mkstemp()[1] os1.write(filename2) os2 =3D DbBase(config, [filename2]) os.unlink(filename2)