From 5e9df7763328f998805b28aff874b56b67d1bd88 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 7 Jul 2014 14:19:43 +0200 Subject: Skip lsb_release tests when module is missing --- tests/test_debiandistro.py | 7 +++++++ tests/test_distro.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/test_debiandistro.py b/tests/test_debiandistro.py index b2041ff..617005c 100644 --- a/tests/test_debiandistro.py +++ b/tests/test_debiandistro.py @@ -23,6 +23,12 @@ try: except ImportError: have_apt_pkg=False +try: + import lsb_release + have_lsb_release=True +except ImportError: + have_lsb_release=False + from whatmaps.debiandistro import DebianDistro from whatmaps.debianpkg import DebianPkg @@ -90,6 +96,7 @@ class TestDebianDistro(unittest.TestCase): @patch('apt_pkg.init') @patch('apt_pkg.Acquire') @unittest.skipUnless(have_apt_pkg, "apt_pkg not installed") + @unittest.skipUnless(have_lsb_release, "lsb_release not installed") def test_filter_security_updates(self, apt_pkg_acquire, apt_pkg_init): pkgs = {'pkg1': DebianPkg('pkg1'), 'pkg2': DebianPkg('pkg2'), diff --git a/tests/test_distro.py b/tests/test_distro.py index c67b0f6..88fa984 100644 --- a/tests/test_distro.py +++ b/tests/test_distro.py @@ -18,6 +18,12 @@ import unittest from mock import patch +try: + import lsb_release + have_lsb_release=True +except ImportError: + have_lsb_release=False + from whatmaps.distro import Distro, detect class Pkg(object): @@ -39,6 +45,8 @@ class TestDistro(unittest.TestCase): self.assertEqual(Distro.pkg_service_blacklist(Pkg), []) self.assertFalse(Distro.has_apt()) + + @unittest.skipUnless(have_lsb_release, "lsb_release not installed") def test_detect_via_lsb_release_module(self): "Detect distro via lsb_release" with patch('lsb_release.get_distro_information', return_value={'ID': 'Debian'}): -- cgit v1.2.3