pytest-dev / pytest-dev/pytest-xdist

Very long strings may be generated when I test a large file with "- n NUM" parameter. And It causes an Error: the string is too long.

Open
#1,138 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

My python version is 3.10.12
pytest version : 8.2.1
execnet Version: 2.1.1
The versions are both the lastest.

When I run the command: pytest -k mykey -n 16, I got the error as follows:

INTERNALERROR> E                 raise DumpError(error)
INTERNALERROR> E             execnet.gateway_base.DumpError: string is too long
INTERNALERROR> E           assert False
INTERNALERROR> 

I checked the source code in gateway_base.py and find that when the byte_ > FOUR_BYTE_INT_MAX , there will raise a DumpError.

 def _write_int4(
        self, i: int, error: str = "int must be less than %i" % (FOUR_BYTE_INT_MAX,)
    ) -> None:
        if i > FOUR_BYTE_INT_MAX:
            raise DumpError(error)
        self._write(struct.pack("!i", i))

I tried to add the int8 bytecodes for long string, but it doesn't work.

How should I fix this bug?
Another idea is that I do not need to print so much string information. Can I simplify the printout or disable this feature directly?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with pytest -k mykey -n 16 using the reported Python, pytest, and execnet versions. Read gateway_base.py, especially _write_int4 and the string serialization path; done means large-file distributed runs no longer raise DumpError for an overly long string, with the intended output behavior established.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.