From 27aff933298968f4b205fd1fcfec1627dba08772 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 15 Aug 2012 18:23:52 +0300 Subject: [PATCH] Fixed tests for gbs help. Tests were running gbs help with os.system, which means that in order to pass tests gbs have to be installed. This doesn't make much sense for developer-level tests. They should be able to run from source tree without any preparations. Change-Id: I4d66326ad26564f2e253d2141284b475a0d4995e --- tests/01_test_help.py | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/tests/01_test_help.py b/tests/01_test_help.py index 8d665de..724f19b 100644 --- a/tests/01_test_help.py +++ b/tests/01_test_help.py @@ -1,24 +1,46 @@ -# vim: set fileencoding=utf-8 : +#!/usr/bin/python -tt +# vim: ai ts=4 sts=4 et sw=4 # -# check if --help works +# Copyright (c) 2012 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Functionality tests for gbs help.""" -import os import unittest +import imp + +from nose.tools import eq_ + +GBS = imp.load_source("gbs", "./tools/gbs").Gbs().main class TestHelp(unittest.TestCase): """Test help output of gbs commands""" - def testSubCommandHelp(self): - for prog in [ "build", "remotebuild"]: - ret = os.system("gbs help %s > /dev/null" % prog) - self.assertEqual(ret, 0) + @staticmethod + def test_subcommand_help(): + """Test running gbs help with all possible subcommands.""" + for sub in [ "build", "lb", "remotebuild", "rb", "changelog", + "submit", "sr", "export", "ex", "import", "im", + "chroot"]: - ret = os.system("gbs %s --help > /dev/null" % prog) - self.assertEqual(ret, 0) + eq_(GBS(argv=["gbs", "help", sub]), None) + eq_(GBS(argv=["gbs", sub, "--help"]), 0) - def testHelp(self): - ret = os.system("gbs --help > /dev/null") - self.assertEqual(ret, 0) + @staticmethod + def test_help(): + """Test running gbs --help and gbs help.""" + eq_(GBS(argv=["gbs", "--help"]), 0) + eq_(GBS(argv=["gbs", "help"]), None) - ret = os.system("gbs help > /dev/null") - self.assertEqual(ret, 0) -- 2.7.4