Fix test_main and test_depends for systems missing lsb_release

There are a couple of tests that actually end up trying to run lsb_release
on the host. If not present, this causes tests to fail. This just makes sure
subprocess.check_output is suitably mocked out to avoid that.

Change-Id: Ifb8981d6b39b7c52b9e72fdf8d1e5e4566d45472
This commit is contained in:
Dan Smith 2017-05-26 07:13:43 -07:00
parent c47e81959e
commit 1a3b063990
2 changed files with 6 additions and 2 deletions

View File

@ -47,8 +47,9 @@ class TestDepends(TestCase):
self.assertEqual([], depends.profiles())
def test_platform_profiles_succeeds(self):
depends = Depends("")
self.assertIsInstance(depends.platform_profiles(), list)
with self._mock_lsb('Ubuntu'):
depends = Depends("")
self.assertIsInstance(depends.platform_profiles(), list)
@contextlib.contextmanager
def _mock_lsb(self, platform):

View File

@ -41,6 +41,9 @@ class MainFixture(Fixture):
self.path = self.useFixture(TempDir()).path
self.addCleanup(os.chdir, self.path)
os.chdir(self.path)
fake_lsb = b'Ubuntu\n14.04\nTrusty'
self.useFixture(MonkeyPatch('subprocess.check_output',
lambda *a, **k: fake_lsb))
class TestMain(TestCase):