Bugfix: cli.py and its unit test case 61/24061/2
authorwu.zhihui <wu.zhihui1@zte.com.cn>
Tue, 8 Nov 2016 12:18:26 +0000 (20:18 +0800)
committerwu.zhihui <wu.zhihui1@zte.com.cn>
Tue, 8 Nov 2016 12:25:21 +0000 (20:25 +0800)
since qtip use log instead of print, assert sentence need
to modify.

Change-Id: I8d19d0e50c4c70f34c7e916c7828984163586260
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
func/cli.py
tests/cli_test.py

index 17f0bde..cea5574 100644 (file)
@@ -44,7 +44,7 @@ class Cli:
 
         args = self._parse_args(args)
         if not args_handler.check_suite(args.file):
-            logger.error("ERROR: This suite file doesn't exist under benchmarks/suite/.\
+            logger.error("ERROR: This suite file %s doesn't exist under benchmarks/suite/.\
                 Please enter correct file." % str(args.file))
             sys.exit(1)
 
index d558329..255c2a3 100644 (file)
@@ -2,6 +2,7 @@ import pytest
 import mock
 import os
 from func.cli import Cli
+from os.path import expanduser
 
 
 class TestClass:
@@ -9,11 +10,11 @@ class TestClass:
         (['-l',
           'zte',
           '-f',
-          'compute'], "You have specified a lab that is not present in test_plan"),
+          'compute'], "You have specified a lab that is not present under test_plan"),
         (['-l',
           'default',
           '-f',
-          'test'], "This suite file doesn't exist under benchmarks/suite/")
+          'test'], "This suite file test doesn't exist under benchmarks/suite/")
     ])
     def test_cli_error(self, capfd, test_input, expected):
         k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'})
@@ -21,8 +22,9 @@ class TestClass:
             k.start()
             Cli(test_input)
             k.stop()
-        resout, reserr = capfd.readouterr()
-        assert expected in resout
+        with open(expanduser('~') + "/qtip/logs/cli.log", "r") as file:
+            data = file.read()
+        assert expected in data
 
     @pytest.mark.parametrize("test_input, expected", [
         (['-l',