Index: sansmodels/src/sans/models/test/testcase_generator.py
===================================================================
--- sansmodels/src/sans/models/test/testcase_generator.py	(revision ae3ce4eaa593202ebf49122e196897c0d45a25b6)
+++ sansmodels/src/sans/models/test/testcase_generator.py	(revision 36948c921d9d5d3627d4ffc58ffa2c6440002c3a)
@@ -344,4 +344,5 @@
         
         if not self.passed:
+            print "\nFailure:"
             print report.trace
         return self.passed
@@ -353,6 +354,6 @@
         @return: True if passed, False otherwise
     """
-    minval = 0
-    maxval = 20
+    minval = 0.001
+    maxval = 1.0
     # Call run with random input
     import random, math
@@ -368,5 +369,6 @@
             output = model.run([input_value, 2*math.pi*random.random()])            
     except ZeroDivisionError:
-        output = -1
+        print "Error evaluating model %s: %g" % (model.name, input_value)
+        output = None
         
     #print "Eval: %g" % output
@@ -374,6 +376,10 @@
     # Oracle bit - just check that we have a number...
     passed = False
-    if math.fabs(output) >= 0: 
-        passed = True
+    try:
+        if output != None and math.fabs(output) >= 0: 
+            passed = True
+    except:
+        print "---> Could not compute abs val", output, model.name
+        
     
     report = ReportCard()
@@ -382,7 +388,7 @@
         report.n_eval_pass = 1
     else:
-        report.log = "Eval: bad output value %g\n" % output
-        
-    report.trace = "Eval(%g) = %g %i\n" % (input_value, output, passed)    
+        report.log = "Eval: bad output value %s\n" % str(output)
+        
+    report.trace = "Eval(%g) = %s %i\n" % (input_value, str(output), passed)    
     return model, report
 
@@ -395,5 +401,5 @@
     import random, math
     minval = 1
-    maxval = 50
+    maxval = 5
     
     # Choose a parameter to change
@@ -407,5 +413,23 @@
     p_name  = keys[i_param]
     
-    # Chose a value
+    # Choose a value
+    # Check for min/max
+    if hasattr(model, "details"):
+        if model.details.has_key(p_name):
+            if model.details[p_name][1] != None:
+                minval = model.details[p_name][1]
+            if model.details[p_name][2] != None:
+                maxval = model.details[p_name][2]
+        elif model.other.details.has_key(p_name):
+            if model.other.details[p_name][1] != None:
+                minval = model.other.details[p_name][1]
+            if model.other.details[p_name][2] != None:
+                maxval = model.other.details[p_name][2]
+        elif model.operateOn.details.has_key(p_name):
+            if model.operateOn.details[p_name][1] != None:
+                minval = model.operateOn.details[p_name][1]
+            if model.operateOn.details[p_name][2] != None:
+                maxval = model.operateOn.details[p_name][2]
+            
     input_val = random.random()*(maxval-minval)+minval
     model.setParam(p_name, input_val)
@@ -613,7 +637,8 @@
     
     try:
-        value2 = tmp.run(1)
+        value2 = tmp.run(1.1 * (1.0 + random()))
         value2 = float(value2)
     except:
+        value2 = None
         passed = False
     
@@ -628,7 +653,7 @@
         report.log = "Sub: bad output from composite model\n"
 
-    report.trace = "Sub %s (%g - %g = %g) %i\n" % \
+    report.trace = "Sub %s (%g - %g = %s) %i\n" % \
         (model.name, model.run(1), \
-         sub_model.run(1), value2, passed)                
+         sub_model.run(1), str(value2), passed)                
     return tmp, report
 
@@ -647,10 +672,16 @@
     # Oracle bit
     passed = False
-
+    
+    from random import random
+    input_val = 1.1 * (1.0 + random())
+    v1 = None
+    v2 = None
     try:
-        value2 = tmp.run(1)
+        v1 = mul_model.run(input_val)
+        v2 = model.run(input_val)
+        value2 = tmp.run(input_val)
         value2 = float(value2)
-    except:
-        passed = False
+    except ZeroDivisionError:
+        value2 = None
     
     # If we made it this far, we have a float
@@ -664,7 +695,6 @@
         report.log = "Mul: bad output from composite model\n"
         
-    report.trace = "Mul %s (%g * %g = %g) %i\n" % \
-      (model.name, model.run(1), \
-       mul_model.run(1), value2, passed)                
+    report.trace = "Mul %s (%s * %s = %s) %i\n" % \
+      (model.name, str(v1), str(v2), str(value2), passed)                
     return tmp, report
 
@@ -678,6 +708,19 @@
     #div_model = factory.getModel("SphereModel")
     #div_model = factory.getModel(randomModel())
-    div_model = getRandomModelObject()
-    
+
+    from random import random
+    input_val = 1.5 * random()
+    
+    # Find a model that will not evaluate to zero
+    # at the input value
+    try_again = True
+    while try_again:
+        div_model = getRandomModelObject()
+        try:
+            v2 = div_model.run(input_val)
+            try_again = False
+        except:
+            pass
+        
     tmp = model / div_model
     
@@ -685,12 +728,18 @@
     passed = False
     
+    v1 = None
+    v2 = None
     try:
-        from random import random
-        input_val = 1.5 * random()
-        if div_model.run(input_val)==0:
-            print "Skipped (DIV) because denominator evaluated to zero"
-        else:
+        
+        # Check individual models against bad combinations,
+        # which happen from time to time given that all 
+        # parameters are random
+        try:
+            v2 = div_model.run(input_val)
+            v1 = model.run(input_val)
             value2 = tmp.run(input_val)
             value2 = float(value2)
+        except ZeroDivisionError:
+            value2 = None
     except:
         passed = False
@@ -706,7 +755,6 @@
         report.log = "Div: bad output from composite model\n"
         
-    report.trace = "Div %s (%g / %g = %g) %i\n" % \
-        (model.name, model.run(1), \
-         div_model.run(1), value2, passed)                
+    report.trace = "Div %s/%s (%g) = %s / %s = %s %i\n" % \
+      (model.name, div_model.name, input_val, str(v1), str(v2), str(value2), passed)                
     return tmp, report
 
@@ -715,5 +763,5 @@
     #print randomModel()
     g = TestCaseGenerator()
-    g.generateAndRun(2000)
+    g.generateAndRun(20000)
     
     #t = TestCase(filename = "error_1.17721e+009.xml")
