pytest-sugar: pytest-sugar is not working with pytest v5.4.0 (released on March 12th 2020)

pytest-sugar is not working with pytest v5.4.0 (released on March 12th 2020)

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 187, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 820, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 308, in call_historic
INTERNALERROR>     res = self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pytest_sugar.py", line 176, in pytest_configure
INTERNALERROR>     sugar_reporter = SugarTerminalReporter(standard_reporter)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pytest_sugar.py", line 214, in __init__
INTERNALERROR>     self.writer = self._tw
INTERNALERROR> AttributeError: can't set attribute

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 53
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

from personal experience i can say that a number of open-source maintainers currently have different priorities due to accommodating for stuff like daycare shut-down and corona preventions,

while i understand the unhappiness with delays, lets have patience and lets hope and wish for the good health of the maintainers and their families

Hello!

It looks like all fixes were merged already. Can I ask when the new version with fixes planned to be released?

Bump!

Can someone cut a release and put onto PyPi?

Reposting a comment I posted on the PR for this:

This will work to get pytest-sugar working until this has merged:

pip install -e git+https://github.com/GuillaumeFavelier/pytest-sugar.git@b56fed42d5c3022ff507ab6ce81cda65a3a5f92a#egg=pytest-sugar

It simply installs the version from @GuillaumeFavelier’s fork.

@GuillaumeFavelier Your patch looks good, please consider creating a PR with it.

It seems that direct access to self.writer is deprecated:

https://github.com/pytest-dev/pytest/blob/master/src/_pytest/terminal.py#L285-L293

and that self.write() should be used instead of self.writer.write():

https://github.com/pytest-dev/pytest/blob/master/src/_pytest/terminal.py#L361-L362

I suggest:

diff --git a/pytest_sugar.py b/pytest_sugar.py
index c479dab..35d018a 100644
--- a/pytest_sugar.py
+++ b/pytest_sugar.py
@@ -211,7 +211,6 @@ def pytest_report_teststatus(report):
 class SugarTerminalReporter(TerminalReporter):
     def __init__(self, reporter):
         TerminalReporter.__init__(self, reporter.config)
-        self.writer = self._tw
         self.paths_left = []
         self.tests_count = 0
         self.tests_taken = 0
@@ -339,14 +338,14 @@ class SugarTerminalReporter(TerminalReporter):
     def overwrite(self, line, rel_line_num):
         # Move cursor up rel_line_num lines
         if rel_line_num > 0:
-            self.writer.write("\033[%dA" % rel_line_num)
+            self.write("\033[%dA" % rel_line_num)
 
         # Overwrite the line
-        self.writer.write("\r%s" % line)
+        self.write("\r%s" % line)
 
         # Return cursor to original line
         if rel_line_num > 0:
-            self.writer.write("\033[%dB" % rel_line_num)
+            self.write("\033[%dB" % rel_line_num)
 
     def get_max_column_for_test_status(self):
         return (
@@ -389,7 +388,7 @@ class SugarTerminalReporter(TerminalReporter):
         else:
             self.current_lines[path] = " " * (2 + len(fspath))
         self.current_line_nums[path] = self.current_line_num
-        self.writer.write("\r\n")
+        self.write("\r\n")
 
     def reached_last_column_for_test_status(self, report):
         len_line = real_string_length(

https://github.com/pytest-dev/pytest/pull/6986 will hopefully solve the pytest side, once i had a bit of time and peace of mind it was done very quickly

great. thank you.

went for this:

pytest~=5.4,!=5.4.1

Keep in mind though that this is basically a regression in pytest: it wanted to deprecate a property (out of nowhere TBH), and hasn’t considered that some plugins like pytest-sugar might actually set this property. Therefore (https://github.com/pytest-dev/pytest/issues/6951) it is more a pytest bug after all.

While this is unfortunate in general and I can see that parents have less time currently, it is still like ~2 weeks already without ttis being fixed.

IMHO:

  1. there is not much reason for deprecating something just because
  2. if it causes a regression it should be fixed quickly

pytest-sugar is not in the camp of having to fix the above after all: it should only have to adjust to DeprectionWarnings (which might still be fatal, but that is another issue) - an attempt to issue a DeprecationWarning that breaks things is a bug in the one that tried to issue it. /cc @nicoddemus