Changeset 1932


Ignore:
Timestamp:
Oct 16, 2005, 8:30:33 AM (19 years ago)
Author:
ole
Message:

First use of Python warning system

Location:
inundation/pyvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/test_util.py

    r1927 r1932  
    10251025
    10261026
     1027    def test_point_on_line_obsolete(self):
     1028        """Test that obsolete call issues appropriate warning"""
     1029
     1030        #Turn warning into an exception
     1031        import warnings
     1032        warnings.filterwarnings('error')
     1033
     1034        try:
     1035            assert point_on_line( 0, 0.5, 0,1, 0,0 )
     1036        except DeprecationWarning:
     1037            pass
     1038        else:
     1039            msg = 'point_on_line should have issued a DeprecationWarning'
     1040            raise Exception(msg)   
     1041
     1042        warnings.resetwarnings()                         
     1043                         
     1044
    10271045#-------------------------------------------------------------
    10281046if __name__ == "__main__":
  • inundation/pyvolution/util.py

    r1927 r1932  
    55"""
    66
    7 #Soon to be obsoleted here
    8 
    9 
    10 #FIXME: Obsolete this shortcut
     7
     8#FIXME: Deprecate this shortcut
    119from utilities.numerical_tools import ensure_numeric
    1210
    13 
    1411import utilities.polygon
     12from warnings import warn
    1513
    1614def point_on_line(*args, **kwargs):
    1715    """Temporary Interface to new location"""
    1816
    19     print 'point_on_line has moved from util.py.  ',
    20     print 'Please use "from utilities.polygon import point_on_line"'
     17    msg = 'point_on_line has moved from util.py.  '
     18    msg += 'Please use "from utilities.polygon import point_on_line"'
     19    warn(msg, DeprecationWarning)
    2120
    2221    return utilities.polygon.point_on_line(*args, **kwargs)     
Note: See TracChangeset for help on using the changeset viewer.