PyUT: Put the distinfo commonities in get_arch_distinfo function.
authorDidier Raboud <odyx@debian.org>
Wed, 23 May 2012 08:42:54 +0000 (10:42 +0200)
committerDidier Raboud <odyx@debian.org>
Wed, 23 May 2012 12:56:48 +0000 (14:56 +0200)
Git-Dch: None

test/test_lsb_release.py

index 57eedb6239d18c185746e6dfd1f591a1974d7645..50c899562c06a3edc5a808b752b62106d0c3d0fb 100644 (file)
@@ -11,6 +11,21 @@ import os
 def rnd_string(min_l,max_l):
        return ''.join( [random.choice(string.letters) for i in xrange(random.randint(min_l,max_l))])
 
+def get_arch_distinfo():
+       # Copied verbatim from guess_debian_release; sucks but unavoidable.
+       distinfo = {'ID' : 'Debian'}
+       kern = os.uname()[0]
+       if kern in ('Linux', 'Hurd', 'NetBSD'):
+               distinfo['OS'] = 'GNU/'+kern
+       elif kern == 'FreeBSD':
+               distinfo['OS'] = 'GNU/k'+kern
+       elif kern in ('GNU/Linux', 'GNU/kFreeBSD'):
+               distinfo['OS'] = kern
+       else:
+               distinfo['OS'] = 'GNU'
+       return distinfo
+
+
 class TestLSBRelease(unittest.TestCase):
 
        def test_lookup_codename(self):
@@ -156,17 +171,7 @@ class TestLSBRelease(unittest.TestCase):
                os.environ.pop('TEST_APT_CACHE_RELEASE')
 
        def test_guess_debian_release(self):
-               # Copied verbatim from guess_debian_release; sucks but unavoidable.
-               distinfo = {'ID' : 'Debian'}
-               kern = os.uname()[0]
-               if kern in ('Linux', 'Hurd', 'NetBSD'):
-                       distinfo['OS'] = 'GNU/'+kern
-               elif kern == 'FreeBSD':
-                       distinfo['OS'] = 'GNU/k'+kern
-               elif kern in ('GNU/Linux', 'GNU/kFreeBSD'):
-                       distinfo['OS'] = kern
-               else:
-                       distinfo['OS'] = 'GNU'
+               distinfo = get_arch_distinfo()
 
                # Test "stable releases" with numeric debian_versions
                for rno in lr.RELEASE_CODENAME_LOOKUP: