pytest-dev / pytest-dev/pytest-xdist

Error "No module named 'py'" when running tests on a remote host using a socket server

Open
#459 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In order to assess xdist when it comes to execution on remote host, I tried to do what is described here https://github.com/pytest-dev/pytest-xdist#sending-tests-to-remote-socket-servers with a really simple test as described below and received the following error in my client.

File "", line 1, in do_exec
File "", line 13, in
ModuleNotFoundError: No module named 'py'

  • test:
import unittest
from mypkg.a_file import print_stuff


class Test(unittest.TestCase):

    def test_it(self):
        print_stuff()
        self.assertTrue(True)
  • project tree:

C:.
│ pytest.ini
│ setup.cfg

├───.cache
│ └───v
│ └───cache
│ lastfailed

├───.pytest_cache
│ │ .gitignore
│ │ CACHEDIR.TAG
│ │ README.md
│ │
│ └───v
│ └───cache
│ nodeids
│ stepwise

├───assets
│ style.css

├───mypkg
│ │ a_file.py
│ │ init.py
│ │
│ └───pycache
│ a_file.cpython-36.pyc
│ a_file.cpython-37.pyc
init.cpython-36.pyc
init.cpython-37.pyc

└───test
init.py

├───mypkg
│ │ test_.py
│ │ init.py
│ │
│ └───pycache
│ test_.cpython-36-pytest-5.0.1.pyc
│ test_.cpython-37-PYTEST.pyc
init.cpython-36.pyc
init.cpython-37.pyc

└───pycache
init.cpython-36.pyc
init.cpython-37.pyc

  • pytest.ini

[pytest]
addopts = --html=remote-results.html --junitxml=remote-results.html --log-level=INFO --tx socket={myhost}:8888

  • setup.cfg

[tool:pytest]
rsyncdirs = . mypkg

  • When running on my local machine:

python -m pytest

===================================================== test session starts ====================================================== platform win32 -- Python 3.6.7, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: \test, inifile: pytest.ini
plugins: forked-1.0.2, html-1.21.1, metadata-1.8.0, xdist-1.29.0
collected 1 item

test\mypkg\test_.py . [100%]

------------- generated xml file: remote-results.html -------------- --------- generated html file: file:\remote-results.html ---------- =================================================== 1 passed in 0.20 seconds ===================================================

  • When running on a remote host with socketserver.py running there:

python -m pytest -d --rsyncdir mypkg mypkg

try: execmodel
except NameError:
execmodel = get_execmodel('thread')
io = SocketIO(clientsock, execmodel)
io.write('1'.encode('ascii'))
serve(io, id='socket={myhost}:8888-slave')", line 1063, in executetask
File "", line 1, in do_exec
File "", line 13, in
ModuleNotFoundError: No module named 'py'

replacing crashed worker gw0

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 with the pytest-xdist remote socket-server instructions and reproduce the failure using socketserver.py with the shown pytest.ini and setup.cfg. Trace the remote exec path where the worker imports py; done means the remote socket test runs without ModuleNotFoundError and the sample test passes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.