PyUT: Implement test for lsb_release.get_distro_information.
authorDidier Raboud <odyx@debian.org>
Wed, 23 May 2012 08:43:38 +0000 (10:43 +0200)
committerDidier Raboud <odyx@debian.org>
Wed, 23 May 2012 12:56:48 +0000 (14:56 +0200)
test/test_lsb_release.py

index 50c899562c06a3edc5a808b752b62106d0c3d0fb..87e5af09f6d5d9126bc254d9e66c07832fb45c91 100644 (file)
@@ -261,9 +261,21 @@ class TestLSBRelease(unittest.TestCase):
                self.assertEqual(lr.get_lsb_information(),supposed_output)
                os.environ.pop('LSB_ETC_LSB_RELEASE')
 
-       @unittest.skip('Test not implemented.')
        def test_get_distro_information(self):
-               raise NotImplementedError()
+               # Test that an inexistant /etc/lsb-release leads to empty output
+               supposed_output = get_arch_distinfo()
+               supposed_output['RELEASE']     = 'testing/unstable';
+               supposed_output['DESCRIPTION'] = '%(ID)s %(OS)s %(RELEASE)s' % supposed_output
+
+               os.environ['LSB_ETC_LSB_RELEASE'] = 'test/inexistant_file_' + rnd_string(2,5)
+               fn = 'test/debian_version_' + rnd_string(5,12)
+               f = open(fn,'w')
+               f.write('testing/sid')
+               f.close()
+               os.environ['LSB_ETC_DEBIAN_VERSION'] = fn
+               self.assertEqual(lr.get_distro_information(),supposed_output)
+               os.remove(fn)
+               os.environ.pop('LSB_ETC_DEBIAN_VERSION')
 
 if __name__ == '__main__':
        unittest.main()