Changeset 335271e in sasmodels


Ignore:
Timestamp:
Jan 31, 2018 2:59:52 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
0e7611b
Parents:
f354e46
Message:

remove restriction on pytest<4

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • .travis.yml

    r2ab1bac r335271e  
    3737- conda update --yes conda 
    3838- conda info -a 
    39 # 2018-01-26 PAK: sasmodels uses yield generator for tests, which isn't supported in pytest 4+ 
    40 - conda install --yes python=$PY numpy scipy matplotlib docutils setuptools "pytest<4" 
     39- conda install --yes python=$PY numpy scipy matplotlib docutils setuptools pytest 
    4140install: 
    4241- pip install bumps 
  • appveyor.yml

    r2ab1bac r335271e  
    6868    #- cmd: conda install --yes --quiet obvious-ci 
    6969    # 2018-01-19 PAK: skipping toolchain cython and cffi (these were for pyopencl?) 
    70     # 2018-01-26 PAK: sasmodels uses yield generator for tests, which isn't supported in pytest 4+ 
    71     - cmd: conda install --yes --quiet numpy scipy matplotlib docutils setuptools "pytest<4" 
     70    - cmd: conda install --yes --quiet numpy scipy matplotlib docutils setuptools pytest 
    7271    # 2018-01-19 PAK: skipping pyopencl; this would be needed for deploy but maybe not for test 
    7372    #- cmd: conda install --yes --channel conda-forge pyopencl 
  • conftest.py

    r6dba2f0 r335271e  
    2020import pytest 
    2121from _pytest.unittest import TestCaseFunction 
     22from _pytest.compat import is_generator 
     23 
     24def pytest_pycollect_makeitem(collector, name, obj): 
     25    """ 
     26    Convert test generator into list of function tests so that pytest doesn't 
     27    complain about deprecated yield tests. 
     28 
     29    Note that unlike nose, the tests are generated and saved instead of run 
     30    immediately.  This means that any dynamic context, such as a for-loop 
     31    variable, must be captured by wrapping the yield result in a function call. 
     32 
     33    For example:: 
     34 
     35        for value in 1, 2, 3: 
     36            for test in test_cases: 
     37                yield test, value 
     38 
     39    will need to be changed to:: 
     40 
     41        def build_test(test, value): 
     42            return test, value 
     43        for value in 1, 2, 3: 
     44            for test in test_cases: 
     45                yield build_test(test, value) 
     46 
     47    This allows the context (test and value) to be captured by lexical closure 
     48    in build_test. See https://stackoverflow.com/a/233835/6195051. 
     49    """ 
     50    if collector.istestfunction(obj, name) and is_generator(obj): 
     51        tests = [pytest.Function(name, parent=collector, args=yielded[1:], callobj=yielded[0]) 
     52                 for yielded in obj()] 
     53        return tests 
     54 
    2255 
    2356USE_DOCSTRING_AS_DESCRIPTION = True 
Note: See TracChangeset for help on using the changeset viewer.