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 stops #1411

Closed
H0R5E opened this issue Feb 24, 2016 · 13 comments
Closed

Pytest stops #1411

H0R5E opened this issue Feb 24, 2016 · 13 comments

Comments

@H0R5E
Copy link

H0R5E commented Feb 24, 2016

Hi,

I have a weird issue where py.test just stops. I have a test module with 5 tests. If I run with the 3 that work - tests 1,2 & 5 - py.test works fine. However, if I run with all 5 it just stops working. I have copied the output below:

[integration] d:\Usuarios\108630\Programming\Python\hg\dtocean-core>py.test test
s\test_modules.py
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: d:\Usuarios\108630\Programming\Python\hg\dtocean-core, inifile: pytest.
ini
collected 3 items

tests\test_modules.py ...

========================== 3 passed in 29.13 seconds ==========================

[integration] d:\Usuarios\108630\Programming\Python\hg\dtocean-core>py.test test
s\test_modules.py
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: d:\Usuarios\108630\Programming\Python\hg\dtocean-core, inifile: pytest.
ini
collected 5 items

tests\test_modules.py .FF.
[integration] d:\Usuarios\108630\Programming\Python\hg\dtocean-core>

I really don't how to diagnose the problem. I'm using anaconda on windows as follows:

[D:\Usuarios\108630]conda info
Current conda install:

             platform : win-64
        conda version : 3.19.3
  conda-build version : 1.19.0
       python version : 2.7.11.final.0
     requests version : 2.9.1
     root environment : C:\Anaconda  (writable)
  default environment : C:\Anaconda
     envs directories : C:\Anaconda\envs
        package cache : C:\Anaconda\pkgs
         channel URLs : https://conda.binstar.org/t/<TOKEN>/topper/win-64/
                        https://conda.binstar.org/t/<TOKEN>/topper/noarch/
                        https://repo.continuum.io/pkgs/free/win-64/
                        https://repo.continuum.io/pkgs/free/noarch/
                        https://repo.continuum.io/pkgs/pro/win-64/
                        https://repo.continuum.io/pkgs/pro/noarch/
          config file : d:\Usuarios\108630\.condarc
    is foreign system : False

If anyone can offer me any advice on what I can do to investigate the issue I would be very grateful.

@The-Compiler
Copy link
Member

I'd guess something in your code under test is hanging - you can run with -v to find out which test it is, and then inspect that code, maybe check if you can reproduce it if you do the same thing outside of pytest.

You could also try using pytest-faulthandler with its --faulthandler-timeout option or pytest-timeout to get a stacktrace of the hang.

@nicoddemus
Copy link
Member

It was not clear to me if the execution was hanging (non responsive) or if you're being dropped back to the command-line (which would be an indication of a crash).

@The-Compiler's suggestions are on the spot and worth trying out, regardless. 😁

@H0R5E
Copy link
Author

H0R5E commented Feb 24, 2016

Ah, no joy I'm afraid. It's not a hang, it just returns to the command line.

The strange thing is that I can run combinations of 4 of the 5 tests no problem, but I can't run all 5 together. I was wondering if it was a memory error, but the system resources look OK, so I don't get it.

Just to say, no joy means I got no output from pytest-faulthandler.

@H0R5E
Copy link
Author

H0R5E commented Feb 24, 2016

OK, so if I swap the order of the tests, all 5 will work together. Bizarre.

@The-Compiler
Copy link
Member

I don't think there's much more we can recommend here without knowing what your tests actually do, I'm afraid 😉

@H0R5E
Copy link
Author

H0R5E commented Feb 24, 2016

OK, thanks. Even though its passing the module now, the whole suite still won't run together.
The tests are far from unit tests - I am testing the execution of whole packages - so I am probably abusing the system a bit here. For the time being I will move these "big" tests to a more manual environment so they don't foul the real unit tests.

If I'm still struggling in 2017 I will send you the links! ;)

