public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/, layman/tests/
Date: Sat, 24 Sep 2011 06:07:08 +0000 (UTC)	[thread overview]
Message-ID: <25ae8b28da0632ed33935e32071c9aa683814da2.dol-sen@gentoo> (raw)

commit:     25ae8b28da0632ed33935e32071c9aa683814da2
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Sep 24 06:03:26 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Sep 24 06:03:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=25ae8b28

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):
 
         >>> import os
         >>> here = os.path.dirname(os.path.realpath(__file__))
-        >>> cache = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> cache = os.path.join(tmpdir, 'cache')
         >>> from layman.config import OptionConfig
         >>> opts = {'overlays' :
         ...           ['file://' + here + '/tests/testfiles/global-overlays.xml'],
@@ -440,6 +442,8 @@ class LaymanAPI(object):
         #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}}
 
         >>> os.unlink(filename)
+        >>> import shutil
+        >>> shutil.rmtree(tmpdir)
         """
 
         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.
 
-        >>> write = os.tmpnam()
-        >>> write2 = os.tmpnam()
-        >>> write3 = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> write = os.path.join(tmpdir, 'installed.xml')
+        >>> write2 = os.path.join(tmpdir, 'make.conf')
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> from layman.config import OptionConfig
         >>> myoptions = {'installed' :
         ...           here + '/tests/testfiles/global-overlays.xml',
         ...           'make_conf' : write2,
         ...           'nocheck'    : 'yes',
-        ...           'storage'   : write3}
+        ...           'storage'   : tmpdir}
 
         >>> config = OptionConfig(myoptions)
         >>> config.set_option('quietness', 3)
@@ -143,8 +144,8 @@ class DB(DbBase):
         # >>> os.unlink(write)
         >>> os.unlink(write2)
 
-        #>>> import shutil
-        # >>> shutil.rmtree(write3)
+        >>> import shutil
+        >>> shutil.rmtree(tmpdir)
         '''
 
         if overlay.name not in self.overlays.keys():
@@ -183,16 +184,17 @@ class DB(DbBase):
         '''
         Add an overlay to the local list of overlays.
 
-        >>> write = os.tmpnam()
-        >>> write2 = os.tmpnam()
-        >>> write3 = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> write = os.path.join(tmpdir, 'installed.xml')
+        >>> write2 = os.path.join(tmpdir, 'make.conf')
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> from layman.config import OptionConfig
         >>> myoptions = {'installed' :
         ...           here + '/tests/testfiles/global-overlays.xml',
         ...           'make_conf' : write2,
         ...           'nocheck'    : 'yes',
-        ...           'storage'   : write3}
+        ...           'storage'   : tmpdir}
 
         >>> config = OptionConfig(myoptions)
         >>> config.set_option('quietness', 3)
@@ -230,8 +232,8 @@ class DB(DbBase):
         # >>> os.unlink(write)
         >>> os.unlink(write2)
 
-        #>>> import shutil
-        # >>> shutil.rmtree(write3)
+        >>> import shutil
+        >>> shutil.rmtree(tmpdir)
         '''
 
         if overlay.name in self.overlays.keys():
@@ -303,8 +305,10 @@ class RemoteDB(DbBase):
         '''
         Copy the remote overlay list to the local cache.
 
+        >>> import tempfile
         >>> here = os.path.dirname(os.path.realpath(__file__))
-        >>> cache = os.tmpnam()
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> cache = os.path.join(tmpdir, 'cache')
         >>> myoptions = {'overlays' :
         ...           ['file://' + here + '/tests/testfiles/global-overlays.xml'],
         ...           'cache' : cache,
@@ -325,6 +329,9 @@ class RemoteDB(DbBase):
 
         >>> a.overlays.keys()
         [u'wrobel', u'wrobel-stable']
+
+        >>> import shutil
+        >>> shutil.rmtree(tmpdir)
         '''
         has_updates = 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.
 
-        >>> write = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> write = os.path.join(tmpdir, 'test.xml')
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> from layman.config import BareConfig
         >>> config = BareConfig()
@@ -209,6 +211,7 @@ class DbBase(object):
         [u'wrobel-stable']
 
         >>> os.unlink(write)
+        >>> os.rmdir(tmpdir)
         '''
 
         tree = ET.Element('repositories', version="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:
 
     >>> import hashlib
-    >>> write = os.tmpnam()
+    >>> import tempfile
+    >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+    >>> write = os.path.join(tmpdir, 'make.conf')
     >>> here = os.path.dirname(os.path.realpath(__file__))
     >>> config = {'installed' :
     ...           here + '/tests/testfiles/global-overlays.xml',
@@ -63,6 +65,8 @@ class MakeConf:
     >>> o_md5 == n_md5
     True
     >>> os.unlink(write)
+    >>> import shutil
+    >>> shutil.rmtree(tmpdir)
     '''
 
     my_re = re.compile('PORTDIR_OVERLAY\s*=\s*"([^"]*)"')
@@ -84,7 +88,9 @@ class MakeConf:
         '''
         Add an overlay to make.conf.
 
-        >>> write = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> write = os.path.join(tmpdir, 'make.conf')
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> config = {'installed' :
         ...           here + '/tests/testfiles/global-overlays.xml',
@@ -104,6 +110,8 @@ class MakeConf:
         [u'/usr/local/portage/ebuilds/testing', u'/usr/local/portage/ebuilds/stable', u'/usr/local/portage/kolab2', u'/usr/local/portage/gentoo-webapps-overlay/experimental', u'/usr/local/portage/gentoo-webapps-overlay/production-ready']
 
         >>> 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.
 
-        >>> write = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> write = os.path.join(tmpdir, 'make.conf')
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> config = {'installed' :
         ...           here + '/tests/testfiles/global-overlays.xml',
@@ -132,6 +142,8 @@ class MakeConf:
         [u'/usr/local/portage/ebuilds/testing', u'/usr/local/portage/ebuilds/stable', u'/usr/local/portage/kolab2', u'/usr/local/portage/gentoo-webapps-overlay/experimental', u'/usr/local/portage/gentoo-webapps-overlay/production-ready']
 
         >>> os.unlink(write)
+        >>> import shutil
+        >>> shutil.rmtree(tmpdir)
         '''
         self.overlays = [i
                          for i in self.overlays
@@ -201,7 +213,9 @@ class MakeConf:
         '''
         Write the list of registered overlays to /etc/make.conf.
 
-        >>> write = os.tmpnam()
+        >>> import tempfile
+        >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_")
+        >>> os.path.join(tmpdir, 'make.conf')
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> config = {'installed' :
         ...           here + '/tests/testfiles/global-overlays.xml',
@@ -221,6 +235,8 @@ class MakeConf:
         [u'/usr/local/portage/ebuilds/testing', u'/usr/local/portage/ebuilds/stable', u'/usr/local/portage/kolab2', u'/usr/local/portage/gentoo-webapps-overlay/experimental', u'/usr/local/portage/gentoo-webapps-overlay/production-ready']
 
         >>> 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[:] = [repo_name, desc, owner, source, subpath]
     >>> from layman.config import BareConfig
     >>> config = BareConfig()
-    >>> testdir = os.tmpnam()
-    >>> os.mkdir(testdir)
+    >>> import tempfile
+    >>> testdir = tempfile.mkdtemp(prefix="laymantmp_")
     >>> from layman.overlays.overlay import Overlay
     >>> a = 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):
 
         # Read, write, re-read, compare
         os1 = DbBase(config, [filename1])
-        filename2 = os.tmpnam()
+        filename2 = tempfile.mkstemp()[1]
         os1.write(filename2)
         os2 = DbBase(config, [filename2])
         os.unlink(filename2)



             reply	other threads:[~2011-09-24  6:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-24  6:07 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/, layman/tests/ Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2011-07-23  6:45 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25ae8b28da0632ed33935e32071c9aa683814da2.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox