Changeset 3c852d4 in sasmodels


Ignore:
Timestamp:
Oct 10, 2016 7:30:02 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
479d0f3
Parents:
ed10b57
Message:

use public api to access test suite (refs #706)

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/custom/__init__.py

    r2a0c7a6 r3c852d4  
    88to occur without error. 
    99""" 
     10from __future__ import division, print_function 
    1011 
     12import sys 
    1113import os 
    1214from os.path import basename, splitext 
     
    2628    def load_module_from_path(fullname, path): 
    2729        """load module from *path* as *fullname*""" 
     30        # Clear out old definitions, if any 
     31        if fullname in sys.modules: 
     32            del sys.modules[fullname] 
    2833        module = imp.load_source(fullname, os.path.expanduser(path)) 
    2934        #os.unlink(path+"c")  # remove the automatic pyc file 
  • sasmodels/model_test.py

    r897ca7f r3c852d4  
    288288        stream.writeln(tb) 
    289289 
    290     # Check if there are user defined tests. 
    291     # Yes, it is naughty to peek into the structure of the test suite, and 
    292     # to assume that it contains only one test. 
    293     if not suite._tests[0].info.tests: 
    294         stream.writeln("Note: %s has no user defined tests."%model) 
     290    # Warn if there are no user defined tests. 
     291    # Note: the test suite constructed above only has one test in it, which 
     292    # runs through some smoke tests to make sure the model runs, then runs 
     293    # through the input-output pairs given in the model definition file.  To 
     294    # check if any such pairs are defined, therefore, we just need to check if 
     295    # they are in the first test of the test suite.  We do this with an 
     296    # iterator since we don't have direct access to the list of tests in the 
     297    # test suite. 
     298    for test in suite: 
     299        if not test.info.tests: 
     300            stream.writeln("Note: %s has no user defined tests."%model) 
     301        break 
     302    else: 
     303        stream.writeln("Note: no test suite created --- this should never happen") 
    295304 
    296305 
Note: See TracChangeset for help on using the changeset viewer.