Added test for command line -q (quite)

This commit is contained in:
Salvador E. Tropea 2020-05-26 14:22:58 -03:00
parent ee6238a2ce
commit 5883b1a616
2 changed files with 13 additions and 6 deletions

View File

@ -7,7 +7,10 @@ We test (both CSV and ASCII):
- Unified file, mm, only SMD
- Unified file, mm, not only SMD
- Separated files, inches, only SMD
- Also test a case without 'comment' field
- Also test a case:
- without 'comment' field
- with coloured logs
- in quiet mode
For debug information use:
pytest-3 --log-cli-level debug
@ -100,22 +103,25 @@ def test_3Rs_position_inches():
def test_3Rs_position_csv():
""" Also test a case without comment """
""" Also test a case without comment and color logs """
ctx = context.TestContext('3Rs_position_csv', '3Rs', 'simple_position_csv', POS_DIR)
ctx.run()
ctx.run(use_a_tty=True)
pos_top = ctx.get_pos_top_csv_filename()
pos_bot = ctx.get_pos_bot_csv_filename()
ctx.expect_out_file(pos_top)
ctx.expect_out_file(pos_bot)
expect_position(ctx, pos_top, ['R1'], ['R2', 'R3'], csv=True)
expect_position(ctx, pos_bot, ['R2'], ['R1', 'R3'], csv=True)
assert ctx.search_err(r"\[36;1mDEBUG:") is not None
ctx.clean_up()
def test_3Rs_position_unified_csv():
""" Also test the quiet mode """
ctx = context.TestContext('3Rs_position_unified_csv', '3Rs', 'simple_position_unified_csv', POS_DIR)
ctx.run()
ctx.run(no_verbose=True, extra=['-q'])
expect_position(ctx, ctx.get_pos_both_csv_filename(), ['R1', 'R2'], ['R3'], csv=True)
assert os.path.getsize(ctx.get_out_path('error.txt')) == 0
ctx.clean_up()

View File

@ -146,7 +146,7 @@ class TestContext(object):
f.write('Dummy file\n')
def run(self, ret_val=None, extra=None, use_a_tty=False, filename=None, no_out_dir=False, no_board_file=False,
no_yaml_file=False, chdir_out=False):
no_yaml_file=False, chdir_out=False, no_verbose=False):
logging.debug('Running '+self.test_name)
# Change the command to be local and add the board and output arguments
cmd = [COVERAGE_SCRIPT, 'run', '-a']
@ -154,7 +154,8 @@ class TestContext(object):
cmd.append('--rcfile=../../.coveragerc')
os.environ['COVERAGE_FILE'] = os.path.join(os.getcwd(), '.coverage')
cmd.append(os.path.abspath(os.path.dirname(os.path.abspath(__file__))+'/../../src/kiplot'))
cmd.append('-vv')
if not no_verbose:
cmd.append('-vv')
if not no_board_file:
cmd = cmd+['-b', filename if filename else self.board_file]
if not no_yaml_file: