Changeset a69d8cd in sasmodels


Ignore:
Timestamp:
Jan 26, 2018 9:13:22 PM (3 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:
ecb485c
Parents:
49284e1
Message:

add support for pytest and use it on travis/appveyor

Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • .travis.yml

    r2d09df1 ra69d8cd  
    3737- conda update --yes conda 
    3838- conda info -a 
    39 - conda install --yes python=$PY numpy scipy cython mako cffi 
     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 cython mako cffi "pytest<4" 
    4041install: 
    4142- pip install bumps 
     
    4344script: 
    4445- python --version 
    45 - python -m sasmodels.model_test -v dll all 
     46#- python -m sasmodels.model_test -v dll all 
     47- python -m pytest -v 
    4648before_deploy: 
    4749- echo -e "Host danse.chem.utk.edu\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 
  • appveyor.yml

    rfefc185 ra69d8cd  
    4444 
    4545install: 
    46     # Set the CONDA_NPY, although it has no impact on the actual build.  
     46    # Set the CONDA_NPY, although it has no impact on the actual build. 
    4747    # We need this because of a test within conda-build. 
    4848    - cmd: set CONDA_NPY=19 
     
    6868    #- cmd: conda install --yes --quiet obvious-ci 
    6969    # 2018-01-19 PAK: skipping toolchain cython and cffi (these were for pyopencl?) 
    70     - cmd: conda install --yes --quiet numpy scipy 
     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 "pytest<4" 
    7172    # 2018-01-19 PAK: skipping pyopencl; this would be needed for deploy but maybe not for test 
    7273    #- cmd: conda install --yes --channel conda-forge pyopencl 
     
    8687    #- "%CMD_IN_ENV% python -m sasmodels.model_test dll all" 
    8788    #- cmd /E:ON /V:ON /C obvci_appveyor_python_build_env.cmd python -m sasmoels.model_test dll all 
    88     - python -m sasmodels.model_test dll all 
     89    #- python -m sasmodels.model_test dll all 
     90    #- nosetests -v sasmodels/*.py 
     91    - python -m pytest -v 
  • sasmodels/convert.py

    r2d81cfe ra69d8cd  
    633633def test_backward_forward(): 
    634634    from .core import list_models 
     635    L = lambda name: _check_one(name, seed=1) 
    635636    for name in list_models('all'): 
    636         L = lambda: _check_one(name, seed=1) 
    637         L.description = name 
    638         yield L 
     637        yield L, name 
  • sasmodels/core.py

    r7a516d0 ra69d8cd  
    320320    print("\n".join(list_models(kind))) 
    321321 
    322 def test_load(): 
    323     # type: () -> None 
    324     """Check that model load works""" 
     322def test_composite_order(): 
    325323    def test_models(fst, snd): 
    326324        """Confirm that two models produce the same parameters""" 
    327325        fst = load_model(fst) 
    328326        snd = load_model(snd) 
    329         # Remove the upper case characters frin the parameters, since 
    330         # they lasndel the order of events and we specfically are 
    331         # changin that aspect 
     327        # Un-disambiguate parameter names so that we can check if the same 
     328        # parameters are in a pair of composite models. Since each parameter in 
     329        # the mixture model is tagged as e.g., A_sld, we ought to use a 
     330        # regex subsitution s/^[A-Z]+_/_/, but removing all uppercase letters 
     331        # is good enough. 
    332332        fst = [[x for x in p.name if x == x.lower()] for p in fst.info.parameters.kernel_parameters] 
    333333        snd = [[x for x in p.name if x == x.lower()] for p in snd.info.parameters.kernel_parameters] 
    334334        assert sorted(fst) == sorted(snd), "{} != {}".format(fst, snd) 
    335335 
    336  
    337     test_models( 
     336    def build_test(first, second): 
     337        test = lambda description: test_models(first, second) 
     338        description = first + " vs. " + second 
     339        return test, description 
     340 
     341    yield build_test( 
    338342        "cylinder+sphere", 
    339343        "sphere+cylinder") 
    340     test_models( 
     344    yield build_test( 
    341345        "cylinder*sphere", 
    342346        "sphere*cylinder") 
    343     test_models( 
     347    yield build_test( 
    344348        "cylinder@hardsphere*sphere", 
    345349        "sphere*cylinder@hardsphere") 
    346     test_models( 
     350    yield build_test( 
    347351        "barbell+sphere*cylinder@hardsphere", 
    348352        "sphere*cylinder@hardsphere+barbell") 
    349     test_models( 
     353    yield build_test( 
    350354        "barbell+cylinder@hardsphere*sphere", 
    351355        "cylinder@hardsphere*sphere+barbell") 
    352     test_models( 
     356    yield build_test( 
    353357        "barbell+sphere*cylinder@hardsphere", 
    354358        "barbell+cylinder@hardsphere*sphere") 
    355     test_models( 
     359    yield build_test( 
    356360        "sphere*cylinder@hardsphere+barbell", 
    357361        "cylinder@hardsphere*sphere+barbell") 
    358     test_models( 
     362    yield build_test( 
    359363        "barbell+sphere*cylinder@hardsphere", 
    360364        "cylinder@hardsphere*sphere+barbell") 
    361     test_models( 
     365    yield build_test( 
    362366        "barbell+cylinder@hardsphere*sphere", 
    363367        "sphere*cylinder@hardsphere+barbell") 
    364368 
     369def test_composite(): 
     370    # type: () -> None 
     371    """Check that model load works""" 
    365372    #Test the the model produces the parameters that we would expect 
    366373    model = load_model("cylinder@hardsphere*sphere") 
  • sasmodels/model_test.py

    r2d81cfe ra69d8cd  
    123123 
    124124        if is_py:  # kernel implemented in python 
    125             test_name = "Model: %s, Kernel: python"%model_name 
     125            test_name = "%s-python"%model_name 
    126126            test_method_name = "test_%s_python" % model_info.id 
    127127            test = ModelTestCase(test_name, model_info, 
     
    135135            # test using dll if desired 
    136136            if 'dll' in loaders or not core.HAVE_OPENCL: 
    137                 test_name = "Model: %s, Kernel: dll"%model_name 
     137                test_name = "%s-dll"%model_name 
    138138                test_method_name = "test_%s_dll" % model_info.id 
    139139                test = ModelTestCase(test_name, model_info, 
     
    146146            # test using opencl if desired and available 
    147147            if 'opencl' in loaders and core.HAVE_OPENCL: 
    148                 test_name = "Model: %s, Kernel: OpenCL"%model_name 
     148                test_name = "%s-opencl"%model_name 
    149149                test_method_name = "test_%s_opencl" % model_info.id 
    150150                # Using dtype=None so that the models that are only 
     
    469469    loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
    470470    tests = make_suite(loaders, ['all']) 
    471     for test_i in tests: 
    472         # In order for nosetest to see the correct test name, need to set 
    473         # the description attribute of the returned function.  Since we 
    474         # can't do this for the returned instance, wrap it in a lambda and 
    475         # set the description on the lambda.  Otherwise we could just do: 
    476         #    yield test_i.run_all 
    477         L = lambda: test_i.run_all() 
    478         L.description = test_i.test_name 
    479         yield L 
     471    for test in tests: 
     472        # In order for nosetest to show the test name, wrap the test.run_all 
     473        # instance in function that takes the test name as a parameter which 
     474        # will be displayed when the test is run. 
     475        yield lambda name: test.run_all(), test.test_name 
    480476 
    481477 
  • sasmodels/sasview_model.py

    r2d81cfe ra69d8cd  
    859859    # type: () -> None 
    860860    """ 
    861     Load and run cylinder model from sas.models.CylinderModel 
     861    Load and run cylinder model as sas-models-CylinderModel 
    862862    """ 
    863863    if not SUPPORT_OLD_STYLE_PLUGINS: 
Note: See TracChangeset for help on using the changeset viewer.