Changeset b345c45 in sasview for Invariant


Ignore:
Timestamp:
Jan 9, 2010 10:35:38 AM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
46d50ca
Parents:
277aab4e
Message:

invariant: minor improvements to unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Invariant/test/utest_use_cases.py

    r277aab4e rb345c45  
    99 
    1010class Data1D: 
    11     print "I am not of type Dataloader.Data1D" 
     11    pass 
    1212     
    1313class TestLineFit(unittest.TestCase): 
     
    9696    def test_wrong_data(self): 
    9797        """ test receiving Data1D not of type loader""" 
     98        # That just doesn;t make sense 
    9899         
    99100        wrong_data= Data1D() 
     101        invariant.InvariantCalculator(wrong_data) 
     102         
    100103        try: 
    101104            self.assertRaises(ValueError,invariant.InvariantCalculator(wrong_data)) 
     
    104107        else: raise ValueError, "fail to raise exception when expected" 
    105108     
     109        print "test" 
     110        self.assertRaises(ValueError,invariant.InvariantCalculator, wrong_data ) 
    106111         
    107112    def test_use_case_1(self): 
     
    439444         
    440445        # Get the volume fraction and surface 
    441         try: 
    442             self.assertRaises(RuntimeError, 
    443                               inv.get_volume_fraction_with_error(contrast=2.6e-6)) 
    444         except RuntimeError, msg: 
    445             print "test pass : volume fraction is not defined for this data"+ str(msg) 
    446         else: raise ValueError, "fail to raise exception when expected" 
    447          
    448         try: 
    449             self.assertRaises(RuntimeError, 
    450                  inv.get_surface_with_error(contrast=2.6e-6, porod_const=2)) 
    451         except RuntimeError, msg: 
    452             print "test pass : surface is not defined for this data"+ str(msg) 
    453         else: raise ValueError, "fail to raise exception when expected" 
     446        self.assertRaises(RuntimeError, inv.get_volume_fraction_with_error, 2.6e-6) 
     447         
     448        # Check that an exception is raised when the 'surface' is not defined 
     449        self.assertRaises(RuntimeError, inv.get_surface_with_error, 2.6e-6, 2) 
     450 
    454451        # Test results 
    455452        self.assertAlmostEquals(qstar, 0.0045773,2) 
     453         
    456454         
    457455        
     
    472470         
    473471        # Get the volume fraction and surface 
    474         try: 
    475             self.assertRaises(RuntimeError, 
    476                               inv.get_volume_fraction_with_error(contrast=2.6e-6)) 
    477         except RuntimeError, msg: 
    478             print "test pass : volume fraction is not defined for this data"+ str(msg) 
    479         else: raise ValueError, "fail to raise exception when expected" 
    480          
    481         try: 
    482             self.assertRaises(RuntimeError, 
    483                  inv.get_surface_with_error(contrast=2.6e-6, porod_const=2)) 
    484         except RuntimeError, msg: 
    485             print "test pass : surface is not defined for this data"+ str(msg) 
    486         else: raise ValueError, "fail to raise exception when expected" 
     472        self.assertRaises(RuntimeError, inv.get_volume_fraction_with_error, 2.6e-6) 
     473        self.assertRaises(RuntimeError, inv.get_surface_with_error, 2.6e-6, 2) 
     474         
    487475        # Test results 
    488476        self.assertAlmostEquals(qstar, 0.00460319,3) 
Note: See TracChangeset for help on using the changeset viewer.