File: test_coverup_83.py

package info (click to toggle)
scalene 1.5.51-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,528 kB
  • sloc: cpp: 22,930; python: 13,403; javascript: 11,769; ansic: 817; makefile: 196; sh: 45
file content (31 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# file scalene/scalene_parseargs.py:15-24
# lines [17, 19, 20, 23, 24]
# branches ['23->exit', '23->24']

import argparse
from unittest.mock import patch
import pytest

# Assuming the RichArgParser class is in a file named scalene_parseargs.py
from scalene.scalene_parseargs import RichArgParser

def test_rich_arg_parser_print_message(capsys):
    with patch('rich.console.Console') as mock_console:
        parser = RichArgParser()
        parser._print_message("Test message")
        mock_console.return_value.print.assert_called_once_with("Test message")

        # Now test with message being None
        parser._print_message(None)
        mock_console.return_value.print.assert_called_once_with("Test message")

        # Capture the output to ensure it's not printed to the actual console
        captured = capsys.readouterr()
        assert captured.out == ""
        assert captured.err == ""

def test_rich_arg_parser_init():
    with patch('rich.console.Console') as mock_console:
        parser = RichArgParser()
        mock_console.assert_called_once()
        assert isinstance(parser, argparse.ArgumentParser)