예제 #1
0
파일: vsifile.py 프로젝트: zaviazhou/gdal
def vsifile_22():
    # VSIOpenL doesn't set errorno
    gdal.VSIErrorReset()
    if gdal.VSIGetLastErrorNo() != 0:
        gdaltest.post_reason("Expected Err=0 after VSIErrorReset(), got %d" % gdal.VSIGetLastErrorNo())
        return 'fail'

    fp = gdal.VSIFOpenL('tmp/not-existing', 'r')
    if fp is not None:
        gdaltest.post_reason("Expected None from VSIFOpenL")
        return 'fail'
    if gdal.VSIGetLastErrorNo() != 0:
        gdaltest.post_reason("Expected Err=0 from VSIFOpenL, got %d" % gdal.VSIGetLastErrorNo())
        return 'fail'

    # VSIOpenExL does
    fp = gdal.VSIFOpenExL('tmp/not-existing', 'r', 1)
    if fp is not None:
        gdaltest.post_reason("Expected None from VSIFOpenExL")
        return 'fail'
    if gdal.VSIGetLastErrorNo() != 1:
        gdaltest.post_reason("Expected Err=1 from VSIFOpenExL, got %d" % gdal.VSIGetLastErrorNo())
        return 'fail'
    if len(gdal.VSIGetLastErrorMsg()) == 0:
        gdaltest.post_reason("Expected a VSI error message")
        return 'fail'
    gdal.VSIErrorReset()
    if gdal.VSIGetLastErrorNo() != 0:
        gdaltest.post_reason("Expected Err=0 after VSIErrorReset(), got %d" % gdal.VSIGetLastErrorNo())
        return 'fail'

    return 'success'
예제 #2
0
def test_vsifile_22():
    # VSIOpenL doesn't set errorno
    gdal.VSIErrorReset()
    assert gdal.VSIGetLastErrorNo() == 0, \
        ("Expected Err=0 after VSIErrorReset(), got %d" % gdal.VSIGetLastErrorNo())

    fp = gdal.VSIFOpenL('tmp/not-existing', 'r')
    assert fp is None, "Expected None from VSIFOpenL"
    assert gdal.VSIGetLastErrorNo() == 0, \
        ("Expected Err=0 from VSIFOpenL, got %d" % gdal.VSIGetLastErrorNo())

    # VSIOpenExL does
    fp = gdal.VSIFOpenExL('tmp/not-existing', 'r', 1)
    assert fp is None, "Expected None from VSIFOpenExL"
    assert gdal.VSIGetLastErrorNo() == 1, \
        ("Expected Err=1 from VSIFOpenExL, got %d" % gdal.VSIGetLastErrorNo())
    assert len(gdal.VSIGetLastErrorMsg()) != 0, "Expected a VSI error message"
    gdal.VSIErrorReset()
    assert gdal.VSIGetLastErrorNo() == 0, \
        ("Expected Err=0 after VSIErrorReset(), got %d" % gdal.VSIGetLastErrorNo())
예제 #3
0
 def _check_error(self):
     if gdal.VSIGetLastErrorNo() != 0:
         raise SimpleVSIMemFileError(gdal.VSIGetLastErrorMsg())