pytest-dev / pytest-dev/execnet

AttributeError: 'ChannelFileWrite' object has no attribute 'encoding'

Offen
#161 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug help wanted
Vorherrschende Sprache
Python
Sterne
102
Forks
47
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

When I try to run testsuite for pytest-xdist and both execnet and teamcity-messages are installed few tests fails with errors like:

__________________ TestRemoteControl.test_failures_somewhere ___________________

self = <test_looponfail.TestRemoteControl object at 0x7fffaa00c7c0>
pytester = <Pytester PosixPath('/tmp/pytest-of-marcel/pytest-10/test_failures_somewhere0')>

    def test_failures_somewhere(self, pytester: pytest.Pytester) -> None:
        item = pytester.getitem("def test_func():\n assert 0\n")
        control = RemoteControl(item.config)
        control.setup()
>       failures = control.runsession()

$(BLDDIR)/testing/test_looponfail.py:126:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _  
$(INSTDIR)/usr/lib/python3.9/vendor-packages/xdist/looponfail.py:117: in runsession
    return self.channel.receive()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Channel id=1 closed>, timeout = None

    def receive(self, timeout=None):
        """receive a data item that was sent from the other side.
        timeout: None [default] blocked waiting.  A positive number
        indicates the number of seconds after which a channel.TimeoutError
        exception will be raised if no item was received.
        Note that exceptions from the remotely executing code will be
        reraised as channel.RemoteError exceptions containing
        a textual representation of the remote traceback.
        """
        itemqueue = self._items
        if itemqueue is None:
            raise IOError("cannot receive(), channel has receiver callback")
        try:
            x = itemqueue.get(timeout=timeout) 
        except self.gateway.execmodel.queue.Empty:
            raise self.TimeoutError("no item after %r seconds" % timeout)
        if x is ENDMARKER:
            itemqueue.put(x)  # for other receivers
>           raise self._getremoteerror() or EOFError()
E           execnet.gateway_base.RemoteError: Traceback (most recent call last):
E             File "/usr/lib/python3.9/vendor-packages/execnet/gateway_base.py", line 1088, in executetask
E               function(channel, **kwargs)
E             File "$(INSTDIR)/usr/lib/python3.9/vendor-packages/xdist/looponfail.py", line 171, in init_worker_session
E               config = Config.fromdictargs(option_dict, list(args))
E             File "/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py", line 1110, in fromdictargs
E               config.parse(args, addopts=False)
E             File "/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py", line 1346, in parse
E               self._preparse(args, addopts=addopts)
E             File "/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py", line 1229, in _preparse
E               self.pluginmanager.load_setuptools_entrypoints("pytest11")
E             File "/usr/lib/python3.9/vendor-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
E               plugin = ep.load()
E             File "/usr/lib/python3.9/importlib/metadata.py", line 86, in load
E               module = import_module(match.group('module'))
E             File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
E               return _bootstrap._gcd_import(name[level:], package, level)
E             File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
E             File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
E             File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
E             File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
E             File "/usr/lib/python3.9/vendor-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
E               exec(co, module.__dict__)
E             File "/usr/lib/python3.9/vendor-packages/teamcity/pytest_plugin.py", line 22, in <module>
E               from teamcity.common import convert_error_to_string, dump_test_stderr, dump_test_stdout
E             File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
E             File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
E             File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
E             File "/usr/lib/python3.9/vendor-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
E               exec(co, module.__dict__)
E             File "/usr/lib/python3.9/vendor-packages/teamcity/common.py", line 19, in <module>
E               _sys_stdout_encoding = sys.stdout.encoding
E           AttributeError: 'ChannelFileWrite' object has no attribute 'encoding'

/usr/lib/python3.9/vendor-packages/execnet/gateway_base.py:749: RemoteError

With teamcity-messages uninstalled these tests pass.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere den Fehler mit installiertem execnet, pytest-xdist und teamcity-messages, ausgehend von execnet's gateway_base.py und dem ChannelFileWrite-Objekt im Traceback. Untersuche teamcity/common.py, wo sys.stdout.encoding gelesen wird, und führe die betroffenen pytest-xdist-Tests mit und ohne teamcity-messages aus. Erledigt ist die Aufgabe, wenn das Plugin ohne dieses AttributeError geladen wird und die Tests bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
distributed-systems
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.