diff options
author | dol-sen <brian.dolbec@gmail.com> | 2011-09-23 23:03:26 -0700 |
---|---|---|
committer | dol-sen <brian.dolbec@gmail.com> | 2011-09-23 23:03:26 -0700 |
commit | 25ae8b28da0632ed33935e32071c9aa683814da2 (patch) | |
tree | e533ddec419bcbd808a4560ef0403f5908415026 /layman/db.py | |
parent | f3e1976da8eeef942a95019669633255fa3b6c50 (diff) | |
download | layman-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.py | 33 |
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 |