Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_cmd_line_script fails with verbosity level more than 1 #85897

Closed
tirkarthi opened this issue Sep 6, 2020 · 6 comments
Closed

test_cmd_line_script fails with verbosity level more than 1 #85897

tirkarthi opened this issue Sep 6, 2020 · 6 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@tirkarthi
Copy link
Member

BPO 41731
Nosy @terryjreedy, @miss-islington, @tirkarthi
PRs
  • bpo-41731: Make test_cmd_line_script pass with -vv #22206
  • [3.9] bpo-41731: Make test_cmd_line_script pass with -vv (GH-22206) #22213
  • [3.8] bpo-41731: Make test_cmd_line_script pass with -vv (GH-22206) #22214
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-09-12.08:34:37.231>
    created_at = <Date 2020-09-06.04:57:49.370>
    labels = ['3.8', 'type-bug', 'tests', '3.9', '3.10']
    title = 'test_cmd_line_script fails with verbosity level more than 1'
    updated_at = <Date 2020-09-12.09:10:39.904>
    user = 'https://github.com/tirkarthi'

    bugs.python.org fields:

    activity = <Date 2020-09-12.09:10:39.904>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-09-12.08:34:37.231>
    closer = 'terry.reedy'
    components = ['Tests']
    creation = <Date 2020-09-06.04:57:49.370>
    creator = 'xtreak'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41731
    keywords = ['patch']
    message_count = 6.0
    messages = ['376457', '376746', '376780', '376781', '376782', '376797']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'miss-islington', 'xtreak']
    pr_nums = ['22206', '22213', '22214']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41731'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @tirkarthi
    Copy link
    Member Author

    When verbosity level is more than 1 the test tries to print the script_exec_args passed to script. It fails when the tuple has more than 1 elements and is used in formatting with %r. The two tests fail as below :

    ./python -m test test_cmd_line_script -vv

    ======================================================================
    ERROR: test_package_error (test.test_cmd_line_script.CmdLineTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/root/cpython/Lib/test/test_cmd_line_script.py", line 368, in test_package_error
        self._check_import_error(["-m", "test_pkg"], msg, cwd=script_dir)
      File "/root/cpython/Lib/test/test_cmd_line_script.py", line 148, in _check_import_error
        print('Output from test script %r:' % script_exec_args)
    TypeError: not all arguments converted during string formatting

    ======================================================================
    ERROR: test_package_recursion (test.test_cmd_line_script.CmdLineTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/root/cpython/Lib/test/test_cmd_line_script.py", line 379, in test_package_recursion
        self._check_import_error(["-m", "test_pkg"], msg, cwd=script_dir)
      File "/root/cpython/Lib/test/test_cmd_line_script.py", line 148, in _check_import_error
        print('Output from test script %r:' % script_exec_args)
    TypeError: not all arguments converted during string formatting

    Ran 44 tests in 4.936s

    FAILED (errors=2)
    test test_cmd_line_script failed
    test_cmd_line_script failed

    == Tests result: FAILURE ==

    1 test failed:
    test_cmd_line_script

    Total duration: 5.0 sec
    Tests result: FAILURE

    @tirkarthi tirkarthi added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Sep 6, 2020
    @terryjreedy
    Copy link
    Member

    I verified with master on Win10 debug 32 build. The relevant lines, 147-151, are

            if verbose > 1:
                print('Output from test script %r:' % script_exec_args)
                print(repr(err))
                print('Expected output: %r' % expected_msg)
            self.assertIn(expected_msg.encode('utf-8'), err)

    Normally, 'script_exec_args' is singular, the absolute file name to be executed. In the two failing cases, file 'name' is an import name, preceded by -m. Line 148 prints an informational header, when very verbose is requested, that only serves to identify the following lines. It is *not* tested. Therefore, we need not worry about the exact format, just avoiding a spurious error. The following is equivalent except when the value is a list (which should have been a tuple), when is prints without error:

                print(f'Output from test script {script_exec_args!r:}')

    "Output from test script ['-m', 'test_pkg']:" seems clear enough for any human reader. I ran entire suite with -vv and did not find any other new, unexpected errors. PR to follow shortly.

    @terryjreedy
    Copy link
    Member

    New changeset 7e711ea by Terry Jan Reedy in branch 'master':
    bpo-41731: Make test_cmd_line_script pass with -vv (GH-22206)
    7e711ea

    @miss-islington
    Copy link
    Contributor

    New changeset 77901dc by Miss Islington (bot) in branch '3.8':
    bpo-41731: Make test_cmd_line_script pass with -vv (GH-22206)
    77901dc

    @miss-islington
    Copy link
    Contributor

    New changeset 34e3c75 by Miss Islington (bot) in branch '3.9':
    bpo-41731: Make test_cmd_line_script pass with -vv (GH-22206)
    34e3c75

    @tirkarthi
    Copy link
    Member Author

    Thanks Terry.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants