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

pytest-xdist fails when running same tests several times #1591

Closed
cooraz opened this issue Jun 7, 2016 · 2 comments
Closed

pytest-xdist fails when running same tests several times #1591

cooraz opened this issue Jun 7, 2016 · 2 comments
Labels
plugin: xdist related to the xdist external plugin

Comments

@cooraz
Copy link

cooraz commented Jun 7, 2016

Hi
I am having an issue with py.test xdist.
I have a PC running the socketserver.py with Loop = True to allow multiple tests, but this seems to be an issue.
When I run a simple test case like:

import time, pytest

def f():
    return 3

def test_f():
    assert f() == 4

using the command line:
py.test -d --tx socket=ip-of-pc:8888 --rsyncdir Testpackage Testpackage
The first executing will return the result, as expect. However, if the same line is executed again, py.test will fail with the following error message:

=================================== ERRORS ====================================
_______________________ ERROR collecting test_script.py _______________________
import file mismatch:
imported module 'Testpackage.test_script' has this __file__ attribute:
  /home/user1/Downloads/pyexecnetcache/Testpackage/test_script.py
which is not the same as the test file we want to collect:
  /home/user1/Downloads/pyexecnetcache/pyexecnetcache/Testpackage/test_script.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test
 file modules
=========================== 1 error in 0.22 seconds ===========================

The package struct is:

Testpackage
   |-     __init__py 
   |-    test_script.py

It seems like the socketserver doesn't do any cleanup, after the test has finished.

I have tried to delete the pyexecnetcache(put in trash) after the first test run, but this gives a similar result:

=================================== ERRORS ====================================
_______________________ ERROR collecting test_script.py _______________________
import file mismatch:
imported module 'Testpackage.test_script' has this __file__ attribute:
  /home/user1/Downloads/pyexecnetcache/Testpackage/test_script.py
which is not the same as the test file we want to collect:
  /home/user1/.local/share/Trash/files/pyexecnetcache.4/pyexecnetcache/Testpackag
e/test_script.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test
 file modules
=========================== 1 error in 0.28 seconds ===========================

My client PC is running Linux, but it is a problem on windows too.
Im running py.test 2.9.2 and xdist 1.14

@Zac-HD
Copy link
Member

Zac-HD commented Oct 20, 2018

Might be caused by #3968?

@Zac-HD Zac-HD added the plugin: xdist related to the xdist external plugin label Oct 20, 2018
@RonnyPfannschmidt
Copy link
Member

closing this as upstream issue with execnet socket servers, pytest cant fix that

@RonnyPfannschmidt RonnyPfannschmidt closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: xdist related to the xdist external plugin
Projects
None yet
Development

No branches or pull requests

3 participants