@H0R5E H0R5E closed this as completed Feb 24, 2016
@hpk42
Copy link
Contributor

hpk42 commented Feb 25, 2016

you might want to run "-n1" or "--boxed" (if you have a unix system) with pytest-xdist installed. This will isolate each test in a separate process which might help with your setup. Please report back if it helped :)

@H0R5E
Copy link
Author

H0R5E commented Feb 25, 2016

@hpk42 thanks for the tip. I tried pytest-xdist with -n1 but it does not play nicely with conda environments (at least in windows) so I could not learn anything. I'm afraid I am stuck in windows until pandas sorts out its .ods support.

@nicoddemus
Copy link
Member

@H0R5E that's strange, we use pytest-xdist in conda environments at work without any hiccups. What problem do you see?

@H0R5E
Copy link
Author

H0R5E commented Feb 25, 2016

Well, it seems to lose packages I have manually installed into the environment. Here are two test sessions, the first without -n1 and second with:

============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: d:\Usuarios\108630\Programming\Python\hg\dtocean-core, inifile: pytest.ini
plugins: xdist-1.14
collected 46 items

tests\test_auto_query.py .F..F
tests\test_core.py ...
tests\test_database.py ...
tests\test_menu.py ......
tests\test_modules.py .....
tests\test_pipeline_inputs.py ........F...
tests\test_pipeline_outputs.py ......
tests\test_query_interface.py ...
tests\test_tools_convert.py .F.

================================== FAILURES ===================================

Stuff I have done wrong...

==================== 4 failed, 42 passed in 62.90 seconds =====================
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: d:\Usuarios\108630\Programming\Python\hg\dtocean-core, inifile: pytest.ini
plugins: xdist-1.14
gw0 I
gw0 [46]

scheduling tests via LoadScheduling
FFFFF...EEE.FFFFFEEEEE.EEEEEEEEEEE.EEEEE.EE.F.
=================================== ERRORS ====================================
_______________________ ERROR at setup of test_connect ________________________
[gw0] win32 -- Python 2.7.11 C:\Anaconda\envs\integration\python.exe
@pytest.fixture(scope="module")
    def database():

        project_title = "Test"

        new_core = Core()
        new_tree = Tree()

        new_poject = new_core.new_project(project_title)

        data_menu = DataMenu()
>       new_poject = data_menu.initiate_pipeline(new_core, new_poject, new_tree)

tests\test_database.py:45: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dtocean_core\menu.py:387: in initiate_pipeline
    project_copy = core.build_hubs(project)
dtocean_core\core.py:239: in build_hubs
    core_interfaces)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\control\pipeline.py:30: in create_new_pipeline
    new_pipeline = Pipeline(socket_cls, interface_module)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\entity\pipeline.py:378: in __init__
    super(Pipeline, self).__init__(interface_name, interface_module)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\entity\pipeline.py:34: in __init__
    self.set_socket(interface_name, interface_module)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\entity\pipeline.py:50: in set_socket
    self._socket_obj.discover_interfaces(interface_module)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\control\sockets.py:158: in discover_interfaces
    self._interface_name)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\control\sockets.py:33: in discover_interfaces
    cls_map = self._discover_plugins(package, super_cls)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\utilities\plugins.py:43: in _discover_plugins
    cls_map[cls_name] = get_class_attr(cls_name, mod_name)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\utilities\plugins.py:151: in get_class_attr
    module = get_module_attr(mod_name)
c:\anaconda\envs\integration\lib\site-packages\aneris-0.1.5.dev1-py2.7.egg\aneris\utilities\plugins.py:160: in get_module_attr
    module = import_module(mod_name)
