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

terminal writer error when pytest is called with pytest.main(pytest_args, plugins=[pytest_finish_plugin(), pytest_start_plugin()]) #7626

Closed
3 of 4 tasks
bugpr0 opened this issue Aug 7, 2020 · 6 comments · Fixed by #7700
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed

Comments

@bugpr0
Copy link

bugpr0 commented Aug 7, 2020

  • a detailed description of the bug or suggestion
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

terminal writer exception, calling pytest as pytest.main(pytest_args, plugins=[pytest_finish_plugin(), pytest_start_plugin()])

relevant pytest pip list:

pytest                             6.0.1                
pytest-html                        2.1.1                
pytest-instafail                   0.4.1.post0          
pytest-lazy-fixture                0.6.3                
pytest-metadata                    1.8.0                
pytest-repeat                      0.8.0                
pytest-sugar                       0.9.4                
pytest-tldr                        0.2.1                
python-key-path-mapping            1.1.0                
pytoolkit                          0.7.0                
PyYAML                             5.3.1                

system host: macOSx , catalina

AttributeError: 'ReprExceptionInfo' object has no attribute 'rsplit'; see traceback below:

Traceback (most recent call last):
  File "<..>/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "<..>/lib/python3.7/site-packages/_pytest/config/__init__.py", line 180, in console_main
    code = main()
  File "<..>/lib/python3.7/site-packages/_pytest/config/__init__.py", line 158, in main
    config=config
  File "<..>/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "<..>/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "<..>/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "<..>/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "<..>/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "<..>/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "<..>/lib/python3.7/site-packages/_pytest/main.py", line 289, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "<..>/lib/python3.7/site-packages/_pytest/main.py", line 278, in wrap_session
    session=session, exitstatus=session.exitstatus
  File "<..>/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "<..>lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "<..>/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "<..>lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "<..>lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "<..>/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "<..>lib/python3.7/site-packages/pytest_tldr-0.2.1-py3.7.egg/pytest_tldr.py", line 303, in pytest_sessionfinish
    self.print(report.longrepr)
  File "<..>/lib/python3.7/site-packages/pytest_tldr-0.2.1-py3.7.egg/pytest_tldr.py", line 124, in print
    self._tw.write(text)
  File "<..>lib/python3.7/site-packages/_pytest/_io/terminalwriter.py", line 144, in write
    current_line = msg.rsplit("\n", 1)[-1]
AttributeError: 'ReprExceptionInfo' object has no attribute 'rsplit'
@RonnyPfannschmidt
Copy link
Member

based on the output my guess would be that pytest-tldr is broken,
it works by accident when report.longrepr is a string attribute and it should use report.longreprext

i believe this started t break when pytest got more serious about types and longrepr was more often something concrete isntead of something else

@RonnyPfannschmidt
Copy link
Member

Upstream fixed this in the latest pytest-tldr releases

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 29, 2020
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix pytest-dev#6681
Fix pytest-dev#2891
Fix pytest-dev#7620
Fix pytest-dev#7626
Close pytest-dev#7649
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 29, 2020
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix pytest-dev#6681
Fix pytest-dev#2891
Fix pytest-dev#7620
Fix pytest-dev#7626
Close pytest-dev#7649
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 29, 2020
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix pytest-dev#6681
Fix pytest-dev#2891
Fix pytest-dev#7620
Fix pytest-dev#7626
Close pytest-dev#7649
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 29, 2020
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix pytest-dev#6681
Fix pytest-dev#2891
Fix pytest-dev#7620
Fix pytest-dev#7626
Close pytest-dev#7649
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 29, 2020
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix pytest-dev#6681
Fix pytest-dev#2891
Fix pytest-dev#7620
Fix pytest-dev#7626
Close pytest-dev#7649
nicoddemus added a commit that referenced this issue Sep 4, 2020
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix #6681
Fix #2891
Fix #7620
Fix #7626
Close #7649

Co-authored-by: Ran Benita <ran@unusedvar.com>
@nicoddemus
Copy link
Member

Closed by accident

@nicoddemus nicoddemus reopened this Sep 4, 2020
@Zac-HD Zac-HD added topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed labels Oct 30, 2020
@damey2011
Copy link

Looks like this has been around for a while.
@RonnyPfannschmidt gave the idea for fixing this and this worked for me. You should be able to fix this by installing the latest version of pytest-tldr which is 0.2.2. So running the following should solve this problem.

pip install pytest-tdlr==0.2.2

@RonnyPfannschmidt
Copy link
Member

@nicoddemus reopen by accident?

@nicoddemus
Copy link
Member

@nicoddemus reopen by accident?

Yep definitely, my mistake, probably the result of too many tabs open, thanks for catching it. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants