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

0.5.0: pytest is failing #413

Closed
5 of 7 tasks
kloczek opened this issue Jul 6, 2022 · 17 comments · Fixed by #995
Closed
5 of 7 tasks

0.5.0: pytest is failing #413

kloczek opened this issue Jul 6, 2022 · 17 comments · Fixed by #995
Labels
feature New feature, enhancement or request investigate

Comments

@kloczek
Copy link

kloczek commented Jul 6, 2022

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

Not examplw code.

Description

I'm packaging your module as the rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Looks like ltwo unist are tring to modify my ~/.bashrc

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.5.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.5.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/typer-0.5.0
plugins: cov-3.0.0
collected 507 items

docs_src/testing/app01/test_main.py .                                                                                                                                [  0%]
docs_src/testing/app02/test_main.py .                                                                                                                                [  0%]
docs_src/testing/app03/test_main.py .                                                                                                                                [  0%]
tests/test_others.py ...........                                                                                                                                     [  2%]
tests/test_prog_name.py .                                                                                                                                            [  2%]
tests/test_tracebacks.py F..                                                                                                                                         [  3%]
tests/test_type_conversion.py ..........                                                                                                                             [  5%]
tests/test_compat/test_option_get_help.py ...                                                                                                                        [  6%]
tests/test_completion/test_completion.py FF........                                                                                                                  [  8%]
tests/test_completion/test_completion_complete.py ..........                                                                                                         [ 10%]
tests/test_completion/test_completion_complete_no_help.py ....                                                                                                       [ 10%]
tests/test_completion/test_completion_install.py .F...                                                                                                               [ 11%]
tests/test_completion/test_completion_show.py ......                                                                                                                 [ 13%]
tests/test_tutorial/test_arguments/test_default/test_tutorial001.py ....                                                                                             [ 13%]
tests/test_tutorial/test_arguments/test_default/test_tutorial002.py ....                                                                                             [ 14%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial001.py .....                                                                                             [ 15%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial002.py .....                                                                                             [ 16%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial003.py .....                                                                                             [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial001.py ...                                                                                                 [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial002.py ...                                                                                                 [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial003.py ...                                                                                                 [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial004.py ...                                                                                                 [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial005.py ...                                                                                                 [ 20%]
tests/test_tutorial/test_arguments/test_help/test_tutorial006.py ...                                                                                                 [ 21%]
tests/test_tutorial/test_arguments/test_help/test_tutorial007.py ...                                                                                                 [ 21%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial001.py ...                                                                                             [ 22%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial002.py ....                                                                                            [ 23%]
tests/test_tutorial/test_commands/test_arguments/test_tutorial001.py .....                                                                                           [ 24%]
tests/test_tutorial/test_commands/test_callback/test_tutorial001.py .......                                                                                          [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial002.py ..                                                                                               [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial003.py ...                                                                                              [ 26%]
tests/test_tutorial/test_commands/test_callback/test_tutorial004.py ...                                                                                              [ 27%]
tests/test_tutorial/test_commands/test_context/test_tutorial001.py ...                                                                                               [ 27%]
tests/test_tutorial/test_commands/test_context/test_tutorial002.py ....                                                                                              [ 28%]
tests/test_tutorial/test_commands/test_context/test_tutorial003.py ....                                                                                              [ 29%]
tests/test_tutorial/test_commands/test_context/test_tutorial004.py ..                                                                                                [ 29%]
tests/test_tutorial/test_commands/test_help/test_tutorial001.py ............                                                                                         [ 31%]
tests/test_tutorial/test_commands/test_help/test_tutorial002.py ......                                                                                               [ 33%]
tests/test_tutorial/test_commands/test_index/test_tutorial001.py ...                                                                                                 [ 33%]
tests/test_tutorial/test_commands/test_index/test_tutorial002.py ....                                                                                                [ 34%]
tests/test_tutorial/test_commands/test_name/test_tutorial001.py ....                                                                                                 [ 35%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial001.py ...                                                                                       [ 35%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial002.py ...                                                                                       [ 36%]
tests/test_tutorial/test_commands/test_options/test_tutorial001.py .........                                                                                         [ 38%]
tests/test_tutorial/test_first_steps/test_tutorial001.py ..                                                                                                          [ 38%]
tests/test_tutorial/test_first_steps/test_tutorial002.py ...                                                                                                         [ 39%]
tests/test_tutorial/test_first_steps/test_tutorial003.py ...                                                                                                         [ 39%]
tests/test_tutorial/test_first_steps/test_tutorial004.py ......                                                                                                      [ 41%]
tests/test_tutorial/test_first_steps/test_tutorial005.py ......                                                                                                      [ 42%]
tests/test_tutorial/test_first_steps/test_tutorial006.py ......                                                                                                      [ 43%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial001.py ..                                                                  [ 43%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial002.py .....                                                               [ 44%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial001.py ....                                                                              [ 45%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial002.py ....                                                                              [ 46%]
tests/test_tutorial/test_multiple_values/test_options_with_multiple_values/test_tutorial001.py .....                                                                 [ 47%]
tests/test_tutorial/test_options/test_callback/test_tutorial001.py ...                                                                                               [ 47%]
tests/test_tutorial/test_options/test_callback/test_tutorial003.py ....                                                                                              [ 48%]
tests/test_tutorial/test_options/test_callback/test_tutorial004.py ....                                                                                              [ 49%]
tests/test_tutorial/test_options/test_completion/test_tutorial002.py ...                                                                                             [ 50%]
tests/test_tutorial/test_options/test_completion/test_tutorial003.py ...                                                                                             [ 50%]
tests/test_tutorial/test_options/test_completion/test_tutorial004.py ...                                                                                             [ 51%]
tests/test_tutorial/test_options/test_completion/test_tutorial007.py ...                                                                                             [ 51%]
tests/test_tutorial/test_options/test_completion/test_tutorial008.py ...                                                                                             [ 52%]
tests/test_tutorial/test_options/test_completion/test_tutorial009.py ...                                                                                             [ 53%]
tests/test_tutorial/test_options/test_help/test_tutorial001.py .....                                                                                                 [ 54%]
tests/test_tutorial/test_options/test_help/test_tutorial002.py ...                                                                                                   [ 54%]
tests/test_tutorial/test_options/test_name/test_tutorial001.py ...                                                                                                   [ 55%]
tests/test_tutorial/test_options/test_name/test_tutorial002.py ....                                                                                                  [ 56%]
tests/test_tutorial/test_options/test_name/test_tutorial003.py ...                                                                                                   [ 56%]
tests/test_tutorial/test_options/test_name/test_tutorial004.py ....                                                                                                  [ 57%]
tests/test_tutorial/test_options/test_name/test_tutorial005.py ......                                                                                                [ 58%]
tests/test_tutorial/test_options/test_prompt/test_tutorial001.py ....                                                                                                [ 59%]
tests/test_tutorial/test_options/test_prompt/test_tutorial002.py ....                                                                                                [ 60%]
tests/test_tutorial/test_options/test_prompt/test_tutorial003.py .....                                                                                               [ 61%]
tests/test_tutorial/test_options/test_required/test_tutorial002.py ....                                                                                              [ 61%]
tests/test_tutorial/test_options/test_version/test_tutorial003.py .....                                                                                              [ 62%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py .....                                                                                         [ 63%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py ......                                                                                        [ 65%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py ....                                                                                          [ 65%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py .....                                                                                         [ 66%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py ....                                                                                      [ 67%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py ...                                                                                       [ 68%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py ....                                                                                          [ 69%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py ...                                                                                           [ 69%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py ..                                                                                            [ 70%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py ..                                                                                            [ 70%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py ..                                                                                            [ 70%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py ..                                                                                            [ 71%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py ..                                                                                            [ 71%]
tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py ....                                                                                         [ 72%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py .......                                                                                     [ 73%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py ...                                                                                         [ 74%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py .......                                                                                     [ 75%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py .....                                                                                         [ 76%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py ....                                                                                          [ 77%]
tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py ...                                                                                           [ 78%]
tests/test_tutorial/test_prompt/test_tutorial001.py ..                                                                                                               [ 78%]
tests/test_tutorial/test_prompt/test_tutorial002.py ...                                                                                                              [ 79%]
tests/test_tutorial/test_prompt/test_tutorial003.py ...                                                                                                              [ 79%]
tests/test_tutorial/test_subcommands/test_tutorial001.py .........                                                                                                   [ 81%]
tests/test_tutorial/test_subcommands/test_tutorial002.py .........                                                                                                   [ 83%]
tests/test_tutorial/test_subcommands/test_tutorial003.py ................                                                                                            [ 86%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py ..                                                                                   [ 86%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py ..                                                                                   [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py ...                                                                                  [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py ...                                                                                  [ 88%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py ....                                                                                         [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py ....                                                                                         [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py ....                                                                                         [ 90%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py ....                                                                                         [ 91%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py ....                                                                                         [ 92%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py ....                                                                                         [ 93%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py ....                                                                                         [ 93%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py ....                                                                                         [ 94%]
tests/test_tutorial/test_terminating/test_tutorial001.py ...                                                                                                         [ 95%]
tests/test_tutorial/test_terminating/test_tutorial002.py ...                                                                                                         [ 95%]
tests/test_tutorial/test_terminating/test_tutorial003.py ...                                                                                                         [ 96%]
tests/test_tutorial/test_testing/test_app01.py ...                                                                                                                   [ 97%]
tests/test_tutorial/test_testing/test_app02.py ...                                                                                                                   [ 97%]
tests/test_tutorial/test_testing/test_app03.py ...                                                                                                                   [ 98%]
tests/test_tutorial/test_using_click/test_tutorial003.py ....                                                                                                        [ 99%]
tests/test_tutorial/test_using_click/test_tutorial004.py .....                                                                                                       [100%]

================================================================================= FAILURES =================================================================================
___________________________________________________________________________ test_traceback_rich ____________________________________________________________________________

    def test_traceback_rich():
        file_path = Path(__file__).parent / "assets/type_error_rich.py"
        result = subprocess.run(
            ["coverage", "run", str(file_path)],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
        )
        assert "return get_command(self)(*args, **kwargs)" not in result.stderr

        assert "typer.run(main)" in result.stderr
        assert "print(name + 3)" in result.stderr

        # TODO: when deprecating Python 3.6, remove second option
        assert (
            'TypeError: can only concatenate str (not "int") to str' in result.stderr
            or "TypeError: must be str, not int" in result.stderr
        )
>       assert "name = 'morty'" in result.stderr
E       assert "name = 'morty'" in 'Traceback (most recent call last):\n\n  File "/home/tkloczko/rpmbuild/BUILD/typer-0.5.0/tests/assets/type_error_rich....ype_error_rich.py", line 5, in main\n    print(name + 3)\n\nTypeError: can only concatenate str (not "int") to str\n\n'
E        +  where 'Traceback (most recent call last):\n\n  File "/home/tkloczko/rpmbuild/BUILD/typer-0.5.0/tests/assets/type_error_rich....ype_error_rich.py", line 5, in main\n    print(name + 3)\n\nTypeError: can only concatenate str (not "int") to str\n\n' = CompletedProcess(args=['coverage', 'run', '/home/tkloczko/rpmbuild/BUILD/typer-0.5.0/tests/assets/type_error_rich.py']...pe_error_rich.py", line 5, in main\n    print(name + 3)\n\nTypeError: can only concatenate str (not "int") to str\n\n').stderr

tests/test_tracebacks.py:23: AssertionError
___________________________________________________________________________ test_show_completion ___________________________________________________________________________

    def test_show_completion():
        result = subprocess.run(
            [
                "bash",
                "-c",
                f"{sys.executable}  -m coverage run {mod.__file__} --show-completion",
            ],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
            env={**os.environ, "SHELL": "/bin/bash", "_TYPER_COMPLETE_TESTING": "True"},
        )
>       assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout
E       AssertionError: assert '_TUTORIAL001.PY_COMPLETE=complete_bash' in ''
E        +  where '' = CompletedProcess(args=['bash', '-c', '/usr/bin/python3  -m coverage run /home/tkloczko/rpmbuild/BUILD/typer-0.5.0/docs_src/first_steps/tutorial001.py --show-completion'], returncode=1, stdout='', stderr='Shell sh not supported.\n').stdout

tests/test_completion/test_completion.py:21: AssertionError
_________________________________________________________________________ test_install_completion __________________________________________________________________________

    def test_install_completion():
        bash_completion_path: Path = Path.home() / ".bashrc"
        text = ""
        if bash_completion_path.is_file():  # pragma: nocover
            text = bash_completion_path.read_text()
        result = subprocess.run(
            [
                "bash",
                "-c",
                f"{sys.executable} -m coverage run {mod.__file__} --install-completion",
            ],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
            env={**os.environ, "SHELL": "/bin/bash", "_TYPER_COMPLETE_TESTING": "True"},
        )
        new_text = bash_completion_path.read_text()
>       bash_completion_path.write_text(text)

tests/test_completion/test_completion.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/pathlib.py:1255: in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.8/pathlib.py:1222: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/tkloczko/.bashrc'), name = '/home/tkloczko/.bashrc', flags = 524865, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'

/usr/lib64/python3.8/pathlib.py:1078: PermissionError
_______________________________________________________________________ test_completion_install_bash _______________________________________________________________________

    def test_completion_install_bash():
        bash_completion_path: Path = Path.home() / ".bashrc"
        text = ""
        if bash_completion_path.is_file():
            text = bash_completion_path.read_text()
        result = subprocess.run(
            ["coverage", "run", mod.__file__, "--install-completion", "bash"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
            env={
                **os.environ,
                "_TYPER_COMPLETE_TESTING": "True",
                "_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION": "True",
            },
        )
        new_text = bash_completion_path.read_text()
>       bash_completion_path.write_text(text)

tests/test_completion/test_completion_install.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/pathlib.py:1255: in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.8/pathlib.py:1222: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/tkloczko/.bashrc'), name = '/home/tkloczko/.bashrc', flags = 524865, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'

/usr/lib64/python3.8/pathlib.py:1078: PermissionError
============================================================================= warnings summary =============================================================================
tests/test_tutorial/test_options/test_completion/test_tutorial002.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial003.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial004.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial007.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial008.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial009.py::test_1
  /home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.5.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/typer/core.py:270: DeprecationWarning: 'autocompletion' is renamed to 'shell_complete'. The old name is deprecated and will be removed in Click 8.1. See the docs about 'Parameter' for information about new behavior.
    _typer_param_setup_autocompletion_compat(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_tracebacks.py::test_traceback_rich - assert "name = 'morty'" in 'Traceback (most recent call last):\n\n  File "/home/tkloczko/rpmbuild/BUILD/typer-0.5....
FAILED tests/test_completion/test_completion.py::test_show_completion - AssertionError: assert '_TUTORIAL001.PY_COMPLETE=complete_bash' in ''
FAILED tests/test_completion/test_completion.py::test_install_completion - PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'
FAILED tests/test_completion/test_completion_install.py::test_completion_install_bash - PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'
================================================================ 4 failed, 503 passed, 6 warnings in 35.40s ================================================================

Wanted Solution

pytest shopuld be working and test suite should not be fidling in user ~/,bashrc

Wanted Code

Not applicable

Alternatives

No response

Operating System

Linux

Operating System Details

No response

Typer Version

0.5.0

Python Version

3.8.13

Additional Context

Not applicable

@kloczek kloczek added the feature New feature, enhancement or request label Jul 6, 2022
@musicinmybrain
Copy link
Contributor

@kloczek, I don’t want to hijack this upstream issue, but I want to make sure you know that I’ve been maintaining a python-typer package in Fedora Linux. I would be happy if that fact can help with whatever you’re trying to do. I also welcome co-maintainers.

@kloczek
Copy link
Author

kloczek commented Jul 7, 2022

Feel free to add my Fedora account kloczek to list co-maintainers.

@kloczek
Copy link
Author

kloczek commented Jul 13, 2022

Just tested and looks like this version is failing in yet another new unit

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.6.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.6.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --deselect tests/test_tracebacks.py::test_traceback_rich --deselect tests/test_completion/test_completion.py::test_show_completion --deselect tests/test_completion/test_completion.py::test_install_completion --deselect tests/test_completion/test_completion_install.py::test_completion_install_bash
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/typer-0.6.1
plugins: cov-3.0.0
collected 567 items / 3 deselected / 564 selected

docs_src/testing/app01/test_main.py .                                                                                                                                [  0%]
docs_src/testing/app02/test_main.py .                                                                                                                                [  0%]
docs_src/testing/app03/test_main.py .                                                                                                                                [  0%]
tests/test_exit_errors.py ...                                                                                                                                        [  1%]
tests/test_others.py ...........                                                                                                                                     [  3%]
tests/test_prog_name.py .                                                                                                                                            [  3%]
tests/test_rich_utils.py .                                                                                                                                           [  3%]
tests/test_tracebacks.py ...                                                                                                                                         [  3%]
tests/test_type_conversion.py ..........                                                                                                                             [  5%]
tests/test_compat/test_option_get_help.py ....                                                                                                                       [  6%]
tests/test_completion/test_completion.py ........                                                                                                                    [  7%]
tests/test_completion/test_completion_complete.py ..........                                                                                                         [  9%]
tests/test_completion/test_completion_complete_no_help.py ....                                                                                                       [ 10%]
tests/test_completion/test_completion_install.py ....                                                                                                                [ 10%]
tests/test_completion/test_completion_show.py ......                                                                                                                 [ 12%]
tests/test_tutorial/test_arguments/test_default/test_tutorial001.py ....                                                                                             [ 12%]
tests/test_tutorial/test_arguments/test_default/test_tutorial002.py ....                                                                                             [ 13%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial001.py ......                                                                                            [ 14%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial002.py .....                                                                                             [ 15%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial003.py .....                                                                                             [ 16%]
tests/test_tutorial/test_arguments/test_help/test_tutorial001.py ....                                                                                                [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial002.py ...                                                                                                 [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial003.py ...                                                                                                 [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial004.py ...                                                                                                 [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial005.py ...                                                                                                 [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial006.py ...                                                                                                 [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial007.py ...                                                                                                 [ 20%]
tests/test_tutorial/test_arguments/test_help/test_tutorial008.py ....                                                                                                [ 20%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial001.py .....                                                                                           [ 21%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial002.py ....                                                                                            [ 22%]
tests/test_tutorial/test_commands/test_arguments/test_tutorial001.py .....                                                                                           [ 23%]
tests/test_tutorial/test_commands/test_callback/test_tutorial001.py ........                                                                                         [ 24%]
tests/test_tutorial/test_commands/test_callback/test_tutorial002.py ..                                                                                               [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial003.py ...                                                                                              [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial004.py ...                                                                                              [ 26%]
tests/test_tutorial/test_commands/test_context/test_tutorial001.py ...                                                                                               [ 26%]
tests/test_tutorial/test_commands/test_context/test_tutorial002.py ....                                                                                              [ 27%]
tests/test_tutorial/test_commands/test_context/test_tutorial003.py ....                                                                                              [ 28%]
tests/test_tutorial/test_commands/test_context/test_tutorial004.py ..                                                                                                [ 28%]
tests/test_tutorial/test_commands/test_help/test_tutorial001.py ............                                                                                         [ 30%]
tests/test_tutorial/test_commands/test_help/test_tutorial002.py ......                                                                                               [ 31%]
tests/test_tutorial/test_commands/test_help/test_tutorial003.py ....                                                                                                 [ 32%]
tests/test_tutorial/test_commands/test_help/test_tutorial004.py ......                                                                                               [ 33%]
tests/test_tutorial/test_commands/test_help/test_tutorial005.py ......                                                                                               [ 34%]
tests/test_tutorial/test_commands/test_help/test_tutorial006.py ...                                                                                                  [ 35%]
tests/test_tutorial/test_commands/test_help/test_tutorial007.py ....                                                                                                 [ 35%]
tests/test_tutorial/test_commands/test_help/test_tutorial008.py ...                                                                                                  [ 36%]
tests/test_tutorial/test_commands/test_index/test_tutorial001.py ...                                                                                                 [ 36%]
tests/test_tutorial/test_commands/test_index/test_tutorial002.py ....                                                                                                [ 37%]
tests/test_tutorial/test_commands/test_name/test_tutorial001.py ....                                                                                                 [ 38%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial001.py ...                                                                                       [ 38%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial002.py ...                                                                                       [ 39%]
tests/test_tutorial/test_commands/test_options/test_tutorial001.py .........                                                                                         [ 40%]
tests/test_tutorial/test_exceptions/test_tutorial001.py ...                                                                                                          [ 41%]
tests/test_tutorial/test_exceptions/test_tutorial002.py ...                                                                                                          [ 42%]
tests/test_tutorial/test_exceptions/test_tutorial003.py ..                                                                                                           [ 42%]
tests/test_tutorial/test_exceptions/test_tutorial004.py ..                                                                                                           [ 42%]
tests/test_tutorial/test_first_steps/test_tutorial001.py ..                                                                                                          [ 43%]
tests/test_tutorial/test_first_steps/test_tutorial002.py ...                                                                                                         [ 43%]
tests/test_tutorial/test_first_steps/test_tutorial003.py ...                                                                                                         [ 44%]
tests/test_tutorial/test_first_steps/test_tutorial004.py ......                                                                                                      [ 45%]
tests/test_tutorial/test_first_steps/test_tutorial005.py ......                                                                                                      [ 46%]
tests/test_tutorial/test_first_steps/test_tutorial006.py ......                                                                                                      [ 47%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial001.py ..                                                                  [ 47%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial002.py .....                                                               [ 48%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial001.py ....                                                                              [ 49%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial002.py ....                                                                              [ 50%]
tests/test_tutorial/test_multiple_values/test_options_with_multiple_values/test_tutorial001.py .....                                                                 [ 50%]
tests/test_tutorial/test_options/test_callback/test_tutorial001.py ...                                                                                               [ 51%]
tests/test_tutorial/test_options/test_callback/test_tutorial003.py ....                                                                                              [ 52%]
tests/test_tutorial/test_options/test_callback/test_tutorial004.py ....                                                                                              [ 52%]
tests/test_tutorial/test_options/test_completion/test_tutorial002.py ...                                                                                             [ 53%]
tests/test_tutorial/test_options/test_completion/test_tutorial003.py ...                                                                                             [ 53%]
tests/test_tutorial/test_options/test_completion/test_tutorial004.py ...                                                                                             [ 54%]
tests/test_tutorial/test_options/test_completion/test_tutorial007.py ...                                                                                             [ 54%]
tests/test_tutorial/test_options/test_completion/test_tutorial008.py ...                                                                                             [ 55%]
tests/test_tutorial/test_options/test_completion/test_tutorial009.py ...                                                                                             [ 56%]
tests/test_tutorial/test_options/test_help/test_tutorial001.py .....                                                                                                 [ 56%]
tests/test_tutorial/test_options/test_help/test_tutorial002.py ....                                                                                                  [ 57%]
tests/test_tutorial/test_options/test_help/test_tutorial003.py ...                                                                                                   [ 58%]
tests/test_tutorial/test_options/test_name/test_tutorial001.py ...                                                                                                   [ 58%]
tests/test_tutorial/test_options/test_name/test_tutorial002.py ....                                                                                                  [ 59%]
tests/test_tutorial/test_options/test_name/test_tutorial003.py ...                                                                                                   [ 59%]
tests/test_tutorial/test_options/test_name/test_tutorial004.py ....                                                                                                  [ 60%]
tests/test_tutorial/test_options/test_name/test_tutorial005.py ......                                                                                                [ 61%]
tests/test_tutorial/test_options/test_prompt/test_tutorial001.py ....                                                                                                [ 62%]
tests/test_tutorial/test_options/test_prompt/test_tutorial002.py ....                                                                                                [ 63%]
tests/test_tutorial/test_options/test_prompt/test_tutorial003.py .....                                                                                               [ 64%]
tests/test_tutorial/test_options/test_required/test_tutorial002.py .....                                                                                             [ 64%]
tests/test_tutorial/test_options/test_version/test_tutorial003.py .....                                                                                              [ 65%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py .....                                                                                         [ 66%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py .......                                                                                       [ 67%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py ....                                                                                          [ 68%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py .....                                                                                         [ 69%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py ....                                                                                      [ 70%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py ...                                                                                       [ 70%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py ....                                                                                          [ 71%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py ...                                                                                           [ 71%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py ..                                                                                            [ 72%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py ..                                                                                            [ 72%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py ..                                                                                            [ 73%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py ..                                                                                            [ 73%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py ..                                                                                            [ 73%]
tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py ....                                                                                         [ 74%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py ........                                                                                    [ 75%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py ...                                                                                         [ 76%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py .......                                                                                     [ 77%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py .....                                                                                         [ 78%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py F...                                                                                          [ 79%]
tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py ...                                                                                           [ 79%]
tests/test_tutorial/test_prompt/test_tutorial001.py ..                                                                                                               [ 80%]
tests/test_tutorial/test_prompt/test_tutorial002.py ...                                                                                                              [ 80%]
tests/test_tutorial/test_prompt/test_tutorial003.py ...                                                                                                              [ 81%]
tests/test_tutorial/test_subcommands/test_tutorial001.py .........                                                                                                   [ 82%]
tests/test_tutorial/test_subcommands/test_tutorial002.py .........                                                                                                   [ 84%]
tests/test_tutorial/test_subcommands/test_tutorial003.py ................                                                                                            [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py ..                                                                                   [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py ..                                                                                   [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py ...                                                                                  [ 88%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py ...                                                                                  [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py ....                                                                                         [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py ....                                                                                         [ 90%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py ....                                                                                         [ 91%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py ....                                                                                         [ 91%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py ....                                                                                         [ 92%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py ....                                                                                         [ 93%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py ....                                                                                         [ 93%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py ....                                                                                         [ 94%]
tests/test_tutorial/test_terminating/test_tutorial001.py ....                                                                                                        [ 95%]
tests/test_tutorial/test_terminating/test_tutorial002.py ...                                                                                                         [ 95%]
tests/test_tutorial/test_terminating/test_tutorial003.py .....                                                                                                       [ 96%]
tests/test_tutorial/test_testing/test_app01.py ...                                                                                                                   [ 97%]
tests/test_tutorial/test_testing/test_app02.py ...                                                                                                                   [ 97%]
tests/test_tutorial/test_testing/test_app03.py ...                                                                                                                   [ 98%]
tests/test_tutorial/test_using_click/test_tutorial003.py ....                                                                                                        [ 99%]
tests/test_tutorial/test_using_click/test_tutorial004.py .....                                                                                                       [100%]

================================================================================= FAILURES =================================================================================
_____________________________________________________________________________ test_not_exists ______________________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-317/test_not_exists1')

    def test_not_exists(tmpdir):
        config_file = Path(tmpdir) / "config.txt"
        if config_file.exists():  # pragma no cover
            config_file.unlink()
        result = runner.invoke(app, ["--config", f"{config_file}"])
        assert result.exit_code != 0
        assert "Invalid value for '--config': File" in result.output
>       assert "does not exist" in result.output
E       assert 'does not exist' in "Usage: main [OPTIONS]\nTry 'main --help' for help.\n╭─ Error ────────────────────────────────────────────────────────...                                 │\n╰──────────────────────────────────────────────────────────────────────────────╯\n"
E        +  where "Usage: main [OPTIONS]\nTry 'main --help' for help.\n╭─ Error ────────────────────────────────────────────────────────...                                 │\n╰──────────────────────────────────────────────────────────────────────────────╯\n" = <Result SystemExit(2)>.output

tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py:22: AssertionError
============================================================================= warnings summary =============================================================================
tests/test_tutorial/test_options/test_completion/test_tutorial002.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial003.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial004.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial007.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial008.py::test_1
tests/test_tutorial/test_options/test_completion/test_tutorial009.py::test_1
  /home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.6.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/typer/core.py:491: DeprecationWarning: 'autocompletion' is renamed to 'shell_complete'. The old name is deprecated and will be removed in Click 8.1. See the docs about 'Parameter' for information about new behavior.
    _typer_param_setup_autocompletion_compat(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py::test_not_exists - assert 'does not exist' in "Usage: main [OPTIONS]\nTry 'main --help' for...
==================================================== 1 failed, 563 passed, 3 deselected, 6 warnings in 70.30s (0:01:10) ====================================================

@musicinmybrain
Copy link
Contributor

Just tested and looks like this version is failing in yet another new unit

I’m also seeing the same test_not_exists failure while working on updating the package for Fedora Rawhide to 0.6.1. It wasn’t present in 0.5.0.

I suspect that the expected output comes from a dependency, and the version available in the distribution is different from what would be installed with pip or flit into a virtualenv. Since I’m not loosening any version bounds in the spec file (at least not for runtime dependencies), it’s probably that one of the dependencies in Fedora is not fully up to date with its upstream.

@sergiosacj
Copy link

I saw the same failure when updating typer to Debian, the problem is related to Rich. This library respects some standard environment variables such as COLUMNS, but this variable can break tests that perform string comparisons if the terminal width is small. The Typer CI passes by running tests with a large terminal width as it is possible to override the terminal width by setting the TERMINAL_WIDTH variable.

@tiangolo
Copy link
Member

Thanks for the help here @sergiosacj ! 👏 🙇

If that solves the original problem, then you can close this issue @kloczek ✔️

@musicinmybrain
Copy link
Contributor

As @sergiosacj suggested,

export TERMINAL_WIDTH=3000

fixes the problem for me in the Fedora Linux package for version 0.6.1.

Updating to 0.7.0 also makes the problem go away, whether I set TERMINAL_WIDTH or not.

@kloczek
Copy link
Author

kloczek commented Nov 12, 2022

On building package build procedure has no access to pty so terminal width is unknown.

@github-actions github-actions bot removed the answered label Nov 12, 2022
@tiangolo
Copy link
Member

Have you tried with the latest source? There was some similar thing with OpenSUSE and they contributed a PR with what they needed.

You might also create a PR with what you need and why that is needed.

For my use case as maintainer, the tests and Pytest are working correctly in CI. But if there's something you would need different and a reason why the current default setup doesn't work for you, maybe you could suggest a PR.

@kloczek
Copy link
Author

kloczek commented Nov 12, 2022

I cannot locate exact commit which could be applied on top of last tagged state to test that.
Can you point on such commit?

@github-actions github-actions bot removed the answered label Nov 12, 2022
@tiangolo
Copy link
Member

What do you mean? It's just the master branch. The last commit in master is this one: e14cf38

@kloczek
Copy link
Author

kloczek commented Nov 14, 2022

I've testes pytest with TERMINAL_WIDTH=3000 _TYPER_FORCE_DISABLE_TERMINAL=1 env variables and it improved results however still have three units failing

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.7.0-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.7.0-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.15, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/typer-0.7.0, configfile: pyproject.toml
plugins: cov-3.0.0
collected 567 items

docs_src/testing/app01/test_main.py .                                                                                                                                [  0%]
docs_src/testing/app02/test_main.py .                                                                                                                                [  0%]
docs_src/testing/app03/test_main.py .                                                                                                                                [  0%]
tests/test_exit_errors.py ...                                                                                                                                        [  1%]
tests/test_others.py ...........                                                                                                                                     [  2%]
tests/test_prog_name.py .                                                                                                                                            [  3%]
tests/test_rich_utils.py .                                                                                                                                           [  3%]
tests/test_tracebacks.py ...                                                                                                                                         [  3%]
tests/test_type_conversion.py ..........                                                                                                                             [  5%]
tests/test_compat/test_option_get_help.py ....                                                                                                                       [  6%]
tests/test_completion/test_completion.py FF........                                                                                                                  [  8%]
tests/test_completion/test_completion_complete.py ..........                                                                                                         [  9%]
tests/test_completion/test_completion_complete_no_help.py ....                                                                                                       [ 10%]
tests/test_completion/test_completion_install.py .F...                                                                                                               [ 11%]
tests/test_completion/test_completion_show.py ......                                                                                                                 [ 12%]
tests/test_tutorial/test_arguments/test_default/test_tutorial001.py ....                                                                                             [ 13%]
tests/test_tutorial/test_arguments/test_default/test_tutorial002.py ....                                                                                             [ 13%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial001.py ......                                                                                            [ 14%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial002.py .....                                                                                             [ 15%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial003.py .....                                                                                             [ 16%]
tests/test_tutorial/test_arguments/test_help/test_tutorial001.py ....                                                                                                [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial002.py ...                                                                                                 [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial003.py ...                                                                                                 [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial004.py ...                                                                                                 [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial005.py ...                                                                                                 [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial006.py ...                                                                                                 [ 20%]
tests/test_tutorial/test_arguments/test_help/test_tutorial007.py ...                                                                                                 [ 20%]
tests/test_tutorial/test_arguments/test_help/test_tutorial008.py ....                                                                                                [ 21%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial001.py .....                                                                                           [ 22%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial002.py ....                                                                                            [ 22%]
tests/test_tutorial/test_commands/test_arguments/test_tutorial001.py .....                                                                                           [ 23%]
tests/test_tutorial/test_commands/test_callback/test_tutorial001.py ........                                                                                         [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial002.py ..                                                                                               [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial003.py ...                                                                                              [ 26%]
tests/test_tutorial/test_commands/test_callback/test_tutorial004.py ...                                                                                              [ 26%]
tests/test_tutorial/test_commands/test_context/test_tutorial001.py ...                                                                                               [ 27%]
tests/test_tutorial/test_commands/test_context/test_tutorial002.py ....                                                                                              [ 27%]
tests/test_tutorial/test_commands/test_context/test_tutorial003.py ....                                                                                              [ 28%]
tests/test_tutorial/test_commands/test_context/test_tutorial004.py ..                                                                                                [ 28%]
tests/test_tutorial/test_commands/test_help/test_tutorial001.py ............                                                                                         [ 31%]
tests/test_tutorial/test_commands/test_help/test_tutorial002.py ......                                                                                               [ 32%]
tests/test_tutorial/test_commands/test_help/test_tutorial003.py ....                                                                                                 [ 32%]
tests/test_tutorial/test_commands/test_help/test_tutorial004.py ......                                                                                               [ 33%]
tests/test_tutorial/test_commands/test_help/test_tutorial005.py ......                                                                                               [ 34%]
tests/test_tutorial/test_commands/test_help/test_tutorial006.py ...                                                                                                  [ 35%]
tests/test_tutorial/test_commands/test_help/test_tutorial007.py ....                                                                                                 [ 36%]
tests/test_tutorial/test_commands/test_help/test_tutorial008.py ...                                                                                                  [ 36%]
tests/test_tutorial/test_commands/test_index/test_tutorial001.py ...                                                                                                 [ 37%]
tests/test_tutorial/test_commands/test_index/test_tutorial002.py ....                                                                                                [ 37%]
tests/test_tutorial/test_commands/test_name/test_tutorial001.py ....                                                                                                 [ 38%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial001.py ...                                                                                       [ 39%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial002.py ...                                                                                       [ 39%]
tests/test_tutorial/test_commands/test_options/test_tutorial001.py .........                                                                                         [ 41%]
tests/test_tutorial/test_exceptions/test_tutorial001.py ...                                                                                                          [ 41%]
tests/test_tutorial/test_exceptions/test_tutorial002.py ...                                                                                                          [ 42%]
tests/test_tutorial/test_exceptions/test_tutorial003.py ..                                                                                                           [ 42%]
tests/test_tutorial/test_exceptions/test_tutorial004.py ..                                                                                                           [ 43%]
tests/test_tutorial/test_first_steps/test_tutorial001.py ..                                                                                                          [ 43%]
tests/test_tutorial/test_first_steps/test_tutorial002.py ...                                                                                                         [ 43%]
tests/test_tutorial/test_first_steps/test_tutorial003.py ...                                                                                                         [ 44%]
tests/test_tutorial/test_first_steps/test_tutorial004.py ......                                                                                                      [ 45%]
tests/test_tutorial/test_first_steps/test_tutorial005.py ......                                                                                                      [ 46%]
tests/test_tutorial/test_first_steps/test_tutorial006.py ......                                                                                                      [ 47%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial001.py ..                                                                  [ 47%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial002.py .....                                                               [ 48%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial001.py ....                                                                              [ 49%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial002.py ....                                                                              [ 50%]
tests/test_tutorial/test_multiple_values/test_options_with_multiple_values/test_tutorial001.py .....                                                                 [ 51%]
tests/test_tutorial/test_options/test_callback/test_tutorial001.py ...                                                                                               [ 51%]
tests/test_tutorial/test_options/test_callback/test_tutorial003.py ....                                                                                              [ 52%]
tests/test_tutorial/test_options/test_callback/test_tutorial004.py ....                                                                                              [ 53%]
tests/test_tutorial/test_options/test_help/test_tutorial001.py .....                                                                                                 [ 53%]
tests/test_tutorial/test_options/test_help/test_tutorial002.py ....                                                                                                  [ 54%]
tests/test_tutorial/test_options/test_help/test_tutorial003.py ...                                                                                                   [ 55%]
tests/test_tutorial/test_options/test_name/test_tutorial001.py ...                                                                                                   [ 55%]
tests/test_tutorial/test_options/test_name/test_tutorial002.py ....                                                                                                  [ 56%]
tests/test_tutorial/test_options/test_name/test_tutorial003.py ...                                                                                                   [ 56%]
tests/test_tutorial/test_options/test_name/test_tutorial004.py ....                                                                                                  [ 57%]
tests/test_tutorial/test_options/test_name/test_tutorial005.py ......                                                                                                [ 58%]
tests/test_tutorial/test_options/test_prompt/test_tutorial001.py ....                                                                                                [ 59%]
tests/test_tutorial/test_options/test_prompt/test_tutorial002.py ....                                                                                                [ 60%]
tests/test_tutorial/test_options/test_prompt/test_tutorial003.py .....                                                                                               [ 61%]
tests/test_tutorial/test_options/test_required/test_tutorial002.py .....                                                                                             [ 61%]
tests/test_tutorial/test_options/test_version/test_tutorial003.py .....                                                                                              [ 62%]
tests/test_tutorial/test_options_autocompletion/test_tutorial002.py ...                                                                                              [ 63%]
tests/test_tutorial/test_options_autocompletion/test_tutorial003.py ...                                                                                              [ 63%]
tests/test_tutorial/test_options_autocompletion/test_tutorial004.py ...                                                                                              [ 64%]
tests/test_tutorial/test_options_autocompletion/test_tutorial007.py ...                                                                                              [ 64%]
tests/test_tutorial/test_options_autocompletion/test_tutorial008.py ...                                                                                              [ 65%]
tests/test_tutorial/test_options_autocompletion/test_tutorial009.py ...                                                                                              [ 65%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py .....                                                                                         [ 66%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py .......                                                                                       [ 68%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py ....                                                                                          [ 68%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py .....                                                                                         [ 69%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py ....                                                                                      [ 70%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py ...                                                                                       [ 70%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py ....                                                                                          [ 71%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py ...                                                                                           [ 72%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py ..                                                                                            [ 72%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py ..                                                                                            [ 72%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py ..                                                                                            [ 73%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py ..                                                                                            [ 73%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py ..                                                                                            [ 73%]
tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py ....                                                                                         [ 74%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py ........                                                                                    [ 76%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py ...                                                                                         [ 76%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py .......                                                                                     [ 77%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py .....                                                                                         [ 78%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py ....                                                                                          [ 79%]
tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py ...                                                                                           [ 79%]
tests/test_tutorial/test_prompt/test_tutorial001.py ..                                                                                                               [ 80%]
tests/test_tutorial/test_prompt/test_tutorial002.py ...                                                                                                              [ 80%]
tests/test_tutorial/test_prompt/test_tutorial003.py ...                                                                                                              [ 81%]
tests/test_tutorial/test_subcommands/test_tutorial001.py .........                                                                                                   [ 82%]
tests/test_tutorial/test_subcommands/test_tutorial002.py .........                                                                                                   [ 84%]
tests/test_tutorial/test_subcommands/test_tutorial003.py ................                                                                                            [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py ..                                                                                   [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py ..                                                                                   [ 88%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py ...                                                                                  [ 88%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py ...                                                                                  [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py ....                                                                                         [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py ....                                                                                         [ 90%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py ....                                                                                         [ 91%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py ....                                                                                         [ 91%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py ....                                                                                         [ 92%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py ....                                                                                         [ 93%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py ....                                                                                         [ 94%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py ....                                                                                         [ 94%]
tests/test_tutorial/test_terminating/test_tutorial001.py ....                                                                                                        [ 95%]
tests/test_tutorial/test_terminating/test_tutorial002.py ...                                                                                                         [ 95%]
tests/test_tutorial/test_terminating/test_tutorial003.py .....                                                                                                       [ 96%]
tests/test_tutorial/test_testing/test_app01.py ...                                                                                                                   [ 97%]
tests/test_tutorial/test_testing/test_app02.py ...                                                                                                                   [ 97%]
tests/test_tutorial/test_testing/test_app03.py ...                                                                                                                   [ 98%]
tests/test_tutorial/test_using_click/test_tutorial003.py ....                                                                                                        [ 99%]
tests/test_tutorial/test_using_click/test_tutorial004.py .....                                                                                                       [100%]

================================================================================= FAILURES =================================================================================
___________________________________________________________________________ test_show_completion ___________________________________________________________________________

    def test_show_completion():
        result = subprocess.run(
            [
                "bash",
                "-c",
                f"{sys.executable}  -m coverage run {mod.__file__} --show-completion",
            ],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
            env={**os.environ, "SHELL": "/bin/bash", "_TYPER_COMPLETE_TESTING": "True"},
        )
>       assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout
E       AssertionError: assert '_TUTORIAL001.PY_COMPLETE=complete_bash' in ''
E        +  where '' = CompletedProcess(args=['bash', '-c', '/usr/bin/python3  -m coverage run /home/tkloczko/rpmbuild/BUILD/typer-0.7.0/docs_src/commands/index/tutorial001.py --show-completion'], returncode=1, stdout='', stderr='Shell sh not supported.\n').stdout

tests/test_completion/test_completion.py:21: AssertionError
_________________________________________________________________________ test_install_completion __________________________________________________________________________

    def test_install_completion():
        bash_completion_path: Path = Path.home() / ".bashrc"
        text = ""
        if bash_completion_path.is_file():  # pragma: nocover
            text = bash_completion_path.read_text()
        result = subprocess.run(
            [
                "bash",
                "-c",
                f"{sys.executable} -m coverage run {mod.__file__} --install-completion",
            ],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
            env={**os.environ, "SHELL": "/bin/bash", "_TYPER_COMPLETE_TESTING": "True"},
        )
        new_text = bash_completion_path.read_text()
>       bash_completion_path.write_text(text)

tests/test_completion/test_completion.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/pathlib.py:1255: in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.8/pathlib.py:1222: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/tkloczko/.bashrc'), name = '/home/tkloczko/.bashrc', flags = 524865, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'

/usr/lib64/python3.8/pathlib.py:1078: PermissionError
_______________________________________________________________________ test_completion_install_bash _______________________________________________________________________

    def test_completion_install_bash():
        bash_completion_path: Path = Path.home() / ".bashrc"
        text = ""
        if bash_completion_path.is_file():
            text = bash_completion_path.read_text()
        result = subprocess.run(
            ["coverage", "run", mod.__file__, "--install-completion", "bash"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            encoding="utf-8",
            env={
                **os.environ,
                "_TYPER_COMPLETE_TESTING": "True",
                "_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION": "True",
            },
        )
        new_text = bash_completion_path.read_text()
>       bash_completion_path.write_text(text)

tests/test_completion/test_completion_install.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/pathlib.py:1255: in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.8/pathlib.py:1222: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/tkloczko/.bashrc'), name = '/home/tkloczko/.bashrc', flags = 524865, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'

/usr/lib64/python3.8/pathlib.py:1078: PermissionError
========================================================================= short test summary info ==========================================================================
FAILED tests/test_completion/test_completion.py::test_show_completion - AssertionError: assert '_TUTORIAL001.PY_COMPLETE=complete_bash' in ''
FAILED tests/test_completion/test_completion.py::test_install_completion - PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'
FAILED tests/test_completion/test_completion_install.py::test_completion_install_bash - PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'
================================================================= 3 failed, 564 passed in 68.94s (0:01:08) =================================================================

Why test units are trying fiddle in files outside build env? 🤔

@kloczek
Copy link
Author

kloczek commented Mar 18, 2024

Gentle ping .. any update? 🤔

@kloczek
Copy link
Author

kloczek commented Mar 27, 2024

Just tested 0.11.0 and still I see that test suite tries to write something in ~.bashrc.

Here is pytest output:
+ export TERMINAL_WIDTH=3000 _TYPER_FORCE_DISABLE_TERMINAL=1
+ TERMINAL_WIDTH=3000
+ _TYPER_FORCE_DISABLE_TERMINAL=1
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.11.0-2.fc36.x86_64/usr/lib64/python3.9/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-typer-0.11.0-2.fc36.x86_64/usr/lib/python3.9/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/typer-0.11.0
configfile: pyproject.toml
collected 901 items

docs_src/testing/app01/test_main.py .                                                                                                                                                 [  0%]
docs_src/testing/app02/test_main.py .                                                                                                                                                 [  0%]
docs_src/testing/app02_an/test_main.py .                                                                                                                                              [  0%]
docs_src/testing/app03/test_main.py .                                                                                                                                                 [  0%]
tests/test_ambiguous_params.py ...................                                                                                                                                    [  2%]
tests/test_annotated.py .s..                                                                                                                                                          [  2%]
tests/test_compat/test_option_get_help.py ....                                                                                                                                        [  3%]
tests/test_completion/test_completion.py FF........                                                                                                                                   [  4%]
tests/test_completion/test_completion_complete.py ..........                                                                                                                          [  5%]
tests/test_completion/test_completion_complete_no_help.py ....                                                                                                                        [  6%]
tests/test_completion/test_completion_install.py .F...                                                                                                                                [  6%]
tests/test_completion/test_completion_show.py .......                                                                                                                                 [  7%]
tests/test_exit_errors.py ...                                                                                                                                                         [  7%]
tests/test_others.py ..............                                                                                                                                                   [  9%]
tests/test_prog_name.py .                                                                                                                                                             [  9%]
tests/test_rich_utils.py .                                                                                                                                                            [  9%]
tests/test_tracebacks.py ...                                                                                                                                                          [  9%]
tests/test_tutorial/test_arguments/test_default/test_tutorial001.py ....                                                                                                              [ 10%]
tests/test_tutorial/test_arguments/test_default/test_tutorial001_an.py ....                                                                                                           [ 10%]
tests/test_tutorial/test_arguments/test_default/test_tutorial002.py ....                                                                                                              [ 11%]
tests/test_tutorial/test_arguments/test_default/test_tutorial002_an.py ....                                                                                                           [ 11%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial001.py ......                                                                                                             [ 12%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial001_an.py ......                                                                                                          [ 12%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial002.py .....                                                                                                              [ 13%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial002_an.py .....                                                                                                           [ 14%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial003.py .....                                                                                                              [ 14%]
tests/test_tutorial/test_arguments/test_envvar/test_tutorial003_an.py .....                                                                                                           [ 15%]
tests/test_tutorial/test_arguments/test_help/test_tutorial001.py ....                                                                                                                 [ 15%]
tests/test_tutorial/test_arguments/test_help/test_tutorial001_an.py ....                                                                                                              [ 16%]
tests/test_tutorial/test_arguments/test_help/test_tutorial002.py ...                                                                                                                  [ 16%]
tests/test_tutorial/test_arguments/test_help/test_tutorial002_an.py ...                                                                                                               [ 16%]
tests/test_tutorial/test_arguments/test_help/test_tutorial003.py ...                                                                                                                  [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial003_an.py ...                                                                                                               [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial004.py ...                                                                                                                  [ 17%]
tests/test_tutorial/test_arguments/test_help/test_tutorial004_an.py ...                                                                                                               [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial005.py ...                                                                                                                  [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial005_an.py ...                                                                                                               [ 18%]
tests/test_tutorial/test_arguments/test_help/test_tutorial006.py ...                                                                                                                  [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial006_an.py ...                                                                                                               [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial007.py ...                                                                                                                  [ 19%]
tests/test_tutorial/test_arguments/test_help/test_tutorial007_an.py ...                                                                                                               [ 20%]
tests/test_tutorial/test_arguments/test_help/test_tutorial008.py ....                                                                                                                 [ 20%]
tests/test_tutorial/test_arguments/test_help/test_tutorial008_an.py ....                                                                                                              [ 20%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial001.py .....                                                                                                            [ 21%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial001_an.py .....                                                                                                         [ 22%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial002.py ....                                                                                                             [ 22%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial002_an.py ....                                                                                                          [ 22%]
tests/test_tutorial/test_arguments/test_optional/test_tutorial003.py .....                                                                                                            [ 23%]
tests/test_tutorial/test_commands/test_arguments/test_tutorial001.py .....                                                                                                            [ 24%]
tests/test_tutorial/test_commands/test_callback/test_tutorial001.py ........                                                                                                          [ 24%]
tests/test_tutorial/test_commands/test_callback/test_tutorial002.py ..                                                                                                                [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial003.py ...                                                                                                               [ 25%]
tests/test_tutorial/test_commands/test_callback/test_tutorial004.py ...                                                                                                               [ 25%]
tests/test_tutorial/test_commands/test_context/test_tutorial001.py ...                                                                                                                [ 26%]
tests/test_tutorial/test_commands/test_context/test_tutorial002.py ....                                                                                                               [ 26%]
tests/test_tutorial/test_commands/test_context/test_tutorial003.py ....                                                                                                               [ 27%]
tests/test_tutorial/test_commands/test_context/test_tutorial004.py ..                                                                                                                 [ 27%]
tests/test_tutorial/test_commands/test_help/test_tutorial001.py ............                                                                                                          [ 28%]
tests/test_tutorial/test_commands/test_help/test_tutorial001_an.py ............                                                                                                       [ 29%]
tests/test_tutorial/test_commands/test_help/test_tutorial002.py ......                                                                                                                [ 30%]
tests/test_tutorial/test_commands/test_help/test_tutorial003.py ....                                                                                                                  [ 31%]
tests/test_tutorial/test_commands/test_help/test_tutorial004.py ......                                                                                                                [ 31%]
tests/test_tutorial/test_commands/test_help/test_tutorial004_an.py ......                                                                                                             [ 32%]
tests/test_tutorial/test_commands/test_help/test_tutorial005.py ......                                                                                                                [ 33%]
tests/test_tutorial/test_commands/test_help/test_tutorial005_an.py ......                                                                                                             [ 33%]
tests/test_tutorial/test_commands/test_help/test_tutorial006.py ...                                                                                                                   [ 34%]
tests/test_tutorial/test_commands/test_help/test_tutorial007.py ....                                                                                                                  [ 34%]
tests/test_tutorial/test_commands/test_help/test_tutorial007_an.py ....                                                                                                               [ 34%]
tests/test_tutorial/test_commands/test_help/test_tutorial008.py ...                                                                                                                   [ 35%]
tests/test_tutorial/test_commands/test_index/test_tutorial001.py ...                                                                                                                  [ 35%]
tests/test_tutorial/test_commands/test_index/test_tutorial002.py ....                                                                                                                 [ 36%]
tests/test_tutorial/test_commands/test_index/test_tutorial003.py ....                                                                                                                 [ 36%]
tests/test_tutorial/test_commands/test_name/test_tutorial001.py ....                                                                                                                  [ 36%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial001.py ...                                                                                                        [ 37%]
tests/test_tutorial/test_commands/test_one_or_multiple/test_tutorial002.py ...                                                                                                        [ 37%]
tests/test_tutorial/test_commands/test_options/test_tutorial001.py .........                                                                                                          [ 38%]
tests/test_tutorial/test_commands/test_options/test_tutorial001_an.py .........                                                                                                       [ 39%]
tests/test_tutorial/test_exceptions/test_tutorial001.py ...                                                                                                                           [ 39%]
tests/test_tutorial/test_exceptions/test_tutorial002.py ...                                                                                                                           [ 40%]
tests/test_tutorial/test_exceptions/test_tutorial003.py ..                                                                                                                            [ 40%]
tests/test_tutorial/test_exceptions/test_tutorial004.py ..                                                                                                                            [ 40%]
tests/test_tutorial/test_first_steps/test_tutorial001.py ..                                                                                                                           [ 40%]
tests/test_tutorial/test_first_steps/test_tutorial002.py ...                                                                                                                          [ 41%]
tests/test_tutorial/test_first_steps/test_tutorial003.py ...                                                                                                                          [ 41%]
tests/test_tutorial/test_first_steps/test_tutorial004.py ......                                                                                                                       [ 42%]
tests/test_tutorial/test_first_steps/test_tutorial005.py ......                                                                                                                       [ 42%]
tests/test_tutorial/test_first_steps/test_tutorial006.py ......                                                                                                                       [ 43%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial001.py ..                                                                                   [ 43%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial002.py .....                                                                                [ 44%]
tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial002_an.py .....                                                                             [ 44%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial001.py ....                                                                                               [ 45%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial001_an.py ....                                                                                            [ 45%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial002.py ....                                                                                               [ 46%]
tests/test_tutorial/test_multiple_values/test_multiple_options/test_tutorial002_an.py ....                                                                                            [ 46%]
tests/test_tutorial/test_multiple_values/test_options_with_multiple_values/test_tutorial001.py .....                                                                                  [ 47%]
tests/test_tutorial/test_multiple_values/test_options_with_multiple_values/test_tutorial001_an.py .....                                                                               [ 47%]
tests/test_tutorial/test_options/test_callback/test_tutorial001.py ...                                                                                                                [ 48%]
tests/test_tutorial/test_options/test_callback/test_tutorial001_an.py ...                                                                                                             [ 48%]
tests/test_tutorial/test_options/test_callback/test_tutorial003.py ....                                                                                                               [ 48%]
tests/test_tutorial/test_options/test_callback/test_tutorial003_an.py ....                                                                                                            [ 49%]
tests/test_tutorial/test_options/test_callback/test_tutorial004.py ....                                                                                                               [ 49%]
tests/test_tutorial/test_options/test_callback/test_tutorial004_an.py ....                                                                                                            [ 50%]
tests/test_tutorial/test_options/test_help/test_tutorial001.py .....                                                                                                                  [ 50%]
tests/test_tutorial/test_options/test_help/test_tutorial001_an.py .....                                                                                                               [ 51%]
tests/test_tutorial/test_options/test_help/test_tutorial002.py ....                                                                                                                   [ 51%]
tests/test_tutorial/test_options/test_help/test_tutorial002_an.py ....                                                                                                                [ 52%]
tests/test_tutorial/test_options/test_help/test_tutorial003.py ...                                                                                                                    [ 52%]
tests/test_tutorial/test_options/test_help/test_tutorial003_an.py ...                                                                                                                 [ 52%]
tests/test_tutorial/test_options/test_name/test_tutorial001.py ....                                                                                                                   [ 53%]
tests/test_tutorial/test_options/test_name/test_tutorial001_an.py ....                                                                                                                [ 53%]
tests/test_tutorial/test_options/test_name/test_tutorial002.py ....                                                                                                                   [ 54%]
tests/test_tutorial/test_options/test_name/test_tutorial002_an.py ....                                                                                                                [ 54%]
tests/test_tutorial/test_options/test_name/test_tutorial003.py ...                                                                                                                    [ 55%]
tests/test_tutorial/test_options/test_name/test_tutorial003_an.py ...                                                                                                                 [ 55%]
tests/test_tutorial/test_options/test_name/test_tutorial004.py ....                                                                                                                   [ 55%]
tests/test_tutorial/test_options/test_name/test_tutorial004_an.py ....                                                                                                                [ 56%]
tests/test_tutorial/test_options/test_name/test_tutorial005.py ......                                                                                                                 [ 56%]
tests/test_tutorial/test_options/test_name/test_tutorial005_an.py ......                                                                                                              [ 57%]
tests/test_tutorial/test_options/test_prompt/test_tutorial001.py ....                                                                                                                 [ 58%]
tests/test_tutorial/test_options/test_prompt/test_tutorial001_an.py ....                                                                                                              [ 58%]
tests/test_tutorial/test_options/test_prompt/test_tutorial002.py ....                                                                                                                 [ 58%]
tests/test_tutorial/test_options/test_prompt/test_tutorial002_an.py ....                                                                                                              [ 59%]
tests/test_tutorial/test_options/test_prompt/test_tutorial003.py .....                                                                                                                [ 59%]
tests/test_tutorial/test_options/test_prompt/test_tutorial003_an.py .....                                                                                                             [ 60%]
tests/test_tutorial/test_options/test_required/test_tutorial001.py .....                                                                                                              [ 61%]
tests/test_tutorial/test_options/test_required/test_tutorial001_an.py .....                                                                                                           [ 61%]
tests/test_tutorial/test_options/test_version/test_tutorial003.py .....                                                                                                               [ 62%]
tests/test_tutorial/test_options/test_version/test_tutorial003_an.py .....                                                                                                            [ 62%]
tests/test_tutorial/test_options_autocompletion/test_tutorial002.py ...                                                                                                               [ 63%]
tests/test_tutorial/test_options_autocompletion/test_tutorial002_an.py ...                                                                                                            [ 63%]
tests/test_tutorial/test_options_autocompletion/test_tutorial003.py ...                                                                                                               [ 63%]
tests/test_tutorial/test_options_autocompletion/test_tutorial003_an.py ...                                                                                                            [ 64%]
tests/test_tutorial/test_options_autocompletion/test_tutorial004.py ...                                                                                                               [ 64%]
tests/test_tutorial/test_options_autocompletion/test_tutorial004_an.py ...                                                                                                            [ 64%]
tests/test_tutorial/test_options_autocompletion/test_tutorial007.py ...                                                                                                               [ 65%]
tests/test_tutorial/test_options_autocompletion/test_tutorial007_an.py ...                                                                                                            [ 65%]
tests/test_tutorial/test_options_autocompletion/test_tutorial008.py ...                                                                                                               [ 65%]
tests/test_tutorial/test_options_autocompletion/test_tutorial008_an.py ...                                                                                                            [ 66%]
tests/test_tutorial/test_options_autocompletion/test_tutorial009.py ...                                                                                                               [ 66%]
tests/test_tutorial/test_options_autocompletion/test_tutorial009_an.py ...                                                                                                            [ 66%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py .....                                                                                                          [ 67%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001_an.py .....                                                                                                       [ 67%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py .......                                                                                                        [ 68%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002_an.py .......                                                                                                     [ 69%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py ....                                                                                                           [ 69%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003_an.py ....                                                                                                        [ 70%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py .....                                                                                                          [ 70%]
tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004_an.py .....                                                                                                       [ 71%]
tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py ....                                                                                                   [ 71%]
tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001_an.py ....                                                                                                [ 72%]
tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002.py ....                                                                                                   [ 72%]
tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002_an.py ....                                                                                                [ 73%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py ....                                                                                                       [ 73%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py ...                                                                                                        [ 73%]
tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002_an.py ...                                                                                                     [ 74%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py .....                                                                                                          [ 74%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py ...                                                                                                            [ 75%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002_an.py ...                                                                                                         [ 75%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003.py .....                                                                                                          [ 76%]
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003_an.py .....                                                                                                       [ 76%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py ..                                                                                                             [ 76%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial001_an.py ..                                                                                                          [ 77%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py ..                                                                                                             [ 77%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial002_an.py ..                                                                                                          [ 77%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py ..                                                                                                             [ 77%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial003_an.py ..                                                                                                          [ 77%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py ..                                                                                                             [ 78%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py ..                                                                                                          [ 78%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py ..                                                                                                             [ 78%]
tests/test_tutorial/test_parameter_types/test_file/test_tutorial005_an.py ..                                                                                                          [ 78%]
tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py ....                                                                                                          [ 79%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py ........                                                                                                     [ 80%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial001_an.py ........                                                                                                  [ 81%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py ...                                                                                                          [ 81%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial002_an.py ...                                                                                                       [ 81%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py .......                                                                                                      [ 82%]
tests/test_tutorial/test_parameter_types/test_number/test_tutorial003_an.py .......                                                                                                   [ 83%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py .....                                                                                                          [ 83%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial001_an.py .....                                                                                                       [ 84%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py ....                                                                                                           [ 84%]
tests/test_tutorial/test_parameter_types/test_path/test_tutorial002_an.py ....                                                                                                        [ 85%]
tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py ...                                                                                                            [ 85%]
tests/test_tutorial/test_prompt/test_tutorial001.py ..                                                                                                                                [ 85%]
tests/test_tutorial/test_prompt/test_tutorial002.py ...                                                                                                                               [ 86%]
tests/test_tutorial/test_prompt/test_tutorial003.py ...                                                                                                                               [ 86%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py ..                                                                                                    [ 86%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py ..                                                                                                    [ 86%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py ...                                                                                                   [ 87%]
tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py ...                                                                                                   [ 87%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py ....                                                                                                          [ 88%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py ....                                                                                                          [ 88%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py ....                                                                                                          [ 88%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py ....                                                                                                          [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py ....                                                                                                          [ 89%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py ....                                                                                                          [ 90%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py ....                                                                                                          [ 90%]
tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py ....                                                                                                          [ 91%]
tests/test_tutorial/test_subcommands/test_tutorial001.py .........                                                                                                                    [ 92%]
tests/test_tutorial/test_subcommands/test_tutorial002.py .........                                                                                                                    [ 93%]
tests/test_tutorial/test_subcommands/test_tutorial003.py ................                                                                                                             [ 94%]
tests/test_tutorial/test_terminating/test_tutorial001.py ....                                                                                                                         [ 95%]
tests/test_tutorial/test_terminating/test_tutorial002.py ...                                                                                                                          [ 95%]
tests/test_tutorial/test_terminating/test_tutorial003.py .....                                                                                                                        [ 96%]
tests/test_tutorial/test_testing/test_app01.py ...                                                                                                                                    [ 96%]
tests/test_tutorial/test_testing/test_app02.py ...                                                                                                                                    [ 96%]
tests/test_tutorial/test_testing/test_app02_an.py ...                                                                                                                                 [ 97%]
tests/test_tutorial/test_testing/test_app03.py ...                                                                                                                                    [ 97%]
tests/test_tutorial/test_using_click/test_tutorial003.py .....                                                                                                                        [ 98%]
tests/test_tutorial/test_using_click/test_tutorial004.py .....                                                                                                                        [ 98%]
tests/test_type_conversion.py ............                                                                                                                                            [100%]

========================================================================================= FAILURES ==========================================================================================
___________________________________________________________________________________ test_show_completion ____________________________________________________________________________________

    def test_show_completion():
        result = subprocess.run(
            [
                "bash",
                "-c",
                f"{sys.executable}  -m coverage run {mod.__file__} --show-completion",
            ],
            capture_output=True,
            encoding="utf-8",
            env={**os.environ, "SHELL": "/bin/bash", "_TYPER_COMPLETE_TESTING": "True"},
        )
>       assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout
E       AssertionError: assert '_TUTORIAL001.PY_COMPLETE=complete_bash' in ''
E        +  where '' = CompletedProcess(args=['bash', '-c', '/usr/bin/python3  -m coverage run /home/tkloczko/rpmbuild/BUILD/typer-0.11.0/docs_src/commands/index/tutorial001.py --show-completion'], returncode=1, stdout='', stderr='Shell sh not supported.\n').stdout

tests/test_completion/test_completion.py:20: AssertionError
__________________________________________________________________________________ test_install_completion __________________________________________________________________________________

    def test_install_completion():
        bash_completion_path: Path = Path.home() / ".bashrc"
        text = ""
        if bash_completion_path.is_file():  # pragma: no cover
            text = bash_completion_path.read_text()
        result = subprocess.run(
            [
                "bash",
                "-c",
                f"{sys.executable} -m coverage run {mod.__file__} --install-completion",
            ],
            capture_output=True,
            encoding="utf-8",
            env={**os.environ, "SHELL": "/bin/bash", "_TYPER_COMPLETE_TESTING": "True"},
        )
        new_text = bash_completion_path.read_text()
>       bash_completion_path.write_text(text)

tests/test_completion/test_completion.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.9/pathlib.py:1285: in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.9/pathlib.py:1252: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/tkloczko/.bashrc'), name = '/home/tkloczko/.bashrc', flags = 524865, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'

/usr/lib64/python3.9/pathlib.py:1120: PermissionError
_______________________________________________________________________________ test_completion_install_bash ________________________________________________________________________________

    def test_completion_install_bash():
        bash_completion_path: Path = Path.home() / ".bashrc"
        text = ""
        if bash_completion_path.is_file():
            text = bash_completion_path.read_text()
        result = subprocess.run(
            [
                sys.executable,
                "-m",
                "coverage",
                "run",
                mod.__file__,
                "--install-completion",
                "bash",
            ],
            capture_output=True,
            encoding="utf-8",
            env={
                **os.environ,
                "_TYPER_COMPLETE_TESTING": "True",
                "_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION": "True",
            },
        )
        new_text = bash_completion_path.read_text()
>       bash_completion_path.write_text(text)

tests/test_completion/test_completion_install.py:56:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.9/pathlib.py:1285: in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.9/pathlib.py:1252: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/tkloczko/.bashrc'), name = '/home/tkloczko/.bashrc', flags = 524865, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'

/usr/lib64/python3.9/pathlib.py:1120: PermissionError
================================================================================== short test summary info ==================================================================================
SKIPPED [1] tests/test_annotated.py:26: requires python3.10+
FAILED tests/test_completion/test_completion.py::test_show_completion - AssertionError: assert '_TUTORIAL001.PY_COMPLETE=complete_bash' in ''
FAILED tests/test_completion/test_completion.py::test_install_completion - PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'
FAILED tests/test_completion/test_completion_install.py::test_completion_install_bash - PermissionError: [Errno 13] Permission denied: '/home/tkloczko/.bashrc'
=================================================================== 3 failed, 897 passed, 1 skipped in 123.20s (0:02:03) ====================================================================

@svlandeg
Copy link
Member

svlandeg commented Sep 5, 2024

Hey @kloczek, apologies for the late follow-up.

We've been discussing this here and it sounds like Tiangolo's proposal would fix your issue, right?

maybe we could have the "install completion" tests run only under some opt-in env var or something like that, that we could enable by default on CI, or we could enable manually when testing locally, but wouldn't affect others that come and try to run the tests.

@kloczek
Copy link
Author

kloczek commented Sep 5, 2024

Do you wan me to test that? 🤔

@svlandeg
Copy link
Member

svlandeg commented Sep 6, 2024

Once we've got a solution ready you could, yea :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request investigate
Projects
None yet
5 participants