C:\Anaconda\envs\integration\lib\importlib\__init__.py:37: in import_module
    __import__(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    """


    import numpy as np
>   from dtocean_electrical.main import (ElectricalSiteData,
                                         ElectricalMachineData,
                                         ElectricalArrayData,
                                         ElectricalInput)
E                                        ImportError: cannot import name ElectricalSiteData

dtocean_core\interfaces\electrical.py:19: ImportError

Complete pandemonium...

=============== 11 failed, 9 passed, 26 error in 47.28 seconds ================

@H0R5E
Copy link
Author

H0R5E commented Feb 25, 2016

Just to prove that they are really installed into the environment...

[integration] d:\Usuarios\108630\Programming\Python\hg\dtocean-core>conda list
# packages in environment at C:\Anaconda\envs\integration:
#
aneris                    0.1.5.dev1                <pip>
apipkg                    1.4                       <pip>
attrdict                  2.0.0                     <pip>
backports.ssl-match-hostname 3.4.0.2                   <pip>
colorama                  0.3.6                    py27_0    defaults
configobj                 5.0.6                    py27_0    <unknown>
cycler                    0.9.0                    py27_0    defaults
deap                      1.0.2                    py27_0    file:///C|/Anaconda
/conda-bld/win-64/deap-1.0.2-py27_0.tar.bz2
decorator                 4.0.4                    py27_0    defaults
descartes                 1.0.1                np19py27_0    https://conda.binst
ar.org/topper/win-64/descartes-1.0.1-np19py27_0.tar.bz2
dtocean-core              0.1.5.dev1                <pip>
dtocean-demo-package      0.1.0                np19py27_2    https://conda.binst
ar.org/topper/win-64/dtocean-demo-package-0.1.0-np19py27_2.tar.bz2
dtocean-economics         0.1.0                np19py27_1    https://conda.binst
ar.org/topper/win-64/dtocean-economics-0.1.0-np19py27_1.tar.bz2
dtocean-electrical        0.1.0                np19py27_1    https://conda.binst
ar.org/topper/win-64/dtocean-electrical-0.1.0-np19py27_1.tar.bz2
dtocean-hydrodynamics     0.2.0.dev0                <pip>
dtocean-installation      0.1.0                np19py27_0    https://conda.binst
ar.org/topper/win-64/dtocean-installation-0.1.0-np19py27_0.tar.bz2
dtocean-moorings          0.1.0                np19py27_0    https://conda.binst
ar.org/topper/win-64/dtocean-moorings-0.1.0-np19py27_0.tar.bz2
dtocean-operations        0.1.0                np19py27_0    https://conda.binst
ar.org/topper/win-64/dtocean-operations-0.1.0-np19py27_0.tar.bz2
dtocean-reliability       0.1.0                np19py27_0    https://conda.binst
ar.org/topper/win-64/dtocean-reliability-0.1.0-np19py27_0.tar.bz2
et-xmlfile                1.0.1                     <pip>
et_xmlfile                1.0.1                    py27_0    defaults
execnet                   1.4.1                     <pip>
funcsigs                  0.4                      py27_0    <unknown>
geoalchemy2               0.3.0.dev1                <pip>
ipykernel                 4.1.1                    py27_0    defaults
ipython                   4.0.0                    py27_1    defaults
ipython-genutils          0.1.0                     <pip>
ipython-notebook          4.0.4                    py27_3    defaults
ipython_genutils          0.1.0                    py27_0    defaults
jdcal                     1.2                      py27_0    defaults
jinja2                    2.8                      py27_0    defaults
jpeg                      8d                        vc9_0  [vc9]  defaults
jsonschema                2.4.0                    py27_0    <unknown>
jupyter-client            4.1.1                     <pip>
jupyter-core              4.0.6                     <pip>
jupyter_client            4.1.1                    py27_0    defaults
jupyter_core              4.0.6                    py27_0    defaults
libpng                    1.6.17                    vc9_1  [vc9]  defaults
libpython                 1.0                      py27_1    defaults
libtiff                   4.0.6                     vc9_1  [vc9]  defaults
lxml                      3.4.4                    py27_0    <unknown>
markupsafe                0.23                     py27_0    <unknown>
matplotlib                1.4.3                np19py27_3    defaults
mingw                     4.7                           1    defaults
mistune                   0.7.1                    py27_0    defaults
mock                      1.3.0                    py27_0    defaults
msvc_runtime              1.0.1                     vc9_0  [vc9]  defaults
nbconvert                 4.0.0                    py27_0    defaults
nbformat                  4.0.1                    py27_0    defaults
nose                      1.3.7                    py27_0    <unknown>
notebook                  4.0.6                    py27_0    defaults
numpy                     1.9.3                    py27_0    defaults
openpyxl                  2.3.2                    py27_0    defaults
openssl                   1.0.2d                    vc9_0  [vc9]  defaults
pandas                    0.17.0               np19py27_0    defaults
path.py                   8.1.2                    py27_0    defaults
pbr                       1.3.0                    py27_0    defaults
pickleshare               0.5                      py27_0    defaults
pip                       8.0.2                    py27_0    defaults
polite                    0.2.0.dev0                <pip>
psycopg2                  2.6.1                     <pip>
psycopg2-win-py27         2.6.1                         0    file:///C|/Anaconda
/conda-bld/win-64/psycopg2-win-py27-2.6.1-0.tar.bz2
py                        1.4.31                   py27_0    defaults
pygments                  2.0.2                    py27_0    <unknown>
pyparsing                 2.0.3                    py27_0    <unknown>
pypower                   4.1.2                np19py27_0    https://conda.binst
ar.org/topper/win-64/pypower-4.1.2-np19py27_0.tar.bz2
pyqt                      4.11.4                   py27_3    defaults
pyreadline                2.1                      py27_0    defaults
pytest                    2.8.5                    py27_0    defaults
pytest-xdist              1.14                      <pip>
python                    2.7.11                        2    defaults
python-dateutil           2.4.2                    py27_0    <unknown>
pytz                      2015.7                   py27_0    defaults
pywin32                   219                      py27_1    defaults
pyyaml                    3.11                     py27_2    defaults
pyzmq                     14.7.0                   py27_1    defaults
qt                        4.8.7                     vc9_4  [vc9]  defaults
requests                  2.8.1                    py27_0    defaults
scikit-learn              0.16.1               np19py27_0    <unknown>
scipy                     0.16.0               np19py27_0    defaults
setuptools                19.6.2                   py27_0    defaults
shapely                   1.5.7                     <pip>
shapely-win-py27          1.5.7                         0    https://conda.binst
ar.org/topper/win-64/shapely-win-py27-1.5.7-0.tar.bz2
simplegeneric             0.8.1                    py27_0    defaults
sip                       4.16.9                   py27_2    defaults
six                       1.10.0                   py27_0    defaults
sqlalchemy                1.0.9                    py27_0    defaults
ssl_match_hostname        3.4.0.2                  py27_0    <unknown>
tk                        8.5.18                    vc9_0  [vc9]  defaults
tornado                   4.2.1                    py27_1    defaults
traitlets                 4.0.0                    py27_0    defaults
wheel                     0.26.0                   py27_1    defaults
xlrd                      0.9.4                    py27_0    defaults
xlwt                      1.0.0                    py27_0    <unknown>
zlib                      1.2.8                     vc9_2  [vc9]  defaults

@H0R5E
Copy link
Author

H0R5E commented Feb 25, 2016

This must be something to do with using importlib. I have a plugin architecture which is used to discover modules on the fly and it uses importlib to load them. Is some intelligent filtering of the name space going on?

Shall I open a bug in pytest-xdist?

@nicoddemus
Copy link
Member

pytest-xdist does not by itself does any filtering when importing nodes on workers... each worker loads all tests even if usually they end up running just a sub-set of the tests. I mention this because it might be relevant to your error.

Can you reproduce the problem in a small reproducible case? Otherwise I feel it will be very hard to reproduce the problem you are having with xdist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants