summaryrefslogtreecommitdiffstats
path: root/layman/db.py
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-09-23 23:03:26 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-09-23 23:03:26 -0700
commit25ae8b28da0632ed33935e32071c9aa683814da2 (patch)
treee533ddec419bcbd808a4560ef0403f5908415026 /layman/db.py
parentf3e1976da8eeef942a95019669633255fa3b6c50 (diff)
downloadlayman-25ae8b28da0632ed33935e32071c9aa683814da2.tar.gz
layman-25ae8b28da0632ed33935e32071c9aa683814da2.tar.bz2
layman-25ae8b28da0632ed33935e32071c9aa683814da2.zip
make the tests more py3 compatibile.
Diffstat (limited to 'layman/db.py')
-rw-r--r--layman/db.py33
1 files changed, 20 insertions, 13 deletions
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