From 499f2eb9c7e58d30cb5a11ce5d88589a44a4df7b Mon Sep 17 00:00:00 2001 From: Fengting Chen Date: Fri, 19 Oct 2018 11:35:28 -0700 Subject: [PATCH 001/488] Fix the issue by freeing the temporary lobs created by readCLob() and writeCLOB(). Put the temporary lob release together with OCIDescriptorFree(). --- gdal/frmts/georaster/georaster_wrapper.cpp | 16 +++--- gdal/frmts/georaster/oci_wrapper.cpp | 62 +++++++++++++++++++--- gdal/frmts/georaster/oci_wrapper.h | 1 + 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/gdal/frmts/georaster/georaster_wrapper.cpp b/gdal/frmts/georaster/georaster_wrapper.cpp index 0594e700fc8a..201670513f37 100644 --- a/gdal/frmts/georaster/georaster_wrapper.cpp +++ b/gdal/frmts/georaster/georaster_wrapper.cpp @@ -526,7 +526,7 @@ GeoRasterWrapper* GeoRasterWrapper::Open( const char* pszStringId, bool bUpdate // Clean up // ------------------------------------------------------------------- - OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocator); CPLFree( pszXML ); delete poStmt; @@ -966,7 +966,7 @@ bool GeoRasterWrapper::Create( char* pszDescription, sDataTable = szBindRDT; nRasterId = nBindRID; - OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocator); delete poStmt; @@ -3185,13 +3185,13 @@ bool GeoRasterWrapper::SetNoData( int nLayer, const char* pszValue ) if( ! poStmt->Execute() ) { - OCIDescriptorFree( phLocatorR, OCI_DTYPE_LOB ); - OCIDescriptorFree( phLocatorW, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocatorR); + poStmt->FreeLob(phLocatorW); delete poStmt; return false; } - OCIDescriptorFree( phLocatorW, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocatorW); // ------------------------------------------------------------ // Read the XML metadata from db to memory with nodata updates @@ -3206,7 +3206,7 @@ bool GeoRasterWrapper::SetNoData( int nLayer, const char* pszValue ) CPLFree( pszXML ); } - OCIDescriptorFree( phLocatorR, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocatorR); bFlushMetadata = true; delete poStmt; @@ -3596,12 +3596,12 @@ bool GeoRasterWrapper::FlushMetadata() if( ! poStmt->Execute() ) { - OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocator); delete poStmt; return false; } - OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); + poStmt->FreeLob(phLocator); delete poStmt; diff --git a/gdal/frmts/georaster/oci_wrapper.cpp b/gdal/frmts/georaster/oci_wrapper.cpp index da47d888e472..c83daa2709ef 100644 --- a/gdal/frmts/georaster/oci_wrapper.cpp +++ b/gdal/frmts/georaster/oci_wrapper.cpp @@ -1117,15 +1117,19 @@ void OWStatement::WriteCLob( OCILobLocator** pphLocator, char* pszData ) { nNextCol++; - CheckError( OCIDescriptorAlloc( + if (CheckError( OCIDescriptorAlloc( poConnection->hEnv, (void**) pphLocator, OCI_DTYPE_LOB, (size_t) 0, (dvoid **) nullptr), - hError ); + hError )) + { + CPLDebug("OCI", "Error in WriteCLob"); + return; + } - CheckError( OCILobCreateTemporary( + if (CheckError( OCILobCreateTemporary( poConnection->hSvcCtx, poConnection->hError, (OCILobLocator*) *pphLocator, @@ -1134,11 +1138,15 @@ void OWStatement::WriteCLob( OCILobLocator** pphLocator, char* pszData ) (ub1) OCI_TEMP_CLOB, false, OCI_DURATION_SESSION ), - hError ); + hError )) + { + CPLDebug("OCI", "Error in WriteCLob creating temporary lob"); + return; + } ub4 nAmont = (ub4) strlen(pszData); - CheckError( OCILobWrite( + if (CheckError( OCILobWrite( poConnection->hSvcCtx, hError, *pphLocator, @@ -1151,7 +1159,11 @@ void OWStatement::WriteCLob( OCILobLocator** pphLocator, char* pszData ) nullptr, (ub2) 0, (ub1) SQLCS_IMPLICIT ), - hError ); + hError )) + { + CPLDebug("OCI", "Error in WriteCLob writing the lob"); + return; + } } void OWStatement::Define( OCIArray** pphData ) @@ -1583,6 +1595,44 @@ char* OWStatement::ReadCLob( OCILobLocator* phLocator ) return pszBuffer; } +// Free OCIDescriptor for the LOB, if it is temporary lob, it is freed too. +void OWStatement::FreeLob(OCILobLocator* phLocator) +{ + boolean is_temporary; + + if (phLocator == nullptr) + return; + + if( CheckError( OCILobIsTemporary( + poConnection->hEnv, + hError, + phLocator, + &is_temporary), + hError)) + { + CPLDebug("OCI", "OCILobIsTemporary failed"); + OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); + return; + } + + if(is_temporary) + { + if( CheckError( OCILobFreeTemporary( + poConnection->hSvcCtx, + hError, + phLocator), + hError)) + { + CPLDebug("OCI", "OCILobFreeTemporary failed"); + OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); + return; + } + + } + + OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); +} + void OWStatement::BindName( const char* pszName, int* pnData ) { OCIBind* hBind = nullptr; diff --git a/gdal/frmts/georaster/oci_wrapper.h b/gdal/frmts/georaster/oci_wrapper.h index cdb519ae6e9f..03314fb40ff4 100644 --- a/gdal/frmts/georaster/oci_wrapper.h +++ b/gdal/frmts/georaster/oci_wrapper.h @@ -417,6 +417,7 @@ class OWStatement unsigned long ReadBlob( OCILobLocator* phLocator, void* pBuffer, unsigned long nOffset, unsigned long nSize ); + void FreeLob(OCILobLocator* phLocator); char* ReadCLob( OCILobLocator* phLocator ); void WriteCLob( OCILobLocator** pphLocator, char* pszData ); bool WriteBlob( OCILobLocator* phLocator, From b10430acb1303d18052fc20ebc36de01e01398fd Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Thu, 25 Oct 2018 14:49:58 -0500 Subject: [PATCH 002/488] VRT: Fix issue #1048 opening VRT with large number of bands --- gdal/frmts/vrt/vrtdataset.cpp | 59 +++++++++++++++++++++++++++++++++++ gdal/frmts/vrt/vrtdataset.h | 2 ++ gdal/frmts/vrt/vrtsources.cpp | 10 ++++-- gdal/gcore/gdal_proxy.h | 5 +++ gdal/gcore/gdalproxypool.cpp | 10 ++++++ 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/gdal/frmts/vrt/vrtdataset.cpp b/gdal/frmts/vrt/vrtdataset.cpp index 0a6207976fbd..219978c5f9b8 100644 --- a/gdal/frmts/vrt/vrtdataset.cpp +++ b/gdal/frmts/vrt/vrtdataset.cpp @@ -36,6 +36,8 @@ #include #include +#include "gdal_proxy.h" + /*! @cond Doxygen_Suppress */ @@ -1384,6 +1386,59 @@ int VRTDataset::CheckCompatibleForDatasetIO() return nSources != 0; } + +/************************************************************************/ +/* ExpandProxyBands() */ +/************************************************************************/ +/* In ProxyPoolDatasets, by default only one band is initialized. When using + * VRTDataset::IRasterIO and CheckCompatibleForDatasetIO is True, we need to have + * all bands initialized (but only for the last band in the VRTDataset). This function + * assumes CheckCompatibleForDatasetIO() has already been run and returned succesfull. + */ +void VRTDataset::ExpandProxyBands() +{ + VRTSourcedRasterBand * poLastBand = reinterpret_cast(papoBands[nBands - 1]); + + CPLAssert(poLastBand != nullptr); // CheckCompatibleForDatasetIO() + + int nSources = poLastBand->nSources; + + for (int iSource = 0; iSource < nSources; iSource++) + { + VRTSimpleSource* poSource = reinterpret_cast(poLastBand->papoSources[iSource]); + + CPLAssert(poSource != nullptr); // CheckCompatibleForDatasetIO() + + GDALProxyPoolDataset * dataset = dynamic_cast(poSource->GetBand()->GetDataset()); + + if (dataset == nullptr) + { + continue; // only GDALProxyPoolDataset needs to be expanded + } + + if (dataset->GetBands()[0] != nullptr) + { + continue; // first band already set, so just assume all the others are set as well + } + + for (int iBand = 1; iBand <= nBands - 1; iBand++ ) + { + VRTSourcedRasterBand * srcband = reinterpret_cast(papoBands[iBand - 1]); + VRTSimpleSource* src = reinterpret_cast(srcband->papoSources[iSource]); + GDALRasterBand * rasterband = src->GetBand(); + + int nBlockXSize, nBlockYSize; + + rasterband->GetBlockSize(&nBlockXSize, &nBlockYSize); + + dataset->AddSrcBand(iBand, rasterband->GetRasterDataType(), nBlockXSize, nBlockYSize); + } + } +} + + + + /************************************************************************/ /* GetSingleSimpleSource() */ /* */ @@ -1593,6 +1648,10 @@ CPLErr VRTDataset::IRasterIO( GDALRWFlag eRWFlag, if( bLocalCompatibleForDatasetIO && eRWFlag == GF_Read ) { + + // Make sure the expand the last band before using them below + ExpandProxyBands(); + for(int iBandIndex=0; iBandIndex m_apoOverviews; std::vector m_apoOverviewsBak; char **m_papszXMLVRTMetadata; diff --git a/gdal/frmts/vrt/vrtsources.cpp b/gdal/frmts/vrt/vrtsources.cpp index d4f7a02a73ed..5475ec28a0c5 100644 --- a/gdal/frmts/vrt/vrtsources.cpp +++ b/gdal/frmts/vrt/vrtsources.cpp @@ -691,8 +691,14 @@ CPLErr VRTSimpleSource::XMLInit( CPLXMLNode *psSrc, const char *pszVRTPath, // Only the information of rasterBand nSrcBand will be accurate // but that's OK since we only use that band afterwards. - for( int i = 1; i <= nSrcBand; i++ ) - proxyDS->AddSrcBandDescription(eDataType, nBlockXSize, nBlockYSize); + // + // Previously this added a src band for every band <= nSrcBand, but this becomes + // prohibitely expensive for files with a large number of bands. This optimization + // only adds the desired band and the rest of the bands will simply be initialized with a nullptr. + // This assumes no other code here accesses any of the lower bands in the GDALProxyPoolDataset. + // It has been suggested that in addition, we should to try share GDALProxyPoolDataset between multiple + // Simple Sources, which would save on memory for papoBands. For now, that's not implemented. + proxyDS->AddSrcBand(nSrcBand, eDataType, nBlockXSize, nBlockYSize); if( bGetMaskBand ) { diff --git a/gdal/gcore/gdal_proxy.h b/gdal/gcore/gdal_proxy.h index 1d96fe1c5828..d1a8fae689ad 100644 --- a/gdal/gcore/gdal_proxy.h +++ b/gdal/gcore/gdal_proxy.h @@ -245,6 +245,11 @@ class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset void AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize ); + // Used by VRT SimpleSource to add a single GDALProxyPoolRasterBand while + // keeping all other bands initialized to a nullptr. This is under the assumption, + // VRT SimpleSource will not have to access any other bands than the one added. + void AddSrcBand(int nBand, GDALDataType eDataType, int nBlockXSize, + int nBlockYSize ); void FlushCache() override; const char *GetProjectionRef() override; diff --git a/gdal/gcore/gdalproxypool.cpp b/gdal/gcore/gdalproxypool.cpp index 7180b60533be..19d1cf16a936 100644 --- a/gdal/gcore/gdalproxypool.cpp +++ b/gdal/gcore/gdalproxypool.cpp @@ -693,6 +693,16 @@ void GDALProxyPoolDataset::AddSrcBandDescription( GDALDataType eDataType, int nB SetBand(nBands + 1, new GDALProxyPoolRasterBand(this, nBands + 1, eDataType, nBlockXSize, nBlockYSize)); } +/************************************************************************/ +/* AddSrcBand() */ +/************************************************************************/ + +void GDALProxyPoolDataset::AddSrcBand(int nBand, GDALDataType eDataType, int nBlockXSize, int nBlockYSize) +{ + SetBand(nBand, new GDALProxyPoolRasterBand(this, nBand, eDataType, nBlockXSize, nBlockYSize)); +} + + /************************************************************************/ /* RefUnderlyingDataset() */ /************************************************************************/ From d2b9ec539a395c7d64b8cbdf3d8b8892f957522d Mon Sep 17 00:00:00 2001 From: Tamas Szekeres Date: Fri, 26 Oct 2018 21:32:32 +0200 Subject: [PATCH 003/488] MSSQLSpatial: Fix geometry parser with M values (#1051) --- .../mssqlspatial/ogrmssqlgeometryparser.cpp | 99 ++++++++++++++++--- 1 file changed, 83 insertions(+), 16 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryparser.cpp b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryparser.cpp index 16271610c318..bd70c0fb1e28 100644 --- a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryparser.cpp +++ b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryparser.cpp @@ -139,15 +139,31 @@ OGRPoint* OGRMSSQLGeometryParser::ReadPoint(int iShape) { if (nColType == MSSQLCOLTYPE_GEOGRAPHY) { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + return new OGRPoint(ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint), ReadM(iPoint) ); + else if ( chProps & SP_HASZVALUES ) return new OGRPoint( ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint) ); + else if ( chProps & SP_HASMVALUES ) + { + OGRPoint* poPoint = new OGRPoint( ReadY(iPoint), ReadX(iPoint) ); + poPoint->setM( ReadZ(iPoint) ); + return poPoint; + } else return new OGRPoint( ReadY(iPoint), ReadX(iPoint) ); } else { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + return new OGRPoint( ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint), ReadM(iPoint) ); + else if ( chProps & SP_HASZVALUES ) return new OGRPoint( ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) ); + else if ( chProps & SP_HASMVALUES ) + { + OGRPoint* poPoint = new OGRPoint( ReadX(iPoint), ReadY(iPoint) ); + poPoint->setM( ReadZ(iPoint) ); + return poPoint; + } else return new OGRPoint( ReadX(iPoint), ReadY(iPoint) ); } @@ -199,15 +215,23 @@ OGRLineString* OGRMSSQLGeometryParser::ReadLineString(int iShape) { if (nColType == MSSQLCOLTYPE_GEOGRAPHY) { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + poLineString->setPoint(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint), ReadM(iPoint) ); + else if ( chProps & SP_HASZVALUES ) poLineString->setPoint(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint) ); + else if ( chProps & SP_HASMVALUES ) + poLineString->setPointM(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint) ); else poLineString->setPoint(i, ReadY(iPoint), ReadX(iPoint) ); } else { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + poLineString->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint), ReadM(iPoint) ); + else if ( chProps & SP_HASZVALUES ) poLineString->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) ); + else if ( chProps & SP_HASMVALUES ) + poLineString->setPointM(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) ); else poLineString->setPoint(i, ReadX(iPoint), ReadY(iPoint) ); } @@ -265,15 +289,23 @@ OGRPolygon* OGRMSSQLGeometryParser::ReadPolygon(int iShape) { if (nColType == MSSQLCOLTYPE_GEOGRAPHY) { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + poRing->setPoint(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint), ReadM(iPoint) ); + else if ( chProps & SP_HASZVALUES ) poRing->setPoint(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint) ); + else if (chProps & SP_HASMVALUES) + poRing->setPointM(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint) ); else poRing->setPoint(i, ReadY(iPoint), ReadX(iPoint) ); } else { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint), ReadM(iPoint) ); + else if ( chProps & SP_HASZVALUES ) poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) ); + else if ( chProps & SP_HASMVALUES ) + poRing->setPointM(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) ); else poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint) ); } @@ -380,12 +412,13 @@ OGRErr OGRMSSQLGeometryParser::ParseSqlGeometry(unsigned char* pszInput, chProps = ReadByte(5); - if ( chProps & SP_HASMVALUES ) - nPointSize = 32; - else if ( chProps & SP_HASZVALUES ) - nPointSize = 24; - else - nPointSize = 16; + nPointSize = 16; + + if (chProps & SP_HASZVALUES) + nPointSize += 8; + + if (chProps & SP_HASMVALUES) + nPointSize += 8; if ( chProps & SP_ISSINGLEPOINT ) { @@ -400,15 +433,29 @@ OGRErr OGRMSSQLGeometryParser::ParseSqlGeometry(unsigned char* pszInput, if (nColType == MSSQLCOLTYPE_GEOGRAPHY) { - if (chProps & SP_HASZVALUES) + if ((chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES)) + *poGeom = new OGRPoint(ReadY(0), ReadX(0), ReadZ(0), ReadM(0)); + else if (chProps & SP_HASZVALUES) *poGeom = new OGRPoint(ReadY(0), ReadX(0), ReadZ(0)); + else if (chProps & SP_HASMVALUES) + { + *poGeom = new OGRPoint(ReadY(0), ReadX(0)); + ((OGRPoint*)(*poGeom))->setM(ReadZ(0)); + } else *poGeom = new OGRPoint(ReadY(0), ReadX(0)); } else { - if (chProps & SP_HASZVALUES) + if ((chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES)) + *poGeom = new OGRPoint(ReadX(0), ReadY(0), ReadZ(0), ReadM(0)); + else if (chProps & SP_HASZVALUES) *poGeom = new OGRPoint(ReadX(0), ReadY(0), ReadZ(0)); + else if (chProps & SP_HASMVALUES) + { + *poGeom = new OGRPoint(ReadX(0), ReadY(0)); + ((OGRPoint*)(*poGeom))->setM(ReadZ(0)); + } else *poGeom = new OGRPoint(ReadX(0), ReadY(0)); } @@ -429,11 +476,21 @@ OGRErr OGRMSSQLGeometryParser::ParseSqlGeometry(unsigned char* pszInput, if (nColType == MSSQLCOLTYPE_GEOGRAPHY) { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + { + line->setPoint(0, ReadY(0), ReadX(0), ReadZ(0), ReadM(0)); + line->setPoint(1, ReadY(1), ReadX(1), ReadZ(1), ReadM(1)); + } + else if ( chProps & SP_HASZVALUES ) { line->setPoint(0, ReadY(0), ReadX(0), ReadZ(0)); line->setPoint(1, ReadY(1), ReadX(1), ReadZ(1)); } + else if ( chProps & SP_HASMVALUES ) + { + line->setPointM(0, ReadY(0), ReadX(0), ReadZ(0)); + line->setPointM(1, ReadY(1), ReadX(1), ReadZ(1)); + } else { line->setPoint(0, ReadY(0), ReadX(0)); @@ -442,11 +499,21 @@ OGRErr OGRMSSQLGeometryParser::ParseSqlGeometry(unsigned char* pszInput, } else { - if ( chProps & SP_HASZVALUES ) + if ( (chProps & SP_HASZVALUES) && (chProps & SP_HASMVALUES) ) + { + line->setPoint(0, ReadX(0), ReadY(0), ReadZ(0), ReadM(0)); + line->setPoint(1, ReadX(1), ReadY(1), ReadZ(1), ReadM(1)); + } + else if ( chProps & SP_HASZVALUES ) { line->setPoint(0, ReadX(0), ReadY(0), ReadZ(0)); line->setPoint(1, ReadX(1), ReadY(1), ReadZ(1)); } + else if ( chProps & SP_HASMVALUES ) + { + line->setPointM(0, ReadX(0), ReadY(0), ReadZ(0)); + line->setPointM(1, ReadX(1), ReadY(1), ReadZ(1)); + } else { line->setPoint(0, ReadX(0), ReadY(0)); From 4b906b2dfd49c259e2bd3c53aece4b5a6139e2c9 Mon Sep 17 00:00:00 2001 From: Jerry Faust Date: Sun, 28 Oct 2018 10:08:53 -0700 Subject: [PATCH 004/488] MSSQLSpatial: driver does not assign new ID following an INSERT (fixes #1052) (#1053) --- autotest/ogr/ogr_mssqlspatial.py | 8 ++++++++ .../ogrmssqlspatialtablelayer.cpp | 20 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/autotest/ogr/ogr_mssqlspatial.py b/autotest/ogr/ogr_mssqlspatial.py index a403b196cb65..733c1e70e07b 100755 --- a/autotest/ogr/ogr_mssqlspatial.py +++ b/autotest/ogr/ogr_mssqlspatial.py @@ -225,6 +225,14 @@ def ogr_mssqlspatial_4(): 'from file "' + wkt_filename + '"') return 'fail' + ###################################################################### + # Before reading back the record, verify that the newly added feature + # is returned from the CreateFeature method with a newly assigned FID. + + if dst_feat.GetFID() == -1: + gdaltest.post_reason('Assigned FID was not returned in the new feature') + return 'fail' + ###################################################################### # Read back the feature and get the geometry. diff --git a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp index ce93c58e8129..0cbf181929cd 100644 --- a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp @@ -2060,11 +2060,18 @@ OGRErr OGRMSSQLSpatialTableLayer::ICreateFeature( OGRFeature *poFeature ) if (oStatement.GetCommand()[strlen(oStatement.GetCommand()) - 1] != ']') { /* no fields were added */ - oStatement.Appendf( "DEFAULT VALUES;" ); + if (nFID == OGRNullFID && pszFIDColumn != nullptr && bIsIdentityFid) + oStatement.Appendf(" OUTPUT INSERTED.[%s] DEFAULT VALUES;", GetFIDColumn()); + else + oStatement.Appendf( "DEFAULT VALUES;" ); } else { - oStatement.Appendf( ") VALUES (" ); + /* prepend VALUES section */ + if (nFID == OGRNullFID && pszFIDColumn != nullptr && bIsIdentityFid) + oStatement.Appendf(") OUTPUT INSERTED.[%s] VALUES (", GetFIDColumn()); + else + oStatement.Appendf( ") VALUES (" ); /* Set the geometry */ bNeedComma = FALSE; @@ -2259,6 +2266,15 @@ OGRErr OGRMSSQLSpatialTableLayer::ICreateFeature( OGRFeature *poFeature ) return OGRERR_FAILURE; } + else if(nFID == OGRNullFID && pszFIDColumn != nullptr && bIsIdentityFid) + { + // fetch new ID and set it into the feature + if (oStatement.Fetch()) + { + GIntBig newID = atoll(oStatement.GetColData(0)); + poFeature->SetFID(newID); + } + } for( i = 0; i < bind_num; i++ ) CPLFree(bind_buffer[i]); From 59411f1decb8a12fb34a595470e51df735b0692e Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 29 Oct 2018 14:18:11 +0900 Subject: [PATCH 005/488] autotest: gdriver_loslas: see inside jar file for downloaded data Fix loslas test failure not to found test data. Downloaded file NADCON.zip has nadcon.jar for grids data. Test script try to unzip NADCON.zip and nadcon.jar to extract test data. Signed-off-by: Hiroshi Miura --- autotest/gdrivers/loslas.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/autotest/gdrivers/loslas.py b/autotest/gdrivers/loslas.py index 0eea8f932533..f0e7d19e5dea 100755 --- a/autotest/gdrivers/loslas.py +++ b/autotest/gdrivers/loslas.py @@ -48,7 +48,15 @@ def loslas_online_1(): except OSError: return 'skip' - tst = gdaltest.GDALTest('LOSLAS', '/vsizip/tmp/cache/NADCON.zip/wyhpgn.los', 1, 0, filename_absolute=1) + try: + gdaltest.unzip('tmp/cache/NADCON', 'tmp/cache/NADCON.zip') + os.stat('tmp/cache/NADCON/nadcon.jar') + gdaltest.unzip('tmp/cache/NADCON', 'tmp/cache/NADCON/nadcon.jar') + os.stat('tmp/cache/NADCON/grids/wyhpgn.los') + except OSError: + return 'skip' + + tst = gdaltest.GDALTest('LOSLAS', 'tmp/cache/NADCON/grids/wyhpgn.los', 1, 0, filename_absolute=1) gt = (-111.625, 0.25, 0.0, 45.625, 0.0, -0.25) stats = (-0.0080000003799796, 0.031125999987125001, 0.0093017323318172005, 0.0075646520354096004) return tst.testOpen(check_gt=gt, check_stat=stats, check_prj='WGS84') From d998b440f368dd43bde5db99445542c31604eb41 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 29 Oct 2018 09:21:32 +0900 Subject: [PATCH 006/488] autotest: update environment variable requirements - Require GDAL_DONWLOAD_TEST_DATA=YES if want to enable it. It also accept NO for explicitly disable download. it is consistent behavior with GDAL_RUN_SLOW_TESTS - Update message when GDAL_RUN_SLOW_TESTS and/or GDAL_DOWNLOAD_TEST_DATA is set to NO or undefined as it is so. - introduce gdaltest.download_test_data() for consistent env detection - update netcdf test notice for environment variable Signed-off-by: Hiroshi Miura --- autotest/gdrivers/netcdf_cf.py | 4 ++-- autotest/pymod/gdaltest.py | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/autotest/gdrivers/netcdf_cf.py b/autotest/gdrivers/netcdf_cf.py index 686be05b51fd..87276857a1e8 100755 --- a/autotest/gdrivers/netcdf_cf.py +++ b/autotest/gdrivers/netcdf_cf.py @@ -102,9 +102,9 @@ def netcdf_cf_setup(): return 'success' # skip http method if GDAL_DOWNLOAD_TEST_DATA and GDAL_RUN_SLOW_TESTS are not defined - if 'GDAL_DOWNLOAD_TEST_DATA' not in os.environ: + if not gdaltest.download_test_data(): print('NOTICE: skipping netcdf CF compliance checks') - print('to enable remote http checker script, define GDAL_DOWNLOAD_TEST_DATA') + print('to enable remote http checker script, define GDAL_DOWNLOAD_TEST_DATA=YES') return 'success' if not gdaltest.run_slow_tests(): diff --git a/autotest/pymod/gdaltest.py b/autotest/pymod/gdaltest.py index 72b078d37bc0..4f78f1b146de 100644 --- a/autotest/pymod/gdaltest.py +++ b/autotest/pymod/gdaltest.py @@ -247,9 +247,9 @@ def summarize(): else: print('Duration: %02.2fs' % duration) if count_skipped_tests_download != 0: - print('As GDAL_DOWNLOAD_TEST_DATA environment variable is not defined, %d tests relying on data to downloaded from the Web have been skipped' % count_skipped_tests_download) + print('As GDAL_DOWNLOAD_TEST_DATA environment variable is not defined or set to NO, %d tests relying on data to downloaded from the Web have been skipped' % count_skipped_tests_download) if count_skipped_tests_slow != 0: - print('As GDAL_RUN_SLOW_TESTS environment variable is not defined, %d "slow" tests have been skipped' % count_skipped_tests_slow) + print('As GDAL_RUN_SLOW_TESTS environment variable is not defined or set to NO, %d "slow" tests have been skipped' % count_skipped_tests_slow) print('') sys.path.append('gcore') @@ -1318,12 +1318,11 @@ def download_file(url, filename=None, download_size=-1, force_download=False, ma elif filename.startswith(base_dir + '/'): filename = filename[len(base_dir + '/'):] - global count_skipped_tests_download try: os.stat(base_dir + '/' + filename) return True except OSError: - if 'GDAL_DOWNLOAD_TEST_DATA' in os.environ or force_download: + if force_download or download_test_data(): val = None start_time = time.time() try: @@ -1390,9 +1389,6 @@ def download_file(url, filename=None, download_size=-1, force_download=False, ma print('Cannot write %s' % (filename)) return False else: - if count_skipped_tests_download == 0: - print('As GDAL_DOWNLOAD_TEST_DATA environment variable is not defined, some tests relying on data to downloaded from the Web will be skipped') - count_skipped_tests_download = count_skipped_tests_download + 1 return False @@ -1659,16 +1655,28 @@ def neginf(): return -1e400 ############################################################################### -# Has the user requested to run the slow tests +# Has the user requested to dowload test data +def download_test_data(): + global count_skipped_tests_download + val = gdal.GetConfigOption('GDAL_DOWNLOAD_TEST_DATA', None) + if val != 'yes' and val != 'YES': + if count_skipped_tests_download == 0: + print('As GDAL_DOWNLOAD_TEST_DATA environment variable is not defined or set to NO, some tests relying on data to downloaded from the Web will be skipped') + count_skipped_tests_download = count_skipped_tests_download + 1 + return False + return True + +############################################################################### +# Has the user requested to run the slow tests def run_slow_tests(): global count_skipped_tests_slow val = gdal.GetConfigOption('GDAL_RUN_SLOW_TESTS', None) if val != 'yes' and val != 'YES': if count_skipped_tests_slow == 0: - print('As GDAL_RUN_SLOW_TESTS environment variable is not defined, some "slow" tests will be skipped') + print('As GDAL_RUN_SLOW_TESTS environment variable is not defined or set to NO, some "slow" tests will be skipped') count_skipped_tests_slow = count_skipped_tests_slow + 1 return False From 98906f740473968e60649eaf73b0138d814062bb Mon Sep 17 00:00:00 2001 From: Hugo Mercier Date: Mon, 29 Oct 2018 13:53:48 +0100 Subject: [PATCH 007/488] Fix an off-by-one --- autotest/cpp/test_marching_squares_contour.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autotest/cpp/test_marching_squares_contour.cpp b/autotest/cpp/test_marching_squares_contour.cpp index ee53dfccbb97..a682e4d49459 100644 --- a/autotest/cpp/test_marching_squares_contour.cpp +++ b/autotest/cpp/test_marching_squares_contour.cpp @@ -113,11 +113,11 @@ class TestRingAppender // we represent them with a vector, we need to find a common "first" point Point pfirst = aRing[0]; size_t offset = 0; - for ( ; pfirst != bRing[offset]; offset++ ) { - if ( offset >= bRing.size() ) { - // can't find a common point - return false; - } + while ( offset < bRing.size() && pfirst != bRing[offset] ) + offset++; + if ( offset >= bRing.size() ) { + // can't find a common point + return false; } // now compare each point of the two rings for ( size_t i = 0; i < aRing.size(); i++ ) { From 03663aa9cc098380fe5420faa4f424c3dac45a08 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 29 Oct 2018 23:18:12 +0100 Subject: [PATCH 008/488] GeoJSON: add partial support for field names differing by case (fixes #1057) - Should work on the reading and writing side of the GeoJSON driver itself - Some support on the writing side of ogr2ogr, sufficient for GeoJSON->GeoJSON conversion case - ... but a lot/most other places in GDAL assume case insensitivity --- autotest/ogr/ogr_geojson.py | 22 +++++++++++++ gdal/apps/ogr2ogr_lib.cpp | 22 +++++++++---- gdal/ogr/ogr_feature.h | 1 + gdal/ogr/ogrfeaturedefn.cpp | 31 +++++++++++++++++++ .../ogrsf_frmts/geojson/ogrgeojsonreader.cpp | 24 +++++++------- .../geojson/ogrgeojsonwritelayer.cpp | 2 +- .../ogrsf_frmts/geojson/ogrgeojsonwriter.cpp | 6 ++-- 7 files changed, 87 insertions(+), 21 deletions(-) diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index 0615b49d832e..2116d0db7596 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -4187,6 +4187,27 @@ def ogr_esrijson_without_geometryType(): return 'success' + +############################################################################### + + +def ogr_geojson_read_fields_with_different_case(): + + ds = ogr.Open("""{ +"type": "FeatureCollection", +"features": [ +{ "type": "Feature", "id": "my_id", "geometry": null, "properties": + { "ID": "MY_ID", "x": "foo", "X": "FOO"} } +]}""") + + lyr = ds.GetLayer(0) + f = lyr.GetNextFeature() + if f.GetField(0) != 'my_id' or f.GetField(1) != 'MY_ID' or f.GetField(2) != 'foo' or f.GetField(3) != 'FOO': + f.DumpReadable() + return 'fail' + + return 'success' + ############################################################################### @@ -4300,6 +4321,7 @@ def ogr_geojson_cleanup(): ogr_geojson_append_flush, ogr_geojson_empty_geometrycollection, ogr_esrijson_without_geometryType, + ogr_geojson_read_fields_with_different_case, ogr_geojson_cleanup] if __name__ == '__main__': diff --git a/gdal/apps/ogr2ogr_lib.cpp b/gdal/apps/ogr2ogr_lib.cpp index 7726989d8f2d..cb357f5802db 100644 --- a/gdal/apps/ogr2ogr_lib.cpp +++ b/gdal/apps/ogr2ogr_lib.cpp @@ -3930,6 +3930,16 @@ TargetLayerInfo* SetupTargetLayer::Setup(OGRLayer* poSrcLayer, { int nDstFieldCount = poDstFDefn ? poDstFDefn->GetFieldCount() : 0; + const bool caseInsensitive = + !EQUAL(m_poDstDS->GetDriver()->GetDescription(), "GeoJSON"); + auto formatName = [caseInsensitive](const char* name) { + if( caseInsensitive ) { + return CPLString(name).toupper(); + } else { + return CPLString(name); + } + }; + /* Save the map of existing fields, before creating new ones */ /* This helps when converting a source layer that has duplicated field names */ /* which is a bad idea */ @@ -3938,7 +3948,7 @@ TargetLayerInfo* SetupTargetLayer::Setup(OGRLayer* poSrcLayer, for( int iField = 0; iField < nDstFieldCount; iField++ ) { const char* pszFieldName = poDstFDefn->GetFieldDefn(iField)->GetNameRef(); - CPLString osUpperFieldName(CPLString(pszFieldName).toupper()); + CPLString osUpperFieldName(formatName(pszFieldName)); oSetDstFieldNames.insert(osUpperFieldName); if( oMapPreExistingFields.find(osUpperFieldName) == oMapPreExistingFields.end() ) @@ -3976,7 +3986,7 @@ TargetLayerInfo* SetupTargetLayer::Setup(OGRLayer* poSrcLayer, for( int i = 0; i < poSrcFDefn->GetFieldCount(); i++ ) { oSetSrcFieldNames.insert( - CPLString(poSrcFDefn->GetFieldDefn(i)->GetNameRef()).toupper()); + formatName(poSrcFDefn->GetFieldDefn(i)->GetNameRef())); } for( size_t i = 0; i < anSrcFieldIndices.size(); i++ ) @@ -4003,7 +4013,7 @@ TargetLayerInfo* SetupTargetLayer::Setup(OGRLayer* poSrcLayer, /* The field may have been already created at layer creation */ std::map::iterator oIter = - oMapPreExistingFields.find(CPLString(oFieldDefn.GetNameRef()).toupper()); + oMapPreExistingFields.find(formatName(oFieldDefn.GetNameRef())); if( oIter != oMapPreExistingFields.end() ) { panMap[iField] = oIter->second; @@ -4014,12 +4024,12 @@ TargetLayerInfo* SetupTargetLayer::Setup(OGRLayer* poSrcLayer, /* In case the field name already exists in the target layer, */ /* build a unique field name */ if( oSetDstFieldNames.find( - CPLString(oFieldDefn.GetNameRef()).toupper()) != + formatName(oFieldDefn.GetNameRef())) != oSetDstFieldNames.end() ) { int nTry = 1; CPLString osTmpNameRaddixUC(oFieldDefn.GetNameRef()); - osTmpNameRaddixUC.toupper(); + osTmpNameRaddixUC = formatName(osTmpNameRaddixUC); CPLString osTmpNameUC = osTmpNameRaddixUC; osTmpNameUC.reserve(osTmpNameUC.size() + 10); while( true ) @@ -4069,7 +4079,7 @@ TargetLayerInfo* SetupTargetLayer::Setup(OGRLayer* poSrcLayer, "Field '%s' already exists. Renaming it as '%s'", poSrcFieldDefn->GetNameRef(), pszNewFieldName); } - oSetDstFieldNames.insert(CPLString(pszNewFieldName).toupper()); + oSetDstFieldNames.insert(formatName(pszNewFieldName)); } panMap[iField] = nDstFieldCount; diff --git a/gdal/ogr/ogr_feature.h b/gdal/ogr/ogr_feature.h index be3f7856d34a..572a5cff487a 100644 --- a/gdal/ogr/ogr_feature.h +++ b/gdal/ogr/ogr_feature.h @@ -284,6 +284,7 @@ class CPL_DLL OGRFeatureDefn virtual OGRFieldDefn *GetFieldDefn( int i ); virtual const OGRFieldDefn *GetFieldDefn( int i ) const; virtual int GetFieldIndex( const char * ) const; + int GetFieldIndexCaseSensitive( const char * ) const; virtual void AddFieldDefn( OGRFieldDefn * ); virtual OGRErr DeleteFieldDefn( int iField ); diff --git a/gdal/ogr/ogrfeaturedefn.cpp b/gdal/ogr/ogrfeaturedefn.cpp index 2b926bae15c4..ea0f9423c955 100644 --- a/gdal/ogr/ogrfeaturedefn.cpp +++ b/gdal/ogr/ogrfeaturedefn.cpp @@ -1228,6 +1228,37 @@ int OGRFeatureDefn::GetFieldIndex( const char * pszFieldName ) const return -1; } +/************************************************************************/ +/* GetFieldIndexCaseSensitive() */ +/************************************************************************/ + +/** + * \brief Find field by name, in a case sensitive way. + * + * The field index of the first field matching the passed field name is returned. + * + * @param pszFieldName the field name to search for. + * + * @return the field index, or -1 if no match found. + */ + +int OGRFeatureDefn::GetFieldIndexCaseSensitive( const char * pszFieldName ) const + +{ + GetFieldCount(); + for( int i = 0; i < nFieldCount; i++ ) + { + const OGRFieldDefn* poFDefn = GetFieldDefn(i); + if( poFDefn != nullptr && + strcmp(pszFieldName, poFDefn->GetNameRef() ) == 0 ) + { + return i; + } + } + + return -1; +} + /************************************************************************/ /* OGR_FD_GetFieldIndex() */ /************************************************************************/ diff --git a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp index cb8c62d23d06..1ff9234711b8 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +++ b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp @@ -1476,7 +1476,7 @@ void OGRGeoJSONBaseReader::FinalizeLayerDefn(OGRLayer* poLayer, if( !bFeatureLevelIdAsFID_ ) { - const int idx = poLayerDefn->GetFieldIndex( "id" ); + const int idx = poLayerDefn->GetFieldIndexCaseSensitive( "id" ); if( idx >= 0 ) { OGRFieldDefn* poFDefn = poLayerDefn->GetFieldDefn(idx); @@ -1535,7 +1535,7 @@ void OGRGeoJSONReaderAddOrUpdateField( return; } - int nIndex = poDefn->GetFieldIndex(pszKey); + int nIndex = poDefn->GetFieldIndexCaseSensitive(pszKey); if( nIndex < 0 ) { OGRFieldSubType eSubType; @@ -1787,7 +1787,7 @@ bool OGRGeoJSONBaseReader::GenerateFeatureDefn( OGRLayer* poLayer, json_object* poObjId = OGRGeoJSONFindMemberByName( poObj, "id" ); if( poObjId ) { - const int nIdx = poDefn->GetFieldIndex( "id" ); + const int nIdx = poDefn->GetFieldIndexCaseSensitive( "id" ); if( nIdx < 0 ) { if( json_object_get_type(poObjId) == json_type_int ) @@ -1937,7 +1937,7 @@ bool OGRGeoJSONBaseReader::GenerateFeatureDefn( OGRLayer* poLayer, it.entry = nullptr; json_object_object_foreachC( poObjProps, it ) { - int nFldIndex = poDefn->GetFieldIndex( it.key ); + int nFldIndex = poDefn->GetFieldIndexCaseSensitive( it.key ); if( -1 == nFldIndex && !bIsGeocouchSpatiallistFormat ) { // Detect the special kind of GeoJSON output by a spatiallist of @@ -1970,7 +1970,7 @@ bool OGRGeoJSONBaseReader::GenerateFeatureDefn( OGRLayer* poLayer, "TRUE")); if( bFlattenGeocouchSpatiallistFormat ) { - poDefn->DeleteFieldDefn(poDefn->GetFieldIndex("type")); + poDefn->DeleteFieldDefn(poDefn->GetFieldIndexCaseSensitive("type")); bIsGeocouchSpatiallistFormat = true; return GenerateFeatureDefn(poLayer, poObj); } @@ -2008,7 +2008,7 @@ bool OGRGeoJSONBaseReader::GenerateFeatureDefn( OGRLayer* poLayer, strcmp(it.key, "bbox") != 0 && strcmp(it.key, "center") != 0 ) { - int nFldIndex = poDefn->GetFieldIndex( it.key ); + int nFldIndex = poDefn->GetFieldIndexCaseSensitive( it.key ); if( -1 == nFldIndex ) { OGRGeoJSONReaderAddOrUpdateField(poDefn, it.key, it.val, @@ -2124,7 +2124,8 @@ static void OGRGeoJSONReaderSetFieldNestedAttribute( OGRLayer* poLayer, } else { - const int nField = poFeature->GetFieldIndex(osAttrName); + const int nField = poFeature->GetDefnRef()-> + GetFieldIndexCaseSensitive(osAttrName); OGRGeoJSONReaderSetField(poLayer, poFeature, nField, osAttrName, it.val, false, 0); } @@ -2292,7 +2293,8 @@ OGRFeature* OGRGeoJSONBaseReader::ReadFeature( OGRLayer* poLayer, { CPLAssert( nullptr != poObj ); - OGRFeature* poFeature = new OGRFeature( poLayer->GetLayerDefn() ); + OGRFeatureDefn* poFDefn = poLayer->GetLayerDefn(); + OGRFeature* poFeature = new OGRFeature( poFDefn ); if( bStoreNativeData_ ) { @@ -2337,7 +2339,7 @@ OGRFeature* OGRGeoJSONBaseReader::ReadFeature( OGRLayer* poLayer, it.entry = nullptr; json_object_object_foreachC( poObjProps, it ) { - const int nField = poFeature->GetFieldIndex(it.key); + const int nField = poFDefn->GetFieldIndexCaseSensitive(it.key); if( nField < 0 && !( bFlattenNestedAttributes_ && it.val != nullptr && json_object_get_type(it.val) == json_type_object) ) @@ -2362,7 +2364,7 @@ OGRFeature* OGRGeoJSONBaseReader::ReadFeature( OGRLayer* poLayer, it.entry = nullptr; json_object_object_foreachC( poObj, it ) { - const int nFldIndex = poFeature->GetFieldIndex(it.key); + const int nFldIndex = poFDefn->GetFieldIndexCaseSensitive(it.key); if( nFldIndex >= 0 ) { if( it.val ) @@ -2390,7 +2392,7 @@ OGRFeature* OGRGeoJSONBaseReader::ReadFeature( OGRLayer* poLayer, /* -------------------------------------------------------------------- */ else if( nullptr != poObjId ) { - const int nIdx = poLayer->GetLayerDefn()->GetFieldIndex( "id" ); + const int nIdx = poFDefn->GetFieldIndexCaseSensitive( "id" ); if( nIdx >= 0 && !poFeature->IsFieldSet(nIdx) ) { poFeature->SetField(nIdx, json_object_get_string(poObjId)); diff --git a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp index ea2525d5e5a3..8dcd788e8e1c 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp @@ -290,7 +290,7 @@ OGRErr OGRGeoJSONWriteLayer::ICreateFeature( OGRFeature* poFeature ) OGRErr OGRGeoJSONWriteLayer::CreateField( OGRFieldDefn* poField, int /* bApproxOK */ ) { - if( poFeatureDefn_->GetFieldIndex(poField->GetNameRef()) >= 0 ) + if( poFeatureDefn_->GetFieldIndexCaseSensitive(poField->GetNameRef()) >= 0 ) { CPLDebug( "GeoJSON", "Field '%s' already present in schema", poField->GetNameRef() ); diff --git a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp index 8ea788192411..89e3d12f0bb8 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp +++ b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp @@ -636,7 +636,7 @@ json_object* OGRGeoJSONWriteFeature( OGRFeature* poFeature, if( it.val != nullptr ) { - int nIdx = poFeature->GetFieldIndex("id"); + int nIdx = poFeature->GetDefnRef()->GetFieldIndexCaseSensitive("id"); if( eType == json_type_string && nIdx >= 0 && poFeature->GetFieldDefnRef(nIdx)->GetType() == OFTString && @@ -678,7 +678,7 @@ json_object* OGRGeoJSONWriteFeature( OGRFeature* poFeature, /* -------------------------------------------------------------------- */ if( !oOptions.osIDField.empty() ) { - int nIdx = poFeature->GetFieldIndex(oOptions.osIDField); + int nIdx = poFeature->GetDefnRef()->GetFieldIndexCaseSensitive(oOptions.osIDField); if( nIdx >= 0 ) { if( (oOptions.bForceIDFieldType && @@ -797,7 +797,7 @@ json_object* OGRGeoJSONWriteAttributes( OGRFeature* poFeature, OGRFeatureDefn* poDefn = poFeature->GetDefnRef(); const int nIDField = !oOptions.osIDField.empty() ? - poFeature->GetFieldIndex(oOptions.osIDField) : -1; + poDefn->GetFieldIndexCaseSensitive(oOptions.osIDField) : -1; const int nFieldCount = poDefn->GetFieldCount(); for( int nField = 0; nField < nFieldCount; ++nField ) From e6e6ac477f8cbb8c817135caaf1154c3c6989b0c Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Tue, 30 Oct 2018 21:33:31 +0900 Subject: [PATCH 009/488] autotest: fix UnicodeEncodeError when test fails in python2 When calling ogr_gmlas.py test and its test fails, python warns UnicodeEncodeError instead of showing test result. Signed-off-by: Hiroshi Miura --- autotest/ogr/ogr_gmlas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotest/ogr/ogr_gmlas.py b/autotest/ogr/ogr_gmlas.py index d5dc2acf00e9..de19582f2890 100755 --- a/autotest/ogr/ogr_gmlas.py +++ b/autotest/ogr/ogr_gmlas.py @@ -75,7 +75,7 @@ def compare_ogrinfo_output(gmlfile, reffile, options=''): if ret != expected: gdaltest.post_reason('fail') print('Got:') - print(ret) + print(ret.encode('utf-8')) open(tmpfilename, 'wb').write(ret.encode('utf-8')) print('Diff:') os.system('diff -u ' + reffile + ' ' + tmpfilename) From 5ed09343b361b78ca5dc2fb55ec882be926e515e Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 30 Oct 2018 18:29:51 +0100 Subject: [PATCH 010/488] Shape: avoid being dependent on correctness of file size field in .shp. Fixes https://lists.osgeo.org/pipermail/gdal-dev/2018-October/049218.html --- gdal/ogr/ogrsf_frmts/shape/shpopen.c | 52 +++++++++++++++------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/shape/shpopen.c b/gdal/ogr/ogrsf_frmts/shape/shpopen.c index 81b245e57cd0..b2d0f5c2f2fc 100644 --- a/gdal/ogr/ogrsf_frmts/shape/shpopen.c +++ b/gdal/ogr/ogrsf_frmts/shape/shpopen.c @@ -2151,33 +2151,35 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) /* Before allocating too much memory, check that the file is big enough */ /* and do not trust the file size in the header the first time we */ /* need to allocate more than 10 MB */ - if( nNewBufSize >= 10 * 1024 * 1024 && - psSHP->nBufSize < 10 * 1024 * 1024 ) - { - SAOffset nFileSize; - psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 2 ); - nFileSize = psSHP->sHooks.FTell(psSHP->fpSHP); - if( nFileSize >= UINT_MAX ) - psSHP->nFileSize = UINT_MAX; - else - psSHP->nFileSize = STATIC_CAST(unsigned int, nFileSize); - } - - if( psSHP->panRecOffset[hEntity] >= psSHP->nFileSize || - /* We should normally use nEntitySize instead of*/ - /* psSHP->panRecSize[hEntity] in the below test, but because of */ - /* the case of non conformant .shx files detailed a bit below, */ - /* let be more tolerant */ - psSHP->panRecSize[hEntity] > psSHP->nFileSize - psSHP->panRecOffset[hEntity] ) + if( nNewBufSize >= 10 * 1024 * 1024 ) { - char str[128]; - snprintf( str, sizeof(str), - "Error in fread() reading object of size %d at offset %u from .shp file", - nEntitySize, psSHP->panRecOffset[hEntity] ); - str[sizeof(str)-1] = '\0'; + if( psSHP->nBufSize < 10 * 1024 * 1024 ) + { + SAOffset nFileSize; + psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 2 ); + nFileSize = psSHP->sHooks.FTell(psSHP->fpSHP); + if( nFileSize >= UINT_MAX ) + psSHP->nFileSize = UINT_MAX; + else + psSHP->nFileSize = STATIC_CAST(unsigned int, nFileSize); + } - psSHP->sHooks.Error( str ); - return SHPLIB_NULLPTR; + if( psSHP->panRecOffset[hEntity] >= psSHP->nFileSize || + /* We should normally use nEntitySize instead of*/ + /* psSHP->panRecSize[hEntity] in the below test, but because of */ + /* the case of non conformant .shx files detailed a bit below, */ + /* let be more tolerant */ + psSHP->panRecSize[hEntity] > psSHP->nFileSize - psSHP->panRecOffset[hEntity] ) + { + char str[128]; + snprintf( str, sizeof(str), + "Error in fread() reading object of size %d at offset %u from .shp file", + nEntitySize, psSHP->panRecOffset[hEntity] ); + str[sizeof(str)-1] = '\0'; + + psSHP->sHooks.Error( str ); + return SHPLIB_NULLPTR; + } } pabyRecNew = STATIC_CAST(uchar *, SfRealloc(psSHP->pabyRec,nNewBufSize)); From a91aa00823f19d395f52296b58196459100b616a Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Wed, 31 Oct 2018 02:53:45 +0900 Subject: [PATCH 011/488] Vagrant: work around for #1058 (#1059) --- Vagrantfile | 2 +- gdal/scripts/vagrant/gdal-mingw.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index caf03c057318..5c185a2cbbc0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -151,7 +151,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| "mingw-w64-tools", "gdb-mingw-w64-target", "libgeos-mingw-w64-dev", - "libproj-mingw-w64-dev", + #"libproj-mingw-w64-dev", "cmake3-curses-gui", "gdb", "gdbserver", diff --git a/gdal/scripts/vagrant/gdal-mingw.sh b/gdal/scripts/vagrant/gdal-mingw.sh index 9719fb113787..791bd921b310 100755 --- a/gdal/scripts/vagrant/gdal-mingw.sh +++ b/gdal/scripts/vagrant/gdal-mingw.sh @@ -33,7 +33,7 @@ ln -sf /usr/x86_64-w64-mingw32/lib/libgeos-3-5-0.dll "$HOME/.wine/drive_c/window (cd /home/vagrant/gnumake-build-mingw-w64 CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld \ - ./configure --prefix=/usr/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --with-geos --with-proj-static + ./configure --prefix=/usr/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --with-geos #--with-proj ln -sf "$PWD/.libs/libgdal-20.dll" "$HOME/.wine/drive_c/windows" # Python bindings From 87f2ab2a6813231ec87acf5e47dca60f4ca95c08 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 30 Oct 2018 19:01:32 +0100 Subject: [PATCH 012/488] CONTRIBUTING.md: enhance backporting section [ci skip] --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a78b50f1f22..22d516b84436 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,7 +103,10 @@ Backporting bugfixes from master to a stable branch git checkout master With git log, identify the sha1sum of the commit you want to backport git checkout 2.2 (if you want to backport to 2.2) +git pull origin 2.2 +(git checkout -b branh_name: if you intend to submit the backport as a pull request) git cherry-pick the_sha1_sum +git push ... ``` If changes are needed, do them and ```git commit -a --amend``` From 48e64636d25ecb2b76fdbe1985a19ce78bc50bcc Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 30 Oct 2018 19:10:16 +0100 Subject: [PATCH 013/488] Spatialite: read table name in its original case (fixes #1060, from suggestion by @aledonati) --- .../ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp index 5f034fa3cc10..09b06d54eb8e 100644 --- a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp @@ -1653,9 +1653,11 @@ int OGRSQLiteDataSource::Open( GDALOpenInfo* poOpenInfo) /* -------------------------------------------------------------------- */ sqlite3_free( pszErrMsg ); rc = sqlite3_get_table( hDB, - "SELECT f_table_name, f_geometry_column, " - "type, coord_dimension, srid, " - "spatial_index_enabled FROM geometry_columns " + "SELECT sm.name, gc.f_geometry_column, " + "gc.type, gc.coord_dimension, gc.srid, " + "gc.spatial_index_enabled FROM geometry_columns gc " + "JOIN sqlite_master sm ON " + "LOWER(gc.f_table_name)=LOWER(sm.name) " "LIMIT 10000", &papszResult, &nRowCount, &nColCount, &pszErrMsg ); @@ -1664,9 +1666,11 @@ int OGRSQLiteDataSource::Open( GDALOpenInfo* poOpenInfo) /* Test with SpatiaLite 4.0 schema */ sqlite3_free( pszErrMsg ); rc = sqlite3_get_table( hDB, - "SELECT f_table_name, f_geometry_column, " - "geometry_type, coord_dimension, srid, " - "spatial_index_enabled FROM geometry_columns " + "SELECT sm.name, gc.f_geometry_column, " + "gc.geometry_type, gc.coord_dimension, gc.srid, " + "gc.spatial_index_enabled FROM geometry_columns gc " + "JOIN sqlite_master sm ON " + "LOWER(gc.f_table_name)=LOWER(sm.name) " "LIMIT 10000", &papszResult, &nRowCount, &nColCount, &pszErrMsg ); From bb795227fc4177d5c7424a6c411f6b802fdfc22a Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Tue, 30 Oct 2018 13:56:23 -0500 Subject: [PATCH 014/488] grib: interpret missing data values correctly for complex packing when original data is integer --- gdal/frmts/grib/gribdataset.cpp | 45 +++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/gdal/frmts/grib/gribdataset.cpp b/gdal/frmts/grib/gribdataset.cpp index 221dfcbf5c0e..632185eb2b2e 100644 --- a/gdal/frmts/grib/gribdataset.cpp +++ b/gdal/frmts/grib/gribdataset.cpp @@ -516,22 +516,39 @@ void GRIBRasterBand::FindNoDataGrib2(bool bSeekToStart) const int nMiss = pabyBody[23-1]; if( nMiss == 1 || nMiss == 2 ) { - float fTemp; - memcpy(&fTemp, &pabyBody[24-1], 4); - CPL_MSBPTR32(&fTemp); - m_dfNoData = fTemp; - m_bHasNoData = true; - - if( nMiss == 2 ) + const int original_field_type = pabyBody[21-1]; + if ( original_field_type == 0 ) // Floating Point { - memcpy(&fTemp, &pabyBody[28-1], 4); + float fTemp; + memcpy(&fTemp, &pabyBody[24-1], 4); CPL_MSBPTR32(&fTemp); - double dfSecondaryNoData = fTemp; - - // What TODO? - CPLDebug("GRIB", - "Secondary missing value also set for band %d : %f", - nBand, dfSecondaryNoData); + m_dfNoData = fTemp; + m_bHasNoData = true; + if( nMiss == 2 ) + { + memcpy(&fTemp, &pabyBody[28-1], 4); + CPL_MSBPTR32(&fTemp); + CPLDebug("GRIB","Secondary missing value also set for band %d : %f", nBand, fTemp); + } + } + else if ( original_field_type == 1 ) // Integer + { + int iTemp; + memcpy(&iTemp, &pabyBody[24-1], 4); + CPL_MSBPTR32(&iTemp); + m_dfNoData = iTemp; + m_bHasNoData = true; + if( nMiss == 2 ) + { + memcpy(&iTemp, &pabyBody[28-1], 4); + CPL_MSBPTR32(&iTemp); + CPLDebug("GRIB","Secondary missing value also set for band %d : %d", nBand, iTemp); + } + } + else + { + // FIXME What to do? Blindly convert to float? + CPLDebug("GRIB","Complex Packing - Type of Original Field Values for band %d: %u", nBand, original_field_type); } } } From 3ab3b331094aadf2a4dbf9aae9cc378406f31112 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 31 Oct 2018 00:13:11 +0100 Subject: [PATCH 015/488] GRIB: fix writing of nodata value for complex value when original data is integer (refs #1063) --- autotest/gdrivers/grib.py | 31 ++++++++++++++++++++++++ gdal/frmts/grib/gribcreatecopy.cpp | 39 ++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/autotest/gdrivers/grib.py b/autotest/gdrivers/grib.py index eaa6bbabe68a..d55f31298fe8 100755 --- a/autotest/gdrivers/grib.py +++ b/autotest/gdrivers/grib.py @@ -1532,6 +1532,36 @@ def grib_grib2_write_temperatures(): return 'success' ############################################################################### + + +def grib_grib2_write_nodata(): + + if gdaltest.grib_drv is None: + return 'skip' + + for src_type in [ gdal.GDT_Byte, gdal.GDT_Float32 ]: + src_ds = gdal.GetDriverByName('MEM').Create('', 2, 2, 1, src_type) + src_ds.SetGeoTransform([2, 1, 0, 49, 0, -1]) + sr = osr.SpatialReference() + sr.SetFromUserInput('WGS84') + src_ds.SetProjection(sr.ExportToWkt()) + src_ds.GetRasterBand(1).SetNoDataValue(123) + tmpfilename = '/vsimem/out.grb2' + options = [ + 'DATA_ENCODING=COMPLEX_PACKING' + ] + gdaltest.grib_drv.CreateCopy(tmpfilename, src_ds, options=options) + + ds = gdal.Open(tmpfilename) + if ds.GetRasterBand(1).GetNoDataValue() != 123: + gdaltest.post_reason('fail') + return 'fail' + ds = None + gdal.Unlink(tmpfilename) + + return 'success' + +############################################################################### # Test GRIB2 file with JPEG2000 codestream on a single line (#6719) @@ -1600,6 +1630,7 @@ def grib_online_grib2_jpeg2000_single_line(): grib_grib2_write_data_encodings, grib_grib2_write_data_encodings_warnings_and_errors, grib_grib2_write_temperatures, + grib_grib2_write_nodata, grib_online_grib2_jpeg2000_single_line ] diff --git a/gdal/frmts/grib/gribcreatecopy.cpp b/gdal/frmts/grib/gribcreatecopy.cpp index 8d7aca6e90be..ac7184b591ca 100644 --- a/gdal/frmts/grib/gribcreatecopy.cpp +++ b/gdal/frmts/grib/gribcreatecopy.cpp @@ -33,6 +33,7 @@ #include "cpl_port.h" #include "gribdataset.h" +#include "gdal_priv_templates.hpp" #include @@ -700,6 +701,7 @@ class GRIB2Section567Writer bool Write(float fValOffset, char** papszOptions, GDALProgressFunc pfnProgress, void * pProgressData); + void WriteComplexPackingNoData(); }; /************************************************************************/ @@ -926,6 +928,33 @@ bool GRIB2Section567Writer::WriteSimplePacking() return true; } +/************************************************************************/ +/* WriteComplexPackingNoData() */ +/************************************************************************/ + +void GRIB2Section567Writer::WriteComplexPackingNoData() +{ + if( !m_bHasNoData ) + { + WriteUInt32(m_fp, GRIB2MISSING_u4); + } + else if( GDALDataTypeIsFloating(m_eDT) ) + { + WriteFloat32(m_fp, static_cast(m_dfNoData)); + } + else + { + if( GDALIsValueInRange(m_dfNoData) ) + { + WriteInt32(m_fp, static_cast(m_dfNoData)); + } + else + { + WriteUInt32(m_fp, GRIB2MISSING_u4); + } + } +} + /************************************************************************/ /* WriteComplexPacking() */ /************************************************************************/ @@ -965,10 +994,7 @@ bool GRIB2Section567Writer::WriteComplexPacking(int nSpatialDifferencingOrder) WriteByte(m_fp, GDALDataTypeIsFloating(m_eDT) ? 0 : 1); WriteByte(m_fp, 0); WriteByte(m_fp, m_bHasNoData ? 1 : 0); // 1 missing value - if( !m_bHasNoData ) - WriteUInt32(m_fp, GRIB2MISSING_u4); - else - WriteFloat32(m_fp, fNoData); + WriteComplexPackingNoData(); WriteUInt32(m_fp, GRIB2MISSING_u4); WriteUInt32(m_fp, 0); WriteByte(m_fp, 0); @@ -1092,10 +1118,7 @@ bool GRIB2Section567Writer::WriteComplexPacking(int nSpatialDifferencingOrder) WriteByte(m_fp, GDALDataTypeIsFloating(m_eDT) ? 0 : 1); WriteByte(m_fp, idrstmpl[TMPL5_GROUP_SPLITTING_IDX]); WriteByte(m_fp, idrstmpl[TMPL5_MISSING_VALUE_MGNT_IDX]); - if( !m_bHasNoData ) - WriteUInt32(m_fp, GRIB2MISSING_u4); - else - WriteFloat32(m_fp, fNoData); + WriteComplexPackingNoData(); WriteUInt32(m_fp, GRIB2MISSING_u4); WriteUInt32(m_fp, idrstmpl[TMPL5_NG_IDX]); WriteByte(m_fp, idrstmpl[TMPL5_REF_GROUP_WIDTHS_IDX]); From 5bd506d5691e5c68da5bb7ab451fa0e99b5e91cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81oskot?= Date: Wed, 31 Oct 2018 09:58:44 +0100 Subject: [PATCH 016/488] Remove support for pre-VS2013 from generate_vcxproj.bat [ci skip] --- gdal/generate_vcxproj.bat | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/gdal/generate_vcxproj.bat b/gdal/generate_vcxproj.bat index 3e4686309f0c..9bc120c59277 100644 --- a/gdal/generate_vcxproj.bat +++ b/gdal/generate_vcxproj.bat @@ -5,7 +5,7 @@ :: :: Name: generate_vcxproj.bat :: Project: GDAL -:: Purpose: Generate MS Visual C++ => 10.0 project files +:: Purpose: Generate MS Visual C++ => 12.0 project files :: Author: Ivan Lucena, [ivan lucena at outlook dot com] :: :: **************************************************************************** @@ -61,12 +61,6 @@ if "%_vcver_%"=="15.0" ( ) else ( if "%_vcver_%"=="12.0" ( set _clver_=1800 set _vstoolset_=v120 -) else ( if "%_vcver_%"=="11.0" ( - set _clver_=1700 - set _vstoolset_=v110 -) else ( if "%_vcver_%"=="10.0" ( - set _clver_=1600 - set _vstoolset_=v100 ) else ( echo Wrong value for parameter 1. See usage: goto :usage @@ -102,15 +96,14 @@ goto :continue echo Usage: generate_vcxproj ^ [32^|64] ^<^(*^) project file name^> echo Parameters: -echo 1 : Visual C++ version is not the same as Visual Studio version ^( =^> 10.0 ^) +echo 1 : Visual C++ version is not the same as Visual Studio version ^( =^> 14.0 ^) echo 2 : Windows platform 32 for Win32 and 64 for Win64 echo 3 : Base file name, with no path and no extension ^(*^) echo Examples: -echo generate_vcxproj 10.1 32 gdal_vs2010 -echo generate_vcxproj 11.0 64 gdal_vs2012 echo generate_vcxproj 12.0 64 gdal_vs2013 echo generate_vcxproj 14.0 64 gdal_vs2015 echo generate_vcxproj 15.0 64 gdal_vs2017 +echo WARNING: GDAL requires C++11. It is not guaranteed to build with VS2013. goto :end From a3c0caeab77354c23a237905cc451dfc89f7f06f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 1 Nov 2018 14:28:43 +0100 Subject: [PATCH 017/488] ogr_merge.py: fix issue with non-ASCII characters (fixes #1067) --- autotest/pyscripts/test_ogrmerge.py | 29 +++++++++++++++++- gdal/swig/python/scripts/ogrmerge.py | 45 ++++++++++++++++++---------- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/autotest/pyscripts/test_ogrmerge.py b/autotest/pyscripts/test_ogrmerge.py index 7b27f061bc27..6b728af940b4 100755 --- a/autotest/pyscripts/test_ogrmerge.py +++ b/autotest/pyscripts/test_ogrmerge.py @@ -404,6 +404,32 @@ def test_ogrmerge_11(): return 'success' +############################################################################### +# Test layer names with accents + + +def test_ogrmerge_12(): + script_path = test_py_scripts.get_py_script('ogrmerge') + if script_path is None: + return 'skip' + + with open('tmp/tmp.json', 'wt') as f: + f.write("""{ "type": "FeatureCollection", "name": "\xc3\xa9ven", "features": [ { "type": "Feature", "properties": {}, "geometry": null} ]}""") + + test_py_scripts.run_py_script(script_path, 'ogrmerge', + '-f VRT -o /vsimem/out.vrt tmp/tmp.json') + + ds = ogr.Open('/vsimem/out.vrt') + if ds is None: + gdaltest.post_reason('fail') + return 'fail' + ds = None + + gdal.Unlink('tmp/tmp.json') + gdal.Unlink('/vsimem/out.vrt') + + return 'success' + gdaltest_list = [ test_ogrmerge_1, @@ -416,7 +442,8 @@ def test_ogrmerge_11(): test_ogrmerge_8, test_ogrmerge_9, test_ogrmerge_10, - test_ogrmerge_11 + test_ogrmerge_11, + test_ogrmerge_12 ] diff --git a/gdal/swig/python/scripts/ogrmerge.py b/gdal/swig/python/scripts/ogrmerge.py index 85bb31e3d2ad..c5af21de9647 100755 --- a/gdal/swig/python/scripts/ogrmerge.py +++ b/gdal/swig/python/scripts/ogrmerge.py @@ -163,8 +163,10 @@ def open_element(self, name, attrs=None): xml_attrs = '' if attrs is not None: for key in attrs: - xml_attrs = xml_attrs + ' %s=\"%s\"' % (key, _Esc(attrs[key])) - _VSIFPrintfL(self.f, '%s<%s%s>\n' % (self._indent(), name, xml_attrs)) + xml_attrs = xml_attrs + ' %s=\"%s\"' % (key, _Esc(attrs[key].encode('utf-8'))) + x = '%s<%s%s>\n' % (self._indent(), name, xml_attrs) + x = x.encode('utf-8') + _VSIFPrintfL(self.f, x) self.inc = self.inc + 1 self.elements.append(name) @@ -172,10 +174,11 @@ def write_element_value(self, name, value, attrs=None): xml_attrs = '' if attrs is not None: for key in attrs: - xml_attrs = xml_attrs + ' %s=\"%s\"' % (key, _Esc(attrs[key])) - _VSIFPrintfL(self.f, '%s<%s%s>%s\n' % - (self._indent(), name, xml_attrs, - _Esc(value), name)) + xml_attrs = xml_attrs + ' %s=\"%s\"' % (key, _Esc(attrs[key].encode('utf-8'))) + x = '%s<%s%s>%s\n' % (self._indent(), name, xml_attrs, + _Esc(value.encode('utf-8')), name) + x = x.encode('utf-8') + _VSIFPrintfL(self.f, x) def close_element(self, closing_name=None): self.inc = self.inc - 1 @@ -406,21 +409,27 @@ def process(argv, progress=None, progress_arg=None): layer_name = src_layer_field_content + src_lyr_name = src_lyr.GetName() + try: + src_lyr_name = src_lyr_name.decode('utf-8') + except AttributeError: + pass + basename = None if os.path.exists(src_dsname): basename = os.path.basename(src_dsname) if basename.find('.') >= 0: basename = '.'.join(basename.split(".")[0:-1]) - if basename == src_lyr.GetName(): + if basename == src_lyr_name: layer_name = layer_name.replace('{AUTO_NAME}', basename) elif basename is None: layer_name = layer_name.replace( '{AUTO_NAME}', - 'Dataset%d_%s' % (src_ds_idx, src_lyr.GetName())) + 'Dataset%d_%s' % (src_ds_idx, src_lyr_name)) else: layer_name = layer_name.replace( - '{AUTO_NAME}', basename + '_' + src_lyr.GetName()) + '{AUTO_NAME}', basename + '_' + src_lyr_name) if basename is not None: layer_name = layer_name.replace('{DS_BASENAME}', basename) @@ -432,7 +441,7 @@ def process(argv, progress=None, progress_arg=None): layer_name = layer_name.replace('{DS_INDEX}', '%d' % src_ds_idx) layer_name = layer_name.replace('{LAYER_NAME}', - src_lyr.GetName()) + src_lyr_name) layer_name = layer_name.replace('{LAYER_INDEX}', '%d' % src_lyr_idx) @@ -485,6 +494,12 @@ def process(argv, progress=None, progress_arg=None): if gt not in src_geom_types: continue + src_lyr_name = src_lyr.GetName() + try: + src_lyr_name = src_lyr_name.decode('utf-8') + except AttributeError: + pass + layer_name = layer_name_template basename = None if os.path.exists(src_dsname): @@ -492,15 +507,15 @@ def process(argv, progress=None, progress_arg=None): if basename.find('.') >= 0: basename = '.'.join(basename.split(".")[0:-1]) - if basename == src_lyr.GetName(): + if basename == src_lyr_name: layer_name = layer_name.replace('{AUTO_NAME}', basename) elif basename is None: layer_name = layer_name.replace( '{AUTO_NAME}', - 'Dataset%d_%s' % (src_ds_idx, src_lyr.GetName())) + 'Dataset%d_%s' % (src_ds_idx, src_lyr_name)) else: layer_name = layer_name.replace( - '{AUTO_NAME}', basename + '_' + src_lyr.GetName()) + '{AUTO_NAME}', basename + '_' + src_lyr_name) if basename is not None: layer_name = layer_name.replace('{DS_BASENAME}', basename) @@ -523,7 +538,7 @@ def process(argv, progress=None, progress_arg=None): layer_name = layer_name.replace('{DS_INDEX}', '%d' % src_ds_idx) layer_name = layer_name.replace('{LAYER_NAME}', - src_lyr.GetName()) + src_lyr_name) layer_name = layer_name.replace('{LAYER_INDEX}', '%d' % src_lyr_idx) @@ -541,7 +556,7 @@ def process(argv, progress=None, progress_arg=None): attrs = {'relativeToVRT': '1'} writer.write_element_value('SrcDataSource', src_dsname, attrs=attrs) - writer.write_element_value('SrcLayer', src_lyr.GetName()) + writer.write_element_value('SrcLayer', src_lyr_name) if a_srs is not None: writer.write_element_value('LayerSRS', a_srs) From 81816bf316a03f75fba348d84daac1416f7c218d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 1 Nov 2018 18:42:21 +0100 Subject: [PATCH 018/488] ogr_merge.py: fix issue with non-ASCII filenames on Windows (fixes #1067, derived from fix by @tobwen) --- gdal/swig/python/scripts/ogrmerge.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdal/swig/python/scripts/ogrmerge.py b/gdal/swig/python/scripts/ogrmerge.py index c5af21de9647..5859c46098e2 100755 --- a/gdal/swig/python/scripts/ogrmerge.py +++ b/gdal/swig/python/scripts/ogrmerge.py @@ -288,7 +288,10 @@ def process(argv, progress=None, progress_arg=None): return Usage() else: if '*' in arg: - src_datasets += glob.glob(arg) + if sys.version_info < (3,0,0): + src_datasets += [unicode(fn, sys.getfilesystemencoding()) for fn in glob.glob(arg)] + else: + src_datasets += glob.glob(arg) else: src_datasets.append(arg) i = i + 1 @@ -601,7 +604,10 @@ def process(argv, progress=None, progress_arg=None): def main(): - argv = ogr.GeneralCmdLineProcessor(sys.argv) + argv = sys.argv + if sys.version_info < (3,0,0): + argv = [unicode(fn, sys.getfilesystemencoding()) for fn in argv] + argv = ogr.GeneralCmdLineProcessor(argv) if argv is None: return 1 return process(argv[1:]) From ef65d88251a15e9f28d01a98a666238a761159c2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 1 Nov 2018 19:28:00 +0100 Subject: [PATCH 019/488] ogrmerge.py: make pyflakes3 happy (refs #1067) --- gdal/swig/python/scripts/ogrmerge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdal/swig/python/scripts/ogrmerge.py b/gdal/swig/python/scripts/ogrmerge.py index 5859c46098e2..06762e15ee9c 100755 --- a/gdal/swig/python/scripts/ogrmerge.py +++ b/gdal/swig/python/scripts/ogrmerge.py @@ -289,7 +289,7 @@ def process(argv, progress=None, progress_arg=None): else: if '*' in arg: if sys.version_info < (3,0,0): - src_datasets += [unicode(fn, sys.getfilesystemencoding()) for fn in glob.glob(arg)] + src_datasets += [fn.decode(sys.getfilesystemencoding()) for fn in glob.glob(arg)] else: src_datasets += glob.glob(arg) else: @@ -606,7 +606,7 @@ def process(argv, progress=None, progress_arg=None): def main(): argv = sys.argv if sys.version_info < (3,0,0): - argv = [unicode(fn, sys.getfilesystemencoding()) for fn in argv] + argv = [fn.decode(sys.getfilesystemencoding()) for fn in argv] argv = ogr.GeneralCmdLineProcessor(argv) if argv is None: return 1 From 93bd2427dbca537cfa6aa37319ec9e1e0b193934 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 1 Nov 2018 19:37:07 +0100 Subject: [PATCH 020/488] GeoJSON RFC7946 writer: clip and offset geometries outside [-180,180] (fixes #1068) --- autotest/ogr/ogr_geojson.py | 46 +++++++++++++++++++++++++++++++++ gdal/ogr/ogrgeometryfactory.cpp | 10 ++++--- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index 2116d0db7596..17937a380135 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -4208,6 +4208,51 @@ def ogr_geojson_read_fields_with_different_case(): return 'success' +############################################################################### +# Test bugfix for https://github.com/OSGeo/gdal/issues/1068 + + +def ogr_geojson_clip_geometries_rfc7946(): + + if not ogrtest.have_geos(): + return 'skip' + + tmpfilename = '/vsimem/out.json' + gdal.VectorTranslate(tmpfilename, """{ + "type": "FeatureCollection", + "features": [ + { "type": "Feature", "geometry": {"type":"Polygon","coordinates":[[[-220,-20],[-220,30],[16,30],[16,-20],[-220,-20]]]} }, + { "type": "Feature", "geometry": {"type":"Polygon","coordinates":[[[220,40],[220,70],[-16,70],[-16,40],[220,40]]]} }, + { "type": "Feature", "geometry": {"type":"Polygon","coordinates":[[[170,-40],[170,-70],[-16,70],[-16,-40],[170,-40]]]} } + ] +}""", options='-f GeoJSON -lco RFC7946=YES') + + ds = ogr.Open(tmpfilename) + lyr = ds.GetLayer(0) + + f = lyr.GetNextFeature() + ref_geom = ogr.CreateGeometryFromWkt('MULTIPOLYGON (((-180 30,-180 -20,16 -20,16 30,-180 30)),((140 -20,180 -20,180 30,140 30,140 -20)))') + if ogrtest.check_feature_geometry(f, ref_geom) != 0: + f.DumpReadable() + return 'fail' + + f = lyr.GetNextFeature() + ref_geom = ogr.CreateGeometryFromWkt('MULTIPOLYGON (((180 40,180 70,-16 70,-16 40,180 40)),((-180 70,-180 40,-140 40,-140 70,-180 70)))') + if ogrtest.check_feature_geometry(f, ref_geom) != 0: + f.DumpReadable() + return 'fail' + + f = lyr.GetNextFeature() + ref_geom = ogr.CreateGeometryFromWkt('POLYGON ((170 -40,-16 -40,-16 70,170 -70,170 -40))') + if ogrtest.check_feature_geometry(f, ref_geom) != 0: + f.DumpReadable() + return 'fail' + ds = None + + gdal.Unlink(tmpfilename) + return 'success' + + ############################################################################### @@ -4322,6 +4367,7 @@ def ogr_geojson_cleanup(): ogr_geojson_empty_geometrycollection, ogr_esrijson_without_geometryType, ogr_geojson_read_fields_with_different_case, + ogr_geojson_clip_geometries_rfc7946, ogr_geojson_cleanup] if __name__ == '__main__': diff --git a/gdal/ogr/ogrgeometryfactory.cpp b/gdal/ogr/ogrgeometryfactory.cpp index c57edd70bc16..8cfa48ee7d7b 100644 --- a/gdal/ogr/ogrgeometryfactory.cpp +++ b/gdal/ogr/ogrgeometryfactory.cpp @@ -2801,8 +2801,10 @@ static void CutGeometryOnDateLineAndAddToMulti( OGRGeometryCollection* poMulti, const double dfDiffSpace = 360 - dfDateLineOffset; const double dfXOffset = (bAroundMinus180) ? 360.0 : 0.0; - if( oEnvelope.MinX + dfXOffset > dfLeftBorderX && - oEnvelope.MaxX + dfXOffset > 180 ) + if( oEnvelope.MinX < -180 || + oEnvelope.MaxX > 180 || + (oEnvelope.MinX + dfXOffset > dfLeftBorderX && + oEnvelope.MaxX + dfXOffset > 180) ) { #ifndef HAVE_GEOS CPLError( CE_Failure, CPLE_NotSupported, @@ -2869,8 +2871,8 @@ static void CutGeometryOnDateLineAndAddToMulti( OGRGeometryCollection* poMulti, OGRGeometry* poRectangle1 = nullptr; OGRGeometry* poRectangle2 = nullptr; const char* pszWKT1 = !bAroundMinus180 ? - "POLYGON((0 90,180 90,180 -90,0 -90,0 90))" : - "POLYGON((0 90,-180 90,-180 -90,0 -90,0 90))"; + "POLYGON((-180 90,180 90,180 -90,-180 -90,-180 90))" : + "POLYGON((180 90,-180 90,-180 -90,180 -90,180 90))"; const char* pszWKT2 = !bAroundMinus180 ? "POLYGON((180 90,360 90,360 -90,180 -90,180 90))" : "POLYGON((-180 90,-360 90,-360 -90,-180 -90,-180 90))"; From f679c3ce6939206a5ce7ed264d2d6ffbdc027869 Mon Sep 17 00:00:00 2001 From: drons Date: Wed, 31 Oct 2018 23:06:46 +0300 Subject: [PATCH 021/488] DBF: Add CP1251 codepage name synonym (ANSI 1251) for DBF files. This synonym is found in the Russian-language OS Windows. --- gdal/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdal/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp b/gdal/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp index 99781665db72..6702ba3a8c27 100644 --- a/gdal/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp @@ -445,6 +445,8 @@ CPLString OGRShapeLayer::ConvertCodePage( const char *pszCodePage ) } if( STARTS_WITH_CI(pszCodePage, "UTF-8") ) return CPL_ENC_UTF8; + if( STARTS_WITH_CI(pszCodePage, "ANSI 1251") ) + return "CP1251"; // Try just using the CPG value directly. Works for stuff like Big5. return pszCodePage; From 301268d2142ba741de1814540d044a45f1f597f4 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 2 Nov 2018 09:48:05 +0100 Subject: [PATCH 022/488] SIGDEM: avoid floating point division by zero. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11220. Credit to OSS Fuzz --- gdal/frmts/sigdem/sigdemdataset.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdal/frmts/sigdem/sigdemdataset.cpp b/gdal/frmts/sigdem/sigdemdataset.cpp index 0d8b4d769872..d188ac9323e6 100644 --- a/gdal/frmts/sigdem/sigdemdataset.cpp +++ b/gdal/frmts/sigdem/sigdemdataset.cpp @@ -520,14 +520,14 @@ CPLErr SIGDEMRasterBand::IReadBlock( const int32_t* pnSourceValues = pBlockBuffer; double* padfDestValues = static_cast(pImage); double dfOffset = this->dfOffsetZ; - double dfScaleFactor = this->dfScaleFactorZ; + const double dfInvScaleFactor = dfScaleFactorZ ? 1.0 / dfScaleFactorZ : 0.0; int nCellCount = this->nRasterXSize; for (int i = 0; i < nCellCount; i++) { int32_t nValue = CPL_MSBWORD32(*pnSourceValues); if (nValue == NO_DATA) { *padfDestValues = -9999; } else { - *padfDestValues = dfOffset + nValue / dfScaleFactor; + *padfDestValues = dfOffset + nValue * dfInvScaleFactor; } pnSourceValues++; From 2ace03ec48c36dae8ba74089d85617c095643428 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 2 Nov 2018 18:02:33 +0100 Subject: [PATCH 023/488] SDTS: avoid long processing time on corrupted dataset. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11219. Credit to OSS Fuzz --- gdal/frmts/sdts/sdts_al.h | 1 + gdal/frmts/sdts/sdtscatd.cpp | 13 +++++++++++++ gdal/frmts/sdts/sdtstransfer.cpp | 12 ++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/gdal/frmts/sdts/sdts_al.h b/gdal/frmts/sdts/sdts_al.h index dbb621699d88..df0d8d03848f 100644 --- a/gdal/frmts/sdts/sdts_al.h +++ b/gdal/frmts/sdts/sdts_al.h @@ -149,6 +149,7 @@ class SDTS_CATD const char * GetEntryTypeDesc(int) const; const char * GetEntryFilePath(int) const; SDTSLayerType GetEntryType(int) const; + void SetEntryTypeUnknown(int); }; /************************************************************************/ diff --git a/gdal/frmts/sdts/sdtscatd.cpp b/gdal/frmts/sdts/sdtscatd.cpp index 19c9a4578eb2..093814936e1b 100644 --- a/gdal/frmts/sdts/sdtscatd.cpp +++ b/gdal/frmts/sdts/sdtscatd.cpp @@ -302,6 +302,19 @@ SDTSLayerType SDTS_CATD::GetEntryType( int iEntry ) const return SLTUnknown; } +/************************************************************************/ +/* SetEntryTypeUnknown() */ +/************************************************************************/ + +void SDTS_CATD::SetEntryTypeUnknown(int iEntry) +{ + if( iEntry >= 0 && iEntry < nEntries ) + { + CPLFree(papoEntries[iEntry]->pszType); + papoEntries[iEntry]->pszType = CPLStrdup("Unknown"); + } +} + /************************************************************************/ /* GetEntryFilePath() */ /************************************************************************/ diff --git a/gdal/frmts/sdts/sdtstransfer.cpp b/gdal/frmts/sdts/sdtstransfer.cpp index e176e954e237..606817e36655 100644 --- a/gdal/frmts/sdts/sdtstransfer.cpp +++ b/gdal/frmts/sdts/sdtstransfer.cpp @@ -238,7 +238,7 @@ SDTSLineReader *SDTSTransfer::GetLayerLineReader( int iEntry ) if( !poLineReader->Open( oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) { - panLayerCATDEntry[iEntry] = SLTUnknown; // to prevent further attempt + oCATD.SetEntryTypeUnknown(iEntry) ; // to prevent further attempt delete poLineReader; return nullptr; } @@ -265,7 +265,7 @@ SDTSPointReader *SDTSTransfer::GetLayerPointReader( int iEntry ) if( !poPointReader->Open( oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) { - panLayerCATDEntry[iEntry] = SLTUnknown; // to prevent further attempt + oCATD.SetEntryTypeUnknown(iEntry) ; // to prevent further attempt delete poPointReader; return nullptr; } @@ -292,7 +292,7 @@ SDTSPolygonReader *SDTSTransfer::GetLayerPolygonReader( int iEntry ) if( !poPolyReader->Open( oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) { - panLayerCATDEntry[iEntry] = SLTUnknown; // to prevent further attempt + oCATD.SetEntryTypeUnknown(iEntry) ; // to prevent further attempt delete poPolyReader; return nullptr; } @@ -319,7 +319,7 @@ SDTSAttrReader *SDTSTransfer::GetLayerAttrReader( int iEntry ) if( !poAttrReader->Open( oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) { - panLayerCATDEntry[iEntry] = SLTUnknown; // to prevent further attempt + oCATD.SetEntryTypeUnknown(iEntry) ; // to prevent further attempt delete poAttrReader; return nullptr; } @@ -361,7 +361,7 @@ SDTSRasterReader *SDTSTransfer::GetLayerRasterReader( int iEntry ) if( !poRasterReader->Open( &oCATD, &oIREF, oCATD.GetEntryModule(panLayerCATDEntry[iEntry] ) ) ) { - panLayerCATDEntry[iEntry] = SLTUnknown; // to prevent further attempt + oCATD.SetEntryTypeUnknown(iEntry) ; // to prevent further attempt delete poRasterReader; return nullptr; } @@ -386,7 +386,7 @@ DDFModule *SDTSTransfer::GetLayerModuleReader( int iEntry ) if( !poModuleReader->Open( oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) { - panLayerCATDEntry[iEntry] = SLTUnknown; // to prevent further attempt + oCATD.SetEntryTypeUnknown(iEntry) ; // to prevent further attempt delete poModuleReader; return nullptr; } From 3f206c1e3684ee1ba033e58791b37608f418b00c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 2 Nov 2018 18:13:44 +0100 Subject: [PATCH 024/488] Fix warning --- gdal/frmts/sigdem/sigdemdataset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/frmts/sigdem/sigdemdataset.cpp b/gdal/frmts/sigdem/sigdemdataset.cpp index d188ac9323e6..5ffc6e6ec61b 100644 --- a/gdal/frmts/sigdem/sigdemdataset.cpp +++ b/gdal/frmts/sigdem/sigdemdataset.cpp @@ -520,7 +520,7 @@ CPLErr SIGDEMRasterBand::IReadBlock( const int32_t* pnSourceValues = pBlockBuffer; double* padfDestValues = static_cast(pImage); double dfOffset = this->dfOffsetZ; - const double dfInvScaleFactor = dfScaleFactorZ ? 1.0 / dfScaleFactorZ : 0.0; + const double dfInvScaleFactor = dfScaleFactorZ != 0.0 ? 1.0 / dfScaleFactorZ : 0.0; int nCellCount = this->nRasterXSize; for (int i = 0; i < nCellCount; i++) { int32_t nValue = CPL_MSBWORD32(*pnSourceValues); From e5e7b313540f0ff913fadfe6a273fb7c356a22cb Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 2 Nov 2018 22:54:20 +0100 Subject: [PATCH 025/488] VRT: deal with serialized nodata value that is slightly outside Float32 validity range (fixes #1071) --- .../minfloat_nodata_slightly_out_of_float.vrt | 11 +++++ autotest/gcore/vrt_read.py | 42 +++++++++++++++++++ gdal/frmts/vrt/vrtrasterband.cpp | 22 ++++++++++ gdal/frmts/vrt/vrtsources.cpp | 26 ++++++++++-- gdal/gcore/gdal_misc.cpp | 14 +++++++ gdal/gcore/gdal_priv.h | 2 + 6 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 autotest/gcore/data/minfloat_nodata_slightly_out_of_float.vrt diff --git a/autotest/gcore/data/minfloat_nodata_slightly_out_of_float.vrt b/autotest/gcore/data/minfloat_nodata_slightly_out_of_float.vrt new file mode 100644 index 000000000000..d238f08bc7d8 --- /dev/null +++ b/autotest/gcore/data/minfloat_nodata_slightly_out_of_float.vrt @@ -0,0 +1,11 @@ + + + -3.402823466385289e+38 + Gray + + minfloat.tif + 1 + -3.402823466385289e+38 + + + diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index 476e6432dedc..495f342179d6 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -1385,6 +1385,47 @@ def vrt_read_31(): return 'success' +############################################################################### +# Test reading a VRT where the NODATA & NoDataValue are slighly below the +# minimum float value (https://github.com/OSGeo/gdal/issues/1071) + +def vrt_float32_with_nodata_slightly_below_float_min(): + + shutil.copyfile('data/minfloat.tif', 'tmp/minfloat.tif') + shutil.copyfile('data/minfloat_nodata_slightly_out_of_float.vrt', + 'tmp/minfloat_nodata_slightly_out_of_float.vrt') + gdal.Unlink('tmp/minfloat_nodata_slightly_out_of_float.vrt.aux.xml') + + ds = gdal.Open('tmp/minfloat_nodata_slightly_out_of_float.vrt') + nodata = ds.GetRasterBand(1).GetNoDataValue() + stats = ds.GetRasterBand(1).ComputeStatistics(False) + ds = None + + vrt_content = open('tmp/minfloat_nodata_slightly_out_of_float.vrt', 'rt').read() + + gdal.Unlink('tmp/minfloat.tif') + gdal.Unlink('tmp/minfloat_nodata_slightly_out_of_float.vrt') + + # Check that the values were 'normalized' when regenerating the VRT + if vrt_content.find('-3.402823466385289') >= 0: + gdaltest.post_reason('did not get expected nodata in rewritten VRT') + print(vrt_content) + return 'fail' + + if nodata != -3.4028234663852886e+38: + gdaltest.post_reason('did not get expected nodata') + print("%.18g" % nodata) + return 'fail' + + if stats != [-3.0, 5.0, 1.0, 4.0]: + gdaltest.post_reason('did not get expected stats') + print(stats) + return 'fail' + + return 'success' + + + for item in init_list: ut = gdaltest.GDALTest('VRT', item[0], item[1], item[2]) if ut is None: @@ -1423,6 +1464,7 @@ def vrt_read_31(): gdaltest_list.append(vrt_read_29) gdaltest_list.append(vrt_read_30) gdaltest_list.append(vrt_read_31) +gdaltest_list.append(vrt_float32_with_nodata_slightly_below_float_min) if __name__ == '__main__': diff --git a/gdal/frmts/vrt/vrtrasterband.cpp b/gdal/frmts/vrt/vrtrasterband.cpp index 826216481ba7..489a1ffba2d1 100644 --- a/gdal/frmts/vrt/vrtrasterband.cpp +++ b/gdal/frmts/vrt/vrtrasterband.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -620,10 +621,26 @@ CPLXMLNode *VRTRasterBand::SerializeToXML( const char *pszVRTPath ) if( m_bNoDataValueSet ) { if (CPLIsNan(m_dfNoDataValue)) + { CPLSetXMLValue( psTree, "NoDataValue", "nan"); + } + else if( eDataType == GDT_Float32 && + m_dfNoDataValue == -std::numeric_limits::max() ) + { + // To avoid rounding out of the range of float + CPLSetXMLValue( psTree, "NoDataValue", "-3.4028234663852886e+38"); + } + else if( eDataType == GDT_Float32 && + m_dfNoDataValue == std::numeric_limits::max() ) + { + // To avoid rounding out of the range of float + CPLSetXMLValue( psTree, "NoDataValue", "3.4028234663852886e+38"); + } else + { CPLSetXMLValue( psTree, "NoDataValue", CPLSPrintf( "%.16g", m_dfNoDataValue ) ); + } } if( m_bHideNoDataValue ) @@ -775,6 +792,11 @@ CPLXMLNode *VRTRasterBand::SerializeToXML( const char *pszVRTPath ) CPLErr VRTRasterBand::SetNoDataValue( double dfNewValue ) { + if( eDataType == GDT_Float32 ) + { + dfNewValue = GDALAdjustNoDataCloseToFloatMax(dfNewValue); + } + m_bNoDataValueSet = TRUE; m_dfNoDataValue = dfNewValue; diff --git a/gdal/frmts/vrt/vrtsources.cpp b/gdal/frmts/vrt/vrtsources.cpp index 5475ec28a0c5..53dc86c46903 100644 --- a/gdal/frmts/vrt/vrtsources.cpp +++ b/gdal/frmts/vrt/vrtsources.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "cpl_conv.h" @@ -2097,9 +2098,23 @@ CPLXMLNode *VRTComplexSource::SerializeToXML( const char *pszVRTPath ) { if( CPLIsNan(m_dfNoDataValue) ) CPLSetXMLValue( psSrc, "NODATA", "nan"); + else if( m_poRasterBand->GetRasterDataType() == GDT_Float32 && + m_dfNoDataValue == -std::numeric_limits::max() ) + { + // To avoid rounding out of the range of float + CPLSetXMLValue( psSrc, "NODATA", "-3.4028234663852886e+38"); + } + else if( m_poRasterBand->GetRasterDataType() == GDT_Float32 && + m_dfNoDataValue == std::numeric_limits::max() ) + { + // To avoid rounding out of the range of float + CPLSetXMLValue( psSrc, "NODATA", "3.4028234663852886e+38"); + } else + { CPLSetXMLValue( psSrc, "NODATA", CPLSPrintf("%.16g", m_dfNoDataValue) ); + } } switch( m_eScalingType ) @@ -2235,6 +2250,10 @@ CPLErr VRTComplexSource::XMLInit( CPLXMLNode *psSrc, const char *pszVRTPath, { m_bNoDataSet = TRUE; m_dfNoDataValue = CPLAtofM( CPLGetXMLValue(psSrc, "NODATA", "0") ); + if( m_poRasterBand->GetRasterDataType() == GDT_Float32 ) + { + m_dfNoDataValue = GDALAdjustNoDataCloseToFloatMax(m_dfNoDataValue); + } } if( CPLGetXMLValue(psSrc, "LUT", nullptr) != nullptr ) @@ -2506,7 +2525,9 @@ CPLErr VRTComplexSource::RasterIOInternal( int nReqXOff, int nReqYOff, const bool bIsComplex = CPL_TO_BOOL( GDALDataTypeIsComplex(eBufType) ); const int nWordSize = GDALGetDataTypeSizeBytes(eWrkDataType); const bool bNoDataSetIsNan = m_bNoDataSet && CPLIsNan(m_dfNoDataValue); - const bool bNoDataSetAndNotNan = m_bNoDataSet && !CPLIsNan(m_dfNoDataValue); + const bool bNoDataSetAndNotNan = m_bNoDataSet && !CPLIsNan(m_dfNoDataValue) && + GDALIsValueInRange(m_dfNoDataValue); + const auto fWorkingDataTypeNoData = static_cast(m_dfNoDataValue); WorkingDT *pafData = nullptr; if( m_eScalingType == VRT_SCALING_LINEAR && @@ -2588,8 +2609,7 @@ CPLErr VRTComplexSource::RasterIOInternal( int nReqXOff, int nReqYOff, if( bNoDataSetIsNan && CPLIsNan(fResult) ) continue; if( bNoDataSetAndNotNan && - GDALIsValueInRange(m_dfNoDataValue) && - ARE_REAL_EQUAL(fResult, static_cast(m_dfNoDataValue)) ) + ARE_REAL_EQUAL(fResult, fWorkingDataTypeNoData) ) continue; if( m_nColorTableComponent ) diff --git a/gdal/gcore/gdal_misc.cpp b/gdal/gcore/gdal_misc.cpp index 109d4d3b3207..602bf350bb75 100644 --- a/gdal/gcore/gdal_misc.cpp +++ b/gdal/gcore/gdal_misc.cpp @@ -4019,3 +4019,17 @@ int GDALCanFileAcceptSidecarFile(const char* pszFilename) return FALSE; return TRUE; } + +/************************************************************************/ +/* GDALAdjustNoDataCloseToFloatMax() */ +/************************************************************************/ + +double GDALAdjustNoDataCloseToFloatMax(double dfVal) +{ + const auto kMaxFloat = std::numeric_limits::max(); + if( std::fabs(dfVal - -kMaxFloat) < 1e-10 * kMaxFloat ) + return -kMaxFloat; + if( std::fabs(dfVal - kMaxFloat) < 1e-10 * kMaxFloat ) + return kMaxFloat; + return dfVal; +} diff --git a/gdal/gcore/gdal_priv.h b/gdal/gcore/gdal_priv.h index 1d54d58e305e..c22a1b6bd4ba 100644 --- a/gdal/gcore/gdal_priv.h +++ b/gdal/gcore/gdal_priv.h @@ -1819,6 +1819,8 @@ template inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2) std::abs(fVal1 - fVal2) < std::numeric_limits::epsilon() * std::abs(fVal1+fVal2) * ulp; } +double GDALAdjustNoDataCloseToFloatMax(double dfVal); + #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) ) // Number of data samples that will be used to compute approximate statistics From 22eb92683f1db950c59a7f2f703f9a007ea9244f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 2 Nov 2018 22:54:59 +0100 Subject: [PATCH 026/488] GTiff and GDALRasterBand: use GDALAdjustNoDataCloseToFloatMax() --- gdal/frmts/gtiff/geotiff.cpp | 11 +---------- gdal/gcore/gdalrasterband.cpp | 15 +-------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/gdal/frmts/gtiff/geotiff.cpp b/gdal/frmts/gtiff/geotiff.cpp index 11b2fd170565..50ed54dca595 100644 --- a/gdal/frmts/gtiff/geotiff.cpp +++ b/gdal/frmts/gtiff/geotiff.cpp @@ -13889,16 +13889,7 @@ CPLErr GTiffDataset::OpenOffset( TIFF *hTIFFIn, dfNoDataValue = CPLAtofM( pszText ); if( nBitsPerSample == 32 && nSampleFormat == SAMPLEFORMAT_IEEEFP ) { - if( fabs(dfNoDataValue - std::numeric_limits::max()) < - 1e-10 * std::numeric_limits::max() ) - { - dfNoDataValue = std::numeric_limits::max(); - } - else if( fabs(dfNoDataValue - (-std::numeric_limits::max())) < - 1e-10 * std::numeric_limits::max() ) - { - dfNoDataValue = -std::numeric_limits::max(); - } + dfNoDataValue = GDALAdjustNoDataCloseToFloatMax(dfNoDataValue); } } diff --git a/gdal/gcore/gdalrasterband.cpp b/gdal/gcore/gdalrasterband.cpp index 02303ad029df..ff0874bdf9b0 100644 --- a/gdal/gcore/gdalrasterband.cpp +++ b/gdal/gcore/gdalrasterband.cpp @@ -2860,26 +2860,13 @@ static inline void ComputeFloatNoDataValue( GDALDataType eDataType, { if( eDataType == GDT_Float32 && bGotNoDataValue ) { + dfNoDataValue = GDALAdjustNoDataCloseToFloatMax(dfNoDataValue); if (GDALIsValueInRange(dfNoDataValue) ) { fNoDataValue = static_cast(dfNoDataValue); bGotFloatNoDataValue = true; bGotNoDataValue = false; } - else if( fabs(dfNoDataValue - std::numeric_limits::max()) < - 1e-10 * std::numeric_limits::max() ) - { - fNoDataValue = std::numeric_limits::max(); - bGotFloatNoDataValue = true; - bGotNoDataValue = false; - } - else if( fabs(dfNoDataValue - (-std::numeric_limits::max())) < - 1e-10 * std::numeric_limits::max() ) - { - fNoDataValue = -std::numeric_limits::max(); - bGotFloatNoDataValue = true; - bGotNoDataValue = false; - } } } From 22058ee3036cda03e00e0a6c73fb6802c46dab14 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 3 Nov 2018 19:46:30 +0100 Subject: [PATCH 027/488] Internal libtiff: resync with upstream --- gdal/frmts/gtiff/libtiff/tif_config.h | 2 ++ gdal/frmts/gtiff/libtiff/tif_dir.h | 4 ++++ gdal/frmts/gtiff/libtiff/tif_webp.c | 5 +++-- gdal/frmts/gtiff/libtiff/tiffio.h | 2 +- gdal/frmts/gtiff/libtiff/tiffiop.h | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gdal/frmts/gtiff/libtiff/tif_config.h b/gdal/frmts/gtiff/libtiff/tif_config.h index 938d785e7bad..8f2cb37c0135 100644 --- a/gdal/frmts/gtiff/libtiff/tif_config.h +++ b/gdal/frmts/gtiff/libtiff/tif_config.h @@ -62,9 +62,11 @@ #ifdef _WIN64 # define TIFF_SSIZE_T GIntBig # define TIFF_SSIZE_FORMAT CPL_FRMT_GIB +# define TIFF_SIZE_FORMAT CPL_FRMT_GUIB #else # define TIFF_SSIZE_T signed long # define TIFF_SSIZE_FORMAT "%ld" +# define TIFF_SIZE_FORMAT "%lu" #endif /* Unsigned 16-bit type */ diff --git a/gdal/frmts/gtiff/libtiff/tif_dir.h b/gdal/frmts/gtiff/libtiff/tif_dir.h index bb508addb401..b2f5e694883b 100644 --- a/gdal/frmts/gtiff/libtiff/tif_dir.h +++ b/gdal/frmts/gtiff/libtiff/tif_dir.h @@ -24,6 +24,10 @@ #ifndef _TIFFDIR_ #define _TIFFDIR_ + +#include "tiff.h" +#include "tiffio.h" + /* * ``Library-private'' Directory-related Definitions. */ diff --git a/gdal/frmts/gtiff/libtiff/tif_webp.c b/gdal/frmts/gtiff/libtiff/tif_webp.c index 0753c00f709e..a002f481daa6 100644 --- a/gdal/frmts/gtiff/libtiff/tif_webp.c +++ b/gdal/frmts/gtiff/libtiff/tif_webp.c @@ -79,8 +79,8 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size, if ( (tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize ) { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer too small by %lu bytes.", - tif->tif_rawcc + data_size - tif->tif_rawdatasize); + "Buffer too small by " TIFF_SIZE_FORMAT " bytes.", + (size_t) (tif->tif_rawcc + data_size - tif->tif_rawdatasize)); return 0; } else { _TIFFmemcpy(tif->tif_rawcp, data, data_size); @@ -594,6 +594,7 @@ TWebPVGetField(TIFF* tif, uint32 tag, va_list ap) break; case TIFFTAG_WEBP_LOSSLESS: *va_arg(ap, int*) = sp->lossless; + break; default: return (*sp->vgetparent)(tif, tag, ap); } diff --git a/gdal/frmts/gtiff/libtiff/tiffio.h b/gdal/frmts/gtiff/libtiff/tiffio.h index 670cd426c9cb..31c2e676e759 100644 --- a/gdal/frmts/gtiff/libtiff/tiffio.h +++ b/gdal/frmts/gtiff/libtiff/tiffio.h @@ -50,7 +50,7 @@ typedef struct tiff TIFF; * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions + * NB: tsize_t is signed and not unsigned because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit diff --git a/gdal/frmts/gtiff/libtiff/tiffiop.h b/gdal/frmts/gtiff/libtiff/tiffiop.h index 9e96d36e5cae..186c291f5d7a 100644 --- a/gdal/frmts/gtiff/libtiff/tiffiop.h +++ b/gdal/frmts/gtiff/libtiff/tiffiop.h @@ -70,6 +70,7 @@ extern int snprintf(char* str, size_t size, const char* format, ...); #endif #define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) #ifndef TRUE #define TRUE 1 From 01b286eda6e94da5f5b3fb14d16583ad282690e8 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 3 Nov 2018 20:31:46 +0100 Subject: [PATCH 028/488] Fix warning on trusty_32bit --- gdal/frmts/gtiff/libtiff/tif_config.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdal/frmts/gtiff/libtiff/tif_config.h b/gdal/frmts/gtiff/libtiff/tif_config.h index 8f2cb37c0135..b691b5bf36bb 100644 --- a/gdal/frmts/gtiff/libtiff/tif_config.h +++ b/gdal/frmts/gtiff/libtiff/tif_config.h @@ -66,7 +66,11 @@ #else # define TIFF_SSIZE_T signed long # define TIFF_SSIZE_FORMAT "%ld" -# define TIFF_SIZE_FORMAT "%lu" +# if SIZEOF_VOIDP == 8 +# define TIFF_SIZE_FORMAT "%lu" +# else +# define TIFF_SIZE_FORMAT "%u" +# endif #endif /* Unsigned 16-bit type */ From fd6cf3bad9192247dff77dbf055eb387a05c321e Mon Sep 17 00:00:00 2001 From: jratike80 Date: Mon, 5 Nov 2018 11:54:16 +0200 Subject: [PATCH 029/488] Fix wrong doublequote charactes in OCI manual --- gdal/ogr/ogrsf_frmts/oci/drv_oci.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/oci/drv_oci.html b/gdal/ogr/ogrsf_frmts/oci/drv_oci.html index 432e25fc95a9..27a903079152 100644 --- a/gdal/ogr/ogrsf_frmts/oci/drv_oci.html +++ b/gdal/ogr/ogrsf_frmts/oci/drv_oci.html @@ -102,11 +102,11 @@

Layer Creation Options

  • OVERWRITE: This may be "YES" to force an existing layer (=table) of the same desired name to be destroyed before creating the requested layer. -The default value is “NO"

    +The default value is "NO"

  • TRUNCATE: This may be "YES" to force the existing table to be reused, but to first truncate all records in the table, preserving -indexes or dependencies. The default value is “NO".

    +indexes or dependencies. The default value is "NO".

  • LAUNDER: This may be "YES" to force new fields created on this layer to have their field names "laundered" into a form more compatible with From b6fd449f8a8f3ec96180eb81ded783e0e8309361 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 5 Nov 2018 23:20:04 +0100 Subject: [PATCH 030/488] ESRIJson driver doc: mention orderByFields option for paged requests (fixes #1073) [ci skip] --- gdal/ogr/ogrsf_frmts/geojson/drv_esrijson.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdal/ogr/ogrsf_frmts/geojson/drv_esrijson.html b/gdal/ogr/ogrsf_frmts/geojson/drv_esrijson.html index 0c46b69252d0..89ef82ef5050 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/drv_esrijson.html +++ b/gdal/ogr/ogrsf_frmts/geojson/drv_esrijson.html @@ -21,6 +21,10 @@

    ESRIJSON / FeatureService driver

    is subject to a server limit). If it is not set, OGR will set it to the maximum value allowed by the server.

    +

    Note: for paged requests to work properly, it is generally necessary to add +a sort clause on a field, typically the OBJECTID with a "&orderByFields=OBJECTID+ASC" +parameter in the URL, so that the server returns the results in a reliable way.

    +

    Datasource

    The driver accepts three types of sources of data:

    From ac89f261c4031e692a82501e47f87f2d9578e198 Mon Sep 17 00:00:00 2001 From: drons Date: Tue, 6 Nov 2018 22:18:22 +0300 Subject: [PATCH 031/488] PRF: Fix Photomod x-dem files georeference --- gdal/frmts/prf/phprfdataset.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdal/frmts/prf/phprfdataset.cpp b/gdal/frmts/prf/phprfdataset.cpp index a3c8e4d45f1c..656d47989e49 100644 --- a/gdal/frmts/prf/phprfdataset.cpp +++ b/gdal/frmts/prf/phprfdataset.cpp @@ -608,11 +608,11 @@ GDALDataset* PhPrfDataset::Open( GDALOpenInfo* poOpenInfo ) abDemMetadataOk[2] && abDemMetadataOk[3] ) { adfGeoTrans[0] = adfDemMetadata[0]; - adfGeoTrans[1] = (adfDemMetadata[1] - adfDemMetadata[0])/nSizeX; + adfGeoTrans[1] = (adfDemMetadata[1] - adfDemMetadata[0])/(nSizeX - 1); adfGeoTrans[2] = 0; adfGeoTrans[3] = adfDemMetadata[3]; adfGeoTrans[4] = 0; - adfGeoTrans[5] = (adfDemMetadata[2] - adfDemMetadata[3])/nSizeY; + adfGeoTrans[5] = (adfDemMetadata[2] - adfDemMetadata[3])/(nSizeY - 1); if( bDemShiftOk ) { From 71d76bef344fbf58e14e5817d80230acefc78e30 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 7 Nov 2018 03:00:41 +0100 Subject: [PATCH 032/488] MRF: add static qualifier --- gdal/frmts/mrf/JPEG_band.cpp | 4 ++-- gdal/frmts/mrf/marfa_dataset.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdal/frmts/mrf/JPEG_band.cpp b/gdal/frmts/mrf/JPEG_band.cpp index 03b6b053aaf6..7f65dda97840 100644 --- a/gdal/frmts/mrf/JPEG_band.cpp +++ b/gdal/frmts/mrf/JPEG_band.cpp @@ -164,7 +164,7 @@ static boolean empty_output_buffer(j_compress_ptr /*cinfo*/) { } // Returns the number of zero pixels in the page, as well as clearing those bits in the mask -template int update_mask(BitMask &mask, T *src, int nc) { +template static int update_mask(BitMask &mask, T *src, int nc) { int zeros = 0; int h = mask.getHeight(); int w = mask.getWidth(); @@ -379,7 +379,7 @@ static void ProgressMonitor(j_common_ptr cinfo) } // Returns the number of zero pixels, as well as clearing those bits int the mask -template void apply_mask(MRFJPEGStruct &sJ, T *s, int nc) { +template static void apply_mask(MRFJPEGStruct &sJ, T *s, int nc) { if (NO_MASK == sJ.mask_state) return; diff --git a/gdal/frmts/mrf/marfa_dataset.cpp b/gdal/frmts/mrf/marfa_dataset.cpp index 234d7092fe64..72f86b923b13 100644 --- a/gdal/frmts/mrf/marfa_dataset.cpp +++ b/gdal/frmts/mrf/marfa_dataset.cpp @@ -1676,7 +1676,7 @@ GDALDataset *GDALMRFDataset::CreateCopy(const char *pszFilename, // Prepares the data so it is suitable for Zen JPEG encoding, based on input mask // If bFBO is set, only the values of the first band are set non-zero when needed -template void ZenFilter(T* buffer, GByte *mask, int nPixels, int nBands, bool bFBO) { +template static void ZenFilter(T* buffer, GByte *mask, int nPixels, int nBands, bool bFBO) { for (int i = 0; i < nPixels; i++) { if (mask[i] == 0) { // enforce zero values for (int b = 0; b < nBands; b++) From 6ec3bfea7e6d0311e4ddfd7ad1a00b4c6fea471d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 7 Nov 2018 03:12:02 +0100 Subject: [PATCH 033/488] Fix linking with ICC --- gdal/port/cpl_safemaths.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/port/cpl_safemaths.hpp b/gdal/port/cpl_safemaths.hpp index 27391c81ce74..3bc8f063a2f9 100644 --- a/gdal/port/cpl_safemaths.hpp +++ b/gdal/port/cpl_safemaths.hpp @@ -37,7 +37,7 @@ #define __has_builtin(x) 0 #endif -#if __GNUC__ >= 5 || __has_builtin(__builtin_sadd_overflow) +#if (__GNUC__ >= 5 && !defined( __INTEL_COMPILER)) || __has_builtin(__builtin_sadd_overflow) # define BUILTIN_OVERFLOW_CHECK_AVAILABLE #elif defined(_MSC_VER) From 64b8571e6604ecfd9ea94489057b9d37e7addf28 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 8 Nov 2018 10:05:05 +0100 Subject: [PATCH 034/488] GDALNoDataMaskBand: improve performance in downsampling cases --- autotest/gcore/nodatamaskband.py | 127 ++++++++++++ gdal/gcore/gdalnodatamaskband.cpp | 334 ++++++++++++++++++------------ 2 files changed, 328 insertions(+), 133 deletions(-) create mode 100755 autotest/gcore/nodatamaskband.py diff --git a/autotest/gcore/nodatamaskband.py b/autotest/gcore/nodatamaskband.py new file mode 100755 index 000000000000..6a26923eccb4 --- /dev/null +++ b/autotest/gcore/nodatamaskband.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +############################################################################### +# $Id$ +# +# Project: GDAL/OGR Test Suite +# Purpose: Test GDALNoDataMaskBand +# Author: Even Rouault +# +############################################################################### +# Copyright (c) 2018, Even Rouault +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +############################################################################### + +import struct +import sys + +sys.path.append('../pymod') + +import gdaltest +from osgeo import gdal + + +def nodatamaskband_1(): + + for (dt, struct_type, v) in [(gdal.GDT_Byte, 'B', 255), + (gdal.GDT_Int16, 'h', 32767), + (gdal.GDT_UInt16, 'H', 65535), + (gdal.GDT_Int32, 'i', 0x7FFFFFFF), + (gdal.GDT_UInt32, 'I', 0xFFFFFFFF), + (gdal.GDT_Float32, 'f', 1.25), + (gdal.GDT_Float32, 'f', float('nan')), + (gdal.GDT_Float64, 'd', 1.2345678), + (gdal.GDT_Float64, 'd', float('nan'))]: + + ds = gdal.GetDriverByName('MEM').Create('', 6, 4, 1, dt) + ds.GetRasterBand(1).SetNoDataValue(v) + ds.GetRasterBand(1).WriteRaster(0, 0, 6, 4, + struct.pack(struct_type * 6 * 4, + v, 1, 1, v, v, 0, + v, 1, 1, v, v, 0, + v, 1, 1, v, v, 0, + 0, v, v, 0, 0, 0)) + + data = ds.GetRasterBand(1).GetMaskBand().ReadRaster() + data_ar = struct.unpack('B' * 6 * 4, data) + expected_ar = (0, 255, 255, 0, 0, 255, + 0, 255, 255, 0, 0, 255, + 0, 255, 255, 0, 0, 255, + 255, 0, 0, 255, 255, 255) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(dt) + print(data_ar) + return 'fail' + + data = ds.GetRasterBand(1).GetMaskBand().ReadBlock(0, 0) + data_ar = struct.unpack('B' * 6 * 1, data) + expected_ar = (0, 255, 255, 0, 0, 255) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(dt) + print(data_ar) + return 'fail' + + data = ds.GetRasterBand(1).GetMaskBand().ReadBlock(0, 3) + data_ar = struct.unpack('B' * 6 * 1, data) + expected_ar = (255, 0, 0, 255, 255, 255) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(dt) + print(data_ar) + return 'fail' + + data = ds.GetRasterBand(1).GetMaskBand().ReadRaster( + buf_xsize=3, buf_ysize=2) + data_ar = struct.unpack('B' * 3 * 2, data) + expected_ar = (255, 0, 255, + 0, 255, 255) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(dt) + print(data_ar) + return 'fail' + + data = ds.GetRasterBand(1).GetMaskBand().ReadRaster( + buf_type=gdal.GDT_UInt16, buf_xsize=3, buf_ysize=2) + data_ar = struct.unpack('H' * 3 * 2, data) + expected_ar = (255, 0, 255, + 0, 255, 255) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(dt) + print(data_ar) + return 'fail' + + return 'success' + + +gdaltest_list = [ + nodatamaskband_1, +] + +if __name__ == '__main__': + + gdaltest.setup_run('nodatamaskband') + + gdaltest.run_tests(gdaltest_list) + + sys.exit(gdaltest.summarize()) diff --git a/gdal/gcore/gdalnodatamaskband.cpp b/gdal/gcore/gdalnodatamaskband.cpp index b97cf8a5119f..10a87cab048a 100644 --- a/gdal/gcore/gdalnodatamaskband.cpp +++ b/gdal/gcore/gdalnodatamaskband.cpp @@ -31,6 +31,7 @@ #include "cpl_port.h" #include "gdal_priv.h" +#include #include #include "cpl_conv.h" @@ -160,132 +161,21 @@ CPLErr GDALNoDataMaskBand::IReadBlock( int nXBlockOff, int nYBlockOff, void * pImage ) { - GDALDataType eWrkDT = GetWorkDataType( poParent->GetRasterDataType() ); + const int nXOff = nXBlockOff * nBlockXSize; + const int nXSizeRequest = std::min(nBlockXSize, nRasterXSize - nXOff); + const int nYOff = nYBlockOff * nBlockYSize; + const int nYSizeRequest = std::min(nBlockYSize, nRasterYSize - nYOff); -/* -------------------------------------------------------------------- */ -/* Read the image data. */ -/* -------------------------------------------------------------------- */ - // TODO(schwehr): pabySrc would probably be better as a void ptr. - GByte *pabySrc = static_cast( - VSI_MALLOC3_VERBOSE( GDALGetDataTypeSizeBytes(eWrkDT), - nBlockXSize, nBlockYSize ) ); - if (pabySrc == nullptr) - { - return CE_Failure; - } - - int nXSizeRequest = nBlockXSize; - if (nXBlockOff * nBlockXSize + nBlockXSize > nRasterXSize) - nXSizeRequest = nRasterXSize - nXBlockOff * nBlockXSize; - int nYSizeRequest = nBlockYSize; - if (nYBlockOff * nBlockYSize + nBlockYSize > nRasterYSize) - nYSizeRequest = nRasterYSize - nYBlockOff * nBlockYSize; - - if (nXSizeRequest != nBlockXSize || nYSizeRequest != nBlockYSize) - { - // memset the whole buffer to avoid Valgrind warnings in case RasterIO - // fetches a partial block. - memset( pabySrc, 0, - GDALGetDataTypeSizeBytes(eWrkDT) * nBlockXSize * nBlockYSize ); - } - - CPLErr eErr = - poParent->RasterIO( GF_Read, - nXBlockOff * nBlockXSize, - nYBlockOff * nBlockYSize, - nXSizeRequest, nYSizeRequest, - pabySrc, nXSizeRequest, nYSizeRequest, - eWrkDT, 0, - nBlockXSize * GDALGetDataTypeSizeBytes(eWrkDT), - nullptr ); - if( eErr != CE_None ) + if( nBlockXSize != nXSizeRequest || nBlockYSize != nYSizeRequest ) { - CPLFree(pabySrc); - return eErr; + memset(pImage, 0, nBlockXSize * nBlockYSize); } - const bool bIsNoDataNan = CPLIsNan(dfNoDataValue) != 0; - -/* -------------------------------------------------------------------- */ -/* Process different cases. */ -/* -------------------------------------------------------------------- */ - switch( eWrkDT ) - { - case GDT_Byte: - { - GByte byNoData = static_cast( dfNoDataValue ); - - for( int i = 0; i < nBlockXSize * nBlockYSize; i++ ) - { - static_cast(pImage)[i] = pabySrc[i] == byNoData ? 0: 255; - } - } - break; - - case GDT_UInt32: - { - GUInt32 nNoData = static_cast( dfNoDataValue ); - - for( int i = 0; i < nBlockXSize * nBlockYSize; i++ ) - { - static_cast(pImage)[i] = - reinterpret_cast(pabySrc)[i] == nNoData ? 0 : 255; - } - } - break; - - case GDT_Int32: - { - GInt32 nNoData = static_cast( dfNoDataValue ); - - for( int i = 0; i < nBlockXSize * nBlockYSize; i++ ) - { - static_cast(pImage)[i] = - reinterpret_cast(pabySrc)[i] == nNoData ? 0 : 255; - } - } - break; - - case GDT_Float32: - { - float fNoData = static_cast( dfNoDataValue ); - - for( int i = 0; i < nBlockXSize * nBlockYSize; i++ ) - { - const float fVal = reinterpret_cast(pabySrc)[i]; - if( bIsNoDataNan && CPLIsNan(fVal)) - static_cast(pImage)[i] = 0; - else if( ARE_REAL_EQUAL(fVal, fNoData) ) - static_cast(pImage)[i] = 0; - else - static_cast(pImage)[i] = 255; - } - } - break; - - case GDT_Float64: - { - for( int i = 0; i < nBlockXSize * nBlockYSize; i++ ) - { - const double dfVal = reinterpret_cast(pabySrc)[i]; - if( bIsNoDataNan && CPLIsNan(dfVal)) - static_cast(pImage)[i] = 0; - else if( ARE_REAL_EQUAL(dfVal, dfNoDataValue) ) - static_cast(pImage)[i] = 0; - else - static_cast(pImage)[i] = 255; - } - } - break; - - default: - CPLAssert( false ); - break; - } - - CPLFree( pabySrc ); - - return CE_None; + GDALRasterIOExtraArg sExtraArg; + INIT_RASTERIO_EXTRA_ARG(sExtraArg); + return IRasterIO(GF_Read, nXOff, nYOff, nXSizeRequest, nYSizeRequest, + pImage, nXSizeRequest, nYSizeRequest, + GDT_Byte, 1, nBlockXSize, &sExtraArg); } /************************************************************************/ @@ -301,13 +191,17 @@ CPLErr GDALNoDataMaskBand::IRasterIO( GDALRWFlag eRWFlag, GSpacing nPixelSpace, GSpacing nLineSpace, GDALRasterIOExtraArg* psExtraArg ) { + if( eRWFlag != GF_Read ) + { + return CE_Failure; + } + + const GDALDataType eWrkDT = GetWorkDataType( poParent->GetRasterDataType() ); + // Optimization in common use case (#4488). // This avoids triggering the block cache on this band, which helps // reducing the global block cache consumption. - if (eRWFlag == GF_Read && eBufType == GDT_Byte && - poParent->GetRasterDataType() == GDT_Byte && - nXSize == nBufXSize && nYSize == nBufYSize && - nPixelSpace == 1 && nLineSpace == nBufXSize) + if (eBufType == GDT_Byte && eWrkDT == GDT_Byte) { const CPLErr eErr = poParent->RasterIO( GF_Read, nXOff, nYOff, nXSize, nYSize, @@ -318,18 +212,192 @@ CPLErr GDALNoDataMaskBand::IRasterIO( GDALRWFlag eRWFlag, return eErr; GByte* pabyData = static_cast( pData ); - GByte byNoData = static_cast( dfNoDataValue ); + const GByte byNoData = static_cast( dfNoDataValue ); - for( int i = nBufXSize * nBufYSize - 1; i >= 0; --i ) + if( nPixelSpace == 1 && nLineSpace == nBufXSize ) + { + const size_t nBufSize = static_cast(nBufXSize) * nBufYSize; + for( size_t i = 0; i < nBufSize; ++i ) + { + pabyData[i] = pabyData[i] == byNoData ? 0 : 255; + } + } + else { - pabyData[i] = pabyData[i] == byNoData ? 0 : 255; + for( int iY = 0; iY < nBufYSize; iY++ ) + { + GByte* pabyLine = pabyData + iY * nLineSpace; + for( int iX = 0; iX < nBufXSize; iX++ ) + { + *pabyLine = *pabyLine == byNoData ? 0 : 255; + pabyLine += nPixelSpace; + } + } } return CE_None; } - return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, - pData, nBufXSize, nBufYSize, - eBufType, - nPixelSpace, nLineSpace, psExtraArg ); + if( eBufType == GDT_Byte ) + { + const int nWrkDTSize = GDALGetDataTypeSizeBytes(eWrkDT); + void *pTemp = + VSI_MALLOC3_VERBOSE( nWrkDTSize, nBufXSize, nBufYSize ); + if (pTemp == nullptr) + { + return GDALRasterBand::IRasterIO( + eRWFlag, nXOff, nYOff, nXSize, nYSize, + pTemp, nBufXSize, nBufYSize, + eWrkDT, + nWrkDTSize, nBufXSize * nWrkDTSize, + psExtraArg ); + } + + const CPLErr eErr = + poParent->RasterIO( GF_Read, nXOff, nYOff, nXSize, nYSize, + pTemp, nBufXSize, nBufYSize, + eWrkDT, + nWrkDTSize, nBufXSize * nWrkDTSize, psExtraArg ); + if (eErr != CE_None) + { + VSIFree(pTemp); + return eErr; + } + + const bool bIsNoDataNan = CPLIsNan(dfNoDataValue) != 0; + GByte* pabyDest = static_cast(pData); + +/* -------------------------------------------------------------------- */ +/* Process different cases. */ +/* -------------------------------------------------------------------- */ + switch( eWrkDT ) + { + case GDT_UInt32: + { + const GUInt32 nNoData = static_cast( dfNoDataValue ); + const GUInt32* panSrc = static_cast(pTemp); + + size_t i = 0; + for( int iY = 0; iY < nBufYSize; iY++ ) + { + GByte* pabyLineDest = pabyDest + iY * nLineSpace; + for( int iX = 0; iX < nBufXSize; iX++ ) + { + *pabyLineDest = panSrc[i] == nNoData ? 0 : 255; + ++i; + pabyLineDest += nPixelSpace; + } + } + } + break; + + case GDT_Int32: + { + const GInt32 nNoData = static_cast( dfNoDataValue ); + const GInt32* panSrc = static_cast(pTemp); + + size_t i = 0; + for( int iY = 0; iY < nBufYSize; iY++ ) + { + GByte* pabyLineDest = pabyDest + iY * nLineSpace; + for( int iX = 0; iX < nBufXSize; iX++ ) + { + *pabyLineDest = panSrc[i] == nNoData ? 0 : 255; + ++i; + pabyLineDest += nPixelSpace; + } + } + } + break; + + case GDT_Float32: + { + const float fNoData = static_cast( dfNoDataValue ); + const float* pafSrc = static_cast(pTemp); + + size_t i = 0; + for( int iY = 0; iY < nBufYSize; iY++ ) + { + GByte* pabyLineDest = pabyDest + iY * nLineSpace; + for( int iX = 0; iX < nBufXSize; iX++ ) + { + const float fVal = pafSrc[i]; + if( bIsNoDataNan && CPLIsNan(fVal)) + *pabyLineDest = 0; + else if( ARE_REAL_EQUAL(fVal, fNoData) ) + *pabyLineDest = 0; + else + *pabyLineDest = 255; + ++i; + pabyLineDest += nPixelSpace; + } + } + } + break; + + case GDT_Float64: + { + const double* padfSrc = static_cast(pTemp); + + size_t i = 0; + for( int iY = 0; iY < nBufYSize; iY++ ) + { + GByte* pabyLineDest = pabyDest + iY * nLineSpace; + for( int iX = 0; iX < nBufXSize; iX++ ) + { + const double dfVal = padfSrc[i]; + if( bIsNoDataNan && CPLIsNan(dfVal)) + *pabyLineDest = 0; + else if( ARE_REAL_EQUAL(dfVal, dfNoDataValue) ) + *pabyLineDest = 0; + else + *pabyLineDest = 255; + ++i; + pabyLineDest += nPixelSpace; + } + } + } + break; + + default: + CPLAssert( false ); + break; + } + + VSIFree(pTemp); + return CE_None; + } + + // Output buffer is non-Byte. Ask for Byte and expand to user requested + // type + GByte* pabyBuf = static_cast( + VSI_MALLOC2_VERBOSE( nBufXSize, nBufYSize )); + if( pabyBuf == nullptr ) + { + return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, + eBufType, + nPixelSpace, nLineSpace, psExtraArg ); + } + const CPLErr eErr = IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pabyBuf, nBufXSize, nBufYSize, + GDT_Byte, + 1, nBufXSize, psExtraArg ); + if( eErr != CE_None ) + { + VSIFree(pabyBuf); + return eErr; + } + + for( int iY = 0; iY < nBufYSize; iY++ ) + { + GDALCopyWords( pabyBuf + static_cast(iY) * nBufXSize, + GDT_Byte, 1, + static_cast(pData) + + iY * nLineSpace, eBufType, + static_cast(nPixelSpace), + nBufXSize ); + } + VSIFree(pabyBuf); + return CE_None; } //! @endcond From beade9d55838ac41f7a798dceb5fce56213a0336 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 8 Nov 2018 11:23:07 +0100 Subject: [PATCH 035/488] /vsicurl/ and derived: implement a LRU cache for file properties (instead of ever growing cache) --- gdal/port/cpl_vsil_az.cpp | 12 +- gdal/port/cpl_vsil_curl.cpp | 316 +++++++++++++++----------------- gdal/port/cpl_vsil_curl_class.h | 36 ++-- gdal/port/cpl_vsil_s3.cpp | 39 ++-- gdal/port/cpl_vsil_swift.cpp | 30 +-- gdal/port/cpl_vsil_webhdfs.cpp | 58 +++--- 6 files changed, 235 insertions(+), 256 deletions(-) diff --git a/gdal/port/cpl_vsil_az.cpp b/gdal/port/cpl_vsil_az.cpp index a2121ba0c5aa..4ca7e9bd8f16 100644 --- a/gdal/port/cpl_vsil_az.cpp +++ b/gdal/port/cpl_vsil_az.cpp @@ -83,7 +83,7 @@ void VSICurlFilesystemHandler::AnalyseAzureFileList( return; CPLXMLNode* psEnumerationResults = CPLGetXMLNode(psTree, "=EnumerationResults"); - std::vector< std::pair > aoProps; + std::vector< std::pair > aoProps; // Count the number of occurrences of a path. Can be 1 or 2. 2 in the case // that both a filename and directory exist std::map aoNameCount; @@ -115,7 +115,7 @@ void VSICurlFilesystemHandler::AnalyseAzureFileList( { bNonEmpty = true; - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bHasComputedFileSize = true; prop.fileSize = static_cast( @@ -148,7 +148,7 @@ void VSICurlFilesystemHandler::AnalyseAzureFileList( } aoProps.push_back( - std::pair + std::pair (pszKey + osPrefix.size(), prop)); aoNameCount[pszKey + osPrefix.size()] ++; } @@ -166,7 +166,7 @@ void VSICurlFilesystemHandler::AnalyseAzureFileList( osKey.resize(osKey.size()-1); if( osKey.size() > osPrefix.size() ) { - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bIsDirectory = true; prop.bHasComputedFileSize = true; @@ -174,7 +174,7 @@ void VSICurlFilesystemHandler::AnalyseAzureFileList( prop.mTime = 0; aoProps.push_back( - std::pair + std::pair (osKey.c_str() + osPrefix.size(), prop)); aoNameCount[osKey.c_str() + osPrefix.size()] ++; } @@ -211,7 +211,7 @@ void VSICurlFilesystemHandler::AnalyseAzureFileList( #if DEBUG_VERBOSE CPLDebug("AZURE", "Cache %s", osCachedFilename.c_str()); #endif - *GetCachedFileProp(osCachedFilename) = aoProps[i].second; + SetCachedFileProp(osCachedFilename, aoProps[i].second); } osFileList.AddString( (aoProps[i].first + osSuffix).c_str() ); } diff --git a/gdal/port/cpl_vsil_curl.cpp b/gdal/port/cpl_vsil_curl.cpp index a1d7fdb3d330..e4af0455e10d 100644 --- a/gdal/port/cpl_vsil_curl.cpp +++ b/gdal/port/cpl_vsil_curl.cpp @@ -325,12 +325,7 @@ VSICurlHandle::VSICurlHandle( VSICurlFilesystemHandler* poFSIn, } m_bCached = poFSIn->AllowCachedDataFor(pszFilename); - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - eExists = cachedFileProp->eExists; - fileSize = cachedFileProp->fileSize; - bHasComputedFileSize = cachedFileProp->bHasComputedFileSize; - bIsDirectory = cachedFileProp->bIsDirectory; - mTime = cachedFileProp->mTime; + poFS->GetCachedFileProp(m_pszURL, oFileProp); } /************************************************************************/ @@ -710,10 +705,10 @@ void VSICURLResetHeaderAndWriterFunctions(CURL* hCurlHandle) vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) { - if( bHasComputedFileSize ) - return fileSize; + if( oFileProp.bHasComputedFileSize ) + return oFileProp.fileSize; - bHasComputedFileSize = true; + oFileProp.bHasComputedFileSize = true; CURLM* hCurlMultiHandle = poFS->GetCurlMultiHandleFor(m_pszURL); @@ -800,7 +795,7 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) curl_slist_free_all(headers); - eExists = EXIST_UNKNOWN; + oFileProp.eExists = EXIST_UNKNOWN; long mtime = 0; curl_easy_getinfo(hCurlHandle, CURLINFO_FILETIME, &mtime); @@ -814,19 +809,19 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) if( pszContentLength ) { pszContentLength += strlen("Content-Length: "); - eExists = EXIST_YES; - fileSize = CPLScanUIntBig( + oFileProp.eExists = EXIST_YES; + oFileProp.fileSize = CPLScanUIntBig( pszContentLength, static_cast(strlen(pszContentLength))); if( ENABLE_DEBUG ) CPLDebug("VSICURL", "GetFileSize(%s)=" CPL_FRMT_GUIB, - osURL.c_str(), fileSize); + osURL.c_str(), oFileProp.fileSize); } } } double dfSize = 0; - if( eExists != EXIST_YES ) + if( oFileProp.eExists != EXIST_YES ) { long response_code = 0; curl_easy_getinfo(hCurlHandle, CURLINFO_HTTP_CODE, &response_code); @@ -894,14 +889,10 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) nValidity); // As our local clock might not be in sync with server clock, // figure out the expiration timestamp in local time - m_bS3LikeRedirect = true; - m_nExpireTimestampLocal = time(nullptr) + nValidity; - m_osRedirectURL = osEffectiveURL; - CachedFileProp* cachedFileProp = - poFS->GetCachedFileProp(m_pszURL); - cachedFileProp->bS3LikeRedirect = m_bS3LikeRedirect; - cachedFileProp->nExpireTimestampLocal = m_nExpireTimestampLocal; - cachedFileProp->osRedirectURL = m_osRedirectURL; + oFileProp.bS3LikeRedirect = true; + oFileProp.nExpireTimestampLocal = time(nullptr) + nValidity; + oFileProp.osRedirectURL = osEffectiveURL; + poFS->SetCachedFileProp(m_pszURL, oFileProp); } } @@ -910,17 +901,17 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) &dfSize ); if( code == 0 ) { - eExists = EXIST_YES; + oFileProp.eExists = EXIST_YES; if( dfSize < 0 ) - fileSize = 0; + oFileProp.fileSize = 0; else - fileSize = static_cast(dfSize); + oFileProp.fileSize = static_cast(dfSize); } if( UseLimitRangeGetInsteadOfHead() && response_code == 206 ) { - eExists = EXIST_NO; - fileSize = 0; + oFileProp.eExists = EXIST_NO; + oFileProp.fileSize = 0; if( sWriteFuncHeaderData.pBuffer != nullptr ) { const char* pszContentRange = @@ -933,8 +924,8 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) pszContentRange = strchr(pszContentRange, '/'); if( pszContentRange ) { - eExists = EXIST_YES; - fileSize = static_cast( + oFileProp.eExists = EXIST_YES; + oFileProp.fileSize = static_cast( CPLAtoGIntBig(pszContentRange + 1)); } @@ -956,9 +947,9 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) else if ( IsDirectoryFromExists(osVerb, static_cast(response_code)) ) { - eExists = EXIST_YES; - fileSize = 0; - bIsDirectory = true; + oFileProp.eExists = EXIST_YES; + oFileProp.fileSize = 0; + oFileProp.bIsDirectory = true; } // 405 = Method not allowed else if (response_code == 405 && !bRetryWithGet && osVerb == "HEAD" ) @@ -972,8 +963,8 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) } else if( response_code == 416 ) { - eExists = EXIST_YES; - fileSize = 0; + oFileProp.eExists = EXIST_YES; + oFileProp.fileSize = 0; } else if( response_code != 200 ) { @@ -1005,7 +996,7 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) sWriteFuncHeaderData.pBuffer, bSetError) ) { - bHasComputedFileSize = false; + oFileProp.bHasComputedFileSize = false; CPLFree(sWriteFuncData.pBuffer); CPLFree(sWriteFuncHeaderData.pBuffer); curl_easy_cleanup(hCurlHandle); @@ -1047,8 +1038,8 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) // else a CPLDebug() is emitted below } - eExists = EXIST_NO; - fileSize = 0; + oFileProp.eExists = EXIST_NO; + oFileProp.fileSize = 0; } else if( sWriteFuncData.pBuffer != nullptr ) { @@ -1061,20 +1052,20 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) strncmp(osURL, osEffectiveURL, osURL.size()) == 0 && osEffectiveURL[osURL.size()] == '/' ) { - eExists = EXIST_YES; - fileSize = 0; - bIsDirectory = true; + oFileProp.eExists = EXIST_YES; + oFileProp.fileSize = 0; + oFileProp.bIsDirectory = true; } else if( osURL.back() == '/' ) { - bIsDirectory = true; + oFileProp.bIsDirectory = true; } if( ENABLE_DEBUG && szCurlErrBuf[0] == '\0' ) { CPLDebug("VSICURL", "GetFileSize(%s)=" CPL_FRMT_GUIB " response_code=%d", - osURL.c_str(), fileSize, + osURL.c_str(), oFileProp.fileSize, static_cast(response_code)); } } @@ -1083,15 +1074,12 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) CPLFree(sWriteFuncHeaderData.pBuffer); curl_easy_cleanup(hCurlHandle); - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - cachedFileProp->bHasComputedFileSize = true; - cachedFileProp->fileSize = fileSize; - cachedFileProp->eExists = eExists; - cachedFileProp->bIsDirectory = bIsDirectory; + oFileProp.bHasComputedFileSize = true; if( mtime != 0 ) - cachedFileProp->mTime = mtime; + oFileProp.mTime = mtime; + poFS->SetCachedFileProp(m_pszURL, oFileProp); - return fileSize; + return oFileProp.fileSize; } /************************************************************************/ @@ -1100,11 +1088,11 @@ vsi_l_offset VSICurlHandle::GetFileSize( bool bSetError ) bool VSICurlHandle::Exists( bool bSetError ) { - if( eExists == EXIST_UNKNOWN ) + if( oFileProp.eExists == EXIST_UNKNOWN ) { GetFileSize(bSetError); } - return eExists == EXIST_YES; + return oFileProp.eExists == EXIST_YES; } /************************************************************************/ @@ -1120,33 +1108,27 @@ vsi_l_offset VSICurlHandle::Tell() /* GetRedirectURLIfValid() */ /************************************************************************/ -CPLString VSICurlHandle::GetRedirectURLIfValid(CachedFileProp* cachedFileProp, - bool& bHasExpired) +CPLString VSICurlHandle::GetRedirectURLIfValid(bool& bHasExpired) { bHasExpired = false; - if( cachedFileProp->bS3LikeRedirect ) - { - m_bS3LikeRedirect = cachedFileProp->bS3LikeRedirect; - m_nExpireTimestampLocal = cachedFileProp->nExpireTimestampLocal; - m_osRedirectURL = cachedFileProp->osRedirectURL; - } + poFS->GetCachedFileProp(m_pszURL, oFileProp); CPLString osURL(m_pszURL); - if( m_bS3LikeRedirect ) + if( oFileProp.bS3LikeRedirect ) { - if( time(nullptr) + 1 < m_nExpireTimestampLocal ) + if( time(nullptr) + 1 < oFileProp.nExpireTimestampLocal ) { CPLDebug("VSICURL", "Using redirect URL as it looks to be still valid " "(%d seconds left)", - static_cast(m_nExpireTimestampLocal - time(nullptr))); - osURL = m_osRedirectURL; + static_cast(oFileProp.nExpireTimestampLocal - time(nullptr))); + osURL = oFileProp.osRedirectURL; } else { CPLDebug("VSICURL", "Redirect URL has expired. Using original URL"); - m_bS3LikeRedirect = false; - cachedFileProp->bS3LikeRedirect = false; + oFileProp.bS3LikeRedirect = false; + poFS->SetCachedFileProp(m_pszURL, oFileProp); bHasExpired = true; } } @@ -1163,14 +1145,13 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, if( bInterrupted && bStopOnInterruptUntilUninstall ) return false; - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - if( cachedFileProp->eExists == EXIST_NO ) + if( oFileProp.eExists == EXIST_NO ) return false; CURLM* hCurlMultiHandle = poFS->GetCurlMultiHandleFor(m_pszURL); bool bHasExpired = false; - CPLString osURL(GetRedirectURLIfValid(cachedFileProp, bHasExpired)); + CPLString osURL(GetRedirectURLIfValid(bHasExpired)); bool bUsedRedirect = osURL != m_pszURL; WriteFuncStruct sWriteFuncData; @@ -1202,10 +1183,10 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, sWriteFuncHeaderData.nEndOffset = startOffset + nBlocks * DOWNLOAD_CHUNK_SIZE - 1; // Some servers don't like we try to read after end-of-file (#5786). - if( cachedFileProp->bHasComputedFileSize && - sWriteFuncHeaderData.nEndOffset >= cachedFileProp->fileSize ) + if( oFileProp.bHasComputedFileSize && + sWriteFuncHeaderData.nEndOffset >= oFileProp.fileSize ) { - sWriteFuncHeaderData.nEndOffset = cachedFileProp->fileSize - 1; + sWriteFuncHeaderData.nEndOffset = oFileProp.fileSize - 1; } char rangeStr[512] = {}; @@ -1267,7 +1248,10 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, long mtime = 0; curl_easy_getinfo(hCurlHandle, CURLINFO_FILETIME, &mtime); if( mtime != 0 ) - cachedFileProp->mTime = mtime; + { + oFileProp.mTime = mtime; + poFS->SetCachedFileProp(m_pszURL, oFileProp); + } if( ENABLE_DEBUG ) CPLDebug("VSICURL", "Got response_code=%ld", response_code); @@ -1276,8 +1260,8 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, { CPLDebug("VSICURL", "Got an error with redirect URL. Retrying with original one"); - m_bS3LikeRedirect = false; - cachedFileProp->bS3LikeRedirect = false; + oFileProp.bS3LikeRedirect = false; + poFS->SetCachedFileProp(m_pszURL, oFileProp); bUsedRedirect = false; osURL = m_pszURL; CPLFree(sWriteFuncData.pBuffer); @@ -1294,7 +1278,7 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, osEffectiveURL = pszEffectiveURL; } - if( !m_bS3LikeRedirect && !osEffectiveURL.empty() && + if( !oFileProp.bS3LikeRedirect && !osEffectiveURL.empty() && strstr(osEffectiveURL, m_pszURL) == nullptr ) { CPLDebug("VSICURL", "Effective URL: %s", osEffectiveURL.c_str()); @@ -1317,12 +1301,10 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, nValidity); // As our local clock might not be in sync with server clock, // figure out the expiration timestamp in local time. - m_bS3LikeRedirect = true; - m_nExpireTimestampLocal = time(nullptr) + nValidity; - m_osRedirectURL = osEffectiveURL; - cachedFileProp->bS3LikeRedirect = m_bS3LikeRedirect; - cachedFileProp->nExpireTimestampLocal = m_nExpireTimestampLocal; - cachedFileProp->osRedirectURL = m_osRedirectURL; + oFileProp.bS3LikeRedirect = true; + oFileProp.nExpireTimestampLocal = time(nullptr) + nValidity; + oFileProp.osRedirectURL = osEffectiveURL; + poFS->SetCachedFileProp(m_pszURL, oFileProp); } } } @@ -1375,11 +1357,12 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, CPLError(CE_Failure, CPLE_AppDefined, "%d: %s", static_cast(response_code), szCurlErrBuf); } - if( !bHasComputedFileSize && startOffset == 0 ) + if( !oFileProp.bHasComputedFileSize && startOffset == 0 ) { - cachedFileProp->bHasComputedFileSize = bHasComputedFileSize = true; - cachedFileProp->fileSize = fileSize = 0; - cachedFileProp->eExists = eExists = EXIST_NO; + oFileProp.bHasComputedFileSize = true; + oFileProp.fileSize = 0; + oFileProp.eExists = EXIST_NO; + poFS->SetCachedFileProp(m_pszURL, oFileProp); } CPLFree(sWriteFuncData.pBuffer); CPLFree(sWriteFuncHeaderData.pBuffer); @@ -1387,7 +1370,7 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, return false; } - if( !bHasComputedFileSize && sWriteFuncHeaderData.pBuffer ) + if( !oFileProp.bHasComputedFileSize && sWriteFuncHeaderData.pBuffer ) { // Try to retrieve the filesize from the HTTP headers // if in the form: "Content-Range: bytes x-y/filesize". @@ -1409,7 +1392,7 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, if( pszSlash ) { pszSlash++; - fileSize = + oFileProp.fileSize = CPLScanUIntBig(pszSlash, static_cast(strlen(pszSlash))); } @@ -1430,25 +1413,24 @@ bool VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset, if( pszEOL ) *pszEOL = 0; - fileSize = + oFileProp.fileSize = CPLScanUIntBig(pszSize, static_cast(strlen(pszSize))); } } } - if( fileSize != 0 ) + if( oFileProp.fileSize != 0 ) { - eExists = EXIST_YES; + oFileProp.eExists = EXIST_YES; if( ENABLE_DEBUG ) CPLDebug("VSICURL", "GetFileSize(%s)=" CPL_FRMT_GUIB " response_code=%d", - m_pszURL, fileSize, static_cast(response_code)); + m_pszURL, oFileProp.fileSize, static_cast(response_code)); - bHasComputedFileSize = cachedFileProp->bHasComputedFileSize = true; - cachedFileProp->fileSize = fileSize; - cachedFileProp->eExists = eExists; + oFileProp.bHasComputedFileSize = true; + poFS->SetCachedFileProp(m_pszURL, oFileProp); } } @@ -1527,9 +1509,9 @@ size_t VSICurlHandle::Read( void * const pBufferIn, size_t const nSize, while( nBufferRequestSize ) { // Don't try to read after end of file. - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - if( cachedFileProp->bHasComputedFileSize && - iterOffset >= cachedFileProp->fileSize ) + poFS->GetCachedFileProp(m_pszURL, oFileProp); + if( oFileProp.bHasComputedFileSize && + iterOffset >= oFileProp.fileSize ) { if( iterOffset == curOffset ) { @@ -1637,8 +1619,8 @@ int VSICurlHandle::ReadMultiRange( int const nRanges, void ** const ppData, if( bInterrupted && bStopOnInterruptUntilUninstall ) return FALSE; - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - if( cachedFileProp->eExists == EXIST_NO ) + poFS->GetCachedFileProp(m_pszURL, oFileProp); + if( oFileProp.eExists == EXIST_NO ) return -1; const char* pszMultiRangeStrategy = @@ -1656,7 +1638,7 @@ int VSICurlHandle::ReadMultiRange( int const nRanges, void ** const ppData, } bool bHasExpired = false; - CPLString osURL(GetRedirectURLIfValid(cachedFileProp, bHasExpired)); + CPLString osURL(GetRedirectURLIfValid(bHasExpired)); if( bHasExpired ) { return VSIVirtualHandle::ReadMultiRange( @@ -2300,7 +2282,8 @@ int VSICurlHandle::Close() /************************************************************************/ VSICurlFilesystemHandler::VSICurlFilesystemHandler(): - oRegionCache{static_cast(N_MAX_REGIONS)} + oRegionCache{static_cast(N_MAX_REGIONS)}, + oCacheFileProp{1024} { } @@ -2405,19 +2388,26 @@ void VSICurlFilesystemHandler::AddRegion( const char* pszURL, /* GetCachedFileProp() */ /************************************************************************/ -CachedFileProp * -VSICurlFilesystemHandler::GetCachedFileProp( const char* pszURL ) +bool +VSICurlFilesystemHandler::GetCachedFileProp( const char* pszURL, + FileProp& oFileProp ) { CPLMutexHolder oHolder( &hMutex ); - CachedFileProp* cachedFileProp = cacheFileSize[pszURL]; - if( cachedFileProp == nullptr ) - { - cachedFileProp = new CachedFileProp; - cacheFileSize[pszURL] = cachedFileProp; - } + return oCacheFileProp.tryGet(std::string(pszURL), oFileProp); +} + +/************************************************************************/ +/* SetCachedFileProp() */ +/************************************************************************/ + +void +VSICurlFilesystemHandler::SetCachedFileProp( const char* pszURL, + const FileProp& oFileProp ) +{ + CPLMutexHolder oHolder( &hMutex ); - return cachedFileProp; + oCacheFileProp.insert(std::string(pszURL), oFileProp); } /************************************************************************/ @@ -2428,13 +2418,7 @@ void VSICurlFilesystemHandler::InvalidateCachedData( const char* pszURL ) { CPLMutexHolder oHolder( &hMutex ); - std::map::iterator oIter = - cacheFileSize.find(pszURL); - if( oIter != cacheFileSize.end() ) - { - delete oIter->second; - cacheFileSize.erase(oIter); - } + oCacheFileProp.remove(std::string(pszURL)); // Invalidate all cached regions for this URL std::list keysToRemove; @@ -2461,14 +2445,7 @@ void VSICurlFilesystemHandler::ClearCache() oRegionCache.clear(); - std::map::const_iterator iterCacheFileSize; - for( iterCacheFileSize = cacheFileSize.begin(); - iterCacheFileSize != cacheFileSize.end(); - ++iterCacheFileSize ) - { - delete iterCacheFileSize->second; - } - cacheFileSize.clear(); + oCacheFileProp.clear(); std::map::const_iterator iterCacheDirList; for( iterCacheDirList = cacheDirList.begin(); @@ -2500,29 +2477,31 @@ void VSICurlFilesystemHandler::PartialClearCache(const char* pszFilenamePrefix) CPLMutexHolder oHolder( &hMutex ); CPLString osURL = GetURLFromFilename(pszFilenamePrefix); - std::list keysToRemove; - auto lambda = [&keysToRemove, &osURL]( - const lru11::KeyValuePair>& kv) { - if( strncmp(kv.key.filename_.c_str(), osURL, osURL.size()) == 0 ) - keysToRemove.push_back(kv.key); - }; - oRegionCache.cwalk(lambda); - for( auto& key: keysToRemove ) - oRegionCache.remove(key); + std::list keysToRemove; + auto lambda = [&keysToRemove, &osURL]( + const lru11::KeyValuePair>& kv) + { + if( strncmp(kv.key.filename_.c_str(), osURL, osURL.size()) == 0 ) + keysToRemove.push_back(kv.key); + }; + oRegionCache.cwalk(lambda); + for( auto& key: keysToRemove ) + oRegionCache.remove(key); + } - auto iterCacheFileSize = cacheFileSize.begin(); - while( iterCacheFileSize != cacheFileSize.end() ) { - auto iter = iterCacheFileSize; - auto nextiter = ++iterCacheFileSize; - if( strncmp(iter->first.c_str(), osURL, osURL.size()) == 0 ) + std::list keysToRemove; + auto lambda = [&keysToRemove, &osURL]( + const lru11::KeyValuePair& kv) { - delete iter->second; - cacheFileSize.erase(iter); - } - iterCacheFileSize = nextiter; + if( strncmp(kv.key.c_str(), osURL, osURL.size()) == 0 ) + keysToRemove.push_back(kv.key); + }; + oCacheFileProp.cwalk(lambda); + for( auto& key: keysToRemove ) + oCacheFileProp.remove(key); } auto iterCacheDirList = cacheDirList.begin(); @@ -2720,9 +2699,9 @@ VSIVirtualHandle* VSICurlFilesystemHandler::Open( const char *pszFilename, CPLString osFilename(pszFilename); bool bGotFileList = true; bool bForceExistsCheck = false; - CachedFileProp* cachedFileProp = - GetCachedFileProp(osFilename + strlen(GetFSPrefix())); - if( !(cachedFileProp != nullptr && cachedFileProp->eExists == EXIST_YES) && + FileProp cachedFileProp; + if( !(GetCachedFileProp(osFilename + strlen(GetFSPrefix()), cachedFileProp) && + cachedFileProp.eExists == EXIST_YES) && strchr(CPLGetFilename(osFilename), '.') != nullptr && !STARTS_WITH(CPLGetExtension(osFilename), "zip") && !bSkipReadDir) { @@ -3125,13 +3104,15 @@ char** VSICurlFilesystemHandler::ParseHTMLFileList( const char* pszFilename, CPLString osCachedFilename = CPLSPrintf("%s/%s", osURL.c_str(), beginFilename); - CachedFileProp* cachedFileProp = - GetCachedFileProp(osCachedFilename); - cachedFileProp->eExists = EXIST_YES; - cachedFileProp->bIsDirectory = bIsDirectory; - cachedFileProp->mTime = static_cast(mTime); - cachedFileProp->bHasComputedFileSize = nFileSize > 0; - cachedFileProp->fileSize = nFileSize; + + FileProp cachedFileProp; + GetCachedFileProp(osCachedFilename, cachedFileProp); + cachedFileProp.eExists = EXIST_YES; + cachedFileProp.bIsDirectory = bIsDirectory; + cachedFileProp.mTime = static_cast(mTime); + cachedFileProp.bHasComputedFileSize = nFileSize > 0; + cachedFileProp.fileSize = nFileSize; + SetCachedFileProp(osCachedFilename, cachedFileProp); oFileList.AddString( beginFilename ); if( ENABLE_DEBUG_VERBOSE ) @@ -3457,13 +3438,15 @@ char** VSICurlFilesystemHandler::GetFileList(const char *pszDirname, CPLSPrintf("%s/%s", osURL.c_str(), pszFilename); - CachedFileProp* cachedFileProp = - GetCachedFileProp(osCachedFilename); - cachedFileProp->eExists = EXIST_YES; - cachedFileProp->bHasComputedFileSize = bSizeValid; - cachedFileProp->fileSize = nFileSize; - cachedFileProp->bIsDirectory = bIsDirectory; - cachedFileProp->mTime = static_cast(mUnixTime); + + FileProp cachedFileProp; + GetCachedFileProp(osCachedFilename, cachedFileProp); + cachedFileProp.eExists = EXIST_YES; + cachedFileProp.bIsDirectory = bIsDirectory; + cachedFileProp.mTime = static_cast(mUnixTime); + cachedFileProp.bHasComputedFileSize = bSizeValid; + cachedFileProp.fileSize = nFileSize; + SetCachedFileProp(osCachedFilename, cachedFileProp); oFileList.AddString(pszFilename); if( ENABLE_DEBUG_VERBOSE ) @@ -3782,15 +3765,14 @@ char** VSICurlFilesystemHandler::ReadDirInternal( const char *pszDirname, // If we know the file exists and is not a directory, // then don't try to list its content. - CachedFileProp* cachedFileProp = - GetCachedFileProp(GetURLFromFilename(osDirname)); - if( cachedFileProp->eExists == EXIST_YES && !cachedFileProp->bIsDirectory ) + FileProp cachedFileProp; + if( GetCachedFileProp(GetURLFromFilename(osDirname), cachedFileProp) && + cachedFileProp.eExists == EXIST_YES && !cachedFileProp.bIsDirectory ) { if( osDirnameOri != osDirname ) { - cachedFileProp = - GetCachedFileProp((GetURLFromFilename(osDirname) + "/").c_str()); - if( cachedFileProp->eExists == EXIST_YES && !cachedFileProp->bIsDirectory ) + if( GetCachedFileProp((GetURLFromFilename(osDirname) + "/").c_str(), cachedFileProp) && + cachedFileProp.eExists == EXIST_YES && !cachedFileProp.bIsDirectory ) { if( pbGotFileList ) *pbGotFileList = true; diff --git a/gdal/port/cpl_vsil_curl_class.h b/gdal/port/cpl_vsil_curl_class.h index e05386693443..e65e03698333 100644 --- a/gdal/port/cpl_vsil_curl_class.h +++ b/gdal/port/cpl_vsil_curl_class.h @@ -66,7 +66,7 @@ typedef enum EXIST_YES, } ExistStatus; -class CachedFileProp +class FileProp { public: ExistStatus eExists = EXIST_UNKNOWN; @@ -147,7 +147,7 @@ class VSICurlFilesystemHandler : public VSIFilesystemHandler } }; - using CacheType = + using RegionCacheType = lru11::Cache, lru11::NullLock, std::unordered_map< @@ -156,9 +156,10 @@ class VSICurlFilesystemHandler : public VSIFilesystemHandler std::shared_ptr>>::iterator, FilenameOffsetPairHasher>>; - CacheType oRegionCache; + RegionCacheType oRegionCache; + + lru11::Cache oCacheFileProp; - std::map cacheFileSize{}; std::map cacheDirList{}; // Per-thread Curl connection cache. @@ -248,7 +249,10 @@ class VSICurlFilesystemHandler : public VSIFilesystemHandler size_t nSize, const char *pData ); - CachedFileProp* GetCachedFileProp( const char* pszURL ); + bool GetCachedFileProp( const char* pszURL, + FileProp& oFileProp ); + void SetCachedFileProp( const char* pszURL, + const FileProp& oFileProp ); void InvalidateCachedData( const char* pszURL ); CURLM *GetCurlMultiHandleFor( const CPLString& osURL ); @@ -284,11 +288,8 @@ class VSICurlHandle : public VSIVirtualHandle bool m_bCached = true; - vsi_l_offset fileSize = 0; - bool bHasComputedFileSize = false; - ExistStatus eExists = EXIST_UNKNOWN; - bool bIsDirectory = false; - time_t mTime = 0; + FileProp oFileProp{}; + CPLString m_osFilename{}; // e.g "/vsicurl/http://example.com/foo" char* m_pszURL = nullptr; // e.g "http://example.com/foo" @@ -318,17 +319,12 @@ class VSICurlHandle : public VSIVirtualHandle virtual bool DownloadRegion(vsi_l_offset startOffset, int nBlocks); - bool m_bS3LikeRedirect = false; - time_t m_nExpireTimestampLocal = 0; - CPLString m_osRedirectURL{}; - bool m_bUseHead = false; int ReadMultiRangeSingleGet( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes ); - CPLString GetRedirectURLIfValid(CachedFileProp* cachedFileProp, - bool& bHasExpired); + CPLString GetRedirectURLIfValid(bool& bHasExpired); protected: virtual struct curl_slist* GetCurlHeaders( const CPLString& /*osVerb*/, @@ -359,12 +355,12 @@ class VSICurlHandle : public VSIVirtualHandle int Flush() override; int Close() override; - bool IsKnownFileSize() const { return bHasComputedFileSize; } + bool IsKnownFileSize() const { return oFileProp.bHasComputedFileSize; } vsi_l_offset GetFileSize() { return GetFileSize(false); } virtual vsi_l_offset GetFileSize( bool bSetError ); bool Exists( bool bSetError ); - bool IsDirectory() const { return bIsDirectory; } - time_t GetMTime() const { return mTime; } + bool IsDirectory() const { return oFileProp.bIsDirectory; } + time_t GetMTime() const { return oFileProp.mTime; } int InstallReadCbk( VSICurlReadCbkFunc pfnReadCbk, void* pfnUserData, @@ -426,7 +422,7 @@ class IVSIS3LikeHandle: public VSICurlHandle } void ProcessGetFileSizeResult( const char* pszContent ) override { - bIsDirectory = strstr(pszContent, "ListBucketResult") != nullptr; + oFileProp.bIsDirectory = strstr(pszContent, "ListBucketResult") != nullptr; } public: diff --git a/gdal/port/cpl_vsil_s3.cpp b/gdal/port/cpl_vsil_s3.cpp index 1dd96c7f92bf..9c96a777f7d8 100644 --- a/gdal/port/cpl_vsil_s3.cpp +++ b/gdal/port/cpl_vsil_s3.cpp @@ -84,7 +84,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( (psListBucketResult != nullptr ) ? nullptr : CPLGetXMLNode(psTree, "=ListAllMyBucketsResult.Buckets"); - std::vector< std::pair > aoProps; + std::vector< std::pair > aoProps; // Count the number of occurrences of a path. Can be 1 or 2. 2 in the case // that both a filename and directory exist std::map aoNameCount; @@ -104,7 +104,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( const char* pszKey = CPLGetXMLValue(psIter, "Key", nullptr); if( pszKey && strlen(pszKey) > osPrefix.size() ) { - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bHasComputedFileSize = true; prop.fileSize = static_cast( @@ -136,7 +136,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( } aoProps.push_back( - std::pair + std::pair (pszKey + osPrefix.size(), prop)); aoNameCount[pszKey + osPrefix.size()] ++; } @@ -151,7 +151,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( osKey.resize(osKey.size()-1); if( osKey.size() > osPrefix.size() ) { - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bIsDirectory = true; prop.bHasComputedFileSize = true; @@ -159,7 +159,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( prop.mTime = 0; aoProps.push_back( - std::pair + std::pair (osKey.c_str() + osPrefix.size(), prop)); aoNameCount[osKey.c_str() + osPrefix.size()] ++; } @@ -196,7 +196,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( #if DEBUG_VERBOSE CPLDebug("S3", "Cache %s", osCachedFilename.c_str()); #endif - *GetCachedFileProp(osCachedFilename) = aoProps[i].second; + SetCachedFileProp(osCachedFilename, aoProps[i].second); } osFileList.AddString( (aoProps[i].first + osSuffix).c_str() ); } @@ -223,7 +223,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( const char* pszName = CPLGetXMLValue(psIter, "Name", nullptr); if( pszName ) { - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bIsDirectory = true; prop.bHasComputedFileSize = true; @@ -234,7 +234,7 @@ void VSICurlFilesystemHandler::AnalyseS3FileList( #if DEBUG_VERBOSE CPLDebug("S3", "Cache %s", osCachedFilename.c_str()); #endif - *GetCachedFileProp(osCachedFilename) = prop; + SetCachedFileProp(osCachedFilename, prop); osFileList.AddString( pszName ); } @@ -1334,11 +1334,12 @@ int IVSIS3LikeFSHandler::Mkdir( const char * pszDirname, long /* nMode */ ) InvalidateDirContent( CPLGetDirname(osDirnameWithoutEndSlash) ); - CachedFileProp* cachedFileProp = - GetCachedFileProp(GetURLFromFilename(osDirname)); - cachedFileProp->eExists = EXIST_YES; - cachedFileProp->bIsDirectory = true; - cachedFileProp->bHasComputedFileSize = true; + FileProp cachedFileProp; + GetCachedFileProp(GetURLFromFilename(osDirname), cachedFileProp); + cachedFileProp.eExists = EXIST_YES; + cachedFileProp.bIsDirectory = true; + cachedFileProp.bHasComputedFileSize = true; + SetCachedFileProp(GetURLFromFilename(osDirname), cachedFileProp); RegisterEmptyDir(osDirnameWithoutEndSlash); RegisterEmptyDir(osDirname); @@ -1433,11 +1434,13 @@ int IVSIS3LikeFSHandler::Stat( const char *pszFilename, VSIStatBufL *pStatBuf, pStatBuf->st_mtime = 0; pStatBuf->st_size = 0; pStatBuf->st_mode = S_IFDIR; - CachedFileProp* cachedFileProp = - GetCachedFileProp(GetURLFromFilename(osFilename)); - cachedFileProp->eExists = EXIST_YES; - cachedFileProp->bIsDirectory = true; - cachedFileProp->bHasComputedFileSize = true; + + FileProp cachedFileProp; + GetCachedFileProp(GetURLFromFilename(osFilename), cachedFileProp); + cachedFileProp.eExists = EXIST_YES; + cachedFileProp.bIsDirectory = true; + cachedFileProp.bHasComputedFileSize = true; + SetCachedFileProp(GetURLFromFilename(osFilename), cachedFileProp); } CSLDestroy(papszRet); return nRet; diff --git a/gdal/port/cpl_vsil_swift.cpp b/gdal/port/cpl_vsil_swift.cpp index 6d430a5ead58..60e3e038b1e5 100644 --- a/gdal/port/cpl_vsil_swift.cpp +++ b/gdal/port/cpl_vsil_swift.cpp @@ -82,7 +82,7 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( if( !oDoc.LoadMemory(reinterpret_cast(pszJson)) ) return; - std::vector< std::pair > aoProps; + std::vector< std::pair > aoProps; // Count the number of occurrences of a path. Can be 1 or 2. 2 in the case // that both a filename and directory exist std::map aoNameCount; @@ -104,7 +104,7 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( if( bHasCount ) { // Case when listing /vsiswift/ - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bIsDirectory = true; prop.bHasComputedFileSize = true; @@ -112,13 +112,13 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( prop.mTime = 0; aoProps.push_back( - std::pair + std::pair (osName, prop)); aoNameCount[ osName ] ++; } else { - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bHasComputedFileSize = true; prop.fileSize = static_cast(nSize); @@ -143,7 +143,7 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( } aoProps.push_back( - std::pair + std::pair (osName.substr(osPrefix.size()), prop)); aoNameCount[ osName.substr(osPrefix.size()) ] ++; } @@ -157,7 +157,7 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( if( osSubdir.find(osPrefix) == 0 ) { - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bIsDirectory = true; prop.bHasComputedFileSize = true; @@ -165,7 +165,7 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( prop.mTime = 0; aoProps.push_back( - std::pair + std::pair (osSubdir.substr(osPrefix.size()), prop)); aoNameCount[ osSubdir.substr(osPrefix.size()) ] ++; } @@ -201,7 +201,7 @@ void VSICurlFilesystemHandler::AnalyseSwiftFileList( #if DEBUG_VERBOSE CPLDebug("SWIFT", "Cache %s", osCachedFilename.c_str()); #endif - *GetCachedFileProp(osCachedFilename) = aoProps[i].second; + SetCachedFileProp(osCachedFilename, aoProps[i].second); } osFileList.AddString( (aoProps[i].first + osSuffix).c_str() ); } @@ -438,13 +438,13 @@ int VSISwiftFSHandler::Stat( const char *pszFilename, VSIStatBufL *pStatBuf, CPLString osURL(poS3HandleHelper->GetURL()); delete poS3HandleHelper; - CPLMutexHolder oHolder( &hMutex ); - CachedFileProp* cachedFileProp = GetCachedFileProp(osURL); - cachedFileProp->eExists = EXIST_YES; - cachedFileProp->bHasComputedFileSize = false; - cachedFileProp->fileSize = 0; - cachedFileProp->bIsDirectory = true; - cachedFileProp->mTime = 0; + FileProp cachedFileProp; + cachedFileProp.eExists = EXIST_YES; + cachedFileProp.bHasComputedFileSize = false; + cachedFileProp.fileSize = 0; + cachedFileProp.bIsDirectory = true; + cachedFileProp.mTime = 0; + SetCachedFileProp(osURL, cachedFileProp); pStatBuf->st_size = 0; pStatBuf->st_mode = S_IFDIR; diff --git a/gdal/port/cpl_vsil_webhdfs.cpp b/gdal/port/cpl_vsil_webhdfs.cpp index 3f56b686e1fd..4df0307cb61b 100644 --- a/gdal/port/cpl_vsil_webhdfs.cpp +++ b/gdal/port/cpl_vsil_webhdfs.cpp @@ -647,7 +647,7 @@ char** VSIWebHDFSFSHandler::GetFileList( const char *pszDirname, { aosList.AddString(osName); - CachedFileProp prop; + FileProp prop; prop.eExists = EXIST_YES; prop.bIsDirectory = bIsDirectory; prop.bHasComputedFileSize = true; @@ -657,7 +657,7 @@ char** VSIWebHDFSFSHandler::GetFileList( const char *pszDirname, #if DEBUG_VERBOSE CPLDebug("WEBHDFS", "Cache %s", osCachedFilename.c_str()); #endif - *GetCachedFileProp(osCachedFilename) = prop; + SetCachedFileProp(osCachedFilename, prop); } } } @@ -845,11 +845,11 @@ int VSIWebHDFSFSHandler::Mkdir( const char *pszDirname, long nMode ) { InvalidateDirContent( CPLGetDirname(osDirnameWithoutEndSlash) ); - CachedFileProp* cachedFileProp = - GetCachedFileProp(GetURLFromFilename(osDirnameWithoutEndSlash)); - cachedFileProp->eExists = EXIST_YES; - cachedFileProp->bIsDirectory = true; - cachedFileProp->bHasComputedFileSize = true; + FileProp cachedFileProp; + cachedFileProp.eExists = EXIST_YES; + cachedFileProp.bIsDirectory = true; + cachedFileProp.bHasComputedFileSize = true; + SetCachedFileProp(GetURLFromFilename(osDirnameWithoutEndSlash), cachedFileProp); RegisterEmptyDir(osDirnameWithoutEndSlash); } @@ -892,10 +892,10 @@ VSIWebHDFSHandle::VSIWebHDFSHandle( VSIWebHDFSFSHandler* poFSIn, vsi_l_offset VSIWebHDFSHandle::GetFileSize( bool bSetError ) { - if( bHasComputedFileSize ) - return fileSize; + if( oFileProp.bHasComputedFileSize ) + return oFileProp.fileSize; - bHasComputedFileSize = true; + oFileProp.bHasComputedFileSize = true; CURLM* hCurlMultiHandle = poFS->GetCurlMultiHandleFor(m_pszURL); @@ -938,18 +938,18 @@ vsi_l_offset VSIWebHDFSHandle::GetFileSize( bool bSetError ) long response_code = 0; curl_easy_getinfo(hCurlHandle, CURLINFO_HTTP_CODE, &response_code); - eExists = EXIST_NO; + oFileProp.eExists = EXIST_NO; if( response_code == 200 && sWriteFuncData.pBuffer ) { CPLJSONDocument oDoc; if( oDoc.LoadMemory(reinterpret_cast(sWriteFuncData.pBuffer )) ) { CPLJSONObject oFileStatus = oDoc.GetRoot().GetObj("FileStatus"); - fileSize = oFileStatus.GetLong("length"); - mTime = static_cast( + oFileProp.fileSize = oFileStatus.GetLong("length"); + oFileProp.mTime = static_cast( oFileStatus.GetLong("modificationTime") / 1000); - bIsDirectory = oFileStatus.GetString("type") == "DIRECTORY"; - eExists = EXIST_YES; + oFileProp.bIsDirectory = oFileStatus.GetString("type") == "DIRECTORY"; + oFileProp.eExists = EXIST_YES; } } @@ -981,20 +981,16 @@ vsi_l_offset VSIWebHDFSHandle::GetFileSize( bool bSetError ) if( ENABLE_DEBUG ) CPLDebug("WEBHDFS", "GetFileSize(%s)=" CPL_FRMT_GUIB " response_code=%d", - osURL.c_str(), fileSize, + osURL.c_str(), oFileProp.fileSize, static_cast(response_code)); CPLFree(sWriteFuncData.pBuffer); curl_easy_cleanup(hCurlHandle); - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - cachedFileProp->bHasComputedFileSize = true; - cachedFileProp->fileSize = fileSize; - cachedFileProp->eExists = eExists; - cachedFileProp->bIsDirectory = bIsDirectory; - cachedFileProp->mTime = mTime; + oFileProp.bHasComputedFileSize = true; + poFS->SetCachedFileProp(m_pszURL, oFileProp); - return fileSize; + return oFileProp.fileSize; } /************************************************************************/ @@ -1007,8 +1003,8 @@ bool VSIWebHDFSHandle::DownloadRegion( const vsi_l_offset startOffset, if( bInterrupted && bStopOnInterruptUntilUninstall ) return false; - CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(m_pszURL); - if( cachedFileProp->eExists == EXIST_NO ) + poFS->GetCachedFileProp(m_pszURL, oFileProp); + if( oFileProp.eExists == EXIST_NO ) return false; CURLM* hCurlMultiHandle = poFS->GetCurlMultiHandleFor(m_pszURL); @@ -1142,18 +1138,20 @@ bool VSIWebHDFSHandle::DownloadRegion( const vsi_l_offset startOffset, CPLError(CE_Failure, CPLE_AppDefined, "%d: %s", static_cast(response_code), szCurlErrBuf); } - if( !bHasComputedFileSize && startOffset == 0 ) + if( !oFileProp.bHasComputedFileSize && startOffset == 0 ) { - cachedFileProp->bHasComputedFileSize = bHasComputedFileSize = true; - cachedFileProp->fileSize = fileSize = 0; - cachedFileProp->eExists = eExists = EXIST_NO; + oFileProp.bHasComputedFileSize = true; + oFileProp.fileSize = 0; + oFileProp.eExists = EXIST_NO; + poFS->SetCachedFileProp(m_pszURL, oFileProp); } CPLFree(sWriteFuncData.pBuffer); curl_easy_cleanup(hCurlHandle); return false; } - cachedFileProp->eExists = eExists = EXIST_YES; + oFileProp.eExists = EXIST_YES; + poFS->SetCachedFileProp(m_pszURL, oFileProp); DownloadRegionPostProcess(startOffset, nBlocks, sWriteFuncData.pBuffer, From cb821a92861d602e5d9883b77a54e1c954362ac8 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 8 Nov 2018 12:03:45 +0100 Subject: [PATCH 036/488] /vsicurl/ and derived: implement a LRU cache for directory content listing --- gdal/port/cpl_mem_cache.h | 10 +++ gdal/port/cpl_vsil_curl.cpp | 144 ++++++++++++++++++++++---------- gdal/port/cpl_vsil_curl_class.h | 25 +++--- 3 files changed, 121 insertions(+), 58 deletions(-) diff --git a/gdal/port/cpl_mem_cache.h b/gdal/port/cpl_mem_cache.h index 264eb6650c08..3721fd224070 100644 --- a/gdal/port/cpl_mem_cache.h +++ b/gdal/port/cpl_mem_cache.h @@ -172,6 +172,16 @@ class Cache { return cache_.find(k) != cache_.end(); } + bool getOldestEntry(Key& kOut, Value& vOut) { + Guard g(lock_); + if( keys_.empty() ) { + return false; + } + kOut = keys_.back().key; + vOut = keys_.back().value; + return true; + } + size_t getMaxSize() const { return maxSize_; } size_t getElasticity() const { return elasticity_; } size_t getMaxAllowedSize() const { return maxSize_ + elasticity_; } diff --git a/gdal/port/cpl_vsil_curl.cpp b/gdal/port/cpl_vsil_curl.cpp index e4af0455e10d..0987d064cc61 100644 --- a/gdal/port/cpl_vsil_curl.cpp +++ b/gdal/port/cpl_vsil_curl.cpp @@ -2283,7 +2283,8 @@ int VSICurlHandle::Close() VSICurlFilesystemHandler::VSICurlFilesystemHandler(): oRegionCache{static_cast(N_MAX_REGIONS)}, - oCacheFileProp{1024} + oCacheFileProp{1024}, + oCacheDirList{1024, 0} { } @@ -2410,6 +2411,73 @@ VSICurlFilesystemHandler::SetCachedFileProp( const char* pszURL, oCacheFileProp.insert(std::string(pszURL), oFileProp); } +/************************************************************************/ +/* GetCachedDirList() */ +/************************************************************************/ + +bool +VSICurlFilesystemHandler::GetCachedDirList( const char* pszURL, + CachedDirList& oCachedDirList ) +{ + CPLMutexHolder oHolder( &hMutex ); + + return oCacheDirList.tryGet(std::string(pszURL), oCachedDirList); +} + +/************************************************************************/ +/* SetCachedDirList() */ +/************************************************************************/ + +void +VSICurlFilesystemHandler::SetCachedDirList( const char* pszURL, + const CachedDirList& oCachedDirList ) +{ + CPLMutexHolder oHolder( &hMutex ); + + std::string key(pszURL); + CachedDirList oldValue; + if( oCacheDirList.tryGet(key, oldValue) ) + { + nCachedFilesInDirList -= oldValue.oFileList.size(); + oCacheDirList.remove(key); + } + + while( (!oCacheDirList.empty() && + nCachedFilesInDirList + oCachedDirList.oFileList.size() > 1024 * 1024) || + oCacheDirList.size() == oCacheDirList.getMaxAllowedSize() ) + { + std::string oldestKey; + oCacheDirList.getOldestEntry(oldestKey, oldValue); + nCachedFilesInDirList -= oldValue.oFileList.size(); + oCacheDirList.remove(oldestKey); + } + + nCachedFilesInDirList += oCachedDirList.oFileList.size(); + oCacheDirList.insert(key, oCachedDirList); +} + +/************************************************************************/ +/* ExistsInCacheDirList() */ +/************************************************************************/ + +bool VSICurlFilesystemHandler::ExistsInCacheDirList( + const CPLString& osDirname, bool *pbIsDir ) +{ + CachedDirList cachedDirList; + if( GetCachedDirList(osDirname, cachedDirList) ) + { + if( pbIsDir ) + *pbIsDir = !cachedDirList.oFileList.empty(); + return false; + } + else + { + if( pbIsDir ) + *pbIsDir = false; + return false; + } +} + /************************************************************************/ /* InvalidateCachedData() */ /************************************************************************/ @@ -2447,15 +2515,8 @@ void VSICurlFilesystemHandler::ClearCache() oCacheFileProp.clear(); - std::map::const_iterator iterCacheDirList; - for( iterCacheDirList = cacheDirList.begin(); - iterCacheDirList != cacheDirList.end(); - ++iterCacheDirList ) - { - CSLDestroy(iterCacheDirList->second->papszFileList); - CPLFree(iterCacheDirList->second); - } - cacheDirList.clear(); + oCacheDirList.clear(); + nCachedFilesInDirList = 0; std::map::const_iterator iterConnections; for( iterConnections = mapConnections.begin(); @@ -2504,19 +2565,21 @@ void VSICurlFilesystemHandler::PartialClearCache(const char* pszFilenamePrefix) oCacheFileProp.remove(key); } - auto iterCacheDirList = cacheDirList.begin(); - const size_t nLen = strlen(pszFilenamePrefix); - while( iterCacheDirList != cacheDirList.end() ) { - auto iter = iterCacheDirList; - auto nextiter = ++iterCacheDirList; - if( strncmp(iter->first.c_str(), pszFilenamePrefix, nLen) == 0 ) + const size_t nLen = strlen(pszFilenamePrefix); + std::list keysToRemove; + auto lambda = [this, &keysToRemove, pszFilenamePrefix, nLen]( + const lru11::KeyValuePair& kv) { - CSLDestroy(iter->second->papszFileList); - CPLFree(iter->second); - cacheDirList.erase(iter); - } - iterCacheDirList = nextiter; + if( strncmp(kv.key.c_str(), pszFilenamePrefix, nLen) == 0 ) + { + keysToRemove.push_back(kv.key); + nCachedFilesInDirList -= kv.value.oFileList.size(); + } + }; + oCacheDirList.cwalk(lambda); + for( auto& key: keysToRemove ) + oCacheDirList.remove(key); } } @@ -3305,14 +3368,12 @@ VSICurlFilesystemHandler::GetURLFromFilename( const CPLString& osFilename ) void VSICurlFilesystemHandler::RegisterEmptyDir( const CPLString& osDirname ) { - CPLMutexHolder oHolder( &hMutex ); - CachedDirList* psCachedDirList = cacheDirList[osDirname]; - if( psCachedDirList == nullptr ) + CachedDirList cachedDirList; + if( !GetCachedDirList(osDirname, cachedDirList) ) { - psCachedDirList = - static_cast(CPLMalloc(sizeof(CachedDirList))); - psCachedDirList->papszFileList = CSLAddString(nullptr, "."); - cacheDirList[osDirname] = psCachedDirList; + cachedDirList.bGotFileList = true; + cachedDirList.oFileList.AddString("."); + SetCachedDirList(osDirname, cachedDirList); } } @@ -3787,21 +3848,19 @@ char** VSICurlFilesystemHandler::ReadDirInternal( const char *pszDirname, } } - CachedDirList* psCachedDirList = cacheDirList[osDirname]; - if( psCachedDirList == nullptr ) + CachedDirList cachedDirList; + if( !GetCachedDirList(osDirname, cachedDirList) ) { - psCachedDirList = - static_cast(CPLMalloc(sizeof(CachedDirList))); - psCachedDirList->papszFileList = + cachedDirList.oFileList.Assign( GetFileList(osDirname, nMaxFiles, - &psCachedDirList->bGotFileList); - cacheDirList[osDirname] = psCachedDirList; + &cachedDirList.bGotFileList), true); + SetCachedDirList(osDirname, cachedDirList); } if( pbGotFileList ) - *pbGotFileList = psCachedDirList->bGotFileList; + *pbGotFileList = cachedDirList.bGotFileList; - return CSLDuplicate(psCachedDirList->papszFileList); + return CSLDuplicate(cachedDirList.oFileList.List()); } /************************************************************************/ @@ -3811,13 +3870,12 @@ char** VSICurlFilesystemHandler::ReadDirInternal( const char *pszDirname, void VSICurlFilesystemHandler::InvalidateDirContent( const char *pszDirname ) { CPLMutexHolder oHolder( &hMutex ); - std::map::iterator oIter = - cacheDirList.find(pszDirname); - if( oIter != cacheDirList.end() ) + + CachedDirList oCachedDirList; + if( oCacheDirList.tryGet(std::string(pszDirname), oCachedDirList) ) { - CSLDestroy( oIter->second->papszFileList ); - CPLFree( oIter->second ); - cacheDirList.erase(oIter); + nCachedFilesInDirList -= oCachedDirList.oFileList.size(); + oCacheDirList.remove(std::string(pszDirname)); } } diff --git a/gdal/port/cpl_vsil_curl_class.h b/gdal/port/cpl_vsil_curl_class.h index e65e03698333..94570bb51deb 100644 --- a/gdal/port/cpl_vsil_curl_class.h +++ b/gdal/port/cpl_vsil_curl_class.h @@ -81,8 +81,8 @@ class FileProp typedef struct { - bool bGotFileList; - char** papszFileList; /* only file name without path */ + bool bGotFileList = false; + CPLStringList oFileList{}; /* only file name without path */ } CachedDirList; typedef struct @@ -160,7 +160,8 @@ class VSICurlFilesystemHandler : public VSIFilesystemHandler lru11::Cache oCacheFileProp; - std::map cacheDirList{}; + int nCachedFilesInDirList = 0; + lru11::Cache oCacheDirList; // Per-thread Curl connection cache. std::map mapConnections{}; @@ -260,18 +261,12 @@ class VSICurlFilesystemHandler : public VSIFilesystemHandler virtual void ClearCache(); virtual void PartialClearCache(const char* pszFilename); - bool ExistsInCacheDirList( const CPLString& osDirname, bool *pbIsDir ) - { - CPLMutexHolder oHolder( &hMutex ); - std::map::const_iterator oIter = - cacheDirList.find(osDirname); - if( pbIsDir ) - { - *pbIsDir = oIter != cacheDirList.end() && - oIter->second->papszFileList != nullptr; - } - return oIter != cacheDirList.end(); - } + + bool GetCachedDirList( const char* pszURL, + CachedDirList& oCachedDirList ); + void SetCachedDirList( const char* pszURL, + const CachedDirList& oCachedDirList ); + bool ExistsInCacheDirList( const CPLString& osDirname, bool *pbIsDir ); }; From 17716b33ff9646d0da3c7d7d81194dfbd26ad526 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 8 Nov 2018 12:34:08 +0100 Subject: [PATCH 037/488] Windows build: add support for JPEGLS driver (derived from contribution by @arturredzko, fixes #1078) --- gdal/frmts/jpegls/makefile.vc | 15 +++++++++++++++ gdal/frmts/makefile.vc | 4 ++++ gdal/nmake.opt | 8 +++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gdal/frmts/jpegls/makefile.vc diff --git a/gdal/frmts/jpegls/makefile.vc b/gdal/frmts/jpegls/makefile.vc new file mode 100644 index 000000000000..aa1f7eeaff81 --- /dev/null +++ b/gdal/frmts/jpegls/makefile.vc @@ -0,0 +1,15 @@ +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +OBJ = jpeglsdataset.obj + +EXTRAFLAGS = -I.. -I..\.. $(CHARLS_INC) $(CHARLS_FLAGS) + +default: $(OBJ) + xcopy /D /Y *.obj ..\o + cd .. + +clean: + -del *.obj + cd .. diff --git a/gdal/frmts/makefile.vc b/gdal/frmts/makefile.vc index 37e559923853..3e6544caf4ee 100644 --- a/gdal/frmts/makefile.vc +++ b/gdal/frmts/makefile.vc @@ -199,6 +199,10 @@ PLUGINFLAGS = $(PLUGINFLAGS) -DFRMT_kea EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_mrf !ENDIF +!IFDEF CHARLS_LIB +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_jpegls +!ENDIF + default: o\gdalallregister.obj subdirs list: diff --git a/gdal/nmake.opt b/gdal/nmake.opt index 1eb049038c8f..1d3038336020 100644 --- a/gdal/nmake.opt +++ b/gdal/nmake.opt @@ -785,6 +785,12 @@ ADD_LIBS = HAVE_LERC=1 !ENDIF +# Comment out the following if you want to build JPEGLS with CHARLS support +#CHARLS_INC=-IE:\work\GIS\gdal\supportlibs\charls\include\ +#CHARLS_LIB=e:\work\GIS\gdal\supportlibs\charls\bin\Release\x86\CharLS.lib +# Comment out for API 2.x: +#CHARLS_FLAGS = -DCHARLS_2 + ########### END OF STUFF THAT NORMALLY NEEDS TO BE UPDATED ################## @@ -979,5 +985,5 @@ EXTERNAL_LIBS = $(OGDILIB) $(XERCES_LIB) $(EXPAT_LIB) $(OCI_LIB) $(PG_LIB) \ $(ODBCLIB) $(JASPER_LIB) $(PNG_LIB) $(ZLIB_LIB) $(ADD_LIBS) $(OPENJPEG_LIB) \ $(MRSID_LIDAR_LIB) $(LIBKML_LIBS) $(SOSI_LIBS) $(PDF_LIB_LINK) $(LZMA_LIBS) $(ZSTD_LIBS) \ $(LIBICONV_LIBRARY) $(WEBP_LIBS) $(FGDB_LIB_LINK) $(FREEXL_LIBS) $(GTA_LIBS) \ - $(INGRES_LIB) $(LIBXML2_LIB) $(PCRE_LIB) $(MONGODB_LIB_LINK) $(CRYPTOPP_LIB) $(OPENSSL_LIB) ws2_32.lib \ + $(INGRES_LIB) $(LIBXML2_LIB) $(PCRE_LIB) $(MONGODB_LIB_LINK) $(CRYPTOPP_LIB) $(OPENSSL_LIB) $(CHARLS_LIB) ws2_32.lib \ kernel32.lib psapi.lib From ce2f3d8c7412aeb9186edf42bc8677a3f60633de Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 8 Nov 2018 14:27:56 +0100 Subject: [PATCH 038/488] /vsis3/: ignores files with GLACIER storage class in directory listing, unless CPL_VSIL_CURL_IGNORE_GLACIER_STORAGE=NO --- autotest/gcore/vsis3.py | 37 ++++++++++++++++++++++++++ gdal/doc/gdal_virtual_file_systems.dox | 4 +++ gdal/port/cpl_vsil_curl.cpp | 8 +++++- gdal/port/cpl_vsil_curl_class.h | 1 + gdal/port/cpl_vsil_s3.cpp | 20 ++++++++++---- 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/autotest/gcore/vsis3.py b/autotest/gcore/vsis3.py index 74dfa3cedf8c..49019076ed9f 100755 --- a/autotest/gcore/vsis3.py +++ b/autotest/gcore/vsis3.py @@ -735,6 +735,12 @@ def method(request): 2015-10-16T12:34:56.000Z 456789 + + a_dir/i_am_a_glacier_file + 2015-10-16T12:34:56.000Z + 456789 + GLACIER + a_dir/subdir/ @@ -764,6 +770,7 @@ def method(request): gdaltest.post_reason('fail') print(dir_contents) return 'fail' + if gdal.VSIStatL('/vsis3/s3_fake_bucket2/a_dir/resource3.bin').size != 123456: gdaltest.post_reason('fail') return 'fail' @@ -825,6 +832,36 @@ def method(request): print(dir_contents) return 'fail' + gdal.VSICurlClearCache() + handler = webserver.SequentialHandler() + handler.add('GET', '/s3_fake_bucket2/?delimiter=%2F&prefix=a_dir%2F', 200, {}, + """ + + a_dir/ + + a_dir/resource4.bin + 2015-10-16T12:34:56.000Z + 456789 + + + a_dir/i_am_a_glacier_file + 2015-10-16T12:34:56.000Z + 456789 + GLACIER + + + a_dir/subdir/ + + + """) + with gdaltest.config_option('CPL_VSIL_CURL_IGNORE_GLACIER_STORAGE', 'NO'): + with webserver.install_http_handler(handler): + dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir') + if dir_contents != ['resource4.bin', 'i_am_a_glacier_file', 'subdir']: + gdaltest.post_reason('fail') + print(dir_contents) + return 'fail' + # Test CPL_VSIL_CURL_NON_CACHED for config_option_value in ['/vsis3/s3_non_cached/test.txt', diff --git a/gdal/doc/gdal_virtual_file_systems.dox b/gdal/doc/gdal_virtual_file_systems.dox index a78ca6a5b18f..c8b40f743545 100644 --- a/gdal/doc/gdal_virtual_file_systems.dox +++ b/gdal/doc/gdal_virtual_file_systems.dox @@ -439,6 +439,10 @@ storage. You'll have to abort yourself with other means such "ghost" uploads files smaller than the chunk size, a simple PUT request is used instead of the multipart upload API. +Since GDAL 2.4, when listing a directory, files with GLACIER storage class are +ignored unless the CPL_VSIL_CURL_IGNORE_GLACIER_STORAGE configuration option +is set to NO. + @since GDAL 2.1 \subsection gdal_virtual_file_systems_vsis3_streaming /vsis3_streaming/ (AWS S3 files: streaming) diff --git a/gdal/port/cpl_vsil_curl.cpp b/gdal/port/cpl_vsil_curl.cpp index a1d7fdb3d330..ea9677ab3a63 100644 --- a/gdal/port/cpl_vsil_curl.cpp +++ b/gdal/port/cpl_vsil_curl.cpp @@ -2614,7 +2614,10 @@ const char* VSICurlFilesystemHandler::GetActualURL(const char* pszFilename) "file' default='16384' min='1024' max='10485760'/>" \ "
  • SYNC_STRATEGY=TIMESTAMP/ETAG. Determines which criterion is used to * determine if a target file must be replaced when it already exists and * has the same file size as the source. - * Only apply for a source being a network filesystem. + * Only applies for a source or target being a network filesystem. * * The default is TIMESTAMP (similarly to how 'aws s3 sync' works), that is * to say that for an upload operation, a remote file is @@ -490,6 +490,8 @@ int VSIRename( const char * oldpath, const char * newpath ) * the MD5Sum of the file content, which is only true in the case of /vsis3/ * for files not using KMS server side encryption and uploaded in a single * PUT operation (so smaller than 50 MB given the default used by GDAL). + * Only to be used for /vsis3/, /vsigs/ or other filesystems using a + * MD5Sum as ETAG. *
  • * * @param pProgressFunc Progress callback, or NULL. From a5343ed6a8af2495681940a9d1cc57c074bddbf9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 10 Nov 2018 09:49:04 +0100 Subject: [PATCH 047/488] OpenFileGDB: fix potential crash on corrupted datasets. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11313. Credit to OSS Fuzz --- .../openfilegdb/ogropenfilegdbdatasource.cpp | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp b/gdal/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp index f448cfe478be..ba1f7e557a23 100644 --- a/gdal/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp @@ -183,6 +183,7 @@ int OGROpenFileGDBDataSource::Open( const char* pszFilename ) } if( !(oTable.GetFieldCount() >= 2 && + oTable.GetTotalRecordCount() < 100000 && oTable.GetField(0)->GetName() == "Name" && oTable.GetField(0)->GetType() == FGFT_STRING && oTable.GetField(1)->GetName() == "FileFormat" && @@ -197,40 +198,47 @@ int OGROpenFileGDBDataSource::Open( const char* pszFilename ) int iGDBObjectClasses = -1; /* V9.X */ std::vector aosTableNames; - for( int i=0;iString); - - if( strcmp(psField->String, "GDB_Items") == 0 ) + if( !oTable.SelectRow(i) ) { - iGDBItems = i; + if( oTable.HasGotError() ) + break; + aosTableNames.push_back(""); + continue; } - else if( strcmp(psField->String, "GDB_FeatureClasses") == 0 ) + + const OGRField* psField = oTable.GetFieldValue(0); + if( psField != nullptr ) { - iGDBFeatureClasses = i; + aosTableNames.push_back(psField->String); + + if( strcmp(psField->String, "GDB_Items") == 0 ) + { + iGDBItems = i; + } + else if( strcmp(psField->String, "GDB_FeatureClasses") == 0 ) + { + iGDBFeatureClasses = i; + } + else if( strcmp(psField->String, "GDB_ObjectClasses") == 0 ) + { + iGDBObjectClasses = i; + } + m_osMapNameToIdx[psField->String] = 1 + i; } - else if( strcmp(psField->String, "GDB_ObjectClasses") == 0 ) + else { - iGDBObjectClasses = i; + aosTableNames.push_back(""); } - m_osMapNameToIdx[psField->String] = 1 + i; - } - else - { - aosTableNames.push_back(""); } } + catch( const std::exception& ) + { + return FALSE; + } oTable.Close(); From c4b4dfe1b5b03622575bd88104977ea52d08ddb7 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 10 Nov 2018 16:21:34 +0100 Subject: [PATCH 048/488] Internal libtiff: resync with change of value for COMPRESSION_ZSTD and COMPRESSION_WEBP (breaking change) --- autotest/gcore/data/byte_zstd.tif | Bin 576 -> 576 bytes autotest/gcore/data/byte_zstd_corrupted.tif | Bin 576 -> 576 bytes autotest/gcore/data/byte_zstd_corrupted2.tif | Bin 576 -> 576 bytes autotest/gcore/data/tif_webp.tif | Bin 1774 -> 1774 bytes .../gcore/data/tif_webp_huge_single_strip.tif | Bin 850 -> 850 bytes gdal/frmts/gtiff/gtiff.h | 4 ++-- gdal/frmts/gtiff/libtiff/tiff.h | 4 ++-- 7 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autotest/gcore/data/byte_zstd.tif b/autotest/gcore/data/byte_zstd.tif index ec19af8efa35301e347cc2a746fe20febfa275c0..ca5e1de3c270a326bd95a21603d8fb1a6d6b5f8f 100644 GIT binary patch delta 13 UcmX@Wa)4!m8B@UFjTRhC03u)nR{#J2 delta 13 UcmX@Wa)4!m8B<=zMhgxm03q!JIsgCw diff --git a/autotest/gcore/data/byte_zstd_corrupted.tif b/autotest/gcore/data/byte_zstd_corrupted.tif index 980e88a26b7d921ade77bd3fb3118ea10c1d85b1..d2d7378ce249aa65ae78a09029df2bb77f9e6582 100644 GIT binary patch delta 13 UcmX@Wa)4!m8B@UFjTRhC03u)nR{#J2 delta 13 UcmX@Wa)4!m8B<=zMhgxm03q!JIsgCw diff --git a/autotest/gcore/data/byte_zstd_corrupted2.tif b/autotest/gcore/data/byte_zstd_corrupted2.tif index 26de0a304cd8bff8ca2e45c34cd4d4a487ed5d46..d3a1c3c7eacc92bf629cfb83c28f65f4bfb89575 100644 GIT binary patch delta 13 UcmX@Wa)4!m8B@UFjTRhC03u)nR{#J2 delta 13 UcmX@Wa)4!m8B<=zMhgxm03q!JIsgCw diff --git a/autotest/gcore/data/tif_webp.tif b/autotest/gcore/data/tif_webp.tif index 8ec4995a9392bfa60990cb9b7226a7da29726bad..ebefb014a53f301ead860c7aba32be9902d962b3 100644 GIT binary patch delta 13 UcmaFI`;K>l8B^fljTYP304UrAcmMzZ delta 13 UcmaFI`;K>l8B>18MvHB104Qk%TL1t6 diff --git a/autotest/gcore/data/tif_webp_huge_single_strip.tif b/autotest/gcore/data/tif_webp_huge_single_strip.tif index 0ea6c28b7f48e8cce66b41026d155404211e18f0..297110aa1fae489ab69d399fa6553260d1d0bd23 100644 GIT binary patch delta 13 Ucmcb_c8P6*8B^fljTTbO03>GwlK=n! delta 13 Ucmcb_c8P6*8B>18Mhhus03-ASb^rhX diff --git a/gdal/frmts/gtiff/gtiff.h b/gdal/frmts/gtiff/gtiff.h index ad75610bd267..ce0f8ed39ceb 100644 --- a/gdal/frmts/gtiff/gtiff.h +++ b/gdal/frmts/gtiff/gtiff.h @@ -97,7 +97,7 @@ uint16 GTiffGetAlphaValue(const char* pszValue, uint16 nDefault); #endif #if !defined(COMPRESSION_ZSTD) -#define COMPRESSION_ZSTD 34926 /* ZSTD */ +#define COMPRESSION_ZSTD 50000 /* ZSTD */ #endif #if !defined(TIFFTAG_ZSTD_LEVEL) @@ -109,7 +109,7 @@ uint16 GTiffGetAlphaValue(const char* pszValue, uint16 nDefault); #endif #if !defined(COMPRESSION_WEBP) -#define COMPRESSION_WEBP 34927 /* WebP */ +#define COMPRESSION_WEBP 50001 /* WebP */ #endif #if !defined(TIFFTAG_WEBP_LEVEL) diff --git a/gdal/frmts/gtiff/libtiff/tiff.h b/gdal/frmts/gtiff/libtiff/tiff.h index 116ac34effe4..5b0a0c90f67a 100644 --- a/gdal/frmts/gtiff/libtiff/tiff.h +++ b/gdal/frmts/gtiff/libtiff/tiff.h @@ -190,8 +190,8 @@ typedef enum { #define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */ /* compression codes 34887-34889 are reserved for ESRI */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ -#define COMPRESSION_ZSTD 34926 /* ZSTD: WARNING not registered in Adobe-maintained registry */ -#define COMPRESSION_WEBP 34927 /* WEBP: WARNING not registered in Adobe-maintained registry */ +#define COMPRESSION_ZSTD 50000 /* ZSTD: WARNING not registered in Adobe-maintained registry */ +#define COMPRESSION_WEBP 50001 /* WEBP: WARNING not registered in Adobe-maintained registry */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ From ca7aa5677aab8221ad4251ae7aa044a3b761a79c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 12 Nov 2018 08:53:03 +0100 Subject: [PATCH 049/488] Internal libtiff: now at v4.0.10 --- gdal/frmts/gtiff/libtiff/tiffvers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdal/frmts/gtiff/libtiff/tiffvers.h b/gdal/frmts/gtiff/libtiff/tiffvers.h index 7c415740f655..403d61be04b5 100644 --- a/gdal/frmts/gtiff/libtiff/tiffvers.h +++ b/gdal/frmts/gtiff/libtiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.9\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.10\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a @@ -6,4 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20171118 +#define TIFFLIB_VERSION 20181110 From 76b0e9fd8e1149b8a412c07a964167c19100271b Mon Sep 17 00:00:00 2001 From: drons Date: Mon, 12 Nov 2018 22:43:36 +0300 Subject: [PATCH 050/488] PRF: Add georeference shift from pixel's center to top-left --- gdal/frmts/prf/phprfdataset.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdal/frmts/prf/phprfdataset.cpp b/gdal/frmts/prf/phprfdataset.cpp index 445a02a0f112..58a8498acea5 100644 --- a/gdal/frmts/prf/phprfdataset.cpp +++ b/gdal/frmts/prf/phprfdataset.cpp @@ -615,6 +615,9 @@ GDALDataset* PhPrfDataset::Open( GDALOpenInfo* poOpenInfo ) adfGeoTrans[4] = 0; adfGeoTrans[5] = (adfDemMetadata[2] - adfDemMetadata[3])/(nSizeY - 1); + adfGeoTrans[0] -= 0.5 * adfGeoTrans[1]; + adfGeoTrans[3] -= 0.5 * adfGeoTrans[5]; + if( bDemShiftOk ) { adfGeoTrans[0] += adfDemShift[0]; From f358ef36ce3adb7ed85ec59a6cbad99f78de3463 Mon Sep 17 00:00:00 2001 From: drons Date: Mon, 12 Nov 2018 23:00:30 +0300 Subject: [PATCH 051/488] PRF: Add georeference test for x-dem files --- autotest/gdrivers/data/PRF/dem.x-dem | 8 ++++---- autotest/gdrivers/prf.py | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/autotest/gdrivers/data/PRF/dem.x-dem b/autotest/gdrivers/data/PRF/dem.x-dem index 03588b00d8b8..9b3d7711b05f 100644 --- a/autotest/gdrivers/data/PRF/dem.x-dem +++ b/autotest/gdrivers/data/PRF/dem.x-dem @@ -18,10 +18,10 @@ - - - - + + + + diff --git a/autotest/gdrivers/prf.py b/autotest/gdrivers/prf.py index cbe21c4509e5..03338af0339c 100755 --- a/autotest/gdrivers/prf.py +++ b/autotest/gdrivers/prf.py @@ -98,13 +98,21 @@ def prf_3(): return 'success' + +def prf_4(): + + tst = gdaltest.GDALTest('prf', './PRF/dem.x-dem', 1, 0) + return tst.testOpen(check_gt=(1.5, 1.0, 0.0, 9329.0, 0.0, -2.0)) + + ############################################################################### gdaltest_list = [ prf_1, prf_2, - prf_3 + prf_3, + prf_4 ] if __name__ == '__main__': From e8c9bea5dbe8e90d01d575f94a040fcaee27c24f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 13 Nov 2018 12:13:41 +0100 Subject: [PATCH 052/488] GDALDestroy(): no longer call it automatically on GCC/CLang (non-MSVC) builds Experiments have shown that a __attribute__((destructor )) function is called *AFTER* the destructor of static C++ objects. Which is prone to crash is code called by this destructor function then uses those C++ objects. There could have been a solution by making the destructor function a C++ object itself and playing with gcc __attribute__((init_priority(XXXX))), unfortunately the destructor of static C++ objects in functions/methods is always called before the destructor of objects with explicit priority, so there is no workaround. With MSVC, apparently according to https://stackoverflow.com/questions/4496233/which-is-called-first-dllmain-or-global-static-object-constructor DllMain(DLL_PROCESS_DETACH) is called before C++ object destruction, so it seems safe to keep it. --- gdal/gcore/gdaldllmain.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/gdal/gcore/gdaldllmain.cpp b/gdal/gcore/gdaldllmain.cpp index 9e0383e43a71..fac9b6da54da 100644 --- a/gdal/gcore/gdaldllmain.cpp +++ b/gdal/gcore/gdaldllmain.cpp @@ -56,10 +56,15 @@ void CPLFinalizeTLS(); * This function calls GDALDestroyDriverManager() and OGRCleanupAll() and * finalize Thread Local Storage variables. * - * This function should *not* usually be explicitly called by application code - * if GDAL is dynamically linked, since it is automatically called through + * Prior to GDAL 2.4.0, this function should normally be explicitly called by + * application code if GDAL is dynamically linked (but that does not hurt), + * since it was automatically called through * the unregistration mechanisms of dynamic library loading. * + * Since GDAL 2.4.0, this function may be called by application code, since + * it is no longer called automatically, on non-MSVC builds, due to ordering + * problems with respect to automatic destruction of global C++ objects. + * * Note: no GDAL/OGR code should be called after this call! * * @since GDAL 2.0 @@ -100,7 +105,6 @@ void GDALDestroy(void) #ifdef __GNUC__ static void GDALInitialize() __attribute__ ((constructor)) ; -static void GDALDestructor() __attribute__ ((destructor)) ; /************************************************************************/ /* Called when GDAL is loaded by loader or by dlopen(), */ @@ -118,20 +122,6 @@ static void GDALInitialize() #endif } -/************************************************************************/ -/* Called when GDAL is unloaded by loader or by dlclose(), */ -/* and before dlclose() returns. */ -/************************************************************************/ - -static void GDALDestructor() -{ - if( bGDALDestroyAlreadyCalled ) - return; - if( !CPLTestBool(CPLGetConfigOption("GDAL_DESTROY", "YES")) ) - return; - GDALDestroy(); -} - #endif // __GNUC__ /************************************************************************/ From 41babc2c7cb61ab76c6a3772735b20e6610eca52 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 14 Nov 2018 00:15:52 +0100 Subject: [PATCH 053/488] Overview / RasterIO resampling: do not use nodata value as a valid output value --- autotest/gcore/rasterio.py | 81 +++++++++++++ autotest/gdrivers/vrtpansharpen.py | 4 +- gdal/gcore/overview.cpp | 180 ++++++++++++++++++++++++++--- 3 files changed, 249 insertions(+), 16 deletions(-) diff --git a/autotest/gcore/rasterio.py b/autotest/gcore/rasterio.py index 273badb3303a..76e15a805188 100755 --- a/autotest/gcore/rasterio.py +++ b/autotest/gcore/rasterio.py @@ -1127,6 +1127,86 @@ def rasterio_lanczos_nodata(): return 'success' +############################################################################### + + +def rasterio_resampled_value_is_nodata(): + + gdal.FileFromMemBuffer('/vsimem/in.asc', +"""ncols 4 +nrows 4 +xllcorner 440720.000000000000 +yllcorner 3750120.000000000000 +cellsize 60.000000000000 +nodata_value 0 + -1.1 -1.1 1.1 1.1 + -1.1 -1.1 1.1 1.1 + -1.1 -1.1 1.1 1.1 + -1.1 -1.1 1.1 1.1""") + + ds = gdal.Open('/vsimem/in.asc') + + data = ds.GetRasterBand(1).ReadRaster(buf_xsize=1, + buf_ysize=1, + resample_alg=gdal.GRIORA_Lanczos) + data_ar = struct.unpack('f' * 1, data) + expected_ar = (1.1754943508222875e-38, ) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(data_ar) + return 'fail' + + data = ds.GetRasterBand(1).ReadRaster(buf_xsize=1, + buf_ysize=1, + resample_alg=gdal.GRIORA_Average) + data_ar = struct.unpack('f' * 1, data) + expected_ar = (1.1754943508222875e-38, ) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(data_ar) + return 'fail' + + gdal.Unlink('/vsimem/in.asc') + + + gdal.FileFromMemBuffer('/vsimem/in.asc', +"""ncols 4 +nrows 4 +xllcorner 440720.000000000000 +yllcorner 3750120.000000000000 +cellsize 60.000000000000 +nodata_value 0 + -1 -1 1 1 + -1 -1 1 1 + -1 -1 1 1 + -1 -1 1 1""") + + ds = gdal.Open('/vsimem/in.asc') + + data = ds.GetRasterBand(1).ReadRaster(buf_xsize=1, + buf_ysize=1, + resample_alg=gdal.GRIORA_Lanczos) + data_ar = struct.unpack('I' * 1, data) + expected_ar = (1, ) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(data_ar) + return 'fail' + + data = ds.GetRasterBand(1).ReadRaster(buf_xsize=1, + buf_ysize=1, + resample_alg=gdal.GRIORA_Average) + data_ar = struct.unpack('I' * 1, data) + expected_ar = (1, ) + if data_ar != expected_ar: + gdaltest.post_reason('fail') + print(data_ar) + return 'fail' + + gdal.Unlink('/vsimem/in.asc') + + return 'success' + gdaltest_list = [ rasterio_1, rasterio_2, @@ -1145,6 +1225,7 @@ def rasterio_lanczos_nodata(): rasterio_15, rasterio_16, rasterio_lanczos_nodata, + rasterio_resampled_value_is_nodata, ] # gdaltest_list = [ rasterio_16 ] diff --git a/autotest/gdrivers/vrtpansharpen.py b/autotest/gdrivers/vrtpansharpen.py index 185a192dd72e..677c0ec86843 100755 --- a/autotest/gdrivers/vrtpansharpen.py +++ b/autotest/gdrivers/vrtpansharpen.py @@ -1681,7 +1681,7 @@ def vrtpansharpen_9(): gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] - if cs not in([4179, 8767, 52257], [4175, 8758, 52249]): + if cs not in ([4640, 9158, 54450],): gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1723,7 +1723,7 @@ def vrtpansharpen_9(): gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] - if cs not in([4179, 8767, 52257], [4175, 8758, 52249]): + if cs not in ([4640, 9158, 54450],): gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/gdal/gcore/overview.cpp b/gdal/gcore/overview.cpp index 62b46e3c2d56..cc0c2b6636e5 100644 --- a/gdal/gcore/overview.cpp +++ b/gdal/gcore/overview.cpp @@ -249,6 +249,100 @@ static bool ReadColorTableAsArray( const GDALColorTable* poColorTable, return true; } +/************************************************************************/ +/* GetReplacementValueIfNoData() */ +/************************************************************************/ + +static float GetReplacementValueIfNoData(GDALDataType dt, int bHasNoData, + float fNoDataValue) +{ + float fReplacementVal = 0.0f; + if( bHasNoData ) + { + if( dt == GDT_Byte ) + { + if( fNoDataValue == std::numeric_limits::max() ) + fReplacementVal = static_cast( + std::numeric_limits::max() - 1); + else + fReplacementVal = fNoDataValue + 1; + } + else if( dt == GDT_UInt16 ) + { + if( fNoDataValue == std::numeric_limits::max() ) + fReplacementVal = static_cast( + std::numeric_limits::max() - 1); + else + fReplacementVal = fNoDataValue + 1; + } + else if( dt == GDT_Int16 ) + { + if( fNoDataValue == std::numeric_limits::max() ) + fReplacementVal = static_cast( + std::numeric_limits::max() - 1); + else + fReplacementVal = fNoDataValue + 1; + } + else if( dt == GDT_UInt32 ) + { + // Be careful to limited precision of float + fReplacementVal = fNoDataValue + 1; + double dfVal = fNoDataValue; + if( fReplacementVal >= static_cast(std::numeric_limits::max() - 128) ) + { + while( fReplacementVal == fNoDataValue ) + { + dfVal -= 1.0; + fReplacementVal = static_cast(dfVal); + } + } + else + { + while( fReplacementVal == fNoDataValue ) + { + dfVal += 1.0; + fReplacementVal = static_cast(dfVal); + } + } + } + else if( dt == GDT_Int32 ) + { + // Be careful to limited precision of float + fReplacementVal = fNoDataValue + 1; + double dfVal = fNoDataValue; + if( fReplacementVal >= static_cast(std::numeric_limits::max() - 64) ) + { + while( fReplacementVal == fNoDataValue ) + { + dfVal -= 1.0; + fReplacementVal = static_cast(dfVal); + } + } + else + { + while( fReplacementVal == fNoDataValue ) + { + dfVal += 1.0; + fReplacementVal = static_cast(dfVal); + } + } + } + else if( dt == GDT_Float32 || dt == GDT_Float64 ) + { + if( fNoDataValue == 0 ) + { + fReplacementVal = std::numeric_limits::min(); + } + else + { + fReplacementVal = static_cast( + fNoDataValue + 1e-7 * fNoDataValue); + } + } + } + return fReplacementVal; +} + /************************************************************************/ /* GDALResampleChunk32R_Average() */ /************************************************************************/ @@ -284,6 +378,8 @@ GDALResampleChunk32R_AverageT( double dfXRatioDstToSrc, tNoDataValue = 0; else tNoDataValue = static_cast(fNoDataValue); + const T tReplacementVal = static_cast(GetReplacementValueIfNoData( + poOverview->GetRasterDataType(), bHasNoData, fNoDataValue)); int nChunkRightXOff = nChunkXOff + nChunkXSize; int nChunkBottomYOff = nChunkYOff + nChunkYSize; @@ -441,7 +537,10 @@ GDALResampleChunk32R_AverageT( double dfXRatioDstToSrc, + pSrcScanlineShifted[nChunkXSize] + pSrcScanlineShifted[1+nChunkXSize]; - pDstScanline[iDstPixel] = static_cast((nTotal + 2) / 4); + auto nVal = static_cast((nTotal + 2) / 4); + if( bHasNoData && nVal == tNoDataValue ) + nVal = tReplacementVal; + pDstScanline[iDstPixel] = nVal; pSrcScanlineShifted += 2; } } @@ -480,11 +579,19 @@ GDALResampleChunk32R_AverageT( double dfXRatioDstToSrc, } else if( eWrkDataType == GDT_Byte || eWrkDataType == GDT_UInt16) - pDstScanline[iDstPixel] = - static_cast((dfTotal + nCount / 2) / nCount); + { + auto nVal = static_cast((dfTotal + nCount / 2) / nCount); + if( bHasNoData && nVal == tNoDataValue ) + nVal = tReplacementVal; + pDstScanline[iDstPixel] = nVal; + } else - pDstScanline[iDstPixel] = - static_cast(dfTotal / nCount); + { + auto nVal = static_cast(dfTotal / nCount); + if( bHasNoData && nVal == tNoDataValue ) + nVal = tReplacementVal; + pDstScanline[iDstPixel] = nVal; + } } } } @@ -1772,6 +1879,33 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, { if( !bHasNoData ) fNoDataValue = 0.0f; + const float fReplacementVal = GetReplacementValueIfNoData( + papoDstBands[0]->GetRasterDataType(), bHasNoData, fNoDataValue); + // cppcheck-suppress unreadVariable + const int isIntegerDT = GDALDataTypeIsInteger(papoDstBands[0]->GetRasterDataType()); + const auto nNodataValueInt64 = static_cast(fNoDataValue); + + auto replaceValIfNodata = + [bHasNoData, isIntegerDT, nNodataValueInt64, fNoDataValue, fReplacementVal](float fVal) + { + if( bHasNoData ) + { + if( isIntegerDT ) + { + if( nNodataValueInt64 == static_cast(fVal) ) + { + // Do not use the nodata value + return fReplacementVal; + } + } + else if( fNoDataValue == fVal ) + { + // Do not use the nodata value + return fReplacementVal; + } + } + return fVal; + }; /* -------------------------------------------------------------------- */ /* Allocate work buffers. */ @@ -2098,6 +2232,14 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, GDALResampleConvolutionVertical_16cols( padfHorizontalFilteredBand + j, nDstXSize, padfWeights, nSrcLineCount, pafDstScanline + iFilteredPixelOff ); + if( bHasNoData ) + { + for( int k = 0; k < 16; k++ ) + { + pafDstScanline[iFilteredPixelOff + k] = + replaceValIfNodata(pafDstScanline[iFilteredPixelOff + k]); + } + } } #else for( ; @@ -2107,16 +2249,24 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, GDALResampleConvolutionVertical_8cols( padfHorizontalFilteredBand + j, nDstXSize, padfWeights, nSrcLineCount, pafDstScanline + iFilteredPixelOff ); + if( bHasNoData ) + { + for( int k = 0; k < 8; k++ ) + { + pafDstScanline[iFilteredPixelOff + k] = + replaceValIfNodata(pafDstScanline[iFilteredPixelOff + k]); + } + } } #endif for( ; iFilteredPixelOff < nDstXSize; iFilteredPixelOff++, j++ ) { - const double dfVal = + const float fVal = static_cast( GDALResampleConvolutionVertical( padfHorizontalFilteredBand + j, - nDstXSize, padfWeights, nSrcLineCount ); - pafDstScanline[iFilteredPixelOff] = static_cast(dfVal); + nDstXSize, padfWeights, nSrcLineCount )); + pafDstScanline[iFilteredPixelOff] = replaceValIfNodata(fVal); } #else for( ; @@ -2128,9 +2278,10 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, GDALResampleConvolutionVertical_2cols( padfHorizontalFilteredBand + j, nDstXSize, padfWeights, nSrcLineCount, dfVal1, dfVal2 ); - pafDstScanline[iFilteredPixelOff] = static_cast(dfVal1); - pafDstScanline[iFilteredPixelOff+1] = - static_cast(dfVal2); + pafDstScanline[iFilteredPixelOff] = replaceValIfNodata( + static_cast(dfVal1)); + pafDstScanline[iFilteredPixelOff+1] = replaceValIfNodata( + static_cast(dfVal2)); } if( iFilteredPixelOff < nDstXSize ) { @@ -2138,7 +2289,8 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, GDALResampleConvolutionVertical( padfHorizontalFilteredBand + j, nDstXSize, padfWeights, nSrcLineCount ); - pafDstScanline[iFilteredPixelOff] = static_cast(dfVal); + pafDstScanline[iFilteredPixelOff] = replaceValIfNodata( + static_cast(dfVal)); } #endif } @@ -2195,8 +2347,8 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, } if( dfWeightSum > 0.0 ) { - pafDstScanline[iFilteredPixelOff] = - static_cast(dfVal / dfWeightSum); + pafDstScanline[iFilteredPixelOff] = replaceValIfNodata( + static_cast(dfVal / dfWeightSum)); } else { From 86c49036793495ff504eedd6d8bb5046181c2e8f Mon Sep 17 00:00:00 2001 From: Michael Entin Date: Wed, 14 Nov 2018 07:49:57 -0800 Subject: [PATCH 054/488] CSV Documentation: describe producing CSV with GeoJSON formatted geometries (#1094) * CSV Documentation: describe using ogr2ogr to create CSV with GeoJSON geometry fields * Fix accidental edit --- gdal/ogr/ogrsf_frmts/csv/drv_csv.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdal/ogr/ogrsf_frmts/csv/drv_csv.html b/gdal/ogr/ogrsf_frmts/csv/drv_csv.html index ff6a9a888b7a..1e8607c0635b 100644 --- a/gdal/ogr/ogrsf_frmts/csv/drv_csv.html +++ b/gdal/ogr/ogrsf_frmts/csv/drv_csv.html @@ -290,7 +290,9 @@

    Creation Issues

    file is discarded. It is possible to export the geometry in its WKT representation by specifying GEOMETRY=AS_WKT. It is also possible to export point geometries into their X,Y,Z components (different columns in the csv file) by specifying GEOMETRY=AS_XYZ, GEOMETRY=AS_XY or GEOMETRY=AS_YX. -The geometry column(s) will be prepended to the columns with the attributes values.

    +The geometry column(s) will be prepended to the columns with the attributes values. +It is also possible to export geometries in GeoJSON representation using SQLite SQL dialect query, +see example below.

  • CREATE_CSVT=YES/NO (Starting with GDAL 1.7.0): Create the associated .csvt file (see above paragraph) to describe the type of each column of the layer and its optional width and precision. Default value : NO
  • SEPARATOR=COMMA/SEMICOLON/TAB/SPACE (Starting with GDAL 1.7.0): Field separator character. Default value : COMMA
  • @@ -324,6 +326,9 @@

    Examples

  • This example shows using ogr2ogr to transform a shapefile with point geometry into a .csv file with the X,Y,Z coordinates of the points as first columns in the .csv file
    ogr2ogr -f CSV output.csv input.shp -lco GEOMETRY=AS_XYZ
  • +
  • This example shows using ogr2ogr to transform a shapefile into a .csv file with geography field formatted using GeoJSON format. +
    ogr2ogr -f CSV -dialect sqlite -sql "select AsGeoJSON(geometry) AS geom, * from input" output.csv input.shp
    +
  • Particular datasources

    From 5a9d61933f5494f590ea1a1c746f4ffd3b693242 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 14 Nov 2018 17:49:45 +0100 Subject: [PATCH 055/488] CONTRIBUTING.md: add alternative for squashing all commits [ci skip] --- CONTRIBUTING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22d516b84436..076a35c1a505 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,7 +83,15 @@ git rebase origin/master # At end of your work, make sure history is reasonable by folding non # significant commits into a consistent set -git rebase -i master (use fixup for example to merge several commits together) +git rebase -i master (use 'fixup' for example to merge several commits together, +and 'reword' to modify commit messages) + +# or alternatively, in case there is a big number of commits and marking +# all them as 'fixup' is tedious +git fetch origin +git rebase origin/master +git reset --soft origin/master +git commit -a -m "Put here the synthetic commit message" # push your branch git push my_user_name my_new_feature_branch From a83a6243ec59e14acdcc6c149b47f956ef6c89a1 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 15 Nov 2018 10:13:51 +0100 Subject: [PATCH 056/488] MVT doc: fix copy & paste error pointed by @velix [ci skip] --- gdal/ogr/ogrsf_frmts/mvt/drv_mvt.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/ogr/ogrsf_frmts/mvt/drv_mvt.html b/gdal/ogr/ogrsf_frmts/mvt/drv_mvt.html index 66f117155053..3071c2b7bffd 100644 --- a/gdal/ogr/ogrsf_frmts/mvt/drv_mvt.html +++ b/gdal/ogr/ogrsf_frmts/mvt/drv_mvt.html @@ -194,7 +194,7 @@

    Dataset creation options

    extension of tiles. Defaults to pbf.
  • MINZOOM=integer: Minimum zoom level at which tiles are generated. Defaults to 0.
  • -
  • MAXZOOM=integer: Minimum zoom level at which tiles are generated. Defaults +
  • MAXZOOM=integer: Maximum zoom level at which tiles are generated. Defaults to 5. Maximum supported value is 22
  • CONF=string: Layer configuration as a JSon serialized string.
  • SIMPLIFICATION=float: Simplification factor for linear or polygonal From 094243ec5954391bc73d0b9c2e7e940d57003b63 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 16 Nov 2018 00:01:37 +0100 Subject: [PATCH 057/488] VSIGZipWriteHandleMT::ProcessCompletedJobs(): fix potential dead-lock (refs #1099, master only) --- gdal/port/cpl_vsil_gzip.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdal/port/cpl_vsil_gzip.cpp b/gdal/port/cpl_vsil_gzip.cpp index 37115248da71..411c98fd8475 100644 --- a/gdal/port/cpl_vsil_gzip.cpp +++ b/gdal/port/cpl_vsil_gzip.cpp @@ -1547,17 +1547,17 @@ bool VSIGZipWriteHandleMT::ProcessCompletedJobs() if( !psJob->bInCRCComputation_ ) { psJob->bInCRCComputation_ = true; + sMutex_.unlock(); if( poPool_ ) { - sMutex_.unlock(); poPool_->SubmitJob( VSIGZipWriteHandleMT::CRCCompute, psJob ); - sMutex_.lock(); } else { CRCCompute(psJob); } + sMutex_.lock(); } } } From adcdba21d66ab34cf1a63055f2260f7ea5478759 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 16 Nov 2018 00:16:43 +0100 Subject: [PATCH 058/488] Test /vsizip/ parallel compression below the treshold (refs #1099) --- autotest/gcore/vsizip.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/autotest/gcore/vsizip.py b/autotest/gcore/vsizip.py index 5b2c2d33e77b..82cb1e4e2218 100755 --- a/autotest/gcore/vsizip.py +++ b/autotest/gcore/vsizip.py @@ -696,6 +696,32 @@ def vsizip_multi_thread(): return 'success' +############################################################################### +# Test multithreaded compression, below the threshold where it triggers + + +def vsizip_multi_thread_below_threshold(): + + with gdaltest.config_options({'GDAL_NUM_THREADS': 'ALL_CPUS'}): + fmain = gdal.VSIFOpenL('/vsizip//vsimem/vsizip_multi_thread.zip', 'wb') + f = gdal.VSIFOpenL('/vsizip//vsimem/vsizip_multi_thread.zip/test', 'wb') + gdal.VSIFWriteL('hello', 1, 5, f) + gdal.VSIFCloseL(f) + gdal.VSIFCloseL(fmain) + + f = gdal.VSIFOpenL('/vsizip//vsimem/vsizip_multi_thread.zip/test', 'rb') + data = gdal.VSIFReadL(1, 5, f).decode('ascii') + gdal.VSIFCloseL(f) + + gdal.Unlink('/vsimem/vsizip_multi_thread.zip') + + if data != 'hello': + gdaltest.post_reason('fail') + print(data) + return 'fail' + + return 'success' + ############################################################################### # Test creating ZIP64 file: uncompressed larger than 4GB, but compressed # data stream < 4 GB @@ -811,6 +837,7 @@ def vsizip_byte_zip64_local_header_zeroed(): vsizip_13, vsizip_14, vsizip_multi_thread, + vsizip_multi_thread_below_threshold, vsizip_create_zip64, vsizip_create_zip64_stream_larger_than_4G, vsizip_byte_zip64_local_header_zeroed, From 29ce66da1a40eae07b3343f9788092b571a7e22a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 16 Nov 2018 00:26:20 +0100 Subject: [PATCH 059/488] MVT: make it possible to output to /vsizip/output.zip out-of-the-box --- gdal/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdal/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp b/gdal/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp index 1fd1cb596d65..b72c09041620 100644 --- a/gdal/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp +++ b/gdal/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp @@ -5982,9 +5982,14 @@ GDALDataset* OGRMVTWriterDataset::Create( const char * pszFilename, poDS->m_pMyVFS = OGRSQLiteCreateVFS(nullptr, poDS); sqlite3_vfs_register(poDS->m_pMyVFS, 0); + CPLString osTempDBDefault = CPLString(pszFilename) + ".temp.db"; + if( STARTS_WITH(osTempDBDefault, "/vsizip/") ) + { + osTempDBDefault = CPLString(pszFilename + strlen("/vsizip/")) + ".temp.db"; + } CPLString osTempDB = CSLFetchNameValueDef(papszOptions, "TEMPORARY_DB", - (CPLString(pszFilename) + ".temp.db").c_str()); + osTempDBDefault.c_str()); if( !bReuseTempFile ) VSIUnlink(osTempDB); From e0eaa5283568fd0ee25d3e709b2e3cf96c6612c9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 17 Nov 2018 14:02:49 +0100 Subject: [PATCH 060/488] NGSGEOID: report a CRS that conforms to the official publications for GEOID2012 and USGG2012 datasets (fixes #1103) --- gdal/frmts/ngsgeoid/ngsgeoiddataset.cpp | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/gdal/frmts/ngsgeoid/ngsgeoiddataset.cpp b/gdal/frmts/ngsgeoid/ngsgeoiddataset.cpp index d5d09a6d7b71..4622a564c111 100644 --- a/gdal/frmts/ngsgeoid/ngsgeoiddataset.cpp +++ b/gdal/frmts/ngsgeoid/ngsgeoiddataset.cpp @@ -51,6 +51,7 @@ class NGSGEOIDDataset : public GDALPamDataset VSILFILE *fp; double adfGeoTransform[6]; int bIsLittleEndian; + CPLString osProjection{}; static int GetHeaderInfo( const GByte* pBuffer, double* padfGeoTransform, @@ -388,6 +389,62 @@ CPLErr NGSGEOIDDataset::GetGeoTransform( double * padfTransform ) const char* NGSGEOIDDataset::GetProjectionRef() { + if( !osProjection.empty() ) + { + return osProjection.c_str(); + } + + CPLString osFilename(CPLGetBasename(GetDescription())); + osFilename.tolower(); + + // See https://www.ngs.noaa.gov/GEOID/GEOID12B/faq_2012B.shtml + + // GEOID2012 files ? + if( STARTS_WITH(osFilename, "g2012") && osFilename.size() >= 7 ) + { + OGRSpatialReference oSRS; + if( osFilename[6] == 'h' /* Hawai */ || + osFilename[6] == 's' /* Samoa */ ) + { + // NAD83 (PA11) + oSRS.importFromEPSG(6322); + } + else if( osFilename[6] == 'g' /* Guam */ ) + { + // NAD83 (MA11) + oSRS.importFromEPSG(6325); + } + else + { + // NAD83 (2011) + oSRS.importFromEPSG(6318); + } + + char* pszProjection = nullptr; + oSRS.exportToWkt(&pszProjection); + if( pszProjection ) + osProjection = pszProjection; + CPLFree(pszProjection); + return osProjection.c_str(); + } + + // USGG2012 files ? We should return IGS08, but there is only a + // geocentric CRS in EPSG, so manually forge a geographic one from it + if( STARTS_WITH(osFilename, "s2012") ) + { + osProjection = +"GEOGCS[\"IGS08\",\n" +" DATUM[\"IGS08\",\n" +" SPHEROID[\"GRS 1980\",6378137,298.257222101,\n" +" AUTHORITY[\"EPSG\",\"7019\"]],\n" +" AUTHORITY[\"EPSG\",\"1141\"]],\n" +" PRIMEM[\"Greenwich\",0,\n" +" AUTHORITY[\"EPSG\",\"8901\"]],\n" +" UNIT[\"degree\",0.0174532925199433,\n" +" AUTHORITY[\"EPSG\",\"9122\"]]]"; + return osProjection.c_str(); + } + return SRS_WKT_WGS84; } From 6cea3aec0032165dba72fc4e3f82b7e5379f7b16 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 17 Nov 2018 18:26:06 +0100 Subject: [PATCH 061/488] PDS4: add UNIT[] node to SRS on reading, so that is valid --- gdal/frmts/pds/pds4dataset.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdal/frmts/pds/pds4dataset.cpp b/gdal/frmts/pds/pds4dataset.cpp index 677d5cdeba73..b7a33840c5fa 100644 --- a/gdal/frmts/pds/pds4dataset.cpp +++ b/gdal/frmts/pds/pds4dataset.cpp @@ -1302,6 +1302,11 @@ void PDS4Dataset::ReadGeoreferencing(CPLXMLNode* psProduct) "Planar.Map_Projection not found"); } + if( oSRS.IsProjected() ) + { + oSRS.SetLinearUnits("Metre", 1.0); + } + CPLXMLNode* psGeodeticModel = CPLGetXMLNode(psSR, "Geodetic_Model"); if( psGeodeticModel != nullptr ) { From 34aa9f038dc8664ede976beaf1fcc4beb00a8e57 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 17 Nov 2018 22:33:18 +0100 Subject: [PATCH 062/488] GRIB: add UNIT[] node to SRS on reading, so that is valid --- autotest/gdrivers/grib.py | 14 +++++++------- gdal/frmts/grib/gribdataset.cpp | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/autotest/gdrivers/grib.py b/autotest/gdrivers/grib.py index d55f31298fe8..a0d84451b6c7 100755 --- a/autotest/gdrivers/grib.py +++ b/autotest/gdrivers/grib.py @@ -440,7 +440,7 @@ def grib_grib2_read_transverse_mercator(): ds = gdal.Open('data/grib/transverse_mercator.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["unknown",SPHEROID["Sphere",6367470,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["unknown",SPHEROID["Sphere",6367470,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) @@ -470,7 +470,7 @@ def grib_grib2_read_mercator(): ds = gdal.Open('data/grib/mercator.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) @@ -500,7 +500,7 @@ def grib_grib2_read_mercator_2sp(): ds = gdal.Open('data/grib/mercator_2sp.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",33.5],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",33.5],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) @@ -530,7 +530,7 @@ def grib_grib2_read_lcc(): ds = gdal.Open('data/grib/lambert_conformal_conic.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",33],PARAMETER["standard_parallel_2",34],PARAMETER["latitude_of_origin",33.5],PARAMETER["central_meridian",117],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",33],PARAMETER["standard_parallel_2",34],PARAMETER["latitude_of_origin",33.5],PARAMETER["central_meridian",117],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) @@ -560,7 +560,7 @@ def grib_grib2_read_polar_stereo(): ds = gdal.Open('data/grib/polar_stereographic.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",60],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",60],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) @@ -590,7 +590,7 @@ def grib_grib2_read_aea(): ds = gdal.Open('data/grib/albers_equal_area.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",33],PARAMETER["standard_parallel_2",34],PARAMETER["latitude_of_center",33.5],PARAMETER["longitude_of_center",117],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",33],PARAMETER["standard_parallel_2",34],PARAMETER["latitude_of_center",33.5],PARAMETER["longitude_of_center",117],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) @@ -620,7 +620,7 @@ def grib_grib2_read_laea(): ds = gdal.Open('data/grib/lambert_azimuthal_equal_area.grb2') projection = ds.GetProjectionRef() - expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",33.5],PARAMETER["longitude_of_center",243],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]""" + expected_projection = """PROJCS["unnamed",GEOGCS["Coordinate System imported from GRIB file",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",33.5],PARAMETER["longitude_of_center",243],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Metre",1]]""" if projection != expected_projection: gdaltest.post_reason('Did not get expected projection') print(projection) diff --git a/gdal/frmts/grib/gribdataset.cpp b/gdal/frmts/grib/gribdataset.cpp index 632185eb2b2e..76a3d7a3c327 100644 --- a/gdal/frmts/grib/gribdataset.cpp +++ b/gdal/frmts/grib/gribdataset.cpp @@ -1207,6 +1207,11 @@ void GRIBDataset::SetGribMetaData(grib_MetaData *meta) break; } + if( oSRS.IsProjected() ) + { + oSRS.SetLinearUnits("Metre", 1.0); + } + const bool bHaveEarthModel = meta->gds.majEarth != 0.0 || meta->gds.minEarth != 0.0; // In meters. From 38da35099ddca0ea7a8aa61a2be6462926dc4154 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 17 Nov 2018 22:33:22 +0100 Subject: [PATCH 063/488] IRIS: add UNIT[] node to SRS on reading, so that is valid --- gdal/frmts/iris/irisdataset.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gdal/frmts/iris/irisdataset.cpp b/gdal/frmts/iris/irisdataset.cpp index 3a9d315ff1ef..cea77c458ec9 100644 --- a/gdal/frmts/iris/irisdataset.cpp +++ b/gdal/frmts/iris/irisdataset.cpp @@ -508,6 +508,7 @@ void IRISDataset::LoadProjection() "degree", 0.0174532925199433); oSRSOut.SetMercator(fProjRefLat, fProjRefLon, 1.0, 0.0, 0.0); + oSRSOut.SetLinearUnits("Metre", 1.0); oSRSOut.exportToWkt(&pszSRS_WKT); // The center coordinates are given in LatLon on the defined From 805bf6906b8af247eab8dee060e215d6b8e5c7ae Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 18 Nov 2018 12:25:32 +0100 Subject: [PATCH 064/488] Code doc: update link [ci skip] --- gdal/alg/gdalwarpkernel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdal/alg/gdalwarpkernel.cpp b/gdal/alg/gdalwarpkernel.cpp index 2a4b946632aa..fc59a2fc0c7a 100644 --- a/gdal/alg/gdalwarpkernel.cpp +++ b/gdal/alg/gdalwarpkernel.cpp @@ -3092,7 +3092,7 @@ static double GWKCubic( double dfX ) { // http://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm // W(x) formula with a = -0.5 (cubic hermite spline ) - // or http://www.cs.utexas.edu/users/fussell/courses/cs384g/lectures/mitchell/Mitchell.pdf + // or https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf // k(x) (formula 8) with (B,C)=(0,0.5) the Catmull-Rom spline double dfAbsX = fabs(dfX); if( dfAbsX <= 1.0 ) @@ -3155,10 +3155,10 @@ static double GWKCubic4Values( double* padfValues ) /* GWKBSpline() */ /************************************************************************/ -// http://www.cs.utexas.edu/users/fussell/courses/cs384g/lectures/mitchell/Mitchell.pdf -// with (B,C)=(1,0) +// https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf +// Equation 8 with (B,C)=(1,0) // 1/6 * ( 3 * |x|^3 - 6 * |x|^2 + 4) |x| < 1 -// 1/6 * ( -|x|^3 + 6 |x|^2 - 12|x| + 8) |x| > 1 +// 1/6 * ( -|x|^3 + 6 |x|^2 - 12|x| + 8) |x| >= 1 and |x| < 2 static double GWKBSpline( double x ) { From b1eecf60a04ac462985fd2c7298d38780248497a Mon Sep 17 00:00:00 2001 From: Simon South Date: Sat, 27 Oct 2018 15:20:25 -0400 Subject: [PATCH 065/488] SQLite: Leverage common date-parsing functionality Use OGRParseDate() in place of the driver-specific OGRSQLITEStringToDateTimeField() to parse date and time values, effectively adding time-zone support to the driver. Refactor the remaining functionality of OGRSQLITEStringToDateTimeField() into a new function, OGRGetDateTimeFieldType(), that returns the simplest appropriate field type for storing a given date or time string. --- .../ogr/data/gmlas/gmlas_test1_generated.xml | 2 +- gdal/ogr/ogrsf_frmts/sqlite/ogr_sqlite.h | 3 - .../ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp | 145 ++++++++---------- .../sqlite/ogrsqlitevirtualogr.cpp | 4 +- 4 files changed, 63 insertions(+), 91 deletions(-) diff --git a/autotest/ogr/data/gmlas/gmlas_test1_generated.xml b/autotest/ogr/data/gmlas/gmlas_test1_generated.xml index 88598c577c93..1104f4c070d2 100644 --- a/autotest/ogr/data/gmlas/gmlas_test1_generated.xml +++ b/autotest/ogr/data/gmlas/gmlas_test1_generated.xml @@ -32,7 +32,7 @@ 2012-01-01T12:34:56Z 2012-01-02T12:34:56Z 2012-01-01 - 12:34:56Z + 12:34:56 true true false diff --git a/gdal/ogr/ogrsf_frmts/sqlite/ogr_sqlite.h b/gdal/ogr/ogrsf_frmts/sqlite/ogr_sqlite.h index 60a50a357d96..c7afa0914b49 100644 --- a/gdal/ogr/ogrsf_frmts/sqlite/ogr_sqlite.h +++ b/gdal/ogr/ogrsf_frmts/sqlite/ogr_sqlite.h @@ -950,9 +950,6 @@ class RL2RasterBand final: public GDALPamRasterBand CPLString OGRSQLiteFieldDefnToSQliteFieldDefn( OGRFieldDefn* poFieldDefn, int bSQLiteDialectInternalUse ); -int OGRSQLITEStringToDateTimeField( OGRFeature* poFeature, int iField, - const char* pszValue ); - typedef void (*pfnNotifyFileOpenedType)(void* pfnUserData, const char* pszFilename, VSILFILE* fp); sqlite3_vfs* OGRSQLiteCreateVFS(pfnNotifyFileOpenedType pfn, void* pfnUserData); diff --git a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp index 230526249772..68564e65f341 100644 --- a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp @@ -129,6 +129,53 @@ void OGRSQLiteLayer::Finalize() papszCompressedColumns = nullptr; } +/************************************************************************/ +/* OGRGetDateTimeFieldType() */ +/************************************************************************/ + +static +bool OGRGetDateTimeFieldType( const char* pszValue, + OGRFieldType* pFieldType ) +{ + bool bSuccess = FALSE; + size_t nValueLength = strnlen( pszValue, 16 ); + + if( nValueLength >= 5 ) + { + unsigned int nYear; + unsigned int nMonth; + unsigned int nDay; + unsigned int nHour; + unsigned int nMinute; + + if( nValueLength >= 10 ) + { + int nItemsMatched = sscanf( pszValue, "%04u-%02u-%02u", + &nYear, &nMonth, &nDay ); + if( nItemsMatched == 1 ) + nItemsMatched = sscanf( pszValue, "%04u/%02u/%02u", + &nYear, &nMonth, &nDay ); + + if( (nItemsMatched == 3) && (nValueLength >= 16) ) + nItemsMatched += sscanf( &pszValue[11], "%02u:%02u", + &nHour, &nMinute ); + + if( nItemsMatched >= 3 ) + { + *pFieldType = (nItemsMatched == 5) ? OFTDateTime : OFTDate; + bSuccess = TRUE; + } + } + else if( sscanf(pszValue, "%02u:%02u", &nHour, &nMinute) == 2 ) + { + *pFieldType = OFTTime; + bSuccess = TRUE; + } + } + + return bSuccess; +} + /************************************************************************/ /* OGRIsBinaryGeomCol() */ /************************************************************************/ @@ -398,13 +445,17 @@ void OGRSQLiteLayer::BuildFeatureDefn( const char *pszLayerName, } else if( nColType == SQLITE_TEXT && (STARTS_WITH_CI(oField.GetNameRef(), "MIN(") || - STARTS_WITH_CI(oField.GetNameRef(), "MAX(")) && - sqlite3_column_text( hStmtIn, iCol ) != nullptr ) + STARTS_WITH_CI(oField.GetNameRef(), "MAX("))) { - int nRet = OGRSQLITEStringToDateTimeField(nullptr, 0, - (const char*)sqlite3_column_text( hStmtIn, iCol )); - if( nRet > 0 ) - eFieldType = (OGRFieldType) nRet; + const char* pszText = reinterpret_cast( + sqlite3_column_text( hStmtIn, iCol )); + if( pszText != nullptr ) + { + OGRField oScratchField; + + if( OGRParseDate( pszText, &oScratchField, 0 ) == TRUE ) + OGRGetDateTimeFieldType( pszText, &eFieldType ); + } } // Recognise some common geometry column names. @@ -819,7 +870,8 @@ OGRFeature *OGRSQLiteLayer::GetNextRawFeature() { const char* pszValue = (const char *) sqlite3_column_text( hStmt, iRawField ); - OGRSQLITEStringToDateTimeField( poFeature, iField, pszValue ); + if( !OGRParseDate( pszValue, poFeature->GetRawFieldRef(iField), 0 ) ) + poFeature->UnsetField( iField ); } else if( sqlite3_column_type( hStmt, iRawField ) == SQLITE_FLOAT ) { @@ -831,7 +883,8 @@ OGRFeature *OGRSQLiteLayer::GetNextRawFeature() &papszResult, nullptr, nullptr, nullptr ); if( papszResult && papszResult[0] && papszResult[1] ) { - OGRSQLITEStringToDateTimeField( poFeature, iField, papszResult[1] ); + if( !OGRParseDate( papszResult[1], poFeature->GetRawFieldRef(iField), 0 ) ) + poFeature->UnsetField( iField ); } sqlite3_free_table(papszResult); } @@ -3322,82 +3375,6 @@ void OGRSQLiteLayer::ClearStatement() } } -/************************************************************************/ -/* OGRSQLITEStringToDateTimeField() */ -/************************************************************************/ - -int OGRSQLITEStringToDateTimeField( OGRFeature* poFeature, int iField, - const char* pszValue ) -{ - int nYear = 0; - int nMonth = 0; - int nDay = 0; - int nHour = 0; - int nMinute = 0; - float fSecond = 0.0f; - - /* YYYY-MM-DD HH:MM:SS.SSS */ - if( sscanf(pszValue, "%04d-%02d-%02d %02d:%02d:%f", - &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond) == 6 || - sscanf(pszValue, "%04d/%02d/%02d %02d:%02d:%f", - &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond) == 6 || - sscanf(pszValue, "%04d-%02d-%02dT%02d:%02d:%f", - &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond) == 6 ) - { - if( poFeature ) - poFeature->SetField( iField, nYear, nMonth, - nDay, nHour, nMinute, fSecond, 0); - return OFTDateTime; - } - - /* YYYY-MM-DD HH:MM */ - if( sscanf(pszValue, "%04d-%02d-%02d %02d:%02d", - &nYear, &nMonth, &nDay, &nHour, &nMinute) == 5 || - sscanf(pszValue, "%04d/%02d/%02d %02d:%02d", - &nYear, &nMonth, &nDay, &nHour, &nMinute) == 5 || - sscanf(pszValue, "%04d-%02d-%02dT%02d:%02d", - &nYear, &nMonth, &nDay, &nHour, &nMinute) == 5 ) - { - if( poFeature ) - poFeature->SetField( iField, nYear, nMonth, - nDay, nHour, nMinute, 0, 0); - return OFTDateTime; - } - - /* YYYY-MM-DD */ - if( sscanf(pszValue, "%04d-%02d-%02d", - &nYear, &nMonth, &nDay) == 3 || - sscanf(pszValue, "%04d/%02d/%02d", - &nYear, &nMonth, &nDay) == 3 ) - { - if( poFeature ) - poFeature->SetField( iField, nYear, nMonth, nDay, - 0, 0, 0, 0 ); - return OFTDate; - } - - /* HH:MM:SS.SSS */ - if( sscanf(pszValue, "%02d:%02d:%f", - &nHour, &nMinute, &fSecond) == 3 ) - { - if( poFeature ) - poFeature->SetField( iField, 0, 0, 0, - nHour, nMinute, fSecond, 0 ); - return OFTTime; - } - - /* HH:MM */ - if( sscanf(pszValue, "%02d:%02d", &nHour, &nMinute) == 2 ) - { - if( poFeature ) - poFeature->SetField( iField, 0, 0, 0, - nHour, nMinute, 0, 0 ); - return OFTTime; - } - - return FALSE; -} - /************************************************************************/ /* FormatSpatialFilterFromRTree() */ /************************************************************************/ diff --git a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp index b97d9b43e10c..d53098418245 100644 --- a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp +++ b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp @@ -1554,11 +1554,9 @@ static OGRFeature* OGR2SQLITE_FeatureFromArgs(OGRLayer* poLayer, case OFTDate: case OFTTime: case OFTDateTime: - { - if( !OGRSQLITEStringToDateTimeField( poFeature, i, pszValue ) ) + if( !OGRParseDate( pszValue, poFeature->GetRawFieldRef(i), 0 ) ) poFeature->SetField(i, pszValue); break; - } default: poFeature->SetField(i, pszValue); From 81c82782567ed5b57930efd3ff8d67ac8f58bf45 Mon Sep 17 00:00:00 2001 From: Simon South Date: Wed, 10 Oct 2018 10:00:28 -0400 Subject: [PATCH 066/488] OGRGetXMLDateTime(): Interpret TZFlag correctly (fixes #996) --- autotest/cpp/test_ogr.cpp | 115 ++++++++++++++++++++++++++++++++++++++ autotest/ogr/ogr_mvt.py | 6 +- gdal/ogr/ogrutils.cpp | 67 ++++++++++++---------- 3 files changed, 154 insertions(+), 34 deletions(-) diff --git a/autotest/cpp/test_ogr.cpp b/autotest/cpp/test_ogr.cpp index cdd72d3362d9..efb1ff4746a2 100644 --- a/autotest/cpp/test_ogr.cpp +++ b/autotest/cpp/test_ogr.cpp @@ -25,6 +25,7 @@ #include "gdal_unit_test.h" +#include "ogr_p.h" #include "ogrsf_frmts.h" #include "../../gdal/ogr/ogrsf_frmts/osm/gpb.h" @@ -1355,4 +1356,118 @@ namespace tut poFeatureDefn->Release(); } + // Test OGRGetXMLDateTime() + template<> + template<> + void object::test<15>() + { + OGRField sField; + char *pszDateTime; + + sField.Date.Year = 2001; + sField.Date.Month = 2; + sField.Date.Day = 3; + sField.Date.Hour = 4; + sField.Date.Minute = 5; + + // Unknown time zone (TZFlag = 0), no millisecond count + sField.Date.TZFlag = 0; + sField.Date.Second = 6.0f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "unknown time zone, no millisecond count", + strcmp("2001-02-03T04:05:06", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Unknown time zone (TZFlag = 0), millisecond count + sField.Date.TZFlag = 0; + sField.Date.Second = 6.789f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "unknown time zone, millisecond count", + strcmp("2001-02-03T04:05:06.789", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Local time zone (TZFlag = 1), no millisecond count + sField.Date.TZFlag = 1; + sField.Date.Second = 6.0f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "local time zone, no millisecond count", + strcmp("2001-02-03T04:05:06", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Local time zone (TZFlag = 1), millisecond count + sField.Date.TZFlag = 1; + sField.Date.Second = 6.789f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "local time zone, millisecond count", + strcmp("2001-02-03T04:05:06.789", pszDateTime) == 0); + CPLFree(pszDateTime); + + // GMT time zone (TZFlag = 100), no millisecond count + sField.Date.TZFlag = 100; + sField.Date.Second = 6.0f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "GMT time zone, no millisecond count", + strcmp("2001-02-03T04:05:06Z", pszDateTime) == 0); + CPLFree(pszDateTime); + + // GMT time zone (TZFlag = 100), millisecond count + sField.Date.TZFlag = 100; + sField.Date.Second = 6.789f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "GMT time zone, millisecond count", + strcmp("2001-02-03T04:05:06.789Z", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Positive time-zone offset, no millisecond count + sField.Date.TZFlag = 111; + sField.Date.Second = 6.0f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "positive time-zone offset, no millisecond count", + strcmp("2001-02-03T04:05:06+02:45", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Positive time-zone offset, millisecond count + sField.Date.TZFlag = 111; + sField.Date.Second = 6.789f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "positive time-zone offset, millisecond count", + strcmp("2001-02-03T04:05:06.789+02:45", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Negative time-zone offset, no millisecond count + sField.Date.TZFlag = 88; + sField.Date.Second = 6.0f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "negative time-zone offset, no millisecond count", + strcmp("2001-02-03T04:05:06-03:00", pszDateTime) == 0); + CPLFree(pszDateTime); + + // Negative time-zone offset, millisecond count + sField.Date.TZFlag = 88; + sField.Date.Second = 6.789f; + pszDateTime = OGRGetXMLDateTime(&sField); + ensure(nullptr != pszDateTime); + ensure("OGRGetXMLDateTime formats date/time field with " + "negative time-zone offset, millisecond count", + strcmp("2001-02-03T04:05:06.789-03:00", pszDateTime) == 0); + CPLFree(pszDateTime); + } } // namespace tut diff --git a/autotest/ogr/ogr_mvt.py b/autotest/ogr/ogr_mvt.py index fefa6cf9fd04..133ab7a472d7 100644 --- a/autotest/ogr/ogr_mvt.py +++ b/autotest/ogr/ogr_mvt.py @@ -998,7 +998,7 @@ def ogr_mvt_write_one_layer(): out_f['int64field'] != 123456789012345 or \ out_f['realfield'] != 1.25 or \ out_f['datefield'] != '2018-02-01' or \ - out_f['datetimefield'] != '2018-02-01T12:34:56Z' or \ + out_f['datetimefield'] != '2018-02-01T12:34:56' or \ out_f['boolfield'] is False or \ ogrtest.check_feature_geometry(out_f, 'POINT (498980.920645632 997961.84129126)') != 0: gdaltest.post_reason('fail') @@ -1011,7 +1011,7 @@ def ogr_mvt_write_one_layer(): out_f['int64field'] != 123456789012345 or \ out_f['realfield'] != 1.25 or \ out_f['datefield'] != '2018-02-01' or \ - out_f['datetimefield'] != '2018-02-01T12:34:56Z' or \ + out_f['datetimefield'] != '2018-02-01T12:34:56' or \ out_f['boolfield'] is False or \ ogrtest.check_feature_geometry(out_f, 'MULTILINESTRING ((498980.920645632 997961.84129126,508764.860266134 1007745.78091176,518548.799886636 1017529.72053226))') != 0: gdaltest.post_reason('fail') @@ -1181,7 +1181,7 @@ def ogr_mvt_write_one_layer(): "count": 1, "type": "string", "values": [ - "2018-02-01T12:34:56Z" + "2018-02-01T12:34:56" ] }, { diff --git a/gdal/ogr/ogrutils.cpp b/gdal/ogr/ogrutils.cpp index 01b262afd07e..1190aef6b00c 100644 --- a/gdal/ogr/ogrutils.cpp +++ b/gdal/ogr/ogrutils.cpp @@ -1377,44 +1377,49 @@ char* OGRGetRFC822DateTime( const OGRField* psField ) char* OGRGetXMLDateTime(const OGRField* psField) { - const int year = psField->Date.Year; - const int month = psField->Date.Month; - const int day = psField->Date.Day; - const int hour = psField->Date.Hour; - const int minute = psField->Date.Minute; + const GInt16 year = psField->Date.Year; + const GByte month = psField->Date.Month; + const GByte day = psField->Date.Day; + const GByte hour = psField->Date.Hour; + const GByte minute = psField->Date.Minute; const float second = psField->Date.Second; - const int TZFlag = psField->Date.TZFlag; + const GByte TZFlag = psField->Date.TZFlag; + char szTimeZone[7]; char* pszRet = nullptr; - if( TZFlag == 0 || TZFlag == 100 ) + switch( TZFlag ) { - if( OGR_GET_MS(second) ) - pszRet = CPLStrdup(CPLSPrintf( - "%04d-%02d-%02dT%02d:%02d:%06.3fZ", - year, month, day, hour, minute, second)); - else - pszRet = CPLStrdup(CPLSPrintf( - "%04d-%02d-%02dT%02d:%02d:%02dZ", - year, month, day, hour, minute, static_cast(second))); + case 0: // Unknown time zone + case 1: // Local time zone (not specified) + szTimeZone[0] = 0; + break; + + case 100: // GMT + szTimeZone[0] = 'Z'; + szTimeZone[1] = 0; + break; + + default: // Offset (in quarter-hour units) from GMT + const int TZOffset = std::abs(TZFlag - 100) * 15; + const int TZHour = TZOffset / 60; + const int TZMinute = TZOffset % 60; + + snprintf(szTimeZone, 7, "%c%02d:%02d", + (TZFlag > 100) ? '+' : '-', TZHour, TZMinute); } + + if( OGR_GET_MS(second) ) + pszRet = CPLStrdup(CPLSPrintf( + "%04d-%02u-%02uT%02u:%02u:%06.3f%s", + year, month, day, hour, minute, second, + szTimeZone)); else - { - const int TZOffset = std::abs(TZFlag - 100) * 15; - const int TZHour = TZOffset / 60; - const int TZMinute = TZOffset - TZHour * 60; - if( OGR_GET_MS(second) ) - pszRet = CPLStrdup(CPLSPrintf( - "%04d-%02d-%02dT%02d:%02d:%06.3f%c%02d:%02d", - year, month, day, hour, minute, second, - (TZFlag > 100) ? '+' : '-', TZHour, TZMinute)); - else - pszRet = CPLStrdup( - CPLSPrintf("%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", - year, month, day, hour, minute, - static_cast(second), - TZFlag > 100 ? '+' : '-', TZHour, TZMinute)); - } + pszRet = CPLStrdup(CPLSPrintf( + "%04d-%02u-%02uT%02u:%02u:%02u%s", + year, month, day, hour, minute, + static_cast(second), szTimeZone)); + return pszRet; } From b468e2f410c61622eb363d0d847096b1124e97cf Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 19 Nov 2018 20:59:38 +0100 Subject: [PATCH 067/488] IGNFHeightASCIIGrid: add support for .gra format --- .../gdrivers/data/ignfheightasciigrid.gra | 9 + autotest/gdrivers/ignfheightasciigrid.py | 38 +++ gdal/frmts/frmt_various.html | 2 +- .../ignfheightasciigrid.cpp | 249 ++++++++++++++++-- gdal/frmts/xyz/xyzdataset.cpp | 5 + 5 files changed, 273 insertions(+), 30 deletions(-) create mode 100644 autotest/gdrivers/data/ignfheightasciigrid.gra diff --git a/autotest/gdrivers/data/ignfheightasciigrid.gra b/autotest/gdrivers/data/ignfheightasciigrid.gra new file mode 100644 index 000000000000..8142f11d9347 --- /dev/null +++ b/autotest/gdrivers/data/ignfheightasciigrid.gra @@ -0,0 +1,9 @@ +-16.75 -16.5 +-152 -151.5 +0.25 0.25 +1 +4 +2 +5 +3 +6 diff --git a/autotest/gdrivers/ignfheightasciigrid.py b/autotest/gdrivers/ignfheightasciigrid.py index 04dc17be3749..e2596b4b7db9 100755 --- a/autotest/gdrivers/ignfheightasciigrid.py +++ b/autotest/gdrivers/ignfheightasciigrid.py @@ -176,6 +176,42 @@ def ignfheightasciigrid_huge(): return 'success' +def ignfheightasciigrid_gra(): + + tst = gdaltest.GDALTest( + 'IGNFHeightASCIIGrid', 'ignfheightasciigrid.gra', 1, 21) + gt = (-152.125, 0.25, 0.0, -16.375, 0.0, -0.25) + if tst.testOpen(check_gt=gt, check_prj='WGS84') != 'success': + return 'fail' + + ds = gdal.OpenEx('data/ignfheightasciigrid.gra', gdal.OF_RASTER) + if ds.GetRasterBand(1).GetNoDataValue() != 9999: + gdaltest.post_reason('fail') + return 'fail' + return 'success' + + +def ignfheightasciigrid_gra_invalid(): + + contents = ['49 50\r\n2\r\n', # missing values + '49 50\r\n2 3\r\n', # missing line + '49 50\r\n2 3\r\nx 1\r\n', # non numeric value + '-200 50\r\n2 3\r\n1 1\r\n', # invalid value + ] + + filename = '/vsimem/ignfheightasciigrid_invalid.gra' + for content in contents: + gdal.FileFromMemBuffer(filename, content) + with gdaltest.error_handler(): + if gdal.OpenEx(filename, gdal.OF_RASTER): + gdaltest.post_reason('fail') + print(content) + return 'fail' + gdal.Unlink(filename) + return 'success' + + + gdaltest_list = [ ignfheightasciigrid_1, ignfheightasciigrid_2, @@ -187,6 +223,8 @@ def ignfheightasciigrid_huge(): ignfheightasciigrid_description_multiword, ignfheightasciigrid_invalid, ignfheightasciigrid_huge, + ignfheightasciigrid_gra, + ignfheightasciigrid_gra_invalid, ] diff --git a/gdal/frmts/frmt_various.html b/gdal/frmts/frmt_various.html index c7b6035c8bad..9aa4652914e9 100644 --- a/gdal/frmts/frmt_various.html +++ b/gdal/frmts/frmt_various.html @@ -633,7 +633,7 @@

    IGNFHeightASCIIGrid -- IGN-France height corre

    (GDAL >= 2.4.0)

    -

    Supports reading IGN-France height correction ASCII grids.

    +

    Supports reading IGN-France height correction ASCII grids (.txt, .mnt, .gra).

    See also:

      diff --git a/gdal/frmts/ignfheightasciigrid/ignfheightasciigrid.cpp b/gdal/frmts/ignfheightasciigrid/ignfheightasciigrid.cpp index 9f5c2a85f621..223a450d4394 100644 --- a/gdal/frmts/ignfheightasciigrid/ignfheightasciigrid.cpp +++ b/gdal/frmts/ignfheightasciigrid/ignfheightasciigrid.cpp @@ -40,14 +40,23 @@ /* ==================================================================== */ /************************************************************************/ -class IGNFHeightASCIIGridDataset: public GDALPamDataset +class IGNFHeightASCIIGridDataset final: public GDALPamDataset { double adfGeoTransform[6]{0,1,0,0,0,1}; int m_nArrangementOrder = 0; size_t getSampleIndex( size_t nBufferCount ); - static bool ParseHeader(GDALOpenInfo* poOpenInfo, + static bool CheckExtentAndComputeRasterSize( double dfLongMin, + double dfLongMax, + double dfLatMin, + double dfLatMax, + double dfStepLong, + double dfStepLat, + double& dfRasterXSize, + double& dfRasterYSize ); + + static bool ParseHeaderMNT(GDALOpenInfo* poOpenInfo, double& dfLongMin, double& dfLongMax, double& dfLatMin, @@ -61,12 +70,24 @@ class IGNFHeightASCIIGridDataset: public GDALPamDataset int& nPrecisionCode, CPLString& osDesc); + static bool ParseHeaderGRA(GDALOpenInfo* poOpenInfo, + double& dfLongMin, + double& dfLongMax, + double& dfLatMin, + double& dfLatMax, + double& dfStepLong, + double& dfStepLat, + double& dfRasterXSize, + double& dfRasterYSize); + public: IGNFHeightASCIIGridDataset() = default; CPLErr GetGeoTransform(double* padfGeoTransform) override; const char* GetProjectionRef() override { return SRS_WKT_WGS84; } + static int IdentifyMNT(GDALOpenInfo* poOpenInfo); + static int IdentifyGRA(GDALOpenInfo* poOpenInfo); static int Identify(GDALOpenInfo* poOpenInfo); static GDALDataset* Open(GDALOpenInfo* poOpenInfo); }; @@ -77,9 +98,13 @@ class IGNFHeightASCIIGridDataset: public GDALPamDataset /* ==================================================================== */ /************************************************************************/ -class IGNFHeightASCIIGridRasterBand: public GDALPamRasterBand +class IGNFHeightASCIIGridRasterBand final: public GDALPamRasterBand { + friend class IGNFHeightASCIIGridDataset; + std::vector adfBuffer; + double m_dfNoDataValue = 0.0; + bool m_bHasNoDataValue = false; public: explicit IGNFHeightASCIIGridRasterBand(GDALDataset* poDS, @@ -87,6 +112,7 @@ class IGNFHeightASCIIGridRasterBand: public GDALPamRasterBand CPLErr IReadBlock(int, int, void*) override; const char* GetUnitType() override { return "m"; } + double GetNoDataValue(int* pbHasNoDataValue) override; }; /************************************************************************/ @@ -117,6 +143,16 @@ CPLErr IGNFHeightASCIIGridRasterBand:: IReadBlock(int, int nBlockYOff, return CE_None; } +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double IGNFHeightASCIIGridRasterBand::GetNoDataValue(int* pbHasNoDataValue) +{ + if( pbHasNoDataValue ) + *pbHasNoDataValue = m_bHasNoDataValue; + return m_dfNoDataValue; +} /************************************************************************/ /* GetGeoTransform() */ @@ -129,10 +165,10 @@ CPLErr IGNFHeightASCIIGridDataset::GetGeoTransform(double* padfGeoTransform) } /************************************************************************/ -/* Identify() */ +/* IdentifyMNT() */ /************************************************************************/ -int IGNFHeightASCIIGridDataset::Identify(GDALOpenInfo* poOpenInfo) +int IGNFHeightASCIIGridDataset::IdentifyMNT(GDALOpenInfo* poOpenInfo) { const GByte* pabyHeader = poOpenInfo->pabyHeader; int iPosFirstNewLine = -1; @@ -201,17 +237,115 @@ int IGNFHeightASCIIGridDataset::Identify(GDALOpenInfo* poOpenInfo) int nCoordinatesAtNode = 0; int nPrecisionCode = 0; CPLString osDesc; - return ParseHeader(poOpenInfo, dfLongMin, dfLongMax, dfLatMin, dfLatMax, + return ParseHeaderMNT(poOpenInfo, dfLongMin, dfLongMax, dfLatMin, dfLatMax, dfStepLong, dfStepLat, dfRasterXSize, dfRasterYSize, nArrangementOrder, nCoordinatesAtNode, nPrecisionCode, osDesc); } /************************************************************************/ -/* ParseHeader() */ +/* IdentifyGRA() */ +/************************************************************************/ + +int IGNFHeightASCIIGridDataset::IdentifyGRA(GDALOpenInfo* poOpenInfo) +{ + if( !EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "GRA") ) + return FALSE; + + const GByte* pabyHeader = poOpenInfo->pabyHeader; + int nCountFields = 0; + int nLine = 1; + for(int i = 0; i < poOpenInfo->nHeaderBytes; i++ ) + { + const GByte ch = pabyHeader[i]; + if( ch == ' ' || ch == '\r' ) + { + continue; + } + if( ch == '\n' ) + { + if( nCountFields != 2 ) + return FALSE; + if( nLine == 3 ) + { + double dfLongMin = 0.0; + double dfLongMax = 0.0; + double dfLatMin = 0.0; + double dfLatMax = 0.0; + double dfStepLong = 0.0; + double dfStepLat = 0.0; + double dfRasterXSize = 0.0; + double dfRasterYSize = 0.0; + return ParseHeaderGRA(poOpenInfo, + dfLongMin, dfLongMax, dfLatMin, dfLatMax, + dfStepLong, dfStepLat, dfRasterXSize, dfRasterYSize); + } + nCountFields = 0; + nLine ++; + continue; + } + if( i == 0 || pabyHeader[i-1] == ' ' || pabyHeader[i-1] == '\n' ) + { + nCountFields ++; + } + if( !((ch >= '0' && ch <= '9') || ch == '-' || ch == '.') ) + { + return FALSE; + } + } + + return FALSE; +} + +/************************************************************************/ +/* Identify() */ +/************************************************************************/ + +int IGNFHeightASCIIGridDataset::Identify(GDALOpenInfo* poOpenInfo) +{ + return (IdentifyMNT(poOpenInfo) == TRUE) || + (IdentifyGRA(poOpenInfo) == TRUE); +} + +/************************************************************************/ +/* CheckExtentAndComputeRasterSize() */ +/************************************************************************/ + +bool IGNFHeightASCIIGridDataset::CheckExtentAndComputeRasterSize( + double dfLongMin, + double dfLongMax, + double dfLatMin, + double dfLatMax, + double dfStepLong, + double dfStepLat, + double& dfRasterXSize, + double& dfRasterYSize) +{ + if( !(dfLongMin >= -180.0 && dfLongMax <= 180.0 && dfLongMin < dfLongMax && + dfLatMin >= -90.0 && dfLatMax <= 90.0 && dfLatMin < dfLatMax) ) + { + return false; + } + if( !(dfStepLong > 0 && dfStepLong < 360 && + dfStepLat > 0 && dfStepLat < 180) ) + { + return false; + } + dfRasterXSize = (dfLongMax - dfLongMin) / dfStepLong; + dfRasterYSize = (dfLatMax - dfLatMin) / dfStepLat; + if( dfRasterXSize > 10000 || dfRasterYSize > 10000 || + dfRasterXSize * dfRasterYSize > 10e6 ) + { + return false; + } + return true; +} + +/************************************************************************/ +/* ParseHeaderMNT() */ /************************************************************************/ -bool IGNFHeightASCIIGridDataset::ParseHeader(GDALOpenInfo* poOpenInfo, +bool IGNFHeightASCIIGridDataset::ParseHeaderMNT(GDALOpenInfo* poOpenInfo, double& dfLongMin, double& dfLongMax, double& dfLatMin, @@ -237,25 +371,15 @@ bool IGNFHeightASCIIGridDataset::ParseHeader(GDALOpenInfo* poOpenInfo, dfLongMax = CPLAtof(aosTokens[1]); dfLatMin = CPLAtof(aosTokens[2]); dfLatMax = CPLAtof(aosTokens[3]); - if( !(dfLongMin >= -180.0 && dfLongMax <= 180.0 && dfLongMin < dfLongMax && - dfLatMin >= -90.0 && dfLatMax <= 90.0 && dfLatMin < dfLatMax) ) - { - return false; - } dfStepLong = CPLAtof(aosTokens[4]); dfStepLat = CPLAtof(aosTokens[5]); - if( !(dfStepLong > 0 && dfStepLong < 360 && - dfStepLat > 0 && dfStepLat < 180) ) - { - return false; - } - dfRasterXSize = (dfLongMax - dfLongMin) / dfStepLong; - dfRasterYSize = (dfLatMax - dfLatMin) / dfStepLat; - if( dfRasterXSize > 10000 || dfRasterYSize > 10000 || - dfRasterXSize * dfRasterYSize > 10e6 ) + if( !CheckExtentAndComputeRasterSize( + dfLongMin, dfLongMax, dfLatMin, dfLatMax, + dfStepLong, dfStepLat, dfRasterXSize, dfRasterYSize) ) { return false; } + nArrangementOrder = atoi(aosTokens[6]); #ifdef DEBUG_VERBOSE CPLDebug("IGNFHeightASCIIGrid", "nArrangementOrder = %d", nArrangementOrder); @@ -308,6 +432,36 @@ bool IGNFHeightASCIIGridDataset::ParseHeader(GDALOpenInfo* poOpenInfo, return true; } +/************************************************************************/ +/* ParseHeaderGRA() */ +/************************************************************************/ + +bool IGNFHeightASCIIGridDataset::ParseHeaderGRA(GDALOpenInfo* poOpenInfo, + double& dfLongMin, + double& dfLongMax, + double& dfLatMin, + double& dfLatMax, + double& dfStepLong, + double& dfStepLat, + double& dfRasterXSize, + double& dfRasterYSize) +{ + std::string osHeader; + osHeader.assign(reinterpret_cast(poOpenInfo->pabyHeader), + poOpenInfo->nHeaderBytes); + CPLStringList aosTokens(CSLTokenizeString2(osHeader.c_str(), " \r\n", 0)); + CPLAssert( aosTokens.size() >= 6 ); // from Identify + dfLatMin = CPLAtof(aosTokens[0]); + dfLatMax = CPLAtof(aosTokens[1]); + dfLongMin = CPLAtof(aosTokens[2]); + dfLongMax = CPLAtof(aosTokens[3]); + dfStepLat = CPLAtof(aosTokens[4]); + dfStepLong = CPLAtof(aosTokens[5]); + return CheckExtentAndComputeRasterSize( + dfLongMin, dfLongMax, dfLatMin, dfLatMax, + dfStepLong, dfStepLat, dfRasterXSize, dfRasterYSize); +} + /************************************************************************/ /* getSampleIndex() */ /************************************************************************/ @@ -341,7 +495,7 @@ size_t IGNFHeightASCIIGridDataset::getSampleIndex( size_t nBufferCount ) GDALDataset* IGNFHeightASCIIGridDataset::Open(GDALOpenInfo* poOpenInfo) { - if( !Identify(poOpenInfo) || poOpenInfo->fpL == nullptr || + if( poOpenInfo->fpL == nullptr || poOpenInfo->eAccess == GA_Update ) { return nullptr; @@ -359,10 +513,26 @@ GDALDataset* IGNFHeightASCIIGridDataset::Open(GDALOpenInfo* poOpenInfo) int nCoordinatesAtNode = 0; int nPrecisionCode = 0; CPLString osDesc; - ParseHeader(poOpenInfo, dfLongMin, dfLongMax, dfLatMin, dfLatMax, + + bool isMNTFormat = false; + if( IdentifyMNT(poOpenInfo) ) + { + isMNTFormat = true; + ParseHeaderMNT(poOpenInfo, dfLongMin, dfLongMax, dfLatMin, dfLatMax, dfStepLong, dfStepLat, dfRasterXSize, dfRasterYSize, nArrangementOrder, nCoordinatesAtNode, nPrecisionCode, osDesc); + } + else if( IdentifyGRA(poOpenInfo) ) + { + ParseHeaderGRA(poOpenInfo, dfLongMin, dfLongMax, dfLatMin, dfLatMax, + dfStepLong, dfStepLat, dfRasterXSize, dfRasterYSize); + nArrangementOrder = 2; + } + else + { + return nullptr; + } // Check file size VSIFSeekL( poOpenInfo->fpL, 0, SEEK_END ); @@ -389,13 +559,28 @@ GDALDataset* IGNFHeightASCIIGridDataset::Open(GDALOpenInfo* poOpenInfo) poDS->adfGeoTransform[5] = -dfStepLat; poDS->nRasterXSize = static_cast( dfRasterXSize + 0.5 + 1 ); poDS->nRasterYSize = static_cast( dfRasterYSize + 0.5 + 1 ); - poDS->GDALDataset::SetMetadataItem("DESCRIPTION", osDesc); + if( !osDesc.empty() ) + { + poDS->GDALDataset::SetMetadataItem("DESCRIPTION", osDesc); + } // Parse values std::vector adfBuffer; adfBuffer.resize( poDS->nRasterXSize * poDS->nRasterYSize ); size_t nBufferCount = 0; - const size_t nHeaderSize = osBuffer.find('\r'); + size_t nHeaderSize; + if( isMNTFormat ) + { + nHeaderSize = osBuffer.find('\r'); + } + else + { + nHeaderSize = osBuffer.find('\n'); + CPLAssert(nHeaderSize != std::string::npos); + nHeaderSize = osBuffer.find('\n', nHeaderSize + 1); + CPLAssert(nHeaderSize != std::string::npos); + nHeaderSize = osBuffer.find('\n', nHeaderSize + 1); + } CPLAssert(nHeaderSize != std::string::npos); size_t nLastPos = nHeaderSize + 1; int iValuePerNode = 0; @@ -476,8 +661,14 @@ GDALDataset* IGNFHeightASCIIGridDataset::Open(GDALOpenInfo* poOpenInfo) return nullptr; } - poDS->SetBand(1, new IGNFHeightASCIIGridRasterBand(poDS, - std::move(adfBuffer))); + auto poBand = new IGNFHeightASCIIGridRasterBand(poDS, + std::move(adfBuffer)); + if( !isMNTFormat ) + { + poBand->m_bHasNoDataValue = true; + poBand->m_dfNoDataValue = 9999; + } + poDS->SetBand(1, poBand); /* -------------------------------------------------------------------- */ /* Initialize any PAM information. */ @@ -511,7 +702,7 @@ void GDALRegister_IGNFHeightASCIIGrid() "IGN France height correction ASCII Grid"); poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "frmt_various.html#IGNFHeightASCIIGrid"); - poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "mnt"); + poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "mnt txt gra"); poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); diff --git a/gdal/frmts/xyz/xyzdataset.cpp b/gdal/frmts/xyz/xyzdataset.cpp index 247565ee05fd..03304f6ecfda 100644 --- a/gdal/frmts/xyz/xyzdataset.cpp +++ b/gdal/frmts/xyz/xyzdataset.cpp @@ -526,6 +526,11 @@ int XYZDataset::IdentifyEx( GDALOpenInfo * poOpenInfo, nCommentLineCount = 0; CPLString osFilename(poOpenInfo->pszFilename); + if( EQUAL(CPLGetExtension(osFilename), "GRA") ) + { + // IGNFHeightASCIIGRID .GRA + return FALSE; + } GDALOpenInfo* poOpenInfoToDelete = nullptr; /* GZipped .xyz files are common, so automagically open them */ From 6bc220ef217363b682d933ac36002bc9b6fe79a0 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 19 Nov 2018 23:28:06 +0100 Subject: [PATCH 068/488] XLSX / ODS: avoid harmless warning in some cases when guessing column data types --- gdal/ogr/ogrsf_frmts/ods/ogrodsdatasource.cpp | 1 + gdal/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/gdal/ogr/ogrsf_frmts/ods/ogrodsdatasource.cpp b/gdal/ogr/ogrsf_frmts/ods/ogrodsdatasource.cpp index 9b9f027e00fe..5af35698d1a5 100644 --- a/gdal/ogr/ogrsf_frmts/ods/ogrodsdatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/ods/ogrodsdatasource.cpp @@ -1072,6 +1072,7 @@ void OGRODSDataSource::endElementRow( CPL_UNUSED /*in non-DEBUG*/ const char * p OGRFieldDefn oNewFieldDefn( poCurLayer->GetLayerDefn()->GetFieldDefn( static_cast(i))); + oNewFieldDefn.SetSubType(OFSTNone); if( ( eFieldType == OFTDate || eFieldType == OFTTime) && eValType == OFTDateTime ) diff --git a/gdal/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp b/gdal/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp index 5e2cb41b55fb..f99fb9f44d17 100644 --- a/gdal/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp @@ -1001,6 +1001,7 @@ void OGRXLSXDataSource::endElementRow(CPL_UNUSED const char *pszNameIn) else if (eFieldType != OFTString && eValType != eFieldType) { OGRFieldDefn oNewFieldDefn(poFieldDefn); + oNewFieldDefn.SetSubType(OFSTNone); if ((eFieldType == OFTDate || eFieldType == OFTTime) && eValType == OFTDateTime) oNewFieldDefn.SetType(OFTDateTime); From b6ed2f66324771094846624cb05b3307660a5229 Mon Sep 17 00:00:00 2001 From: Norman Barker Date: Mon, 19 Nov 2018 14:29:11 -0600 Subject: [PATCH 069/488] enable lossless compression for webp in tiff --- autotest/gcore/tiff_write.py | 24 +++++++++--------------- gdal/frmts/gtiff/libtiff/tif_webp.c | 25 ++++++++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/autotest/gcore/tiff_write.py b/autotest/gcore/tiff_write.py index bde604acb73c..a61191658485 100755 --- a/autotest/gcore/tiff_write.py +++ b/autotest/gcore/tiff_write.py @@ -8044,8 +8044,7 @@ def tiff_write_webp(): return 'skip' ut = gdaltest.GDALTest('GTiff', 'md_ge_rgb_0010000.tif', 0, None, - options=['COMPRESS=WEBP', - 'WEBP_LOSSLESS=true']) + options=['COMPRESS=WEBP']) return ut.testCreateCopy() ############################################################################### @@ -8058,6 +8057,9 @@ def tiff_write_tiled_webp(): if md['DMD_CREATIONOPTIONLIST'].find('WEBP') == -1: return 'skip' + if md['DMD_CREATIONOPTIONLIST'].find('WEBP_LOSSLESS') == -1: + return 'skip' + filename = '/vsimem/tiff_write_tiled_webp.tif' src_ds = gdal.Open('data/md_ge_rgb_0010000.tif') gdaltest.tiff_drv.CreateCopy(filename, src_ds, @@ -8065,19 +8067,11 @@ def tiff_write_tiled_webp(): 'WEBP_LOSSLESS=true', 'TILED=true']) ds = gdal.Open(filename) - original_stats = [src_ds.GetRasterBand(i + 1).ComputeStatistics(True) for i in range(3)] - got_stats = [ds.GetRasterBand(i + 1).ComputeStatistics(True) for i in range(3)] - ds = None - src_ds = None - - for i in range(3): - for j in range(4): - if abs(original_stats[i][j] - got_stats[i][j]) > 1e-1 * abs(original_stats[i][j]): - gdaltest.post_reason('did not get expected statistics') - print(i, j) - print(original_stats) - print(got_stats) - return 'fail' + cs = [ds.GetRasterBand(i+1).Checksum() for i in range(3)] + if cs != [21212, 21053, 21349]: + gdaltest.post_reason('fail') + print(cs) + return 'fail' gdaltest.tiff_drv.Delete(filename) gdal.Unlink('data/md_ge_rgb_0010000.tif.aux.xml') diff --git a/gdal/frmts/gtiff/libtiff/tif_webp.c b/gdal/frmts/gtiff/libtiff/tif_webp.c index a002f481daa6..ee0a0649e673 100644 --- a/gdal/frmts/gtiff/libtiff/tif_webp.c +++ b/gdal/frmts/gtiff/libtiff/tif_webp.c @@ -349,6 +349,12 @@ TWebPSetupEncode(TIFF* tif) sp->state |= LSTATE_INIT_ENCODE; + if (!WebPPictureInit(&sp->sPicture)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing WebP picture."); + return 0; + } + if (!WebPConfigInitInternal(&sp->sEncoderConfig, WEBP_PRESET_DEFAULT, sp->quality_level, WEBP_ENCODER_ABI_VERSION)) { @@ -357,9 +363,13 @@ TWebPSetupEncode(TIFF* tif) return 0; } -#if WEBP_ENCODER_ABI_VERSION >= 0x0100 - sp->sEncoderConfig.lossless = sp->lossless; -#endif + // WebPConfigInitInternal above sets lossless to false + #if WEBP_ENCODER_ABI_VERSION >= 0x0100 + sp->sEncoderConfig.lossless = sp->lossless; + if (sp->lossless) { + sp->sPicture.use_argb = 1; + } + #endif if (!WebPValidateConfig(&sp->sEncoderConfig)) { TIFFErrorExt(tif->tif_clientdata, module, @@ -367,12 +377,6 @@ TWebPSetupEncode(TIFF* tif) return 0; } - if (!WebPPictureInit(&sp->sPicture)) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error initializing WebP picture."); - return 0; - } - return 1; } @@ -570,6 +574,9 @@ TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) case TIFFTAG_WEBP_LOSSLESS: #if WEBP_ENCODER_ABI_VERSION >= 0x0100 sp->lossless = va_arg(ap, int); + if (sp->lossless){ + sp->quality_level = 100.0f; + } return 1; #else TIFFErrorExt(tif->tif_clientdata, module, From 76bc4fed0662a4be6d6e7e17b6dfd6f8329ce47c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 21 Nov 2018 19:28:32 +0100 Subject: [PATCH 070/488] Add JSON field subtype for String fields --- gdal/ogr/ogr_core.h | 6 +++++- gdal/ogr/ogrfielddefn.cpp | 5 +++++ gdal/swig/include/ogr.i | 8 +++++++- gdal/swig/python/extensions/ogr_wrap.cpp | 13 +++++++++++++ gdal/swig/python/osgeo/ogr.py | 3 +++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gdal/ogr/ogr_core.h b/gdal/ogr/ogr_core.h index 6114dff2a737..adcbb14c25d7 100644 --- a/gdal/ogr/ogr_core.h +++ b/gdal/ogr/ogr_core.h @@ -628,7 +628,11 @@ typedef enum OFSTInt16 = 2, /** Single precision (32 bit) floating point. Only valid for OFTReal and OFTRealList. */ OFSTFloat32 = 3, - OFSTMaxSubType = 3 + /** JSON content. Only valid for OFTString. + * @since GDAL 2.4 + */ + OFSTJSON = 4, + OFSTMaxSubType = 4 } OGRFieldSubType; /** diff --git a/gdal/ogr/ogrfielddefn.cpp b/gdal/ogr/ogrfielddefn.cpp index 34110ee23fdb..7b0b41de0eb2 100644 --- a/gdal/ogr/ogrfielddefn.cpp +++ b/gdal/ogr/ogrfielddefn.cpp @@ -720,6 +720,9 @@ const char * OGRFieldDefn::GetFieldSubTypeName( OGRFieldSubType eSubType ) case OFSTFloat32: return "Float32"; + case OFSTJSON: + return "JSON"; + default: return "(unknown)"; } @@ -767,6 +770,8 @@ int OGR_AreTypeSubTypeCompatible( OGRFieldType eType, OGRFieldSubType eSubType ) return eType == OFTInteger || eType == OFTIntegerList; if( eSubType == OFSTFloat32 ) return eType == OFTReal || eType == OFTRealList; + if( eSubType == OFSTJSON ) + return eType == OFTString; return FALSE; } diff --git a/gdal/swig/include/ogr.i b/gdal/swig/include/ogr.i index 58ea5f951581..54a69f08f466 100644 --- a/gdal/swig/include/ogr.i +++ b/gdal/swig/include/ogr.i @@ -195,7 +195,11 @@ typedef enum /** Signed 16-bit integer. Only valid for OFTInteger and OFTIntegerList. */ OFSTInt16 = 2, /** Single precision (32 bit) floating point. Only valid for OFTReal and OFTRealList. */ - OFSTFloat32 = 3 + OFSTFloat32 = 3, + /** JSON content. Only valid for OFTString. + * @since GDAL 2.4 + */ + OFSTJSON = 4, } OGRFieldSubType; @@ -370,6 +374,7 @@ typedef void retGetPoints; %constant OFSTBoolean = 1; %constant OFSTInt16 = 2; %constant OFSTFloat32 = 3; +%constant OFSTJSON = 4; %constant OJUndefined = 0; %constant OJLeft = 1; @@ -2154,6 +2159,7 @@ public: case OFSTBoolean: case OFSTInt16: case OFSTFloat32: + case OFSTJSON: return TRUE; default: CPLError(CE_Failure, CPLE_IllegalArg, "Illegal field subtype value"); diff --git a/gdal/swig/python/extensions/ogr_wrap.cpp b/gdal/swig/python/extensions/ogr_wrap.cpp index 28fede3de55e..ae4bf8ece43f 100644 --- a/gdal/swig/python/extensions/ogr_wrap.cpp +++ b/gdal/swig/python/extensions/ogr_wrap.cpp @@ -4760,6 +4760,7 @@ SWIGINTERN int OGRFeatureDefnShadow_IsSame(OGRFeatureDefnShadow *self,OGRFeature case OFSTBoolean: case OFSTInt16: case OFSTFloat32: + case OFSTJSON: return TRUE; default: CPLError(CE_Failure, CPLE_IllegalArg, "Illegal field subtype value"); @@ -6458,6 +6459,17 @@ SWIGINTERN PyObject *OFSTFloat32_swigconstant(PyObject *SWIGUNUSEDPARM(self), Py } +SWIGINTERN PyObject *OFSTJSON_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *module; + PyObject *d; + if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL; + d = PyModule_GetDict(module); + if (!d) return NULL; + SWIG_Python_SetConstant(d, "OFSTJSON",SWIG_From_int(static_cast< int >(4))); + return SWIG_Py_Void(); +} + + SWIGINTERN PyObject *OJUndefined_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *module; PyObject *d; @@ -30732,6 +30744,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"OFSTBoolean_swigconstant", OFSTBoolean_swigconstant, METH_VARARGS, NULL}, { (char *)"OFSTInt16_swigconstant", OFSTInt16_swigconstant, METH_VARARGS, NULL}, { (char *)"OFSTFloat32_swigconstant", OFSTFloat32_swigconstant, METH_VARARGS, NULL}, + { (char *)"OFSTJSON_swigconstant", OFSTJSON_swigconstant, METH_VARARGS, NULL}, { (char *)"OJUndefined_swigconstant", OJUndefined_swigconstant, METH_VARARGS, NULL}, { (char *)"OJLeft_swigconstant", OJLeft_swigconstant, METH_VARARGS, NULL}, { (char *)"OJRight_swigconstant", OJRight_swigconstant, METH_VARARGS, NULL}, diff --git a/gdal/swig/python/osgeo/ogr.py b/gdal/swig/python/osgeo/ogr.py index 810fc827027d..22ffd90a34eb 100644 --- a/gdal/swig/python/osgeo/ogr.py +++ b/gdal/swig/python/osgeo/ogr.py @@ -364,6 +364,9 @@ class _object: _ogr.OFSTFloat32_swigconstant(_ogr) OFSTFloat32 = _ogr.OFSTFloat32 +_ogr.OFSTJSON_swigconstant(_ogr) +OFSTJSON = _ogr.OFSTJSON + _ogr.OJUndefined_swigconstant(_ogr) OJUndefined = _ogr.OJUndefined From 14787d4dc99b60b85c305b08e4424a51abb27f9a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 21 Nov 2018 19:44:02 +0100 Subject: [PATCH 071/488] GPKG: add read/write support for JSON field subtype --- autotest/ogr/ogr_gpkg.py | 92 +++++++ gdal/ogr/ogrsf_frmts/gpkg/ogr_geopackage.h | 8 +- .../gpkg/ogrgeopackagedatasource.cpp | 45 +-- .../gpkg/ogrgeopackagetablelayer.cpp | 260 +++++++++++------- gdal/swig/python/samples/validate_gpkg.py | 64 ++++- 5 files changed, 356 insertions(+), 113 deletions(-) diff --git a/autotest/ogr/ogr_gpkg.py b/autotest/ogr/ogr_gpkg.py index ed2834be6ea8..f1a81379ddb5 100755 --- a/autotest/ogr/ogr_gpkg.py +++ b/autotest/ogr/ogr_gpkg.py @@ -4759,6 +4759,97 @@ def ogr_gpkg_wal(): return 'success' +############################################################################### +# Test JSon subtype support + + +def ogr_gpkg_json(): + + if gdaltest.gpkg_dr is None: + return 'skip' + + filename = '/vsimem/ogr_gpkg_json.gpkg' + ds = gdaltest.gpkg_dr.CreateDataSource(filename) + lyr = ds.CreateLayer('test') + + fld_defn = ogr.FieldDefn('test_json', ogr.OFTString) + fld_defn.SetSubType(ogr.OFSTJSON) + lyr.CreateField(fld_defn) + if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + + ds.ReleaseResultSet(ds.ExecuteSQL('SELECT 1 FROM test')) # will crystalize + + fld_defn = ogr.FieldDefn('test2_json', ogr.OFTString) + fld_defn.SetSubType(ogr.OFSTJSON) + lyr.CreateField(fld_defn) + if lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + + fld_defn = ogr.FieldDefn('test_string', ogr.OFTString) + lyr.CreateField(fld_defn) + + ds = None + + ds = ogr.Open(filename, update = 1) + lyr = ds.GetLayer(0) + if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + if lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + + # Demote field from JSON + new_defn = ogr.FieldDefn('test_was_json_now_string', ogr.OFTString) + if lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test2_json'), new_defn, ogr.ALTER_ALL_FLAG) != 0: + gdaltest.post_reason('fail') + return 'fail' + + # Alter field to JSON + new_defn = ogr.FieldDefn('test_was_string_now_json', ogr.OFTString) + new_defn.SetSubType(ogr.OFSTJSON) + if lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test_string'), new_defn, ogr.ALTER_ALL_FLAG) != 0: + gdaltest.post_reason('fail') + return 'fail' + + # Delete JSON field + if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('test_json')) != 0: + gdaltest.post_reason('fail') + return 'fail' + + ds = None + + if not validate(filename): + gdaltest.post_reason('validation failed') + return 'fail' + + ds = ogr.Open(filename) + lyr = ds.GetLayer(0) + if lyr.GetLayerDefn().GetFieldDefn( + lyr.GetLayerDefn().GetFieldIndex('test_was_json_now_string')).GetSubType() != ogr.OFSTNone: + gdaltest.post_reason('fail') + return 'fail' + if lyr.GetLayerDefn().GetFieldDefn( + lyr.GetLayerDefn().GetFieldIndex('test_was_string_now_json')).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + + sql_lyr = ds.ExecuteSQL("SELECT 1 FROM gpkg_data_columns WHERE table_name = 'test'") + fc = sql_lyr.GetFeatureCount() + ds.ReleaseResultSet(sql_lyr) + if fc != 1: # only test_was_string_now_json remaining + gdaltest.post_reason('fail') + return 'fail' + + ds = None + + gdal.Unlink(filename) + + return 'success' + ############################################################################### # Remove the test db from the tmp directory @@ -4847,6 +4938,7 @@ def ogr_gpkg_cleanup(): ogr_gpkg_59, ogr_gpkg_savepoint, ogr_gpkg_wal, + ogr_gpkg_json, ogr_gpkg_test_ogrsf, ogr_gpkg_cleanup, ] diff --git a/gdal/ogr/ogrsf_frmts/gpkg/ogr_geopackage.h b/gdal/ogr/ogrsf_frmts/gpkg/ogr_geopackage.h index 9750be5056a8..c3ccbdf9ecbb 100644 --- a/gdal/ogr/ogrsf_frmts/gpkg/ogr_geopackage.h +++ b/gdal/ogr/ogrsf_frmts/gpkg/ogr_geopackage.h @@ -205,7 +205,7 @@ class GDALGeoPackageDataset final : public OGRSQLiteBaseDataSource, public GDALG bool m_bMapTableToExtensionsBuilt; std::map< CPLString, std::vector > m_oMapTableToExtensions; const std::map< CPLString, std::vector > & - GetExtensions(); + GetUnknownExtensionsTableSpecific(); bool m_bMapTableToContentsBuilt; std::map< CPLString, GPKGContentsDesc > m_oMapTableToContents; @@ -276,9 +276,11 @@ class GDALGeoPackageDataset final : public OGRSQLiteBaseDataSource, public GDALG OGRErr CreateExtensionsTableIfNecessary(); bool HasExtensionsTable(); OGRErr CreateGDALAspatialExtension(); - bool HasDataColumnsTable(); void SetMetadataDirty() { m_bMetadataDirty = true; } + bool HasDataColumnsTable(); + bool HasDataColumnConstraintsTable(); + const char* GetGeometryTypeString(OGRwkbGeometryType eType); void ResetReadingAllLayers(); @@ -450,6 +452,8 @@ class OGRGeoPackageTableLayer final : public OGRGeoPackageLayer OGRErr ReadTableDefinition(); void InitView(); + bool DoSpecialProcessingForColumnCreation(OGRFieldDefn* poField); + public: OGRGeoPackageTableLayer( GDALGeoPackageDataset *poDS, const char * pszTableName ); diff --git a/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp b/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp index 3befa85aeab2..362467c1d9e0 100644 --- a/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp @@ -669,11 +669,11 @@ void GDALGeoPackageDataset::RemoveTableFromSQLiteMasterCache( } /************************************************************************/ -/* GetExtensions() */ +/* GetUnknownExtensionsTableSpecific() */ /************************************************************************/ const std::map< CPLString, std::vector > & - GDALGeoPackageDataset::GetExtensions() + GDALGeoPackageDataset::GetUnknownExtensionsTableSpecific() { if( m_bMapTableToExtensionsBuilt ) return m_oMapTableToExtensions; @@ -693,7 +693,7 @@ const std::map< CPLString, std::vector > & "'gpkg_geom_MULTISURFACE', 'gpkg_geom_CURVE', 'gpkg_geom_SURFACE', " "'gpkg_geom_POLYHEDRALSURFACE', 'gpkg_geom_TIN', 'gpkg_geom_TRIANGLE', " "'gpkg_rtree_index', 'gpkg_geometry_type_trigger', 'gpkg_srs_id_trigger', " - "'gpkg_crs_wkt')"); + "'gpkg_crs_wkt', 'gpkg_schema')"); const int nTableLimit = atoi(CPLGetConfigOption("OGR_TABLE_LIMIT", "10000")); if( nTableLimit > 0 ) @@ -2745,6 +2745,30 @@ bool GDALGeoPackageDataset::HasMetadataTables() return nCount == 2; } +/************************************************************************/ +/* HasDataColumnsTable() */ +/************************************************************************/ + +bool GDALGeoPackageDataset::HasDataColumnsTable() +{ + const int nCount = SQLGetInteger(hDB, + "SELECT 1 FROM sqlite_master WHERE name = 'gpkg_data_columns'" + "AND type IN ('table', 'view')", nullptr); + return nCount == 1; +} + +/************************************************************************/ +/* HasDataColumnConstraintsTable() */ +/************************************************************************/ + +bool GDALGeoPackageDataset::HasDataColumnConstraintsTable() +{ + const int nCount = SQLGetInteger(hDB, + "SELECT 1 FROM sqlite_master WHERE name = 'gpkg_data_column_constraints'" + "AND type IN ('table', 'view')", nullptr); + return nCount == 1; +} + /************************************************************************/ /* GetMetadata() */ /************************************************************************/ @@ -5776,21 +5800,6 @@ OGRErr GDALGeoPackageDataset::CreateExtensionsTableIfNecessary() return SQLCommand(hDB, pszCreateGpkgExtensions); } -/************************************************************************/ -/* HasDataColumnsTable() */ -/************************************************************************/ - -bool GDALGeoPackageDataset::HasDataColumnsTable() -{ - SQLResult oResultTable; - OGRErr err = SQLQuery(hDB, - "SELECT * FROM sqlite_master WHERE name = 'gpkg_data_columns' " - "AND type IN ('table', 'view')", &oResultTable); - bool bHasExtensionsTable = ( err == OGRERR_NONE && oResultTable.nRowCount == 1 ); - SQLResultFree(&oResultTable); - return bHasExtensionsTable; -} - /************************************************************************/ /* OGRGeoPackageGetHeader() */ /************************************************************************/ diff --git a/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp b/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp index 62df354e5853..21491fd35f68 100644 --- a/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp @@ -661,96 +661,6 @@ OGRErr OGRGeoPackageTableLayer::ReadTableDefinition() } #endif -#if 0 - { - SQLResult oResult; - char* pszSQL; -#ifdef ENABLE_GPKG_OGR_CONTENTS - if( m_poDS->m_bHasGPKGOGRContents ) - { - pszSQL = sqlite3_mprintf( - "SELECT name, type FROM sqlite_master WHERE name IN ('%q', " - "'trigger_insert_feature_count_%q', " - "'trigger_delete_feature_count_%q')", - m_pszTableName, - m_pszTableName, - m_pszTableName); - } - else -#endif - { - pszSQL = sqlite3_mprintf( - "SELECT name, type FROM sqlite_master WHERE name = '%q' AND " - "type IN ('view', 'table')", - m_pszTableName); - } - err = SQLQuery(poDb, pszSQL, &oResult); - sqlite3_free(pszSQL); - if ( err == OGRERR_NONE && oResult.nRowCount == 0 ) - { - SQLResultFree(&oResult); - pszSQL = sqlite3_mprintf( - "SELECT name, type FROM sqlite_master WHERE " - "lower(name) = lower('%q') AND type " - "IN ('view', 'table')", - m_pszTableName); - err = SQLQuery(poDb, pszSQL, &oResult); - sqlite3_free(pszSQL); - } - - m_bIsTable = false; - bool bIsView = false; - if ( err == OGRERR_NONE && oResult.nRowCount >= 1 ) - { -#ifdef ENABLE_GPKG_OGR_CONTENTS - int nTriggerCount = 0; -#endif - for( int i = 0; i < oResult.nRowCount; i++ ) - { - const char* pszName = SQLResultGetValue(&oResult, 0, i); - const char* pszType = SQLResultGetValue(&oResult, 1, i); - if( EQUAL(pszName, m_pszTableName) ) - { - if( EQUAL(pszType, "table") ) - m_bIsTable = true; - else if( EQUAL(pszType, "view") ) - bIsView = true; - } -#ifdef ENABLE_GPKG_OGR_CONTENTS - else if( STARTS_WITH(pszName, "trigger_") ) - { - nTriggerCount++; - } -#endif - } - -#ifdef ENABLE_GPKG_OGR_CONTENTS - if( m_poDS->m_bHasGPKGOGRContents ) - { - if( nTriggerCount == 2 ) - { - m_bOGRFeatureCountTriggersEnabled = true; - } - else if( m_bIsTable ) - { - CPLDebug("GPKG", "Insert/delete feature_count triggers " - "missing on %s", m_pszTableName); - } - } -#endif - } - - SQLResultFree(&oResult); - if( !m_bIsTable && !bIsView ) - { - CPLError( CE_Failure, CPLE_AppDefined, - "Table or view '%s' does not exist", - m_pszTableName ); - return OGRERR_FAILURE; - } - } -#endif - if( m_bIsInGpkgContents ) { /* Check that the table name is registered in gpkg_contents */ @@ -1107,6 +1017,38 @@ OGRErr OGRGeoPackageTableLayer::ReadTableDefinition() SQLResultFree(&oResultTable); + // Look for sub-types such as JSON + if( m_poDS->HasDataColumnsTable() ) + { + pszSQL = sqlite3_mprintf( + "SELECT column_name, mime_type FROM gpkg_data_columns " + "WHERE table_name = '%q'", + m_pszTableName); + err = SQLQuery(poDb, pszSQL, &oResultTable); + sqlite3_free(pszSQL); + if( err == OGRERR_NONE ) + { + for ( int iRecord = 0; iRecord < oResultTable.nRowCount; iRecord++ ) + { + const char *pszColumn = + SQLResultGetValue(&oResultTable, 0, iRecord); + const char *pszMimeType = + SQLResultGetValue(&oResultTable, 1, iRecord); + if( pszColumn && pszMimeType && + EQUAL(pszMimeType, "application/json") ) + { + int iIdx = m_poFeatureDefn->GetFieldIndex(pszColumn); + if( iIdx >= 0 && + m_poFeatureDefn->GetFieldDefn(iIdx)->GetType() == OFTString) + { + m_poFeatureDefn->GetFieldDefn(iIdx)->SetSubType(OFSTJSON); + } + } + } + SQLResultFree(&oResultTable); + } + } + /* Update the columns string */ BuildColumns(); @@ -1325,7 +1267,7 @@ bool OGRGeoPackageTableLayer::CheckUpdatableTable(const char* pszOperation) /************************************************************************/ OGRErr OGRGeoPackageTableLayer::CreateField( OGRFieldDefn *poField, - CPL_UNUSED int bApproxOK ) + int /* bApproxOK */ ) { if( !m_bFeatureDefnCompleted ) GetLayerDefn(); @@ -1401,6 +1343,11 @@ OGRErr OGRGeoPackageTableLayer::CreateField( OGRFieldDefn *poField, if ( err != OGRERR_NONE ) return err; + + if( !DoSpecialProcessingForColumnCreation(poField) ) + { + return OGRERR_FAILURE; + } } m_poFeatureDefn->AddFieldDefn( &oFieldDefn ); @@ -1419,6 +1366,102 @@ OGRErr OGRGeoPackageTableLayer::CreateField( OGRFieldDefn *poField, return OGRERR_NONE; } +/************************************************************************/ +/* DoSpecialProcessingForColumnCreation() */ +/************************************************************************/ + +bool OGRGeoPackageTableLayer::DoSpecialProcessingForColumnCreation( + OGRFieldDefn* poField) +{ + + if( poField->GetType() == OFTString && poField->GetSubType() == OFSTJSON ) + { + /* A lot of one time setup ! */ + + if( !m_poDS->HasDataColumnsTable() ) + { + if( OGRERR_NONE != SQLCommand(m_poDS->GetDB(), + "CREATE TABLE gpkg_data_columns (" + "table_name TEXT NOT NULL," + "column_name TEXT NOT NULL," + "name TEXT UNIQUE," + "title TEXT," + "description TEXT," + "mime_type TEXT," + "constraint_name TEXT," + "CONSTRAINT pk_gdc PRIMARY KEY (table_name, column_name)," + "CONSTRAINT fk_gdc_tn FOREIGN KEY (table_name) " + "REFERENCES gpkg_contents(table_name));") ) + { + return false; + } + } + if( !m_poDS->HasDataColumnConstraintsTable() ) + { + if( OGRERR_NONE != SQLCommand(m_poDS->GetDB(), + "CREATE TABLE gpkg_data_column_constraints (" + "constraint_name TEXT NOT NULL," + "constraint_type TEXT NOT NULL," + "value TEXT," + "min NUMERIC," + "min_is_inclusive BOOLEAN," + "max NUMERIC," + "max_is_inclusive BOOLEAN," + "description TEXT," + "CONSTRAINT gdcc_ntv UNIQUE (constraint_name, " + "constraint_type, value));") ) + { + return false; + } + } + if( m_poDS->CreateExtensionsTableIfNecessary() != OGRERR_NONE ) + { + return false; + } + if( SQLGetInteger(m_poDS->GetDB(), + "SELECT 1 FROM gpkg_extensions WHERE " + "table_name = 'gpkg_data_columns'", nullptr) != 1 ) + { + if( OGRERR_NONE != SQLCommand(m_poDS->GetDB(), + "INSERT INTO gpkg_extensions " + "(table_name,column_name,extension_name,definition,scope) " + "VALUES ('gpkg_data_columns', NULL, 'gpkg_schema', " + "'http://www.geopackage.org/spec121/#extension_schema', " + "'read-write')") ) + { + return false; + } + } + if( SQLGetInteger(m_poDS->GetDB(), + "SELECT 1 FROM gpkg_extensions WHERE " + "table_name = 'gpkg_data_column_constraints'", nullptr) != 1 ) + { + if( OGRERR_NONE != SQLCommand(m_poDS->GetDB(), + "INSERT INTO gpkg_extensions " + "(table_name,column_name,extension_name,definition,scope) " + "VALUES ('gpkg_data_column_constraints', NULL, 'gpkg_schema', " + "'http://www.geopackage.org/spec121/#extension_schema', " + "'read-write')") ) + { + return false; + } + } + + /* Now let's register our column. */ + char* pszSQL = sqlite3_mprintf( + "INSERT INTO gpkg_data_columns (table_name, column_name, name, " + "title, description, mime_type, constraint_name) VALUES (" + "'%q', '%q', NULL, NULL, NULL, 'application/json', NULL)", + m_pszTableName, poField->GetNameRef()); + bool ok = SQLCommand(m_poDS->GetDB(), pszSQL) == OGRERR_NONE; + sqlite3_free(pszSQL); + return ok; + + } + return true; +} + + /************************************************************************/ /* CreateGeomField() */ /************************************************************************/ @@ -3001,7 +3044,7 @@ CPLString OGRGeoPackageTableLayer::ReturnSQLCreateSpatialIndexTriggers( void OGRGeoPackageTableLayer::CheckUnknownExtensions() { const std::map< CPLString, std::vector >& oMap = - m_poDS->GetExtensions(); + m_poDS->GetUnknownExtensionsTableSpecific(); std::map< CPLString, std::vector >::const_iterator oIter = oMap.find( CPLString(m_pszTableName).toupper() ); if( oIter != oMap.end() ) @@ -3767,6 +3810,14 @@ OGRErr OGRGeoPackageTableLayer::RunDeferredCreationIfNecessary() if ( OGRERR_NONE != err ) return OGRERR_FAILURE; + for( auto& poField: apoFields ) + { + if( !DoSpecialProcessingForColumnCreation(poField) ) + { + return OGRERR_FAILURE; + } + } + /* Update gpkg_contents with the table info */ const OGRwkbGeometryType eGType = GetGeomType(); const bool bIsSpatial = (eGType != wkbNone); @@ -4575,8 +4626,28 @@ OGRErr OGRGeoPackageTableLayer::AlterFieldDefn( int iFieldToAlter, OGRFieldDefn* poFieldDefn = m_poFeatureDefn->GetFieldDefn(iFieldToAlter); + bool bRunDoSpecialProcessingForColumnCreation = false; if (nFlagsIn & ALTER_TYPE_FLAG) { + if( poFieldDefn->GetSubType() == OFSTJSON && + poNewFieldDefn->GetSubType() == OFSTNone ) + { + char* pszSQL = sqlite3_mprintf( + "DELETE FROM gpkg_data_columns WHERE " + "lower(table_name) = lower('%q') AND " + "lower(column_name) = lower('%q')", + m_pszTableName, + poNewFieldDefn->GetNameRef() ); + eErr = SQLCommand( m_poDS->GetDB(), pszSQL ); + sqlite3_free(pszSQL); + } + else if ( poFieldDefn->GetSubType() == OFSTNone && + poNewFieldDefn->GetType() == OFTString && + poNewFieldDefn->GetSubType() == OFSTJSON ) + { + bRunDoSpecialProcessingForColumnCreation = true; + } + poFieldDefn->SetSubType(OFSTNone); poFieldDefn->SetType(poNewFieldDefn->GetType()); poFieldDefn->SetSubType(poNewFieldDefn->GetSubType()); @@ -4595,6 +4666,11 @@ OGRErr OGRGeoPackageTableLayer::AlterFieldDefn( int iFieldToAlter, if (nFlagsIn & ALTER_DEFAULT_FLAG) poFieldDefn->SetDefault(poNewFieldDefn->GetDefault()); + if( bRunDoSpecialProcessingForColumnCreation ) + { + DoSpecialProcessingForColumnCreation(poFieldDefn); + } + ResetReading(); } } diff --git a/gdal/swig/python/samples/validate_gpkg.py b/gdal/swig/python/samples/validate_gpkg.py index 6c37de28508c..d1fb37d8baf3 100755 --- a/gdal/swig/python/samples/validate_gpkg.py +++ b/gdal/swig/python/samples/validate_gpkg.py @@ -1493,6 +1493,67 @@ def _check_metadata(self, c): "Row with md_file_id = md_parent_id = %s " % str(md_file_id)) + def _check_schema(self, c): + + # Partial: doesn't check gpkg_data_column_constraints + + self._log('Checking gpkg_schema (partial)') + + must_have_gpkg_schema = False + c.execute("SELECT 1 FROM sqlite_master WHERE name = 'gpkg_extensions'") + if c.fetchone() is not None: + c.execute("SELECT scope FROM gpkg_extensions WHERE " + "extension_name = 'gpkg_schema'") + row = c.fetchone() + if row is not None: + must_have_gpkg_schema = True + (scope, ) = row + self._assert(scope == 'read-write', 141, + "Wrong scope for gpkg_schema in " + "gpkg_extensions") + + c.execute("SELECT 1 FROM sqlite_master WHERE name = 'gpkg_data_columns'") + if c.fetchone() is None: + if must_have_gpkg_schema: + self._log("gpkg_data_columns table missing. Not forbidden by requirements, but odd") + else: + self._log('... No schema') + return + + c.execute("PRAGMA table_info(gpkg_data_columns)") + columns = c.fetchall() + expected_columns = [ + (0, 'table_name', 'TEXT', 1, None, 1), + (1, 'column_name', 'TEXT', 1, None, 2), + (2, 'name', 'TEXT', 0, None, 0), + (3, 'title', 'TEXT', 0, None, 0), + (4, 'description', 'TEXT', 0, None, 0), + (5, 'mime_type', 'TEXT', 0, None, 0), + (6, 'constraint_name', 'TEXT', 0, None, 0) + ] + self._check_structure(columns, expected_columns, 107, + 'gpkg_data_columns') + + c.execute("SELECT table_name, column_name FROM gpkg_data_columns") + rows = c.fetchall() + for (table_name, column_name) in rows: + c.execute("SELECT 1 FROM gpkg_contents WHERE table_name = ?", + (table_name,)) + self._assert(c.fetchone(), 104, + ("table_name = %s " % table_name + + "in gpkg_data_columns refer to non-existing " + + "table/view in gpkg_contents")) + + try: + c.execute("SELECT %s FROM %s" % (_esc_id(column_name), + _esc_id(table_name))) + except sqlite3.OperationalError: + self._assert(False, 105, + ("table_name = %s, " % table_name + + "column_name = %s " % column_name + + "in gpkg_data_columns refer to non-existing " + + "column")) + def check(self): self._assert(os.path.exists(self.filename), None, "%s does not exist" % self.filename) @@ -1564,7 +1625,8 @@ def check(self): self._check_metadata(c) - # TODO: check gpkg_schema + self._check_schema(c) + finally: c.close() conn.close() From e57c8627b2925254b5d0b35d42d987891eb3bcd0 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 21 Nov 2018 20:25:46 +0100 Subject: [PATCH 072/488] PG: add read/write support for JSON field subtype --- autotest/ogr/ogr_pg.py | 40 ++++++++++++- gdal/ogr/ogrsf_frmts/pg/ogr_pg.h | 2 + gdal/ogr/ogrsf_frmts/pg/ogrpglayer.cpp | 5 ++ .../ogr/ogrsf_frmts/pgdump/ogrpgdumplayer.cpp | 60 ++++++++++--------- 4 files changed, 79 insertions(+), 28 deletions(-) diff --git a/autotest/ogr/ogr_pg.py b/autotest/ogr/ogr_pg.py index e7f53c8472a5..96eb0ebddb4d 100755 --- a/autotest/ogr/ogr_pg.py +++ b/autotest/ogr/ogr_pg.py @@ -5545,6 +5545,42 @@ def ogr_pg_87(): return 'success' +############################################################################### +# Test JSON subtype + + +def ogr_pg_json(): + + if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + return 'skip' + + lyr = gdaltest.pg_ds.CreateLayer('ogr_pg_json') + fld_defn = ogr.FieldDefn('test_json', ogr.OFTString) + fld_defn.SetSubType(ogr.OFSTJSON) + lyr.CreateField(fld_defn) + f = ogr.Feature(lyr.GetLayerDefn()) + f['test_json'] = '{"a": "b"}' + lyr.CreateFeature(f) + + gdaltest.pg_ds = ogr.Open('PG:' + gdaltest.pg_connection_string, update=1) + lyr = gdaltest.pg_ds.GetLayer('ogr_pg_json') + if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + f = lyr.GetNextFeature() + if f.GetField(0) != '{"a": "b"}': + gdaltest.post_reason('fail') + f.DumpReadable() + return 'fail' + + sql_lyr = gdaltest.pg_ds.ExecuteSQL('SELECT * FROM ogr_pg_json') + if sql_lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: + gdaltest.post_reason('fail') + return 'fail' + gdaltest.pg_ds.ReleaseResultSet(sql_lyr) + + return 'success' + ############################################################################### # @@ -5614,6 +5650,7 @@ def ogr_pg_table_cleanup(): gdaltest.pg_ds.ExecuteSQL('DELLAYER:ogr_pg_85_2') gdaltest.pg_ds.ExecuteSQL('DELLAYER:ogr_pg_86') gdaltest.pg_ds.ExecuteSQL('DELLAYER:ogr_pg_87') + gdaltest.pg_ds.ExecuteSQL('DELLAYER:ogr_pg_json') # Drop second 'tpoly' from schema 'AutoTest-schema' (do NOT quote names here) gdaltest.pg_ds.ExecuteSQL('DELLAYER:AutoTest-schema.tpoly') @@ -5737,12 +5774,13 @@ def ogr_pg_cleanup(): ogr_pg_85, ogr_pg_86, ogr_pg_87, + ogr_pg_json, ogr_pg_cleanup ] disabled_gdaltest_list_internal = [ ogr_pg_table_cleanup, - ogr_pg_86, + ogr_pg_json, ogr_pg_cleanup] ############################################################################### diff --git a/gdal/ogr/ogrsf_frmts/pg/ogr_pg.h b/gdal/ogr/ogrsf_frmts/pg/ogr_pg.h index 62dc48df7bdd..c34c217b4c7b 100644 --- a/gdal/ogr/ogrsf_frmts/pg/ogr_pg.h +++ b/gdal/ogr/ogrsf_frmts/pg/ogr_pg.h @@ -56,6 +56,7 @@ #define XIDOID 28 #define CIDOID 29 #define OIDVECTOROID 30 +#define JSONOID 114 #define FLOAT4OID 700 #define FLOAT8OID 701 #define BOOLARRAYOID 1000 @@ -75,6 +76,7 @@ #define TIMESTAMPTZOID 1184 #define NUMERICOID 1700 #define NUMERICARRAYOID 1231 +#define JSONBOID 3802 CPLString OGRPGEscapeString(void *hPGConn, const char* pszStrValue, int nMaxLength = -1, diff --git a/gdal/ogr/ogrsf_frmts/pg/ogrpglayer.cpp b/gdal/ogr/ogrsf_frmts/pg/ogrpglayer.cpp index 82b0d5f7ac34..ac6a46bfa840 100644 --- a/gdal/ogr/ogrsf_frmts/pg/ogrpglayer.cpp +++ b/gdal/ogr/ogrsf_frmts/pg/ogrpglayer.cpp @@ -2187,6 +2187,11 @@ int OGRPGLayer::ReadResultDefinition(PGresult *hInitialResultIn) oField.SetType( OFTDateTime ); } + else if ( nTypeOID == JSONOID || nTypeOID == JSONBOID ) + { + oField.SetType( OFTString ); + oField.SetSubType( OFSTJSON ); + } else /* unknown type */ { CPLDebug("PG", "Unhandled OID (%d) for column %s. Defaulting to String.", diff --git a/gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumplayer.cpp b/gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumplayer.cpp index d3450e7045b3..c8b14a921917 100644 --- a/gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumplayer.cpp +++ b/gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumplayer.cpp @@ -1179,7 +1179,7 @@ CPLString OGRPGCommonLayerGetType( OGRFieldDefn& oField, bool bPreservePrecision, bool bApproxOK ) { - char szFieldType[256]; + const char* pszFieldType = ""; /* -------------------------------------------------------------------- */ /* Work out the PostgreSQL type. */ @@ -1187,79 +1187,81 @@ CPLString OGRPGCommonLayerGetType( OGRFieldDefn& oField, if( oField.GetType() == OFTInteger ) { if( oField.GetSubType() == OFSTBoolean ) - strcpy( szFieldType, "BOOLEAN" ); + pszFieldType = "BOOLEAN"; else if( oField.GetSubType() == OFSTInt16 ) - strcpy( szFieldType, "SMALLINT" ); + pszFieldType = "SMALLINT"; else if( oField.GetWidth() > 0 && bPreservePrecision ) - snprintf( szFieldType, sizeof(szFieldType), "NUMERIC(%d,0)", oField.GetWidth() ); + pszFieldType = CPLSPrintf( "NUMERIC(%d,0)", oField.GetWidth() ); else - strcpy( szFieldType, "INTEGER" ); + pszFieldType = "INTEGER"; } else if( oField.GetType() == OFTInteger64 ) { if( oField.GetWidth() > 0 && bPreservePrecision ) - snprintf( szFieldType, sizeof(szFieldType), "NUMERIC(%d,0)", oField.GetWidth() ); + pszFieldType = CPLSPrintf( "NUMERIC(%d,0)", oField.GetWidth() ); else - strcpy( szFieldType, "INT8" ); + pszFieldType = "INT8"; } else if( oField.GetType() == OFTReal ) { if( oField.GetSubType() == OFSTFloat32 ) - strcpy( szFieldType, "REAL" ); + pszFieldType = "REAL"; else if( oField.GetWidth() > 0 && oField.GetPrecision() > 0 && bPreservePrecision ) - snprintf( szFieldType, sizeof(szFieldType), "NUMERIC(%d,%d)", + pszFieldType = CPLSPrintf( "NUMERIC(%d,%d)", oField.GetWidth(), oField.GetPrecision() ); else - strcpy( szFieldType, "FLOAT8" ); + pszFieldType = "FLOAT8"; } else if( oField.GetType() == OFTString ) { - if (oField.GetWidth() > 0 && bPreservePrecision ) - snprintf( szFieldType, sizeof(szFieldType), "VARCHAR(%d)", oField.GetWidth() ); + if (oField.GetSubType() == OFSTJSON ) + pszFieldType = CPLGetConfigOption("OGR_PG_JSON_TYPE", "JSON"); + else if (oField.GetWidth() > 0 && bPreservePrecision ) + pszFieldType = CPLSPrintf( "VARCHAR(%d)", oField.GetWidth() ); else - strcpy( szFieldType, "VARCHAR"); + pszFieldType = CPLGetConfigOption("OGR_PG_STRING_TYPE", "VARCHAR"); } else if( oField.GetType() == OFTIntegerList ) { if( oField.GetSubType() == OFSTBoolean ) - strcpy( szFieldType, "BOOLEAN[]" ); + pszFieldType = "BOOLEAN[]"; else if( oField.GetSubType() == OFSTInt16 ) - strcpy( szFieldType, "INT2[]" ); + pszFieldType = "INT2[]"; else - strcpy( szFieldType, "INTEGER[]" ); + pszFieldType = "INTEGER[]"; } else if( oField.GetType() == OFTInteger64List ) { - strcpy( szFieldType, "INT8[]" ); + pszFieldType = "INT8[]"; } else if( oField.GetType() == OFTRealList ) { if( oField.GetSubType() == OFSTFloat32 ) - strcpy( szFieldType, "REAL[]" ); + pszFieldType = "REAL[]"; else - strcpy( szFieldType, "FLOAT8[]" ); + pszFieldType = "FLOAT8[]"; } else if( oField.GetType() == OFTStringList ) { - strcpy( szFieldType, "varchar[]" ); + pszFieldType = "varchar[]"; } else if( oField.GetType() == OFTDate ) { - strcpy( szFieldType, "date" ); + pszFieldType = "date"; } else if( oField.GetType() == OFTTime ) { - strcpy( szFieldType, "time" ); + pszFieldType = "time"; } else if( oField.GetType() == OFTDateTime ) { - strcpy( szFieldType, "timestamp with time zone" ); + pszFieldType = "timestamp with time zone"; } else if( oField.GetType() == OFTBinary ) { - strcpy( szFieldType, "bytea" ); + pszFieldType = "bytea"; } else if( bApproxOK ) { @@ -1267,7 +1269,7 @@ CPLString OGRPGCommonLayerGetType( OGRFieldDefn& oField, "Can't create field %s with type %s on PostgreSQL layers. Creating as VARCHAR.", oField.GetNameRef(), OGRFieldDefn::GetFieldTypeName(oField.GetType()) ); - strcpy( szFieldType, "VARCHAR" ); + pszFieldType = "VARCHAR"; } else { @@ -1275,10 +1277,9 @@ CPLString OGRPGCommonLayerGetType( OGRFieldDefn& oField, "Can't create field %s with type %s on PostgreSQL layers.", oField.GetNameRef(), OGRFieldDefn::GetFieldTypeName(oField.GetType()) ); - strcpy( szFieldType, ""); } - return szFieldType; + return pszFieldType; } /************************************************************************/ @@ -1443,6 +1444,11 @@ bool OGRPGCommonLayerSetType( OGRFieldDefn& oField, { oField.SetType( OFTBinary ); } + else if( EQUAL(pszType,"json") || EQUAL(pszType, "jsonb") ) + { + oField.SetType( OFTString ); + oField.SetSubType( OFSTJSON ); + } else { CPLDebug( "PGCommon", "Field %s is of unknown format type %s (type=%s).", From 9f0bbc321e11d7f88ee59af5ccdfb58204ec04f6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 22 Nov 2018 11:25:14 +0100 Subject: [PATCH 073/488] GDALPansharpenOperation: fix inverted arguments in error message (spotted by @sotex, fixes #1110) --- gdal/alg/gdalpansharpen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/alg/gdalpansharpen.cpp b/gdal/alg/gdalpansharpen.cpp index 4369114e92f7..98ace11c53e0 100644 --- a/gdal/alg/gdalpansharpen.cpp +++ b/gdal/alg/gdalpansharpen.cpp @@ -254,7 +254,7 @@ GDALPansharpenOperation::Initialize( const GDALPansharpenOptions* psOptionsIn ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid value panOutPansharpenedBands[%d] = %d", - psOptionsIn->panOutPansharpenedBands[i], i); + i, psOptionsIn->panOutPansharpenedBands[i]); return CE_Failure; } } From a965bda62acdb21b5ac3e5291f84cdadcbeb4b05 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 22 Nov 2018 12:39:10 +0100 Subject: [PATCH 074/488] GeoJSON: no longer write NaN/Infinity values by default (fixes #1109) But allow to write them if WRITE_NON_FINITE_VALUES layer creation option is set to YES. --- autotest/cpp/test_cpl.cpp | 69 +++ autotest/ogr/ogr_geojson.py | 77 +++ gdal/ogr/ogrsf_frmts/geojson/drv_geojson.html | 4 + .../geojson/libjson/json_tokener.c | 443 +++++++++++++----- .../geojson/libjson/json_tokener.h | 36 +- .../geojson/libjson/symbol_renames.h | 1 - .../ogrsf_frmts/geojson/ogrgeojsondriver.cpp | 1 + .../ogrsf_frmts/geojson/ogrgeojsonreader.cpp | 15 + .../geojson/ogrgeojsonwritelayer.cpp | 2 + .../ogrsf_frmts/geojson/ogrgeojsonwriter.cpp | 17 +- .../ogrsf_frmts/geojson/ogrgeojsonwriter.h | 1 + gdal/port/cpl_json_streaming_parser.cpp | 77 ++- .../detect_suspicious_char_digit_zero.sh | 2 +- 13 files changed, 598 insertions(+), 147 deletions(-) diff --git a/autotest/cpp/test_cpl.cpp b/autotest/cpp/test_cpl.cpp index c76dd1e7f7ab..a5d109e5ceae 100644 --- a/autotest/cpp/test_cpl.cpp +++ b/autotest/cpp/test_cpl.cpp @@ -1635,6 +1635,39 @@ namespace tut ensure( oParser.Parse( sText + i, 1, sText[i+1] == 0 ) ); ensure_equals( oParser.GetSerialized(), sExpected ); } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "infinity"; + ensure( oParser.Parse( sText, strlen(sText), true ) ); + ensure_equals( oParser.GetSerialized(), sText ); + + oParser.Reset(); + for( size_t i = 0; sText[i]; i++ ) + ensure( oParser.Parse( sText + i, 1, sText[i+1] == 0 ) ); + ensure_equals( oParser.GetSerialized(), sText ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "-infinity"; + ensure( oParser.Parse( sText, strlen(sText), true ) ); + ensure_equals( oParser.GetSerialized(), sText ); + + oParser.Reset(); + for( size_t i = 0; sText[i]; i++ ) + ensure( oParser.Parse( sText + i, 1, sText[i+1] == 0 ) ); + ensure_equals( oParser.GetSerialized(), sText ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "nan"; + ensure( oParser.Parse( sText, strlen(sText), true ) ); + ensure_equals( oParser.GetSerialized(), sText ); + + oParser.Reset(); + for( size_t i = 0; sText[i]; i++ ) + ensure( oParser.Parse( sText + i, 1, sText[i+1] == 0 ) ); + ensure_equals( oParser.GetSerialized(), sText ); + } // errors { @@ -1697,6 +1730,42 @@ namespace tut ensure( !oParser.Parse( sText, strlen(sText), true ) ); ensure( !oParser.GetException().empty() ); } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "na"; + ensure( !oParser.Parse( sText, strlen(sText), true ) ); + ensure( !oParser.GetException().empty() ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "nanx"; + ensure( !oParser.Parse( sText, strlen(sText), true ) ); + ensure( !oParser.GetException().empty() ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "infinit"; + ensure( !oParser.Parse( sText, strlen(sText), true ) ); + ensure( !oParser.GetException().empty() ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "infinityx"; + ensure( !oParser.Parse( sText, strlen(sText), true ) ); + ensure( !oParser.GetException().empty() ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "-infinit"; + ensure( !oParser.Parse( sText, strlen(sText), true ) ); + ensure( !oParser.GetException().empty() ); + } + { + CPLJSonStreamingParserDump oParser; + const char sText[] = "-infinityx"; + ensure( !oParser.Parse( sText, strlen(sText), true ) ); + ensure( !oParser.GetException().empty() ); + } { CPLJSonStreamingParserDump oParser; const char sText[] = "true false"; diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index 17937a380135..6ed3b96a0798 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -29,6 +29,7 @@ ############################################################################### import json +import math import os import sys @@ -4252,6 +4253,81 @@ def ogr_geojson_clip_geometries_rfc7946(): gdal.Unlink(tmpfilename) return 'success' +############################################################################### +# Test bugfix for https://github.com/OSGeo/gdal/issues/1109 + + +def ogr_geojson_non_finite(): + + json_content = """{ + "type": "FeatureCollection", + "features": [ + { "type": "Feature", "properties": { "inf_prop": infinity, "minus_inf_prop": -infinity, "nan_prop": nan }, "geometry": null } + ] +}""" + with gdaltest.error_handler(): + ds = ogr.Open(json_content) + if ds is None: + # Might fail with older libjson-c versions + return 'skip' + lyr = ds.GetLayer(0) + f = lyr.GetNextFeature() + for i in range(3): + if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTReal: + gdaltest.post_reason('fail') + print(i) + return 'fail' + + if f['inf_prop'] != float('inf'): + gdaltest.post_reason('fail') + f.DumpReadable() + return 'fail' + if f['minus_inf_prop'] != float('-inf'): + gdaltest.post_reason('fail') + f.DumpReadable() + return 'fail' + if not math.isnan(f['nan_prop']): + gdaltest.post_reason('fail') + print(str(f['nan_prop'])) + f.DumpReadable() + return 'fail' + ds = None + + tmpfilename = '/vsimem/out.json' + + with gdaltest.error_handler(): + gdal.VectorTranslate(tmpfilename, json_content, options='-f GeoJSON') + ds = ogr.Open(tmpfilename) + lyr = ds.GetLayer(0) + if lyr.GetLayerDefn().GetFieldCount() != 0: + gdaltest.post_reason('fail') + return 'fail' + ds = None + + gdal.VectorTranslate(tmpfilename, json_content, options='-f GeoJSON -lco WRITE_NON_FINITE_VALUES=YES') + ds = ogr.Open(tmpfilename) + lyr = ds.GetLayer(0) + if lyr.GetLayerDefn().GetFieldCount() != 3: + gdaltest.post_reason('fail') + return 'fail' + f = lyr.GetNextFeature() + if f['inf_prop'] != float('inf'): + gdaltest.post_reason('fail') + f.DumpReadable() + return 'fail' + if f['minus_inf_prop'] != float('-inf'): + gdaltest.post_reason('fail') + f.DumpReadable() + return 'fail' + if not math.isnan(f['nan_prop']): + gdaltest.post_reason('fail') + print(str(f['nan_prop'])) + f.DumpReadable() + return 'fail' + ds = None + + gdal.Unlink(tmpfilename) + return 'success' ############################################################################### @@ -4368,6 +4444,7 @@ def ogr_geojson_cleanup(): ogr_esrijson_without_geometryType, ogr_geojson_read_fields_with_different_case, ogr_geojson_clip_geometries_rfc7946, + ogr_geojson_non_finite, ogr_geojson_cleanup] if __name__ == '__main__': diff --git a/gdal/ogr/ogrsf_frmts/geojson/drv_geojson.html b/gdal/ogr/ogrsf_frmts/geojson/drv_geojson.html index 609b88a35b52..52d988a559e7 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/drv_geojson.html +++ b/gdal/ogr/ogrsf_frmts/geojson/drv_geojson.html @@ -191,6 +191,10 @@

      Layer creation options

      written as the 'id' member of Feature objects.
    • ID_TYPE=AUTO/String/Integer. (OGR >= 2.3) Type of the 'id' memer of Feature objects.
    • +
    • WRITE_NON_FINITE_VALUES=YES/NO. (OGR >= 2.4) Whether to write NaN / Infinity values. +Such values are not allowed in strict JSon mode, but some JSon parsers +(libjson-c >= 0.12 for exampl) can understand them as they are allowed by ECMAScript. +Defaults to NO

    VSI Virtual File System API support

    diff --git a/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.c b/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.c index 42c1a45cd749..51b4fa1e3978 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.c +++ b/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.c @@ -13,6 +13,10 @@ * (http://www.opensource.org/licenses/mit-license.php) */ +// For uselocale +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 700 + #include "config.h" #include "cpl_conv.h" @@ -30,19 +34,18 @@ #include "arraylist.h" #include "json_inttypes.h" #include "json_object.h" +#include "json_object_private.h" #include "json_tokener.h" #include "json_util.h" -#ifdef HAVE_LOCALE_H +#if defined(HAVE_LOCALE_H) || defined(HAVE_USELOCALE) #include #endif /* HAVE_LOCALE_H */ +#ifdef HAVE_XLOCALE_H +#include +#endif -#if !HAVE_STRDUP && defined(_MSC_VER) - /* MSC has the version as _strdup */ -# define strdup _strdup -#elif !HAVE_STRDUP -# error You do not have strdup on your system. -#endif /* HAVE_STRDUP */ +#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) #if !HAVE_STRNCASECMP && defined(_MSC_VER) /* MSC has the version as _strnicmp */ @@ -51,12 +54,24 @@ # error You do not have strncasecmp on your system. #endif /* HAVE_STRNCASECMP */ -static const char* json_null_str = "null"; -static const char* json_true_str = "true"; -static const char* json_false_str = "false"; - -// XXX after v0.10 this array will become static: -const char* json_tokener_errors[] = { +/* Use C99 NAN by default; if not available, nan("") should work too. */ +#ifndef NAN +#define NAN nan("") +#endif /* !NAN */ + +static const char json_null_str[] = "null"; +static const int json_null_str_len = sizeof(json_null_str) - 1; +static const char json_inf_str[] = "Infinity"; +static const char json_inf_str_lower[] = "infinity"; +static const unsigned int json_inf_str_len = sizeof(json_inf_str) - 1; +static const char json_nan_str[] = "NaN"; +static const int json_nan_str_len = sizeof(json_nan_str) - 1; +static const char json_true_str[] = "true"; +static const int json_true_str_len = sizeof(json_true_str) - 1; +static const char json_false_str[] = "false"; +static const int json_false_str_len = sizeof(json_false_str) - 1; + +static const char* json_tokener_errors[] = { "success", "continue", "nesting too deep", @@ -71,17 +86,20 @@ const char* json_tokener_errors[] = { "object value separator ',' expected", "invalid string sequence", "expected comment", + "buffer size overflow" }; const char *json_tokener_error_desc(enum json_tokener_error jerr) { - int jerr_int = (int)jerr; - if (jerr_int < 0 || jerr_int >= (int)(sizeof(json_tokener_errors) / sizeof(json_tokener_errors[0]))) - return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()"; + int jerr_int = (int) jerr; + if (jerr_int < 0 || + jerr_int >= (int)(sizeof(json_tokener_errors) / sizeof(json_tokener_errors[0]))) + return "Unknown error, " + "invalid json_tokener_error value passed to json_tokener_error_desc()"; return json_tokener_errors[jerr]; } -enum json_tokener_error json_tokener_get_error(json_tokener *tok) +enum json_tokener_error json_tokener_get_error(struct json_tokener *tok) { return tok->err; } @@ -98,7 +116,8 @@ struct json_tokener* json_tokener_new_ex(int depth) tok = (struct json_tokener*)calloc(1, sizeof(struct json_tokener)); if (!tok) return NULL; - tok->stack = (struct json_tokener_srec *)calloc(depth, sizeof(struct json_tokener_srec)); + tok->stack = (struct json_tokener_srec *) calloc(depth, + sizeof(struct json_tokener_srec)); if (!tok->stack) { free(tok); return NULL; @@ -118,7 +137,7 @@ void json_tokener_free(struct json_tokener *tok) { json_tokener_reset(tok); if (tok->pb) printbuf_free(tok->pb); - if (tok->stack) free(tok->stack); + free(tok->stack); free(tok); } @@ -152,7 +171,8 @@ struct json_object* json_tokener_parse(const char *str) return obj; } -struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokener_error *error) +struct json_object* json_tokener_parse_verbose(const char *str, + enum json_tokener_error *error) { struct json_tokener* tok; struct json_object* obj; @@ -195,14 +215,17 @@ struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokene * Returns 1 on success, sets tok->err and returns 0 if no more chars. * Implicit inputs: str, len vars */ -#define PEEK_CHAR(dest, tok) \ - (((tok)->char_offset == len) ? \ - (((tok)->depth == 0 && state == json_tokener_state_eatws && saved_state == json_tokener_state_finish) ? \ - (((tok)->err = json_tokener_success), 0) \ - : \ - (((tok)->err = json_tokener_continue), 0) \ - ) : \ - (((dest) = *str), 1) \ +#define PEEK_CHAR(dest, tok) \ + (((tok)->char_offset == len) ? \ + (((tok)->depth == 0 && \ + state == json_tokener_state_eatws && \ + saved_state == json_tokener_state_finish \ + ) ? \ + (((tok)->err = json_tokener_success), 0) \ + : \ + (((tok)->err = json_tokener_continue), 0) \ + ) : \ + (((dest) = *str), 1) \ ) /* ADVANCE_CHAR() macro: @@ -222,17 +245,53 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, { struct json_object *obj = NULL; char c = '\1'; -#ifdef HAVE_SETLOCALE - char *oldlocale=NULL, *tmplocale; - - tmplocale = setlocale(LC_NUMERIC, NULL); - if (tmplocale) oldlocale = strdup(tmplocale); - setlocale(LC_NUMERIC, "C"); +#ifdef HAVE_USELOCALE + locale_t oldlocale = uselocale(NULL); + locale_t newloc; +#elif defined(HAVE_SETLOCALE) + char *oldlocale = NULL; #endif tok->char_offset = 0; tok->err = json_tokener_success; + /* this interface is presently not 64-bit clean due to the int len argument + and the internal printbuf interface that takes 32-bit int len arguments + so the function limits the maximum string size to INT32_MAX (2GB). + If the function is called with len == -1 then strlen is called to check + the string length is less than INT32_MAX (2GB) */ + if ((len < -1) || (len == -1 && strlen(str) > INT32_MAX)) { + tok->err = json_tokener_error_size; + return NULL; + } + +#ifdef HAVE_USELOCALE + { + locale_t duploc = duplocale(oldlocale); + newloc = newlocale(LC_NUMERIC, "C", duploc); + // XXX at least Debian 8.4 has a bug in newlocale where it doesn't + // change the decimal separator unless you set LC_TIME! + if (newloc) + { + duploc = newloc; // original duploc has been freed by newlocale() + newloc = newlocale(LC_TIME, "C", duploc); + } + if (newloc == NULL) + { + freelocale(duploc); + return NULL; + } + uselocale(newloc); + } +#elif defined(HAVE_SETLOCALE) + { + char *tmplocale; + tmplocale = setlocale(LC_NUMERIC, NULL); + if (tmplocale) oldlocale = strdup(tmplocale); + setlocale(LC_NUMERIC, "C"); + } +#endif + while (PEEK_CHAR(c, tok)) { redo_char: @@ -240,11 +299,11 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_eatws: /* Advance until we change state */ - while (isspace((int)c)) { + while (isspace((unsigned char)c)) { if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok))) goto out; } - if(c == '/') { + if(c == '/' && !(tok->flags & JSON_TOKENER_STRICT)) { printbuf_reset(tok->pb); printbuf_memappend_fast(tok->pb, &c, 1); state = json_tokener_state_comment_start; @@ -260,24 +319,36 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, state = json_tokener_state_eatws; saved_state = json_tokener_state_object_field_start; current = json_object_new_object(); - if( current == NULL ) - goto out; + if(current == NULL) + goto out; break; case '[': state = json_tokener_state_eatws; saved_state = json_tokener_state_array; current = json_object_new_array(); - if( current == NULL ) - goto out; + if(current == NULL) + goto out; break; + case 'I': + case 'i': + state = json_tokener_state_inf; + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; case 'N': case 'n': - state = json_tokener_state_null; + state = json_tokener_state_null; // or NaN printbuf_reset(tok->pb); tok->st_pos = 0; goto redo_char; - case '"': case '\'': + if (tok->flags & JSON_TOKENER_STRICT) { + /* in STRICT mode only double-quote are allowed */ + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + /* FALLTHRU */ + case '"': state = json_tokener_state_string; printbuf_reset(tok->pb); tok->quote_char = c; @@ -290,10 +361,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, printbuf_reset(tok->pb); tok->st_pos = 0; goto redo_char; -#if defined(__GNUC__) - case '0' ... '9': -#else - case '0': + case '0': case '1': case '2': case '3': @@ -303,7 +371,6 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case '7': case '8': case '9': -#endif case '-': state = json_tokener_state_number; printbuf_reset(tok->pb); @@ -322,21 +389,95 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, tok->depth--; goto redo_char; - case json_tokener_state_null: - printbuf_memappend_fast(tok->pb, &c, 1); - if(strncasecmp(json_null_str, tok->pb->buf, - json_min(tok->st_pos+1, (int)strlen(json_null_str))) == 0) { - if(tok->st_pos == (int)strlen(json_null_str)) { - current = NULL; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - goto redo_char; + case json_tokener_state_inf: /* aka starts with 'i' (or 'I', or "-i", or "-I") */ + { + /* If we were guaranteed to have len set, then we could (usually) handle + * the entire "Infinity" check in a single strncmp (strncasecmp), but + * since len might be -1 (i.e. "read until \0"), we need to check it + * a character at a time. + * Trying to handle it both ways would make this code considerably more + * complicated with likely little performance benefit. + */ + int is_negative = 0; + const char *_json_inf_str = json_inf_str; + if (!(tok->flags & JSON_TOKENER_STRICT)) + _json_inf_str = json_inf_str_lower; + + /* Note: tok->st_pos must be 0 when state is set to json_tokener_state_inf */ + while (tok->st_pos < (int)json_inf_str_len) + { + char inf_char = *str; + if (!(tok->flags & JSON_TOKENER_STRICT)) + inf_char = tolower((int)*str); + if (inf_char != _json_inf_str[tok->st_pos]) + { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + tok->st_pos++; + (void)ADVANCE_CHAR(str, tok); + if (!PEEK_CHAR(c, tok)) + { + /* out of input chars, for now at least */ + goto out; + } } - } else { - tok->err = json_tokener_error_parse_null; - goto out; + /* We checked the full length of "Infinity", so create the object. + * When handling -Infinity, the number parsing code will have dropped + * the "-" into tok->pb for us, so check it now. + */ + if (printbuf_length(tok->pb) > 0 && *(tok->pb->buf) == '-') + { + is_negative = 1; + } + current = json_object_new_double(is_negative + ? -INFINITY : INFINITY); + if (current == NULL) + goto out; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + + } + break; + case json_tokener_state_null: /* aka starts with 'n' */ + { + int size; + int size_nan; + printbuf_memappend_fast(tok->pb, &c, 1); + size = json_min(tok->st_pos+1, json_null_str_len); + size_nan = json_min(tok->st_pos+1, json_nan_str_len); + if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_null_str, tok->pb->buf, size) == 0) + || (strncmp(json_null_str, tok->pb->buf, size) == 0) + ) { + if (tok->st_pos == json_null_str_len) { + current = NULL; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } + else if ((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_nan_str, tok->pb->buf, size_nan) == 0) || + (strncmp(json_nan_str, tok->pb->buf, size_nan) == 0) + ) + { + if (tok->st_pos == json_nan_str_len) + { + current = json_object_new_double(NAN); + if (current == NULL) + goto out; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_null; + goto out; + } + tok->st_pos++; } - tok->st_pos++; break; case json_tokener_state_comment_start: @@ -400,8 +541,8 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, if(c == tok->quote_char) { printbuf_memappend_fast(tok->pb, case_start, str-case_start); current = json_object_new_string_len(tok->pb->buf, tok->pb->bpos); - if( current == NULL ) - goto out; + if(current == NULL) + goto out; saved_state = json_tokener_state_finish; state = json_tokener_state_eatws; break; @@ -456,21 +597,21 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, /* Handle a 4-byte sequence, or two sequences if a surrogate pair */ while(1) { - if(strchr(json_hex_chars, c)) { - tok->ucs_char += ((unsigned int)hexdigit(c) << ((3-tok->st_pos++)*4)); + if (c && strchr(json_hex_chars, c)) { + tok->ucs_char += ((unsigned int)jt_hexdigit(c) << ((3-tok->st_pos++)*4)); if(tok->st_pos == 4) { unsigned char unescaped_utf[4]; if (got_hi_surrogate) { if (IS_LOW_SURROGATE(tok->ucs_char)) { - /* Recalculate the ucs_char, then fall through to process normally */ + /* Recalculate the ucs_char, then fall thru to process normally */ tok->ucs_char = DECODE_SURROGATE_PAIR(got_hi_surrogate, tok->ucs_char); } else { /* Hi surrogate was not followed by a low surrogate */ /* Replace the hi and process the rest normally */ printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); } - /*got_hi_surrogate = 0;*/ + got_hi_surrogate = 0; } if (tok->ucs_char < 0x80) { @@ -487,8 +628,8 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, */ got_hi_surrogate = tok->ucs_char; /* Not at end, and the next two chars should be "\u" */ - if ((tok->char_offset+1 != len) && - (tok->char_offset+2 != len) && + if ((len == -1 || len > (tok->char_offset + 2)) && + // str[0] != '0' && // implied by json_hex_chars, above. (str[1] == '\\') && (str[2] == 'u')) { @@ -497,13 +638,15 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, * characters. */ if( !ADVANCE_CHAR(str, tok) || !ADVANCE_CHAR(str, tok) ) { - printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); - } + printbuf_memappend_fast(tok->pb, + (char*) utf8_replacement_char, 3); + } /* Advance to the first char of the next sequence and * continue processing with the next sequence. */ if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { - printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + printbuf_memappend_fast(tok->pb, + (char*) utf8_replacement_char, 3); goto out; } tok->ucs_char = 0; @@ -514,7 +657,8 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, * it. Put a replacement char in for the hi surrogate * and pretend we finished. */ - printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + printbuf_memappend_fast(tok->pb, + (char*) utf8_replacement_char, 3); } } else if (IS_LOW_SURROGATE(tok->ucs_char)) { /* Got a low surrogate not preceded by a high */ @@ -551,32 +695,40 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, break; case json_tokener_state_boolean: - printbuf_memappend_fast(tok->pb, &c, 1); - if(strncasecmp(json_true_str, tok->pb->buf, - json_min(tok->st_pos+1, (int)strlen(json_true_str))) == 0) { - if(tok->st_pos == (int)strlen(json_true_str)) { - current = json_object_new_boolean(1); - if( current == NULL ) - goto out; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - goto redo_char; - } - } else if(strncasecmp(json_false_str, tok->pb->buf, - json_min(tok->st_pos+1, (int)strlen(json_false_str))) == 0) { - if(tok->st_pos == (int)strlen(json_false_str)) { - current = json_object_new_boolean(0); - if( current == NULL ) - goto out; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - goto redo_char; + { + int size1, size2; + printbuf_memappend_fast(tok->pb, &c, 1); + size1 = json_min(tok->st_pos+1, json_true_str_len); + size2 = json_min(tok->st_pos+1, json_false_str_len); + if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_true_str, tok->pb->buf, size1) == 0) + || (strncmp(json_true_str, tok->pb->buf, size1) == 0) + ) { + if(tok->st_pos == json_true_str_len) { + current = json_object_new_boolean(1); + if(current == NULL) + goto out; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_false_str, tok->pb->buf, size2) == 0) + || (strncmp(json_false_str, tok->pb->buf, size2) == 0)) { + if(tok->st_pos == json_false_str_len) { + current = json_object_new_boolean(0); + if(current == NULL) + goto out; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_boolean; + goto out; } - } else { - tok->err = json_tokener_error_parse_boolean; - goto out; + tok->st_pos++; } - tok->st_pos++; break; case json_tokener_state_number: @@ -584,10 +736,45 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, /* Advance until we change state */ const char *case_start = str; int case_len=0; + int is_exponent=0; + int negativesign_next_possible_location=1; while(c && strchr(json_number_chars, c)) { ++case_len; - if(c == '.' || c == 'e' || c == 'E') + + /* non-digit characters checks */ + /* note: since the main loop condition to get here was + an input starting with 0-9 or '-', we are + protected from input starting with '.' or + e/E. */ + if (c == '.') { + if (tok->is_double != 0) { + /* '.' can only be found once, and out of the exponent part. + Thus, if the input is already flagged as double, it + is invalid. */ + tok->err = json_tokener_error_parse_number; + goto out; + } + tok->is_double = 1; + } + if (c == 'e' || c == 'E') { + if (is_exponent != 0) { + /* only one exponent possible */ + tok->err = json_tokener_error_parse_number; + goto out; + } + is_exponent = 1; tok->is_double = 1; + /* the exponent part can begin with a negative sign */ + negativesign_next_possible_location = case_len + 1; + } + if (c == '-' && case_len != negativesign_next_possible_location) { + /* If the negative sign is not where expected (ie + start of input or start of exponent part), the + input is invalid. */ + tok->err = json_tokener_error_parse_number; + goto out; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { printbuf_memappend_fast(tok->pb, case_start, case_len); goto out; @@ -595,18 +782,35 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, } if (case_len>0) printbuf_memappend_fast(tok->pb, case_start, case_len); + + // Check for -Infinity + if (tok->pb->buf[0] == '-' && case_len <= 1 && + (c == 'i' || c == 'I')) + { + state = json_tokener_state_inf; + tok->st_pos = 0; + goto redo_char; + } } { int64_t num64; double numd; if (!tok->is_double && json_parse_int64(tok->pb->buf, &num64) == 0) { - current = json_object_new_int64(num64); - if( current == NULL ) - goto out; - } else if(tok->is_double && json_parse_double(tok->pb->buf, &numd) == 0) { + if (num64 && tok->pb->buf[0]=='0' && + (tok->flags & JSON_TOKENER_STRICT)) { + /* in strict mode, number must not start with 0 */ + tok->err = json_tokener_error_parse_number; + goto out; + } + current = json_object_new_int64(num64); + if(current == NULL) + goto out; + } + else if(tok->is_double && json_parse_double(tok->pb->buf, &numd) == 0) + { current = json_object_new_double(numd); - if( current == NULL ) - goto out; + if(current == NULL) + goto out; } else { tok->err = json_tokener_error_parse_number; goto out; @@ -620,12 +824,12 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_array_after_sep: case json_tokener_state_array: if(c == ']') { - if (state == json_tokener_state_array_after_sep && - (tok->flags & JSON_TOKENER_STRICT)) - { - tok->err = json_tokener_error_parse_unexpected; - goto out; - } + if (state == json_tokener_state_array_after_sep && + (tok->flags & JSON_TOKENER_STRICT)) + { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } saved_state = json_tokener_state_finish; state = json_tokener_state_eatws; } else { @@ -642,9 +846,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_array_add: if( json_object_array_add(current, obj) != 0 ) - { - goto out; - } + goto out; saved_state = json_tokener_state_array_sep; state = json_tokener_state_eatws; goto redo_char; @@ -737,6 +939,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, goto redo_char; case json_tokener_state_object_sep: + /* { */ if(c == '}') { saved_state = json_tokener_state_finish; state = json_tokener_state_eatws; @@ -752,18 +955,28 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, } if (!ADVANCE_CHAR(str, tok)) goto out; - } /* while(POP_CHAR) */ + } /* while(PEEK_CHAR) */ out: + if (c && + (state == json_tokener_state_finish) && + (tok->depth == 0) && + (tok->flags & JSON_TOKENER_STRICT)) { + /* unexpected char after JSON data */ + tok->err = json_tokener_error_parse_unexpected; + } if (!c) { /* We hit an eof char (0) */ if(state != json_tokener_state_finish && saved_state != json_tokener_state_finish) tok->err = json_tokener_error_parse_eof; } -#ifdef HAVE_SETLOCALE +#ifdef HAVE_USELOCALE + uselocale(oldlocale); + freelocale(newloc); +#elif defined(HAVE_SETLOCALE) setlocale(LC_NUMERIC, oldlocale); - if (oldlocale) free(oldlocale); + free(oldlocale); #endif if (tok->err == json_tokener_success) diff --git a/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.h b/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.h index 247ae01f0616..c3862162b45b 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.h +++ b/gdal/ogr/ogrsf_frmts/geojson/libjson/json_tokener.h @@ -33,7 +33,8 @@ enum json_tokener_error { json_tokener_error_parse_object_key_sep, json_tokener_error_parse_object_value_sep, json_tokener_error_parse_string, - json_tokener_error_parse_comment + json_tokener_error_parse_comment, + json_tokener_error_size }; enum json_tokener_state { @@ -60,7 +61,8 @@ enum json_tokener_state { json_tokener_state_object_value_add, json_tokener_state_object_sep, json_tokener_state_array_after_sep, - json_tokener_state_object_field_start_after_sep + json_tokener_state_object_field_start_after_sep, + json_tokener_state_inf }; struct json_tokener_srec @@ -105,14 +107,6 @@ struct json_tokener */ const char *json_tokener_error_desc(enum json_tokener_error jerr); -/** - * @b XXX do not use json_tokener_errors directly. - * After v0.10 this will be removed. - * - * See json_tokener_error_desc() instead. - */ -extern const char* json_tokener_errors[]; - /** * Retrieve the error caused by the last call to json_tokener_parse_ex(), * or json_tokener_success if there is no error. @@ -142,26 +136,27 @@ extern void json_tokener_set_flags(struct json_tokener *tok, int flags); * it can also be a string, number or boolean value. * * A partial JSON string can be parsed. If the parsing is incomplete, - * NULL will be returned and json_tokener_get_error() will be return + * NULL will be returned and json_tokener_get_error() will return * json_tokener_continue. * json_tokener_parse_ex() can then be called with additional bytes in str * to continue the parsing. * - * If json_tokener_parse_ex() returns NULL and the error anything other than + * If json_tokener_parse_ex() returns NULL and the error is anything other than * json_tokener_continue, a fatal error has occurred and parsing must be - * halted. Then tok object must not be re-used until json_tokener_reset() is + * halted. Then, the tok object must not be reused until json_tokener_reset() is * called. * * When a valid JSON value is parsed, a non-NULL json_object will be - * returned. Also, json_tokener_get_error() will return json_tokener_success. - * Be sure to check the type with json_object_is_type() or - * json_object_get_type() before using the object. + * returned, with a reference count of one which belongs to the caller. Also, + * json_tokener_get_error() will return json_tokener_success. Be sure to check + * the type with json_object_is_type() or json_object_get_type() before using + * the object. * - * @b XXX this should not use internal fields: + * @b XXX this shouldn't use internal fields: * Trailing characters after the parsed value do not automatically cause an * error. It is up to the caller to decide whether to treat this as an * error or to handle the additional characters, perhaps by parsing another - * JSON value starting from that point. + * json value starting from that point. * * Extra characters can be detected by comparing the tok->char_offset against * the length of the last len parameter passed in. @@ -170,6 +165,11 @@ extern void json_tokener_set_flags(struct json_tokener *tok, int flags); * responsible for calling json_tokener_parse_ex with an appropriate str * parameter starting with the extra characters. * + * This interface is presently not 64-bit clean due to the int len argument + * so the function limits the maximum string size to INT32_MAX (2GB). + * If the function is called with len == -1 then strlen is called to check + * the string length is less than INT32_MAX (2GB) + * * Example: * @code json_object *jobj = NULL; diff --git a/gdal/ogr/ogrsf_frmts/geojson/libjson/symbol_renames.h b/gdal/ogr/ogrsf_frmts/geojson/libjson/symbol_renames.h index 28d209a08b30..64fb27acfc52 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/libjson/symbol_renames.h +++ b/gdal/ogr/ogrsf_frmts/geojson/libjson/symbol_renames.h @@ -83,7 +83,6 @@ #define json_false_str gdal_json_false_str #define json_null_str gdal_json_null_str #define json_true_str gdal_json_true_str -#define json_tokener_errors gdal_json_tokener_errors #define json_object_iter_begin gdal_json_object_iter_begin #define json_object_iter_end gdal_json_object_iter_end #define json_object_iter_equal gdal_json_object_iter_equal diff --git a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsondriver.cpp b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsondriver.cpp index c7323ca1b113..a57d8f77f48e 100644 --- a/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsondriver.cpp +++ b/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsondriver.cpp @@ -662,6 +662,7 @@ void RegisterOGRGeoJSON() " String" " Integer" " " +"

    \section gdal_vrttut_format .vrt Format -A XML schema of the GDAL VRT format +A XML schema of the GDAL VRT format is available.

    Virtual files stored on disk are kept in an XML format with the following From c5fbfaa0ef4888fe4f1e1799cd3c32ff42eb36c8 Mon Sep 17 00:00:00 2001 From: Norman Barker Date: Wed, 28 Nov 2018 14:49:02 -0600 Subject: [PATCH 086/488] fix memory leak with tiff webp encoding --- gdal/frmts/gtiff/libtiff/tif_webp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gdal/frmts/gtiff/libtiff/tif_webp.c b/gdal/frmts/gtiff/libtiff/tif_webp.c index ee0a0649e673..53c3b214b2ac 100644 --- a/gdal/frmts/gtiff/libtiff/tif_webp.c +++ b/gdal/frmts/gtiff/libtiff/tif_webp.c @@ -419,6 +419,12 @@ TWebPPreEncode(TIFF* tif, uint16 s) /* set up buffer for raw data */ /* given above check and that nSamples <= 4, buffer_size is <= 1 GB */ sp->buffer_size = segment_width * segment_height * sp->nSamples; + + if (sp->pBuffer != NULL) { + _TIFFfree(sp->pBuffer); + sp->pBuffer = NULL; + } + sp->pBuffer = _TIFFmalloc(sp->buffer_size); if( !sp->pBuffer) { TIFFErrorExt(tif->tif_clientdata, module, "Cannot allocate buffer"); @@ -464,7 +470,7 @@ TWebPPostEncode(TIFF* tif) "WebPPictureImportRGB() failed"); return 0; } - + if (!WebPEncode(&sp->sEncoderConfig, &sp->sPicture)) { #if WEBP_ENCODER_ABI_VERSION >= 0x0100 @@ -544,10 +550,10 @@ TWebPCleanup(TIFF* tif) } if (sp->pBuffer != NULL) { - _TIFFfree(sp->pBuffer); - sp->pBuffer = NULL; + _TIFFfree(sp->pBuffer); + sp->pBuffer = NULL; } - + if (tif->tif_data) { _TIFFfree(tif->tif_data); tif->tif_data = NULL; From 371ebe3983688f29e551259497b1781d429ce00b Mon Sep 17 00:00:00 2001 From: jratike80 Date: Thu, 29 Nov 2018 12:32:42 +0200 Subject: [PATCH 087/488] Validate_gpkg.py: change "type" into "typ" --- gdal/swig/python/samples/validate_gpkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/swig/python/samples/validate_gpkg.py b/gdal/swig/python/samples/validate_gpkg.py index d1fb37d8baf3..cef05c590193 100755 --- a/gdal/swig/python/samples/validate_gpkg.py +++ b/gdal/swig/python/samples/validate_gpkg.py @@ -56,7 +56,7 @@ def _is_valid_data_type(typ): return typ in ('BOOLEAN', 'TINYINT', 'SMALLINT', 'MEDIUMINT', 'INT', 'INTEGER', 'FLOAT', 'DOUBLE', 'REAL', 'TEXT', 'BLOB', 'DATE', 'DATETIME') or \ - type.startswith('TEXT(') or type.startswith('BLOB(') + typ.startswith('TEXT(') or typ.startswith('BLOB(') class GPKGCheckException(Exception): From 6e4b50c32e72fe2f68d3c69ba85e91f9a6379242 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 29 Nov 2018 11:56:33 +0100 Subject: [PATCH 088/488] SQLite: do not run spatial index creation in rollback code --- gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp index 09b06d54eb8e..7eab34e63196 100644 --- a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp @@ -2915,7 +2915,6 @@ OGRErr OGRSQLiteDataSource::CommitTransaction() { OGRSQLiteTableLayer* poLayer = (OGRSQLiteTableLayer*) papoLayers[iLayer]; poLayer->RunDeferredCreationIfNecessary(); - //poLayer->CreateSpatialIndexIfNecessary(); } } } @@ -2953,7 +2952,6 @@ OGRErr OGRSQLiteDataSource::RollbackTransaction() { OGRSQLiteTableLayer* poLayer = (OGRSQLiteTableLayer*) papoLayers[iLayer]; poLayer->RunDeferredCreationIfNecessary(); - poLayer->CreateSpatialIndexIfNecessary(); } } From 37c175741c6a8ce9733cb1c66421ece6e7a32d57 Mon Sep 17 00:00:00 2001 From: Mathijs Dumon Date: Thu, 29 Nov 2018 11:59:49 +0100 Subject: [PATCH 089/488] MSSQLSPATIAL: Adding configuration option MSSQLSPATIAL_ALWAYS_OUTPUT_FID (#1101) Adding configuration option to always output the OGR_FID column for inserted entities. Makes sure views or sequence generated ID fields are supported --- gdal/ogr/ogrsf_frmts/mssqlspatial/drv_mssqlspatial.html | 1 + gdal/ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h | 2 ++ .../ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp | 1 + .../ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp | 7 ++++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/mssqlspatial/drv_mssqlspatial.html b/gdal/ogr/ogrsf_frmts/mssqlspatial/drv_mssqlspatial.html index d70cdf89270e..71c62b41e840 100644 --- a/gdal/ogr/ogrsf_frmts/mssqlspatial/drv_mssqlspatial.html +++ b/gdal/ogr/ogrsf_frmts/mssqlspatial/drv_mssqlspatial.html @@ -133,6 +133,7 @@

    Configuration options

    this parameter is TRUE, otherwise the parameter is ignored by the driver.
  • MSSQLSPATIAL_BCP_SIZE: (From GDAL 2.1.0) Specifies the bulk insert batch size. The larger value makes the insert faster, but consumes more memory. Default = 1000.
  • MSSQLSPATIAL_OGR_FID: Override FID column name. Default = ogr_fid.
  • +
  • MSSQLSPATIAL_ALWAYS_OUTPUT_FID: Always return the OGR_FID column - even if it is not a true IDENTITY column - when creating features. Default = "NO".
  • MSSQLSPATIAL_USE_GEOMETRY_COLUMNS: Use/create geometry_columns metadata table in the database. Default = "YES".
  • MSSQLSPATIAL_LIST_ALL_TABLES: Use mssql catalog to list available layers. Default = "NO".
  • diff --git a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h index 8612c97ae0c3..071e1a5e3fe1 100644 --- a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h +++ b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h @@ -449,6 +449,7 @@ class OGRMSSQLSpatialDataSource final: public OGRDataSource int nGeometryFormat; int bUseGeometryColumns; + bool bAlwaysOutputFid; int bListAllTables; @@ -487,6 +488,7 @@ class OGRMSSQLSpatialDataSource final: public OGRDataSource int GetGeometryFormat() { return nGeometryFormat; } int UseGeometryColumns() { return bUseGeometryColumns; } + bool AlwaysOutputFid() { return bAlwaysOutputFid; } virtual OGRErr DeleteLayer( int iLayer ) override; virtual OGRLayer *ICreateLayer( const char *, diff --git a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp index 629afc156ae0..b8c5c5333f05 100644 --- a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp +++ b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp @@ -53,6 +53,7 @@ OGRMSSQLSpatialDataSource::OGRMSSQLSpatialDataSource() : pszConnection = nullptr; bUseGeometryColumns = CPLTestBool(CPLGetConfigOption("MSSQLSPATIAL_USE_GEOMETRY_COLUMNS", "YES")); + bAlwaysOutputFid = CPLTestBool(CPLGetConfigOption("MSSQLSPATIAL_ALWAYS_OUTPUT_FID", "NO")); bListAllTables = CPLTestBool(CPLGetConfigOption("MSSQLSPATIAL_LIST_ALL_TABLES", "NO")); const char* nBCPSizeParam = CPLGetConfigOption("MSSQLSPATIAL_BCP_SIZE", nullptr); diff --git a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp index 0cbf181929cd..81fcf1c51985 100644 --- a/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp @@ -2060,7 +2060,8 @@ OGRErr OGRMSSQLSpatialTableLayer::ICreateFeature( OGRFeature *poFeature ) if (oStatement.GetCommand()[strlen(oStatement.GetCommand()) - 1] != ']') { /* no fields were added */ - if (nFID == OGRNullFID && pszFIDColumn != nullptr && bIsIdentityFid) + + if (nFID == OGRNullFID && pszFIDColumn != nullptr && (bIsIdentityFid || poDS->AlwaysOutputFid() )) oStatement.Appendf(" OUTPUT INSERTED.[%s] DEFAULT VALUES;", GetFIDColumn()); else oStatement.Appendf( "DEFAULT VALUES;" ); @@ -2068,7 +2069,7 @@ OGRErr OGRMSSQLSpatialTableLayer::ICreateFeature( OGRFeature *poFeature ) else { /* prepend VALUES section */ - if (nFID == OGRNullFID && pszFIDColumn != nullptr && bIsIdentityFid) + if (nFID == OGRNullFID && pszFIDColumn != nullptr && (bIsIdentityFid || poDS->AlwaysOutputFid() )) oStatement.Appendf(") OUTPUT INSERTED.[%s] VALUES (", GetFIDColumn()); else oStatement.Appendf( ") VALUES (" ); @@ -2266,7 +2267,7 @@ OGRErr OGRMSSQLSpatialTableLayer::ICreateFeature( OGRFeature *poFeature ) return OGRERR_FAILURE; } - else if(nFID == OGRNullFID && pszFIDColumn != nullptr && bIsIdentityFid) + else if(nFID == OGRNullFID && pszFIDColumn != nullptr && (bIsIdentityFid || poDS->AlwaysOutputFid() )) { // fetch new ID and set it into the feature if (oStatement.Fetch()) From 330939d525652662c1e4b664dd205be1ecf92783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81ris=20Narti=C5=A1s?= Date: Thu, 29 Nov 2018 13:05:02 +0200 Subject: [PATCH 090/488] SENTINEL2: Add support of S2x_MSIL2A files (#1069) S2xMSIL2A files have two product types (S2MSI2A and S2MSI2Ap). This change allows to open both of them either compressed or uncompressed. Tested on following files: S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.zip S2B_MSIL2A_20180823T094029_N0208_R036_T34VFJ_20180823T122014.zip S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.zip --- .../R10m/T34VFJ_20180818T094031_AOT_10m.jp2 | Bin 0 -> 446 bytes .../R10m/T34VFJ_20180818T094031_B02_10m.jp2 | Bin 0 -> 446 bytes .../R10m/T34VFJ_20180818T094031_B03_10m.jp2 | Bin 0 -> 446 bytes .../R10m/T34VFJ_20180818T094031_B04_10m.jp2 | Bin 0 -> 446 bytes .../R10m/T34VFJ_20180818T094031_B08_10m.jp2 | Bin 0 -> 446 bytes .../R10m/T34VFJ_20180818T094031_TCI_10m.jp2 | Bin 0 -> 446 bytes .../R10m/T34VFJ_20180818T094031_WVP_10m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_AOT_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B02_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B03_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B04_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B05_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B06_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B07_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B11_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B12_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_B8A_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_SCL_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_TCI_20m.jp2 | Bin 0 -> 446 bytes .../R20m/T34VFJ_20180818T094031_WVP_20m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_AOT_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B01_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B02_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B03_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B04_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B05_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B06_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B07_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B09_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B11_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B12_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_B8A_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_SCL_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_TCI_60m.jp2 | Bin 0 -> 446 bytes .../R60m/T34VFJ_20180818T094031_WVP_60m.jp2 | Bin 0 -> 446 bytes .../MTD_TL.xml | 71 +++ .../MTD_MSIL2A.xml | 206 +++++++ .../L2A_T34VFJ_20170823T094031_AOT_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B02_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B03_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B04_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B08_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_TCI_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_WVP_10m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_AOT_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B02_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B03_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B04_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B05_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B06_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B07_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B11_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B12_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B8A_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_SCL_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_TCI_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_VIS_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_WVP_20m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_AOT_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B01_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B02_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B03_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B04_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B05_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B06_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B07_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B09_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B11_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B12_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_B8A_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_SCL_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_TCI_60m.jp2 | Bin 0 -> 446 bytes .../L2A_T34VFJ_20170823T094031_WVP_60m.jp2 | Bin 0 -> 446 bytes .../MTD_TL.xml | 78 +++ .../MTD_MSIL2A.xml | 250 +++++++++ autotest/gdrivers/sentinel2.py | 513 ++++++++++++++++++ gdal/frmts/sentinel2/frmt_sentinel2.html | 5 - gdal/frmts/sentinel2/sentinel2dataset.cpp | 449 +++++++++++++-- 78 files changed, 1520 insertions(+), 52 deletions(-) create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_AOT_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B02_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B03_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B04_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B08_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_TCI_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_WVP_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_AOT_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B02_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B03_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B04_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B05_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B06_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B07_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B11_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B12_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B8A_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_SCL_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_TCI_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_WVP_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_AOT_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B01_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B02_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B03_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B04_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B05_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B06_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B07_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B09_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B11_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B12_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B8A_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_SCL_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_TCI_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_WVP_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/MTD_TL.xml create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_AOT_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B02_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B03_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B04_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B08_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_TCI_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_WVP_10m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_AOT_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B02_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B03_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B04_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B05_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B06_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B07_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B11_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B12_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B8A_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_SCL_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_TCI_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_VIS_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_WVP_20m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_AOT_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B01_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B02_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B03_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B04_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B05_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B06_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B07_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B09_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B11_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B12_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B8A_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_SCL_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_TCI_60m.jp2 create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_WVP_60m.jp2 create mode 100755 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/MTD_TL.xml create mode 100644 autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml diff --git a/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_AOT_10m.jp2 b/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_AOT_10m.jp2 new file mode 100644 index 0000000000000000000000000000000000000000..a8b7386a5f7082b09868597a801c71a3f6945bfe GIT binary patch literal 446 zcmebD)MDUZU|`^3U|?isU<9(%*nvzWHWQQ$RKdUuWrNhQA+be~*fL0LCny_ag) + + + S2A_OPER_MSI_L1C_TL_MTI__20180818T101348_A016478_T34VFJ_N02.06 + S2A_OPER_MSI_L2A_TL_MTI__20180818T120345_A016478_T34VFJ_N02.08 + S2A_OPER_MSI_L2A_DS_MTI__20180818T120345_S20180818T094030_N02.08 + NOMINAL + 2018-08-18T09:40:30.459Z + + MTI_ + 2018-08-18T15:07:55.560Z + + + + + WGS84 / UTM zone 34N + EPSG:32634 + + 10980 + 10980 + + + 5490 + 5490 + + + 1830 + 1830 + + + 600000 + 6400020 + 10 + -10 + + + 600000 + 6400020 + 20 + -20 + + + 600000 + 6400020 + 60 + -60 + + + + + + 54.416476 + 0 + 0.000000 + 0.000000 + 1.566982 + 1.521106 + 14.057219 + 3.544726 + 18.739088 + 5.750781 + 24.111301 + 15.382876 + 14.922300 + 0.403622 + 0.0 + 0.0 + 0.0 + + + diff --git a/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml b/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml new file mode 100644 index 000000000000..d259eb721e05 --- /dev/null +++ b/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml @@ -0,0 +1,206 @@ + + + + + 2018-08-18T09:40:31.024Z + 2018-08-18T09:40:31.024Z + S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE + Level-2A + S2MSI2A + 02.08 + 2018-08-18T12:03:45.000000Z + Not applicable + Not applicable + + Sentinel-2A + INS-NOBS + 2018-08-18T09:40:31.024Z + 36 + DESCENDING + + +SAFE_COMPACT + + + + + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B02_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B03_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B04_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_B08_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_TCI_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_AOT_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R10m/T34VFJ_20180818T094031_WVP_10m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B02_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B03_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B04_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B05_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B06_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B07_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B8A_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B11_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_B12_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_TCI_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_AOT_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_WVP_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R20m/T34VFJ_20180818T094031_SCL_20m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B01_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B02_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B03_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B04_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B05_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B06_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B07_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B8A_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B09_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B11_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B12_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_TCI_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_AOT_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_WVP_60m + GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_SCL_60m + + + + + + + NODATA + 0 + + + SATURATED + 6 + + + 3 + 2 + 1 + + + 10000 + 1000.0 + 1000.0 + + + 0.97 + + 1884.69 + 1959.72 + 1823.24 + 1512.06 + 1424.64 + 1287.61 + 1162.08 + 1041.63 + 955.32 + 812.92 + 367.15 + 245.59 + 85.25 + + + + + + SC_NODATA + 0 + + + SC_SATURATED_DEFECTIVE + 1 + + + SC_DARK_FEATURE_SHADOW + 2 + + + SC_CLOUD_SHADOW + 3 + + + SC_VEGETATION + 4 + + + SC_NOT_VEGETATED + 5 + + + SC_WATER + 6 + + + SC_UNCLASSIFIED + 7 + + + SC_CLOUD_MEDIUM_PROBA + 8 + + + SC_CLOUD_HIGH_PROBA + 9 + + + SC_THIN_CIRRUS + 10 + + + SC_SNOW_ICE + 11 + + + + + + + + + 57.7 22.6 57.6 24.5 56.7 24.4 56.7 22.6 57.7 22.6 + + + POINT + 1 + + + EPSG + GEOGRAPHIC + + + + + 54.4 + + 0.0 + 0 + + + + PASSED + PASSED + PASSED + PASSED + PASSED + + + + + 0.0 + 0.0 + 1.5 + 1.5 + 14.0 + 3.5 + 18.7 + 5.7 + 24.1 + 15.3 + 14.9 + 0.4 + 0.0 + 0.0 + 0.0 + + + diff --git a/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_AOT_10m.jp2 b/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_AOT_10m.jp2 new file mode 100644 index 0000000000000000000000000000000000000000..a8b7386a5f7082b09868597a801c71a3f6945bfe GIT binary patch literal 446 zcmebD)MDUZU|`^3U|?isU<9(%*nvzWHWQQ$RKdUuWrNhQA+be~*fL0LCny_ag) + + + S2A_USER_MSI_L2A_TL_SGS__20170823T133142_A011330_T34VFJ_N02.05 + S2A_USER_MSI_L2A_DS_SGS__20170823T133142_S20170823T094252_N02.05 + NOMINAL + 2017-08-23T09:42:52.161Z + + SGS_ + 2017-08-23T14:08:32.325838Z + + + + + WGS84 / UTM zone 34N + EPSG:32634 + + 10980 + 10980 + + + 5490 + 5490 + + + 1830 + 1830 + + + 600000 + 6400020 + 10 + -10 + + + 600000 + 6400020 + 20 + -20 + + + 600000 + 6400020 + 60 + -60 + + + + + + 86.3421 + 0 + + + 0.000000 + 0.000000 + 1.058892 + 4.194147 + 5.036503 + 0.448578 + 2.938666 + 1.662363 + 28.919381 + 36.154309 + 19.373934 + 84.447624 + 0.213228 + 0.0 + 0.0 + 0.0 + + + L2A_T34VFJ_20170823T094031_CLD + L2A_T34VFJ_20170823T094031_SNW + + L2A_T34VFJ_20170823T094031_PVI + + diff --git a/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml b/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml new file mode 100644 index 000000000000..bbb37ca823ba --- /dev/null +++ b/autotest/gdrivers/data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml @@ -0,0 +1,250 @@ + + + + + 2017-08-23T09:40:31.026Z + 2017-08-23T09:40:31.026Z + S2A_MSIL1C_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE + S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE + Level-2Ap + S2MSI2Ap + 02.05 + 2017-08-25T08:50:10Z + Not applicable + Not applicable + + Sentinel-2A + INS-NOBS + 2017-08-23T09:40:31.026Z + 36 + DESCENDING + + + SAFE_COMPACT + + + + + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B01_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B02_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B03_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B04_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B05_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B06_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B07_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B8A_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B09_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B11_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B12_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/AUX_DATA/L2A_T34VFJ_20170823T094031_DEM_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_SCL_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/QI_DATA/L2A_T34VFJ_20170823T094031_SNW_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/QI_DATA/L2A_T34VFJ_20170823T094031_CLD_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_AOT_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_WVP_60m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_TCI_60m + + + + + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B02_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B03_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B04_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B05_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B06_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B07_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B8A_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B11_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_B12_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/AUX_DATA/L2A_T34VFJ_20170823T094031_DEM_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_SCL_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/QI_DATA/L2A_T34VFJ_20170823T094031_SNW_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/QI_DATA/L2A_T34VFJ_20170823T094031_CLD_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_AOT_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_WVP_20m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R20m/L2A_T34VFJ_20170823T094031_TCI_20m + + + + + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B02_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B03_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B04_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_B08_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/AUX_DATA/L2A_T34VFJ_20170823T094031_DEM_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_AOT_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_WVP_10m + GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R10m/L2A_T34VFJ_20170823T094031_TCI_10m + + + + + + + NODATA + 0 + + + SATURATED + 6 + + + 3 + 2 + 1 + + + 10000 + 10000 + 1000.0 + 1000.0 + + + 0.97 + + 1913.57 + 1941.63 + 1822.61 + 1512.79 + 1425.56 + 1288.32 + 1163.19 + 1036.39 + 955.19 + 813.04 + 367.15 + 245.59 + 85.25 + + + 4.05258688 + 3.79421934 + 4.19056789 + 4.516256 + 5.19904998 + 4.86711284 + 4.52865796 + 6.19052531 + 5.13233152 + 8.52613546 + 55.22178219 + 35.32963486 + 106.39533241 + 0 + + + SC_NODATA + 0 + + + SC_SATURATED_DEFECTIVE + 1 + + + SC_DARK_FEATURE_SHADOW + 2 + + + SC_CLOUD_SHADOW + 3 + + + SC_VEGETATION + 4 + + + SC_BARE_SOIL_DESERT + 5 + + + SC_WATER + 6 + + + SC_CLOUD_LOW_PROBA + 7 + + + SC_CLOUD_MEDIUM_PROBA + 8 + + + SC_CLOUD_HIGH_PROBA + 9 + + + SC_THIN_CIRRUS + 10 + + + SC_SNOW_ICE + 11 + + + + + + + + + 57.7 22.6 57.6 24.5 56.7 24.4 56.7 22.6 57.7 22.6 + + + POINT + 1 + + + EPSG + GEOGRAPHIC + + + + + + L2A_T34VFJ_A011330_20170823T094252 + L2A_T34VFJ_A011330_20170823T094252 + L2A_T34VFJ_A011330_20170823T094252 + + http://data_public:GDdci@data.cgiar-csi.org/srtm/tiles/GeoTIFF/ + + GlobalSnowMap.tiff + + + + 86.3 + + 0 + 0 + + + + PASSED + PASSED + PASSED + PASSED + PASSED + + + + + + + 0.0 + 0.0 + 1.0 + 4.1 + 5.0 + 0.4 + 2.9 + 1.6 + 28.9 + 36.1 + 19.3 + 84.4 + 0.2 + 0.0 + 0.0 + 0.0 + + + diff --git a/autotest/gdrivers/sentinel2.py b/autotest/gdrivers/sentinel2.py index 244f0563c93f..6602278729b4 100755 --- a/autotest/gdrivers/sentinel2.py +++ b/autotest/gdrivers/sentinel2.py @@ -2110,6 +2110,515 @@ def sentinel2_l2a_3(): return 'success' +############################################################################### +# Test opening a L2A MSIL2A product + + +def sentinel2_l2a_4(): + + filename_xml = 'data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml' + gdal.ErrorReset() + ds = gdal.Open(filename_xml) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + return 'fail' + + expected_md = { + 'AOT_QUANTIFICATION_VALUE': '1000.0', + 'AOT_QUANTIFICATION_VALUE_UNIT': 'none', + 'AOT_RETRIEVAL_ACCURACY': '0.0', + 'BOA_QUANTIFICATION_VALUE': '10000', + 'BOA_QUANTIFICATION_VALUE_UNIT': 'none', + 'CLOUD_COVERAGE_ASSESSMENT': '54.4', + 'CLOUD_SHADOW_PERCENTAGE': '1.5', + 'DARK_FEATURES_PERCENTAGE': '1.5', + 'DATATAKE_1_DATATAKE_SENSING_START': '2018-08-18T09:40:31.024Z', + 'DATATAKE_1_DATATAKE_TYPE': 'INS-NOBS', + 'DATATAKE_1_ID': 'GS2A_20180818T094031_016478_N02.08', + 'DATATAKE_1_SENSING_ORBIT_DIRECTION': 'DESCENDING', + 'DATATAKE_1_SENSING_ORBIT_NUMBER': '36', + 'DATATAKE_1_SPACECRAFT_NAME': 'Sentinel-2A', + 'DEGRADED_ANC_DATA_PERCENTAGE': '0.0', + 'DEGRADED_MSI_DATA_PERCENTAGE': '0', + 'FOOTPRINT': 'POLYGON((22.6 57.7, 24.5 57.6, 24.4 56.7, 22.6 56.7, 22.6 57.7))', + 'FORMAT_CORRECTNESS': 'PASSED', + 'GENERAL_QUALITY': 'PASSED', + 'GENERATION_TIME': '2018-08-18T12:03:45.000000Z', + 'GEOMETRIC_QUALITY': 'PASSED', + 'HIGH_PROBA_CLOUDS_PERCENTAGE': '15.3', + 'MEDIUM_PROBA_CLOUDS_PERCENTAGE': '24.1', + 'NODATA_PIXEL_PERCENTAGE': '0.0', + 'NOT_VEGETATED_PERCENTAGE': '3.5', + 'PREVIEW_GEO_INFO': 'Not applicable', + 'PREVIEW_IMAGE_URL': 'Not applicable', + 'PROCESSING_BASELINE': '02.08', + 'PROCESSING_LEVEL': 'Level-2A', + 'PRODUCT_START_TIME': '2018-08-18T09:40:31.024Z', + 'PRODUCT_STOP_TIME': '2018-08-18T09:40:31.024Z', + 'PRODUCT_TYPE': 'S2MSI2A', + 'PRODUCT_URI': 'S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE', + 'RADIATIVE_TRANSFER_ACCURACY': '0.0', + 'RADIOMETRIC_QUALITY': 'PASSED', + 'REFLECTANCE_CONVERSION_U': '0.97', + 'SATURATED_DEFECTIVE_PIXEL_PERCENTAGE': '0.0', + 'SENSOR_QUALITY': 'PASSED', + 'SNOW_ICE_PERCENTAGE': '0.4', + 'SPECIAL_VALUE_NODATA': '0', + 'SPECIAL_VALUE_SATURATED': '6', + 'THIN_CIRRUS_PERCENTAGE': '14.9', + 'UNCLASSIFIED_PERCENTAGE': '5.7', + 'VEGETATION_PERCENTAGE': '14.0', + 'WATER_PERCENTAGE': '18.7', + 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0.0', + 'WVP_QUANTIFICATION_VALUE': '1000.0', + 'WVP_QUANTIFICATION_VALUE_UNIT': 'cm'} + got_md = ds.GetMetadata() + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + expected_md = { + 'SUBDATASET_1_DESC': + 'Bands B2, B3, B4, B8 with 10m resolution, UTM 34N', + 'SUBDATASET_1_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml:10m:EPSG_32634', + 'SUBDATASET_2_DESC': + 'Bands B5, B6, B7, B8A, B11, B12 with 20m resolution, UTM 34N', + 'SUBDATASET_2_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml:20m:EPSG_32634', + 'SUBDATASET_3_DESC': + 'Bands B1, B9 with 60m resolution, UTM 34N', + 'SUBDATASET_3_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml:60m:EPSG_32634', + 'SUBDATASET_4_DESC': + 'True color image, UTM 34N', + 'SUBDATASET_4_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml:TCI:EPSG_32634'} + got_md = ds.GetMetadata('SUBDATASETS') + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + # Try opening the 4 subdatasets + for i in range(2): + gdal.ErrorReset() + ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) + return 'fail' + + # Try various invalid subdataset names + for name in ['SENTINEL2_L2A:', + 'SENTINEL2_L2A:foo.xml:10m:EPSG_32632', + 'SENTINEL2_L2A:%s' % filename_xml, + 'SENTINEL2_L2A:%s:' % filename_xml, + 'SENTINEL2_L2A:%s:10m' % filename_xml, + 'SENTINEL2_L2A:%s:10m:' % filename_xml, + 'SENTINEL2_L2A:%s:10m:EPSG_' % filename_xml, + 'SENTINEL2_L2A:%s:50m:EPSG_32632' % filename_xml, + 'SENTINEL2_L2A:%s:10m:EPSG_32633' % filename_xml]: + with gdaltest.error_handler(): + ds = gdal.Open(name) + if ds is not None: + gdaltest.post_reason('fail') + print(name) + return 'fail' + + return 'success' + + +############################################################################### +# Test opening a L2A MSIL2A subdataset on the 60m bands + + +def sentinel2_l2a_5(): + + filename_xml = 'data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml' + gdal.ErrorReset() + ds = gdal.Open('SENTINEL2_L2A:%s:60m:EPSG_32634' % filename_xml) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + return 'fail' + + expected_md = { + 'AOT_QUANTIFICATION_VALUE': '1000.0', + 'AOT_QUANTIFICATION_VALUE_UNIT': 'none', + 'AOT_RETRIEVAL_ACCURACY': '0.0', + 'BOA_QUANTIFICATION_VALUE': '10000', + 'BOA_QUANTIFICATION_VALUE_UNIT': 'none', + 'CLOUD_COVERAGE_ASSESSMENT': '54.4', + 'CLOUD_SHADOW_PERCENTAGE': '1.5', + 'DARK_FEATURES_PERCENTAGE': '1.5', + 'DATATAKE_1_DATATAKE_SENSING_START': '2018-08-18T09:40:31.024Z', + 'DATATAKE_1_DATATAKE_TYPE': 'INS-NOBS', + 'DATATAKE_1_ID': 'GS2A_20180818T094031_016478_N02.08', + 'DATATAKE_1_SENSING_ORBIT_DIRECTION': 'DESCENDING', + 'DATATAKE_1_SENSING_ORBIT_NUMBER': '36', + 'DATATAKE_1_SPACECRAFT_NAME': 'Sentinel-2A', + 'DEGRADED_ANC_DATA_PERCENTAGE': '0.0', + 'DEGRADED_MSI_DATA_PERCENTAGE': '0', + 'FORMAT_CORRECTNESS': 'PASSED', + 'GENERAL_QUALITY': 'PASSED', + 'GENERATION_TIME': '2018-08-18T12:03:45.000000Z', + 'GEOMETRIC_QUALITY': 'PASSED', + 'HIGH_PROBA_CLOUDS_PERCENTAGE': '15.3', + 'MEDIUM_PROBA_CLOUDS_PERCENTAGE': '24.1', + 'NODATA_PIXEL_PERCENTAGE': '0.0', + 'NOT_VEGETATED_PERCENTAGE': '3.5', + 'PREVIEW_GEO_INFO': 'Not applicable', + 'PREVIEW_IMAGE_URL': 'Not applicable', + 'PROCESSING_BASELINE': '02.08', + 'PROCESSING_LEVEL': 'Level-2A', + 'PRODUCT_START_TIME': '2018-08-18T09:40:31.024Z', + 'PRODUCT_STOP_TIME': '2018-08-18T09:40:31.024Z', + 'PRODUCT_TYPE': 'S2MSI2A', + 'PRODUCT_URI': 'S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE', + 'RADIATIVE_TRANSFER_ACCURACY': '0.0', + 'RADIOMETRIC_QUALITY': 'PASSED', + 'REFLECTANCE_CONVERSION_U': '0.97', + 'SATURATED_DEFECTIVE_PIXEL_PERCENTAGE': '0.0', + 'SENSOR_QUALITY': 'PASSED', + 'SNOW_ICE_PERCENTAGE': '0.4', + 'SPECIAL_VALUE_NODATA': '0', + 'SPECIAL_VALUE_SATURATED': '6', + 'THIN_CIRRUS_PERCENTAGE': '14.9', + 'UNCLASSIFIED_PERCENTAGE': '5.7', + 'VEGETATION_PERCENTAGE': '14.0', + 'WATER_PERCENTAGE': '18.7', + 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0.0', + 'WVP_QUANTIFICATION_VALUE': '1000.0', + 'WVP_QUANTIFICATION_VALUE_UNIT': 'cm'} + got_md = ds.GetMetadata() + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + if ds.RasterXSize != 1830 or ds.RasterYSize != 1830: + gdaltest.post_reason('fail') + print(ds.RasterXSize) + print(ds.RasterYSize) + return 'fail' + + if ds.GetProjectionRef().find('32634') < 0: + gdaltest.post_reason('fail') + return 'fail' + + got_gt = ds.GetGeoTransform() + if got_gt != (600000.0, 60.0, 0.0, 6400020.0, 0.0, -60.0): + gdaltest.post_reason('fail') + print(got_gt) + return 'fail' + + if ds.RasterCount != 2: + gdaltest.post_reason('fail') + print(ds.RasterCount) + return 'fail' + + vrt = ds.GetMetadata('xml:VRT')[0] + placement_vrt = """ + data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/GRANULE/L2A_T34VFJ_A016478_20180818T094030/IMG_DATA/R60m/T34VFJ_20180818T094031_B01_60m.jp2 + 1 + + + + """ + if vrt.find(placement_vrt) < 0: + gdaltest.post_reason('fail') + print(vrt) + return 'fail' + + if ds.GetMetadata('xml:SENTINEL2') is None: + gdaltest.post_reason('fail') + return 'fail' + + band = ds.GetRasterBand(1) + got_md = band.GetMetadata() + expected_md = {'BANDNAME': 'B1', + 'BANDWIDTH': '20', + 'BANDWIDTH_UNIT': 'nm', + 'SOLAR_IRRADIANCE': '1884.69', + 'SOLAR_IRRADIANCE_UNIT': 'W/m2/um', + 'WAVELENGTH': '443', + 'WAVELENGTH_UNIT': 'nm'} + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + if band.DataType != gdal.GDT_UInt16: + gdaltest.post_reason('fail') + return 'fail' + + return 'success' + +############################################################################### +# Test opening a L2A MSIL2Ap product + + +def sentinel2_l2a_6(): + + filename_xml = 'data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml' + gdal.ErrorReset() + ds = gdal.Open(filename_xml) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + return 'fail' + + expected_md = { + 'AOT_RETRIEVAL_ACCURACY': '0.0', + 'BARE_SOILS_PERCENTAGE': '0.4', + 'CLOUD_COVERAGE_ASSESSMENT': '86.3', + 'CLOUD_COVERAGE_PERCENTAGE': '84.4', + 'CLOUD_SHADOW_PERCENTAGE': '4.1', + 'DARK_FEATURES_PERCENTAGE': '1.0', + 'DATATAKE_1_DATATAKE_SENSING_START': '2017-08-23T09:40:31.026Z', + 'DATATAKE_1_DATATAKE_TYPE': 'INS-NOBS', + 'DATATAKE_1_ID': 'GS2A_20170823T094031_011330_N02.05', + 'DATATAKE_1_SENSING_ORBIT_DIRECTION': 'DESCENDING', + 'DATATAKE_1_SENSING_ORBIT_NUMBER': '36', + 'DATATAKE_1_SPACECRAFT_NAME': 'Sentinel-2A', + 'DEGRADED_ANC_DATA_PERCENTAGE': '0', + 'DEGRADED_MSI_DATA_PERCENTAGE': '0', + 'FOOTPRINT': 'POLYGON((22.6 57.7, 24.5 57.6, 24.4 56.7, 22.6 56.7, 22.6 57.7))', + 'FORMAT_CORRECTNESS_FLAG': 'PASSED', + 'GENERAL_QUALITY_FLAG': 'PASSED', + 'GENERATION_TIME': '2017-08-25T08:50:10Z', + 'GEOMETRIC_QUALITY_FLAG': 'PASSED', + 'HIGH_PROBA_CLOUDS_PERCENTAGE': '36.1', + 'MEDIUM_PROBA_CLOUDS_PERCENTAGE': '28.9', + 'L1C_TOA_QUANTIFICATION_VALUE': '10000', + 'L1C_TOA_QUANTIFICATION_VALUE_UNIT': 'none', + 'L2A_AOT_QUANTIFICATION_VALUE': '1000.0', + 'L2A_AOT_QUANTIFICATION_VALUE_UNIT': 'none', + 'L2A_BOA_QUANTIFICATION_VALUE': '10000', + 'L2A_BOA_QUANTIFICATION_VALUE_UNIT': 'none', + 'L2A_WVP_QUANTIFICATION_VALUE': '1000.0', + 'L2A_WVP_QUANTIFICATION_VALUE_UNIT': 'cm', + 'LOW_PROBA_CLOUDS_PERCENTAGE': '1.6', + 'NODATA_PIXEL_PERCENTAGE': '0.0', + 'PREVIEW_GEO_INFO': 'Not applicable', + 'PREVIEW_IMAGE_URL': 'Not applicable', + 'PROCESSING_BASELINE': '02.05', + 'PROCESSING_LEVEL': 'Level-2Ap', + 'PRODUCT_START_TIME': '2017-08-23T09:40:31.026Z', + 'PRODUCT_STOP_TIME': '2017-08-23T09:40:31.026Z', + 'PRODUCT_TYPE': 'S2MSI2Ap', + 'PRODUCT_URI_1C': 'S2A_MSIL1C_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE', + 'PRODUCT_URI_2A': 'S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE', + 'RADIATIVE_TRANSFER_ACCURAY': '0.0', + 'RADIOMETRIC_QUALITY_FLAG': 'PASSED', + 'REFERENCE_BAND': 'B1', + 'REFLECTANCE_CONVERSION_U': '0.97', + 'SATURATED_DEFECTIVE_PIXEL_PERCENTAGE': '0.0', + 'SENSOR_QUALITY_FLAG': 'PASSED', + 'SNOW_ICE_PERCENTAGE': '0.2', + 'SPECIAL_VALUE_NODATA': '0', + 'SPECIAL_VALUE_SATURATED': '6', + 'THIN_CIRRUS_PERCENTAGE': '19.3', + 'VEGETATION_PERCENTAGE': '5.0', + 'WATER_PERCENTAGE': '2.9', + 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0.0'} + got_md = ds.GetMetadata() + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + expected_md = { + 'SUBDATASET_1_DESC': + 'Bands B2, B3, B4, B8 with 10m resolution, UTM 34N', + 'SUBDATASET_1_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml:10m:EPSG_32634', + 'SUBDATASET_2_DESC': + 'Bands B5, B6, B7, B8A, B11, B12 with 20m resolution, UTM 34N', + 'SUBDATASET_2_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml:20m:EPSG_32634', + 'SUBDATASET_3_DESC': + 'Bands B1, B9 with 60m resolution, UTM 34N', + 'SUBDATASET_3_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml:60m:EPSG_32634', + 'SUBDATASET_4_DESC': + 'True color image, UTM 34N', + 'SUBDATASET_4_NAME': + 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml:TCI:EPSG_32634'} + got_md = ds.GetMetadata('SUBDATASETS') + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + # Try opening the 4 subdatasets + for i in range(2): + gdal.ErrorReset() + ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) + return 'fail' + + # Try various invalid subdataset names + for name in ['SENTINEL2_L2A:', + 'SENTINEL2_L2A:foo.xml:10m:EPSG_32632', + 'SENTINEL2_L2A:%s' % filename_xml, + 'SENTINEL2_L2A:%s:' % filename_xml, + 'SENTINEL2_L2A:%s:10m' % filename_xml, + 'SENTINEL2_L2A:%s:10m:' % filename_xml, + 'SENTINEL2_L2A:%s:10m:EPSG_' % filename_xml, + 'SENTINEL2_L2A:%s:50m:EPSG_32632' % filename_xml, + 'SENTINEL2_L2A:%s:10m:EPSG_32633' % filename_xml]: + with gdaltest.error_handler(): + ds = gdal.Open(name) + if ds is not None: + gdaltest.post_reason('fail') + print(name) + return 'fail' + + return 'success' + + +############################################################################### +# Test opening a L2A MSIL2Ap subdataset on the 60m bands + + +def sentinel2_l2a_7(): + + filename_xml = 'data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml' + gdal.ErrorReset() + ds = gdal.Open('SENTINEL2_L2A:%s:60m:EPSG_32634' % filename_xml) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + return 'fail' + + expected_md = { + 'AOT_RETRIEVAL_ACCURACY': '0.0', + 'BARE_SOILS_PERCENTAGE': '0.4', + 'CLOUD_COVERAGE_ASSESSMENT': '86.3', + 'CLOUD_COVERAGE_PERCENTAGE': '84.4', + 'CLOUD_SHADOW_PERCENTAGE': '4.1', + 'DARK_FEATURES_PERCENTAGE': '1.0', + 'DATATAKE_1_DATATAKE_SENSING_START': '2017-08-23T09:40:31.026Z', + 'DATATAKE_1_DATATAKE_TYPE': 'INS-NOBS', + 'DATATAKE_1_ID': 'GS2A_20170823T094031_011330_N02.05', + 'DATATAKE_1_SENSING_ORBIT_DIRECTION': 'DESCENDING', + 'DATATAKE_1_SENSING_ORBIT_NUMBER': '36', + 'DATATAKE_1_SPACECRAFT_NAME': 'Sentinel-2A', + 'DEGRADED_ANC_DATA_PERCENTAGE': '0', + 'DEGRADED_MSI_DATA_PERCENTAGE': '0', + 'FORMAT_CORRECTNESS_FLAG': 'PASSED', + 'GENERAL_QUALITY_FLAG': 'PASSED', + 'GENERATION_TIME': '2017-08-25T08:50:10Z', + 'GEOMETRIC_QUALITY_FLAG': 'PASSED', + 'HIGH_PROBA_CLOUDS_PERCENTAGE': '36.1', + 'MEDIUM_PROBA_CLOUDS_PERCENTAGE': '28.9', + 'L1C_TOA_QUANTIFICATION_VALUE': '10000', + 'L1C_TOA_QUANTIFICATION_VALUE_UNIT': 'none', + 'L2A_AOT_QUANTIFICATION_VALUE': '1000.0', + 'L2A_AOT_QUANTIFICATION_VALUE_UNIT': 'none', + 'L2A_BOA_QUANTIFICATION_VALUE': '10000', + 'L2A_BOA_QUANTIFICATION_VALUE_UNIT': 'none', + 'L2A_WVP_QUANTIFICATION_VALUE': '1000.0', + 'L2A_WVP_QUANTIFICATION_VALUE_UNIT': 'cm', + 'LOW_PROBA_CLOUDS_PERCENTAGE': '1.6', + 'NODATA_PIXEL_PERCENTAGE': '0.0', + 'PREVIEW_GEO_INFO': 'Not applicable', + 'PREVIEW_IMAGE_URL': 'Not applicable', + 'PROCESSING_BASELINE': '02.05', + 'PROCESSING_LEVEL': 'Level-2Ap', + 'PRODUCT_START_TIME': '2017-08-23T09:40:31.026Z', + 'PRODUCT_STOP_TIME': '2017-08-23T09:40:31.026Z', + 'PRODUCT_TYPE': 'S2MSI2Ap', + 'PRODUCT_URI_1C': 'S2A_MSIL1C_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE', + 'PRODUCT_URI_2A': 'S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE', + 'RADIATIVE_TRANSFER_ACCURAY': '0.0', + 'RADIOMETRIC_QUALITY_FLAG': 'PASSED', + 'REFERENCE_BAND': 'B1', + 'REFLECTANCE_CONVERSION_U': '0.97', + 'SATURATED_DEFECTIVE_PIXEL_PERCENTAGE': '0.0', + 'SENSOR_QUALITY_FLAG': 'PASSED', + 'SNOW_ICE_PERCENTAGE': '0.2', + 'SPECIAL_VALUE_NODATA': '0', + 'SPECIAL_VALUE_SATURATED': '6', + 'THIN_CIRRUS_PERCENTAGE': '19.3', + 'VEGETATION_PERCENTAGE': '5.0', + 'WATER_PERCENTAGE': '2.9', + 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0.0'} + got_md = ds.GetMetadata() + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + if ds.RasterXSize != 1830 or ds.RasterYSize != 1830: + gdaltest.post_reason('fail') + print(ds.RasterXSize) + print(ds.RasterYSize) + return 'fail' + + if ds.GetProjectionRef().find('32634') < 0: + gdaltest.post_reason('fail') + return 'fail' + + got_gt = ds.GetGeoTransform() + if got_gt != (600000.0, 60.0, 0.0, 6400020.0, 0.0, -60.0): + gdaltest.post_reason('fail') + print(got_gt) + return 'fail' + + if ds.RasterCount != 2: + gdaltest.post_reason('fail') + print(ds.RasterCount) + return 'fail' + + vrt = ds.GetMetadata('xml:VRT')[0] + placement_vrt = """ + data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/GRANULE/L2A_T34VFJ_A011330_20170823T094252/IMG_DATA/R60m/L2A_T34VFJ_20170823T094031_B01_60m.jp2 + 1 + + + + """ + if vrt.find(placement_vrt) < 0: + gdaltest.post_reason('fail') + print(vrt) + return 'fail' + + if ds.GetMetadata('xml:SENTINEL2') is None: + gdaltest.post_reason('fail') + return 'fail' + + band = ds.GetRasterBand(1) + got_md = band.GetMetadata() + expected_md = {'BANDNAME': 'B1', + 'BANDWIDTH': '20', + 'BANDWIDTH_UNIT': 'nm', + 'SOLAR_IRRADIANCE': '1913.57', + 'SOLAR_IRRADIANCE_UNIT': 'W/m2/um', + 'WAVELENGTH': '443', + 'WAVELENGTH_UNIT': 'nm'} + if got_md != expected_md: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_md) + return 'fail' + + if band.DataType != gdal.GDT_UInt16: + gdaltest.post_reason('fail') + return 'fail' + + return 'success' + + ############################################################################### # Test opening a L1C Safe Compact product @@ -2403,6 +2912,10 @@ def sentinel2_l1c_safe_compact_3(): sentinel2_l2a_1, sentinel2_l2a_2, sentinel2_l2a_3, + sentinel2_l2a_4, + sentinel2_l2a_5, + sentinel2_l2a_6, + sentinel2_l2a_7, sentinel2_l1c_safe_compact_1, sentinel2_l1c_safe_compact_2, sentinel2_l1c_safe_compact_3 diff --git a/gdal/frmts/sentinel2/frmt_sentinel2.html b/gdal/frmts/sentinel2/frmt_sentinel2.html index 940b43ba3fb7..976e6f70d9bc 100644 --- a/gdal/frmts/sentinel2/frmt_sentinel2.html +++ b/gdal/frmts/sentinel2/frmt_sentinel2.html @@ -124,11 +124,6 @@

    Level-2A

    If a product spans over several UTM zones, they will be exposed as separate subdatasets.

    -

    Note: at the time of writing (December 2015), the exact format of Level-2A -has not been yet decided by ESA. The driver is based on the output of the -sen2cor v2.0.5 (Sentinel 2 Level 2A -Prototype Processor) software that processes Level-1C datasets into Level-2A.

    -

    Metadata

    Metadata of the main metadata .xml file is available in the general metadata diff --git a/gdal/frmts/sentinel2/sentinel2dataset.cpp b/gdal/frmts/sentinel2/sentinel2dataset.cpp index 8634df92f927..3ddaad42209f 100644 --- a/gdal/frmts/sentinel2/sentinel2dataset.cpp +++ b/gdal/frmts/sentinel2/sentinel2dataset.cpp @@ -66,6 +66,12 @@ typedef enum SENTINEL2_L2A } SENTINEL2Level; +typedef enum +{ + MSI2Ap, + MSI2A +} SENTINEL2ProductType; + typedef struct { const char* pszBandName; @@ -168,6 +174,7 @@ class SENTINEL2Dataset : public VRTDataset static SENTINEL2Dataset *CreateL1CL2ADataset( SENTINEL2Level eLevel, + SENTINEL2ProductType pType, bool bIsSafeCompact, const std::vector& aosGranuleList, const std::vector& aoL1CSafeCompactGranuleList, @@ -179,8 +186,8 @@ class SENTINEL2Dataset : public VRTDataset bool bAlpha, const std::vector& aosBands, int nSaturatedVal, - int nNodataVal); - + int nNodataVal, + const CPLString& osProductURI); public: SENTINEL2Dataset(int nXSize, int nYSize); virtual ~SENTINEL2Dataset(); @@ -384,6 +391,8 @@ int SENTINEL2Dataset::Identify( GDALOpenInfo *poOpenInfo ) /* Accept directly .zip as provided by https://scihub.esa.int/ */ if( (STARTS_WITH_CI(pszJustFilename, "S2A_MSIL1C_") || STARTS_WITH_CI(pszJustFilename, "S2B_MSIL1C_") || + STARTS_WITH_CI(pszJustFilename, "S2A_MSIL2A_") || + STARTS_WITH_CI(pszJustFilename, "S2B_MSIL2A_") || STARTS_WITH_CI(pszJustFilename, "S2A_OPER_PRD_MSI") || STARTS_WITH_CI(pszJustFilename, "S2B_OPER_PRD_MSI") || STARTS_WITH_CI(pszJustFilename, "S2A_USER_PRD_MSI") || @@ -451,16 +460,28 @@ GDALDataset *SENTINEL2Dataset::Open( GDALOpenInfo * poOpenInfo ) } if( STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL2_L1B:") ) + { + CPLDebug("SENTINEL2", "Trying OpenL1BSubdataset"); return OpenL1BSubdataset(poOpenInfo); + } if( STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL2_L1C:") ) + { + CPLDebug("SENTINEL2", "Trying OpenL1C_L2ASubdataset"); return OpenL1C_L2ASubdataset(poOpenInfo, SENTINEL2_L1C); + } if( STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL2_L1C_TILE:") ) + { + CPLDebug("SENTINEL2", "Trying OpenL1CTileSubdataset"); return OpenL1CTileSubdataset(poOpenInfo); + } if( STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL2_L2A:") ) + { + CPLDebug("SENTINEL2", "Trying OpenL1C_L2ASubdataset"); return OpenL1C_L2ASubdataset(poOpenInfo, SENTINEL2_L2A); + } const char* pszJustFilename = CPLGetFilename(poOpenInfo->pszFilename); if( (STARTS_WITH_CI(pszJustFilename, "S2A_OPER_PRD_MSI") || @@ -494,7 +515,7 @@ GDALDataset *SENTINEL2Dataset::Open( GDALOpenInfo * poOpenInfo ) CPLString osFilename(poOpenInfo->pszFilename); CPLString osSAFE(osBasename); // S2B_MSIL1C_20171004T233419_N0206_R001_T54DWM_20171005T001811.SAFE.zip - // has .SAFE.zip extension, but other products have just a .zip + // has .SAFE.zip extension, but other products have just a .zip // extension. So for the subdir in the zip only add .SAFE when needed if( !EQUAL(CPLGetExtension(osSAFE), "SAFE") ) osSAFE += ".SAFE"; @@ -505,34 +526,62 @@ GDALDataset *SENTINEL2Dataset::Open( GDALOpenInfo * poOpenInfo ) GDALOpenInfo oOpenInfo(osFilename, GA_ReadOnly); return Open(&oOpenInfo); } + else if( (STARTS_WITH_CI(pszJustFilename, "S2A_MSIL2A_") || + STARTS_WITH_CI(pszJustFilename, "S2B_MSIL2A_") ) && + EQUAL(CPLGetExtension(pszJustFilename), "zip") ) + { + CPLString osBasename(CPLGetBasename(pszJustFilename)); + CPLString osFilename(poOpenInfo->pszFilename); + CPLString osSAFE(osBasename); + // S2B_MSIL1C_20171004T233419_N0206_R001_T54DWM_20171005T001811.SAFE.zip + // has .SAFE.zip extension, but other products have just a .zip + // extension. So for the subdir in the zip only add .SAFE when needed + if( !EQUAL(CPLGetExtension(osSAFE), "SAFE") ) + osSAFE += ".SAFE"; + osFilename = osFilename + "/" + osSAFE + "/MTD_MSIL2A.xml"; + if( strncmp(osFilename, "/vsizip/", strlen("/vsizip/")) != 0 ) + osFilename = "/vsizip/" + osFilename; + CPLDebug("SENTINEL2", "Trying %s", osFilename.c_str()); + GDALOpenInfo oOpenInfo(osFilename, GA_ReadOnly); + return Open(&oOpenInfo); + } const char* pszHeader = reinterpret_cast(poOpenInfo->pabyHeader); if( strstr(pszHeader, "pszFilename); } if( strstr(pszHeader, "pszFilename, SENTINEL2_L1C); } if( strstr(pszHeader, "pszFilename); + } if( strstr(pszHeader, "pszFilename, SENTINEL2_L2A); + } return nullptr; } @@ -595,7 +644,7 @@ static bool SENTINEL2GetGranuleInfo(SENTINEL2Level eLevel, { if( fp ) VSIFCloseL(fp); - CPLError(CE_Failure, CPLE_AppDefined, "Cannot read %s", + CPLError(CE_Failure, CPLE_AppDefined, "SENTINEL2GetGranuleInfo: Cannot read %s", osGranuleMTDPath.c_str()); return false; } @@ -776,19 +825,28 @@ static bool SENTINEL2GetGranuleList(CPLXMLNode* psMainMTD, CPLError(CE_Failure, CPLE_AppDefined, "Cannot find =%s", pszNodePath); return false; } - pszNodePath = (eLevel == SENTINEL2_L2A) ? - "General_Info.L2A_Product_Info" : "General_Info.Product_Info"; + pszNodePath = "General_Info.Product_Info"; CPLXMLNode* psProductInfo = CPLGetXMLNode(psRoot, pszNodePath); + if( psProductInfo == nullptr && eLevel == SENTINEL2_L2A ) + { + pszNodePath = "General_Info.L2A_Product_Info"; + psProductInfo = CPLGetXMLNode(psRoot, pszNodePath); + } if( psProductInfo == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot find %s", pszNodePath); return false; } - pszNodePath = (eLevel == SENTINEL2_L2A) ? - "L2A_Product_Organisation" : "Product_Organisation"; + pszNodePath = "Product_Organisation"; CPLXMLNode* psProductOrganisation = CPLGetXMLNode(psProductInfo, pszNodePath); + if( psProductOrganisation == nullptr && eLevel == SENTINEL2_L2A ) + { + pszNodePath = "L2A_Product_Organisation"; + psProductOrganisation = + CPLGetXMLNode(psProductInfo, pszNodePath); + } if( psProductOrganisation == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot find %s", pszNodePath); @@ -809,6 +867,11 @@ static bool SENTINEL2GetGranuleList(CPLXMLNode* psMainMTD, } #endif + const bool bIsMSI2Ap = EQUAL(CPLGetXMLValue(psProductInfo, "PRODUCT_TYPE", ""), + "S2MSI2Ap"); + const bool bIsCompact = EQUAL(CPLGetXMLValue(psProductInfo, "PRODUCT_FORMAT", ""), + "SAFE_COMPACT"); + CPLString oGranuleId("L2A_"); std::set aoSetGranuleId; for(CPLXMLNode* psIter = psProductOrganisation->psChild; psIter != nullptr; psIter = psIter->psNext ) @@ -822,7 +885,8 @@ static bool SENTINEL2GetGranuleList(CPLXMLNode* psMainMTD, psIter2 = psIter2->psNext ) { if( psIter2->eType != CXT_Element || - !EQUAL(psIter2->pszValue, "Granules") ) + (!EQUAL(psIter2->pszValue, "Granule") && + !EQUAL(psIter2->pszValue, "Granules")) ) { continue; } @@ -839,12 +903,15 @@ static bool SENTINEL2GetGranuleList(CPLXMLNode* psMainMTD, psIter3 = psIter3->psNext ) { if( psIter3->eType != CXT_Element || - !EQUAL(psIter3->pszValue, "IMAGE_ID_2A") ) + ( !EQUAL(psIter3->pszValue, "IMAGE_ID_2A") && + !EQUAL(psIter3->pszValue, "IMAGE_FILE") && + !EQUAL(psIter3->pszValue, "IMAGE_FILE_2A") ) ) { continue; } const char* pszTileName = CPLGetXMLValue(psIter3, nullptr, ""); size_t nLen = strlen(pszTileName); + // If granule name ends with resolution: _60m if( nLen > 4 && pszTileName[nLen-4] == '_' && pszTileName[nLen-1] == 'm' ) { @@ -881,17 +948,42 @@ static bool SENTINEL2GetGranuleList(CPLXMLNode* psMainMTD, /* S2A_OPER_MSI_L1C_TL_SGS__20151024T023555_A001758_T53JLJ_N01.04 --> */ /* S2A_OPER_MTD_L1C_TL_SGS__20151024T023555_A001758_T53JLJ */ + // S2B_OPER_MSI_L2A_TL_MPS__20180823T122014_A007641_T34VFJ_N02.08 CPLString osGranuleMTD = pszGranuleId; - if( osGranuleMTD.size() > strlen("S2A_OPER_MSI_") && + if( bIsCompact == 0 && + osGranuleMTD.size() > strlen("S2A_OPER_MSI_") && osGranuleMTD[8] == '_' && osGranuleMTD[12] == '_' && osGranuleMTD[osGranuleMTD.size()-7] == '_' && - osGranuleMTD[osGranuleMTD.size()-6] == 'N' ) + osGranuleMTD[osGranuleMTD.size()-6] == 'N' && + osGranuleMTD[7] == 'R' ) { osGranuleMTD[9] = 'M'; osGranuleMTD[10] = 'T'; osGranuleMTD[11] = 'D'; osGranuleMTD.resize(osGranuleMTD.size()-7); } + else if( bIsMSI2Ap ) + { + osGranuleMTD = "MTD_TL"; + oGranuleId = "L2A_"; + // S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE + // S2A_USER_MSI_L2A_TL_SGS__20170823T133142_A011330_T34VFJ_N02.05 --> + // L2A_T34VFJ_A011330_20170823T094252 + const char* pszProductURI = CPLGetXMLValue(psProductInfo, "PRODUCT_URI_2A", nullptr); + if( pszProductURI != nullptr ) + { + CPLString psProductURI(pszProductURI); + if( psProductURI.size() < 60 ) + { + CPLDebug("SENTINEL2", "Invalid PRODUCT_URI_2A"); + continue; + } + oGranuleId += psProductURI.substr(38, 7); + oGranuleId += CPLString(pszGranuleId).substr(41, 8).c_str(); + oGranuleId += psProductURI.substr(45, 15); + pszGranuleId = oGranuleId.c_str(); + } + } else { CPLDebug("SENTINEL2", "Invalid granule ID: %s", pszGranuleId); @@ -931,9 +1023,19 @@ char** SENTINEL2GetUserProductMetadata( CPLXMLNode* psMainMTD, CPLError(CE_Failure, CPLE_AppDefined, "Cannot find =%s", pszRootNode); return nullptr; } - CPLXMLNode* psProductInfo = CPLGetXMLNode(psRoot, - EQUAL(pszRootNode, "Level-2A_User_Product") ? - "General_Info.L2A_Product_Info" : "General_Info.Product_Info"); + const char* psPIPath = "General_Info.Product_Info"; + CPLXMLNode* psProductInfo = CPLGetXMLNode(psRoot, psPIPath); + if( psProductInfo == nullptr && + EQUAL(pszRootNode, "Level-2A_User_Product")) + { + psPIPath = "General_Info.L2A_Product_Info"; + psProductInfo = CPLGetXMLNode(psRoot, psPIPath); + } + if( psProductInfo == nullptr ) + { + CPLError(CE_Failure, CPLE_AppDefined, "Cannot find =%s", psPIPath); + return nullptr; + } int nDataTakeCounter = 1; for( CPLXMLNode* psIter = (psProductInfo ? psProductInfo->psChild : nullptr); psIter != nullptr; @@ -968,10 +1070,13 @@ char** SENTINEL2GetUserProductMetadata( CPLXMLNode* psMainMTD, } } - CPLXMLNode* psIC = CPLGetXMLNode(psRoot, - EQUAL(pszRootNode, "Level-2A_User_Product") ? - "General_Info.L2A_Product_Image_Characteristics" : - "General_Info.Product_Image_Characteristics"); + const char* psICPath = "General_Info.Product_Image_Characteristics"; + CPLXMLNode* psIC = CPLGetXMLNode(psRoot, psICPath); + if( psIC == nullptr ) + { + psICPath = "General_Info.L2A_Product_Image_Characteristics"; + psIC = CPLGetXMLNode(psRoot, psICPath); + } if( psIC != nullptr ) { for( CPLXMLNode* psIter = psIC->psChild; psIter != nullptr; @@ -1003,6 +1108,10 @@ char** SENTINEL2GetUserProductMetadata( CPLXMLNode* psMainMTD, // L2A specific CPLXMLNode* psQVL = CPLGetXMLNode(psIC, "L1C_L2A_Quantification_Values_List"); + if( psQVL == nullptr ) + { + psQVL = CPLGetXMLNode(psIC, "Quantification_Values_List"); + } for( CPLXMLNode* psIter = psQVL ? psQVL->psChild : nullptr; psIter != nullptr; psIter = psIter->psNext ) { @@ -1051,6 +1160,18 @@ char** SENTINEL2GetUserProductMetadata( CPLXMLNode* psMainMTD, psIter != nullptr; psIter = psIter->psNext ) { + // MSIL2A approach + if( psIter->psChild != nullptr && + psIter->psChild->psChild != nullptr && + psIter->psChild->psNext != nullptr && + psIter->psChild->psChild->eType == CXT_Text && + psIter->psChild->psNext->eType == CXT_Text ) + { + aosList.AddNameValue( psIter->psChild->psChild->pszValue, + psIter->psChild->psNext->pszValue); + continue; + } + if( psIter->eType != CXT_Element ) continue; if( psIter->psChild != nullptr && psIter->psChild->eType == CXT_Text ) @@ -1059,22 +1180,29 @@ char** SENTINEL2GetUserProductMetadata( CPLXMLNode* psMainMTD, psIter->psChild->pszValue ); } } - } - CPLXMLNode* psL2A_QII = CPLGetXMLNode(psRoot, "L2A_Quality_Indicators_Info"); - if( psL2A_QII != nullptr ) - { - CPLXMLNode* psICCQI = CPLGetXMLNode(psL2A_QII, "Image_Content_QI"); - for( CPLXMLNode* psIter = (psICCQI ? psICCQI->psChild : nullptr); - psIter != nullptr; - psIter = psIter->psNext ) + CPLXMLNode* psICCQI = CPLGetXMLNode(psQII, "Image_Content_QI"); + if( psICCQI == nullptr ) { - if( psIter->eType != CXT_Element ) - continue; - if( psIter->psChild != nullptr && psIter->psChild->eType == CXT_Text ) + CPLXMLNode* psL2A_QII = CPLGetXMLNode(psRoot, "L2A_Quality_Indicators_Info"); + if( psL2A_QII != nullptr ) { - aosList.AddNameValue( psIter->pszValue, - psIter->psChild->pszValue ); + psICCQI = CPLGetXMLNode(psL2A_QII, "Image_Content_QI"); + } + } + if( psICCQI != nullptr ) + { + for( CPLXMLNode* psIter = (psICCQI ? psICCQI->psChild : nullptr); + psIter != nullptr; + psIter = psIter->psNext ) + { + if( psIter->eType != CXT_Element ) + continue; + if( psIter->psChild != nullptr && psIter->psChild->eType == CXT_Text ) + { + aosList.AddNameValue( psIter->pszValue, + psIter->psChild->pszValue ); + } } } } @@ -1203,7 +1331,10 @@ GDALDataset *SENTINEL2Dataset::OpenL1BUserProduct( GDALOpenInfo * poOpenInfo ) { CPLXMLNode *psRoot = CPLParseXMLFile( poOpenInfo->pszFilename ); if( psRoot == nullptr ) + { + CPLDebug("SENTINEL2", "Cannot XML parse %s", poOpenInfo->pszFilename); return nullptr; + } char* pszOriginalXML = CPLSerializeXMLTree(psRoot); CPLString osOriginalXML; @@ -1229,6 +1360,7 @@ GDALDataset *SENTINEL2Dataset::OpenL1BUserProduct( GDALOpenInfo * poOpenInfo ) oSetResolutions, oMapResolutionsToBands) ) { + CPLDebug("SENTINEL2", "Failed to get resolution set"); return nullptr; } @@ -1238,6 +1370,7 @@ GDALDataset *SENTINEL2Dataset::OpenL1BUserProduct( GDALOpenInfo * poOpenInfo ) poOpenInfo->pszFilename, aosGranuleList) ) { + CPLDebug("SENTINEL2", "Failed to get granule list"); return nullptr; } @@ -1386,9 +1519,11 @@ char** SENTINEL2GetL1BGranuleMetadata( CPLXMLNode* psMainMTD ) static CPLString SENTINEL2GetTilename(const CPLString& osGranulePath, const CPLString& osGranuleName, const CPLString& osBandName, + const CPLString& osProductURI = CPLString(), bool bIsPreview = false, int nPrecisionL2A = 0) { + bool granuleNameMatchTilename = true; CPLString osJPEG2000Name(osGranuleName); if( osJPEG2000Name.size() > 7 && osJPEG2000Name[osJPEG2000Name.size()-7] == '_' && @@ -1460,12 +1595,20 @@ static CPLString SENTINEL2GetTilename(const CPLString& osGranulePath, osJPEG2000Name[11] = osBandName[2]; } } + else if( osProductURI.size() > 44 && + osProductURI.substr(3, 8) == "_MSIL2A_" ) + { + osTile += osProductURI.substr(38, 6); + osTile += osProductURI.substr(10, 16); + granuleNameMatchTilename = false; + } else { CPLDebug("SENTINEL2", "Invalid granule path: %s", osGranulePath.c_str()); } - osTile += osJPEG2000Name; + if( granuleNameMatchTilename ) + osTile += osJPEG2000Name; if( atoi(osBandName) > 0 ) { osTile += "_B"; @@ -1604,7 +1747,10 @@ GDALDataset *SENTINEL2Dataset::OpenL1BGranule( const char* pszFilename, { CPLXMLNode *psRoot = CPLParseXMLFile( pszFilename ); if( psRoot == nullptr ) + { + CPLDebug("SENTINEL2", "Cannot XML parse %s", pszFilename); return nullptr; + } char* pszOriginalXML = CPLSerializeXMLTree(psRoot); CPLString osOriginalXML; @@ -1776,7 +1922,10 @@ GDALDataset *SENTINEL2Dataset::OpenL1BSubdataset( GDALOpenInfo * poOpenInfo ) GDALDataset* poTmpDS = OpenL1BGranule( osFilename, &psRoot, nSubDSPrecision, &oSetBands); if( poTmpDS == nullptr ) + { + CPLDebug("SENTINEL2", "Failed to open L1B granule %s", osFilename.c_str()); return nullptr; + } SENTINEL2_CPLXMLNodeHolder oXMLHolder(psRoot); @@ -2155,6 +2304,110 @@ static bool SENTINEL2GetGranuleList_L1CSafeCompact(CPLXMLNode* psMainMTD, return true; } +/************************************************************************/ +/* SENTINEL2GetGranuleList_L2ASafeCompact() */ +/************************************************************************/ + +static bool SENTINEL2GetGranuleList_L2ASafeCompact(CPLXMLNode* psMainMTD, + const char* pszFilename, + std::vector& osList) +{ + const char* pszNodePath = "=Level-2A_User_Product.General_Info.Product_Info"; + CPLXMLNode* psProductInfo = CPLGetXMLNode(psMainMTD, pszNodePath); + if( psProductInfo == nullptr ) + { + pszNodePath = "=Level-2A_User_Product.General_Info.L2A_Product_Info"; + psProductInfo = CPLGetXMLNode(psMainMTD, pszNodePath); + } + if( psProductInfo == nullptr ) + { + CPLError(CE_Failure, CPLE_AppDefined, "Cannot find %s", + pszNodePath); + return false; + } + + CPLXMLNode* psProductOrganisation = + CPLGetXMLNode(psProductInfo, "Product_Organisation"); + if( psProductOrganisation == nullptr ) + { + psProductOrganisation = + CPLGetXMLNode(psProductInfo, "L2A_Product_Organisation"); + if( psProductOrganisation == nullptr ) + { + CPLError(CE_Failure, CPLE_AppDefined, "Cannot find %s", "Product_Organisation"); + return false; + } + } + + CPLString osDirname( CPLGetDirname(pszFilename) ); +#ifdef HAVE_READLINK + char szPointerFilename[2048]; + int nBytes = static_cast(readlink(pszFilename, szPointerFilename, + sizeof(szPointerFilename))); + if (nBytes != -1) + { + const int nOffset = + std::min(nBytes, static_cast(sizeof(szPointerFilename)-1)); + szPointerFilename[nOffset] = '\0'; + osDirname = CPLGetDirname(szPointerFilename); + } +#endif + + const char chSeparator = SENTINEL2GetPathSeparator(osDirname); + for(CPLXMLNode* psIter = psProductOrganisation->psChild; psIter != nullptr; + psIter = psIter->psNext ) + { + if( psIter->eType != CXT_Element || + !EQUAL(psIter->pszValue, "Granule_List") ) + { + continue; + } + for(CPLXMLNode* psIter2 = psIter->psChild; psIter2 != nullptr; + psIter2 = psIter2->psNext ) + { + if( psIter2->eType != CXT_Element || + !EQUAL(psIter2->pszValue, "Granule") ) + { + continue; + } + + const char* pszImageFile = CPLGetXMLValue(psIter2, "IMAGE_FILE", nullptr); + if( pszImageFile == nullptr ) + { + pszImageFile = CPLGetXMLValue(psIter2, "IMAGE_FILE_2A", nullptr); + if( pszImageFile == nullptr || strlen(pszImageFile) < 3 ) + { + CPLDebug("SENTINEL2", "Missing IMAGE_FILE element"); + continue; + } + } + L1CSafeCompatGranuleDescription oDesc; + oDesc.osBandPrefixPath = osDirname + chSeparator + pszImageFile; + if( oDesc.osBandPrefixPath.size() < 36 ) + { + CPLDebug("SENTINEL2", "Band prefix path too short"); + continue; + } + oDesc.osBandPrefixPath.resize( oDesc.osBandPrefixPath.size() - 36 ); + // GRANULE/L1C_T30TXT_A007999_20170102T111441/IMG_DATA/T30TXT_20170102T111442_B12_60m --> + // GRANULE/L1C_T30TXT_A007999_20170102T111441/MTD_TL.xml + oDesc.osMTDTLPath = osDirname + chSeparator + + CPLGetDirname(CPLGetDirname(pszImageFile)); + if( oDesc.osMTDTLPath.size() < 9 ) + { + CPLDebug("SENTINEL2", "MTDTL path too short"); + continue; + } + oDesc.osMTDTLPath.resize( oDesc.osMTDTLPath.size() - 9 ); + oDesc.osMTDTLPath = oDesc.osMTDTLPath + + chSeparator + "MTD_TL.xml"; + osList.push_back(oDesc); + } + } + + return true; +} + /************************************************************************/ /* OpenL1C_L2A() */ /************************************************************************/ @@ -2164,7 +2417,10 @@ GDALDataset *SENTINEL2Dataset::OpenL1C_L2A( const char* pszFilename, { CPLXMLNode *psRoot = CPLParseXMLFile( pszFilename ); if( psRoot == nullptr ) + { + CPLDebug("SENTINEL2", "Cannot XML parse %s", pszFilename); return nullptr; + } char* pszOriginalXML = CPLSerializeXMLTree(psRoot); CPLString osOriginalXML; @@ -2177,15 +2433,20 @@ GDALDataset *SENTINEL2Dataset::OpenL1C_L2A( const char* pszFilename, const char* pszNodePath = (eLevel == SENTINEL2_L1C ) ? "=Level-1C_User_Product.General_Info.Product_Info" : - "=Level-2A_User_Product.General_Info.L2A_Product_Info"; + "=Level-2A_User_Product.General_Info.Product_Info"; CPLXMLNode* psProductInfo = CPLGetXMLNode(psRoot, pszNodePath); + if( psProductInfo == nullptr && eLevel == SENTINEL2_L2A ) + { + pszNodePath = "=Level-2A_User_Product.General_Info.L2A_Product_Info"; + psProductInfo = CPLGetXMLNode(psRoot, pszNodePath); + } if( psProductInfo == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot find %s", pszNodePath); return nullptr; } - const bool bIsSafeCompact = eLevel == SENTINEL2_L1C && + const bool bIsSafeCompact = EQUAL(CPLGetXMLValue(psProductInfo, "Query_Options.PRODUCT_FORMAT", ""), "SAFE_COMPACT"); @@ -2195,6 +2456,9 @@ GDALDataset *SENTINEL2Dataset::OpenL1C_L2A( const char* pszFilename, { for(unsigned int i = 0; i < NB_BANDS; ++i) { + // L2 does not contain B10 + if( i == 10 && eLevel == SENTINEL2_L2A ) + continue; const SENTINEL2BandDescription * psBandDesc = &asBandDesc[i]; oSetResolutions.insert( psBandDesc->nResolution ); CPLString osName = psBandDesc->pszBandName + 1; /* skip B character */ @@ -2208,6 +2472,7 @@ GDALDataset *SENTINEL2Dataset::OpenL1C_L2A( const char* pszFilename, oSetResolutions, oMapResolutionsToBands) ) { + CPLDebug("SENTINEL2", "Failed to get resolution set"); return nullptr; } @@ -2215,9 +2480,18 @@ GDALDataset *SENTINEL2Dataset::OpenL1C_L2A( const char* pszFilename, if( bIsSafeCompact ) { std::vector aoL1CSafeCompactGranuleList; - if( !SENTINEL2GetGranuleList_L1CSafeCompact(psRoot, pszFilename, + if( eLevel == SENTINEL2_L1C && + !SENTINEL2GetGranuleList_L1CSafeCompact(psRoot, pszFilename, aoL1CSafeCompactGranuleList) ) { + CPLDebug("SENTINEL2", "Failed to get granule list"); + return nullptr; + } + else if ( eLevel == SENTINEL2_L2A && + !SENTINEL2GetGranuleList_L2ASafeCompact(psRoot, pszFilename, + aoL1CSafeCompactGranuleList) ) + { + CPLDebug("SENTINEL2", "Failed to get granule list"); return nullptr; } for(size_t i=0;i aosGranuleList; std::map > oMapResolutionsToBands; @@ -2775,15 +3081,27 @@ GDALDataset *SENTINEL2Dataset::OpenL1C_L2ASubdataset( GDALOpenInfo * poOpenInfo, { for(unsigned int i = 0; i < NB_BANDS; ++i) { + // L2 does not contain B10 + if( i == 10 && eLevel == SENTINEL2_L2A ) + continue; const SENTINEL2BandDescription * psBandDesc = &asBandDesc[i]; CPLString osName = psBandDesc->pszBandName + 1; /* skip B character */ if( atoi(osName) < 10 ) osName = "0" + osName; oMapResolutionsToBands[psBandDesc->nResolution].insert(osName); } - if( !SENTINEL2GetGranuleList_L1CSafeCompact(psRoot, osFilename, + if( eLevel == SENTINEL2_L1C && + !SENTINEL2GetGranuleList_L1CSafeCompact(psRoot, osFilename, + aoL1CSafeCompactGranuleList) ) + { + CPLDebug("SENTINEL2", "Failed to get granule list"); + return nullptr; + } + if( eLevel == SENTINEL2_L2A && + !SENTINEL2GetGranuleList_L2ASafeCompact(psRoot, osFilename, aoL1CSafeCompactGranuleList) ) { + CPLDebug("SENTINEL2", "Failed to get granule list"); return nullptr; } for(size_t i=0;i(aosBands.size());nBand++) { @@ -3019,13 +3353,20 @@ void SENTINEL2Dataset::AddL1CL2ABandMetadata(SENTINEL2Level eLevel, psIter = psIter->psNext ) { if( psIter->eType != CXT_Element || - !EQUAL(psIter->pszValue, "L2A_Scene_Classification_ID") ) + (!EQUAL(psIter->pszValue, "L2A_Scene_Classification_ID") && + !EQUAL(psIter->pszValue, "Scene_Classification_ID") ) ) { continue; } const char* pszText = CPLGetXMLValue(psIter, + "SCENE_CLASSIFICATION_TEXT", nullptr); + if( pszText == nullptr) + pszText = CPLGetXMLValue(psIter, "L2A_SCENE_CLASSIFICATION_TEXT", nullptr); const char* pszIdx = CPLGetXMLValue(psIter, + "SCENE_CLASSIFICATION_INDEX", nullptr); + if( pszIdx == nullptr ) + pszIdx = CPLGetXMLValue(psIter, "L2A_SCENE_CLASSIFICATION_INDEX", nullptr); if( pszText && pszIdx && atoi(pszIdx) >= 0 && atoi(pszIdx) < 100 ) { @@ -3053,6 +3394,7 @@ void SENTINEL2Dataset::AddL1CL2ABandMetadata(SENTINEL2Level eLevel, SENTINEL2Dataset* SENTINEL2Dataset::CreateL1CL2ADataset( SENTINEL2Level eLevel, + SENTINEL2ProductType pType, bool bIsSafeCompact, const std::vector& aosGranuleList, const std::vector& aoL1CSafeCompactGranuleList, @@ -3064,7 +3406,8 @@ SENTINEL2Dataset* SENTINEL2Dataset::CreateL1CL2ADataset( bool bAlpha, const std::vector& aosBands, int nSaturatedVal, - int nNodataVal) + int nNodataVal, + const CPLString& osProductURI) { /* Iterate over granule metadata to know the layer extent */ @@ -3212,7 +3555,7 @@ SENTINEL2Dataset* SENTINEL2Dataset::CreateL1CL2ADataset( const SENTINEL2GranuleInfo& oGranuleInfo = aosGranuleInfoList[iSrc]; CPLString osTile; - if( bIsSafeCompact ) + if( bIsSafeCompact && eLevel != SENTINEL2_L2A ) { if( bIsTCI ) { @@ -3236,8 +3579,18 @@ SENTINEL2Dataset* SENTINEL2Dataset::CreateL1CL2ADataset( oGranuleInfo.osPath, CPLGetFilename(oGranuleInfo.osPath), osBandName, + osProductURI, bIsPreview, (eLevel == SENTINEL2_L1C) ? 0 : nSubDSPrecision); + if( bIsSafeCompact && eLevel == SENTINEL2_L2A && + pType == MSI2Ap && osTile.size() >= 34 ) + { + osTile.insert(osTile.size() - 34, "L2A_"); + } + if( bIsTCI && osTile.size() >= 14 ) + { + osTile.replace(osTile.size() - 11, 3, "TCI"); + } } bool bTileFound = false; @@ -3416,6 +3769,7 @@ GDALDataset* SENTINEL2Dataset::OpenL1CTileSubdataset( GDALOpenInfo * poOpenInfo std::vector aosNonJP2Files; SENTINEL2Dataset* poDS = CreateL1CL2ADataset(SENTINEL2_L1C, + MSI2A, false, // bIsSafeCompact aosGranuleList, std::vector(), @@ -3427,7 +3781,8 @@ GDALDataset* SENTINEL2Dataset::OpenL1CTileSubdataset( GDALOpenInfo * poOpenInfo bAlpha, aosBands, nSaturatedVal, - nNodataVal); + nNodataVal, + CPLString()); if( poDS == nullptr ) { delete poTmpDS; From 1f32f6fdbfd2fd352047db41d316d8afbe3c3319 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 30 Nov 2018 01:05:06 +0100 Subject: [PATCH 091/488] gdal2tiles: rename 'tilesize' and 'tileSize' variables to 'tile_size' to have uniform spelling, and fix exception (suggested by @psusmars, fixes #1127) --- gdal/swig/python/scripts/gdal2tiles.py | 160 ++++++++++++------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/gdal/swig/python/scripts/gdal2tiles.py b/gdal/swig/python/scripts/gdal2tiles.py index 668abeda1f6c..37eb380ff1f8 100755 --- a/gdal/swig/python/scripts/gdal2tiles.py +++ b/gdal/swig/python/scripts/gdal2tiles.py @@ -207,11 +207,11 @@ class GlobalMercator(object): AUTHORITY["EPSG","9001"]]] """ - def __init__(self, tileSize=256): + def __init__(self, tile_size=256): "Initialize the TMS Global Mercator pyramid" - self.tileSize = tileSize - self.initialResolution = 2 * math.pi * 6378137 / self.tileSize - # 156543.03392804062 for tileSize 256 pixels + self.tile_size = tile_size + self.initialResolution = 2 * math.pi * 6378137 / self.tile_size + # 156543.03392804062 for tile_size 256 pixels self.originShift = 2 * math.pi * 6378137 / 2.0 # 20037508.342789244 @@ -252,14 +252,14 @@ def MetersToPixels(self, mx, my, zoom): def PixelsToTile(self, px, py): "Returns a tile covering region in given pixel coordinates" - tx = int(math.ceil(px / float(self.tileSize)) - 1) - ty = int(math.ceil(py / float(self.tileSize)) - 1) + tx = int(math.ceil(px / float(self.tile_size)) - 1) + ty = int(math.ceil(py / float(self.tile_size)) - 1) return tx, ty def PixelsToRaster(self, px, py, zoom): "Move the origin of pixel coordinates to top-left corner" - mapSize = self.tileSize << zoom + mapSize = self.tile_size << zoom return px, mapSize - py def MetersToTile(self, mx, my, zoom): @@ -271,8 +271,8 @@ def MetersToTile(self, mx, my, zoom): def TileBounds(self, tx, ty, zoom): "Returns bounds of the given tile in EPSG:3857 coordinates" - minx, miny = self.PixelsToMeters(tx * self.tileSize, ty * self.tileSize, zoom) - maxx, maxy = self.PixelsToMeters((tx + 1) * self.tileSize, (ty + 1) * self.tileSize, zoom) + minx, miny = self.PixelsToMeters(tx * self.tile_size, ty * self.tile_size, zoom) + maxx, maxy = self.PixelsToMeters((tx + 1) * self.tile_size, (ty + 1) * self.tile_size, zoom) return (minx, miny, maxx, maxy) def TileLatLonBounds(self, tx, ty, zoom): @@ -287,7 +287,7 @@ def TileLatLonBounds(self, tx, ty, zoom): def Resolution(self, zoom): "Resolution (meters/pixel) for given zoom level (measured at Equator)" - # return (2 * math.pi * 6378137) / (self.tileSize * 2**zoom) + # return (2 * math.pi * 6378137) / (self.tile_size * 2**zoom) return self.initialResolution / (2**zoom) def ZoomForPixelSize(self, pixelSize): @@ -356,17 +356,17 @@ class GlobalGeodetic(object): WMS, KML Web Clients, Google Earth TileMapService """ - def __init__(self, tmscompatible, tileSize=256): - self.tileSize = tileSize + def __init__(self, tmscompatible, tile_size=256): + self.tile_size = tile_size if tmscompatible is not None: # Defaults the resolution factor to 0.703125 (2 tiles @ level 0) # Adhers to OSGeo TMS spec # http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic - self.resFact = 180.0 / self.tileSize + self.resFact = 180.0 / self.tile_size else: # Defaults the resolution factor to 1.40625 (1 tile @ level 0) # Adheres OpenLayers, MapProxy, etc default resolution for WMTS - self.resFact = 360.0 / self.tileSize + self.resFact = 360.0 / self.tile_size def LonLatToPixels(self, lon, lat, zoom): "Converts lon/lat to pixel coordinates in given zoom of the EPSG:4326 pyramid" @@ -379,8 +379,8 @@ def LonLatToPixels(self, lon, lat, zoom): def PixelsToTile(self, px, py): "Returns coordinates of the tile covering region in pixel coordinates" - tx = int(math.ceil(px / float(self.tileSize)) - 1) - ty = int(math.ceil(py / float(self.tileSize)) - 1) + tx = int(math.ceil(px / float(self.tile_size)) - 1) + ty = int(math.ceil(py / float(self.tile_size)) - 1) return tx, ty def LonLatToTile(self, lon, lat, zoom): @@ -406,10 +406,10 @@ def TileBounds(self, tx, ty, zoom): "Returns bounds of the given tile" res = self.resFact / 2**zoom return ( - tx * self.tileSize * res - 180, - ty * self.tileSize * res - 90, - (tx + 1) * self.tileSize * res - 180, - (ty + 1) * self.tileSize * res - 90 + tx * self.tile_size * res - 180, + ty * self.tile_size * res - 90, + (tx + 1) * self.tile_size * res - 180, + (ty + 1) * self.tile_size * res - 90 ) def TileLatLonBounds(self, tx, ty, zoom): @@ -424,13 +424,13 @@ class Zoomify(object): ---------------------------------------- """ - def __init__(self, width, height, tilesize=256, tileformat='jpg'): + def __init__(self, width, height, tile_size=256, tileformat='jpg'): """Initialization of the Zoomify tile tree""" - self.tilesize = tilesize + self.tile_size = tile_size self.tileformat = tileformat imagesize = (width, height) - tiles = (math.ceil(width / tilesize), math.ceil(height / tilesize)) + tiles = (math.ceil(width / tile_size), math.ceil(height / tile_size)) # Size (in tiles) for each tier of pyramid. self.tierSizeInTiles = [] @@ -440,9 +440,9 @@ def __init__(self, width, height, tilesize=256, tileformat='jpg'): self.tierImageSize = [] self.tierImageSize.append(imagesize) - while (imagesize[0] > tilesize or imagesize[1] > tilesize): + while (imagesize[0] > tile_size or imagesize[1] > tile_size): imagesize = (math.floor(imagesize[0] / 2), math.floor(imagesize[1] / 2)) - tiles = (math.ceil(imagesize[0] / tilesize), math.ceil(imagesize[1] / tilesize)) + tiles = (math.ceil(imagesize[0] / tile_size), math.ceil(imagesize[1] / tile_size)) self.tierSizeInTiles.append(tiles) self.tierImageSize.append(imagesize) @@ -484,7 +484,7 @@ def exit_with_error(message, details=""): sys.exit(2) -def generate_kml(tx, ty, tz, tileext, tilesize, tileswne, options, children=None, **args): +def generate_kml(tx, ty, tz, tileext, tile_size, tileswne, options, children=None, **args): """ Template for the KML. Returns filled string. """ @@ -493,13 +493,13 @@ def generate_kml(tx, ty, tz, tileext, tilesize, tileswne, options, children=None args['tx'], args['ty'], args['tz'] = tx, ty, tz args['tileformat'] = tileext - if 'tilesize' not in args: - args['tilesize'] = tilesize + if 'tile_size' not in args: + args['tile_size'] = tile_size if 'minlodpixels' not in args: - args['minlodpixels'] = int(args['tilesize'] / 2) + args['minlodpixels'] = int(args['tile_size'] / 2) if 'maxlodpixels' not in args: - args['maxlodpixels'] = int(args['tilesize'] * 8) + args['maxlodpixels'] = int(args['tile_size'] * 8) if children == []: args['maxlodpixels'] = -1 @@ -599,7 +599,7 @@ def scale_query_to_tile(dsquery, dstile, tiledriver, options, tilefilename=''): """Scales down query dataset to the tile dataset""" querysize = dsquery.RasterXSize - tilesize = dstile.RasterXSize + tile_size = dstile.RasterXSize tilebands = dstile.RasterCount if options.resampling == 'average': @@ -621,7 +621,7 @@ def scale_query_to_tile(dsquery, dstile, tiledriver, options, tilefilename=''): array[:, :, i] = gdalarray.BandReadAsArray(dsquery.GetRasterBand(i + 1), 0, 0, querysize, querysize) im = Image.fromarray(array, 'RGBA') # Always four bands - im1 = im.resize((tilesize, tilesize), Image.ANTIALIAS) + im1 = im.resize((tile_size, tile_size), Image.ANTIALIAS) if os.path.exists(tilefilename): im0 = Image.open(tilefilename) im1 = Image.composite(im1, im0, im1) @@ -645,8 +645,8 @@ def scale_query_to_tile(dsquery, dstile, tiledriver, options, tilefilename=''): gdal_resampling = gdal.GRA_Lanczos # Other algorithms are implemented by gdal.ReprojectImage(). - dsquery.SetGeoTransform((0.0, tilesize / float(querysize), 0.0, 0.0, 0.0, - tilesize / float(querysize))) + dsquery.SetGeoTransform((0.0, tile_size / float(querysize), 0.0, 0.0, 0.0, + tile_size / float(querysize))) dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) res = gdal.ReprojectImage(dsquery, dstile, None, None, gdal_resampling) @@ -897,7 +897,7 @@ def create_base_tile(tile_job_info, tile_detail, queue=None): dataBandsCount = tile_job_info.nb_data_bands output = tile_job_info.output_file_path tileext = tile_job_info.tile_extension - tilesize = tile_job_info.tile_size + tile_size = tile_job_info.tile_size options = tile_job_info.options tilebands = dataBandsCount + 1 @@ -929,7 +929,7 @@ def create_base_tile(tile_job_info, tile_detail, queue=None): # Tile dataset in memory tilefilename = os.path.join( output, str(tz), str(tx), "%s.%s" % (ty, tileext)) - dstile = mem_drv.Create('', tilesize, tilesize, tilebands) + dstile = mem_drv.Create('', tile_size, tile_size, tilebands) data = alpha = None @@ -937,8 +937,8 @@ def create_base_tile(tile_job_info, tile_detail, queue=None): print("\tReadRaster Extent: ", (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) - # Query is in 'nearest neighbour' but can be bigger in then the tilesize - # We scale down the query to the tilesize by supplied algorithm. + # Query is in 'nearest neighbour' but can be bigger in then the tile_size + # We scale down the query to the tile_size by supplied algorithm. if rxsize != 0 and rysize != 0 and wxsize != 0 and wysize != 0: alpha = alphaband.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize) @@ -953,7 +953,7 @@ def create_base_tile(tile_job_info, tile_detail, queue=None): # The tile in memory is a transparent file by default. Write pixel values into it if # any if data: - if tilesize == querysize: + if tile_size == querysize: # Use the ReadRaster result directly in tiles ('nearest neighbour' query) dstile.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1, dataBandsCount + 1))) @@ -964,7 +964,7 @@ def create_base_tile(tile_job_info, tile_detail, queue=None): # nearest neighbour) # TODO: Use directly 'near' for WaveLet files else: - # Big ReadRaster query in memory scaled to the tilesize - all but 'near' + # Big ReadRaster query in memory scaled to the tile_size - all but 'near' # algo dsquery = mem_drv.Create('', querysize, querysize, tilebands) # TODO: fill the null value in case a tile without alpha is produced (now @@ -1365,7 +1365,7 @@ def __init__(self, input_file, output_folder, options): self.in_srs_wkt = None # Tile format - self.tilesize = 256 + self.tile_size = 256 self.tiledriver = 'PNG' self.tileext = 'png' self.tmp_dir = tempfile.mkdtemp() @@ -1379,7 +1379,7 @@ def __init__(self, input_file, output_folder, options): self.scaledquery = True # How big should be query window be for scaling down # Later on reset according the chosen resampling algorightm - self.querysize = 4 * self.tilesize + self.querysize = 4 * self.tile_size # Should we use Read on the input file for generating overview tiles? # Note: Modified later by open_input() @@ -1391,10 +1391,10 @@ def __init__(self, input_file, output_folder, options): self.options = options if self.options.resampling == 'near': - self.querysize = self.tilesize + self.querysize = self.tile_size elif self.options.resampling == 'bilinear': - self.querysize = self.tilesize * 2 + self.querysize = self.tile_size * 2 # User specified zoom levels self.tminz = None @@ -1574,7 +1574,7 @@ def open_input(self): self.out_gt[1] * max(self.warped_input_dataset.RasterXSize, self.warped_input_dataset.RasterYSize) / - float(self.tilesize)) + float(self.tile_size)) # Get the maximal zoom level # (closest possible zoom level up on the resolution of raster) @@ -1618,7 +1618,7 @@ def open_input(self): self.out_gt[1] * max(self.warped_input_dataset.RasterXSize, self.warped_input_dataset.RasterYSize) / - float(self.tilesize)) + float(self.tile_size)) # Get the maximal zoom level # (closest possible zoom level up on the resolution of raster) @@ -1634,8 +1634,8 @@ def log2(x): return math.log10(x) / math.log10(2) self.nativezoom = int( - max(math.ceil(log2(self.warped_input_dataset.RasterXSize / float(self.tilesize))), - math.ceil(log2(self.warped_input_dataset.RasterYSize / float(self.tilesize))))) + max(math.ceil(log2(self.warped_input_dataset.RasterXSize / float(self.tile_size))), + math.ceil(log2(self.warped_input_dataset.RasterYSize / float(self.tile_size))))) if self.options.verbose: print("Native zoom of the raster:", self.nativezoom) @@ -1652,7 +1652,7 @@ def log2(x): self.tminmax = list(range(0, self.tmaxz + 1)) self.tsize = list(range(0, self.tmaxz + 1)) for tz in range(0, self.tmaxz + 1): - tsize = 2.0**(self.nativezoom - tz) * self.tilesize + tsize = 2.0**(self.nativezoom - tz) * self.tile_size tminx, tminy = 0, 0 tmaxx = int(math.ceil(self.warped_input_dataset.RasterXSize / tsize)) - 1 tmaxy = int(math.ceil(self.warped_input_dataset.RasterYSize / tsize)) - 1 @@ -1665,10 +1665,10 @@ def log2(x): def rastertileswne(x, y, z): pixelsizex = (2**(self.tmaxz - z) * self.out_gt[1]) # X-pixel size in level - west = self.out_gt[0] + x * self.tilesize * pixelsizex - east = west + self.tilesize * pixelsizex - south = self.ominy + y * self.tilesize * pixelsizex - north = south + self.tilesize * pixelsizex + west = self.out_gt[0] + x * self.tile_size * pixelsizex + east = west + self.tile_size * pixelsizex + south = self.ominy + y * self.tile_size * pixelsizex + north = south + self.tile_size * pixelsizex if not self.isepsg4326: # Transformation to EPSG:4326 (WGS84 datum) west, south = ct.TransformPoint(west, south)[:2] @@ -1765,7 +1765,7 @@ def generate_metadata(self): os.path.exists(os.path.join(self.output_folder, 'doc.kml'))): with open(os.path.join(self.output_folder, 'doc.kml'), 'wb') as f: f.write(generate_kml( - None, None, None, self.tileext, self.tilesize, self.tileswne, + None, None, None, self.tileext, self.tile_size, self.tileswne, self.options, children ).encode('utf-8')) @@ -1843,11 +1843,11 @@ def generate_base_tiles(self): else: # 'raster' profile: - tsize = int(self.tsize[tz]) # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) # tile_size in raster coordinates for actual zoom xsize = self.warped_input_dataset.RasterXSize # size of the raster in pixels ysize = self.warped_input_dataset.RasterYSize if tz >= self.nativezoom: - querysize = self.tilesize + querysize = self.tile_size rx = (tx) * tsize rxsize = 0 @@ -1864,10 +1864,10 @@ def generate_base_tiles(self): ry = ysize - (ty * tsize) - rysize wx, wy = 0, 0 - wxsize = int(rxsize / float(tsize) * self.tilesize) - wysize = int(rysize / float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize + wxsize = int(rxsize / float(tsize) * self.tile_size) + wysize = int(rysize / float(tsize) * self.tile_size) + if wysize != self.tile_size: + wy = self.tile_size - wysize # Read the source raster if anything is going inside the tile as per the computed # geo_query @@ -1884,7 +1884,7 @@ def generate_base_tiles(self): output_file_path=self.output_folder, tile_extension=self.tileext, tile_driver=self.tiledriver, - tile_size=self.tilesize, + tile_size=self.tile_size, kml=self.kml, tminmax=self.tminmax, tminz=self.tminz, @@ -1947,13 +1947,13 @@ def generate_tilemapresource(self): """ Template for tilemapresource.xml. Returns filled string. Expected variables: title, north, south, east, west, isepsg4326, projection, publishurl, - zoompixels, tilesize, tileformat, profile + zoompixels, tile_size, tileformat, profile """ args = {} args['title'] = self.options.title args['south'], args['west'], args['north'], args['east'] = self.swne - args['tilesize'] = self.tilesize + args['tile_size'] = self.tile_size args['tileformat'] = self.tileext args['publishurl'] = self.options.url args['profile'] = self.options.profile @@ -1976,7 +1976,7 @@ def generate_tilemapresource(self): %(srs)s - + """ % args # noqa for z in range(self.tminz, self.tmaxz + 1): @@ -1998,7 +1998,7 @@ def generate_googlemaps(self): """ Template for googlemaps.html implementing Overlay of tiles for 'mercator' profile. It returns filled string. Expected variables: - title, googlemapskey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, + title, googlemapskey, north, south, east, west, minzoom, maxzoom, tile_size, tileformat, publishurl """ args = {} @@ -2007,7 +2007,7 @@ def generate_googlemaps(self): args['south'], args['west'], args['north'], args['east'] = self.swne args['minzoom'] = self.tminz args['maxzoom'] = self.tmaxz - args['tilesize'] = self.tilesize + args['tile_size'] = self.tile_size args['tileformat'] = self.tileext args['publishurl'] = self.options.url args['copyright'] = self.options.copyright @@ -2295,7 +2295,7 @@ def generate_leaflet(self): """ Template for leaflet.html implementing overlay of tiles for 'mercator' profile. It returns filled string. Expected variables: - title, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + title, north, south, east, west, minzoom, maxzoom, tile_size, tileformat, publishurl """ args = {} @@ -2307,7 +2307,7 @@ def generate_leaflet(self): args['minzoom'] = self.tminz args['maxzoom'] = self.tmaxz args['beginzoom'] = self.tmaxz - args['tilesize'] = self.tilesize # not used + args['tile_size'] = self.tile_size # not used args['tileformat'] = self.tileext args['publishurl'] = self.options.url # not used args['copyright'] = self.options.copyright.replace('"', '\\"') @@ -2427,7 +2427,7 @@ def generate_openlayers(self): Template for openlayers.html implementing overlay of available Spherical Mercator layers. It returns filled string. Expected variables: - title, bingkey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + title, bingkey, north, south, east, west, minzoom, maxzoom, tile_size, tileformat, publishurl """ args = {} @@ -2436,7 +2436,7 @@ def generate_openlayers(self): args['south'], args['west'], args['north'], args['east'] = self.swne args['minzoom'] = self.tminz args['maxzoom'] = self.tmaxz - args['tilesize'] = self.tilesize + args['tile_size'] = self.tile_size args['tileformat'] = self.tileext args['publishurl'] = self.options.url args['copyright'] = self.options.copyright @@ -2638,8 +2638,8 @@ def generate_openlayers(self): function getURL(bounds) { bounds = this.adjustBounds(bounds); var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tile_size.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tile_size.h)); var z = this.getServerZoom(); if (this.map.baseLayer.CLASS_NAME === 'OpenLayers.Layer.Bing') { z+=1; @@ -2662,8 +2662,8 @@ def generate_openlayers(self): function getURL(bounds) { bounds = this.adjustBounds(bounds); var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tile_size.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tile_size.h)); var z = this.getServerZoom()%(tmsoffset)s; var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; var url = this.url; @@ -2683,8 +2683,8 @@ def generate_openlayers(self): function getURL(bounds) { bounds = this.adjustBounds(bounds); var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tile_size.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tile_size.h)); var z = this.getServerZoom(); var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; var url = this.url; @@ -2815,10 +2815,10 @@ def get_tile_swne(tile_job_info, options): def rastertileswne(x, y, z): pixelsizex = (2 ** (tile_job_info.tmaxz - z) * tile_job_info.out_geo_trans[1]) - west = tile_job_info.out_geo_trans[0] + x * tile_job_info.tilesize * pixelsizex - east = west + tile_job_info.tilesize * pixelsizex - south = tile_job_info.ominy + y * tile_job_info.tilesize * pixelsizex - north = south + tile_job_info.tilesize * pixelsizex + west = tile_job_info.out_geo_trans[0] + x * tile_job_info.tile_size * pixelsizex + east = west + tile_job_info.tile_size * pixelsizex + south = tile_job_info.ominy + y * tile_job_info.tile_size * pixelsizex + north = south + tile_job_info.tile_size * pixelsizex if not tile_job_info.is_epsg_4326: # Transformation to EPSG:4326 (WGS84 datum) west, south = ct.TransformPoint(west, south)[:2] From 444c9ae25b192a87ac1bf81747a6d75acff36a32 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 1 Dec 2018 14:11:29 +0100 Subject: [PATCH 092/488] Overview / RasterIO resampling: do not use nodata value as a valid output value (complementary fix to 41babc2c7cb61ab76c6a3772735b20e6610eca52) --- autotest/gdrivers/vrtpansharpen.py | 4 +- gdal/gcore/gdaldataset.cpp | 14 +++++++ gdal/gcore/overview.cpp | 66 +++++++++++++++++++++++------- 3 files changed, 68 insertions(+), 16 deletions(-) diff --git a/autotest/gdrivers/vrtpansharpen.py b/autotest/gdrivers/vrtpansharpen.py index 677c0ec86843..b7f7f6195e61 100755 --- a/autotest/gdrivers/vrtpansharpen.py +++ b/autotest/gdrivers/vrtpansharpen.py @@ -1681,7 +1681,7 @@ def vrtpansharpen_9(): gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] - if cs not in ([4640, 9158, 54450],): + if cs not in ([6950, 11745, 8965],): gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1723,7 +1723,7 @@ def vrtpansharpen_9(): gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] - if cs not in ([4640, 9158, 54450],): + if cs not in ([6950, 11745, 8965],): gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/gdal/gcore/gdaldataset.cpp b/gdal/gcore/gdaldataset.cpp index b6a8b629def6..5af8f4ddc7e9 100644 --- a/gdal/gcore/gdaldataset.cpp +++ b/gdal/gcore/gdaldataset.cpp @@ -1588,6 +1588,8 @@ CPLErr GDALDataset::IRasterIO( GDALRWFlag eRWFlag, int nFirstMaskFlags = 0; GDALRasterBand *poFirstMaskBand = nullptr; int nOKBands = 0; + + // Check if bands share the same mask band for( int i = 0; i < nBandCount; ++i ) { GDALRasterBand *poBand = GetRasterBand(panBandMap[i]); @@ -1610,6 +1612,12 @@ CPLErr GDALDataset::IRasterIO( GDALRWFlag eRWFlag, { eFirstBandDT = eDT; nFirstMaskFlags = poBand->GetMaskFlags(); + if( nFirstMaskFlags == GMF_NODATA) + { + // The dataset-level resampling code is not ready for nodata + // Fallback to band-level resampling + break; + } poFirstMaskBand = poBand->GetMaskBand(); } else @@ -1619,6 +1627,12 @@ CPLErr GDALDataset::IRasterIO( GDALRWFlag eRWFlag, break; } int nMaskFlags = poBand->GetMaskFlags(); + if( nMaskFlags == GMF_NODATA) + { + // The dataset-level resampling code is not ready for nodata + // Fallback to band-level resampling + break; + } GDALRasterBand *poMaskBand = poBand->GetMaskBand(); if( nFirstMaskFlags == GMF_ALL_VALID && nMaskFlags == GMF_ALL_VALID ) diff --git a/gdal/gcore/overview.cpp b/gdal/gcore/overview.cpp index cc0c2b6636e5..8c7b83d9a8c3 100644 --- a/gdal/gcore/overview.cpp +++ b/gdal/gcore/overview.cpp @@ -1879,32 +1879,70 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, { if( !bHasNoData ) fNoDataValue = 0.0f; + const auto dstDataType = papoDstBands[0]->GetRasterDataType(); const float fReplacementVal = GetReplacementValueIfNoData( - papoDstBands[0]->GetRasterDataType(), bHasNoData, fNoDataValue); + dstDataType, bHasNoData, fNoDataValue); // cppcheck-suppress unreadVariable - const int isIntegerDT = GDALDataTypeIsInteger(papoDstBands[0]->GetRasterDataType()); + const int isIntegerDT = GDALDataTypeIsInteger(dstDataType); const auto nNodataValueInt64 = static_cast(fNoDataValue); + // TODO: we should have some generic function to do this. + float fDstMin = -std::numeric_limits::max(); + float fDstMax = std::numeric_limits::max(); + if( dstDataType == GDT_Byte ) + { + fDstMin = std::numeric_limits::min(); + fDstMax = std::numeric_limits::max(); + } + else if( dstDataType == GDT_UInt16 ) + { + fDstMin = std::numeric_limits::min(); + fDstMax = std::numeric_limits::max(); + } + else if( dstDataType == GDT_Int16 ) + { + fDstMin = std::numeric_limits::min(); + fDstMax = std::numeric_limits::max(); + } + else if( dstDataType == GDT_UInt32 ) + { + fDstMin = static_cast(std::numeric_limits::min()); + fDstMax = static_cast(std::numeric_limits::max()); + } + else if( dstDataType == GDT_Int32 ) + { + fDstMin = static_cast(std::numeric_limits::min()); + fDstMax = static_cast(std::numeric_limits::max()); + } + auto replaceValIfNodata = - [bHasNoData, isIntegerDT, nNodataValueInt64, fNoDataValue, fReplacementVal](float fVal) + [bHasNoData, isIntegerDT, fDstMin, fDstMax, nNodataValueInt64, + fNoDataValue, fReplacementVal](float fVal) { - if( bHasNoData ) + if( !bHasNoData ) + return fVal; + + // Clamp value before comparing to nodata: this is only needed for + // kernels with negative weights (Lanczos) + float fClamped = fVal; + if( fClamped < fDstMin ) + fClamped = fDstMin; + else if( fClamped > fDstMax ) + fClamped = fDstMax; + if( isIntegerDT ) { - if( isIntegerDT ) - { - if( nNodataValueInt64 == static_cast(fVal) ) - { - // Do not use the nodata value - return fReplacementVal; - } - } - else if( fNoDataValue == fVal ) + if( nNodataValueInt64 == static_cast(std::round(fClamped)) ) { // Do not use the nodata value return fReplacementVal; } } - return fVal; + else if( fNoDataValue == fClamped ) + { + // Do not use the nodata value + return fReplacementVal; + } + return fClamped; }; /* -------------------------------------------------------------------- */ From 06f3b061a9a2f0a89c71e4806817fd2680e3537d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 1 Dec 2018 14:51:42 +0100 Subject: [PATCH 093/488] Fix spelling (and unintended profanity) [ci skip] --- gdal/frmts/gtiff/gt_wkt_srs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/frmts/gtiff/gt_wkt_srs.cpp b/gdal/frmts/gtiff/gt_wkt_srs.cpp index d03e7cd3552e..9f5e7d71a15a 100644 --- a/gdal/frmts/gtiff/gt_wkt_srs.cpp +++ b/gdal/frmts/gtiff/gt_wkt_srs.cpp @@ -2333,7 +2333,7 @@ int GTIFSetFromOGISDefnEx( GTIF * psGTIF, const char *pszOGCWKT, { // Anything we can't map, store as an ESRI PE string with a citation key. char *pszPEString = nullptr; - // We shit a bit, but if we have a custom_proj4, do not morph to ESRI + // We cheat a bit, but if we have a custom_proj4, do not morph to ESRI // so as to keep the EXTENSION PROJ4 node if( !(bUnknownProjection && poSRS->GetExtension("PROJCS", "PROJ4", nullptr) != nullptr) ) From a4cdcbd7fdd8249962485d15c4fb3c86d9e83260 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 1 Dec 2018 15:08:36 +0100 Subject: [PATCH 094/488] fix cppcheck false positive --- gdal/gcore/overview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdal/gcore/overview.cpp b/gdal/gcore/overview.cpp index 8c7b83d9a8c3..eeeb1b16bcea 100644 --- a/gdal/gcore/overview.cpp +++ b/gdal/gcore/overview.cpp @@ -1911,7 +1911,9 @@ GDALResampleChunk32R_ConvolutionT( double dfXRatioDstToSrc, } else if( dstDataType == GDT_Int32 ) { + // cppcheck-suppress unreadVariable fDstMin = static_cast(std::numeric_limits::min()); + // cppcheck-suppress unreadVariable fDstMax = static_cast(std::numeric_limits::max()); } From 1e082b59d067cf2edf5713e15101c0b369d37e9a Mon Sep 17 00:00:00 2001 From: drons Date: Sun, 2 Dec 2018 22:16:23 +0300 Subject: [PATCH 095/488] OGR: Restore font field at OGRStyleSymbol Partial revert b98fd4b51bda2f5de0b8c5876b704e5a2fa3ca95 --- gdal/ogr/ogr_core.h | 2 +- gdal/ogr/ogr_featurestyle.h | 4 ++++ gdal/ogr/ogrfeaturestyle.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdal/ogr/ogr_core.h b/gdal/ogr/ogr_core.h index adcbb14c25d7..fe2b53e3007b 100644 --- a/gdal/ogr/ogr_core.h +++ b/gdal/ogr/ogr_core.h @@ -873,7 +873,7 @@ typedef enum ogr_style_tool_param_symbol_id OGRSTSymbolPerp = 7, /**< Perpendicular */ OGRSTSymbolOffset = 8, /**< Offset */ OGRSTSymbolPriority = 9, /**< Priority */ - OGRSTSymbolFontName = 10, /**< OBSOLETE; do not use */ + OGRSTSymbolFontName = 10, /**< Font name */ OGRSTSymbolOColor = 11, /**< Outline color */ #ifndef DOXYGEN_SKIP OGRSTSymbolLast = 12 diff --git a/gdal/ogr/ogr_featurestyle.h b/gdal/ogr/ogr_featurestyle.h index fd6bdc3750ac..2cf653c3b91a 100644 --- a/gdal/ogr/ogr_featurestyle.h +++ b/gdal/ogr/ogr_featurestyle.h @@ -399,6 +399,10 @@ class CPL_DLL OGRStyleSymbol : public OGRStyleTool void SetPerp(double dfPerp){SetParamDbl(OGRSTSymbolPerp,dfPerp );} int Priority(GBool &bDefault){return GetParamNum(OGRSTSymbolPriority,bDefault);} void SetPriority(int nPriority){SetParamNum(OGRSTSymbolPriority,nPriority);} + const char *FontName(GBool &bDefault) + {return GetParamStr(OGRSTSymbolFontName,bDefault);} + void SetFontName(const char *pszFontName) + {SetParamStr(OGRSTSymbolFontName,pszFontName);} const char *OColor(GBool &bDefault){return GetParamStr(OGRSTSymbolOColor,bDefault);} void SetOColor(const char *pszColor){SetParamStr(OGRSTSymbolOColor,pszColor);} diff --git a/gdal/ogr/ogrfeaturestyle.cpp b/gdal/ogr/ogrfeaturestyle.cpp index b2e2bb063e9f..b46c238f132e 100644 --- a/gdal/ogr/ogrfeaturestyle.cpp +++ b/gdal/ogr/ogrfeaturestyle.cpp @@ -89,7 +89,7 @@ static const OGRStyleParamId asStyleSymbol[] = {OGRSTSymbolPerp, "dp", TRUE, OGRSTypeDouble}, {OGRSTSymbolOffset, "di", TRUE, OGRSTypeDouble}, {OGRSTSymbolPriority, "l", FALSE, OGRSTypeInteger}, - {-1, nullptr, FALSE, OGRSTypeUnused}, // was OGRSTSymbolFontName + {OGRSTSymbolFontName, "f", FALSE, OGRSTypeString}, {OGRSTSymbolOColor, "o", FALSE, OGRSTypeString} }; From 387984b9f4eab1a3ac4e729ee944b36191997a88 Mon Sep 17 00:00:00 2001 From: drons Date: Sun, 2 Dec 2018 22:21:35 +0300 Subject: [PATCH 096/488] MITAB: Expose symbol's font family to restored OGRStyleSymbol 'f' field --- autotest/ogr/data/all_geoms.mif.golden.csv | 2 +- gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/autotest/ogr/data/all_geoms.mif.golden.csv b/autotest/ogr/data/all_geoms.mif.golden.csv index d9f3297ab009..1a621a580706 100644 --- a/autotest/ogr/data/all_geoms.mif.golden.csv +++ b/autotest/ogr/data/all_geoms.mif.golden.csv @@ -1,7 +1,7 @@ WKT,ogr_style "POINT (0 1)","SYMBOL(a:0,c:#000000,s:12pt,id:""mapinfo-sym-35,ogr-sym-10"")" "POINT (2 3)","SYMBOL(a:0,c:#000000,s:1pt,id:""mapinfo-sym-35,ogr-sym-10"")" -"POINT (4 5)","SYMBOL(a:30,c:#000001,s:2pt,id:""mapinfo-sym-99,ogr-sym-1"")" +"POINT (4 5)","SYMBOL(a:30,c:#000001,s:2pt,id:""mapinfo-sym-99,ogr-sym-1"",f:foo)" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp index 7f9c02fd20b7..4a65c485ca10 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp @@ -1538,7 +1538,8 @@ const char *TABFontPoint::GetStyleString() const outlineColor = ""; m_pszStyleString = - CPLStrdup(CPLSPrintf("%s%s)", pszSymbolStyleString, outlineColor)); + CPLStrdup(CPLSPrintf("%s%s,f:%s)", pszSymbolStyleString, + outlineColor, GetFontNameRef())); CPLFree(pszSymbolStyleString); } From 20063634f94e16873499dd62646bcf2259a85743 Mon Sep 17 00:00:00 2001 From: drons Date: Mon, 3 Dec 2018 21:16:42 +0300 Subject: [PATCH 097/488] MITAB: Add double quotes around symbol font name --- autotest/ogr/data/all_geoms.mif.golden.csv | 2 +- gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autotest/ogr/data/all_geoms.mif.golden.csv b/autotest/ogr/data/all_geoms.mif.golden.csv index 1a621a580706..ed61f26b4b77 100644 --- a/autotest/ogr/data/all_geoms.mif.golden.csv +++ b/autotest/ogr/data/all_geoms.mif.golden.csv @@ -1,7 +1,7 @@ WKT,ogr_style "POINT (0 1)","SYMBOL(a:0,c:#000000,s:12pt,id:""mapinfo-sym-35,ogr-sym-10"")" "POINT (2 3)","SYMBOL(a:0,c:#000000,s:1pt,id:""mapinfo-sym-35,ogr-sym-10"")" -"POINT (4 5)","SYMBOL(a:30,c:#000001,s:2pt,id:""mapinfo-sym-99,ogr-sym-1"",f:foo)" +"POINT (4 5)","SYMBOL(a:30,c:#000001,s:2pt,id:""mapinfo-sym-99,ogr-sym-1"",f:""foo"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp index 4a65c485ca10..1844469a05f7 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp @@ -1538,7 +1538,7 @@ const char *TABFontPoint::GetStyleString() const outlineColor = ""; m_pszStyleString = - CPLStrdup(CPLSPrintf("%s%s,f:%s)", pszSymbolStyleString, + CPLStrdup(CPLSPrintf("%s%s,f:\"%s\")", pszSymbolStyleString, outlineColor, GetFontNameRef())); CPLFree(pszSymbolStyleString); } From 76c48879ddcedfda840401c9fe30c5d087df6eed Mon Sep 17 00:00:00 2001 From: drons Date: Mon, 3 Dec 2018 21:29:09 +0300 Subject: [PATCH 098/488] OGR: Update feature style documentation related to point symbols --- gdal/ogr/ogr_feature_style.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gdal/ogr/ogr_feature_style.html b/gdal/ogr/ogr_feature_style.html index 030de8410838..572a51148847 100644 --- a/gdal/ogr/ogr_feature_style.html +++ b/gdal/ogr/ogr_feature_style.html @@ -10,12 +10,14 @@

    GDAL - Feature Style Specification

    -

    Version 0.015 - 2018-01-08

    +

    Version 0.016 - 2018-12-03


    REVISION HISTORY

      +
    • Version 0.016 - 2018-12-03 - Andrew Sudorgin
      + Restored and documented font property for point symbols
    • Version 0.015 - 2018-01-08 - Alan Thomas
      Update outdated material; minor changes to BRUSH 'id' and LABEL 't', 'bo', 'it', 'un', 'st'; clarify BRUSH 'fc', 'bc', SYMBOL 'o' and LABEL 's', 'w', 'p'
    • Version 0.014 - 2011-07-24 - Even Rouault
      @@ -686,6 +688,18 @@

      higher priority ones are drawn on top.
      If priority level is unspecified, the default is 1. + + + f + Font Name - + Comma-delimited list of fonts names. Works like the CSS font-family +property: the list of font names is scanned until a known font name is encountered. +
      + Example: SYMBOL(c:#00FF00,s:12pt,id:"mapinfo-sym-75",f:"MapInfo_Cartographic") + + + +

      From 71134e6ee371423d833364de9410e82107efd88d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 3 Dec 2018 22:31:05 +0100 Subject: [PATCH 099/488] GPKG: improve warning message (fixes #1131) --- gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp b/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp index 21491fd35f68..c280005b9e36 100644 --- a/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp +++ b/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp @@ -1664,7 +1664,12 @@ void OGRGeoPackageTableLayer::CheckGeometryType( OGRFeature *poFeature ) { CPLError(CE_Warning, CPLE_AppDefined, "A geometry of type %s is inserted into layer %s " - "of geometry type %s, which is not allowed. " + "of geometry type %s, which is not normally allowed " + "by the GeoPackage specification, but the driver will " + "however do it. " + "To create a conformant GeoPackage, if using ogr2ogr, " + "the -nlt option can be used to override the layer " + "geometry type. " "This warning will no longer be emitted for this " "combination of layer and feature geometry type.", OGRToOGCGeomType(eGeomType), From 207e408ac146becd6f9907c547e070fc49fd6fa9 Mon Sep 17 00:00:00 2001 From: drons Date: Tue, 4 Dec 2018 21:41:22 +0300 Subject: [PATCH 100/488] MITAB: Add "font-sym-%d" symbol style for a font based symbols --- autotest/ogr/data/all_geoms.mif.golden.csv | 2 +- gdal/ogr/ogr_feature_style.html | 4 +- gdal/ogr/ogrsf_frmts/mitab/mitab.h | 3 +- gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp | 50 ++++++++++++-------- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/autotest/ogr/data/all_geoms.mif.golden.csv b/autotest/ogr/data/all_geoms.mif.golden.csv index ed61f26b4b77..70d7f8aed78b 100644 --- a/autotest/ogr/data/all_geoms.mif.golden.csv +++ b/autotest/ogr/data/all_geoms.mif.golden.csv @@ -1,7 +1,7 @@ WKT,ogr_style "POINT (0 1)","SYMBOL(a:0,c:#000000,s:12pt,id:""mapinfo-sym-35,ogr-sym-10"")" "POINT (2 3)","SYMBOL(a:0,c:#000000,s:1pt,id:""mapinfo-sym-35,ogr-sym-10"")" -"POINT (4 5)","SYMBOL(a:30,c:#000001,s:2pt,id:""mapinfo-sym-99,ogr-sym-1"",f:""foo"")" +"POINT (4 5)","SYMBOL(a:30,c:#000001,s:2pt,id:""font-sym-99,ogr-sym-9"",f:""foo"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" "LINESTRING (0 1,2 3)","PEN(w:1px,c:#000000,id:""mapinfo-pen-2,ogr-pen-0"")" diff --git a/gdal/ogr/ogr_feature_style.html b/gdal/ogr/ogr_feature_style.html index 572a51148847..e138e31afc29 100644 --- a/gdal/ogr/ogr_feature_style.html +++ b/gdal/ogr/ogr_feature_style.html @@ -608,7 +608,9 @@

      The following conventions will be used for common system-specific symbol ids:

      • "bmp-filename.bmp" for Windows BMP symbols - +
      • "font-sym-%d" for a font symbols, + where %d is a glyph number inside a font, + font family is defined by f style field.

      Other conventions may be added in the future (such as vector symbols, WMF, etc). diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab.h b/gdal/ogr/ogrsf_frmts/mitab/mitab.h index 88a5934d8d14..6643941cd936 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab.h +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab.h @@ -954,7 +954,7 @@ class ITABFeatureSymbol void SetSymbolSize(GInt16 val) { m_sSymbolDef.nPointSize = val;} void SetSymbolColor(GInt32 clr) { m_sSymbolDef.rgbColor = clr;} - const char *GetSymbolStyleString(double dfAngle = 0.0) const; + virtual const char *GetSymbolStyleString(double dfAngle = 0.0) const; void SetSymbolFromStyleString(const char *pszStyleString); void DumpSymbolDef(FILE *fpOut = nullptr); @@ -1155,6 +1155,7 @@ class TABFontPoint final : public TABPoint, virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp) override; virtual int WriteGeometryToMIFFile(MIDDATAFile *fp) override; + virtual const char *GetSymbolStyleString(double dfAngle = 0.0) const override; virtual const char *GetStyleString() const override; GBool QueryFontStyle(TABFontStyle eStyleToQuery); diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp index 1844469a05f7..6fbdc73dd070 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp @@ -1511,6 +1511,36 @@ void TABFontPoint::SetSymbolAngle(double dAngle) m_dAngle = dAngle; } +/********************************************************************** + * TABFontPoint::GetSymbolStyleString() + * + * Return a Symbol() string. All representations info for the Symbol are here. + **********************************************************************/ +const char* TABFontPoint::GetSymbolStyleString(double dfAngle) const +{ + /* Get the SymbolStyleString, and add the outline Color + (halo/border in MapInfo Symbol terminology) */ + const char *outlineColor = nullptr; + if (m_nFontStyle & 16) + outlineColor = ",o:#000000"; + else if (m_nFontStyle & 512) + outlineColor = ",o:#ffffff"; + else + outlineColor = ""; + + int nAngle = static_cast(dfAngle); + const char* pszStyle; + + pszStyle=CPLSPrintf("SYMBOL(a:%d,c:#%6.6x,s:%dpt,id:\"font-sym-%d,ogr-sym-9\"%s,f:\"%s\")", + nAngle, + m_sSymbolDef.rgbColor, + m_sSymbolDef.nPointSize, + m_sSymbolDef.nSymbolNo, + outlineColor, + GetFontNameRef()); + return pszStyle; +} + /********************************************************************** * TABFontPoint::GetStyleString() const * @@ -1522,25 +1552,7 @@ const char *TABFontPoint::GetStyleString() const { if (m_pszStyleString == nullptr) { - /* Get the SymbolStyleString, and add the outline Color - (halo/border in MapInfo Symbol terminology) */ - char *pszSymbolStyleString = - CPLStrdup(GetSymbolStyleString(GetSymbolAngle())); - int nStyleStringlen = static_cast(strlen(pszSymbolStyleString)); - pszSymbolStyleString[nStyleStringlen - 1] = '\0'; - - const char *outlineColor = nullptr; - if (m_nFontStyle & 16) - outlineColor = ",o:#000000"; - else if (m_nFontStyle & 512) - outlineColor = ",o:#ffffff"; - else - outlineColor = ""; - - m_pszStyleString = - CPLStrdup(CPLSPrintf("%s%s,f:\"%s\")", pszSymbolStyleString, - outlineColor, GetFontNameRef())); - CPLFree(pszSymbolStyleString); + m_pszStyleString = CPLStrdup(GetSymbolStyleString(GetSymbolAngle())); } return m_pszStyleString; From ad25ca25caa01bbc7d125b216c1119939330bc90 Mon Sep 17 00:00:00 2001 From: drons Date: Tue, 4 Dec 2018 22:17:28 +0300 Subject: [PATCH 101/488] MITAB: Add symbol font setup from style string --- gdal/ogr/ogrsf_frmts/mitab/mitab.h | 2 + gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp | 123 ++++++++++++------- 2 files changed, 79 insertions(+), 46 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab.h b/gdal/ogr/ogrsf_frmts/mitab/mitab.h index 6643941cd936..bc36a67a006b 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab.h +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab.h @@ -956,6 +956,7 @@ class ITABFeatureSymbol virtual const char *GetSymbolStyleString(double dfAngle = 0.0) const; void SetSymbolFromStyleString(const char *pszStyleString); + virtual void SetSymbolFromStyle(OGRStyleSymbol* poSymbolStyle); void DumpSymbolDef(FILE *fpOut = nullptr); }; @@ -1157,6 +1158,7 @@ class TABFontPoint final : public TABPoint, virtual const char *GetSymbolStyleString(double dfAngle = 0.0) const override; virtual const char *GetStyleString() const override; + virtual void SetSymbolFromStyle(OGRStyleSymbol* poSymbolStyle) override; GBool QueryFontStyle(TABFontStyle eStyleToQuery); void ToggleFontStyle(TABFontStyle eStyleToToggle, GBool bStatus); diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp index 6fbdc73dd070..7f69caf5895a 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp @@ -1558,6 +1558,27 @@ const char *TABFontPoint::GetStyleString() const return m_pszStyleString; } +void TABFontPoint::SetSymbolFromStyle(OGRStyleSymbol* poSymbolStyle) +{ + ITABFeatureSymbol::SetSymbolFromStyle(poSymbolStyle); + + GBool bIsNull = 0; + + // Try to set font glyph number + const char* pszSymbolId = poSymbolStyle->Id(bIsNull); + if((!bIsNull) && pszSymbolId && strstr(pszSymbolId, "font-sym-")) + { + const int nSymbolId = atoi(pszSymbolId+9); + SetSymbolNo(static_cast(nSymbolId)); + } + + const char* pszFontName = poSymbolStyle->FontName(bIsNull); + if((!bIsNull) && pszFontName) + { + SetFontName(pszFontName); + } +} + /*===================================================================== * class TABCustomPoint *====================================================================*/ @@ -8871,56 +8892,12 @@ const char *ITABFeatureSymbol::GetSymbolStyleString(double dfAngle) const /********************************************************************** * ITABFeatureSymbol::SetSymbolFromStyleString() * - * Set all Symbol var from a StyleString. Use StyleMgr to do so. + * Set all Symbol var from a OGRStyleSymbol. **********************************************************************/ -void ITABFeatureSymbol::SetSymbolFromStyleString(const char *pszStyleString) +void ITABFeatureSymbol::SetSymbolFromStyle(OGRStyleSymbol* poSymbolStyle) { GBool bIsNull = 0; - // Use the Style Manager to retrieve all the information we need. - OGRStyleMgr *poStyleMgr = new OGRStyleMgr(nullptr); - OGRStyleTool *poStylePart = nullptr; - - // Init the StyleMgr with the StyleString. - poStyleMgr->InitStyleString(pszStyleString); - - // Retrieve the Symbol info. - const int numParts = poStyleMgr->GetPartCount(); - for( int i = 0; i < numParts; i++ ) - { - poStylePart = poStyleMgr->GetPart(i); - if( poStylePart == nullptr ) - continue; - - if(poStylePart->GetType() == OGRSTCSymbol) - { - break; - } - else - { - delete poStylePart; - poStylePart = nullptr; - } - } - - // If the no Symbol found, do nothing. - if(poStylePart == nullptr) - { - delete poStyleMgr; - return; - } - - OGRStyleSymbol *poSymbolStyle = cpl::down_cast(poStylePart); - - // With Symbol, we always want to output points - // - // It's very important to set the output unit of the feature. - // The default value is meter. If we don't do it all numerical values - // will be assumed to be converted from the input unit to meter when we - // will get them via GetParam...() functions. - // See OGRStyleTool::Parse() for more details. - poSymbolStyle->SetUnit(OGRSTUPoints, (72.0 * 39.37)); - // Set the Symbol Id (SymbolNo) const char *pszSymbolId = poSymbolStyle->Id(bIsNull); if(bIsNull) pszSymbolId = nullptr; @@ -8995,6 +8972,60 @@ void ITABFeatureSymbol::SetSymbolFromStyleString(const char *pszStyleString) int nSymbolColor = static_cast(strtol(pszSymbolColor, nullptr, 16)); SetSymbolColor(static_cast(nSymbolColor)); } +} + +/********************************************************************** + * ITABFeatureSymbol::SetSymbolFromStyleString() + * + * Set all Symbol var from a StyleString. Use StyleMgr to do so. + **********************************************************************/ +void ITABFeatureSymbol::SetSymbolFromStyleString(const char *pszStyleString) +{ + // Use the Style Manager to retrieve all the information we need. + OGRStyleMgr *poStyleMgr = new OGRStyleMgr(nullptr); + OGRStyleTool *poStylePart = nullptr; + + // Init the StyleMgr with the StyleString. + poStyleMgr->InitStyleString(pszStyleString); + + // Retrieve the Symbol info. + const int numParts = poStyleMgr->GetPartCount(); + for( int i = 0; i < numParts; i++ ) + { + poStylePart = poStyleMgr->GetPart(i); + if( poStylePart == nullptr ) + continue; + + if(poStylePart->GetType() == OGRSTCSymbol) + { + break; + } + else + { + delete poStylePart; + poStylePart = nullptr; + } + } + + // If the no Symbol found, do nothing. + if(poStylePart == nullptr) + { + delete poStyleMgr; + return; + } + + OGRStyleSymbol *poSymbolStyle = cpl::down_cast(poStylePart); + + // With Symbol, we always want to output points + // + // It's very important to set the output unit of the feature. + // The default value is meter. If we don't do it all numerical values + // will be assumed to be converted from the input unit to meter when we + // will get them via GetParam...() functions. + // See OGRStyleTool::Parse() for more details. + poSymbolStyle->SetUnit(OGRSTUPoints, (72.0 * 39.37)); + + SetSymbolFromStyle(poSymbolStyle); delete poStyleMgr; delete poStylePart; From 3cd611b1a20b629b8ab1e8d4a272ab4aaffd04d3 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 4 Dec 2018 20:19:15 +0100 Subject: [PATCH 102/488] CPLOpenSSLCleanup(): reset callbacks to nullptr to avoid potential segfault --- gdal/port/cpl_http.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdal/port/cpl_http.cpp b/gdal/port/cpl_http.cpp index dbedc291da2b..6a7feb1117f3 100644 --- a/gdal/port/cpl_http.cpp +++ b/gdal/port/cpl_http.cpp @@ -145,6 +145,8 @@ static void CPLOpenSSLCleanup() } CPLFree(pahSSLMutex); pahSSLMutex = nullptr; + CRYPTO_set_id_callback(nullptr); + CRYPTO_set_locking_callback(nullptr); } } From a108bbcedcbd624f915301259d47551d03402376 Mon Sep 17 00:00:00 2001 From: drons Date: Tue, 4 Dec 2018 23:54:55 +0300 Subject: [PATCH 103/488] OGR: Update feature style documentation --- gdal/ogr/ogr_feature_style.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/ogr/ogr_feature_style.html b/gdal/ogr/ogr_feature_style.html index e138e31afc29..0d9281b539ff 100644 --- a/gdal/ogr/ogr_feature_style.html +++ b/gdal/ogr/ogr_feature_style.html @@ -697,7 +697,7 @@

      Comma-delimited list of fonts names. Works like the CSS font-family property: the list of font names is scanned until a known font name is encountered.
      - Example: SYMBOL(c:#00FF00,s:12pt,id:"mapinfo-sym-75",f:"MapInfo_Cartographic") + Example: SYMBOL(c:#00FF00,s:12pt,id:"font-sym-75,ogr-sym-9",f:"MapInfo_Cartographic") From c4da0061d84a3cf6008b02d033565b5a0a416c13 Mon Sep 17 00:00:00 2001 From: Sai Cheemalapati Date: Fri, 30 Nov 2018 14:51:49 -0800 Subject: [PATCH 104/488] EEDA: Replace usage of deprecated paths/fields --- autotest/gdrivers/eedai.py | 18 ++-- autotest/ogr/ogr_eeda.py | 164 +++++++++++++++++++++++++------ gdal/frmts/eeda/drv_eeda.html | 16 +-- gdal/frmts/eeda/eeda.h | 1 + gdal/frmts/eeda/eedacommon.cpp | 45 ++++++++- gdal/frmts/eeda/eedadataset.cpp | 77 ++++++++++----- gdal/frmts/eeda/eedaidataset.cpp | 16 +-- gdal/frmts/eeda/frmt_eedai.html | 7 +- 8 files changed, 261 insertions(+), 83 deletions(-) diff --git a/autotest/gdrivers/eedai.py b/autotest/gdrivers/eedai.py index 6873636fe103..458880d9bab9 100644 --- a/autotest/gdrivers/eedai.py +++ b/autotest/gdrivers/eedai.py @@ -72,7 +72,7 @@ def eedai_2(): if gdaltest.eedai_drv is None: return 'skip' - gdal.FileFromMemBuffer('/vsimem/ee/assets/image', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/image', json.dumps({ 'type': 'IMAGE', 'properties': { @@ -320,7 +320,7 @@ def eedai_2(): npy_serialized += ''.encode('ascii').join(val for i in range(38 * 39)) gdal.FileFromMemBuffer( - '/vsimem/ee/assets:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "path": "image", "fileFormat": "NPY", "bandIds": [ "B1", "B9" ], "grid": { "affineTransform": { "translateX": 607500.0, "translateY": 4092480.0, "scaleX": 60.0, "scaleY": -60.0, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 38, "height": 39 } } }', npy_serialized) + '/vsimem/ee/projects/earthengine-public/assets/image:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "fileFormat": "NPY", "bandIds": [ "B1", "B9" ], "grid": { "affineTransform": { "translateX": 607500.0, "translateY": 4092480.0, "scaleX": 60.0, "scaleY": -60.0, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 38, "height": 39 } } }', npy_serialized) got_data = ds.GetRasterBand(1).ReadRaster(1800, 1810, 1, 1) got_data = struct.unpack('h', got_data)[0] if got_data != 12345: @@ -552,7 +552,7 @@ def eedai_4(): if gdaltest.eedai_drv is None: return 'skip' - gdal.FileFromMemBuffer('/vsimem/ee/assets/image', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/image', json.dumps({ 'type': 'IMAGE', 'bands': [ @@ -641,7 +641,7 @@ def eedai_4(): gdal.Unlink('/vsimem/out.png') gdal.FileFromMemBuffer( - '/vsimem/ee/assets:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "path": "image", "fileFormat": "PNG", "bandIds": [ "B1", "B2", "B3" ], "grid": { "affineTransform": { "translateX": 499980.0, "translateY": 4200000.0, "scaleX": 60.0, "scaleY": -60.0, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 256, "height": 256 } } }', png_data) + '/vsimem/ee/projects/earthengine-public/assets/image:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "fileFormat": "PNG", "bandIds": [ "B1", "B2", "B3" ], "grid": { "affineTransform": { "translateX": 499980.0, "translateY": 4200000.0, "scaleX": 60.0, "scaleY": -60.0, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 256, "height": 256 } } }', png_data) got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) got_data = struct.unpack('B', got_data)[0] if got_data != 127: @@ -668,7 +668,7 @@ def eedai_4(): # Sub-sampled query gdal.FileFromMemBuffer( - '/vsimem/ee/assets:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "path": "image", "fileFormat": "PNG", "bandIds": [ "B1", "B2", "B3" ], "grid": { "affineTransform": { "translateX": 499980.0, "translateY": 4200000.0, "scaleX": 120.0, "scaleY": -120.06557377049181, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 256, "height": 256 } } }', png_data) + '/vsimem/ee/projects/earthengine-public/assets/image:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "fileFormat": "PNG", "bandIds": [ "B1", "B2", "B3" ], "grid": { "affineTransform": { "translateX": 499980.0, "translateY": 4200000.0, "scaleX": 120.0, "scaleY": -120.06557377049181, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 256, "height": 256 } } }', png_data) got_data = ds.GetRasterBand(1).ReadRaster( 0, 0, 2, 2, buf_xsize=1, buf_ysize=1) got_data = struct.unpack('B', got_data)[0] @@ -701,7 +701,7 @@ def eedai_geotiff(): if gdaltest.eedai_drv is None: return 'skip' - gdal.FileFromMemBuffer('/vsimem/ee/assets/image', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/image', json.dumps({ 'type': 'IMAGE', 'bands': [ @@ -744,7 +744,7 @@ def eedai_geotiff(): gdal.Unlink('/vsimem/out.tif') gdal.FileFromMemBuffer( - '/vsimem/ee/assets:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "path": "image", "fileFormat": "GEO_TIFF", "bandIds": [ "B1" ], "grid": { "affineTransform": { "translateX": 499980.0, "translateY": 4200000.0, "scaleX": 60.0, "scaleY": -60.0, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 256, "height": 256 } } }', data) + '/vsimem/ee/projects/earthengine-public/assets/image:getPixels&CUSTOMREQUEST=POST&POSTFIELDS={ "fileFormat": "GEO_TIFF", "bandIds": [ "B1" ], "grid": { "affineTransform": { "translateX": 499980.0, "translateY": 4200000.0, "scaleX": 60.0, "scaleY": -60.0, "shearX": 0.0, "shearY": 0.0 }, "dimensions": { "width": 256, "height": 256 } } }', data) got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) got_data = struct.unpack('H', got_data)[0] if got_data != 12345: @@ -782,7 +782,7 @@ def eedai_real_service(): gdaltest.post_reason('fail') return 'fail' res = gdal.Info(ds, format='json') - expected = {'files': [], 'cornerCoordinates': {'upperRight': [415016.0, 4435536.0], 'lowerLeft': [408970.0, 4427936.0], 'lowerRight': [415016.0, 4427936.0], 'upperLeft': [408970.0, 4435536.0], 'center': [411993.0, 4431736.0]}, 'wgs84Extent': {'type': 'Polygon', 'coordinates': [[[-100.067433, 40.0651671], [-100.0663662, 39.9967049], [-99.9955511, 39.9973349], [-99.9965471, 40.0657986], [-100.067433, 40.0651671]]]}, 'description': 'EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725', 'driverShortName': 'EEDAI', 'driverLongName': 'Earth Engine Data API Image', 'bands': [{'description': 'R', 'band': 1, 'colorInterpretation': 'Red', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'G', 'band': 2, 'colorInterpretation': 'Green', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'B', 'band': 3, 'colorInterpretation': 'Blue', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}], 'coordinateSystem': {'wkt': 'PROJCS["NAD83 / UTM zone 14N",\n GEOGCS["NAD83",\n DATUM["North_American_Datum_1983",\n SPHEROID["GRS 1980",6378137,298.257222101,\n AUTHORITY["EPSG","7019"]],\n TOWGS84[0,0,0,0,0,0,0],\n AUTHORITY["EPSG","6269"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4269"]],\n PROJECTION["Transverse_Mercator"],\n PARAMETER["latitude_of_origin",0],\n PARAMETER["central_meridian",-99],\n PARAMETER["scale_factor",0.9996],\n PARAMETER["false_easting",500000],\n PARAMETER["false_northing",0],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n AXIS["Easting",EAST],\n AXIS["Northing",NORTH],\n AUTHORITY["EPSG","26914"]]'}, 'geoTransform': [408970.0, 2.0, 0.0, 4435536.0, 0.0, -2.0], 'metadata': {'IMAGE_STRUCTURE': {'INTERLEAVE': 'PIXEL'}}, 'size': [3023, 3800]} + expected = {'files': [], 'cornerCoordinates': {'upperRight': [415016.0, 4435536.0], 'lowerLeft': [408970.0, 4427936.0], 'lowerRight': [415016.0, 4427936.0], 'upperLeft': [408970.0, 4435536.0], 'center': [411993.0, 4431736.0]}, 'wgs84Extent': {'type': 'Polygon', 'coordinates': [[]]}, 'description': 'EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725', 'driverShortName': 'EEDAI', 'driverLongName': 'Earth Engine Data API Image', 'bands': [{'description': 'R', 'band': 1, 'colorInterpretation': 'Red', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'G', 'band': 2, 'colorInterpretation': 'Green', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'B', 'band': 3, 'colorInterpretation': 'Blue', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}], 'coordinateSystem': {'wkt': 'PROJCS["NAD83 / UTM zone 14N",\n GEOGCS["NAD83",\n DATUM["North_American_Datum_1983",\n SPHEROID["GRS 1980",6378137,298.257222101,\n AUTHORITY["EPSG","7019"]],\n TOWGS84[0,0,0,0,0,0,0],\n AUTHORITY["EPSG","6269"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4269"]],\n PROJECTION["Transverse_Mercator"],\n PARAMETER["latitude_of_origin",0],\n PARAMETER["central_meridian",-99],\n PARAMETER["scale_factor",0.9996],\n PARAMETER["false_easting",500000],\n PARAMETER["false_northing",0],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n AXIS["Easting",EAST],\n AXIS["Northing",NORTH],\n AUTHORITY["EPSG","26914"]]'}, 'geoTransform': [408970.0, 2.0, 0.0, 4435536.0, 0.0, -2.0], 'metadata': {'IMAGE_STRUCTURE': {'INTERLEAVE': 'PIXEL'}}, 'size': [3023, 3800]} if expected != res: gdaltest.post_reason('fail') print(res) @@ -825,7 +825,7 @@ def eedai_cleanup(): gdal.SetConfigOption('GOA2_NOW', None) gdal.SetConfigOption('GOOGLE_APPLICATION_CREDENTIALS', gdaltest.GOOGLE_APPLICATION_CREDENTIALS) - gdal.Unlink('/vsimem/ee/assets/image') + gdal.Unlink('/vsimem/ee/projects/earthengine-public/assets/image') gdal.RmdirRecursive('/vsimem/ee/') return 'success' diff --git a/autotest/ogr/ogr_eeda.py b/autotest/ogr/ogr_eeda.py index 516890e63855..0e7cc177c1a1 100644 --- a/autotest/ogr/ogr_eeda.py +++ b/autotest/ogr/ogr_eeda.py @@ -63,7 +63,7 @@ def eeda_2(): if ogrtest.eeda_drv is None: return 'skip' - gdal.FileFromMemBuffer('/vsimem/ee/assets:listImages?parentPath=collection&pageSize=1', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/collection:listImages?pageSize=1', json.dumps({ 'assets': [ { 'properties': @@ -95,7 +95,7 @@ def eeda_2(): gdaltest.post_reason('fail') return 'fail' - if lyr.GetLayerDefn().GetFieldCount() != 6 + 7 + 4: + if lyr.GetLayerDefn().GetFieldCount() != 8 + 7 + 4: gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) return 'fail' @@ -110,10 +110,12 @@ def eeda_2(): print(lyr.GetFeatureCount()) return 'fail' - gdal.FileFromMemBuffer('/vsimem/ee/assets:listImages?parentPath=collection', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/collection:listImages', json.dumps({ 'assets': [ { - 'path': 'first_feature', + 'name': 'projects/earthengine-public/assets/collection/first_feature', + 'id': 'collection/first_feature', + 'path': 'collection/first_feature', 'time': '2017-01-02T12:34:56.789Z', 'updateTime': '2017-01-03T12:34:56.789Z', 'sizeBytes': 1, @@ -152,15 +154,17 @@ def eeda_2(): ] }, { - 'path': 'second_feature' + 'name': 'projects/earthengine-public/assets/collection/second_feature' } ], 'nextPageToken': 'myToken' })) f = lyr.GetNextFeature() - if f.GetField('path') != 'first_feature' or \ - f.GetField('gdal_dataset') != 'EEDAI:first_feature' or \ + if f.GetField('name') != 'projects/earthengine-public/assets/collection/first_feature' or \ + f.GetField('id') != 'collection/first_feature' or \ + f.GetField('path') != 'collection/first_feature' or \ + f.GetField('gdal_dataset') != 'EEDAI:projects/earthengine-public/assets/collection/first_feature' or \ f.GetField('time') != '2017/01/02 12:34:56.789+00' or \ f.GetField('updateTime') != '2017/01/03 12:34:56.789+00' or \ f.GetField('sizeBytes') != 1 or \ @@ -182,21 +186,21 @@ def eeda_2(): return 'fail' f = lyr.GetNextFeature() - if f.GetField('path') != 'second_feature': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/second_feature': gdaltest.post_reason('fail') f.DumpReadable() return 'fail' - gdal.FileFromMemBuffer('/vsimem/ee/assets:listImages?parentPath=collection&pageToken=myToken', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/collection:listImages?pageToken=myToken', json.dumps({ 'assets': [ { - 'path': 'third_feature' + 'name': 'projects/earthengine-public/assets/collection/third_feature' } ] })) f = lyr.GetNextFeature() - if f.GetField('path') != 'third_feature': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/third_feature': gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -209,23 +213,23 @@ def eeda_2(): lyr.ResetReading() f = lyr.GetNextFeature() - if f.GetField('path') != 'first_feature': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/first_feature': gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr.SetAttributeFilter('EEDA:raw_filter') - gdal.FileFromMemBuffer('/vsimem/ee/assets:listImages?parentPath=collection&filter=raw%5Ffilter', json.dumps({ + gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/collection:listImages?filter=raw%5Ffilter', json.dumps({ 'assets': [ { - 'path': 'raw_filter' + 'name': 'projects/earthengine-public/assets/collection/raw_filter' } ] })) f = lyr.GetNextFeature() - if f.GetField('path') != 'raw_filter': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/raw_filter': gdaltest.post_reason('fail') return 'fail' @@ -241,11 +245,11 @@ def eeda_2(): "string_field IN ('bar', 'baz') AND " + "NOT( int_field IN (0) OR double_field IN (3.5) )") - ogrtest.eeda_drv_tmpfile = '/vsimem/ee/assets:listImages?parentPath=collection®ion=%7B%20%22type%22%3A%20%22Polygon%22%2C%20%22coordinates%22%3A%20%5B%20%5B%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%20%5D%20%5D%20%7D&filter=%28%28%28%28%28%28%28string%5Ffield%20%3D%20%22bar%22%20AND%20int%5Ffield%20%3E%200%29%20AND%20int%5Ffield%20%3C%202%29%20AND%20int64%5Ffield%20%3E%3D%200%29%20AND%20int64%5Ffield%20%3C%3D%209999999999999%29%20AND%20double%5Ffield%20%21%3D%203%2E5%29%20AND%20string%5Ffield%20%3D%20%22bar%22%20OR%20string%5Ffield%20%3D%20%22baz%22%29%20AND%20%28NOT%20%28int%5Ffield%20%3D%200%20OR%20double%5Ffield%20%3D%203%2E5%29%29%29&startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=2100%2D01%2D01T00%3A00%3A00Z' + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?region=%7B%20%22type%22%3A%20%22Polygon%22%2C%20%22coordinates%22%3A%20%5B%20%5B%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%20%5D%20%5D%20%7D&filter=%28%28%28%28%28%28%28string%5Ffield%20%3D%20%22bar%22%20AND%20int%5Ffield%20%3E%200%29%20AND%20int%5Ffield%20%3C%202%29%20AND%20int64%5Ffield%20%3E%3D%200%29%20AND%20int64%5Ffield%20%3C%3D%209999999999999%29%20AND%20double%5Ffield%20%21%3D%203%2E5%29%20AND%20string%5Ffield%20%3D%20%22bar%22%20OR%20string%5Ffield%20%3D%20%22baz%22%29%20AND%20%28NOT%20%28int%5Ffield%20%3D%200%20OR%20double%5Ffield%20%3D%203%2E5%29%29%29&startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=2100%2D01%2D01T00%3A00%3A00Z' gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ 'assets': [ { - 'path': 'filtered_feature', + 'name': 'projects/earthengine-public/assets/collection/filtered_feature', 'time': '2017-01-02T12:34:56.789Z', 'updateTime': '2017-01-03T12:34:56.789Z', 'sizeBytes': 1, @@ -260,7 +264,7 @@ def eeda_2(): } }, { - 'path': 'second_feature' + 'name': 'projects/earthengine-public/assets/collection/second_feature' } ] })) @@ -270,7 +274,7 @@ def eeda_2(): f = lyr.GetNextFeature() gdal.Unlink(ogrtest.eeda_drv_tmpfile) - if f.GetField('path') != 'filtered_feature': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/filtered_feature': gdaltest.post_reason('fail') return 'fail' @@ -279,15 +283,15 @@ def eeda_2(): # Test time equality with second granularity lyr.SetAttributeFilter("time = '1980-01-01T00:00:00Z'") - ogrtest.eeda_drv_tmpfile = '/vsimem/ee/assets:listImages?parentPath=collection&startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D01T00%3A00%3A01Z' + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D01T00%3A00%3A01Z' gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ 'assets': [ { - 'path': 'filtered_feature', - 'time': '1980-01-01T00:00:00Z', + 'name': 'projects/earthengine-public/assets/collection/filtered_feature', + 'time': '1980-01-01T00:00:00Z' }, { - 'path': 'second_feature' + 'name': 'projects/earthengine-public/assets/collection/second_feature' } ] })) @@ -295,22 +299,22 @@ def eeda_2(): f = lyr.GetNextFeature() gdal.Unlink(ogrtest.eeda_drv_tmpfile) - if f.GetField('path') != 'filtered_feature': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/filtered_feature': gdaltest.post_reason('fail') return 'fail' # Test time equality with day granularity lyr.SetAttributeFilter("time = '1980-01-01'") - ogrtest.eeda_drv_tmpfile = '/vsimem/ee/assets:listImages?parentPath=collection&startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D01T23%3A59%3A59Z' + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D01T23%3A59%3A59Z' gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ 'assets': [ { - 'path': 'filtered_feature', + 'name': 'projects/earthengine-public/assets/collection/filtered_feature', 'time': '1980-01-01T12:00:00Z', }, { - 'path': 'second_feature' + 'name': 'projects/earthengine-public/assets/collection/second_feature' } ] })) @@ -318,7 +322,7 @@ def eeda_2(): f = lyr.GetNextFeature() gdal.Unlink(ogrtest.eeda_drv_tmpfile) - if f.GetField('path') != 'filtered_feature': + if f.GetField('name') != 'projects/earthengine-public/assets/collection/filtered_feature': gdaltest.post_reason('fail') return 'fail' @@ -344,7 +348,7 @@ def eeda_3(): lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 6 + 7 + 4: + if lyr.GetLayerDefn().GetFieldCount() != 8 + 7 + 4: gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) return 'fail' @@ -354,6 +358,101 @@ def eeda_3(): return 'success' +############################################################################### +# Test that name and id variants are handled correctly. + + +def eeda_4(): + + if ogrtest.eeda_drv is None: + return 'skip' + + gdal.SetConfigOption('EEDA_BEARER', 'mybearer') + gdal.SetConfigOption('EEDA_URL', '/vsimem/ee/') + + # User asset ID ("users/**"). + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-legacy/assets/users/foo:listImages?pageSize=1' + gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ + 'assets': [ + { + 'name': 'projects/earthengine-legacy/assets/users/foo/bar' + } + ] + })) + if not ogr.Open('EEDA:users/foo').GetLayer(0): + gdaltest.post_reason('fail') + return 'fail' + gdal.Unlink(ogrtest.eeda_drv_tmpfile) + + # Project asset ID ("projects/**"). + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-legacy/assets/projects/foo:listImages?pageSize=1' + gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ + 'assets': [ + { + 'name': 'projects/earthengine-legacy/assets/projects/foo/bar' + } + ] + })) + ds = ogr.Open('EEDA:projects/foo') + if not ds.GetLayer(0): + gdaltest.post_reason('fail') + return 'fail' + gdal.Unlink(ogrtest.eeda_drv_tmpfile) + ds = None + + # Multi-folder project asset ID ("projects/foo/bar/baz"). + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-legacy/assets/projects/foo/bar/baz:listImages?pageSize=1' + gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ + 'assets': [ + { + 'name': 'projects/earthengine-legacy/assets/projects/foo/bar/baz/qux' + } + ] + })) + ds = ogr.Open('EEDA:projects/foo/bar/baz') + if not ds.GetLayer(0): + gdaltest.post_reason('fail') + return 'fail' + gdal.Unlink(ogrtest.eeda_drv_tmpfile) + ds = None + + # Public-catalog asset ID (e.g. "LANDSAT"). + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/foo:listImages?pageSize=1' + gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ + 'assets': [ + { + 'name': 'projects/earthengine-public/assets/foo/bar' + } + ] + })) + ds = ogr.Open('EEDA:foo') + if not ds.GetLayer(0): + gdaltest.post_reason('fail') + return 'fail' + gdal.Unlink(ogrtest.eeda_drv_tmpfile) + ds = None + + # Asset name ("projects/*/assets/**"). + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/foo/assets/bar:listImages?pageSize=1' + gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ + 'assets': [ + { + 'name': 'projects/foo/assets/bar/baz' + } + ] + })) + ds = ogr.Open('EEDA:projects/foo/assets/bar') + if not ds.GetLayer(0): + gdaltest.post_reason('fail') + return 'fail' + gdal.Unlink(ogrtest.eeda_drv_tmpfile) + ds = None + + gdal.SetConfigOption('EEDA_BEARER', None) + gdal.SetConfigOption('EEDA_URL', None) + + return 'success' + ############################################################################### # @@ -372,9 +471,9 @@ def eeda_cleanup(): gdal.SetConfigOption('GOA2_NOW', None) gdal.Unlink('/vsimem/ee/') - gdal.Unlink('/vsimem/ee/assets:listImages?parentPath=collection&pageSize=1') - gdal.Unlink('/vsimem/ee/assets:listImages?parentPath=collection&pageToken=myToken') - gdal.Unlink('/vsimem/ee/assets:listImages?parentPath=collection&filter=raw%5Ffilter') + gdal.Unlink('/vsimem/ee/projects/earthengine-public/assets/collection:listImages?pageSize=1') + gdal.Unlink('/vsimem/ee/projects/earthengine-public/assets/collection:listImages?pageToken=myToken') + gdal.Unlink('/vsimem/ee/projects/earthengine-public/assets/collection:listImages?filter=raw%5Ffilter') return 'success' @@ -383,6 +482,7 @@ def eeda_cleanup(): eeda_1, eeda_2, eeda_3, + eeda_4, eeda_cleanup] if __name__ == '__main__': diff --git a/gdal/frmts/eeda/drv_eeda.html b/gdal/frmts/eeda/drv_eeda.html index 1ab358df6d84..8cf3ccc84e68 100644 --- a/gdal/frmts/eeda/drv_eeda.html +++ b/gdal/frmts/eeda/drv_eeda.html @@ -16,7 +16,7 @@

      Dataset name syntax

      The minimal syntax to open a datasource is :
      EEDA:[collection]

      -where collection is something like COPERNICUS/S2. +where collection is something like projects/earthengine-public/assets/COPERNICUS/S2.

      Open options

      @@ -85,8 +85,10 @@

      Attributes

      Server-side filter compatible -pathStringImage path (e.g. COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG)No -gdal_datasetStringGDAL dataset name (e.g. EEDAI:COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG)
      hat can be opened with the Google Earth Engine Data API Image driverNo +nameStringImage name (e.g. projects/earthengine-public/assets/COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG)No +idStringImage ID; equivalent to name without the "projects/*/assets/" prefix (e.g. users/USER/ASSET)No +pathString(Deprecated) Image path; equivalent to idNo +gdal_datasetStringGDAL dataset name (e.g. EEDAI:projects/earthengine-public/assets/COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG)
      hat can be opened with the Google Earth Engine Data API Image driverNo timeDateTimeAcquisition dateYes updateTimeDateTimeUpdate dateNo sizeBytesInteger64File size in bytesNo @@ -134,25 +136,25 @@

      Examples

    • Listing all images available:
      -ogrinfo -ro -al "EEDA:" -oo COLLECTION=COPERNICUS/S2 --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
      +ogrinfo -ro -al "EEDA:" -oo COLLECTION=projects/earthengine-public/assets/COPERNICUS/S2 --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
       
      or
      -ogrinfo -ro -al "EEDA:COPERNICUS/S2" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
      +ogrinfo -ro -al "EEDA:projects/earthengine-public/assets/COPERNICUS/S2" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
       

    • Listing all images under a point of (lat,lon)=(40,-100) :
      -ogrinfo -ro -al "EEDA:COPERNICUS/S2" -spat -100 40 -100 40 --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
      +ogrinfo -ro -al "EEDA:projects/earthengine-public/assets/COPERNICUS/S2" -spat -100 40 -100 40 --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
       

    • Listing all images available matching criteria :
      -ogrinfo -ro -al "EEDA:COPERNICUS/S2" -where "time >= '2015/03/26 00:00:00' AND CLOUDY_PIXEL_PERCENTAGE < 10" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
      +ogrinfo -ro -al "EEDA:projects/earthengine-public/assets/COPERNICUS/S2" -where "time >= '2015/03/26 00:00:00' AND CLOUDY_PIXEL_PERCENTAGE < 10" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
       

      diff --git a/gdal/frmts/eeda/eeda.h b/gdal/frmts/eeda/eeda.h index 98cef6d8ade1..c68c15ae0889 100644 --- a/gdal/frmts/eeda/eeda.h +++ b/gdal/frmts/eeda/eeda.h @@ -85,6 +85,7 @@ class GDALEEDABaseDataset: public GDALDataset GIntBig m_nExpirationTime; char **GetBaseHTTPOptions(); + static CPLString ConvertPathToName(const CPLString& path); public: GDALEEDABaseDataset(); diff --git a/gdal/frmts/eeda/eedacommon.cpp b/gdal/frmts/eeda/eedacommon.cpp index 061ff67ba6c4..0ce5bdd8ef6f 100644 --- a/gdal/frmts/eeda/eedacommon.cpp +++ b/gdal/frmts/eeda/eedacommon.cpp @@ -276,6 +276,47 @@ GDALEEDABaseDataset::~GDALEEDABaseDataset() } } +/************************************************************************/ +/* ConvertPathToName() */ +/************************************************************************/ + +CPLString GDALEEDABaseDataset::ConvertPathToName(const CPLString& path) { + size_t end = path.find('/'); + CPLString folder = path.substr(0, end); + + if ( folder == "users" ) + { + return "projects/earthengine-legacy/assets/" + path; + } + else if ( folder != "projects" ) + { + return "projects/earthengine-public/assets/" + path; + } + + // Find the start and end positions of the third segment, if it exists. + int segment = 1; + size_t start = 0; + while ( end != std::string::npos && segment < 3 ) + { + segment++; + start = end + 1; + end = path.find('/', start); + } + + end = (end == std::string::npos) ? path.size() : end; + // segment is 3 if path has at least 3 segments. + if ( folder == "projects" && segment == 3 ) + { + // If the first segment is "projects" and the third segment is "assets", + // path is a name, so return as-is. + if ( path.substr(start, end - start) == "assets" ) + { + return path; + } + } + return "projects/earthengine-legacy/assets/" + path; +} + /************************************************************************/ /* GetBaseHTTPOptions() */ /************************************************************************/ @@ -470,7 +511,7 @@ CPLHTTPResult* EEDAHTTPFetch(const char* pszURL, char** papszOptions) (nHTTPStatus >= 502 && nHTTPStatus <= 504)) && i < RETRY_COUNT ) { - CPLError( CE_Warning, CPLE_FileIO, + CPLError( CE_Warning, CPLE_FileIO, "GET error when downloading %s, HTTP status=%d, retrying in %.2fs : %s", pszURL, nHTTPStatus, dfRetryDelay, pszErrorText); CPLHTTPDestroyResult(psResult); @@ -487,4 +528,4 @@ CPLHTTPResult* EEDAHTTPFetch(const char* pszURL, char** papszOptions) } return psResult; -} \ No newline at end of file +} diff --git a/gdal/frmts/eeda/eedadataset.cpp b/gdal/frmts/eeda/eedadataset.cpp index 075f4591ee34..6bc2d0c78a6f 100644 --- a/gdal/frmts/eeda/eedadataset.cpp +++ b/gdal/frmts/eeda/eedadataset.cpp @@ -110,6 +110,7 @@ class GDALEEDALayer: public OGRLayer GDALEEDADataset* m_poDS; CPLString m_osCollection{}; + CPLString m_osCollectionName{}; OGRFeatureDefn* m_poFeatureDefn; json_object* m_poCurPageObj; json_object* m_poCurPageAssets; @@ -129,6 +130,7 @@ class GDALEEDALayer: public OGRLayer public: GDALEEDALayer(GDALEEDADataset* poDS, const CPLString& osCollection, + const CPLString& osCollectionName, json_object* poAsset, json_object* poLayerConf); virtual ~GDALEEDALayer(); @@ -159,10 +161,12 @@ class GDALEEDALayer: public OGRLayer GDALEEDALayer::GDALEEDALayer(GDALEEDADataset* poDS, const CPLString& osCollection, + const CPLString& osCollectionName, json_object* poAsset, json_object* poLayerConf) : m_poDS(poDS), m_osCollection(osCollection), + m_osCollectionName(osCollectionName), m_poFeatureDefn(nullptr), m_poCurPageObj(nullptr), m_poCurPageAssets(nullptr), @@ -187,6 +191,14 @@ GDALEEDALayer::GDALEEDALayer(GDALEEDADataset* poDS, m_poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poSRS); poSRS->Release(); + { + OGRFieldDefn oFieldDefn("name", OFTString); + m_poFeatureDefn->AddFieldDefn(&oFieldDefn); + } + { + OGRFieldDefn oFieldDefn("id", OFTString); + m_poFeatureDefn->AddFieldDefn(&oFieldDefn); + } { OGRFieldDefn oFieldDefn("path", OFTString); m_poFeatureDefn->AddFieldDefn(&oFieldDefn); @@ -385,41 +397,45 @@ OGRFeature* GDALEEDALayer::GetNextRawFeature() if( m_poCurPageObj == nullptr ) { - CPLString osURL(m_poDS->GetBaseURL() + "assets:listImages?parentPath=" + - CPLEscapeURLQueryParameter(m_osCollection)); + CPLString osURL(m_poDS->GetBaseURL() + m_osCollectionName + + ":listImages"); + CPLString query = ""; if( !osNextPageToken.empty() ) { - osURL += "&pageToken=" + + query += "&pageToken=" + CPLEscapeURLQueryParameter(osNextPageToken); } const char *pszPageSize = CPLGetConfigOption("EEDA_PAGE_SIZE", nullptr); if( pszPageSize ) { - osURL += "&pageSize="; - osURL += pszPageSize; + query += "&pageSize="; + query += pszPageSize; } if( m_poFilterGeom != nullptr ) { char* pszGeoJSON = OGR_G_ExportToJson( reinterpret_cast(m_poFilterGeom) ); - osURL += "®ion="; - osURL += CPLEscapeURLQueryParameter(pszGeoJSON); + query += "®ion="; + query += CPLEscapeURLQueryParameter(pszGeoJSON); CPLFree(pszGeoJSON); } if( !m_osAttributeFilter.empty() ) { - osURL += "&filter="; - osURL += CPLEscapeURLQueryParameter(m_osAttributeFilter); + query += "&filter="; + query += CPLEscapeURLQueryParameter(m_osAttributeFilter); } if( !m_osStartTime.empty() ) { - osURL += "&startTime="; - osURL += CPLEscapeURLQueryParameter(m_osStartTime); + query += "&startTime="; + query += CPLEscapeURLQueryParameter(m_osStartTime); } if( !m_osEndTime.empty() ) { - osURL += "&endTime="; - osURL += CPLEscapeURLQueryParameter(m_osEndTime); + query += "&endTime="; + query += CPLEscapeURLQueryParameter(m_osEndTime); + } + if (query.size() > 0) { + osURL = osURL + "?" + query.substr(1); } m_poCurPageObj = m_poDS->RunRequest(osURL); if( m_poCurPageObj == nullptr ) @@ -471,13 +487,27 @@ OGRFeature* GDALEEDALayer::GetNextRawFeature() } } + const char* pszName = + json_object_get_string(CPL_json_object_object_get(poAsset, "name")); + if( pszName ) + { + poFeature->SetField("name", pszName); + poFeature->SetField("gdal_dataset", + ("EEDAI:" + CPLString(pszName)).c_str()); + } + + const char* pszId = + json_object_get_string(CPL_json_object_object_get(poAsset, "id")); + if ( pszId ) + { + poFeature->SetField("id", pszId); + } + const char* pszPath = json_object_get_string(CPL_json_object_object_get(poAsset, "path")); - if( pszPath ) + if ( pszPath ) { - poFeature->SetField("path", pszPath); - poFeature->SetField("gdal_dataset", - ("EEDAI:" + CPLString(pszPath)).c_str()); + poFeature->SetField("path", pszId); } const char* const apszBaseProps[] = @@ -1109,6 +1139,7 @@ bool GDALEEDADataset::Open(GDALOpenInfo* poOpenInfo) osCollection = papszTokens[1]; CSLDestroy(papszTokens); } + CPLString osCollectionName = ConvertPathToName(osCollection); json_object* poRootConf = GDALEEDADatasetGetConf(); if( poRootConf ) @@ -1118,7 +1149,7 @@ bool GDALEEDADataset::Open(GDALOpenInfo* poOpenInfo) if( poLayerConf != nullptr && json_object_get_type(poLayerConf) == json_type_object ) { - m_poLayer = new GDALEEDALayer(this, osCollection, + m_poLayer = new GDALEEDALayer(this, osCollection, osCollectionName, nullptr, poLayerConf); json_object_put(poRootConf); return true; @@ -1127,9 +1158,8 @@ bool GDALEEDADataset::Open(GDALOpenInfo* poOpenInfo) } // Issue request to get layer schema - json_object* poRootAsset = RunRequest(m_osBaseURL + "assets:listImages?parentPath=" + - CPLEscapeURLQueryParameter(osCollection) + - "&pageSize=1"); + json_object* poRootAsset = RunRequest(m_osBaseURL + osCollectionName + + ":listImages?pageSize=1"); if( poRootAsset == nullptr ) return false; @@ -1150,7 +1180,8 @@ bool GDALEEDADataset::Open(GDALOpenInfo* poOpenInfo) return false; } - m_poLayer = new GDALEEDALayer(this, osCollection, poAsset, nullptr); + m_poLayer = new GDALEEDALayer(this, osCollection, osCollectionName, poAsset, + nullptr); json_object_put(poRootAsset); return true; @@ -1204,7 +1235,7 @@ void GDALRegister_EEDA() poDriver->SetMetadataItem( GDAL_DMD_CONNECTION_PREFIX, "EEDA:" ); poDriver->SetMetadataItem( GDAL_DMD_OPENOPTIONLIST, "" -" "); poDriver->pfnOpen = GDALEEDAOpen; diff --git a/gdal/frmts/eeda/eedaidataset.cpp b/gdal/frmts/eeda/eedaidataset.cpp index f72da8ef848a..76162e341017 100644 --- a/gdal/frmts/eeda/eedaidataset.cpp +++ b/gdal/frmts/eeda/eedaidataset.cpp @@ -62,6 +62,7 @@ class GDALEEDAIDataset: public GDALEEDABaseDataset int m_nBlockSize; CPLString m_osAsset{}; + CPLString m_osAssetName{}; GDALEEDAIDataset* m_poParentDS; #ifdef DEBUG_VERBOSE int m_iOvrLevel; @@ -185,6 +186,7 @@ GDALEEDAIDataset::GDALEEDAIDataset(GDALEEDAIDataset* poParentDS, int iOvrLevel ) : m_nBlockSize(poParentDS->m_nBlockSize), m_osAsset(poParentDS->m_osAsset), + m_osAssetName(poParentDS->m_osAssetName), m_poParentDS(poParentDS), #ifdef DEBUG_VERBOSE m_iOvrLevel(iOvrLevel), @@ -573,8 +575,6 @@ CPLErr GDALEEDAIRasterBand::GetBlocks(int nBlockXOff, int nBlockYOff, // Build request content json_object* poReq = json_object_new_object(); - json_object_object_add(poReq, "path", - json_object_new_string(poGDS->m_osAsset)); json_object_object_add(poReq, "fileFormat", json_object_new_string(poGDS->m_osPixelEncoding)); json_object* poBands = json_object_new_array(); @@ -648,7 +648,7 @@ CPLErr GDALEEDAIRasterBand::GetBlocks(int nBlockXOff, int nBlockYOff, papszOptions = CSLSetNameValue(papszOptions, "HEADERS", osHeaders); papszOptions = CSLSetNameValue(papszOptions, "POSTFIELDS", osPostContent); CPLHTTPResult* psResult = EEDAHTTPFetch( - (poGDS->m_osBaseURL + "assets:getPixels").c_str(), + (poGDS->m_osBaseURL + poGDS->m_osAssetName + ":getPixels").c_str(), papszOptions); CSLDestroy(papszOptions); if( psResult == nullptr ) @@ -1276,6 +1276,8 @@ bool GDALEEDAIDataset::Open(GDALOpenInfo* poOpenInfo) m_osAsset = papszTokens[1]; CSLDestroy(papszTokens); } + m_osAssetName = ConvertPathToName(m_osAsset); + m_osPixelEncoding = CSLFetchNameValueDef(poOpenInfo->papszOpenOptions, "PIXEL_ENCODING", "AUTO"); @@ -1301,7 +1303,7 @@ bool GDALEEDAIDataset::Open(GDALOpenInfo* poOpenInfo) if( papszOptions == nullptr ) return false; CPLHTTPResult* psResult = EEDAHTTPFetch( - (m_osBaseURL + "assets/" + m_osAsset).c_str(), papszOptions); + (m_osBaseURL + m_osAssetName).c_str(), papszOptions); CSLDestroy(papszOptions); if( psResult == nullptr ) return false; @@ -1506,11 +1508,11 @@ bool GDALEEDAIDataset::Open(GDALOpenInfo* poOpenInfo) osSubDSSuffix += aoBandDesc[oIter->second[i]].osName; } aoSubDSList.AddNameValue( - CPLSPrintf("SUBDATASET_%d_NAME", aoSubDSList.size() / 2 + 1), + CPLSPrintf("SUBDATASET_%d_NAME", aoSubDSList.size() / 2 + 1), CPLSPrintf("EEDAI:%s:%s", m_osAsset.c_str(), osSubDSSuffix.c_str()) ); aoSubDSList.AddNameValue( - CPLSPrintf("SUBDATASET_%d_DESC", aoSubDSList.size() / 2 + 1), + CPLSPrintf("SUBDATASET_%d_DESC", aoSubDSList.size() / 2 + 1), CPLSPrintf("Band%s %s of %s", oIter->second.size() > 1 ? "s" : "", osSubDSSuffix.c_str(), m_osAsset.c_str()) ); @@ -1644,7 +1646,7 @@ void GDALRegister_EEDAI() poDriver->SetMetadataItem( GDAL_DMD_CONNECTION_PREFIX, "EEDAI:" ); poDriver->SetMetadataItem( GDAL_DMD_OPENOPTIONLIST, "" -"

    • The minimal syntax to open a datasource is :
      EEDAI:[asset][:band_names]

      -where asset is something like COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG, +where asset is something like +projects/earthengine-public/assets/COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG, and band_names a comma separated list of band names (typically indicated by subdatasets on the main image) @@ -101,11 +102,11 @@

      Examples

    • Get metadata on an image:
      -gdalinfo "EEDAI:" -oo ASSET=COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
      +gdalinfo "EEDAI:" -oo ASSET=projects/earthengine-public/assets/COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
       
      or
      -gdalinfo "EEDAI:COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
      +gdalinfo "EEDAI:projects/earthengine-public/assets/COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
       

      From 52efc6ddb9cde38e0ef658ff7cdcfa4ca266e689 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 5 Dec 2018 17:48:32 +0100 Subject: [PATCH 105/488] VRT: fix source window computation that caused sub-pixel shift with non-nearest resampling Addresses issue raised in https://lists.osgeo.org/pipermail/gdal-dev/2018-December/049415.html --- .../gcore/data/left_vrt_subpixel_offset.tif | Bin 0 -> 558 bytes .../data/right_bottom_vrt_subpixel_offset.tif | Bin 0 -> 458 bytes .../data/right_top_vrt_subpixel_offset.tif | Bin 0 -> 458 bytes autotest/gcore/data/vrt_subpixel_offset.vrt | 28 +++++++++ autotest/gcore/vrt_read.py | 14 +++++ gdal/frmts/gtiff/geotiff.cpp | 8 +-- gdal/frmts/vrt/vrtsources.cpp | 55 ++++++++++++++---- gdal/gcore/rasterio.cpp | 19 ++---- 8 files changed, 95 insertions(+), 29 deletions(-) create mode 100644 autotest/gcore/data/left_vrt_subpixel_offset.tif create mode 100644 autotest/gcore/data/right_bottom_vrt_subpixel_offset.tif create mode 100644 autotest/gcore/data/right_top_vrt_subpixel_offset.tif create mode 100644 autotest/gcore/data/vrt_subpixel_offset.vrt diff --git a/autotest/gcore/data/left_vrt_subpixel_offset.tif b/autotest/gcore/data/left_vrt_subpixel_offset.tif new file mode 100644 index 0000000000000000000000000000000000000000..e1dad6177102d16cffcf96d752fcbe1e879b2b7c GIT binary patch literal 558 zcmZvYu}T9$5QgV+#~DIU1fw7+4pM0&v9V3S#-M3bgliW?SkPiRCzTFdvsi6;*ri+~ z#g%CU!9sihAHY|z)Y;1!uJB;^zuo_z+1)!j+JzA>z3>}E&M+ETLgSOX; z>!{S7-gtPpe~|1Y=VvF$-R;d~((jKa<>mx5F)|xw5lt4SXf(>2L=9Rd5}S}X_aQ{2 zxpUT{CC#tS8pBF#E1i}MX_UBxeUCB9D3q9%;Up<-6%lD8BQbS;p-JhvWjR0$o%fylU{`p{;W4S1Do9B7K_7@QCfQ|qF literal 0 HcmV?d00001 diff --git a/autotest/gcore/data/right_bottom_vrt_subpixel_offset.tif b/autotest/gcore/data/right_bottom_vrt_subpixel_offset.tif new file mode 100644 index 0000000000000000000000000000000000000000..0dccee37af2748d00ac5a4b905bc81c8630ce56b GIT binary patch literal 458 zcmebD)MDUZU|`^9U|?isU<9(bfS3`9%>-qGR53%@Aa!g=Y(YjAu--JFgea1@7?ce% zQyi)$1;~~`QWK2C=4<9*Ur^>cl|G>FXz_5nKs0}F%=bS_woiDhHEC`g`TV>=szC<7ZX zAQ&0?lo@zHba(~}nATMGb96B>SI}1o4e?c|%FjzxFf{b50SneJWEYfAm{3_*USAW_ z+S}HYn^jR)I%#5UW@dVRSx48r#**6l)Uw*{X+K>>brpRbeN(zxyP8USCUn(RmF5@b=K=uhxJhvU literal 0 HcmV?d00001 diff --git a/autotest/gcore/data/right_top_vrt_subpixel_offset.tif b/autotest/gcore/data/right_top_vrt_subpixel_offset.tif new file mode 100644 index 0000000000000000000000000000000000000000..1a69b1730baa0850708c35564947e877831cd072 GIT binary patch literal 458 zcmebD)MDUZU|`^9U|?isU<9(bfS3`9%>-qGR53%@Aa!g=Y(YjAu--JFgea1@7?ce% zQyi)$1;~~`QWK2C=4<9*UrGxL1FG>FXz_5nKs0}F%=bS_woiDhHEC`g`TV>=szC<7ZX zAQ&0?lo@zHba(~}nATMGb96B>SI}1o4e?c|%FjzxFf{b50SneJQ~*IsMR9q@jKaFy z;>P;cwt|N0ro!^}nxg#t{PK$8oc6}-riPlXwuzJKDl*EZ^wd;NZOAFFZdgCJp{uR1 nsIg|w^zz!;+=8rv> + PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.9786982138982,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]] + 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01 + + Gray + + left_vrt_subpixel_offset.tif + 1 + + + + + + right_top_vrt_subpixel_offset.tif + 1 + + + + + + right_bottom_vrt_subpixel_offset.tif + 1 + + + + + + diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index 495f342179d6..cefb86372c59 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -1425,6 +1425,19 @@ def vrt_float32_with_nodata_slightly_below_float_min(): return 'success' +############################################################################### +# Fix issue raised in https://lists.osgeo.org/pipermail/gdal-dev/2018-December/049415.html + +def vrt_subpixel_offset(): + + ds = gdal.Open('data/vrt_subpixel_offset.vrt') + cs = ds.GetRasterBand(1).Checksum() + if cs != 4849: + gdaltest.post_reason('fail') + print(cs) + return 'fail' + + return 'success' for item in init_list: ut = gdaltest.GDALTest('VRT', item[0], item[1], item[2]) @@ -1465,6 +1478,7 @@ def vrt_float32_with_nodata_slightly_below_float_min(): gdaltest_list.append(vrt_read_30) gdaltest_list.append(vrt_read_31) gdaltest_list.append(vrt_float32_with_nodata_slightly_below_float_min) +gdaltest_list.append(vrt_subpixel_offset) if __name__ == '__main__': diff --git a/gdal/frmts/gtiff/geotiff.cpp b/gdal/frmts/gtiff/geotiff.cpp index 50ed54dca595..1c358e28756a 100644 --- a/gdal/frmts/gtiff/geotiff.cpp +++ b/gdal/frmts/gtiff/geotiff.cpp @@ -4043,10 +4043,10 @@ void* GTiffRasterBand::CacheMultiRange( int nXOff, int nYOff, const double dfSrcXInc = dfXSize / static_cast( nBufXSize ); const double dfSrcYInc = dfYSize / static_cast( nBufYSize ); const double EPS = 1e-10; - const int nBlockX1 = static_cast((0+0.5) * dfSrcXInc + dfXOff + EPS) / nBlockXSize; - const int nBlockY1 = static_cast((0+0.5) * dfSrcYInc + dfYOff + EPS) / nBlockYSize; - const int nBlockX2 = static_cast((nBufXSize-1+0.5) * dfSrcXInc + dfXOff + EPS) / nBlockXSize; - const int nBlockY2 = static_cast((nBufYSize-1+0.5) * dfSrcYInc + dfYOff + EPS) / nBlockYSize; + const int nBlockX1 = static_cast(std::max(0.0, (0+0.5) * dfSrcXInc + dfXOff + EPS)) / nBlockXSize; + const int nBlockY1 = static_cast(std::max(0.0, (0+0.5) * dfSrcYInc + dfYOff + EPS)) / nBlockYSize; + const int nBlockX2 = static_cast(std::min(static_cast(nRasterXSize), (nBufXSize-1+0.5) * dfSrcXInc + dfXOff + EPS)) / nBlockXSize; + const int nBlockY2 = static_cast(std::min(static_cast(nRasterYSize), (nBufYSize-1+0.5) * dfSrcYInc + dfYOff + EPS)) / nBlockYSize; thandle_t th = TIFFClientdata( poGDS->hTIFF ); if( poGDS->SetDirectory() && !VSI_TIFFHasCachedRanges(th) ) diff --git a/gdal/frmts/vrt/vrtsources.cpp b/gdal/frmts/vrt/vrtsources.cpp index 53dc86c46903..350347dc637e 100644 --- a/gdal/frmts/vrt/vrtsources.cpp +++ b/gdal/frmts/vrt/vrtsources.cpp @@ -1120,24 +1120,41 @@ VRTSimpleSource::GetSrcDstWindow( int nXOff, int nYOff, int nXSize, int nYSize, const double dfScaleWinToBufX = nBufXSize / static_cast( nXSize ); - const double dfOutXOff = (dfDstULX - nXOff) * dfScaleWinToBufX+0.001; + const double dfOutXOff = (dfDstULX - nXOff) * dfScaleWinToBufX; if( dfOutXOff <= 0 ) *pnOutXOff = 0; else if( dfOutXOff > INT_MAX ) *pnOutXOff = INT_MAX; else - *pnOutXOff = (int) (dfOutXOff); - double dfOutRightXOff = (dfDstLRX - nXOff) * dfScaleWinToBufX-0.001; + *pnOutXOff = (int) (dfOutXOff+0.001); + + // Apply correction on floating-point source window + { + double dfDstDeltaX = (dfOutXOff - *pnOutXOff) / dfScaleWinToBufX; + double dfSrcDeltaX = dfDstDeltaX / m_dfDstXSize * m_dfSrcXSize; + *pdfReqXOff -= dfSrcDeltaX; + *pdfReqXSize = std::min( *pdfReqXSize + dfSrcDeltaX, + static_cast(INT_MAX) ); + } + + double dfOutRightXOff = (dfDstLRX - nXOff) * dfScaleWinToBufX; if( dfOutRightXOff < dfOutXOff ) return FALSE; if( dfOutRightXOff > INT_MAX ) dfOutRightXOff = INT_MAX; - *pnOutXSize = (int) ceil(dfOutRightXOff) - *pnOutXOff; + *pnOutXSize = (int) ceil(dfOutRightXOff-0.001) - *pnOutXOff; - *pnOutXOff = std::max(0, *pnOutXOff); if( *pnOutXSize > INT_MAX - *pnOutXOff || *pnOutXOff + *pnOutXSize > nBufXSize ) *pnOutXSize = nBufXSize - *pnOutXOff; + + // Apply correction on floating-point source window + { + double dfDstDeltaX = (ceil(dfOutRightXOff) - dfOutRightXOff) / dfScaleWinToBufX; + double dfSrcDeltaX = dfDstDeltaX / m_dfDstXSize * m_dfSrcXSize; + *pdfReqXSize = std::min( *pdfReqXSize + dfSrcDeltaX, + static_cast(INT_MAX) ); + } } if( bModifiedY ) @@ -1145,25 +1162,41 @@ VRTSimpleSource::GetSrcDstWindow( int nXOff, int nYOff, int nXSize, int nYSize, const double dfScaleWinToBufY = nBufYSize / static_cast( nYSize ); - const double dfOutYOff = (dfDstULY - nYOff) * dfScaleWinToBufY+0.001; + const double dfOutYOff = (dfDstULY - nYOff) * dfScaleWinToBufY; if( dfOutYOff <= 0 ) *pnOutYOff = 0; else if( dfOutYOff > INT_MAX ) *pnOutYOff = INT_MAX; else - *pnOutYOff = static_cast(dfOutYOff); - *pnOutYOff = (int) (dfOutYOff); - double dfOutTopYOff = (dfDstLRY - nYOff) * dfScaleWinToBufY-0.001; + *pnOutYOff = static_cast(dfOutYOff+0.001); + + // Apply correction on floating-point source window + { + double dfDstDeltaY = (dfOutYOff - *pnOutYOff) / dfScaleWinToBufY; + double dfSrcDeltaY = dfDstDeltaY / m_dfDstYSize * m_dfSrcYSize; + *pdfReqYOff -= dfSrcDeltaY; + *pdfReqYSize = std::min( *pdfReqYSize + dfSrcDeltaY, + static_cast(INT_MAX) ); + } + + double dfOutTopYOff = (dfDstLRY - nYOff) * dfScaleWinToBufY; if( dfOutTopYOff < dfOutYOff ) return FALSE; if( dfOutTopYOff > INT_MAX ) dfOutTopYOff = INT_MAX; - *pnOutYSize = static_cast( ceil(dfOutTopYOff) ) - *pnOutYOff; + *pnOutYSize = static_cast( ceil(dfOutTopYOff-0.001) ) - *pnOutYOff; - *pnOutYOff = std::max(0, *pnOutYOff); if( *pnOutYSize > INT_MAX - *pnOutYOff || *pnOutYOff + *pnOutYSize > nBufYSize ) *pnOutYSize = nBufYSize - *pnOutYOff; + + // Apply correction on floating-point source window + { + double dfDstDeltaY = (ceil(dfOutTopYOff) - dfOutTopYOff) / dfScaleWinToBufY; + double dfSrcDeltaY = dfDstDeltaY / m_dfDstYSize * m_dfSrcYSize; + *pdfReqYSize = std::min( *pdfReqYSize + dfSrcDeltaY, + static_cast(INT_MAX) ); + } } if( *pnOutXSize < 1 || *pnOutYSize < 1 ) diff --git a/gdal/gcore/rasterio.cpp b/gdal/gcore/rasterio.cpp index 1544be7ffd16..70825c7f4fcf 100644 --- a/gdal/gcore/rasterio.cpp +++ b/gdal/gcore/rasterio.cpp @@ -470,10 +470,6 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag, dfYOff = psExtraArg->dfYOff; dfXSize = psExtraArg->dfXSize; dfYSize = psExtraArg->dfYSize; - CPLAssert(dfXOff - nXOff < 1.0); - CPLAssert(dfYOff - nYOff < 1.0); - CPLAssert(nXSize - dfXSize < 1.0); - CPLAssert(nYSize - dfYSize < 1.0); } /* -------------------------------------------------------------------- */ @@ -657,7 +653,8 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag, // Add small epsilon to avoid some numeric precision issues. dfSrcY = (iBufYOff+0.5) * dfSrcYInc + dfYOff + EPS; dfSrcX = 0.5 * dfSrcXInc + dfXOff + EPS; - iSrcY = static_cast(dfSrcY); + iSrcY = static_cast(std::min(std::max(0.0, dfSrcY), + static_cast(nRasterYSize))); GPtrDiff_t iBufOffset = static_cast(iBufYOff) @@ -690,7 +687,9 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag, iBufXOff < nBufXSize; iBufXOff++, dfSrcX += dfSrcXInc ) { - iSrcX = static_cast( dfSrcX ); + // TODO?: try to avoid the clamping for most iterations + iSrcX = static_cast(std::min(std::max(0.0, dfSrcX), + static_cast(nRasterXSize))); /* -------------------------------------------------------------------- */ /* Ensure we have the appropriate block loaded. */ @@ -842,10 +841,6 @@ CPLErr GDALRasterBand::RasterIOResampled( dfYOff = psExtraArg->dfYOff; dfXSize = psExtraArg->dfXSize; dfYSize = psExtraArg->dfYSize; - CPLAssert(dfXOff - nXOff < 1.0); - CPLAssert(dfYOff - nYOff < 1.0); - CPLAssert(nXSize - dfXSize < 1.0); - CPLAssert(nYSize - dfYSize < 1.0); } const double dfXRatioDstToSrc = dfXSize / nBufXSize; @@ -1338,10 +1333,6 @@ CPLErr GDALDataset::RasterIOResampled( dfYOff = psExtraArg->dfYOff; dfXSize = psExtraArg->dfXSize; dfYSize = psExtraArg->dfYSize; - CPLAssert(dfXOff - nXOff < 1.0); - CPLAssert(dfYOff - nYOff < 1.0); - CPLAssert(nXSize - dfXSize < 1.0); - CPLAssert(nYSize - dfYSize < 1.0); } const double dfXRatioDstToSrc = dfXSize / nBufXSize; From 6f609bb956b7c0e0de7608f912fdebec5540a1e6 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 5 Dec 2018 16:55:58 +0000 Subject: [PATCH 106/488] cURL: added curl cookiefile and cookiejar variables (fixes #1000) Committer: Scott Henderson (scottyhq@gmail.com) --- gdal/port/cpl_http.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gdal/port/cpl_http.cpp b/gdal/port/cpl_http.cpp index 6a7feb1117f3..46f5df0a817e 100644 --- a/gdal/port/cpl_http.cpp +++ b/gdal/port/cpl_http.cpp @@ -1776,6 +1776,19 @@ void *CPLHTTPSetOptions(void *pcurl, const char* pszURL, pszCookie = CPLGetConfigOption("GDAL_HTTP_COOKIE", nullptr); if( pszCookie != nullptr ) curl_easy_setopt(http_handle, CURLOPT_COOKIE, pszCookie); + + const char* pszCookieFile = CSLFetchNameValue(papszOptions, "COOKIEFILE"); + if( pszCookieFile == nullptr ) + pszCookieFile = CPLGetConfigOption("GDAL_HTTP_COOKIEFILE", nullptr); + if( pszCookieFile != nullptr ) + curl_easy_setopt(http_handle, CURLOPT_COOKIEFILE, pszCookieFile); + + const char* pszCookieJar = CSLFetchNameValue(papszOptions, "COOKIEJAR"); + if( pszCookieJar == nullptr ) + pszCookieJar = CPLGetConfigOption("GDAL_HTTP_COOKIEJAR", nullptr); + if( pszCookieJar != nullptr ) + curl_easy_setopt(http_handle, CURLOPT_COOKIEJAR, pszCookieJar); + struct curl_slist* headers = nullptr; const char *pszHeaderFile = CSLFetchNameValue( papszOptions, "HEADER_FILE" ); From 7ad910793a73592b64bc03575dbeee5643c4eee6 Mon Sep 17 00:00:00 2001 From: Scott Henderson Date: Wed, 5 Dec 2018 17:32:34 +0000 Subject: [PATCH 107/488] documented new cookie options in Doxygen section of CPLHTTPFetch() --- gdal/port/cpl_http.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdal/port/cpl_http.cpp b/gdal/port/cpl_http.cpp index 46f5df0a817e..635f5ddc593a 100644 --- a/gdal/port/cpl_http.cpp +++ b/gdal/port/cpl_http.cpp @@ -586,6 +586,8 @@ static void CPLHTTPEmitFetchDebug(const char* pszURL, *

    • NETRC=[YES/NO] to enable or disable use of $HOME/.netrc, default YES.
    • *
    • CUSTOMREQUEST=val, where val is GET, PUT, POST, DELETE, etc.. (GDAL >= 1.9.0)
    • *
    • COOKIE=val, where val is formatted as COOKIE1=VALUE1; COOKIE2=VALUE2; ...
    • + *
    • COOKIEFILE=val, where val is file name to read cookies from (GDAL >= 2.4)
    • + *
    • COOKIEJAR=val, where val is file name to store cookies to (GDAL >= 2.4)
    • *
    • MAX_RETRY=val, where val is the maximum number of retry attempts if a 429, 502, 503 or * 504 HTTP error occurs. Default is 0. (GDAL >= 2.0)
    • *
    • RETRY_DELAY=val, where val is the number of seconds between retry attempts. From 7f866d27311cb7c38456fb300c50588045bed782 Mon Sep 17 00:00:00 2001 From: drons Date: Wed, 5 Dec 2018 21:47:12 +0300 Subject: [PATCH 108/488] MITAB: Made symbol ID checks more stringent - replace strstr by STARTS_WITH --- gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp index 7f69caf5895a..756f8219b388 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp @@ -1566,7 +1566,7 @@ void TABFontPoint::SetSymbolFromStyle(OGRStyleSymbol* poSymbolStyle) // Try to set font glyph number const char* pszSymbolId = poSymbolStyle->Id(bIsNull); - if((!bIsNull) && pszSymbolId && strstr(pszSymbolId, "font-sym-")) + if((!bIsNull) && pszSymbolId && STARTS_WITH(pszSymbolId, "font-sym-")) { const int nSymbolId = atoi(pszSymbolId+9); SetSymbolNo(static_cast(nSymbolId)); @@ -8902,16 +8902,14 @@ void ITABFeatureSymbol::SetSymbolFromStyle(OGRStyleSymbol* poSymbolStyle) const char *pszSymbolId = poSymbolStyle->Id(bIsNull); if(bIsNull) pszSymbolId = nullptr; - if(pszSymbolId && - (strstr(pszSymbolId, "mapinfo-sym-") || - strstr(pszSymbolId, "ogr-sym-")) ) + if(pszSymbolId) { - if(strstr(pszSymbolId, "mapinfo-sym-")) + if(STARTS_WITH(pszSymbolId, "mapinfo-sym-")) { const int nSymbolId = atoi(pszSymbolId+12); SetSymbolNo(static_cast(nSymbolId)); } - else if(strstr(pszSymbolId, "ogr-sym-")) + else if(STARTS_WITH(pszSymbolId, "ogr-sym-")) { const int nSymbolId = atoi(pszSymbolId+8); From 241ddd6210cbfad84dd2e83fa061c64ae0a8560d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 7 Dec 2018 11:58:04 +0100 Subject: [PATCH 109/488] gdal_grid: fix -clipsrc from a vector datasource (broken at least since GDAL 2.1) --- autotest/utilities/test_gdal_grid.py | 36 ++++++++++++++++++++++++++++ gdal/apps/gdal_grid_lib.cpp | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/autotest/utilities/test_gdal_grid.py b/autotest/utilities/test_gdal_grid.py index de53732b35f1..20708faca2df 100755 --- a/autotest/utilities/test_gdal_grid.py +++ b/autotest/utilities/test_gdal_grid.py @@ -919,6 +919,41 @@ def test_gdal_grid_12(): return 'success' +############################################################################### +# Test -clipsrc + + +def test_gdal_grid_clipsrc(): + if gdal_grid is None: + return 'skip' + + ################# + outfiles.append('tmp/grid_clipsrc.tif') + try: + os.remove(outfiles[-1]) + except OSError: + pass + + open('tmp/clip.csv', 'wt').write( + 'id,WKT\n1,"POLYGON((440750 3751340,440750 3750100,441900 3750100,441900 3751340,440750 3751340))"\n') + + # Create a GDAL dataset from the values of "grid.csv". + # Grid nodes are located exactly in raster nodes. + gdaltest.runexternal_out_and_err(gdal_grid + ' -clipsrc tmp/clip.csv -txe 440720.0 441920.0 -tye 3751320.0 3750120.0 -outsize 20 20 -ot Byte -l grid -a nearest:radius1=0.0:radius2=0.0:angle=0.0:nodata=0.0 data/grid.vrt ' + outfiles[-1]) + + os.unlink('tmp/clip.csv') + + # We should get the same values as in "gcore/data/byte.tif" + ds = gdal.Open(outfiles[-1]) + cs = ds.GetRasterBand(1).Checksum() + if cs == 0 or cs == 4672: + gdaltest.post_reason('bad checksum') + print(cs) + return 'fail' + ds = None + + return 'success' + ############################################################################### # Cleanup @@ -946,6 +981,7 @@ def test_gdal_grid_cleanup(): test_gdal_grid_10, test_gdal_grid_11, test_gdal_grid_12, + test_gdal_grid_clipsrc, test_gdal_grid_cleanup ] diff --git a/gdal/apps/gdal_grid_lib.cpp b/gdal/apps/gdal_grid_lib.cpp index e63cff254b5f..a7bc0ed53374 100644 --- a/gdal/apps/gdal_grid_lib.cpp +++ b/gdal/apps/gdal_grid_lib.cpp @@ -625,7 +625,8 @@ static OGRGeometryCollection* LoadGeometry( const char* pszDS, const char* pszLyr, const char* pszWhere ) { - GDALDataset *poDS = static_cast(GDALOpen(pszDS, GA_ReadOnly)); + GDALDataset *poDS = static_cast( + GDALOpenEx(pszDS, GDAL_OF_VECTOR, nullptr, nullptr, nullptr)); if ( poDS == nullptr ) return nullptr; From c4f363669c762fc82d3d044894635b2f6f89ae8b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 7 Dec 2018 20:18:55 +0100 Subject: [PATCH 110/488] Skip test_gdal_grid_clipsrc if GEOS not available --- autotest/utilities/test_gdal_grid.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autotest/utilities/test_gdal_grid.py b/autotest/utilities/test_gdal_grid.py index 20708faca2df..df09f584749b 100755 --- a/autotest/utilities/test_gdal_grid.py +++ b/autotest/utilities/test_gdal_grid.py @@ -40,6 +40,7 @@ from osgeo import ogr import gdaltest +import ogrtest import test_cli_utilities # List of output TIFF files that will be created by tests and later deleted @@ -927,6 +928,9 @@ def test_gdal_grid_clipsrc(): if gdal_grid is None: return 'skip' + if not ogrtest.have_geos(): + return 'skip' + ################# outfiles.append('tmp/grid_clipsrc.tif') try: From 6b5bc8879996c446736147f8e7968693f05e9cf3 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 9 Dec 2018 14:31:55 +0100 Subject: [PATCH 111/488] VRT: fix bug due to 52efc6ddb9cde38e0ef658ff7cdcfa4ca266e689 (master only) --- .../gcore/data/dstsize_larger_than_source.tif | Bin 0 -> 977 bytes .../gcore/data/dstsize_larger_than_source.vrt | 14 ++++++++++++++ autotest/gcore/vrt_read.py | 17 +++++++++++++++++ gdal/frmts/gtiff/geotiff.cpp | 4 ++-- gdal/gcore/rasterio.cpp | 4 ++-- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 autotest/gcore/data/dstsize_larger_than_source.tif create mode 100644 autotest/gcore/data/dstsize_larger_than_source.vrt diff --git a/autotest/gcore/data/dstsize_larger_than_source.tif b/autotest/gcore/data/dstsize_larger_than_source.tif new file mode 100644 index 0000000000000000000000000000000000000000..1f6128a44a6b996f3d1a2d9d816e685d41a60df4 GIT binary patch literal 977 zcmebD)MDUZU|~%mk2pAHHrGe_s0QLL@Vm+XLbb!$y zyYKM0*bm|8|~2(vRVumHmt1fet&%f@ywpdv<&jqU6VVhn7+ zz-DCVQ)b`+(aH5JU|Lf-+&x&q!bCw|AvDBSp(;NwRl(5EuLdGo!%#8j?Lk9ONE}-5 kZ)G~S{sNe_nDm46fK|7?k7^hep~Phmj_G}D(h>!Q0LLt)q5uE@ literal 0 HcmV?d00001 diff --git a/autotest/gcore/data/dstsize_larger_than_source.vrt b/autotest/gcore/data/dstsize_larger_than_source.vrt new file mode 100644 index 000000000000..5038472c9766 --- /dev/null +++ b/autotest/gcore/data/dstsize_larger_than_source.vrt @@ -0,0 +1,14 @@ + + PROJCS["WGS 84 / UTM zone 11N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32611"]] + 1.3468857985001034e+05, 5.0009600968988252e+01, 0.0000000000000000e+00, 4.0103732789101200e+06, 0.0000000000000000e+00, -5.0009600968988252e+01 + + Gray + + dstsize_larger_than_source.tif + 1 + + + + + + diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index cefb86372c59..c43d32ab3aa7 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -1439,6 +1439,22 @@ def vrt_subpixel_offset(): return 'success' + +############################################################################### +# Check bug fix of bug fix of +# https://lists.osgeo.org/pipermail/gdal-dev/2018-December/049415.html + +def vrt_dstsize_larger_than_source(): + + ds = gdal.Open('data/dstsize_larger_than_source.vrt') + cs = ds.GetRasterBand(1).Checksum() + if cs != 33273: + gdaltest.post_reason('fail') + print(cs) + return 'fail' + + return 'success' + for item in init_list: ut = gdaltest.GDALTest('VRT', item[0], item[1], item[2]) if ut is None: @@ -1479,6 +1495,7 @@ def vrt_subpixel_offset(): gdaltest_list.append(vrt_read_31) gdaltest_list.append(vrt_float32_with_nodata_slightly_below_float_min) gdaltest_list.append(vrt_subpixel_offset) +gdaltest_list.append(vrt_dstsize_larger_than_source) if __name__ == '__main__': diff --git a/gdal/frmts/gtiff/geotiff.cpp b/gdal/frmts/gtiff/geotiff.cpp index 1c358e28756a..50bff7d34e9d 100644 --- a/gdal/frmts/gtiff/geotiff.cpp +++ b/gdal/frmts/gtiff/geotiff.cpp @@ -4045,8 +4045,8 @@ void* GTiffRasterBand::CacheMultiRange( int nXOff, int nYOff, const double EPS = 1e-10; const int nBlockX1 = static_cast(std::max(0.0, (0+0.5) * dfSrcXInc + dfXOff + EPS)) / nBlockXSize; const int nBlockY1 = static_cast(std::max(0.0, (0+0.5) * dfSrcYInc + dfYOff + EPS)) / nBlockYSize; - const int nBlockX2 = static_cast(std::min(static_cast(nRasterXSize), (nBufXSize-1+0.5) * dfSrcXInc + dfXOff + EPS)) / nBlockXSize; - const int nBlockY2 = static_cast(std::min(static_cast(nRasterYSize), (nBufYSize-1+0.5) * dfSrcYInc + dfYOff + EPS)) / nBlockYSize; + const int nBlockX2 = static_cast(std::min(static_cast(nRasterXSize - 1), (nBufXSize-1+0.5) * dfSrcXInc + dfXOff + EPS)) / nBlockXSize; + const int nBlockY2 = static_cast(std::min(static_cast(nRasterYSize - 1), (nBufYSize-1+0.5) * dfSrcYInc + dfYOff + EPS)) / nBlockYSize; thandle_t th = TIFFClientdata( poGDS->hTIFF ); if( poGDS->SetDirectory() && !VSI_TIFFHasCachedRanges(th) ) diff --git a/gdal/gcore/rasterio.cpp b/gdal/gcore/rasterio.cpp index 70825c7f4fcf..c1bfb28e8c08 100644 --- a/gdal/gcore/rasterio.cpp +++ b/gdal/gcore/rasterio.cpp @@ -654,7 +654,7 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag, dfSrcY = (iBufYOff+0.5) * dfSrcYInc + dfYOff + EPS; dfSrcX = 0.5 * dfSrcXInc + dfXOff + EPS; iSrcY = static_cast(std::min(std::max(0.0, dfSrcY), - static_cast(nRasterYSize))); + static_cast(nRasterYSize - 1))); GPtrDiff_t iBufOffset = static_cast(iBufYOff) @@ -689,7 +689,7 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag, { // TODO?: try to avoid the clamping for most iterations iSrcX = static_cast(std::min(std::max(0.0, dfSrcX), - static_cast(nRasterXSize))); + static_cast(nRasterXSize - 1))); /* -------------------------------------------------------------------- */ /* Ensure we have the appropriate block loaded. */ From fbfb0dc354235da8ad6daa0824f9e52cf8ef2a2c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 9 Dec 2018 17:49:27 +0100 Subject: [PATCH 112/488] Internal libtiff: resync with upstream (Do not attempt to re-sync zip stream after reported data error from inflate()) --- gdal/frmts/gtiff/libtiff/tif_pixarlog.c | 4 ++-- gdal/frmts/gtiff/libtiff/tif_zip.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gdal/frmts/gtiff/libtiff/tif_pixarlog.c b/gdal/frmts/gtiff/libtiff/tif_pixarlog.c index 7438d6921511..77620e3da64b 100644 --- a/gdal/frmts/gtiff/libtiff/tif_pixarlog.c +++ b/gdal/frmts/gtiff/libtiff/tif_pixarlog.c @@ -817,8 +817,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) TIFFErrorExt(tif->tif_clientdata, module, "Decoding error at scanline %lu, %s", (unsigned long) tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); - if (inflateSync(&sp->stream) != Z_OK) - return (0); + /* if (inflateSync(&sp->stream) != Z_OK) */ + return (0); continue; } if (state != Z_OK) { diff --git a/gdal/frmts/gtiff/libtiff/tif_zip.c b/gdal/frmts/gtiff/libtiff/tif_zip.c index 9d4bceb179c4..b71c44e829b8 100644 --- a/gdal/frmts/gtiff/libtiff/tif_zip.c +++ b/gdal/frmts/gtiff/libtiff/tif_zip.c @@ -179,8 +179,8 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) TIFFErrorExt(tif->tif_clientdata, module, "Decoding error at scanline %lu, %s", (unsigned long) tif->tif_row, SAFE_MSG(sp)); - if (inflateSync(&sp->stream) != Z_OK) - return (0); + /* if (inflateSync(&sp->stream) != Z_OK) */ + return (0); continue; } if (state != Z_OK) { From b21bb7a43d02a7aca72085bd501aeb5eca295367 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 10 Dec 2018 15:51:24 +0100 Subject: [PATCH 113/488] typo fix [ci skip] --- gdal/ogr/ogrsf_frmts/gpkg/drv_geopackage_raster.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdal/ogr/ogrsf_frmts/gpkg/drv_geopackage_raster.html b/gdal/ogr/ogrsf_frmts/gpkg/drv_geopackage_raster.html index e84db2459044..783fbbfbc0da 100644 --- a/gdal/ogr/ogrsf_frmts/gpkg/drv_geopackage_raster.html +++ b/gdal/ogr/ogrsf_frmts/gpkg/drv_geopackage_raster.html @@ -258,7 +258,7 @@

      Nodata value

      datasets. For regular tiled rasters, the alpha band must rather be used.

      For Float32 datasets with TIFF tiles, the concepts of nodata in GDAL -and null_value in the GeoPackage internasl perfectly match.

      +and null_value in the GeoPackage internals perfectly match.

      For Int16, UInt16 or Float32 with PNG tiles, GDAL will generally remap the input nodata value to another value.

      From 38d3e28ebb765b56749b67416f0c4113c5191478 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Tue, 2 Oct 2018 23:05:53 +1300 Subject: [PATCH 114/488] Ditch testing for shlex/subprocess modules They've been around for ages --- autotest/pymod/gdaltest_python2.py | 38 +++++++----------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/autotest/pymod/gdaltest_python2.py b/autotest/pymod/gdaltest_python2.py index fcd226224075..35c27fbcea77 100644 --- a/autotest/pymod/gdaltest_python2.py +++ b/autotest/pymod/gdaltest_python2.py @@ -32,6 +32,8 @@ import urllib2 import socket import os +import subprocess +import shlex import sys from sys import version_info from Queue import Queue @@ -124,8 +126,6 @@ def warn_if_memleak(cmd, out_str): def spawn_async26(cmd): - import shlex - import subprocess command = shlex.split(cmd) try: process = subprocess.Popen(command, stdout=subprocess.PIPE) @@ -157,8 +157,6 @@ def wait_process(process): def _runexternal_subprocess(cmd, strin=None, check_memleak=True, display_live_on_parent_stdout=False, encoding=None): # pylint: disable=unused-argument - import subprocess - import shlex command = shlex.split(cmd) command = [elt.replace('\x00', '') for elt in command] if strin is None: @@ -196,20 +194,11 @@ def _runexternal_subprocess(cmd, strin=None, check_memleak=True, display_live_on def runexternal(cmd, strin=None, check_memleak=True, display_live_on_parent_stdout=False, encoding=None): from gdaltest import is_travis_branch if not is_travis_branch('mingw'): - has_subprocess = False - try: - import subprocess - import shlex - if hasattr(subprocess, 'Popen') and hasattr(shlex, 'split'): - has_subprocess = True - except (ImportError, AttributeError): - pass - if has_subprocess: - return _runexternal_subprocess(cmd, - strin=strin, - check_memleak=check_memleak, - display_live_on_parent_stdout=display_live_on_parent_stdout, - encoding=encoding) + return _runexternal_subprocess(cmd, + strin=strin, + check_memleak=check_memleak, + display_live_on_parent_stdout=display_live_on_parent_stdout, + encoding=encoding) if strin is None: ret_stdout = os.popen(cmd) @@ -248,8 +237,6 @@ def read_in_thread(f, q): def _runexternal_out_and_err_subprocess(cmd, check_memleak=True): # pylint: disable=unused-argument - import subprocess - import shlex command = shlex.split(cmd) command = [elt.replace('\x00', '') for elt in command] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -285,16 +272,7 @@ def _runexternal_out_and_err_subprocess(cmd, check_memleak=True): def runexternal_out_and_err(cmd, check_memleak=True): from gdaltest import is_travis_branch if not is_travis_branch('mingw'): - has_subprocess = False - try: - import subprocess - import shlex - if hasattr(subprocess, 'Popen') and hasattr(shlex, 'split'): - has_subprocess = True - except ImportError: - pass - if has_subprocess: - return _runexternal_out_and_err_subprocess(cmd, check_memleak=check_memleak) + return _runexternal_out_and_err_subprocess(cmd, check_memleak=check_memleak) (ret_stdin, ret_stdout, ret_stderr) = os.popen3(cmd) ret_stdin.close() From caa6a31f96193e511536de11b3a4d0dd3ce396a1 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Tue, 2 Oct 2018 23:40:21 +1300 Subject: [PATCH 115/488] WIP: refactor some dynamic tests to use pytest parametrization --- autotest/gcore/hfa_srs.py | 146 +++++++++++++---------------------- autotest/ogr/ogr_wktempty.py | 62 +++++---------- 2 files changed, 74 insertions(+), 134 deletions(-) diff --git a/autotest/gcore/hfa_srs.py b/autotest/gcore/hfa_srs.py index 6140d3d33eb7..47f23f910e8d 100755 --- a/autotest/gcore/hfa_srs.py +++ b/autotest/gcore/hfa_srs.py @@ -30,105 +30,65 @@ import sys +import pytest + from osgeo import gdal from osgeo import osr sys.path.append('../pymod') -import gdaltest - ############################################################################### # Write a HFA/Imagine and read it back to check its SRS -class TestHFASRS(object): - def __init__(self, epsg_code, use_epsg_code, expected_fail): - self.epsg_code = epsg_code - self.use_epsg_code = use_epsg_code - self.expected_fail = expected_fail - - def test(self): - sr = osr.SpatialReference() - sr.ImportFromEPSG(self.epsg_code) - if self.use_epsg_code == 0: - proj4str = sr.ExportToProj4() - # print(proj4str) - sr.SetFromUserInput(proj4str) - - ds = gdal.GetDriverByName('HFA').Create('/vsimem/TestHFASRS.img', 1, 1) - ds.SetProjection(sr.ExportToWkt()) - ds = None - - ds = gdal.Open('/vsimem/TestHFASRS.img') - wkt = ds.GetProjectionRef() - sr2 = osr.SpatialReference() - sr2.SetFromUserInput(wkt) - ds = None - - gdal.Unlink('/vsimem/TestHFASRS.img') - - # For EPSG:2065. Those 2 datums are translated into D_S_JTSK in ESRI WKT... So for the purpose of - # comparison, substitute one for another - if sr.ExportToWkt().find('"System_Jednotne_Trigonometricke_Site_Katastralni_Ferro"') != -1 and \ - sr2.ExportToWkt().find('"System_Jednotne_Trigonometricke_Site_Katastralni"') != -1: - wkt2 = sr2.ExportToWkt().replace('"System_Jednotne_Trigonometricke_Site_Katastralni"', '"System_Jednotne_Trigonometricke_Site_Katastralni_Ferro"') - sr2.SetFromUserInput(wkt2) - - if (self.epsg_code == 4326 and sr2.GetAuthorityCode(None) != '4326') or sr.IsSame(sr2) != 1: - if self.expected_fail: - print('did not get expected SRS. known to be broken currently. FIXME!') - # print(sr) - # print(sr2) - return 'expected_fail' - - gdaltest.post_reason('did not get expected SRS') - print(sr) - print(sr2) - return 'fail' - - return 'success' - - -gdaltest_list = [] - -hfa_srs_list = [2758, # tmerc - [2036, True], # sterea # failure caused by revert done in r22803 - 2046, # tmerc - [3031, True], # stere - [32661, True], # stere - 3035, # laea - 2062, # lcc - 2065, # krovak - 2066, # cass - 2964, # aea - [3410, True], # cea - [3786, True], # eqc - [2934, True], # merc - 27200, # nzmg - [2057, True], # omerc - 29100, # poly - 2056, # somerc - 2027, # utm - 4326, # longlat - ] - -for item in hfa_srs_list: - try: - epsg_code = item[0] - epsg_broken = item[1] - except TypeError: - epsg_code = item - epsg_broken = False - - ut = TestHFASRS(epsg_code, 1, epsg_broken) - gdaltest_list.append((ut.test, "hfa_srs_epsg_%d" % epsg_code)) - # ut = TestHFASRS( epsg_code, 0, epsg_proj4_broken ) - # gdaltest_list.append( (ut.test, "hfa_srs_proj4_of_epsg_%d" % epsg_code) ) - -if __name__ == '__main__': - - gdaltest.setup_run('hfa_srs') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) +@pytest.mark.parametrize('epsg_code,epsg_broken', [ + [2758, False], # tmerc + [2036, True], # sterea # failure caused by revert done in r22803 + [2046, False], # tmerc + [3031, True], # stere + [32661, True], # stere + [3035, False], # laea + [2062, False], # lcc + [2065, False], # krovak + [2066, False], # cass + [2964, False], # aea + [3410, True], # cea + [3786, True], # eqc + [2934, True], # merc + [27200, False], # nzmg + [2057, True], # omerc + [29100, False], # poly + [2056, False], # somerc + [2027, False], # utm + [4326, False], # longlat +]) +def test_hfa_srs(epsg_code, epsg_broken): + sr = osr.SpatialReference() + sr.ImportFromEPSG(epsg_code) + + ds = gdal.GetDriverByName('HFA').Create('/vsimem/TestHFASRS.img', 1, 1) + ds.SetProjection(sr.ExportToWkt()) + ds = None + + ds = gdal.Open('/vsimem/TestHFASRS.img') + wkt = ds.GetProjectionRef() + sr2 = osr.SpatialReference() + sr2.SetFromUserInput(wkt) + ds = None + + gdal.Unlink('/vsimem/TestHFASRS.img') + + # For EPSG:2065. Those 2 datums are translated into D_S_JTSK in ESRI WKT... So for the purpose of + # comparison, substitute one for another + if sr.ExportToWkt().find('"System_Jednotne_Trigonometricke_Site_Katastralni_Ferro"') != -1 and \ + sr2.ExportToWkt().find('"System_Jednotne_Trigonometricke_Site_Katastralni"') != -1: + wkt2 = sr2.ExportToWkt().replace('"System_Jednotne_Trigonometricke_Site_Katastralni"', '"System_Jednotne_Trigonometricke_Site_Katastralni_Ferro"') + sr2.SetFromUserInput(wkt2) + + if (epsg_code == 4326 and sr2.GetAuthorityCode(None) != '4326') or sr.IsSame(sr2) != 1: + if epsg_broken: + pytest.xfail('did not get expected SRS. known to be broken currently. FIXME!') + + print(sr) + print(sr2) + assert False, 'did not get expected SRS' diff --git a/autotest/ogr/ogr_wktempty.py b/autotest/ogr/ogr_wktempty.py index a683e93c485d..3e37eede4d19 100755 --- a/autotest/ogr/ogr_wktempty.py +++ b/autotest/ogr/ogr_wktempty.py @@ -28,48 +28,13 @@ import sys -sys.path.append('../pymod') +import pytest import gdaltest from osgeo import ogr -class TestWktEmpty(object): - def __init__(self, inString, expectedOutString): - self.inString = inString - self.expectedOutString = expectedOutString - - def isEmpty(self, geom): - try: - ogr.Geometry.IsEmpty - except AttributeError: - return 'skip' - - if not geom.IsEmpty(): - geom.Destroy() - gdaltest.post_reason("IsEmpty returning false for an empty geometry") - return 'fail' - - return 'success' - - def CheckIsEmpty(self): - geom = ogr.CreateGeometryFromWkt(self.inString) - wkt = geom.ExportToWkt() - - if self.expectedOutString != 'POINT EMPTY': - if ogr.CreateGeometryFromWkb(geom.ExportToWkb()).ExportToWkt() != wkt: - return 'fail' - - if wkt == self.expectedOutString: - if self.isEmpty(geom) == 'fail': - return 'fail' - return 'success' - else: - gdaltest.post_reason('WKT is wrong: ' + wkt + '. Expected value is: ' + self.expectedOutString) - return 'fail' - - -empty_wkt_list = [ +@pytest.mark.parametrize("test_input,expected", [ ('GEOMETRYCOLLECTION(EMPTY)', 'GEOMETRYCOLLECTION EMPTY'), ('MULTIPOLYGON( EMPTY )', 'MULTIPOLYGON EMPTY'), ('MULTILINESTRING(EMPTY)', 'MULTILINESTRING EMPTY'), @@ -85,7 +50,25 @@ def CheckIsEmpty(self): ('POINT EMPTY', 'POINT EMPTY'), ('LINESTRING EMPTY', 'LINESTRING EMPTY'), ('POLYGON EMPTY', 'POLYGON EMPTY') -] +]) +def test_empty_wkt(test_input, expected): + geom = ogr.CreateGeometryFromWkt(test_input) + wkt = geom.ExportToWkt() + + if expected != 'POINT EMPTY': + assert ogr.CreateGeometryFromWkb(geom.ExportToWkb()).ExportToWkt() == wkt + + assert wkt == expected + + try: + ogr.Geometry.IsEmpty + except AttributeError: + pytest.skip() + + try: + assert geom.IsEmpty(), "IsEmpty returning false for an empty geometry" + finally: + geom.Destroy() def ogr_wktempty_test_partial_empty_geoms(): @@ -169,9 +152,6 @@ def ogr_wktempty_test_partial_empty_geoms(): gdaltest_list = [] -for item in empty_wkt_list: - ut = TestWktEmpty(item[0], item[1]) - gdaltest_list.append((ut.CheckIsEmpty, item[0])) gdaltest_list.append(ogr_wktempty_test_partial_empty_geoms) if __name__ == '__main__': From 4452a3b41e08c626b90c57c06e58de337c42c9b2 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Tue, 2 Oct 2018 23:41:09 +1300 Subject: [PATCH 116/488] Pytest config --- autotest/GNUmakefile | 14 +++++++------- autotest/conftest.py | 23 +++++++++++++++++++++++ autotest/pytest.ini | 3 +++ 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 autotest/conftest.py create mode 100644 autotest/pytest.ini diff --git a/autotest/GNUmakefile b/autotest/GNUmakefile index c0fa6c8c7ea8..61e42ea9a772 100644 --- a/autotest/GNUmakefile +++ b/autotest/GNUmakefile @@ -2,25 +2,25 @@ all: @echo "Run 'make -j test'" gcore-test: - python run_all.py gcore + pytest gcore gdrivers-test: - python run_all.py gdrivers + pytest gdrivers alg-test: - python run_all.py alg + pytest alg osr-test: - python run_all.py osr + pytest osr ogr-test: - python run_all.py ogr + pytest ogr utilities-test: - python run_all.py utilities + pytest utilities pyscripts-test: - python run_all.py pyscripts + pytest pyscripts test check: @$(MAKE) $(MFLAGS) gcore-test gdrivers-test alg-test ogr-test osr-test utilities-test pyscripts-test diff --git a/autotest/conftest.py b/autotest/conftest.py new file mode 100644 index 000000000000..5706d8cff2e7 --- /dev/null +++ b/autotest/conftest.py @@ -0,0 +1,23 @@ +# coding: utf-8 +from __future__ import absolute_import, division, print_function, unicode_literals + +import os +import sys + +import pytest + +sys.path.insert(0, "pymod") +sys.path.insert(0, ".") + + +@pytest.fixture(scope="module", autouse=True) +def chdir_to_test_file(request): + """ + Changes to the same directory as the test file. + Tests have grown to expect this. + """ + old = os.getcwd() + + os.chdir(os.path.dirname(request.module.__file__)) + yield + os.chdir(old) diff --git a/autotest/pytest.ini b/autotest/pytest.ini new file mode 100644 index 000000000000..c25ef5fa7e75 --- /dev/null +++ b/autotest/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = *.py +testpaths = ogr gcore gdrivers osr alg gnm utilities pyscripts From 9151d45b87df8ef85d40adbdda91199966b5bcc7 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Tue, 2 Oct 2018 23:42:01 +1300 Subject: [PATCH 117/488] Remove hacky method to run scripts as imported The *need* for this hack is unclear. Docstring states it's so the interpreter doesn't need to guess it's own name, but the `_as_external_script` variant is alive and well and being used in other parts of the codebase, so it works fine. This hack seems to play weirdly with pytest (maybe something to do with the output capturing?) and it seemed best to just remove it. --- autotest/pymod/test_py_scripts.py | 91 +------------------------------ 1 file changed, 2 insertions(+), 89 deletions(-) diff --git a/autotest/pymod/test_py_scripts.py b/autotest/pymod/test_py_scripts.py index 056a1e9fafd0..930dc69eb538 100644 --- a/autotest/pymod/test_py_scripts.py +++ b/autotest/pymod/test_py_scripts.py @@ -61,27 +61,12 @@ def get_py_script(script_name): return None -############################################################################### -# Utility function of run_py_script_as_py_module() -# -has_main = False - - -def find_main_in_module(names): - global has_main - has_main = 'main' in names - - ############################################################################### # Runs a Python script +# Alias of run_py_script_as_external_script() # def run_py_script(script_path, script_name, concatenated_argv): - - run_as_external_script = gdal.GetConfigOption('RUN_AS_EXTERNAL_SCRIPT', 'NO') - - if run_as_external_script == 'yes' or run_as_external_script == 'YES': - return run_py_script_as_external_script(script_path, script_name, concatenated_argv) - return run_py_script_as_py_module(script_path, script_name, concatenated_argv) + return run_py_script_as_external_script(script_path, script_name, concatenated_argv) ############################################################################### @@ -99,75 +84,3 @@ def run_py_script_as_external_script(script_path, script_name, concatenated_argv script_file_path = script_file_path.replace('\\', '/') return gdaltest.runexternal(python_exe + ' ' + script_file_path + ' ' + concatenated_argv, display_live_on_parent_stdout=display_live_on_parent_stdout) - -############################################################################### -# Runs a Python script as a py module -# -# This function is an interesting concentrate of dirty hacks to run python -# scripts without forking a new process. This way we don't need to know the -# name and path of the python interpreter. -# - - -def run_py_script_as_py_module(script_path, script_name, concatenated_argv): - - # Save original sys variables - saved_syspath = sys.path - saved_sysargv = sys.argv - - sys.path.append(script_path) - - # Replace argv by user provided one - # Add first a fake first arg that we set to be the script - # name but which could be any arbitrary name - sys.argv = [script_name + '.py'] - - import shlex - sys.argv.extend(shlex.split(concatenated_argv)) - - has_imported_module = False - - ret = None - - if os.path.exists('tmp'): - tmp_stdout = 'tmp/stdout.txt' - else: - tmp_stdout = 'stdout.txt' - - try: - # Redirect stdout to file - fout = open(tmp_stdout, 'wt') - ori_stdout = sys.stdout - sys.stdout = fout - - exec('import ' + script_name) - has_imported_module = True - - # Detect if the script has a main() function - exec('find_main_in_module(dir(' + script_name + '))') - - # If so, run it (otherwise the import has already run the script) - if has_main: - exec(script_name + '.main()') - finally: - # Restore original stdout - fout.close() - sys.stdout = ori_stdout - - fout = open(tmp_stdout, 'rt') - ret = fout.read() - fout.close() - - os.remove(tmp_stdout) - - # Restore original sys variables - sys.path = saved_syspath - sys.argv = saved_sysargv - - if has_imported_module: - # Unload the module so that it gets imported again next time - # (useful if wanting to run a script without main() function - # several time) - del sys.modules[script_name] - - return ret From bb0f12e2b98086c3fa33175dfe91cf1097d3751d Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Wed, 3 Oct 2018 10:16:14 +1300 Subject: [PATCH 118/488] Minimal changes to fix test collection-time errors with pytest --- autotest/conftest.py | 17 +++- autotest/gdrivers/envisat.py | 61 +++----------- autotest/gdrivers/mrf.py | 137 +++++++++++++------------------- autotest/ogr/ogr_gml_geom.py | 2 +- autotest/ogr/ogr_gpkg.py | 4 +- autotest/ogr/ogr_wkbwkt_geom.py | 2 +- autotest/osr/osr_metacrs.py | 3 +- 7 files changed, 91 insertions(+), 135 deletions(-) diff --git a/autotest/conftest.py b/autotest/conftest.py index 5706d8cff2e7..8c885b42ae73 100644 --- a/autotest/conftest.py +++ b/autotest/conftest.py @@ -6,18 +6,31 @@ import pytest -sys.path.insert(0, "pymod") -sys.path.insert(0, ".") +# Put the pymod dir on the path, so modules can `import gdaltest` +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "pymod")) + +# These files may be non-importable, and don't contain tests anyway. +# So we skip searching them during test collection. +collect_ignore = ["gdrivers/netcdf_cfchecks.py"] @pytest.fixture(scope="module", autouse=True) def chdir_to_test_file(request): """ Changes to the same directory as the test file. + Also puts that directory at the start of sys.path, + so that imports of other files in the same directory are easy. + Tests have grown to expect this. + + NOTE: This happens when the test is *run*, not during collection. + So test modules must not rely on it at module level. """ old = os.getcwd() os.chdir(os.path.dirname(request.module.__file__)) + sys.path.insert(0, ".") yield + if sys.path and sys.path[0] == ".": + sys.path.pop(0) os.chdir(old) diff --git a/autotest/gdrivers/envisat.py b/autotest/gdrivers/envisat.py index 0cdeb4c62587..5ebc48a1f3a0 100755 --- a/autotest/gdrivers/envisat.py +++ b/autotest/gdrivers/envisat.py @@ -31,7 +31,6 @@ ############################################################################### import os -import sys import gzip from osgeo import gdal @@ -75,15 +74,9 @@ def _get_mds_num(filename): # -class TestEnvisat(object): +class EnvisatTestBase(object): # Just a base class - def __init__(self, downloadURL, fileName, size, checksum): - self.downloadURL = downloadURL - self.fileName = fileName - self.size = size - self.checksum = checksum - def download_file(self): # download and decompress if not gdaltest.download_file(self.downloadURL, os.path.basename(self.downloadURL), -1): @@ -193,7 +186,12 @@ def test_envisat_5(self): # -class TestEnvisatASAR(TestEnvisat): +class TestEnvisatASAR(EnvisatTestBase): + downloadURL = 'http://earth.esa.int/services/sample_products/asar/DS1/WS/ASA_WS__BPXPDE20020714_100425_000001202007_00380_01937_0053.N1.gz' + fileName = 'ASA_WS__BPXPDE20020714_100425_000001202007_00380_01937_0053.N1' + size = (524, 945) + checksum = 44998 + def test_envisat_asar_1(self): # test sensor ID @@ -261,7 +259,12 @@ def test_envisat_asar_2(self): # -class TestEnvisatMERIS(TestEnvisat): +class TestEnvisatMERIS(EnvisatTestBase): + downloadURL = 'http://earth.esa.int/services/sample_products/meris/RRC/L2/MER_RRC_2PTGMV20000620_104318_00000104X000_00000_00000_0001.N1.gz' + fileName = 'MER_RRC_2PTGMV20000620_104318_00000104X000_00000_00000_0001.N1' + size = (1121, 593) + checksum = 55146 + def test_envisat_meris_1(self): # test sensor ID @@ -406,41 +409,3 @@ def test_envisat_meris_4(self): return 'fail' return 'success' - - -ut1 = TestEnvisatASAR( - 'http://earth.esa.int/services/sample_products/asar/DS1/WS/ASA_WS__BPXPDE20020714_100425_000001202007_00380_01937_0053.N1.gz', - 'ASA_WS__BPXPDE20020714_100425_000001202007_00380_01937_0053.N1', - (524, 945), - 44998) -ut2 = TestEnvisatMERIS( - 'http://earth.esa.int/services/sample_products/meris/RRC/L2/MER_RRC_2PTGMV20000620_104318_00000104X000_00000_00000_0001.N1.gz', - 'MER_RRC_2PTGMV20000620_104318_00000104X000_00000_00000_0001.N1', - (1121, 593), - 55146) - -gdaltest_list = [ - ut1.test_envisat_1, - ut1.test_envisat_2, - ut1.test_envisat_3, - ut1.test_envisat_4, - ut1.test_envisat_asar_1, - ut1.test_envisat_asar_2, - ut2.test_envisat_1, - ut2.test_envisat_2, - ut2.test_envisat_3, - ut2.test_envisat_4, - ut2.test_envisat_meris_1, - ut2.test_envisat_meris_2, - ut2.test_envisat_meris_3, - ut2.test_envisat_meris_4, -] - - -if __name__ == '__main__': - - gdaltest.setup_run('envisat') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index be480ae7f85e..d9f2fc72ad60 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -31,48 +31,69 @@ import sys import glob +import pytest + sys.path.append('../pymod') from osgeo import gdal import gdaltest -init_list = [ - ('byte.tif', 1, 4672, None), - ('byte.tif', 1, 4672, ['COMPRESS=DEFLATE']), - ('byte.tif', 1, 4672, ['COMPRESS=NONE']), - ('byte.tif', 1, 4672, ['COMPRESS=LERC']), - ('byte.tif', 1, [4672, 5015], ['COMPRESS=LERC', 'OPTIONS:LERC_PREC=10']), - ('byte.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('int16.tif', 1, 4672, None), - ('int16.tif', 1, 4672, ['COMPRESS=LERC']), - ('int16.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('../../gcore/data/uint16.tif', 1, 4672, None), - ('../../gcore/data/uint16.tif', 1, 4672, ['COMPRESS=LERC']), - ('../../gcore/data/uint16.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('../../gcore/data/int32.tif', 1, 4672, ['COMPRESS=TIF']), - ('../../gcore/data/int32.tif', 1, 4672, ['COMPRESS=LERC']), - ('../../gcore/data/int32.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('../../gcore/data/uint32.tif', 1, 4672, ['COMPRESS=TIF']), - ('../../gcore/data/uint32.tif', 1, 4672, ['COMPRESS=LERC']), - ('../../gcore/data/uint32.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('../../gcore/data/float32.tif', 1, 4672, ['COMPRESS=TIF']), - ('../../gcore/data/float32.tif', 1, 4672, ['COMPRESS=LERC']), - ('../../gcore/data/float32.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('../../gcore/data/float64.tif', 1, 4672, ['COMPRESS=TIF']), - ('../../gcore/data/float64.tif', 1, 4672, ['COMPRESS=LERC']), - ('../../gcore/data/float64.tif', 1, [4672, 5015], ['COMPRESS=LERC', 'OPTIONS:LERC_PREC=10']), - ('../../gcore/data/float64.tif', 1, 4672, ['COMPRESS=LERC', 'OPTIONS=V1:YES']), - ('../../gcore/data/utmsmall.tif', 1, 50054, None), - ('small_world_pct.tif', 1, 14890, ['COMPRESS=PPNG']), - ('byte.tif', 1, [4672, [4603, 4652]], ['COMPRESS=JPEG', 'QUALITY=99']), + +@pytest.mark.parametrize('src_filename,chksum,chksum_after_reopening,options', [ + ('byte.tif', 4672, [4672], []), + ('byte.tif', 4672, [4672], ['COMPRESS=DEFLATE']), + ('byte.tif', 4672, [4672], ['COMPRESS=NONE']), + ('byte.tif', 4672, [4672], ['COMPRESS=LERC']), + ('byte.tif', 4672, [5015], ['COMPRESS=LERC', 'OPTIONS:LERC_PREC=10']), + ('byte.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('int16.tif', 4672, [4672], []), + ('int16.tif', 4672, [4672], ['COMPRESS=LERC']), + ('int16.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('../../gcore/data/uint16.tif', 4672, [4672], []), + ('../../gcore/data/uint16.tif', 4672, [4672], ['COMPRESS=LERC']), + ('../../gcore/data/uint16.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('../../gcore/data/int32.tif', 4672, [4672], ['COMPRESS=TIF']), + ('../../gcore/data/int32.tif', 4672, [4672], ['COMPRESS=LERC']), + ('../../gcore/data/int32.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('../../gcore/data/uint32.tif', 4672, [4672], ['COMPRESS=TIF']), + ('../../gcore/data/uint32.tif', 4672, [4672], ['COMPRESS=LERC']), + ('../../gcore/data/uint32.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('../../gcore/data/float32.tif', 4672, [4672], ['COMPRESS=TIF']), + ('../../gcore/data/float32.tif', 4672, [4672], ['COMPRESS=LERC']), + ('../../gcore/data/float32.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('../../gcore/data/float64.tif', 4672, [4672], ['COMPRESS=TIF']), + ('../../gcore/data/float64.tif', 4672, [4672], ['COMPRESS=LERC']), + ('../../gcore/data/float64.tif', 4672, [5015], ['COMPRESS=LERC', 'OPTIONS:LERC_PREC=10']), + ('../../gcore/data/float64.tif', 4672, [4672], ['COMPRESS=LERC', 'OPTIONS=V1:YES']), + ('../../gcore/data/utmsmall.tif', 50054, [50054], []), + ('small_world_pct.tif', 14890, [14890], ['COMPRESS=PPNG']), + ('byte.tif', 4672, [4603, 4652], ['COMPRESS=JPEG', 'QUALITY=99']), # following expected checksums are for: gcc 4.4 debug, mingw/vc9 32-bit, mingw-w64/vc12 64bit, MacOSX - ('rgbsmall.tif', 1, [21212, [21162, 21110, 21155, 21116]], ['COMPRESS=JPEG', 'QUALITY=99']), - ('rgbsmall.tif', 1, [21212, [21266, 21369, 21256, 21495]], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99']), - ('rgbsmall.tif', 1, [21212, [21261, 21209, 21254, 21215]], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99', 'PHOTOMETRIC=RGB']), - ('rgbsmall.tif', 1, [21212, [21283, 21127, 21278, 21124]], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99', 'PHOTOMETRIC=YCC']), - ('12bit_rose_extract.jpg', 1, [30075, [29650, 29680, 29680, 29650]], ['COMPRESS=JPEG']), -] + ('rgbsmall.tif', 21212, [21162, 21110, 21155, 21116], ['COMPRESS=JPEG', 'QUALITY=99']), + ('rgbsmall.tif', 21212, [21266, 21369, 21256, 21495], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99']), + ('rgbsmall.tif', 21212, [21261, 21209, 21254, 21215], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99', 'PHOTOMETRIC=RGB']), + ('rgbsmall.tif', 21212, [21283, 21127, 21278, 21124], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99', 'PHOTOMETRIC=YCC']), + ('12bit_rose_extract.jpg', 30075, [29650, 29680, 29680, 29650], ['COMPRESS=JPEG']), +]) +def test_mrf(src_filename, chksum, chksum_after_reopening, options): + if src_filename == '12bit_rose_extract.jpg': + import jpeg + jpeg.jpeg_1() + pytest.skipif(gdaltest.jpeg_version == '9b') + + with gdaltest.error_handler(): + ds = gdal.Open('data/' + src_filename) + pytest.skipif(ds is None) + + ds = None + ut = gdaltest.GDALTest('MRF', src_filename, 1, chksum, options=options, chksum_after_reopening=chksum_after_reopening) + + check_minmax = 'COMPRESS=JPEG' not in ut.options + for x in ut.options: + if x.find('OPTIONS:LERC_PREC=') >= 0: + check_minmax = False + return ut.testCreateCopy(check_minmax=check_minmax) def mrf_zen_test(): @@ -730,52 +751,6 @@ def mrf_cleanup(): gdaltest_list = [] -class myTestCreateCopyWrapper(object): - - def __init__(self, ut): - self.ut = ut - - def myTestCreateCopy(self): - check_minmax = 'COMPRESS=JPEG' not in self.ut.options - for x in self.ut.options: - if x.find('OPTIONS:LERC_PREC=') >= 0: - check_minmax = False - return self.ut.testCreateCopy(check_minmax=check_minmax) - - -for item in init_list: - src_filename = item[0] - - if src_filename == '12bit_rose_extract.jpg': - import jpeg - jpeg.jpeg_1() - if gdaltest.jpeg_version == '9b': - continue - - with gdaltest.error_handler(): - ds = gdal.Open('data/' + src_filename) - if ds is None: - continue - ds = None - options = [] - if item[3]: - options = item[3] - chksum_param = item[2] - if isinstance(chksum_param, list): - chksum = chksum_param[0] - chksum_after_reopening = chksum_param[1] - else: - chksum = chksum_param - chksum_after_reopening = chksum_param - - ut = gdaltest.GDALTest('MRF', src_filename, item[1], chksum, options=options, chksum_after_reopening=chksum_after_reopening) - if ut is None: - print('MRF tests skipped') - - ut = myTestCreateCopyWrapper(ut) - - gdaltest_list.append((ut.myTestCreateCopy, item[0] + ' ' + str(options))) - gdaltest_list += [mrf_overview_near_fact_2] gdaltest_list += [mrf_overview_near_with_nodata_fact_2] gdaltest_list += [mrf_overview_avg_fact_2] diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index cc605e73798c..c4dc4471193f 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -2441,7 +2441,7 @@ def gml_write_gml_ns(): gdaltest_list = [] -files = os.listdir('data/wkb_wkt') +files = os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt')) for filename in files: if filename[-4:] == '.wkt': ut = gml_geom_unit(filename[:-4]) diff --git a/autotest/ogr/ogr_gpkg.py b/autotest/ogr/ogr_gpkg.py index f1a81379ddb5..5d6ad075818b 100755 --- a/autotest/ogr/ogr_gpkg.py +++ b/autotest/ogr/ogr_gpkg.py @@ -46,8 +46,10 @@ from osgeo import ogr from osgeo import osr import gdaltest -sys.path.append('../osr') + +sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '../osr'))) import osr_proj4 +sys.path.pop() ############################################################################### # Validate a geopackage diff --git a/autotest/ogr/ogr_wkbwkt_geom.py b/autotest/ogr/ogr_wkbwkt_geom.py index 456ed2e2e75b..27f5f8e3e1db 100755 --- a/autotest/ogr/ogr_wkbwkt_geom.py +++ b/autotest/ogr/ogr_wkbwkt_geom.py @@ -679,7 +679,7 @@ def ogr_wkt_multipolygon_corrupted(): gdaltest_list = [] -files = os.listdir('data/wkb_wkt') +files = os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt')) for filename in files: if filename[-4:] == '.wkb': ut = wkb_wkt_unit(filename[:-4]) diff --git a/autotest/osr/osr_metacrs.py b/autotest/osr/osr_metacrs.py index 01d889570df5..97bcee50cf05 100755 --- a/autotest/osr/osr_metacrs.py +++ b/autotest/osr/osr_metacrs.py @@ -30,6 +30,7 @@ # DEALINGS IN THE SOFTWARE. ############################################################################### +import os import sys import csv @@ -169,7 +170,7 @@ def testMetaCRS(self): gdaltest_list = [] -csv_reader = csv.DictReader(open('data/Test_Data_File.csv', 'rt')) +csv_reader = csv.DictReader(open(os.path.join(os.path.dirname(__file__), 'data/Test_Data_File.csv'), 'rt')) for test in csv_reader: ut = MetaCRSTest(test) From 064263b099bc57d2bc46516931187498d0c9320c Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Wed, 3 Oct 2018 11:04:10 +1300 Subject: [PATCH 119/488] Remove extra sys.path entries when running tests pytest runs all tests in the same process, which means we can append this to the path *once* rather than in each module. See conftest.py where this gets added once. --- autotest/alg/applyverticalshiftgrid.py | 1 - autotest/alg/contour.py | 1 - autotest/alg/cutline.py | 1 - autotest/alg/dither.py | 1 - autotest/alg/polygonize.py | 1 - autotest/alg/proximity.py | 1 - autotest/alg/rasterize.py | 1 - autotest/alg/reproject.py | 1 - autotest/alg/sieve.py | 1 - autotest/alg/tps.py | 1 - autotest/alg/transformgeoloc.py | 1 - autotest/alg/warp.py | 1 - autotest/gcore/aaigrid_read.py | 1 - autotest/gcore/aaigrid_write.py | 1 - autotest/gcore/asyncreader.py | 1 - autotest/gcore/basic_test.py | 1 - autotest/gcore/bmp_read.py | 1 - autotest/gcore/bmp_write.py | 1 - autotest/gcore/colortable.py | 1 - autotest/gcore/envi_read.py | 1 - autotest/gcore/gcps2geotransform.py | 1 - autotest/gcore/gdal_api_proxy.py | 1 - autotest/gcore/gdal_stats.py | 1 - autotest/gcore/geoloc.py | 1 - autotest/gcore/gtiff_write.py | 1 - autotest/gcore/hdf4_read.py | 1 - autotest/gcore/hdf4_write.py | 1 - autotest/gcore/hfa_read.py | 1 - autotest/gcore/hfa_rfc40.py | 1 - autotest/gcore/hfa_srs.py | 1 - autotest/gcore/hfa_write.py | 1 - autotest/gcore/histogram.py | 1 - autotest/gcore/identify.py | 1 - autotest/gcore/mask.py | 1 - autotest/gcore/minixml.py | 1 - autotest/gcore/misc.py | 1 - autotest/gcore/numpy_rw.py | 1 - autotest/gcore/overviewds.py | 1 - autotest/gcore/pam.py | 1 - autotest/gcore/pixfun.py | 1 - autotest/gcore/pnm_read.py | 1 - autotest/gcore/pnm_write.py | 1 - autotest/gcore/rasterio.py | 1 - autotest/gcore/rat.py | 1 - autotest/gcore/rfc30.py | 1 - autotest/gcore/testnonboundtoswig.py | 1 - autotest/gcore/thread_test.py | 1 - autotest/gcore/tiff_ovr.py | 1 - autotest/gcore/tiff_read.py | 1 - autotest/gcore/tiff_srs.py | 1 - autotest/gcore/tiff_write.py | 1 - autotest/gcore/transformer.py | 1 - autotest/gcore/virtualmem.py | 1 - autotest/gcore/vrt_read.py | 1 - autotest/gcore/vrtmisc.py | 1 - autotest/gcore/vsiaz.py | 1 - autotest/gcore/vsicrypt.py | 1 - autotest/gcore/vsicurl.py | 1 - autotest/gcore/vsicurl_streaming.py | 1 - autotest/gcore/vsifile.py | 1 - autotest/gcore/vsigs.py | 1 - autotest/gcore/vsihdfs.py | 1 - autotest/gcore/vsioss.py | 1 - autotest/gcore/vsis3.py | 1 - autotest/gcore/vsistdin.py | 1 - autotest/gcore/vsiswift.py | 1 - autotest/gcore/vsiwebhdfs.py | 1 - autotest/gcore/vsizip.py | 1 - autotest/gdrivers/aaigrid.py | 1 - autotest/gdrivers/ace2.py | 1 - autotest/gdrivers/adrg.py | 1 - autotest/gdrivers/aigrid.py | 1 - autotest/gdrivers/arg.py | 1 - autotest/gdrivers/bag.py | 1 - autotest/gdrivers/blx.py | 1 - autotest/gdrivers/bsb.py | 1 - autotest/gdrivers/bt.py | 1 - autotest/gdrivers/byn.py | 1 - autotest/gdrivers/cals.py | 1 - autotest/gdrivers/ceos.py | 1 - autotest/gdrivers/cpg.py | 1 - autotest/gdrivers/ctg.py | 1 - autotest/gdrivers/db2.py | 1 - autotest/gdrivers/derived.py | 1 - autotest/gdrivers/dimap.py | 1 - autotest/gdrivers/dipex.py | 1 - autotest/gdrivers/dods.py | 1 - autotest/gdrivers/doq1.py | 1 - autotest/gdrivers/doq2.py | 1 - autotest/gdrivers/dted.py | 1 - autotest/gdrivers/e00grid.py | 1 - autotest/gdrivers/ecrgtoc.py | 1 - autotest/gdrivers/ecw.py | 1 - autotest/gdrivers/eedai.py | 1 - autotest/gdrivers/ehdr.py | 1 - autotest/gdrivers/eir.py | 1 - autotest/gdrivers/elas.py | 1 - autotest/gdrivers/envi.py | 1 - autotest/gdrivers/envisat.py | 1 - autotest/gdrivers/ers.py | 1 - autotest/gdrivers/fast.py | 1 - autotest/gdrivers/fit.py | 1 - autotest/gdrivers/fits.py | 1 - autotest/gdrivers/fujibas.py | 1 - autotest/gdrivers/gdalhttp.py | 1 - autotest/gdrivers/genbin.py | 1 - autotest/gdrivers/georaster.py | 1 - autotest/gdrivers/gff.py | 1 - autotest/gdrivers/gif.py | 1 - autotest/gdrivers/gmt.py | 1 - autotest/gdrivers/gpkg.py | 1 - autotest/gdrivers/grass.py | 1 - autotest/gdrivers/grassasciigrid.py | 1 - autotest/gdrivers/grib.py | 1 - autotest/gdrivers/gsc.py | 1 - autotest/gdrivers/gsg.py | 1 - autotest/gdrivers/gta.py | 1 - autotest/gdrivers/gtx.py | 1 - autotest/gdrivers/gxf.py | 1 - autotest/gdrivers/hdf5.py | 1 - autotest/gdrivers/hf2.py | 1 - autotest/gdrivers/hfa.py | 1 - autotest/gdrivers/ida.py | 1 - autotest/gdrivers/idrisi.py | 1 - autotest/gdrivers/ilwis.py | 1 - autotest/gdrivers/ingr.py | 1 - autotest/gdrivers/iris.py | 1 - autotest/gdrivers/isce.py | 1 - autotest/gdrivers/isis.py | 1 - autotest/gdrivers/isis2.py | 1 - autotest/gdrivers/jdem.py | 1 - autotest/gdrivers/jp2kak.py | 1 - autotest/gdrivers/jp2lura.py | 1 - autotest/gdrivers/jp2metadata.py | 1 - autotest/gdrivers/jp2openjpeg.py | 1 - autotest/gdrivers/jpeg.py | 1 - autotest/gdrivers/jpeg2000.py | 1 - autotest/gdrivers/jpeg_profile.py | 1 - autotest/gdrivers/jpegls.py | 1 - autotest/gdrivers/jpipkak.py | 1 - autotest/gdrivers/kea.py | 1 - autotest/gdrivers/kmlsuperoverlay.py | 1 - autotest/gdrivers/kro.py | 1 - autotest/gdrivers/l1b.py | 1 - autotest/gdrivers/lan.py | 1 - autotest/gdrivers/lcp.py | 1 - autotest/gdrivers/leveller.py | 1 - autotest/gdrivers/loslas.py | 1 - autotest/gdrivers/mbtiles.py | 1 - autotest/gdrivers/mem.py | 1 - autotest/gdrivers/mff.py | 1 - autotest/gdrivers/mff2.py | 1 - autotest/gdrivers/mg4lidar.py | 1 - autotest/gdrivers/mrf.py | 1 - autotest/gdrivers/mrsid.py | 1 - autotest/gdrivers/ndf.py | 1 - autotest/gdrivers/netcdf.py | 1 - autotest/gdrivers/netcdf_cf.py | 1 - autotest/gdrivers/ngsgeoid.py | 1 - autotest/gdrivers/nitf.py | 1 - autotest/gdrivers/ntv2.py | 1 - autotest/gdrivers/nwt_grc.py | 1 - autotest/gdrivers/nwt_grd.py | 1 - autotest/gdrivers/ozi.py | 1 - autotest/gdrivers/paux.py | 1 - autotest/gdrivers/pcidsk.py | 1 - autotest/gdrivers/pcraster.py | 1 - autotest/gdrivers/pdf.py | 1 - autotest/gdrivers/pds.py | 1 - autotest/gdrivers/pds4.py | 1 - autotest/gdrivers/plmosaic.py | 1 - autotest/gdrivers/png.py | 1 - autotest/gdrivers/png_profile.py | 1 - autotest/gdrivers/pnm.py | 1 - autotest/gdrivers/postgisraster.py | 1 - autotest/gdrivers/prf.py | 1 - autotest/gdrivers/r.py | 1 - autotest/gdrivers/rasdaman.py | 1 - autotest/gdrivers/rasterlite.py | 1 - autotest/gdrivers/rda.py | 1 - autotest/gdrivers/rik.py | 1 - autotest/gdrivers/rl2.py | 1 - autotest/gdrivers/rmf.py | 1 - autotest/gdrivers/roipac.py | 1 - autotest/gdrivers/rpftoc.py | 1 - autotest/gdrivers/rraster.py | 1 - autotest/gdrivers/rs2.py | 1 - autotest/gdrivers/safe.py | 1 - autotest/gdrivers/saga.py | 1 - autotest/gdrivers/sar_ceos.py | 1 - autotest/gdrivers/sdts.py | 1 - autotest/gdrivers/sentinel2.py | 1 - autotest/gdrivers/sgi.py | 1 - autotest/gdrivers/sigdem.py | 1 - autotest/gdrivers/snodas.py | 1 - autotest/gdrivers/srp.py | 1 - autotest/gdrivers/srtmhgt.py | 1 - autotest/gdrivers/terragen.py | 1 - autotest/gdrivers/test_validate_jp2.py | 1 - autotest/gdrivers/tiff_profile.py | 1 - autotest/gdrivers/til.py | 1 - autotest/gdrivers/usgsdem.py | 1 - autotest/gdrivers/vicar.py | 1 - autotest/gdrivers/vrtderived.py | 1 - autotest/gdrivers/vrtfilt.py | 1 - autotest/gdrivers/vrtlut.py | 1 - autotest/gdrivers/vrtmask.py | 1 - autotest/gdrivers/vrtovr.py | 1 - autotest/gdrivers/vrtpansharpen.py | 1 - autotest/gdrivers/vrtrawlink.py | 1 - autotest/gdrivers/vrtwarp.py | 1 - autotest/gdrivers/wcs.py | 1 - autotest/gdrivers/webp.py | 1 - autotest/gdrivers/wms.py | 1 - autotest/gdrivers/wmts.py | 1 - autotest/gdrivers/xmp.py | 1 - autotest/gdrivers/xpm.py | 1 - autotest/gdrivers/xyz.py | 1 - autotest/gdrivers/zmap.py | 1 - autotest/gnm/gnm_test.py | 1 - autotest/ogr/ogr_arcgen.py | 1 - autotest/ogr/ogr_avc.py | 1 - autotest/ogr/ogr_basic_test.py | 1 - autotest/ogr/ogr_bna.py | 1 - autotest/ogr/ogr_cad.py | 1 - autotest/ogr/ogr_carto.py | 3 +-- autotest/ogr/ogr_cloudant.py | 1 - autotest/ogr/ogr_couchdb.py | 1 - autotest/ogr/ogr_csv.py | 1 - autotest/ogr/ogr_csw.py | 1 - autotest/ogr/ogr_db2.py | 1 - autotest/ogr/ogr_db2_hack.py | 1 - autotest/ogr/ogr_dgn.py | 1 - autotest/ogr/ogr_dgnv8.py | 1 - autotest/ogr/ogr_dods.py | 1 - autotest/ogr/ogr_dxf.py | 1 - autotest/ogr/ogr_edigeo.py | 1 - autotest/ogr/ogr_eeda.py | 1 - autotest/ogr/ogr_elasticsearch.py | 1 - autotest/ogr/ogr_factory.py | 1 - autotest/ogr/ogr_feature.py | 1 - autotest/ogr/ogr_fgdb.py | 1 - autotest/ogr/ogr_fgdb_stress_test.py | 1 - autotest/ogr/ogr_geoconcept.py | 1 - autotest/ogr/ogr_geojson.py | 1 - autotest/ogr/ogr_geojsonseq.py | 1 - autotest/ogr/ogr_geom.py | 1 - autotest/ogr/ogr_georss.py | 1 - autotest/ogr/ogr_geos.py | 1 - autotest/ogr/ogr_gft.py | 1 - autotest/ogr/ogr_gml_fgd_read.py | 1 - autotest/ogr/ogr_gml_geom.py | 1 - autotest/ogr/ogr_gml_read.py | 1 - autotest/ogr/ogr_gmlas.py | 1 - autotest/ogr/ogr_gmt.py | 1 - autotest/ogr/ogr_gpkg.py | 1 - autotest/ogr/ogr_gpsbabel.py | 1 - autotest/ogr/ogr_gpx.py | 1 - autotest/ogr/ogr_grass.py | 1 - autotest/ogr/ogr_gtm.py | 1 - autotest/ogr/ogr_htf.py | 1 - autotest/ogr/ogr_idrisi.py | 1 - autotest/ogr/ogr_ili.py | 1 - autotest/ogr/ogr_index_test.py | 1 - autotest/ogr/ogr_ingres.py | 1 - autotest/ogr/ogr_jml.py | 1 - autotest/ogr/ogr_join_test.py | 1 - autotest/ogr/ogr_kml.py | 1 - autotest/ogr/ogr_layer_algebra.py | 1 - autotest/ogr/ogr_libkml.py | 1 - autotest/ogr/ogr_mem.py | 1 - autotest/ogr/ogr_mitab.py | 1 - autotest/ogr/ogr_mongodb.py | 1 - autotest/ogr/ogr_mssqlspatial.py | 1 - autotest/ogr/ogr_mvt.py | 1 - autotest/ogr/ogr_mysql.py | 1 - autotest/ogr/ogr_nas.py | 1 - autotest/ogr/ogr_ntf.py | 1 - autotest/ogr/ogr_oci.py | 1 - autotest/ogr/ogr_odbc.py | 1 - autotest/ogr/ogr_ods.py | 1 - autotest/ogr/ogr_ogdi.py | 1 - autotest/ogr/ogr_openair.py | 1 - autotest/ogr/ogr_openfilegdb.py | 1 - autotest/ogr/ogr_osm.py | 1 - autotest/ogr/ogr_pcidsk.py | 1 - autotest/ogr/ogr_pdf.py | 1 - autotest/ogr/ogr_pds.py | 1 - autotest/ogr/ogr_pg.py | 1 - autotest/ogr/ogr_pgdump.py | 1 - autotest/ogr/ogr_pgeo.py | 1 - autotest/ogr/ogr_plscenes.py | 1 - autotest/ogr/ogr_rec.py | 1 - autotest/ogr/ogr_refcount.py | 1 - autotest/ogr/ogr_rfc30.py | 1 - autotest/ogr/ogr_rfc35_mem.py | 1 - autotest/ogr/ogr_rfc35_mitab.py | 1 - autotest/ogr/ogr_rfc35_shape.py | 1 - autotest/ogr/ogr_rfc35_sqlite.py | 1 - autotest/ogr/ogr_rfc41.py | 1 - autotest/ogr/ogr_s57.py | 1 - autotest/ogr/ogr_sde.py | 1 - autotest/ogr/ogr_sdts.py | 1 - autotest/ogr/ogr_segukooa.py | 1 - autotest/ogr/ogr_segy.py | 1 - autotest/ogr/ogr_selafin.py | 1 - autotest/ogr/ogr_shape.py | 1 - autotest/ogr/ogr_shape_qix.py | 1 - autotest/ogr/ogr_shape_sbn.py | 1 - autotest/ogr/ogr_sosi.py | 1 - autotest/ogr/ogr_sql_rfc28.py | 1 - autotest/ogr/ogr_sql_sqlite.py | 1 - autotest/ogr/ogr_sql_test.py | 1 - autotest/ogr/ogr_sqlite.py | 1 - autotest/ogr/ogr_style.py | 1 - autotest/ogr/ogr_sua.py | 1 - autotest/ogr/ogr_svg.py | 1 - autotest/ogr/ogr_sxf.py | 1 - autotest/ogr/ogr_tiger.py | 1 - autotest/ogr/ogr_vdv.py | 1 - autotest/ogr/ogr_vfk.py | 1 - autotest/ogr/ogr_virtualogr.py | 1 - autotest/ogr/ogr_vrt.py | 1 - autotest/ogr/ogr_wasp.py | 1 - autotest/ogr/ogr_wfs.py | 1 - autotest/ogr/ogr_wfs3.py | 1 - autotest/ogr/ogr_wkbwkt_geom.py | 1 - autotest/ogr/ogr_xls.py | 1 - autotest/ogr/ogr_xlsx.py | 1 - autotest/ogr/ogr_xplane.py | 1 - autotest/ogr/ograpispy.py | 1 - autotest/osr/osr_basic.py | 1 - autotest/osr/osr_compd.py | 1 - autotest/osr/osr_ct.py | 1 - autotest/osr/osr_ct_proj.py | 1 - autotest/osr/osr_epsg.py | 1 - autotest/osr/osr_erm.py | 1 - autotest/osr/osr_esri.py | 1 - autotest/osr/osr_getprojectionmethods.py | 1 - autotest/osr/osr_metacrs.py | 1 - autotest/osr/osr_micoordsys.py | 1 - autotest/osr/osr_ozi.py | 1 - autotest/osr/osr_pci.py | 1 - autotest/osr/osr_pm.py | 1 - autotest/osr/osr_proj4.py | 1 - autotest/osr/osr_url.py | 1 - autotest/osr/osr_usgs.py | 1 - autotest/osr/osr_validate.py | 1 - autotest/osr/osr_xml.py | 1 - autotest/pyscripts/test_gdal2tiles.py | 1 - autotest/pyscripts/test_gdal_calc.py | 1 - autotest/pyscripts/test_gdal_edit.py | 5 ++--- autotest/pyscripts/test_gdal_fillnodata.py | 1 - autotest/pyscripts/test_gdal_ls_py.py | 1 - autotest/pyscripts/test_gdal_merge.py | 1 - autotest/pyscripts/test_gdal_pansharpen.py | 1 - autotest/pyscripts/test_gdal_polygonize.py | 1 - autotest/pyscripts/test_gdal_proximity.py | 1 - autotest/pyscripts/test_gdal_retile.py | 1 - autotest/pyscripts/test_gdal_sieve.py | 1 - autotest/pyscripts/test_gdalinfo_py.py | 1 - autotest/pyscripts/test_gdalmove.py | 1 - autotest/pyscripts/test_ogr2ogr_py.py | 1 - autotest/pyscripts/test_ogrinfo_py.py | 1 - autotest/pyscripts/test_ogrmerge.py | 1 - autotest/pyscripts/test_rgb2pct.py | 1 - autotest/utilities/test_gdal_contour.py | 1 - autotest/utilities/test_gdal_grid.py | 1 - autotest/utilities/test_gdal_grid_lib.py | 1 - autotest/utilities/test_gdal_rasterize.py | 1 - autotest/utilities/test_gdal_rasterize_lib.py | 1 - autotest/utilities/test_gdal_translate.py | 1 - autotest/utilities/test_gdal_translate_lib.py | 1 - autotest/utilities/test_gdaladdo.py | 1 - autotest/utilities/test_gdalbuildvrt.py | 1 - autotest/utilities/test_gdalbuildvrt_lib.py | 1 - autotest/utilities/test_gdaldem.py | 1 - autotest/utilities/test_gdaldem_lib.py | 1 - autotest/utilities/test_gdalinfo.py | 1 - autotest/utilities/test_gdalinfo_lib.py | 1 - autotest/utilities/test_gdallocationinfo.py | 1 - autotest/utilities/test_gdalsrsinfo.py | 1 - autotest/utilities/test_gdaltindex.py | 1 - autotest/utilities/test_gdaltransform.py | 1 - autotest/utilities/test_gdalwarp.py | 1 - autotest/utilities/test_gdalwarp_lib.py | 1 - autotest/utilities/test_gnmutils.py | 1 - autotest/utilities/test_nearblack.py | 1 - autotest/utilities/test_nearblack_lib.py | 1 - autotest/utilities/test_ogr2ogr.py | 1 - autotest/utilities/test_ogr2ogr_lib.py | 1 - autotest/utilities/test_ogrinfo.py | 1 - autotest/utilities/test_ogrlineref.py | 1 - autotest/utilities/test_ogrtindex.py | 1 - 394 files changed, 3 insertions(+), 397 deletions(-) diff --git a/autotest/alg/applyverticalshiftgrid.py b/autotest/alg/applyverticalshiftgrid.py index 63e7c8504e50..8aa3b39b0b07 100755 --- a/autotest/alg/applyverticalshiftgrid.py +++ b/autotest/alg/applyverticalshiftgrid.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal, osr diff --git a/autotest/alg/contour.py b/autotest/alg/contour.py index d208fc54a86d..3a7f8ce958e1 100755 --- a/autotest/alg/contour.py +++ b/autotest/alg/contour.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/alg/cutline.py b/autotest/alg/cutline.py index ffacaa73d128..5fb297351126 100755 --- a/autotest/alg/cutline.py +++ b/autotest/alg/cutline.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import ogrtest diff --git a/autotest/alg/dither.py b/autotest/alg/dither.py index 72b301fac490..372f8df50018 100755 --- a/autotest/alg/dither.py +++ b/autotest/alg/dither.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/alg/polygonize.py b/autotest/alg/polygonize.py index 84e98c9ed094..29fda58e8302 100755 --- a/autotest/alg/polygonize.py +++ b/autotest/alg/polygonize.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/alg/proximity.py b/autotest/alg/proximity.py index 8276b165c75a..d92f06acf975 100755 --- a/autotest/alg/proximity.py +++ b/autotest/alg/proximity.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/alg/rasterize.py b/autotest/alg/rasterize.py index 66ba514800c5..b0c2fb1bf54e 100755 --- a/autotest/alg/rasterize.py +++ b/autotest/alg/rasterize.py @@ -31,7 +31,6 @@ import struct import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/alg/reproject.py b/autotest/alg/reproject.py index cde70c0dbbb6..4cc7ca0473ee 100755 --- a/autotest/alg/reproject.py +++ b/autotest/alg/reproject.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/alg/sieve.py b/autotest/alg/sieve.py index 0486e0409600..889c54d39444 100755 --- a/autotest/alg/sieve.py +++ b/autotest/alg/sieve.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/alg/tps.py b/autotest/alg/tps.py index 2823496f0e59..5875c11b7921 100755 --- a/autotest/alg/tps.py +++ b/autotest/alg/tps.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal, osr diff --git a/autotest/alg/transformgeoloc.py b/autotest/alg/transformgeoloc.py index 0c0d6a01f233..d1dc9836dfc3 100755 --- a/autotest/alg/transformgeoloc.py +++ b/autotest/alg/transformgeoloc.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/alg/warp.py b/autotest/alg/warp.py index 7f0657c7fde2..db2eedae5358 100755 --- a/autotest/alg/warp.py +++ b/autotest/alg/warp.py @@ -36,7 +36,6 @@ import sys import shutil -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/gcore/aaigrid_read.py b/autotest/gcore/aaigrid_read.py index 01df8465a4e6..cda5cd771321 100755 --- a/autotest/gcore/aaigrid_read.py +++ b/autotest/gcore/aaigrid_read.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/aaigrid_write.py b/autotest/gcore/aaigrid_write.py index c9931850ddd8..ad78630a7a0d 100755 --- a/autotest/gcore/aaigrid_write.py +++ b/autotest/gcore/aaigrid_write.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/asyncreader.py b/autotest/gcore/asyncreader.py index 5abd0c7b3553..24f4c59daeb8 100755 --- a/autotest/gcore/asyncreader.py +++ b/autotest/gcore/asyncreader.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/basic_test.py b/autotest/gcore/basic_test.py index 46ffdb2e0242..5f5a6f32c699 100755 --- a/autotest/gcore/basic_test.py +++ b/autotest/gcore/basic_test.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/bmp_read.py b/autotest/gcore/bmp_read.py index b9a0c640c65f..074b9ce9397e 100755 --- a/autotest/gcore/bmp_read.py +++ b/autotest/gcore/bmp_read.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/bmp_write.py b/autotest/gcore/bmp_write.py index c54230384835..b2d842d29ec7 100755 --- a/autotest/gcore/bmp_write.py +++ b/autotest/gcore/bmp_write.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/colortable.py b/autotest/gcore/colortable.py index 1bbbb8dc06b9..4f8dc3ea3413 100755 --- a/autotest/gcore/colortable.py +++ b/autotest/gcore/colortable.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/envi_read.py b/autotest/gcore/envi_read.py index c365e6ef5121..99ac328eabea 100755 --- a/autotest/gcore/envi_read.py +++ b/autotest/gcore/envi_read.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gcore/gcps2geotransform.py b/autotest/gcore/gcps2geotransform.py index a5123fa70684..8f5d87cafd15 100755 --- a/autotest/gcore/gcps2geotransform.py +++ b/autotest/gcore/gcps2geotransform.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/gdal_api_proxy.py b/autotest/gcore/gdal_api_proxy.py index 6aa16ca2e0f7..7b3e656e3366 100755 --- a/autotest/gcore/gdal_api_proxy.py +++ b/autotest/gcore/gdal_api_proxy.py @@ -34,7 +34,6 @@ import time from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/gdal_stats.py b/autotest/gcore/gdal_stats.py index 25b031db1277..9325410b586a 100755 --- a/autotest/gcore/gdal_stats.py +++ b/autotest/gcore/gdal_stats.py @@ -32,7 +32,6 @@ import struct import shutil -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/geoloc.py b/autotest/gcore/geoloc.py index 221d016dbd9c..2ad2e6e5b730 100755 --- a/autotest/gcore/geoloc.py +++ b/autotest/gcore/geoloc.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/gtiff_write.py b/autotest/gcore/gtiff_write.py index 14e202385509..0997de9bdcfa 100755 --- a/autotest/gcore/gtiff_write.py +++ b/autotest/gcore/gtiff_write.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/hdf4_read.py b/autotest/gcore/hdf4_read.py index b93989d8fcc2..ed37cdd94538 100755 --- a/autotest/gcore/hdf4_read.py +++ b/autotest/gcore/hdf4_read.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/hdf4_write.py b/autotest/gcore/hdf4_write.py index 7aa13e9571c1..a75f68c3ffbf 100755 --- a/autotest/gcore/hdf4_write.py +++ b/autotest/gcore/hdf4_write.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/hfa_read.py b/autotest/gcore/hfa_read.py index aa49e1a57bd4..d904e5da6b27 100755 --- a/autotest/gcore/hfa_read.py +++ b/autotest/gcore/hfa_read.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gcore/hfa_rfc40.py b/autotest/gcore/hfa_rfc40.py index a4cf03ee3027..0042476918d0 100755 --- a/autotest/gcore/hfa_rfc40.py +++ b/autotest/gcore/hfa_rfc40.py @@ -34,7 +34,6 @@ import numpy from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/hfa_srs.py b/autotest/gcore/hfa_srs.py index 47f23f910e8d..9f82bae3fe12 100755 --- a/autotest/gcore/hfa_srs.py +++ b/autotest/gcore/hfa_srs.py @@ -35,7 +35,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') ############################################################################### diff --git a/autotest/gcore/hfa_write.py b/autotest/gcore/hfa_write.py index 134a6a60d521..5b63ccb3ab19 100755 --- a/autotest/gcore/hfa_write.py +++ b/autotest/gcore/hfa_write.py @@ -35,7 +35,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/histogram.py b/autotest/gcore/histogram.py index 21705be9d839..5ef38cde8dc4 100755 --- a/autotest/gcore/histogram.py +++ b/autotest/gcore/histogram.py @@ -33,7 +33,6 @@ import sys import shutil -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gcore/identify.py b/autotest/gcore/identify.py index b2b2ee56f8d0..799b2a0c7642 100755 --- a/autotest/gcore/identify.py +++ b/autotest/gcore/identify.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/mask.py b/autotest/gcore/mask.py index d7abdf9581a1..acfbe6efa5b3 100755 --- a/autotest/gcore/mask.py +++ b/autotest/gcore/mask.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/minixml.py b/autotest/gcore/minixml.py index d3e0880a8471..86937f4001c6 100755 --- a/autotest/gcore/minixml.py +++ b/autotest/gcore/minixml.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/misc.py b/autotest/gcore/misc.py index b05d58eee910..35d0a9e073c2 100755 --- a/autotest/gcore/misc.py +++ b/autotest/gcore/misc.py @@ -34,7 +34,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/numpy_rw.py b/autotest/gcore/numpy_rw.py index 21e7dddb018d..3d70b42e9e7b 100755 --- a/autotest/gcore/numpy_rw.py +++ b/autotest/gcore/numpy_rw.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/overviewds.py b/autotest/gcore/overviewds.py index 369fb47ea030..b100105d82a1 100755 --- a/autotest/gcore/overviewds.py +++ b/autotest/gcore/overviewds.py @@ -33,7 +33,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/pam.py b/autotest/gcore/pam.py index 5f537e4e5795..b48848e6bef1 100755 --- a/autotest/gcore/pam.py +++ b/autotest/gcore/pam.py @@ -35,7 +35,6 @@ import shutil import stat -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/pixfun.py b/autotest/gcore/pixfun.py index 66d20f8bf882..a277636b50f2 100755 --- a/autotest/gcore/pixfun.py +++ b/autotest/gcore/pixfun.py @@ -38,7 +38,6 @@ from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/pnm_read.py b/autotest/gcore/pnm_read.py index ffb469312486..7857312ab410 100755 --- a/autotest/gcore/pnm_read.py +++ b/autotest/gcore/pnm_read.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/pnm_write.py b/autotest/gcore/pnm_write.py index 38bb96bde533..3086f303a330 100755 --- a/autotest/gcore/pnm_write.py +++ b/autotest/gcore/pnm_write.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/rasterio.py b/autotest/gcore/rasterio.py index 76e15a805188..5d7a9f2bdae7 100755 --- a/autotest/gcore/rasterio.py +++ b/autotest/gcore/rasterio.py @@ -32,7 +32,6 @@ import struct import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/rat.py b/autotest/gcore/rat.py index 0aa3cd020eb1..752380dcb07a 100755 --- a/autotest/gcore/rat.py +++ b/autotest/gcore/rat.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/rfc30.py b/autotest/gcore/rfc30.py index c83d846e20f8..d11fa0f6df57 100755 --- a/autotest/gcore/rfc30.py +++ b/autotest/gcore/rfc30.py @@ -33,7 +33,6 @@ from sys import version_info from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/testnonboundtoswig.py b/autotest/gcore/testnonboundtoswig.py index 189466bd314c..3751c9de9f86 100755 --- a/autotest/gcore/testnonboundtoswig.py +++ b/autotest/gcore/testnonboundtoswig.py @@ -33,7 +33,6 @@ from sys import version_info from osgeo import gdal -sys.path.append('../pymod') try: import ctypes diff --git a/autotest/gcore/thread_test.py b/autotest/gcore/thread_test.py index c7f3ce5460fa..24ad6b8a37de 100755 --- a/autotest/gcore/thread_test.py +++ b/autotest/gcore/thread_test.py @@ -32,7 +32,6 @@ import sys import threading -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/tiff_ovr.py b/autotest/gcore/tiff_ovr.py index 5f4e303146b4..1f606648d7b8 100755 --- a/autotest/gcore/tiff_ovr.py +++ b/autotest/gcore/tiff_ovr.py @@ -38,7 +38,6 @@ from osgeo import osr from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index b6411ef7fff6..9312e50a9c62 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -31,7 +31,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest from osgeo import gdal, osr diff --git a/autotest/gcore/tiff_srs.py b/autotest/gcore/tiff_srs.py index 6f39bd6a9021..c21da49a5b20 100755 --- a/autotest/gcore/tiff_srs.py +++ b/autotest/gcore/tiff_srs.py @@ -33,7 +33,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/tiff_write.py b/autotest/gcore/tiff_write.py index a61191658485..5d4039f4e644 100755 --- a/autotest/gcore/tiff_write.py +++ b/autotest/gcore/tiff_write.py @@ -35,7 +35,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') sys.path.append('../../gdal/swig/python/samples') import gdaltest diff --git a/autotest/gcore/transformer.py b/autotest/gcore/transformer.py index 80d6d289a991..119da9099ef9 100755 --- a/autotest/gcore/transformer.py +++ b/autotest/gcore/transformer.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/virtualmem.py b/autotest/gcore/virtualmem.py index 5a2ca46ad4aa..c2e13340fa01 100755 --- a/autotest/gcore/virtualmem.py +++ b/autotest/gcore/virtualmem.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index c43d32ab3aa7..0894e5c66d4a 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -35,7 +35,6 @@ import shutil import struct -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/vrtmisc.py b/autotest/gcore/vrtmisc.py index 3666f74602fd..8ec5cdf31d85 100755 --- a/autotest/gcore/vrtmisc.py +++ b/autotest/gcore/vrtmisc.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/vsiaz.py b/autotest/gcore/vsiaz.py index a42b6b7a61a2..209e6a22a7c5 100755 --- a/autotest/gcore/vsiaz.py +++ b/autotest/gcore/vsiaz.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsicrypt.py b/autotest/gcore/vsicrypt.py index 812ed88de0cd..0d5344f8ad07 100755 --- a/autotest/gcore/vsicrypt.py +++ b/autotest/gcore/vsicrypt.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/vsicurl.py b/autotest/gcore/vsicurl.py index ddb82878fc43..7f5ff0ea4ee2 100755 --- a/autotest/gcore/vsicurl.py +++ b/autotest/gcore/vsicurl.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsicurl_streaming.py b/autotest/gcore/vsicurl_streaming.py index f5e2c0a759f4..9b37675b5eca 100755 --- a/autotest/gcore/vsicurl_streaming.py +++ b/autotest/gcore/vsicurl_streaming.py @@ -32,7 +32,6 @@ import time from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/vsifile.py b/autotest/gcore/vsifile.py index 62e46fe7ed94..8639cb1de51c 100755 --- a/autotest/gcore/vsifile.py +++ b/autotest/gcore/vsifile.py @@ -33,7 +33,6 @@ import time from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/vsigs.py b/autotest/gcore/vsigs.py index 2580f3142702..cbc9dfd3675a 100755 --- a/autotest/gcore/vsigs.py +++ b/autotest/gcore/vsigs.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsihdfs.py b/autotest/gcore/vsihdfs.py index 7c938f7681a2..141b0b475e7c 100755 --- a/autotest/gcore/vsihdfs.py +++ b/autotest/gcore/vsihdfs.py @@ -34,7 +34,6 @@ import os from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gcore/vsioss.py b/autotest/gcore/vsioss.py index db5362d67164..bbc1c5885d28 100755 --- a/autotest/gcore/vsioss.py +++ b/autotest/gcore/vsioss.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsis3.py b/autotest/gcore/vsis3.py index d187199ec2d8..87ae1faf9fc8 100755 --- a/autotest/gcore/vsis3.py +++ b/autotest/gcore/vsis3.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsistdin.py b/autotest/gcore/vsistdin.py index 3e8ca62cf16b..87c7c3db39e4 100755 --- a/autotest/gcore/vsistdin.py +++ b/autotest/gcore/vsistdin.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gcore/vsiswift.py b/autotest/gcore/vsiswift.py index de3ac7be99c9..8c9ff60823f8 100644 --- a/autotest/gcore/vsiswift.py +++ b/autotest/gcore/vsiswift.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsiwebhdfs.py b/autotest/gcore/vsiwebhdfs.py index 55a2c2cb2533..64b6fb9a58fa 100644 --- a/autotest/gcore/vsiwebhdfs.py +++ b/autotest/gcore/vsiwebhdfs.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gcore/vsizip.py b/autotest/gcore/vsizip.py index 82cb1e4e2218..a96ae08942e9 100755 --- a/autotest/gcore/vsizip.py +++ b/autotest/gcore/vsizip.py @@ -32,7 +32,6 @@ import random import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/aaigrid.py b/autotest/gdrivers/aaigrid.py index 6061156549ef..01e9271ff88b 100755 --- a/autotest/gdrivers/aaigrid.py +++ b/autotest/gdrivers/aaigrid.py @@ -35,7 +35,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ace2.py b/autotest/gdrivers/ace2.py index abd1301dd9b9..59689598d8c7 100755 --- a/autotest/gdrivers/ace2.py +++ b/autotest/gdrivers/ace2.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/adrg.py b/autotest/gdrivers/adrg.py index 801e17cd4398..56ee3499b10a 100755 --- a/autotest/gdrivers/adrg.py +++ b/autotest/gdrivers/adrg.py @@ -34,7 +34,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/aigrid.py b/autotest/gdrivers/aigrid.py index 4563f388f36d..4fa1f4cc0290 100755 --- a/autotest/gdrivers/aigrid.py +++ b/autotest/gdrivers/aigrid.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/arg.py b/autotest/gdrivers/arg.py index b12a11023deb..1c48d3569b1c 100755 --- a/autotest/gdrivers/arg.py +++ b/autotest/gdrivers/arg.py @@ -34,7 +34,6 @@ from copy import copy from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index 8bf4a746a007..d0493710b682 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/blx.py b/autotest/gdrivers/blx.py index 83093afb106d..6a15d171ce64 100755 --- a/autotest/gdrivers/blx.py +++ b/autotest/gdrivers/blx.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/bsb.py b/autotest/gdrivers/bsb.py index 24440c42886f..793fc2e3162a 100755 --- a/autotest/gdrivers/bsb.py +++ b/autotest/gdrivers/bsb.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/bt.py b/autotest/gdrivers/bt.py index 91ee51cdf5e7..3c9afe74beae 100755 --- a/autotest/gdrivers/bt.py +++ b/autotest/gdrivers/bt.py @@ -31,7 +31,6 @@ import sys from osgeo import osr -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/byn.py b/autotest/gdrivers/byn.py index 7d85011aee2c..af67c11cf1b5 100755 --- a/autotest/gdrivers/byn.py +++ b/autotest/gdrivers/byn.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/cals.py b/autotest/gdrivers/cals.py index e9cf612f9a13..3c9999ab072e 100755 --- a/autotest/gdrivers/cals.py +++ b/autotest/gdrivers/cals.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/ceos.py b/autotest/gdrivers/ceos.py index fc5660d1214c..d7bf9afcbc4a 100755 --- a/autotest/gdrivers/ceos.py +++ b/autotest/gdrivers/ceos.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/cpg.py b/autotest/gdrivers/cpg.py index de3f50b8a233..cf6ab753275b 100755 --- a/autotest/gdrivers/cpg.py +++ b/autotest/gdrivers/cpg.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ctg.py b/autotest/gdrivers/ctg.py index ac8b4e948a4e..dddff6accde4 100755 --- a/autotest/gdrivers/ctg.py +++ b/autotest/gdrivers/ctg.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/db2.py b/autotest/gdrivers/db2.py index 6c6881811471..34999b5e16c8 100755 --- a/autotest/gdrivers/db2.py +++ b/autotest/gdrivers/db2.py @@ -37,7 +37,6 @@ if os.path.dirname(sys.argv[0]) != '': os.chdir(os.path.dirname(sys.argv[0])) -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/derived.py b/autotest/gdrivers/derived.py index 94bb573fc92a..410d0f95cdc0 100755 --- a/autotest/gdrivers/derived.py +++ b/autotest/gdrivers/derived.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/dimap.py b/autotest/gdrivers/dimap.py index 543f85f71e1f..a0724364cab0 100755 --- a/autotest/gdrivers/dimap.py +++ b/autotest/gdrivers/dimap.py @@ -33,7 +33,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/dipex.py b/autotest/gdrivers/dipex.py index 169ab5e8ad1a..cec4ad8283cf 100755 --- a/autotest/gdrivers/dipex.py +++ b/autotest/gdrivers/dipex.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/dods.py b/autotest/gdrivers/dods.py index a895ae870978..93f1efba24e2 100755 --- a/autotest/gdrivers/dods.py +++ b/autotest/gdrivers/dods.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/doq1.py b/autotest/gdrivers/doq1.py index 4eb590abaa64..4e1c3bd297da 100755 --- a/autotest/gdrivers/doq1.py +++ b/autotest/gdrivers/doq1.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/doq2.py b/autotest/gdrivers/doq2.py index c55146969869..23b540ec868c 100755 --- a/autotest/gdrivers/doq2.py +++ b/autotest/gdrivers/doq2.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/dted.py b/autotest/gdrivers/dted.py index d7d37441bdbc..fd036bc00347 100755 --- a/autotest/gdrivers/dted.py +++ b/autotest/gdrivers/dted.py @@ -34,7 +34,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/e00grid.py b/autotest/gdrivers/e00grid.py index 7f34a7b0ed9b..2983daa516bc 100755 --- a/autotest/gdrivers/e00grid.py +++ b/autotest/gdrivers/e00grid.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ecrgtoc.py b/autotest/gdrivers/ecrgtoc.py index dd01513dd01a..8e5cde8aff4e 100755 --- a/autotest/gdrivers/ecrgtoc.py +++ b/autotest/gdrivers/ecrgtoc.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ecw.py b/autotest/gdrivers/ecw.py index d20ce05f75d3..45d58965d84d 100755 --- a/autotest/gdrivers/ecw.py +++ b/autotest/gdrivers/ecw.py @@ -39,7 +39,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/eedai.py b/autotest/gdrivers/eedai.py index 458880d9bab9..6778ec4f5944 100644 --- a/autotest/gdrivers/eedai.py +++ b/autotest/gdrivers/eedai.py @@ -33,7 +33,6 @@ import struct import sys -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gdrivers/ehdr.py b/autotest/gdrivers/ehdr.py index 160ee300b853..a49bb466449d 100755 --- a/autotest/gdrivers/ehdr.py +++ b/autotest/gdrivers/ehdr.py @@ -36,7 +36,6 @@ from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/eir.py b/autotest/gdrivers/eir.py index 1f27fb2277b1..69a8fca98f27 100755 --- a/autotest/gdrivers/eir.py +++ b/autotest/gdrivers/eir.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/elas.py b/autotest/gdrivers/elas.py index 6a86a29b7718..c6daf36ff873 100755 --- a/autotest/gdrivers/elas.py +++ b/autotest/gdrivers/elas.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/envi.py b/autotest/gdrivers/envi.py index ac0c971cdb2a..91dc4ed218d4 100755 --- a/autotest/gdrivers/envi.py +++ b/autotest/gdrivers/envi.py @@ -35,7 +35,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/envisat.py b/autotest/gdrivers/envisat.py index 5ebc48a1f3a0..a2e6c07420c2 100755 --- a/autotest/gdrivers/envisat.py +++ b/autotest/gdrivers/envisat.py @@ -34,7 +34,6 @@ import gzip from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ers.py b/autotest/gdrivers/ers.py index a4407ef385ec..285f7dc217e2 100755 --- a/autotest/gdrivers/ers.py +++ b/autotest/gdrivers/ers.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/fast.py b/autotest/gdrivers/fast.py index 17d5d1266450..ffc6355ea226 100755 --- a/autotest/gdrivers/fast.py +++ b/autotest/gdrivers/fast.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/fit.py b/autotest/gdrivers/fit.py index 3f280e011de9..05a0896eda2d 100755 --- a/autotest/gdrivers/fit.py +++ b/autotest/gdrivers/fit.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/fits.py b/autotest/gdrivers/fits.py index 11816a78e7a4..63110d721abd 100755 --- a/autotest/gdrivers/fits.py +++ b/autotest/gdrivers/fits.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/fujibas.py b/autotest/gdrivers/fujibas.py index cc45c4506c74..6153a36e8bb7 100755 --- a/autotest/gdrivers/fujibas.py +++ b/autotest/gdrivers/fujibas.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gdalhttp.py b/autotest/gdrivers/gdalhttp.py index 9ab7bd90c9c1..29a42d3e5397 100755 --- a/autotest/gdrivers/gdalhttp.py +++ b/autotest/gdrivers/gdalhttp.py @@ -35,7 +35,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/genbin.py b/autotest/gdrivers/genbin.py index 3886f44ef85a..96f22e01294e 100755 --- a/autotest/gdrivers/genbin.py +++ b/autotest/gdrivers/genbin.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/georaster.py b/autotest/gdrivers/georaster.py index bfc99f1748e8..524d7a6086ed 100755 --- a/autotest/gdrivers/georaster.py +++ b/autotest/gdrivers/georaster.py @@ -33,7 +33,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gff.py b/autotest/gdrivers/gff.py index be72bd1eae96..774d40c2da4c 100755 --- a/autotest/gdrivers/gff.py +++ b/autotest/gdrivers/gff.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gif.py b/autotest/gdrivers/gif.py index 876d8a02ce51..fdb7b10d2d74 100755 --- a/autotest/gdrivers/gif.py +++ b/autotest/gdrivers/gif.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gmt.py b/autotest/gdrivers/gmt.py index d6edb163701a..9efbd9613549 100755 --- a/autotest/gdrivers/gmt.py +++ b/autotest/gdrivers/gmt.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gpkg.py b/autotest/gdrivers/gpkg.py index 5320e4db8cc7..413aafe3018d 100755 --- a/autotest/gdrivers/gpkg.py +++ b/autotest/gdrivers/gpkg.py @@ -37,7 +37,6 @@ if os.path.dirname(sys.argv[0]) != '': os.chdir(os.path.dirname(sys.argv[0])) -sys.path.append('../pymod') sys.path.append('../../gdal/swig/python/samples') from osgeo import osr, gdal, ogr diff --git a/autotest/gdrivers/grass.py b/autotest/gdrivers/grass.py index cde00a6cd07e..ce69be146b5f 100755 --- a/autotest/gdrivers/grass.py +++ b/autotest/gdrivers/grass.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/grassasciigrid.py b/autotest/gdrivers/grassasciigrid.py index 12dde9da0c54..c4f80dd0f8d6 100755 --- a/autotest/gdrivers/grassasciigrid.py +++ b/autotest/gdrivers/grassasciigrid.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/grib.py b/autotest/gdrivers/grib.py index a0d84451b6c7..7892d815c2a7 100755 --- a/autotest/gdrivers/grib.py +++ b/autotest/gdrivers/grib.py @@ -37,7 +37,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') sys.path.append('../osr') import gdaltest diff --git a/autotest/gdrivers/gsc.py b/autotest/gdrivers/gsc.py index 877ad8492cb0..58bb8e78d267 100755 --- a/autotest/gdrivers/gsc.py +++ b/autotest/gdrivers/gsc.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gsg.py b/autotest/gdrivers/gsg.py index ee8fa74ec64e..1254a43856b6 100755 --- a/autotest/gdrivers/gsg.py +++ b/autotest/gdrivers/gsg.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gta.py b/autotest/gdrivers/gta.py index 5b9dc1062461..3fe6e417d65a 100755 --- a/autotest/gdrivers/gta.py +++ b/autotest/gdrivers/gta.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/gtx.py b/autotest/gdrivers/gtx.py index 6aa48f680f21..620f6db4734a 100755 --- a/autotest/gdrivers/gtx.py +++ b/autotest/gdrivers/gtx.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/gxf.py b/autotest/gdrivers/gxf.py index 6355ea150f8e..05c63232ad30 100755 --- a/autotest/gdrivers/gxf.py +++ b/autotest/gdrivers/gxf.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/hdf5.py b/autotest/gdrivers/hdf5.py index 8f87a30502db..d0229f214808 100755 --- a/autotest/gdrivers/hdf5.py +++ b/autotest/gdrivers/hdf5.py @@ -34,7 +34,6 @@ from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/hf2.py b/autotest/gdrivers/hf2.py index 2dc0fa0fb256..a899006089ac 100755 --- a/autotest/gdrivers/hf2.py +++ b/autotest/gdrivers/hf2.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/hfa.py b/autotest/gdrivers/hfa.py index 4fd1824b6a01..7df7b3f43760 100755 --- a/autotest/gdrivers/hfa.py +++ b/autotest/gdrivers/hfa.py @@ -34,7 +34,6 @@ import array from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ida.py b/autotest/gdrivers/ida.py index 5f828838581a..f6c5125fc1f0 100755 --- a/autotest/gdrivers/ida.py +++ b/autotest/gdrivers/ida.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/idrisi.py b/autotest/gdrivers/idrisi.py index a7184d8a3c07..4f8a7795f3a9 100755 --- a/autotest/gdrivers/idrisi.py +++ b/autotest/gdrivers/idrisi.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ilwis.py b/autotest/gdrivers/ilwis.py index 6bc4239a14f3..46c40b2b7cab 100755 --- a/autotest/gdrivers/ilwis.py +++ b/autotest/gdrivers/ilwis.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ingr.py b/autotest/gdrivers/ingr.py index eb985bacf87e..787a2eb3f295 100755 --- a/autotest/gdrivers/ingr.py +++ b/autotest/gdrivers/ingr.py @@ -34,7 +34,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/iris.py b/autotest/gdrivers/iris.py index 8ed2af1a3d91..0f24d35adbfd 100755 --- a/autotest/gdrivers/iris.py +++ b/autotest/gdrivers/iris.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/isce.py b/autotest/gdrivers/isce.py index 2279d8b301f7..e671e710d6d7 100755 --- a/autotest/gdrivers/isce.py +++ b/autotest/gdrivers/isce.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/isis.py b/autotest/gdrivers/isis.py index 2b4c9920d07e..fdd1a46ac82f 100755 --- a/autotest/gdrivers/isis.py +++ b/autotest/gdrivers/isis.py @@ -33,7 +33,6 @@ import struct import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/gdrivers/isis2.py b/autotest/gdrivers/isis2.py index cae8302053ad..61326c66a52f 100755 --- a/autotest/gdrivers/isis2.py +++ b/autotest/gdrivers/isis2.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/jdem.py b/autotest/gdrivers/jdem.py index 70ca710954f3..219ae6e3c73a 100755 --- a/autotest/gdrivers/jdem.py +++ b/autotest/gdrivers/jdem.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/jp2kak.py b/autotest/gdrivers/jp2kak.py index fc724d4a177f..8a9007cb673e 100755 --- a/autotest/gdrivers/jp2kak.py +++ b/autotest/gdrivers/jp2kak.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/jp2lura.py b/autotest/gdrivers/jp2lura.py index 1fccd804103b..f9c18b29b529 100755 --- a/autotest/gdrivers/jp2lura.py +++ b/autotest/gdrivers/jp2lura.py @@ -37,7 +37,6 @@ from osgeo import ogr from osgeo import osr -sys.path.append('../pymod') sys.path.append('../../gdal/swig/python/samples') import gdaltest diff --git a/autotest/gdrivers/jp2metadata.py b/autotest/gdrivers/jp2metadata.py index 2d9de1bd5c14..0d59f5cbc269 100755 --- a/autotest/gdrivers/jp2metadata.py +++ b/autotest/gdrivers/jp2metadata.py @@ -31,7 +31,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gdrivers/jp2openjpeg.py b/autotest/gdrivers/jp2openjpeg.py index ef1d831fe280..f380d2cc148f 100755 --- a/autotest/gdrivers/jp2openjpeg.py +++ b/autotest/gdrivers/jp2openjpeg.py @@ -36,7 +36,6 @@ from osgeo import ogr from osgeo import osr -sys.path.append('../pymod') sys.path.append('../ogr') sys.path.append('../../gdal/swig/python/samples') diff --git a/autotest/gdrivers/jpeg.py b/autotest/gdrivers/jpeg.py index bc4b3e05b7a6..f9d1d42e0d35 100755 --- a/autotest/gdrivers/jpeg.py +++ b/autotest/gdrivers/jpeg.py @@ -35,7 +35,6 @@ import shutil import struct -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/jpeg2000.py b/autotest/gdrivers/jpeg2000.py index 3f2ec599568d..129d9a31b1f2 100755 --- a/autotest/gdrivers/jpeg2000.py +++ b/autotest/gdrivers/jpeg2000.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/jpeg_profile.py b/autotest/gdrivers/jpeg_profile.py index b7b715641bcf..8a75bb843ff2 100755 --- a/autotest/gdrivers/jpeg_profile.py +++ b/autotest/gdrivers/jpeg_profile.py @@ -34,7 +34,6 @@ import sys import base64 -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/jpegls.py b/autotest/gdrivers/jpegls.py index e518e928da24..e1f06cc3ad06 100755 --- a/autotest/gdrivers/jpegls.py +++ b/autotest/gdrivers/jpegls.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/jpipkak.py b/autotest/gdrivers/jpipkak.py index c9c6a3d7cf53..ff2faa332765 100755 --- a/autotest/gdrivers/jpipkak.py +++ b/autotest/gdrivers/jpipkak.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/kea.py b/autotest/gdrivers/kea.py index d0045a46c1f3..2c885e70dfb1 100755 --- a/autotest/gdrivers/kea.py +++ b/autotest/gdrivers/kea.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/kmlsuperoverlay.py b/autotest/gdrivers/kmlsuperoverlay.py index df16a2f062f4..d1d81084f5e4 100755 --- a/autotest/gdrivers/kmlsuperoverlay.py +++ b/autotest/gdrivers/kmlsuperoverlay.py @@ -34,7 +34,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/kro.py b/autotest/gdrivers/kro.py index 7400cf6af9f1..3a4d8bdba2d6 100755 --- a/autotest/gdrivers/kro.py +++ b/autotest/gdrivers/kro.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/l1b.py b/autotest/gdrivers/l1b.py index 3f76d86f95d0..6a80a525c2bd 100755 --- a/autotest/gdrivers/l1b.py +++ b/autotest/gdrivers/l1b.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/lan.py b/autotest/gdrivers/lan.py index f27a7d996908..89b33e8d72d8 100755 --- a/autotest/gdrivers/lan.py +++ b/autotest/gdrivers/lan.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/lcp.py b/autotest/gdrivers/lcp.py index 6ba72b135565..5bbbb0cd1429 100755 --- a/autotest/gdrivers/lcp.py +++ b/autotest/gdrivers/lcp.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/leveller.py b/autotest/gdrivers/leveller.py index 215e9b90b2bf..6489da027acc 100755 --- a/autotest/gdrivers/leveller.py +++ b/autotest/gdrivers/leveller.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/loslas.py b/autotest/gdrivers/loslas.py index f0e7d19e5dea..20de8dbf8034 100755 --- a/autotest/gdrivers/loslas.py +++ b/autotest/gdrivers/loslas.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/mbtiles.py b/autotest/gdrivers/mbtiles.py index 52560bc635d0..94e67197ecab 100755 --- a/autotest/gdrivers/mbtiles.py +++ b/autotest/gdrivers/mbtiles.py @@ -33,7 +33,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest import webserver diff --git a/autotest/gdrivers/mem.py b/autotest/gdrivers/mem.py index 724c874e9ec9..b3839e4cae88 100755 --- a/autotest/gdrivers/mem.py +++ b/autotest/gdrivers/mem.py @@ -33,7 +33,6 @@ import array from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/mff.py b/autotest/gdrivers/mff.py index b928e8454cbf..19e4821ad32a 100755 --- a/autotest/gdrivers/mff.py +++ b/autotest/gdrivers/mff.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/mff2.py b/autotest/gdrivers/mff2.py index d01771b3a750..5d6f59b864c7 100755 --- a/autotest/gdrivers/mff2.py +++ b/autotest/gdrivers/mff2.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/mg4lidar.py b/autotest/gdrivers/mg4lidar.py index 51c432f169d5..b7a2b01d66db 100755 --- a/autotest/gdrivers/mg4lidar.py +++ b/autotest/gdrivers/mg4lidar.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index d9f2fc72ad60..35dcc67f7e20 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -33,7 +33,6 @@ import pytest -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gdrivers/mrsid.py b/autotest/gdrivers/mrsid.py index 576d90932a75..624b26a6ac60 100755 --- a/autotest/gdrivers/mrsid.py +++ b/autotest/gdrivers/mrsid.py @@ -34,7 +34,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ndf.py b/autotest/gdrivers/ndf.py index aebd0e026d45..c27e6ba09198 100755 --- a/autotest/gdrivers/ndf.py +++ b/autotest/gdrivers/ndf.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index 347f3bce23af..9e2c842cd411 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -39,7 +39,6 @@ from osgeo import ogr from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/netcdf_cf.py b/autotest/gdrivers/netcdf_cf.py index 87276857a1e8..ed271c43bc81 100755 --- a/autotest/gdrivers/netcdf_cf.py +++ b/autotest/gdrivers/netcdf_cf.py @@ -36,7 +36,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ngsgeoid.py b/autotest/gdrivers/ngsgeoid.py index d56e02b5ebd7..ea6e2c6041c6 100755 --- a/autotest/gdrivers/ngsgeoid.py +++ b/autotest/gdrivers/ngsgeoid.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/nitf.py b/autotest/gdrivers/nitf.py index bc298f89ded1..08c292c7e9ae 100755 --- a/autotest/gdrivers/nitf.py +++ b/autotest/gdrivers/nitf.py @@ -39,7 +39,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/ntv2.py b/autotest/gdrivers/ntv2.py index f69080ea5717..c5d7a4829fe4 100755 --- a/autotest/gdrivers/ntv2.py +++ b/autotest/gdrivers/ntv2.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/nwt_grc.py b/autotest/gdrivers/nwt_grc.py index e7121c1956d1..2ce7b8d87fc4 100755 --- a/autotest/gdrivers/nwt_grc.py +++ b/autotest/gdrivers/nwt_grc.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/nwt_grd.py b/autotest/gdrivers/nwt_grd.py index db951d68d14c..e22a766b8c5c 100755 --- a/autotest/gdrivers/nwt_grd.py +++ b/autotest/gdrivers/nwt_grd.py @@ -31,7 +31,6 @@ import sys import shutil -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/ozi.py b/autotest/gdrivers/ozi.py index c509f4243cac..0969b9c03795 100755 --- a/autotest/gdrivers/ozi.py +++ b/autotest/gdrivers/ozi.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/paux.py b/autotest/gdrivers/paux.py index 865507441bd3..25c6fa7b04d9 100755 --- a/autotest/gdrivers/paux.py +++ b/autotest/gdrivers/paux.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/pcidsk.py b/autotest/gdrivers/pcidsk.py index 9247c1cf3a8b..c933a14a1088 100755 --- a/autotest/gdrivers/pcidsk.py +++ b/autotest/gdrivers/pcidsk.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/pcraster.py b/autotest/gdrivers/pcraster.py index 0b11c8067f11..e4ec4dcb6530 100755 --- a/autotest/gdrivers/pcraster.py +++ b/autotest/gdrivers/pcraster.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/pdf.py b/autotest/gdrivers/pdf.py index 7292fa72a9b6..6dc85cc05360 100755 --- a/autotest/gdrivers/pdf.py +++ b/autotest/gdrivers/pdf.py @@ -35,7 +35,6 @@ from osgeo import ogr from osgeo import osr -sys.path.append('../pymod') sys.path.append('../osr') import gdaltest diff --git a/autotest/gdrivers/pds.py b/autotest/gdrivers/pds.py index cafaf8e92775..6e95a7fdb223 100755 --- a/autotest/gdrivers/pds.py +++ b/autotest/gdrivers/pds.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/pds4.py b/autotest/gdrivers/pds4.py index 415bf4365ea4..323826e1fe62 100755 --- a/autotest/gdrivers/pds4.py +++ b/autotest/gdrivers/pds4.py @@ -33,7 +33,6 @@ import struct import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/gdrivers/plmosaic.py b/autotest/gdrivers/plmosaic.py index c9f5c28a35b9..883e54a77469 100755 --- a/autotest/gdrivers/plmosaic.py +++ b/autotest/gdrivers/plmosaic.py @@ -34,7 +34,6 @@ import shutil import struct -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gdrivers/png.py b/autotest/gdrivers/png.py index 338d9148f4f4..f37e28efee42 100755 --- a/autotest/gdrivers/png.py +++ b/autotest/gdrivers/png.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/png_profile.py b/autotest/gdrivers/png_profile.py index 806e04a44c4c..6ec7dd3a9a2d 100755 --- a/autotest/gdrivers/png_profile.py +++ b/autotest/gdrivers/png_profile.py @@ -34,7 +34,6 @@ import sys import base64 -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/pnm.py b/autotest/gdrivers/pnm.py index 5c24a6870985..e40c9a68e05c 100755 --- a/autotest/gdrivers/pnm.py +++ b/autotest/gdrivers/pnm.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/postgisraster.py b/autotest/gdrivers/postgisraster.py index 01f402e7a70b..841458516fc2 100755 --- a/autotest/gdrivers/postgisraster.py +++ b/autotest/gdrivers/postgisraster.py @@ -36,7 +36,6 @@ from osgeo import ogr from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/prf.py b/autotest/gdrivers/prf.py index 03338af0339c..35b2440ffa07 100755 --- a/autotest/gdrivers/prf.py +++ b/autotest/gdrivers/prf.py @@ -26,7 +26,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/r.py b/autotest/gdrivers/r.py index a5f1b5e168bf..829f797d05d4 100755 --- a/autotest/gdrivers/r.py +++ b/autotest/gdrivers/r.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rasdaman.py b/autotest/gdrivers/rasdaman.py index 5b32473bd5f4..b0a0c7da5624 100755 --- a/autotest/gdrivers/rasdaman.py +++ b/autotest/gdrivers/rasdaman.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rasterlite.py b/autotest/gdrivers/rasterlite.py index de6f39c269d3..2931fde8f872 100755 --- a/autotest/gdrivers/rasterlite.py +++ b/autotest/gdrivers/rasterlite.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rda.py b/autotest/gdrivers/rda.py index 4a857ff71619..96f8788004c5 100755 --- a/autotest/gdrivers/rda.py +++ b/autotest/gdrivers/rda.py @@ -34,7 +34,6 @@ import sys import json -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gdrivers/rik.py b/autotest/gdrivers/rik.py index a44f5f8bf94b..21401baceb42 100755 --- a/autotest/gdrivers/rik.py +++ b/autotest/gdrivers/rik.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rl2.py b/autotest/gdrivers/rl2.py index 34bcc334e875..499f4726c3d0 100755 --- a/autotest/gdrivers/rl2.py +++ b/autotest/gdrivers/rl2.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal, ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rmf.py b/autotest/gdrivers/rmf.py index 5fc6bbda1edf..c545036e80ee 100755 --- a/autotest/gdrivers/rmf.py +++ b/autotest/gdrivers/rmf.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/roipac.py b/autotest/gdrivers/roipac.py index 835aa0309308..4bee985a9bc5 100755 --- a/autotest/gdrivers/roipac.py +++ b/autotest/gdrivers/roipac.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rpftoc.py b/autotest/gdrivers/rpftoc.py index a6417d31fa65..05ec9c22389a 100755 --- a/autotest/gdrivers/rpftoc.py +++ b/autotest/gdrivers/rpftoc.py @@ -33,7 +33,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rraster.py b/autotest/gdrivers/rraster.py index f79091e0c50d..36ab5efa17d1 100755 --- a/autotest/gdrivers/rraster.py +++ b/autotest/gdrivers/rraster.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/rs2.py b/autotest/gdrivers/rs2.py index d1c5bf40c9be..40379a95167a 100755 --- a/autotest/gdrivers/rs2.py +++ b/autotest/gdrivers/rs2.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/safe.py b/autotest/gdrivers/safe.py index 1102a8b8c53e..f20ce6a57188 100755 --- a/autotest/gdrivers/safe.py +++ b/autotest/gdrivers/safe.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/saga.py b/autotest/gdrivers/saga.py index 271ae7042048..2c426ae2efa0 100755 --- a/autotest/gdrivers/saga.py +++ b/autotest/gdrivers/saga.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/sar_ceos.py b/autotest/gdrivers/sar_ceos.py index 3c83fcaf1f2a..94669b3d999e 100755 --- a/autotest/gdrivers/sar_ceos.py +++ b/autotest/gdrivers/sar_ceos.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/sdts.py b/autotest/gdrivers/sdts.py index f80f92ffcfa9..dcf63a9875b2 100755 --- a/autotest/gdrivers/sdts.py +++ b/autotest/gdrivers/sdts.py @@ -32,7 +32,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/sentinel2.py b/autotest/gdrivers/sentinel2.py index 6602278729b4..3625e405b0e6 100755 --- a/autotest/gdrivers/sentinel2.py +++ b/autotest/gdrivers/sentinel2.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/sgi.py b/autotest/gdrivers/sgi.py index 3871df5c6904..ccdb45fcf40b 100755 --- a/autotest/gdrivers/sgi.py +++ b/autotest/gdrivers/sgi.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/sigdem.py b/autotest/gdrivers/sigdem.py index 1c695a2c000f..b3cac67a20d2 100755 --- a/autotest/gdrivers/sigdem.py +++ b/autotest/gdrivers/sigdem.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/snodas.py b/autotest/gdrivers/snodas.py index 58cb7ae41b43..2a0d3b68c753 100755 --- a/autotest/gdrivers/snodas.py +++ b/autotest/gdrivers/snodas.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/srp.py b/autotest/gdrivers/srp.py index 80c910fc5547..dabb996f103d 100755 --- a/autotest/gdrivers/srp.py +++ b/autotest/gdrivers/srp.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/srtmhgt.py b/autotest/gdrivers/srtmhgt.py index 0006f20b8a88..f858358c298b 100755 --- a/autotest/gdrivers/srtmhgt.py +++ b/autotest/gdrivers/srtmhgt.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/terragen.py b/autotest/gdrivers/terragen.py index 90fdd74a72cb..5133f5126335 100755 --- a/autotest/gdrivers/terragen.py +++ b/autotest/gdrivers/terragen.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/gdrivers/test_validate_jp2.py b/autotest/gdrivers/test_validate_jp2.py index 94ce46b7de37..ce42759dda6a 100755 --- a/autotest/gdrivers/test_validate_jp2.py +++ b/autotest/gdrivers/test_validate_jp2.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') sys.path.append('../../gdal/swig/python/samples') import gdaltest diff --git a/autotest/gdrivers/tiff_profile.py b/autotest/gdrivers/tiff_profile.py index 9847f64daee4..2e41363e960f 100755 --- a/autotest/gdrivers/tiff_profile.py +++ b/autotest/gdrivers/tiff_profile.py @@ -34,7 +34,6 @@ import sys import base64 -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/til.py b/autotest/gdrivers/til.py index 58f5fd0b70c1..9c0be4774454 100755 --- a/autotest/gdrivers/til.py +++ b/autotest/gdrivers/til.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/gdrivers/usgsdem.py b/autotest/gdrivers/usgsdem.py index d0853c02e123..988fb715b0ca 100755 --- a/autotest/gdrivers/usgsdem.py +++ b/autotest/gdrivers/usgsdem.py @@ -33,7 +33,6 @@ from osgeo import gdal from osgeo import osr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vicar.py b/autotest/gdrivers/vicar.py index 436e6af88a33..103134941074 100755 --- a/autotest/gdrivers/vicar.py +++ b/autotest/gdrivers/vicar.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtderived.py b/autotest/gdrivers/vrtderived.py index d4c9d827be35..37228a4b5a12 100755 --- a/autotest/gdrivers/vrtderived.py +++ b/autotest/gdrivers/vrtderived.py @@ -35,7 +35,6 @@ import threading from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtfilt.py b/autotest/gdrivers/vrtfilt.py index 1e17d5de7f0a..bfe86d07f35c 100755 --- a/autotest/gdrivers/vrtfilt.py +++ b/autotest/gdrivers/vrtfilt.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtlut.py b/autotest/gdrivers/vrtlut.py index 81d6e7681f0d..b135a89de082 100755 --- a/autotest/gdrivers/vrtlut.py +++ b/autotest/gdrivers/vrtlut.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtmask.py b/autotest/gdrivers/vrtmask.py index 8c7c771ab208..b1134a131584 100755 --- a/autotest/gdrivers/vrtmask.py +++ b/autotest/gdrivers/vrtmask.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtovr.py b/autotest/gdrivers/vrtovr.py index acaed92f7a26..c753ac4f4730 100755 --- a/autotest/gdrivers/vrtovr.py +++ b/autotest/gdrivers/vrtovr.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtpansharpen.py b/autotest/gdrivers/vrtpansharpen.py index b7f7f6195e61..20398b25be5a 100755 --- a/autotest/gdrivers/vrtpansharpen.py +++ b/autotest/gdrivers/vrtpansharpen.py @@ -32,7 +32,6 @@ import shutil from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtrawlink.py b/autotest/gdrivers/vrtrawlink.py index 21d77b2e2645..e9ed17ea8d9f 100755 --- a/autotest/gdrivers/vrtrawlink.py +++ b/autotest/gdrivers/vrtrawlink.py @@ -34,7 +34,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/vrtwarp.py b/autotest/gdrivers/vrtwarp.py index 120ba806dfa1..ef1c7f07ac97 100755 --- a/autotest/gdrivers/vrtwarp.py +++ b/autotest/gdrivers/vrtwarp.py @@ -33,7 +33,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/wcs.py b/autotest/gdrivers/wcs.py index 7fcd40cb1f16..6e9baba60df4 100755 --- a/autotest/gdrivers/wcs.py +++ b/autotest/gdrivers/wcs.py @@ -43,7 +43,6 @@ from osgeo import gdal -sys.path.append('../pymod') import webserver import gdaltest diff --git a/autotest/gdrivers/webp.py b/autotest/gdrivers/webp.py index e1d7c9179f75..70d887369332 100755 --- a/autotest/gdrivers/webp.py +++ b/autotest/gdrivers/webp.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/wms.py b/autotest/gdrivers/wms.py index 0eac2ae7c629..7d513ed083cb 100755 --- a/autotest/gdrivers/wms.py +++ b/autotest/gdrivers/wms.py @@ -37,7 +37,6 @@ import hashlib from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/wmts.py b/autotest/gdrivers/wmts.py index c874230600e3..21e60c9ab981 100755 --- a/autotest/gdrivers/wmts.py +++ b/autotest/gdrivers/wmts.py @@ -32,7 +32,6 @@ import sys import shutil -sys.path.append('../pymod') from osgeo import gdal diff --git a/autotest/gdrivers/xmp.py b/autotest/gdrivers/xmp.py index c1c559bf7daf..f0a7018150b3 100755 --- a/autotest/gdrivers/xmp.py +++ b/autotest/gdrivers/xmp.py @@ -33,7 +33,6 @@ from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/xpm.py b/autotest/gdrivers/xpm.py index 929e763942a2..bc50e91be07d 100755 --- a/autotest/gdrivers/xpm.py +++ b/autotest/gdrivers/xpm.py @@ -31,7 +31,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/xyz.py b/autotest/gdrivers/xyz.py index e6ffad6874a4..bce66004cb07 100755 --- a/autotest/gdrivers/xyz.py +++ b/autotest/gdrivers/xyz.py @@ -33,7 +33,6 @@ import struct from osgeo import gdal -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gdrivers/zmap.py b/autotest/gdrivers/zmap.py index 9fdeba5eeb4e..41dec9a52f31 100755 --- a/autotest/gdrivers/zmap.py +++ b/autotest/gdrivers/zmap.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/gnm/gnm_test.py b/autotest/gnm/gnm_test.py index 09b18c007c70..50b41b220371 100755 --- a/autotest/gnm/gnm_test.py +++ b/autotest/gnm/gnm_test.py @@ -35,7 +35,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest diff --git a/autotest/ogr/ogr_arcgen.py b/autotest/ogr/ogr_arcgen.py index 638634b7b8ce..2388b94446e1 100755 --- a/autotest/ogr/ogr_arcgen.py +++ b/autotest/ogr/ogr_arcgen.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_avc.py b/autotest/ogr/ogr_avc.py index c51d622e95f3..a49ece921d34 100755 --- a/autotest/ogr/ogr_avc.py +++ b/autotest/ogr/ogr_avc.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_basic_test.py b/autotest/ogr/ogr_basic_test.py index f3603d9ea5c1..32697f36f2ea 100755 --- a/autotest/ogr/ogr_basic_test.py +++ b/autotest/ogr/ogr_basic_test.py @@ -30,7 +30,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_bna.py b/autotest/ogr/ogr_bna.py index 8afa02c8117c..9b07d9adf74c 100755 --- a/autotest/ogr/ogr_bna.py +++ b/autotest/ogr/ogr_bna.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_cad.py b/autotest/ogr/ogr_cad.py index 8a1800971161..0cc3dfb83a7a 100755 --- a/autotest/ogr/ogr_cad.py +++ b/autotest/ogr/ogr_cad.py @@ -32,7 +32,6 @@ ################################################################################ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_carto.py b/autotest/ogr/ogr_carto.py index 18517b4c3b25..67e41a8f80c3 100755 --- a/autotest/ogr/ogr_carto.py +++ b/autotest/ogr/ogr_carto.py @@ -32,7 +32,6 @@ import sys import uuid -sys.path.append('../pymod') import gdaltest import ogrtest @@ -1038,7 +1037,7 @@ def ogr_carto_vsimem(): gdaltest.post_reason('fail') return 'fail' - + return 'success' diff --git a/autotest/ogr/ogr_cloudant.py b/autotest/ogr/ogr_cloudant.py index 9cd88cdcd5a2..443dd0ebc6f6 100755 --- a/autotest/ogr/ogr_cloudant.py +++ b/autotest/ogr/ogr_cloudant.py @@ -33,7 +33,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_couchdb.py b/autotest/ogr/ogr_couchdb.py index f5c9158da5aa..990df5f0a182 100755 --- a/autotest/ogr/ogr_couchdb.py +++ b/autotest/ogr/ogr_couchdb.py @@ -33,7 +33,6 @@ import sys import uuid -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_csv.py b/autotest/ogr/ogr_csv.py index d6d34a317957..b69fb6bbaabf 100755 --- a/autotest/ogr/ogr_csv.py +++ b/autotest/ogr/ogr_csv.py @@ -30,7 +30,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_csw.py b/autotest/ogr/ogr_csw.py index 1f39a06cd277..b86252f88cee 100755 --- a/autotest/ogr/ogr_csw.py +++ b/autotest/ogr/ogr_csw.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_db2.py b/autotest/ogr/ogr_db2.py index ed22919a79cd..89aeda7206a0 100755 --- a/autotest/ogr/ogr_db2.py +++ b/autotest/ogr/ogr_db2.py @@ -41,7 +41,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_db2_hack.py b/autotest/ogr/ogr_db2_hack.py index 28ac0024f055..d8c8582d6779 100755 --- a/autotest/ogr/ogr_db2_hack.py +++ b/autotest/ogr/ogr_db2_hack.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_dgn.py b/autotest/ogr/ogr_dgn.py index 10be1f93f05d..8f15a639ec11 100755 --- a/autotest/ogr/ogr_dgn.py +++ b/autotest/ogr/ogr_dgn.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_dgnv8.py b/autotest/ogr/ogr_dgnv8.py index 2243e96a582b..7d47fa8c5c93 100755 --- a/autotest/ogr/ogr_dgnv8.py +++ b/autotest/ogr/ogr_dgnv8.py @@ -32,7 +32,6 @@ import shutil import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_dods.py b/autotest/ogr/ogr_dods.py index c4a3bd83dfa2..dc2f4678c288 100755 --- a/autotest/ogr/ogr_dods.py +++ b/autotest/ogr/ogr_dods.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_dxf.py b/autotest/ogr/ogr_dxf.py index b25a89dcc1d6..4f77d0329964 100644 --- a/autotest/ogr/ogr_dxf.py +++ b/autotest/ogr/ogr_dxf.py @@ -34,7 +34,6 @@ import sys from sys import version_info -sys.path.append('../pymod') import ogrtest import gdaltest diff --git a/autotest/ogr/ogr_edigeo.py b/autotest/ogr/ogr_edigeo.py index 0dd39a6f2a04..9b35ef78d5f6 100755 --- a/autotest/ogr/ogr_edigeo.py +++ b/autotest/ogr/ogr_edigeo.py @@ -33,7 +33,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_eeda.py b/autotest/ogr/ogr_eeda.py index 0e7cc177c1a1..52b10cf5245f 100644 --- a/autotest/ogr/ogr_eeda.py +++ b/autotest/ogr/ogr_eeda.py @@ -32,7 +32,6 @@ import json import sys -sys.path.append('../pymod') from osgeo import gdal, ogr diff --git a/autotest/ogr/ogr_elasticsearch.py b/autotest/ogr/ogr_elasticsearch.py index 4c4b6514c729..6ffe25900d31 100755 --- a/autotest/ogr/ogr_elasticsearch.py +++ b/autotest/ogr/ogr_elasticsearch.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import ogrtest import gdaltest diff --git a/autotest/ogr/ogr_factory.py b/autotest/ogr/ogr_factory.py index 31e23c084b90..a9b36965fccd 100755 --- a/autotest/ogr/ogr_factory.py +++ b/autotest/ogr/ogr_factory.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import ogrtest import gdaltest diff --git a/autotest/ogr/ogr_feature.py b/autotest/ogr/ogr_feature.py index 5552e8f659be..05dae6d07ba4 100755 --- a/autotest/ogr/ogr_feature.py +++ b/autotest/ogr/ogr_feature.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/ogr/ogr_fgdb.py b/autotest/ogr/ogr_fgdb.py index b854ec4cb126..3da90cb55f4a 100755 --- a/autotest/ogr/ogr_fgdb.py +++ b/autotest/ogr/ogr_fgdb.py @@ -33,7 +33,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_fgdb_stress_test.py b/autotest/ogr/ogr_fgdb_stress_test.py index cd9f262ecfdd..3e37ce4c5ced 100755 --- a/autotest/ogr/ogr_fgdb_stress_test.py +++ b/autotest/ogr/ogr_fgdb_stress_test.py @@ -34,7 +34,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_geoconcept.py b/autotest/ogr/ogr_geoconcept.py index 102ddacf7dc5..020752a2b22e 100755 --- a/autotest/ogr/ogr_geoconcept.py +++ b/autotest/ogr/ogr_geoconcept.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index 6ed3b96a0798..a702b95eb684 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -33,7 +33,6 @@ import os import sys -sys.path.append('../pymod') from osgeo import osr from osgeo import ogr diff --git a/autotest/ogr/ogr_geojsonseq.py b/autotest/ogr/ogr_geojsonseq.py index 11636e8585f1..6107c96ae2df 100755 --- a/autotest/ogr/ogr_geojsonseq.py +++ b/autotest/ogr/ogr_geojsonseq.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/ogr/ogr_geom.py b/autotest/ogr/ogr_geom.py index 8e92bbd24a66..2e11a421f336 100755 --- a/autotest/ogr/ogr_geom.py +++ b/autotest/ogr/ogr_geom.py @@ -32,7 +32,6 @@ import random import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_georss.py b/autotest/ogr/ogr_georss.py index 040196010ad6..e81739b8da59 100755 --- a/autotest/ogr/ogr_georss.py +++ b/autotest/ogr/ogr_georss.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_geos.py b/autotest/ogr/ogr_geos.py index 460ad2b4e3a4..870dcc05b301 100755 --- a/autotest/ogr/ogr_geos.py +++ b/autotest/ogr/ogr_geos.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gft.py b/autotest/ogr/ogr_gft.py index e7449b572472..00890531e686 100755 --- a/autotest/ogr/ogr_gft.py +++ b/autotest/ogr/ogr_gft.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gml_fgd_read.py b/autotest/ogr/ogr_gml_fgd_read.py index 6badd173e37f..6c02156b73f8 100755 --- a/autotest/ogr/ogr_gml_fgd_read.py +++ b/autotest/ogr/ogr_gml_fgd_read.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index c4dc4471193f..7cf7b2fe68eb 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -30,7 +30,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gml_read.py b/autotest/ogr/ogr_gml_read.py index 97ae391b1fd0..7c21d54d450c 100755 --- a/autotest/ogr/ogr_gml_read.py +++ b/autotest/ogr/ogr_gml_read.py @@ -33,7 +33,6 @@ import os import sys -sys.path.append('../pymod') import shutil import gdaltest diff --git a/autotest/ogr/ogr_gmlas.py b/autotest/ogr/ogr_gmlas.py index de19582f2890..830825a320af 100755 --- a/autotest/ogr/ogr_gmlas.py +++ b/autotest/ogr/ogr_gmlas.py @@ -41,7 +41,6 @@ import os.path import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gmt.py b/autotest/ogr/ogr_gmt.py index 547d46646c11..18447411cbef 100755 --- a/autotest/ogr/ogr_gmt.py +++ b/autotest/ogr/ogr_gmt.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gpkg.py b/autotest/ogr/ogr_gpkg.py index 5d6ad075818b..54fd44c791a5 100755 --- a/autotest/ogr/ogr_gpkg.py +++ b/autotest/ogr/ogr_gpkg.py @@ -39,7 +39,6 @@ if os.path.dirname(sys.argv[0]) != '': os.chdir(os.path.dirname(sys.argv[0])) -sys.path.append('../pymod') sys.path.append('../../gdal/swig/python/samples') from osgeo import gdal diff --git a/autotest/ogr/ogr_gpsbabel.py b/autotest/ogr/ogr_gpsbabel.py index d21c0ed8eb35..52134ddb788d 100755 --- a/autotest/ogr/ogr_gpsbabel.py +++ b/autotest/ogr/ogr_gpsbabel.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_gpx.py b/autotest/ogr/ogr_gpx.py index d04f0a5ebfaf..5431cdcfa934 100755 --- a/autotest/ogr/ogr_gpx.py +++ b/autotest/ogr/ogr_gpx.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_grass.py b/autotest/ogr/ogr_grass.py index 96f999d24169..36ca14da4298 100755 --- a/autotest/ogr/ogr_grass.py +++ b/autotest/ogr/ogr_grass.py @@ -31,7 +31,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/ogr/ogr_gtm.py b/autotest/ogr/ogr_gtm.py index 8fabfd14051b..2d93ad7f7efe 100755 --- a/autotest/ogr/ogr_gtm.py +++ b/autotest/ogr/ogr_gtm.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_htf.py b/autotest/ogr/ogr_htf.py index a364f1de5044..19b4cef56f7d 100755 --- a/autotest/ogr/ogr_htf.py +++ b/autotest/ogr/ogr_htf.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_idrisi.py b/autotest/ogr/ogr_idrisi.py index 28b3014a211b..891c03424c75 100755 --- a/autotest/ogr/ogr_idrisi.py +++ b/autotest/ogr/ogr_idrisi.py @@ -31,7 +31,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_ili.py b/autotest/ogr/ogr_ili.py index 37e109da3224..54aea9615cfe 100755 --- a/autotest/ogr/ogr_ili.py +++ b/autotest/ogr/ogr_ili.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_index_test.py b/autotest/ogr/ogr_index_test.py index c39233c47685..e4947d9c7d1b 100755 --- a/autotest/ogr/ogr_index_test.py +++ b/autotest/ogr/ogr_index_test.py @@ -29,7 +29,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_ingres.py b/autotest/ogr/ogr_ingres.py index c11fee5db32c..88928c3a7fc7 100755 --- a/autotest/ogr/ogr_ingres.py +++ b/autotest/ogr/ogr_ingres.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_jml.py b/autotest/ogr/ogr_jml.py index 0abab1c5de10..c7cffd7e46e3 100755 --- a/autotest/ogr/ogr_jml.py +++ b/autotest/ogr/ogr_jml.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_join_test.py b/autotest/ogr/ogr_join_test.py index 6cd6afaee548..662638539980 100755 --- a/autotest/ogr/ogr_join_test.py +++ b/autotest/ogr/ogr_join_test.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/ogr/ogr_kml.py b/autotest/ogr/ogr_kml.py index ca3f859bcbab..fd04258ecd96 100755 --- a/autotest/ogr/ogr_kml.py +++ b/autotest/ogr/ogr_kml.py @@ -33,7 +33,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_layer_algebra.py b/autotest/ogr/ogr_layer_algebra.py index 5bd338259694..032008f17149 100755 --- a/autotest/ogr/ogr_layer_algebra.py +++ b/autotest/ogr/ogr_layer_algebra.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_libkml.py b/autotest/ogr/ogr_libkml.py index 64b830803e90..cf140360ecf2 100755 --- a/autotest/ogr/ogr_libkml.py +++ b/autotest/ogr/ogr_libkml.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_mem.py b/autotest/ogr/ogr_mem.py index bfffe994df66..f3dbf18f27c1 100755 --- a/autotest/ogr/ogr_mem.py +++ b/autotest/ogr/ogr_mem.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_mitab.py b/autotest/ogr/ogr_mitab.py index 4c45461c23ad..e1bcc0a7a42d 100755 --- a/autotest/ogr/ogr_mitab.py +++ b/autotest/ogr/ogr_mitab.py @@ -33,7 +33,6 @@ import shutil import time -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_mongodb.py b/autotest/ogr/ogr_mongodb.py index 7c2dfad0048c..3742d636fe3b 100755 --- a/autotest/ogr/ogr_mongodb.py +++ b/autotest/ogr/ogr_mongodb.py @@ -33,7 +33,6 @@ import sys import uuid -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_mssqlspatial.py b/autotest/ogr/ogr_mssqlspatial.py index 733c1e70e07b..e174aa1f8a85 100755 --- a/autotest/ogr/ogr_mssqlspatial.py +++ b/autotest/ogr/ogr_mssqlspatial.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_mvt.py b/autotest/ogr/ogr_mvt.py index 133ab7a472d7..723357d8b7e2 100644 --- a/autotest/ogr/ogr_mvt.py +++ b/autotest/ogr/ogr_mvt.py @@ -31,7 +31,6 @@ import json import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_mysql.py b/autotest/ogr/ogr_mysql.py index e3b95c700ac3..afb037367f05 100755 --- a/autotest/ogr/ogr_mysql.py +++ b/autotest/ogr/ogr_mysql.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_nas.py b/autotest/ogr/ogr_nas.py index 4ac7070a8e75..cebee95920e2 100755 --- a/autotest/ogr/ogr_nas.py +++ b/autotest/ogr/ogr_nas.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_ntf.py b/autotest/ogr/ogr_ntf.py index 7de31c0cf161..92f956ec10a4 100755 --- a/autotest/ogr/ogr_ntf.py +++ b/autotest/ogr/ogr_ntf.py @@ -80,7 +80,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/ogr/ogr_oci.py b/autotest/ogr/ogr_oci.py index 684f46aa12da..12dc80d6f638 100755 --- a/autotest/ogr/ogr_oci.py +++ b/autotest/ogr/ogr_oci.py @@ -29,7 +29,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_odbc.py b/autotest/ogr/ogr_odbc.py index 26f7e097eb7f..abb632f2428f 100755 --- a/autotest/ogr/ogr_odbc.py +++ b/autotest/ogr/ogr_odbc.py @@ -33,7 +33,6 @@ from osgeo import ogr from osgeo import gdal -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_ods.py b/autotest/ogr/ogr_ods.py index 64eb13ddca6e..fc76f3f9a96d 100755 --- a/autotest/ogr/ogr_ods.py +++ b/autotest/ogr/ogr_ods.py @@ -32,7 +32,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/ogr/ogr_ogdi.py b/autotest/ogr/ogr_ogdi.py index 788879733076..a81f35844f13 100755 --- a/autotest/ogr/ogr_ogdi.py +++ b/autotest/ogr/ogr_ogdi.py @@ -32,7 +32,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_openair.py b/autotest/ogr/ogr_openair.py index 63957daafce9..53183dab4823 100755 --- a/autotest/ogr/ogr_openair.py +++ b/autotest/ogr/ogr_openair.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_openfilegdb.py b/autotest/ogr/ogr_openfilegdb.py index b7aeca15d457..476cefe6306a 100755 --- a/autotest/ogr/ogr_openfilegdb.py +++ b/autotest/ogr/ogr_openfilegdb.py @@ -33,7 +33,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_osm.py b/autotest/ogr/ogr_osm.py index 8f1ddb3cd307..481f3684b68b 100755 --- a/autotest/ogr/ogr_osm.py +++ b/autotest/ogr/ogr_osm.py @@ -34,7 +34,6 @@ from osgeo import ogr from osgeo import gdal -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_pcidsk.py b/autotest/ogr/ogr_pcidsk.py index d13ed311408e..98c21c35f507 100755 --- a/autotest/ogr/ogr_pcidsk.py +++ b/autotest/ogr/ogr_pcidsk.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_pdf.py b/autotest/ogr/ogr_pdf.py index 56b7c4b39a78..6425cf17a6d9 100755 --- a/autotest/ogr/ogr_pdf.py +++ b/autotest/ogr/ogr_pdf.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_pds.py b/autotest/ogr/ogr_pds.py index 4d55b8c2120b..e32ad1f7236e 100755 --- a/autotest/ogr/ogr_pds.py +++ b/autotest/ogr/ogr_pds.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_pg.py b/autotest/ogr/ogr_pg.py index 96eb0ebddb4d..0aba6cc522e7 100755 --- a/autotest/ogr/ogr_pg.py +++ b/autotest/ogr/ogr_pg.py @@ -31,7 +31,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_pgdump.py b/autotest/ogr/ogr_pgdump.py index 9a6f37d18fb2..56de8f87c00c 100755 --- a/autotest/ogr/ogr_pgdump.py +++ b/autotest/ogr/ogr_pgdump.py @@ -31,7 +31,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_pgeo.py b/autotest/ogr/ogr_pgeo.py index 9d0f08e25c04..38af7371755a 100755 --- a/autotest/ogr/ogr_pgeo.py +++ b/autotest/ogr/ogr_pgeo.py @@ -33,7 +33,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_plscenes.py b/autotest/ogr/ogr_plscenes.py index 95d90b5f53a9..4dd8e2ca037d 100755 --- a/autotest/ogr/ogr_plscenes.py +++ b/autotest/ogr/ogr_plscenes.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import ogr from osgeo import gdal diff --git a/autotest/ogr/ogr_rec.py b/autotest/ogr/ogr_rec.py index 199a45b4e7dd..7114732af9b3 100755 --- a/autotest/ogr/ogr_rec.py +++ b/autotest/ogr/ogr_rec.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest diff --git a/autotest/ogr/ogr_refcount.py b/autotest/ogr/ogr_refcount.py index 2e492e51c6f5..f68fdf225645 100755 --- a/autotest/ogr/ogr_refcount.py +++ b/autotest/ogr/ogr_refcount.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_rfc30.py b/autotest/ogr/ogr_rfc30.py index f316404a90d0..5534c647b999 100755 --- a/autotest/ogr/ogr_rfc30.py +++ b/autotest/ogr/ogr_rfc30.py @@ -32,7 +32,6 @@ from sys import version_info from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/ogr/ogr_rfc35_mem.py b/autotest/ogr/ogr_rfc35_mem.py index a5160f8b0a7e..e6dbe09ec6eb 100755 --- a/autotest/ogr/ogr_rfc35_mem.py +++ b/autotest/ogr/ogr_rfc35_mem.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_rfc35_mitab.py b/autotest/ogr/ogr_rfc35_mitab.py index d979eaef4ee2..6fc3fd024b0b 100755 --- a/autotest/ogr/ogr_rfc35_mitab.py +++ b/autotest/ogr/ogr_rfc35_mitab.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_rfc35_shape.py b/autotest/ogr/ogr_rfc35_shape.py index 9f140696a614..c3553329a79f 100755 --- a/autotest/ogr/ogr_rfc35_shape.py +++ b/autotest/ogr/ogr_rfc35_shape.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_rfc35_sqlite.py b/autotest/ogr/ogr_rfc35_sqlite.py index af24a67da84f..4a7ff5058078 100755 --- a/autotest/ogr/ogr_rfc35_sqlite.py +++ b/autotest/ogr/ogr_rfc35_sqlite.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_rfc41.py b/autotest/ogr/ogr_rfc41.py index 08669b2fdfb3..b5d652b3c8b6 100755 --- a/autotest/ogr/ogr_rfc41.py +++ b/autotest/ogr/ogr_rfc41.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_s57.py b/autotest/ogr/ogr_s57.py index d6c43ea3d7fe..52d9356833dd 100755 --- a/autotest/ogr/ogr_s57.py +++ b/autotest/ogr/ogr_s57.py @@ -34,7 +34,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_sde.py b/autotest/ogr/ogr_sde.py index 7d4a4f204cba..6a2add8b484f 100755 --- a/autotest/ogr/ogr_sde.py +++ b/autotest/ogr/ogr_sde.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_sdts.py b/autotest/ogr/ogr_sdts.py index 0973fa9c620a..2fff407e33c9 100755 --- a/autotest/ogr/ogr_sdts.py +++ b/autotest/ogr/ogr_sdts.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_segukooa.py b/autotest/ogr/ogr_segukooa.py index 37544bb1cfaa..93815daefa06 100755 --- a/autotest/ogr/ogr_segukooa.py +++ b/autotest/ogr/ogr_segukooa.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_segy.py b/autotest/ogr/ogr_segy.py index 0c6ed2f2e576..7414dd76d4d0 100755 --- a/autotest/ogr/ogr_segy.py +++ b/autotest/ogr/ogr_segy.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_selafin.py b/autotest/ogr/ogr_selafin.py index 2581b6ead55e..67b14d001e2c 100755 --- a/autotest/ogr/ogr_selafin.py +++ b/autotest/ogr/ogr_selafin.py @@ -32,7 +32,6 @@ import sys import math -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_shape.py b/autotest/ogr/ogr_shape.py index a11ec426796b..f62b0072fc94 100755 --- a/autotest/ogr/ogr_shape.py +++ b/autotest/ogr/ogr_shape.py @@ -32,7 +32,6 @@ import struct import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_shape_qix.py b/autotest/ogr/ogr_shape_qix.py index 5a9a20203619..30eab6495492 100755 --- a/autotest/ogr/ogr_shape_qix.py +++ b/autotest/ogr/ogr_shape_qix.py @@ -32,7 +32,6 @@ import sys import random -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_shape_sbn.py b/autotest/ogr/ogr_shape_sbn.py index b76eecdd2a1b..5414513fe509 100755 --- a/autotest/ogr/ogr_shape_sbn.py +++ b/autotest/ogr/ogr_shape_sbn.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_sosi.py b/autotest/ogr/ogr_sosi.py index a9dba25b82aa..84b7724d2187 100755 --- a/autotest/ogr/ogr_sosi.py +++ b/autotest/ogr/ogr_sosi.py @@ -32,7 +32,6 @@ import sys from osgeo import ogr -sys.path.append('../pymod') import gdaltest diff --git a/autotest/ogr/ogr_sql_rfc28.py b/autotest/ogr/ogr_sql_rfc28.py index 65f7318b3593..f14da9947cbf 100755 --- a/autotest/ogr/ogr_sql_rfc28.py +++ b/autotest/ogr/ogr_sql_rfc28.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/ogr/ogr_sql_sqlite.py b/autotest/ogr/ogr_sql_sqlite.py index 7ff7c6973414..5e6e2c93f2b8 100755 --- a/autotest/ogr/ogr_sql_sqlite.py +++ b/autotest/ogr/ogr_sql_sqlite.py @@ -36,7 +36,6 @@ import sys -sys.path.append('../pymod') from osgeo import ogr from osgeo import osr diff --git a/autotest/ogr/ogr_sql_test.py b/autotest/ogr/ogr_sql_test.py index 9b26a5d080de..ae8b16074745 100755 --- a/autotest/ogr/ogr_sql_test.py +++ b/autotest/ogr/ogr_sql_test.py @@ -29,7 +29,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/ogr/ogr_sqlite.py b/autotest/ogr/ogr_sqlite.py index 9ee84ebc2430..d2c32cfd3993 100755 --- a/autotest/ogr/ogr_sqlite.py +++ b/autotest/ogr/ogr_sqlite.py @@ -39,7 +39,6 @@ if os.path.dirname(sys.argv[0]) != '': os.chdir(os.path.dirname(sys.argv[0])) -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/ogr/ogr_style.py b/autotest/ogr/ogr_style.py index 2253db38a0f6..ed8eb2a30681 100755 --- a/autotest/ogr/ogr_style.py +++ b/autotest/ogr/ogr_style.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_sua.py b/autotest/ogr/ogr_sua.py index d93eb801b479..659e38e3d541 100755 --- a/autotest/ogr/ogr_sua.py +++ b/autotest/ogr/ogr_sua.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_svg.py b/autotest/ogr/ogr_svg.py index 5fdf3f0c1cab..c12ce59819e2 100755 --- a/autotest/ogr/ogr_svg.py +++ b/autotest/ogr/ogr_svg.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_sxf.py b/autotest/ogr/ogr_sxf.py index 121ed6beb3e8..1cdb3199a6f0 100755 --- a/autotest/ogr/ogr_sxf.py +++ b/autotest/ogr/ogr_sxf.py @@ -28,7 +28,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_tiger.py b/autotest/ogr/ogr_tiger.py index 8280944e63bc..5540eb78f41a 100755 --- a/autotest/ogr/ogr_tiger.py +++ b/autotest/ogr/ogr_tiger.py @@ -34,7 +34,6 @@ from osgeo import gdal from osgeo import ogr -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_vdv.py b/autotest/ogr/ogr_vdv.py index 4818e2ff3fe9..593404b58454 100755 --- a/autotest/ogr/ogr_vdv.py +++ b/autotest/ogr/ogr_vdv.py @@ -32,7 +32,6 @@ import shutil import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_vfk.py b/autotest/ogr/ogr_vfk.py index efbca365f2b9..07537e2b30ae 100755 --- a/autotest/ogr/ogr_vfk.py +++ b/autotest/ogr/ogr_vfk.py @@ -33,7 +33,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/ogr/ogr_virtualogr.py b/autotest/ogr/ogr_virtualogr.py index 9cc9dbacf2b3..3ccf11aaf6e2 100755 --- a/autotest/ogr/ogr_virtualogr.py +++ b/autotest/ogr/ogr_virtualogr.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import ogr from osgeo import gdal diff --git a/autotest/ogr/ogr_vrt.py b/autotest/ogr/ogr_vrt.py index 555e72073928..6a702b314da4 100755 --- a/autotest/ogr/ogr_vrt.py +++ b/autotest/ogr/ogr_vrt.py @@ -30,7 +30,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_wasp.py b/autotest/ogr/ogr_wasp.py index ee7d06ea713b..22140cc7247d 100755 --- a/autotest/ogr/ogr_wasp.py +++ b/autotest/ogr/ogr_wasp.py @@ -32,7 +32,6 @@ import sys import math -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_wfs.py b/autotest/ogr/ogr_wfs.py index 3f2c72899aa1..748973331744 100755 --- a/autotest/ogr/ogr_wfs.py +++ b/autotest/ogr/ogr_wfs.py @@ -37,7 +37,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/ogr/ogr_wfs3.py b/autotest/ogr/ogr_wfs3.py index 5153840f791f..db39eb065b7a 100755 --- a/autotest/ogr/ogr_wfs3.py +++ b/autotest/ogr/ogr_wfs3.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_wkbwkt_geom.py b/autotest/ogr/ogr_wkbwkt_geom.py index 27f5f8e3e1db..1daef0149608 100755 --- a/autotest/ogr/ogr_wkbwkt_geom.py +++ b/autotest/ogr/ogr_wkbwkt_geom.py @@ -30,7 +30,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ogr_xls.py b/autotest/ogr/ogr_xls.py index 0a7cac642657..35d33aa5e126 100755 --- a/autotest/ogr/ogr_xls.py +++ b/autotest/ogr/ogr_xls.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/ogr/ogr_xlsx.py b/autotest/ogr/ogr_xlsx.py index 72e403e6e892..f6bcc643aaa7 100755 --- a/autotest/ogr/ogr_xlsx.py +++ b/autotest/ogr/ogr_xlsx.py @@ -32,7 +32,6 @@ import sys import shutil -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/ogr/ogr_xplane.py b/autotest/ogr/ogr_xplane.py index fbdc087ca474..3ac8110cd552 100755 --- a/autotest/ogr/ogr_xplane.py +++ b/autotest/ogr/ogr_xplane.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import ogr diff --git a/autotest/ogr/ograpispy.py b/autotest/ogr/ograpispy.py index 4e4f81fd5f52..38b440009f8c 100755 --- a/autotest/ogr/ograpispy.py +++ b/autotest/ogr/ograpispy.py @@ -34,7 +34,6 @@ import shutil from difflib import unified_diff -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/osr/osr_basic.py b/autotest/osr/osr_basic.py index 4c6b38997216..6ac462df2090 100755 --- a/autotest/osr/osr_basic.py +++ b/autotest/osr/osr_basic.py @@ -33,7 +33,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_compd.py b/autotest/osr/osr_compd.py index 64876e1832ab..d2d00d82e099 100755 --- a/autotest/osr/osr_compd.py +++ b/autotest/osr/osr_compd.py @@ -33,7 +33,6 @@ import sys import osr_proj4 -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_ct.py b/autotest/osr/osr_ct.py index 7597d8bf42ee..82b7874206fb 100755 --- a/autotest/osr/osr_ct.py +++ b/autotest/osr/osr_ct.py @@ -33,7 +33,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/osr/osr_ct_proj.py b/autotest/osr/osr_ct_proj.py index 46262a60ff90..21652be4e08b 100755 --- a/autotest/osr/osr_ct_proj.py +++ b/autotest/osr/osr_ct_proj.py @@ -33,7 +33,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr, gdal diff --git a/autotest/osr/osr_epsg.py b/autotest/osr/osr_epsg.py index 706ff9d4129d..59aa99930bae 100755 --- a/autotest/osr/osr_epsg.py +++ b/autotest/osr/osr_epsg.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_erm.py b/autotest/osr/osr_erm.py index ed4d504c659f..c51dfab5db7a 100755 --- a/autotest/osr/osr_erm.py +++ b/autotest/osr/osr_erm.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_esri.py b/autotest/osr/osr_esri.py index 488cd0d885ac..f22a15d0f5e6 100755 --- a/autotest/osr/osr_esri.py +++ b/autotest/osr/osr_esri.py @@ -37,7 +37,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/osr/osr_getprojectionmethods.py b/autotest/osr/osr_getprojectionmethods.py index 6010febbcbea..52776e4d8a7e 100755 --- a/autotest/osr/osr_getprojectionmethods.py +++ b/autotest/osr/osr_getprojectionmethods.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_metacrs.py b/autotest/osr/osr_metacrs.py index 97bcee50cf05..2f7d4fee1191 100755 --- a/autotest/osr/osr_metacrs.py +++ b/autotest/osr/osr_metacrs.py @@ -34,7 +34,6 @@ import sys import csv -sys.path.append('../pymod') import gdaltest diff --git a/autotest/osr/osr_micoordsys.py b/autotest/osr/osr_micoordsys.py index e89b24b54452..507d18ea313a 100755 --- a/autotest/osr/osr_micoordsys.py +++ b/autotest/osr/osr_micoordsys.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_ozi.py b/autotest/osr/osr_ozi.py index 128008d0652a..39c48ba60520 100755 --- a/autotest/osr/osr_ozi.py +++ b/autotest/osr/osr_ozi.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_pci.py b/autotest/osr/osr_pci.py index 6e36cd48cdee..3c62a2b66260 100755 --- a/autotest/osr/osr_pci.py +++ b/autotest/osr/osr_pci.py @@ -27,7 +27,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_pm.py b/autotest/osr/osr_pm.py index dbf9f57f3ac0..90c6679dab25 100755 --- a/autotest/osr/osr_pm.py +++ b/autotest/osr/osr_pm.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_proj4.py b/autotest/osr/osr_proj4.py index 26ab5f641f3d..6ccd98cd262f 100755 --- a/autotest/osr/osr_proj4.py +++ b/autotest/osr/osr_proj4.py @@ -34,7 +34,6 @@ import os import sys -sys.path.append('../pymod') from osgeo import gdal, osr import gdaltest diff --git a/autotest/osr/osr_url.py b/autotest/osr/osr_url.py index 82de82703d4e..486820ec9648 100755 --- a/autotest/osr/osr_url.py +++ b/autotest/osr/osr_url.py @@ -32,7 +32,6 @@ import sys import socket -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_usgs.py b/autotest/osr/osr_usgs.py index bb8d083d3486..d564d2e85fe2 100755 --- a/autotest/osr/osr_usgs.py +++ b/autotest/osr/osr_usgs.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import gdal diff --git a/autotest/osr/osr_validate.py b/autotest/osr/osr_validate.py index 364dc53c6602..2923b6a13061 100755 --- a/autotest/osr/osr_validate.py +++ b/autotest/osr/osr_validate.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/osr/osr_xml.py b/autotest/osr/osr_xml.py index de8f5e340ba8..e3e353342f4e 100755 --- a/autotest/osr/osr_xml.py +++ b/autotest/osr/osr_xml.py @@ -31,7 +31,6 @@ import re import sys -sys.path.append('../pymod') import gdaltest from osgeo import osr diff --git a/autotest/pyscripts/test_gdal2tiles.py b/autotest/pyscripts/test_gdal2tiles.py index 1ae3710bc303..4d81629116ba 100755 --- a/autotest/pyscripts/test_gdal2tiles.py +++ b/autotest/pyscripts/test_gdal2tiles.py @@ -33,7 +33,6 @@ import sys import shutil -sys.path.append('../pymod') from osgeo import gdal # noqa import gdaltest # noqa # pylint: disable=E0401 diff --git a/autotest/pyscripts/test_gdal_calc.py b/autotest/pyscripts/test_gdal_calc.py index 9d79d181a2ba..1a8682b3b2f0 100755 --- a/autotest/pyscripts/test_gdal_calc.py +++ b/autotest/pyscripts/test_gdal_calc.py @@ -34,7 +34,6 @@ import os import shutil -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/pyscripts/test_gdal_edit.py b/autotest/pyscripts/test_gdal_edit.py index 26dbe66404e1..08709fdfc069 100755 --- a/autotest/pyscripts/test_gdal_edit.py +++ b/autotest/pyscripts/test_gdal_edit.py @@ -33,7 +33,6 @@ import os import shutil -sys.path.append('../pymod') from osgeo import gdal import gdaltest @@ -313,7 +312,7 @@ def test_gdal_edit_py_6(): if stat_stddev is None or abs(float(stat_stddev) - 22.928)>0.001: gdaltest.post_reason('fail') return 'fail' - + ds = None test_py_scripts.run_py_script(script_path, 'gdal_edit', "tmp/test_gdal_edit_py.tif -setstats 22 217 100 30") @@ -336,7 +335,7 @@ def test_gdal_edit_py_6(): gdaltest.post_reason('fail') return 'fail' ds = None - + return 'success' ############################################################################### diff --git a/autotest/pyscripts/test_gdal_fillnodata.py b/autotest/pyscripts/test_gdal_fillnodata.py index f22778b1aa6f..9db3808e74b0 100755 --- a/autotest/pyscripts/test_gdal_fillnodata.py +++ b/autotest/pyscripts/test_gdal_fillnodata.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/pyscripts/test_gdal_ls_py.py b/autotest/pyscripts/test_gdal_ls_py.py index 043e653a241d..8fb481cd8789 100755 --- a/autotest/pyscripts/test_gdal_ls_py.py +++ b/autotest/pyscripts/test_gdal_ls_py.py @@ -32,7 +32,6 @@ import sys from osgeo import gdal -sys.path.append('../pymod') import gdaltest import test_py_scripts diff --git a/autotest/pyscripts/test_gdal_merge.py b/autotest/pyscripts/test_gdal_merge.py index ad61fed31aa5..d3bbdd165303 100755 --- a/autotest/pyscripts/test_gdal_merge.py +++ b/autotest/pyscripts/test_gdal_merge.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/pyscripts/test_gdal_pansharpen.py b/autotest/pyscripts/test_gdal_pansharpen.py index e416044e0c63..d77073570689 100755 --- a/autotest/pyscripts/test_gdal_pansharpen.py +++ b/autotest/pyscripts/test_gdal_pansharpen.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/pyscripts/test_gdal_polygonize.py b/autotest/pyscripts/test_gdal_polygonize.py index a89f6fb5a738..c1fc6399c4e0 100755 --- a/autotest/pyscripts/test_gdal_polygonize.py +++ b/autotest/pyscripts/test_gdal_polygonize.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/pyscripts/test_gdal_proximity.py b/autotest/pyscripts/test_gdal_proximity.py index 260e2967b9e1..8332f9adab44 100755 --- a/autotest/pyscripts/test_gdal_proximity.py +++ b/autotest/pyscripts/test_gdal_proximity.py @@ -32,7 +32,6 @@ import os import sys -sys.path.append('../pymod') import gdaltest import test_py_scripts diff --git a/autotest/pyscripts/test_gdal_retile.py b/autotest/pyscripts/test_gdal_retile.py index 2bb6fba219a5..eac1290e6940 100755 --- a/autotest/pyscripts/test_gdal_retile.py +++ b/autotest/pyscripts/test_gdal_retile.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/pyscripts/test_gdal_sieve.py b/autotest/pyscripts/test_gdal_sieve.py index 400782c21992..456a7d7570f3 100755 --- a/autotest/pyscripts/test_gdal_sieve.py +++ b/autotest/pyscripts/test_gdal_sieve.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import test_py_scripts diff --git a/autotest/pyscripts/test_gdalinfo_py.py b/autotest/pyscripts/test_gdalinfo_py.py index b6edffa4dd0f..a4e4d40fb7c8 100755 --- a/autotest/pyscripts/test_gdalinfo_py.py +++ b/autotest/pyscripts/test_gdalinfo_py.py @@ -31,7 +31,6 @@ import sys import os -sys.path.append('../pymod') import gdaltest import test_py_scripts diff --git a/autotest/pyscripts/test_gdalmove.py b/autotest/pyscripts/test_gdalmove.py index 43b230a824c2..57c7d1b8b7fa 100755 --- a/autotest/pyscripts/test_gdalmove.py +++ b/autotest/pyscripts/test_gdalmove.py @@ -32,7 +32,6 @@ import shutil import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/pyscripts/test_ogr2ogr_py.py b/autotest/pyscripts/test_ogr2ogr_py.py index e032281280b9..c1aee28f81f9 100755 --- a/autotest/pyscripts/test_ogr2ogr_py.py +++ b/autotest/pyscripts/test_ogr2ogr_py.py @@ -33,7 +33,6 @@ import os import shutil -sys.path.append('../pymod') sys.path.append('../ogr') from osgeo import gdal diff --git a/autotest/pyscripts/test_ogrinfo_py.py b/autotest/pyscripts/test_ogrinfo_py.py index 06f46ab884a2..953c7f6bf70f 100755 --- a/autotest/pyscripts/test_ogrinfo_py.py +++ b/autotest/pyscripts/test_ogrinfo_py.py @@ -31,7 +31,6 @@ import sys import os -sys.path.append('../pymod') import gdaltest import ogrtest diff --git a/autotest/pyscripts/test_ogrmerge.py b/autotest/pyscripts/test_ogrmerge.py index 6b728af940b4..742f143fe142 100755 --- a/autotest/pyscripts/test_ogrmerge.py +++ b/autotest/pyscripts/test_ogrmerge.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/pyscripts/test_rgb2pct.py b/autotest/pyscripts/test_rgb2pct.py index 270aad56d194..9d6c1ba352e3 100755 --- a/autotest/pyscripts/test_rgb2pct.py +++ b/autotest/pyscripts/test_rgb2pct.py @@ -33,7 +33,6 @@ import os import struct -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdal_contour.py b/autotest/utilities/test_gdal_contour.py index 1433e40c132e..4e91d48594a8 100755 --- a/autotest/utilities/test_gdal_contour.py +++ b/autotest/utilities/test_gdal_contour.py @@ -33,7 +33,6 @@ import os import array -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/utilities/test_gdal_grid.py b/autotest/utilities/test_gdal_grid.py index df09f584749b..9a0700e7dbaf 100755 --- a/autotest/utilities/test_gdal_grid.py +++ b/autotest/utilities/test_gdal_grid.py @@ -33,7 +33,6 @@ import os import struct -sys.path.append('../pymod') sys.path.append('../gcore') from osgeo import gdal diff --git a/autotest/utilities/test_gdal_grid_lib.py b/autotest/utilities/test_gdal_grid_lib.py index af3e8609f01d..f9e2ef0794b8 100755 --- a/autotest/utilities/test_gdal_grid_lib.py +++ b/autotest/utilities/test_gdal_grid_lib.py @@ -32,7 +32,6 @@ import sys import struct -sys.path.append('../pymod') from osgeo import gdal, ogr diff --git a/autotest/utilities/test_gdal_rasterize.py b/autotest/utilities/test_gdal_rasterize.py index 0cedad48708a..5cbceac04a75 100755 --- a/autotest/utilities/test_gdal_rasterize.py +++ b/autotest/utilities/test_gdal_rasterize.py @@ -33,7 +33,6 @@ import sys import os -sys.path.append('../pymod') sys.path.append('../gcore') from osgeo import gdal diff --git a/autotest/utilities/test_gdal_rasterize_lib.py b/autotest/utilities/test_gdal_rasterize_lib.py index 6d5467826de3..61b41356bf55 100755 --- a/autotest/utilities/test_gdal_rasterize_lib.py +++ b/autotest/utilities/test_gdal_rasterize_lib.py @@ -32,7 +32,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal, ogr, osr import gdaltest diff --git a/autotest/utilities/test_gdal_translate.py b/autotest/utilities/test_gdal_translate.py index c16c66a07c99..023af4d4ae6e 100755 --- a/autotest/utilities/test_gdal_translate.py +++ b/autotest/utilities/test_gdal_translate.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdal_translate_lib.py b/autotest/utilities/test_gdal_translate_lib.py index 1f8422e5ab8c..3a429f8ece29 100755 --- a/autotest/utilities/test_gdal_translate_lib.py +++ b/autotest/utilities/test_gdal_translate_lib.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdaladdo.py b/autotest/utilities/test_gdaladdo.py index 4e74fe1dae7d..4e9ac9e3a081 100755 --- a/autotest/utilities/test_gdaladdo.py +++ b/autotest/utilities/test_gdaladdo.py @@ -33,7 +33,6 @@ import os import shutil -sys.path.append('../pymod') sys.path.append('../gcore') from osgeo import gdal diff --git a/autotest/utilities/test_gdalbuildvrt.py b/autotest/utilities/test_gdalbuildvrt.py index 2133964b1874..86f70f691697 100755 --- a/autotest/utilities/test_gdalbuildvrt.py +++ b/autotest/utilities/test_gdalbuildvrt.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/utilities/test_gdalbuildvrt_lib.py b/autotest/utilities/test_gdalbuildvrt_lib.py index 96d3267ce6d6..37f2815ad471 100755 --- a/autotest/utilities/test_gdalbuildvrt_lib.py +++ b/autotest/utilities/test_gdalbuildvrt_lib.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdaldem.py b/autotest/utilities/test_gdaldem.py index 24c53a864b02..d0d5bd74c4fa 100755 --- a/autotest/utilities/test_gdaldem.py +++ b/autotest/utilities/test_gdaldem.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/utilities/test_gdaldem_lib.py b/autotest/utilities/test_gdaldem_lib.py index 6cd723ebcfa4..68b394f04f05 100755 --- a/autotest/utilities/test_gdaldem_lib.py +++ b/autotest/utilities/test_gdaldem_lib.py @@ -32,7 +32,6 @@ import struct import sys -sys.path.append('../pymod') from osgeo import gdal from osgeo import osr diff --git a/autotest/utilities/test_gdalinfo.py b/autotest/utilities/test_gdalinfo.py index ad5824afa680..72b5d6e20cbc 100755 --- a/autotest/utilities/test_gdalinfo.py +++ b/autotest/utilities/test_gdalinfo.py @@ -33,7 +33,6 @@ import os import json -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdalinfo_lib.py b/autotest/utilities/test_gdalinfo_lib.py index 351429e92a20..6d4ca74ee58d 100755 --- a/autotest/utilities/test_gdalinfo_lib.py +++ b/autotest/utilities/test_gdalinfo_lib.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdallocationinfo.py b/autotest/utilities/test_gdallocationinfo.py index 38c1f141037c..28c47852fba6 100755 --- a/autotest/utilities/test_gdallocationinfo.py +++ b/autotest/utilities/test_gdallocationinfo.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') sys.path.append('../gcore') from osgeo import gdal diff --git a/autotest/utilities/test_gdalsrsinfo.py b/autotest/utilities/test_gdalsrsinfo.py index d9a45b43f97d..1c879d9df8d9 100755 --- a/autotest/utilities/test_gdalsrsinfo.py +++ b/autotest/utilities/test_gdalsrsinfo.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') import gdaltest import test_cli_utilities diff --git a/autotest/utilities/test_gdaltindex.py b/autotest/utilities/test_gdaltindex.py index 6cf76a53d5b7..51d6573f46f6 100755 --- a/autotest/utilities/test_gdaltindex.py +++ b/autotest/utilities/test_gdaltindex.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal from osgeo import ogr diff --git a/autotest/utilities/test_gdaltransform.py b/autotest/utilities/test_gdaltransform.py index 71bfaafe043e..4889da5c3749 100755 --- a/autotest/utilities/test_gdaltransform.py +++ b/autotest/utilities/test_gdaltransform.py @@ -30,7 +30,6 @@ import sys -sys.path.append('../pymod') import gdaltest import test_cli_utilities diff --git a/autotest/utilities/test_gdalwarp.py b/autotest/utilities/test_gdalwarp.py index 23b98b253180..978bba0e385a 100755 --- a/autotest/utilities/test_gdalwarp.py +++ b/autotest/utilities/test_gdalwarp.py @@ -33,7 +33,6 @@ import os import stat -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_gdalwarp_lib.py b/autotest/utilities/test_gdalwarp_lib.py index c69347c7f280..4c8602bd5386 100755 --- a/autotest/utilities/test_gdalwarp_lib.py +++ b/autotest/utilities/test_gdalwarp_lib.py @@ -34,7 +34,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal, ogr, osr import gdaltest diff --git a/autotest/utilities/test_gnmutils.py b/autotest/utilities/test_gnmutils.py index 1e8fa4a623a7..1c4cc05a7d72 100755 --- a/autotest/utilities/test_gnmutils.py +++ b/autotest/utilities/test_gnmutils.py @@ -34,7 +34,6 @@ import sys import os -sys.path.append('../pymod') import gdaltest import test_cli_utilities diff --git a/autotest/utilities/test_nearblack.py b/autotest/utilities/test_nearblack.py index 789b9ddabb54..f64c14a4cd90 100755 --- a/autotest/utilities/test_nearblack.py +++ b/autotest/utilities/test_nearblack.py @@ -33,7 +33,6 @@ import os import shutil -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_nearblack_lib.py b/autotest/utilities/test_nearblack_lib.py index 156e3b09c207..e455722bd02e 100755 --- a/autotest/utilities/test_nearblack_lib.py +++ b/autotest/utilities/test_nearblack_lib.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_ogr2ogr.py b/autotest/utilities/test_ogr2ogr.py index 7bf485e0673e..f1ffec3add1d 100755 --- a/autotest/utilities/test_ogr2ogr.py +++ b/autotest/utilities/test_ogr2ogr.py @@ -33,7 +33,6 @@ import os import shutil -sys.path.append('../pymod') sys.path.append('../ogr') from osgeo import gdal, ogr, osr diff --git a/autotest/utilities/test_ogr2ogr_lib.py b/autotest/utilities/test_ogr2ogr_lib.py index 7b89605a5937..65d41994b42c 100755 --- a/autotest/utilities/test_ogr2ogr_lib.py +++ b/autotest/utilities/test_ogr2ogr_lib.py @@ -31,7 +31,6 @@ import sys -sys.path.append('../pymod') from osgeo import gdal, gdalconst, ogr import gdaltest diff --git a/autotest/utilities/test_ogrinfo.py b/autotest/utilities/test_ogrinfo.py index 201805f5af0d..8eb21a5e4738 100755 --- a/autotest/utilities/test_ogrinfo.py +++ b/autotest/utilities/test_ogrinfo.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import gdal import gdaltest diff --git a/autotest/utilities/test_ogrlineref.py b/autotest/utilities/test_ogrlineref.py index 0fda9c04ec4b..011e37230c3d 100755 --- a/autotest/utilities/test_ogrlineref.py +++ b/autotest/utilities/test_ogrlineref.py @@ -31,7 +31,6 @@ import sys import os -sys.path.append('../pymod') sys.path.append('../ogr') from osgeo import ogr diff --git a/autotest/utilities/test_ogrtindex.py b/autotest/utilities/test_ogrtindex.py index 4344aaa3fdab..c7805766d23f 100755 --- a/autotest/utilities/test_ogrtindex.py +++ b/autotest/utilities/test_ogrtindex.py @@ -32,7 +32,6 @@ import sys import os -sys.path.append('../pymod') from osgeo import ogr from osgeo import osr From 2508d8119049786bd96b61a1f4d3042526705a16 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Wed, 3 Oct 2018 22:21:54 +1300 Subject: [PATCH 120/488] Refactor more of the dynamic tests to use parametrization --- autotest/gcore/tiff_srs.py | 246 ++++++++++++++++++------------------- autotest/gdrivers/fit.py | 55 ++------- autotest/gdrivers/fits.py | 95 ++++---------- autotest/gdrivers/gxf.py | 50 ++++---- autotest/gdrivers/hdf5.py | 142 ++++++--------------- autotest/gdrivers/l1b.py | 95 +++++++------- autotest/gdrivers/xmp.py | 156 ++++++++++------------- autotest/gdrivers/xpm.py | 42 +++---- 8 files changed, 339 insertions(+), 542 deletions(-) diff --git a/autotest/gcore/tiff_srs.py b/autotest/gcore/tiff_srs.py index c21da49a5b20..3b2e15d9dfec 100755 --- a/autotest/gcore/tiff_srs.py +++ b/autotest/gcore/tiff_srs.py @@ -30,6 +30,8 @@ import sys +import pytest + from osgeo import gdal from osgeo import osr @@ -37,55 +39,6 @@ import gdaltest -############################################################################### -# Write a geotiff and read it back to check its SRS - -class TestTiffSRS(object): - def __init__(self, epsg_code, use_epsg_code, expected_fail): - self.epsg_code = epsg_code - self.use_epsg_code = use_epsg_code - self.expected_fail = expected_fail - - def test(self): - sr = osr.SpatialReference() - if isinstance(self.epsg_code, str): - sr.SetFromUserInput(self.epsg_code) - else: - sr.ImportFromEPSG(self.epsg_code) - if self.use_epsg_code == 0: - proj4str = sr.ExportToProj4() - # print(proj4str) - sr.SetFromUserInput(proj4str) - - ds = gdal.GetDriverByName('GTiff').Create('/vsimem/TestTiffSRS.tif', 1, 1) - ds.SetProjection(sr.ExportToWkt()) - ds = None - - ds = gdal.Open('/vsimem/TestTiffSRS.tif') - wkt = ds.GetProjectionRef() - sr2 = osr.SpatialReference() - sr2.SetFromUserInput(wkt) - ds = None - - gdal.Unlink('/vsimem/TestTiffSRS.tif') - - if sr.IsSame(sr2) != 1: - if self.expected_fail: - print('did not get expected SRS. known to be broken currently. FIXME!') - # print(sr) - # print(sr2) - return 'expected_fail' - - gdaltest.post_reason('did not get expected SRS') - print(sr) - print(sr2) - return 'fail' - else: - if self.expected_fail: - print('Succeeded but expected fail...') - - return 'success' - ############################################################################### # Test fix for #4677: @@ -501,82 +454,125 @@ def tiff_srs_pcscitation(): return 'success' -gdaltest_list = [] - -tiff_srs_list = [2758, # tmerc - 2036, # sterea - 2046, # tmerc - 3031, # polar stere (ticket #3220) - 3032, # polar stere (ticket #3220) - 32661, # stere - 3035, # laea - 2062, # lcc 1SP - [2065, False, True], # krovak - 2066, # cass - 2964, # aea - 3410, # cea - 3786, # eqc spherical, method=9823 - 32663, # eqc elliptical, method=9842 - 4087, # eqc WGS 84 / World Equidistant Cylindrical method=1028 - 4088, # eqc World Equidistant Cylindrical (Sphere) method=1029 - 2934, # merc - 27200, # nzmg - 2057, # omerc Hotine_Oblique_Mercator_Azimuth_Center - 3591, # omerc Hotine_Oblique_Mercator - 29100, # poly - 2056, # somerc - 2027, # utm - 4326, # longlat - 26943, # lcc 2SP, - 4328, # geocentric - 3994, # mercator 2SP - 26920, # UTM NAD83 special case - 26720, # UTM NAD27 special case - 32630, # UTM WGS84 north special case - 32730, # UTM WGS84 south special case - 22700, # unknown datum 'Deir_ez_Zor' - 31491, # Germany Zone projection - [3857, False, True], # Web Mercator - [102113, False, True], # ESRI WGS_1984_Web_Mercator - ] - -for item in tiff_srs_list: - try: - epsg_code = item[0] - epsg_broken = item[1] - epsg_proj4_broken = item[2] - except TypeError: - epsg_code = item - epsg_broken = False - epsg_proj4_broken = False - - ut = TestTiffSRS(epsg_code, 1, epsg_broken) - gdaltest_list.append((ut.test, "tiff_srs_epsg_%d" % epsg_code)) - ut = TestTiffSRS(epsg_code, 0, epsg_proj4_broken) - gdaltest_list.append((ut.test, "tiff_srs_proj4_of_epsg_%d" % epsg_code)) - -tiff_srs_list_proj4 = [['eqdc', '+proj=eqdc +lat_0=%.16g +lon_0=%.16g +lat_1=%.16g +lat_2=%.16g" +x_0=%.16g +y_0=%.16g' % (1, 2, 3, 4, 5, 6)], - ['mill', '+proj=mill +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g +R_A' % (1, 2, 3, 4)], - ['gnom', '+proj=gnom +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g' % (1, 2, 3, 4)], - ['robin', '+proj=robin +lon_0=%.16g +x_0=%.16g +y_0=%.16g' % (1, 2, 3)], - ['sinu', '+proj=sinu +lon_0=%.16g +x_0=%.16g +y_0=%.16g' % (1, 2, 3)], - ] -for (title, proj4) in tiff_srs_list_proj4: - ut = TestTiffSRS(proj4, 0, False) - gdaltest_list.append((ut.test, "tiff_srs_proj4_%s" % title)) - -gdaltest_list.append(tiff_srs_without_linear_units) -gdaltest_list.append(tiff_srs_compd_cs) -gdaltest_list.append(tiff_srs_weird_mercator_2sp) -gdaltest_list.append(tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere) -gdaltest_list.append(tiff_srs_angular_units) -gdaltest_list.append(tiff_custom_datum_known_ellipsoid) -gdaltest_list.append(tiff_srs_epsg_2853_with_us_feet) -gdaltest_list.append(tiff_srs_PCSCitationGeoKey_LUnits) -gdaltest_list.append(tiff_srs_projection_3856) -gdaltest_list.append(tiff_srs_imagine_localcs_citation) -gdaltest_list.append(tiff_srs_towgs84_override) -gdaltest_list.append(tiff_srs_pcscitation) +def _test_tiff_srs(sr, expect_fail): + """ + This is not a test by itself; it gets called by the tests below. + """ + ds = gdal.GetDriverByName('GTiff').Create('/vsimem/TestTiffSRS.tif', 1, 1) + ds.SetProjection(sr.ExportToWkt()) + ds = None + + ds = gdal.Open('/vsimem/TestTiffSRS.tif') + wkt = ds.GetProjectionRef() + sr2 = osr.SpatialReference() + sr2.SetFromUserInput(wkt) + ds = None + + gdal.Unlink('/vsimem/TestTiffSRS.tif') + + if sr.IsSame(sr2) != 1: + if expect_fail: + pytest.xfail('did not get expected SRS. known to be broken currently. FIXME!') + + print(sr) + print(sr2) + assert False, 'did not get expected SRS' + else: + if expect_fail: + print('Succeeded but expected fail...') + + +############################################################################### +# Write a geotiff and read it back to check its SRS + +@pytest.mark.parametrize('use_epsg_code', [0, 1]) +@pytest.mark.parametrize('epsg_code,epsg_proj4_broken', [ + [2758, False], # tmerc + [2036, False], # sterea + [2046, False], # tmerc + [3031, False], # polar stere (ticket #3220) + [3032, False], # polar stere (ticket #3220) + [32661, False], # stere + [3035, False], # laea + [2062, False], # lcc 1SP + [2065, True], # krovak + [2066, False], # cass + [2964, False], # aea + [3410, False], # cea + [3786, False], # eqc spherical, method=9823 + [32663, False], # eqc elliptical, method=9842 + [4087, False], # eqc WGS 84 / World Equidistant Cylindrical method=1028 + [4088, False], # eqc World Equidistant Cylindrical (Sphere) method=1029 + [2934, False], # merc + [27200, False], # nzmg + [2057, False], # omerc Hotine_Oblique_Mercator_Azimuth_Center + [3591, False], # omerc Hotine_Oblique_Mercator + [29100, False], # poly + [2056, False], # somerc + [2027, False], # utm + [4326, False], # longlat + [26943, False], # lcc 2SP, + [4328, False], # geocentric + [3994, False], # mercator 2SP + [26920, False], # UTM NAD83 special case + [26720, False], # UTM NAD27 special case + [32630, False], # UTM WGS84 north special case + [32730, False], # UTM WGS84 south special case + [22700, False], # unknown datum 'Deir_ez_Zor' + [31491, False], # Germany Zone projection + [3857, True], # Web Mercator + [102113, True], # ESRI WGS_1984_Web_Mercator +]) +def test_tiff_srs(use_epsg_code, epsg_code, epsg_proj4_broken): + sr = osr.SpatialReference() + sr.ImportFromEPSG(epsg_code) + expect_fail = False + if use_epsg_code == 0: + proj4str = sr.ExportToProj4() + # print(proj4str) + sr.SetFromUserInput(proj4str) + expect_fail = epsg_proj4_broken + + _test_tiff_srs(sr, expect_fail) + + +@pytest.mark.parametrize( + 'proj4', + [ + ['+proj=eqdc +lat_0=%.16g +lon_0=%.16g +lat_1=%.16g +lat_2=%.16g" +x_0=%.16g +y_0=%.16g' % (1, 2, 3, 4, 5, 6)], + ['+proj=mill +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g +R_A' % (1, 2, 3, 4)], + ['+proj=gnom +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g' % (1, 2, 3, 4)], + ['+proj=robin +lon_0=%.16g +x_0=%.16g +y_0=%.16g' % (1, 2, 3)], + ['+proj=sinu +lon_0=%.16g +x_0=%.16g +y_0=%.16g' % (1, 2, 3)], + ], + ids=[ + 'eqdc', + 'mill', + 'gnom', + 'robin', + 'sinu', + ] +) +def test_tiff_srs_proj4(proj4): + sr = osr.SpatialReference() + sr.SetFromUserInput(proj4) + _test_tiff_srs(sr, False) + + +gdaltest_list = [ + tiff_srs_without_linear_units, + tiff_srs_compd_cs, + tiff_srs_weird_mercator_2sp, + tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere, + tiff_srs_angular_units, + tiff_custom_datum_known_ellipsoid, + tiff_srs_epsg_2853_with_us_feet, + tiff_srs_PCSCitationGeoKey_LUnits, + tiff_srs_projection_3856, + tiff_srs_imagine_localcs_citation, + tiff_srs_towgs84_override, + tiff_srs_pcscitation, +] if __name__ == '__main__': diff --git a/autotest/gdrivers/fit.py b/autotest/gdrivers/fit.py index 05a0896eda2d..7cbc6318ed14 100755 --- a/autotest/gdrivers/fit.py +++ b/autotest/gdrivers/fit.py @@ -28,51 +28,22 @@ # DEALINGS IN THE SOFTWARE. ############################################################################### -import sys -from osgeo import gdal - - -import gdaltest - -############################################################################### -# - - -class TestFIT(object): - def __init__(self, fileName): - self.fileName = fileName - self.fitDriver = gdal.GetDriverByName('FIT') - - def test(self): +import pytest - ds = gdal.Open('../gcore/data/' + self.fileName + '.tif') - self.fitDriver.CreateCopy('tmp/' + self.fileName + '.fit', ds, options=['PAGESIZE=2,2']) - - ds2 = gdal.Open('tmp/' + self.fileName + '.fit') - if ds2.GetRasterBand(1).Checksum() != ds.GetRasterBand(1).Checksum(): - return 'fail' - - if ds2.GetRasterBand(1).DataType != ds.GetRasterBand(1).DataType: - return 'fail' - - ds2 = None - self.fitDriver.Delete('tmp/' + self.fileName + '.fit') - return 'success' - - -gdaltest_list = [] - -fit_list = ['byte', 'int16', 'uint16', 'int32', 'uint32', 'float32', 'float64'] - -for item in fit_list: - ut = TestFIT(item) - gdaltest_list.append((ut.test, item)) +from osgeo import gdal -if __name__ == '__main__': +@pytest.mark.parametrize('filename', [ + 'byte', 'int16', 'uint16', 'int32', 'uint32', 'float32', 'float64' +]) +def test_fit(filename): + fitDriver = gdal.GetDriverByName('FIT') - gdaltest.setup_run('fit') + ds = gdal.Open('../gcore/data/' + filename + '.tif') + fitDriver.CreateCopy('tmp/' + filename + '.fit', ds, options=['PAGESIZE=2,2']) - gdaltest.run_tests(gdaltest_list) + ds2 = gdal.Open('tmp/' + filename + '.fit') + assert ds2.GetRasterBand(1).Checksum() == ds.GetRasterBand(1).Checksum() - sys.exit(gdaltest.summarize()) + assert ds2.GetRasterBand(1).DataType == ds.GetRasterBand(1).DataType + ds2 = None diff --git a/autotest/gdrivers/fits.py b/autotest/gdrivers/fits.py index 63110d721abd..605e5506899d 100755 --- a/autotest/gdrivers/fits.py +++ b/autotest/gdrivers/fits.py @@ -28,59 +28,39 @@ # DEALINGS IN THE SOFTWARE. ############################################################################### -import sys -from osgeo import gdal - - -import gdaltest - -############################################################################### -# - - -def fits_init(): - gdaltest.fitsDriver = gdal.GetDriverByName('FITS') - if gdaltest.fitsDriver is None: - return 'skip' +import pytest - return 'success' - -############################################################################### -# - - -class TestFITS(object): - def __init__(self, fileName): - self.fileName = fileName +from osgeo import gdal - def test(self): - if gdaltest.fitsDriver is None: - return 'skip' - ds = gdal.Open('../gcore/data/' + self.fileName + '.tif') - gdaltest.fitsDriver.CreateCopy('tmp/' + self.fileName + '.fits', ds, options=['PAGESIZE=2,2']) +@pytest.fixture +def driver(): + driver = gdal.GetDriverByName('FITS') + if driver is None: + pytest.skip() + return driver - ds2 = gdal.Open('tmp/' + self.fileName + '.fits') - if ds2.GetRasterBand(1).Checksum() != ds.GetRasterBand(1).Checksum(): - return 'fail' - if ds2.GetRasterBand(1).DataType != ds.GetRasterBand(1).DataType: - return 'fail' +@pytest.mark.parametrize( + 'filename', + ['byte', 'int16', 'int32', 'float32', 'float64'] +) +def test_fits(driver, filename): + ds = gdal.Open('../gcore/data/' + filename + '.tif') + driver.CreateCopy('tmp/' + filename + '.fits', ds, options=['PAGESIZE=2,2']) - ds2 = None - gdaltest.fitsDriver.Delete('tmp/' + self.fileName + '.fits') - return 'success' + ds2 = gdal.Open('tmp/' + filename + '.fits') + assert ds2.GetRasterBand(1).Checksum() == ds.GetRasterBand(1).Checksum() -############################################################################### -# + assert ds2.GetRasterBand(1).DataType == ds.GetRasterBand(1).DataType + ds2 = None + driver.Delete('tmp/' + filename + '.fits') -def fits_metadata(): - if gdaltest.fitsDriver is None: - return 'skip' +def fits_metadata(driver): ds = gdal.Open('../gcore/data/byte.tif') - ds2 = gdaltest.fitsDriver.CreateCopy('tmp/byte.fits', ds) + ds2 = driver.CreateCopy('tmp/byte.fits', ds) md = {'TEST': 'test_value'} ds2.SetMetadata(md) ds2 = None @@ -90,8 +70,7 @@ def fits_metadata(): md = ds2.GetMetadata() ds2 = None - if md['TEST'] != 'test_value': - return 'fail' + assert md['TEST'] == 'test_value' ds2 = gdal.Open('tmp/byte.fits', gdal.GA_Update) md = {'TEST2': 'test_value2'} @@ -103,30 +82,4 @@ def fits_metadata(): md = ds2.GetMetadata() ds2 = None - if md['TEST2'] != 'test_value2': - return 'fail' - - gdaltest.fitsDriver.Delete('tmp/byte.fits') - - return 'success' - - -############################################################################### -# -gdaltest_list = [fits_init] - -fits_list = ['byte', 'int16', 'int32', 'float32', 'float64'] - -for item in fits_list: - ut = TestFITS(item) - gdaltest_list.append((ut.test, item)) - -gdaltest_list.append(fits_metadata) - -if __name__ == '__main__': - - gdaltest.setup_run('fits') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + assert md['TEST2'] == 'test_value2' diff --git a/autotest/gdrivers/gxf.py b/autotest/gdrivers/gxf.py index 05c63232ad30..8b970146aaff 100755 --- a/autotest/gdrivers/gxf.py +++ b/autotest/gdrivers/gxf.py @@ -30,6 +30,9 @@ ############################################################################### import sys + +import pytest + from osgeo import gdal @@ -68,44 +71,33 @@ def gxf_2(): return tst.testOpen(check_prj=wkt) -############################################################################### -# - -class TestGXF(object): - def __init__(self, downloadURL, fileName, checksum, download_size): - self.downloadURL = downloadURL - self.fileName = fileName - self.checksum = checksum - self.download_size = download_size +gxf_list = [ + ('http://download.osgeo.org/gdal/data/gxf', 'SAMPLE.GXF', 24068, -1), + ('http://download.osgeo.org/gdal/data/gxf', 'gxf_compressed.gxf', 20120, -1), + ('http://download.osgeo.org/gdal/data/gxf', 'gxf_text.gxf', 20265, -1), + ('http://download.osgeo.org/gdal/data/gxf', 'gxf_ul_r.gxf', 19930, -1), + ('http://download.osgeo.org/gdal/data/gxf', 'latlong.gxf', 12243, -1), + ('http://download.osgeo.org/gdal/data/gxf', 'spif83.gxf', 28752, -1), +] - def test(self): - if not gdaltest.download_file(self.downloadURL + '/' + self.fileName, self.fileName, self.download_size): - return 'skip' - ds = gdal.Open('tmp/cache/' + self.fileName) +@pytest.mark.parametrize( + 'downloadURL,fileName,checksum,download_size', + gxf_list, + ids=[tup[1] for tup in gxf_list], +) +def test_gxf(downloadURL, fileName, checksum, download_size): + if not gdaltest.download_file(downloadURL + '/' + fileName, fileName, download_size): + pytest.skip() - if ds.GetRasterBand(1).Checksum() != self.checksum: - gdaltest.post_reason('Bad checksum. Expected %d, got %d' % (self.checksum, ds.GetRasterBand(1).Checksum())) - return 'fail' + ds = gdal.Open('tmp/cache/' + fileName) - return 'success' + assert ds.GetRasterBand(1).Checksum() == checksum, 'Bad checksum. Expected %d, got %d' % (checksum, ds.GetRasterBand(1).Checksum()) gdaltest_list = [gxf_1, gxf_2] -gxf_list = [('http://download.osgeo.org/gdal/data/gxf', 'SAMPLE.GXF', 24068, -1), - ('http://download.osgeo.org/gdal/data/gxf', 'gxf_compressed.gxf', 20120, -1), - ('http://download.osgeo.org/gdal/data/gxf', 'gxf_text.gxf', 20265, -1), - ('http://download.osgeo.org/gdal/data/gxf', 'gxf_ul_r.gxf', 19930, -1), - ('http://download.osgeo.org/gdal/data/gxf', 'latlong.gxf', 12243, -1), - ('http://download.osgeo.org/gdal/data/gxf', 'spif83.gxf', 28752, -1) - ] - -for item in gxf_list: - ut = TestGXF(item[0], item[1], item[2], item[3]) - gdaltest_list.append((ut.test, item[1])) - if __name__ == '__main__': diff --git a/autotest/gdrivers/hdf5.py b/autotest/gdrivers/hdf5.py index d0229f214808..eec1d07133eb 100755 --- a/autotest/gdrivers/hdf5.py +++ b/autotest/gdrivers/hdf5.py @@ -32,6 +32,8 @@ import sys import shutil +import pytest + from osgeo import gdal @@ -43,25 +45,29 @@ # Test if HDF5 driver is present -def hdf5_1(): +@pytest.fixture +def driver(autouse=True, scope='module'): + driver = gdal.GetDriverByName('HDF5') + if driver is None: + pytest.skip('No HDF5 driver') + return driver - gdaltest.hdf5_drv = gdal.GetDriverByName('HDF5') - if gdaltest.hdf5_drv is None: - return 'skip' - gdaltest.count_opened_files = len(gdaltest.get_opened_files()) +@pytest.fixture(autouse=True) +def check_no_file_leaks(): + num_files = len(gdaltest.get_opened_files()) + + yield + + diff = len(gdaltest.get_opened_files()) - num_files + assert diff == 0, 'Leak of file handles: %d leaked' % diff - return 'success' ############################################################################### # Confirm expected subdataset information. def hdf5_2(): - - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('data/groups.h5') sds_list = ds.GetMetadata('SUBDATASETS') @@ -92,9 +98,6 @@ def hdf5_2(): def hdf5_3(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/u8be.h5"://TestArray') cs = ds.GetRasterBand(1).Checksum() @@ -116,9 +119,6 @@ def hdf5_3(): def hdf5_4(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/u8be.h5"://TestArray') cs = ds.GetRasterBand(1).Checksum() @@ -134,9 +134,6 @@ def hdf5_4(): def hdf5_5(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/groups.h5"://MyGroup/dset1') cs = ds.GetRasterBand(1).Checksum() @@ -152,9 +149,6 @@ def hdf5_5(): def hdf5_6(): - if gdaltest.hdf5_drv is None: - return 'skip' - shutil.copyfile('data/groups.h5', 'tmp/groups.h5') ds = gdal.Open('HDF5:"tmp/groups.h5"://MyGroup/dset1') @@ -194,9 +188,6 @@ def hdf5_6(): def hdf5_7(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('data/metadata.h5') metadata = ds.GetMetadata() metadataList = ds.GetMetadata_List() @@ -225,9 +216,6 @@ def hdf5_7(): def hdf5_8(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('data/metadata.h5') metadata = ds.GetMetadata() ds = None @@ -292,9 +280,6 @@ def scanMetadata(parts): def hdf5_9(): - if gdaltest.hdf5_drv is None: - return 'skip' - if int(gdal.VersionInfo('VERSION_NUM')) < 1900: gdaltest.post_reason('would crash') return 'skip' @@ -340,9 +325,6 @@ def hdf5_9(): def hdf5_10(): - if gdaltest.hdf5_drv is None: - return 'skip' - # Try opening the QLK subdataset to check that no error is generated gdal.ErrorReset() ds = gdal.Open('HDF5:"data/CSK_DGM.h5"://S01/QLK') @@ -381,9 +363,6 @@ def hdf5_10(): def hdf5_11(): - if gdaltest.hdf5_drv is None: - return 'skip' - # Try opening the QLK subdataset to check that no error is generated gdal.ErrorReset() ds = gdal.Open('HDF5:"data/CSK_GEC.h5"://S01/QLK') @@ -421,9 +400,6 @@ def hdf5_11(): def hdf5_12(): - if gdaltest.hdf5_drv is None: - return 'skip' - if not gdaltest.download_file('http://trac.osgeo.org/gdal/raw-attachment/ticket/5032/norsa.ss.ppi-00.5-dbz.aeqd-1000.20070601T000039Z.hdf', 'norsa.ss.ppi-00.5-dbz.aeqd-1000.20070601T000039Z.hdf'): return 'skip' @@ -453,9 +429,6 @@ def hdf5_12(): def hdf5_13(): - if gdaltest.hdf5_drv is None: - return 'skip' - if not gdaltest.download_file('http://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A2016273115000.L2_LAC_OC.nc', 'A2016273115000.L2_LAC_OC.nc'): return 'skip' @@ -480,9 +453,6 @@ def hdf5_13(): def hdf5_14(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('data/complex.h5') sds_list = ds.GetMetadata('SUBDATASETS') @@ -513,9 +483,6 @@ def hdf5_14(): def hdf5_15(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/complex.h5"://f32') cs = ds.GetRasterBand(1).Checksum() @@ -530,9 +497,6 @@ def hdf5_15(): def hdf5_16(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/complex.h5"://f64') cs = ds.GetRasterBand(1).Checksum() @@ -547,9 +511,6 @@ def hdf5_16(): def hdf5_17(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/complex.h5"://f16') cs = ds.GetRasterBand(1).Checksum() @@ -562,9 +523,6 @@ def hdf5_17(): def hdf5_single_char_varname(): - if gdaltest.hdf5_drv is None: - return 'skip' - ds = gdal.Open('HDF5:"data/single_char_varname.h5"://e') if ds is None: return 'fail' @@ -573,10 +531,6 @@ def hdf5_single_char_varname(): def hdf5_virtual_file(): - - if gdaltest.hdf5_drv is None: - return 'skip' - hdf5_files = [ 'CSK_GEC.h5', 'vlstr_metadata.h5', @@ -594,45 +548,32 @@ def hdf5_virtual_file(): return 'success' -class TestHDF5(object): - def __init__(self, downloadURL, fileName, subdatasetname, checksum, download_size): - self.downloadURL = downloadURL - self.fileName = fileName - self.subdatasetname = subdatasetname - self.checksum = checksum - self.download_size = download_size - - def test(self): - if gdaltest.hdf5_drv is None: - return 'skip' - - if not gdaltest.download_file(self.downloadURL + '/' + self.fileName, self.fileName, self.download_size): - return 'skip' - - ds = gdal.Open('HDF5:"tmp/cache/' + self.fileName + '"://' + self.subdatasetname) - - if ds.GetRasterBand(1).Checksum() != self.checksum: - gdaltest.post_reason('Bad checksum. Expected %d, got %d' % (self.checksum, ds.GetRasterBand(1).Checksum())) - return 'fail' - - return 'success' - +# FIXME: This FTP server seems to have disappeared. Replace with something else? +hdf5_list = [ + ('ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf_files/hdf5/samples/convert', 'C1979091.h5', + 'HDF4_PALGROUP/HDF4_PALETTE_2', 7488, -1), + ('ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf_files/hdf5/samples/convert', 'C1979091.h5', + 'Raster_Image_#0', 3661, -1), + ('ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf_files/hdf5/geospatial/DEM', 'half_moon_bay.grid', + 'HDFEOS/GRIDS/DEMGRID/Data_Fields/Elevation', 30863, -1), +] -def hdf5_postcheck(): +@pytest.mark.parametrize( + 'downloadURL,fileName,subdatasetname,checksum,download_size', + hdf5_list, + ids=['HDF5:"' + item[1] + '"://' + item[2] for item in hdf5_list], +) +def test_hdf5(driver, downloadURL, fileName, subdatasetname, checksum, download_size): + if not gdaltest.download_file(downloadURL + '/' + fileName, fileName, download_size): + pytest.skip('no download') - if gdaltest.hdf5_drv is None: - return 'skip' + ds = gdal.Open('HDF5:"tmp/cache/' + fileName + '"://' + subdatasetname) - diff = len(gdaltest.get_opened_files()) - gdaltest.count_opened_files - if diff != 0: - gdaltest.post_reason('Leak of file handles: %d leaked' % diff) - return 'fail' + assert ds.GetRasterBand(1).Checksum() == checksum, 'Bad checksum. Expected %d, got %d' % (checksum, ds.GetRasterBand(1).Checksum()) - return 'success' gdaltest_list = [ - hdf5_1, hdf5_2, hdf5_3, hdf5_4, @@ -651,21 +592,8 @@ def hdf5_postcheck(): hdf5_17, hdf5_single_char_varname, hdf5_virtual_file, - hdf5_postcheck, ] -hdf5_list = [('ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf_files/hdf5/samples/convert', 'C1979091.h5', - 'HDF4_PALGROUP/HDF4_PALETTE_2', 7488, -1), - ('ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf_files/hdf5/samples/convert', 'C1979091.h5', - 'Raster_Image_#0', 3661, -1), - ('ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf_files/hdf5/geospatial/DEM', 'half_moon_bay.grid', - 'HDFEOS/GRIDS/DEMGRID/Data_Fields/Elevation', 30863, -1), - ] - -for item in hdf5_list: - ut = TestHDF5(item[0], item[1], item[2], item[3], item[4]) - gdaltest_list.append((ut.test, 'HDF5:"' + item[1] + '"://' + item[2])) - if __name__ == '__main__': diff --git a/autotest/gdrivers/l1b.py b/autotest/gdrivers/l1b.py index 6a80a525c2bd..988d0ddab31e 100755 --- a/autotest/gdrivers/l1b.py +++ b/autotest/gdrivers/l1b.py @@ -31,40 +31,49 @@ import os import sys -from osgeo import gdal +import pytest + +from osgeo import gdal import gdaltest ############################################################################### # -class TestL1B(object): - def __init__(self, downloadURL, fileName, checksum, download_size, gcpNumber): - self.downloadURL = downloadURL - self.fileName = fileName - self.checksum = checksum - self.download_size = download_size - self.gcpNumber = gcpNumber - - def test(self): - if not gdaltest.download_file(self.downloadURL + '/' + self.fileName, self.fileName, self.download_size): - return 'skip' - - ds = gdal.Open('tmp/cache/' + self.fileName) - - if ds.GetRasterBand(1).Checksum() != self.checksum: - gdaltest.post_reason('Bad checksum. Expected %d, got %d' % (self.checksum, ds.GetRasterBand(1).Checksum())) - return 'fail' - if len(ds.GetGCPs()) != self.gcpNumber: - gdaltest.post_reason('Bad GCP number. Expected %d, got %d' % (self.gcpNumber, len(ds.GetGCPs()))) - return 'fail' - return 'success' +l1b_list = [ + ('http://download.osgeo.org/gdal/data/l1b', 'n12gac8bit.l1b', 51754, -1, 1938), + ('http://download.osgeo.org/gdal/data/l1b', 'n12gac10bit.l1b', 46039, -1, 1887), + ('http://download.osgeo.org/gdal/data/l1b', 'n12gac10bit_ebcdic.l1b', 46039, -1, 1887), # 2848 + ('http://download.osgeo.org/gdal/data/l1b', 'n14gac16bit.l1b', 42286, -1, 2142), + ('http://download.osgeo.org/gdal/data/l1b', 'n15gac8bit.l1b', 55772, -1, 2091), + ('http://download.osgeo.org/gdal/data/l1b', 'n16gac10bit.l1b', 6749, -1, 2142), + ('http://download.osgeo.org/gdal/data/l1b', 'n17gac16bit.l1b', 61561, -1, 2040), + ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'frang.1b', 33700, 30000, 357), # 10 bit guess + ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'franh.1b', 56702, 100000, 255), # 10 bit guess + ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'calfirel.1b', 55071, 30000, 255), # 16 bit guess + ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'rapnzg.1b', 58084, 30000, 612), # 16 bit guess + ('http://www.sat.dundee.ac.uk/testdata/new_noaa/new_klm_format/', 'noaa18.n1b', 50229, 50000, 102), + ('http://www.sat.dundee.ac.uk/testdata/metop', 'noaa1b', 62411, 150000, 408) +] -############################################################################### -# + +@pytest.mark.parametrize( + 'downloadURL,fileName,checksum,download_size,gcpNumber', + l1b_list, + ids=[item[1] for item in l1b_list] +) +def test_l1b(downloadURL, fileName, checksum, download_size, gcpNumber): + if not gdaltest.download_file(downloadURL + '/' + fileName, fileName, download_size): + pytest.skip() + + ds = gdal.Open('tmp/cache/' + fileName) + + assert ds.GetRasterBand(1).Checksum() == checksum + + assert len(ds.GetGCPs()) == gcpNumber def l1b_geoloc(): @@ -295,34 +304,16 @@ def l1b_little_endian(): return 'success' -gdaltest_list = [] - -l1b_list = [('http://download.osgeo.org/gdal/data/l1b', 'n12gac8bit.l1b', 51754, -1, 1938), - ('http://download.osgeo.org/gdal/data/l1b', 'n12gac10bit.l1b', 46039, -1, 1887), - ('http://download.osgeo.org/gdal/data/l1b', 'n12gac10bit_ebcdic.l1b', 46039, -1, 1887), # 2848 - ('http://download.osgeo.org/gdal/data/l1b', 'n14gac16bit.l1b', 42286, -1, 2142), - ('http://download.osgeo.org/gdal/data/l1b', 'n15gac8bit.l1b', 55772, -1, 2091), - ('http://download.osgeo.org/gdal/data/l1b', 'n16gac10bit.l1b', 6749, -1, 2142), - ('http://download.osgeo.org/gdal/data/l1b', 'n17gac16bit.l1b', 61561, -1, 2040), - ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'frang.1b', 33700, 30000, 357), # 10 bit guess - ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'franh.1b', 56702, 100000, 255), # 10 bit guess - ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'calfirel.1b', 55071, 30000, 255), # 16 bit guess - ('http://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/podug/data/avhrr', 'rapnzg.1b', 58084, 30000, 612), # 16 bit guess - ('http://www.sat.dundee.ac.uk/testdata/new_noaa/new_klm_format/', 'noaa18.n1b', 50229, 50000, 102), - ('http://www.sat.dundee.ac.uk/testdata/metop', 'noaa1b', 62411, 150000, 408) - ] - -for item in l1b_list: - ut = TestL1B(item[0], item[1], item[2], item[3], item[4]) - gdaltest_list.append((ut.test, item[1])) - -gdaltest_list.append(l1b_geoloc) -gdaltest_list.append(l1b_solar_zenith_angles_before_noaa_15) -gdaltest_list.append(l1b_metadata_before_noaa_15) -gdaltest_list.append(l1b_angles_after_noaa_15) -gdaltest_list.append(l1b_clouds_after_noaa_15) -gdaltest_list.append(l1b_metadata_after_noaa_15) -gdaltest_list.append(l1b_little_endian) +gdaltest_list = [ + l1b_geoloc, + l1b_solar_zenith_angles_before_noaa_15, + l1b_metadata_before_noaa_15, + l1b_angles_after_noaa_15, + l1b_clouds_after_noaa_15, + l1b_metadata_after_noaa_15, + l1b_little_endian, +] + if __name__ == '__main__': diff --git a/autotest/gdrivers/xmp.py b/autotest/gdrivers/xmp.py index f0a7018150b3..8e956bc2c3a3 100755 --- a/autotest/gdrivers/xmp.py +++ b/autotest/gdrivers/xmp.py @@ -29,7 +29,7 @@ # DEALINGS IN THE SOFTWARE. ############################################################################### -import sys +import pytest from osgeo import gdal @@ -40,94 +40,72 @@ # -class TestXMPRead(object): - def __init__(self, drivername, filename, expect_xmp): - self.drivername = drivername - self.filename = filename - self.expect_xmp = expect_xmp - - def test(self): - drv = gdal.GetDriverByName(self.drivername) - if drv is None: - return 'skip' - - if self.drivername == 'PDF': - md = drv.GetMetadata() - if 'HAVE_POPPLER' not in md and 'HAVE_PODOFO' not in md: - return 'skip' - - # we set ECW to not resolve projection and datum strings to get 3.x behavior. - gdal.SetConfigOption("ECW_DO_NOT_RESOLVE_DATUM_PROJECTION", "YES") - - if self.filename.find('.jp2') >= 0: - gdaltest.deregister_all_jpeg2000_drivers_but(self.drivername) - - ret = 'success' - ds = gdal.Open(self.filename) - if ds is None: - # Old libwebp don't support VP8X containers - if self.filename == 'data/rgbsmall_with_xmp.webp': - ret = 'skip' - else: - gdaltest.post_reason('open failed') - ret = 'failure' +lst = [ + ["GTiff", "data/byte_with_xmp.tif", True], + ["GTiff", "data/byte.tif", False], + ["GIF", "data/byte_with_xmp.gif", True], + ["BIGGIF", "data/fakebig.gif", False], + ["JPEG", "data/byte_with_xmp.jpg", True], + ["JPEG", "data/rgbsmall_rgb.jpg", False], + ["PNG", "data/byte_with_xmp.png", True], + ["PNG", "data/test.png", False], + ["JP2ECW", "data/byte_with_xmp.jp2", True], + ["JP2ECW", "data/byte.jp2", False], + ["JP2MrSID", "data/byte_with_xmp.jp2", True], + ["JP2MrSID", "data/byte.jp2", False], + ["JPEG2000", "data/byte_with_xmp.jp2", True], + ["JPEG2000", "data/byte.jp2", False], + ["JP2OpenJPEG", "data/byte_with_xmp.jp2", True], + ["JP2OpenJPEG", "data/byte.jp2", False], + ["JP2KAK", "data/byte_with_xmp.jp2", True], + ["JP2KAK", "data/byte.jp2", False], + ["PDF", "data/adobe_style_geospatial_with_xmp.pdf", True], + ["PDF", "data/adobe_style_geospatial.pdf", False], + ["WEBP", "data/rgbsmall_with_xmp.webp", True], + ["WEBP", "data/rgbsmall.webp", False], +] + + +@pytest.mark.parametrize( + 'drivername,filename,expect_xmp', + lst, + ids=[ + "xmp_read_%s_%s" % (drivername, str(expect_xmp)) + for (drivername, filename, expect_xmp) in lst + ] +) +def test_xmp(drivername, filename, expect_xmp): + drv = gdal.GetDriverByName(drivername) + if drv is None: + pytest.skip() + + if drivername == 'PDF': + md = drv.GetMetadata() + if 'HAVE_POPPLER' not in md and 'HAVE_PODOFO' not in md: + pytest.skip() + + # we set ECW to not resolve projection and datum strings to get 3.x behavior. + gdal.SetConfigOption("ECW_DO_NOT_RESOLVE_DATUM_PROJECTION", "YES") + + if filename.find('.jp2') >= 0: + gdaltest.deregister_all_jpeg2000_drivers_but(drivername) + + try: + ds = gdal.Open(filename) + if filename == 'data/rgbsmall_with_xmp.webp': + if ds is None: + pytest.skip("Old libwebp don't support VP8X containers") else: - xmp_md = ds.GetMetadata('xml:XMP') - if ds.GetDriver().ShortName != self.drivername: - gdaltest.post_reason('opened with wrong driver') - print(ds.GetDriver().ShortName) - ret = 'failure' - elif self.expect_xmp and not xmp_md: - gdaltest.post_reason('did not find xml:XMP metadata') - ret = 'failure' - elif self.expect_xmp and 'xml:XMP' not in ds.GetMetadataDomainList(): - gdaltest.post_reason('did not find xml:XMP metadata domain') - ret = 'failure' - elif (not self.expect_xmp) and xmp_md: - gdaltest.post_reason('found unexpected xml:XMP metadata') - ret = 'failure' - ds = None + assert ds is not None, 'open failed' - if self.filename.find('.jp2') >= 0: - gdaltest.reregister_all_jpeg2000_drivers() + xmp_md = ds.GetMetadata('xml:XMP') + + assert ds.GetDriver().ShortName == drivername, 'opened with wrong driver' + assert not (expect_xmp and not xmp_md), 'did not find xml:XMP metadata' + assert not (expect_xmp and 'xml:XMP' not in ds.GetMetadataDomainList()), 'did not find xml:XMP metadata domain' + assert expect_xmp or not xmp_md, 'found unexpected xml:XMP metadata' - return ret - - -gdaltest_list = [] - -lst = [["GTiff", "data/byte_with_xmp.tif", True], - ["GTiff", "data/byte.tif", False], - ["GIF", "data/byte_with_xmp.gif", True], - ["BIGGIF", "data/fakebig.gif", False], - ["JPEG", "data/byte_with_xmp.jpg", True], - ["JPEG", "data/rgbsmall_rgb.jpg", False], - ["PNG", "data/byte_with_xmp.png", True], - ["PNG", "data/test.png", False], - ["JP2ECW", "data/byte_with_xmp.jp2", True], - ["JP2ECW", "data/byte.jp2", False], - ["JP2MrSID", "data/byte_with_xmp.jp2", True], - ["JP2MrSID", "data/byte.jp2", False], - ["JPEG2000", "data/byte_with_xmp.jp2", True], - ["JPEG2000", "data/byte.jp2", False], - ["JP2OpenJPEG", "data/byte_with_xmp.jp2", True], - ["JP2OpenJPEG", "data/byte.jp2", False], - ["JP2KAK", "data/byte_with_xmp.jp2", True], - ["JP2KAK", "data/byte.jp2", False], - ["PDF", "data/adobe_style_geospatial_with_xmp.pdf", True], - ["PDF", "data/adobe_style_geospatial.pdf", False], - ["WEBP", "data/rgbsmall_with_xmp.webp", True], - ["WEBP", "data/rgbsmall.webp", False], - ] - -for drivername, filename, expect_xmp in lst: - ut = TestXMPRead(drivername, filename, expect_xmp) - gdaltest_list.append((ut.test, "xmp_read_%s_%s" % (drivername, "true" if expect_xmp is True else "false"))) - -if __name__ == '__main__': - - gdaltest.setup_run('xmp') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + ds = None + finally: + if filename.find('.jp2') >= 0: + gdaltest.reregister_all_jpeg2000_drivers() diff --git a/autotest/gdrivers/xpm.py b/autotest/gdrivers/xpm.py index bc50e91be07d..05b288be4cfc 100755 --- a/autotest/gdrivers/xpm.py +++ b/autotest/gdrivers/xpm.py @@ -29,50 +29,38 @@ ############################################################################### import sys -from osgeo import gdal +import pytest + +from osgeo import gdal import gdaltest -############################################################################### -# -class TestXPM(object): - def __init__(self, downloadURL, fileName, checksum, download_size): - self.downloadURL = downloadURL - self.fileName = fileName - self.checksum = checksum - self.download_size = download_size +xpm_list = [('http://download.osgeo.org/gdal/data/xpm', 'utm.xpm', 44206, -1)] - def test(self): - if not gdaltest.download_file(self.downloadURL + '/' + self.fileName, self.fileName, self.download_size): - return 'skip' - ds = gdal.Open('tmp/cache/' + self.fileName) +@pytest.mark.parametrize( + 'downloadURL,fileName,checksum,download_size', + xpm_list, + ids=[item[1] for item in xpm_list], +) +def test_xpm(downloadURL, fileName, checksum, download_size): + if not gdaltest.download_file(downloadURL + '/' + fileName, fileName, download_size): + pytest.skip() - if ds.GetRasterBand(1).Checksum() != self.checksum: - gdaltest.post_reason('Bad checksum. Expected %d, got %d' % (self.checksum, ds.GetRasterBand(1).Checksum())) - return 'fail' + ds = gdal.Open('tmp/cache/' + fileName) - return 'success' + assert ds.GetRasterBand(1).Checksum() == checksum, 'Bad checksum. Expected %d, got %d' % (checksum, ds.GetRasterBand(1).Checksum()) def xpm_1(): - tst = gdaltest.GDALTest('XPM', 'byte.tif', 1, 4583) return tst.testCreateCopy(vsimem=1, check_minmax=False) -gdaltest_list = [] - -xpm_list = [('http://download.osgeo.org/gdal/data/xpm', 'utm.xpm', 44206, -1), - ] - -for item in xpm_list: - ut = TestXPM(item[0], item[1], item[2], item[3]) - gdaltest_list.append((ut.test, item[1])) +gdaltest_list = [xpm_1] -gdaltest_list.append(xpm_1) if __name__ == '__main__': From 9d6055e76a7c5144c72cca081655b570ba41c3e2 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Thu, 4 Oct 2018 08:50:53 +1300 Subject: [PATCH 121/488] Refactor leaked FD checks as pytest fixtures --- autotest/gdrivers/bag.py | 30 ++++++++++++++---------------- autotest/gdrivers/netcdf.py | 32 ++++++++++++-------------------- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index d0493710b682..72110d6db5b4 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -31,11 +31,24 @@ ############################################################################### import sys -from osgeo import gdal +import pytest + +from osgeo import gdal import gdaltest + +@pytest.fixture(autouse=True) +def check_no_file_leaks(): + num_files = len(gdaltest.get_opened_files()) + + yield + + diff = len(gdaltest.get_opened_files()) - num_files + assert diff == 0, 'Leak of file handles: %d leaked' % diff + + ############################################################################### # Test if BAG driver is present @@ -46,8 +59,6 @@ def bag_1(): if gdaltest.bag_drv is None: return 'skip' - gdaltest.count_opened_files = len(gdaltest.get_opened_files()) - return 'success' ############################################################################### @@ -896,18 +907,6 @@ def bag_write_south_up(): return 'success' -def bag_postcheck(): - - if gdaltest.bag_drv is None: - return 'skip' - - diff = len(gdaltest.get_opened_files()) - gdaltest.count_opened_files - if diff != 0: - gdaltest.post_reason('Leak of file handles: %d leaked' % diff) - return 'fail' - - return 'success' - gdaltest_list = [bag_1, bag_2, bag_3, @@ -920,7 +919,6 @@ def bag_postcheck(): bag_write_single_band, bag_write_two_bands, bag_write_south_up, - bag_postcheck, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index 9e2c842cd411..d8563e357bcb 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -40,6 +40,8 @@ from osgeo import osr +import pytest + import gdaltest import test_cli_utilities @@ -54,6 +56,16 @@ # Get netcdf version and test for supported files +@pytest.fixture(autouse=True) +def check_no_file_leaks(): + num_files = len(gdaltest.get_opened_files()) + + yield + + diff = len(gdaltest.get_opened_files()) - num_files + assert diff == 0, 'Leak of file handles: %d leaked' % diff + + def netcdf_setup(): gdaltest.netcdf_drv_version = 'unknown' @@ -97,8 +109,6 @@ def netcdf_setup(): ' has_nc2: ' + str(gdaltest.netcdf_drv_has_nc2) + ' has_nc4: ' + str(gdaltest.netcdf_drv_has_nc4)) - gdaltest.count_opened_files = len(gdaltest.get_opened_files()) - return 'success' ############################################################################### @@ -3337,19 +3347,6 @@ def netcdf_uffd(): return 'success' -def netcdf_postcheck(): - - if gdaltest.netcdf_drv is None: - return 'skip' - - diff = len(gdaltest.get_opened_files()) - gdaltest.count_opened_files - if diff != 0: - gdaltest.post_reason('Leak of file handles: %d leaked' % diff) - return 'fail' - - return 'success' - - ############################################################################### ############################################################################### @@ -3482,8 +3479,6 @@ def netcdf_postcheck(): gdaltest_list.append((ut.testCreate, item[0])) gdaltest_list.append((ut.testSetNoDataValue, item[0])) -gdaltest_list.append(netcdf_postcheck) - ############################################################################### # other tests @@ -3493,7 +3488,4 @@ def netcdf_postcheck(): gdaltest.run_tests(gdaltest_list) - # make sure we cleanup - gdaltest.clean_tmp() - sys.exit(gdaltest.summarize()) From b3c4596330ca425aa5a2539ebb863ab4b9cd6e80 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Thu, 4 Oct 2018 09:39:59 +1300 Subject: [PATCH 122/488] Add a marker for drivers in tests --- autotest/conftest.py | 21 +++++++++++++++++++++ autotest/gdrivers/bag.py | 20 +++++--------------- autotest/gdrivers/fits.py | 15 +++++++-------- autotest/gdrivers/hdf5.py | 9 ++------- autotest/pytest.ini | 3 +++ 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/autotest/conftest.py b/autotest/conftest.py index 8c885b42ae73..75eebfef102e 100644 --- a/autotest/conftest.py +++ b/autotest/conftest.py @@ -6,6 +6,8 @@ import pytest +import gdal + # Put the pymod dir on the path, so modules can `import gdaltest` sys.path.insert(0, os.path.join(os.path.dirname(__file__), "pymod")) @@ -34,3 +36,22 @@ def chdir_to_test_file(request): if sys.path and sys.path[0] == ".": sys.path.pop(0) os.chdir(old) + + +def pytest_collection_modifyitems(config, items): + # skip tests with @pytest.mark.require_driver(name) when the driver isn't available + skip = pytest.mark.skip("Driver not present") + import gdaltest + + drivers_checked = {} + for item in items: + for mark in item.iter_markers('require_driver'): + driver_name = mark.args[0] + if driver_name not in drivers_checked: + driver = gdal.GetDriverByName(driver_name) + drivers_checked[driver_name] = bool(driver) + if driver: + # Store the driver on gdaltest module so test functions can assume it's there. + setattr(gdaltest, '%s_drv' % driver_name.lower(), driver) + if not drivers_checked[driver_name]: + item.add_marker(skip) diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index 72110d6db5b4..583f5b38bab6 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -39,6 +39,9 @@ import gdaltest +pytestmark = pytest.mark.require_driver('BAG') + + @pytest.fixture(autouse=True) def check_no_file_leaks(): num_files = len(gdaltest.get_opened_files()) @@ -49,23 +52,11 @@ def check_no_file_leaks(): assert diff == 0, 'Leak of file handles: %d leaked' % diff -############################################################################### -# Test if BAG driver is present - - -def bag_1(): - - gdaltest.bag_drv = gdal.GetDriverByName('BAG') - if gdaltest.bag_drv is None: - return 'skip' - - return 'success' - ############################################################################### # Confirm various info on true_n_nominal 1.1 sample file. -def bag_2(): +def test_bag_2(): if gdaltest.bag_drv is None: return 'skip' @@ -907,8 +898,7 @@ def bag_write_south_up(): return 'success' -gdaltest_list = [bag_1, - bag_2, +gdaltest_list = [test_bag_2, bag_3, bag_vr_normal, bag_vr_list_supergrids, diff --git a/autotest/gdrivers/fits.py b/autotest/gdrivers/fits.py index 605e5506899d..2b33f76823d8 100755 --- a/autotest/gdrivers/fits.py +++ b/autotest/gdrivers/fits.py @@ -33,19 +33,16 @@ from osgeo import gdal -@pytest.fixture -def driver(): - driver = gdal.GetDriverByName('FITS') - if driver is None: - pytest.skip() - return driver +pytestmark = pytest.mark.require_driver('FITS') @pytest.mark.parametrize( 'filename', ['byte', 'int16', 'int32', 'float32', 'float64'] ) -def test_fits(driver, filename): +def test_fits(filename): + driver = gdal.GetDriverByName('FITS') + ds = gdal.Open('../gcore/data/' + filename + '.tif') driver.CreateCopy('tmp/' + filename + '.fits', ds, options=['PAGESIZE=2,2']) @@ -58,7 +55,9 @@ def test_fits(driver, filename): driver.Delete('tmp/' + filename + '.fits') -def fits_metadata(driver): +def fits_metadata(): + driver = gdal.GetDriverByName('FITS') + ds = gdal.Open('../gcore/data/byte.tif') ds2 = driver.CreateCopy('tmp/byte.fits', ds) md = {'TEST': 'test_value'} diff --git a/autotest/gdrivers/hdf5.py b/autotest/gdrivers/hdf5.py index eec1d07133eb..0b18b46ac952 100755 --- a/autotest/gdrivers/hdf5.py +++ b/autotest/gdrivers/hdf5.py @@ -45,12 +45,7 @@ # Test if HDF5 driver is present -@pytest.fixture -def driver(autouse=True, scope='module'): - driver = gdal.GetDriverByName('HDF5') - if driver is None: - pytest.skip('No HDF5 driver') - return driver +pytestmark = pytest.mark.require_driver('HDF5') @pytest.fixture(autouse=True) @@ -564,7 +559,7 @@ def hdf5_virtual_file(): hdf5_list, ids=['HDF5:"' + item[1] + '"://' + item[2] for item in hdf5_list], ) -def test_hdf5(driver, downloadURL, fileName, subdatasetname, checksum, download_size): +def test_hdf5(downloadURL, fileName, subdatasetname, checksum, download_size): if not gdaltest.download_file(downloadURL + '/' + fileName, fileName, download_size): pytest.skip('no download') diff --git a/autotest/pytest.ini b/autotest/pytest.ini index c25ef5fa7e75..68ff57b77059 100644 --- a/autotest/pytest.ini +++ b/autotest/pytest.ini @@ -1,3 +1,6 @@ [pytest] python_files = *.py testpaths = ogr gcore gdrivers osr alg gnm utilities pyscripts + +markers = + require_driver: Skip test(s) if driver isn't present From 0ad0018c36fa531f67320e8352508e65826c4e5f Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Thu, 4 Oct 2018 22:59:51 +1300 Subject: [PATCH 123/488] Fix skipif bug --- autotest/gdrivers/mrf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index 35dcc67f7e20..e15fa7385d13 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -79,11 +79,13 @@ def test_mrf(src_filename, chksum, chksum_after_reopening, options): if src_filename == '12bit_rose_extract.jpg': import jpeg jpeg.jpeg_1() - pytest.skipif(gdaltest.jpeg_version == '9b') + if gdaltest.jpeg_version == '9b': + pytest.skip() with gdaltest.error_handler(): ds = gdal.Open('data/' + src_filename) - pytest.skipif(ds is None) + if ds is None: + pytest.skip() ds = None ut = gdaltest.GDALTest('MRF', src_filename, 1, chksum, options=options, chksum_after_reopening=chksum_after_reopening) @@ -124,8 +126,6 @@ def mrf_zen_test(): result = 'fail' for f in glob.glob('tmp/masked.*'): gdal.Unlink(f) - if result != 'success': - return result return result From 75c0dc375faabbe7d27d9d9a0eb4a98bd41cf44f Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Thu, 4 Oct 2018 23:11:13 +1300 Subject: [PATCH 124/488] Use pytest in CI --- autotest/requirements.txt | 2 ++ .../travis/gcc52_stdcpp14_sanitize/script.sh | 26 +++++++++++-------- gdal/ci/travis/mingw_w64/before_install.sh | 16 +++++++----- gdal/ci/travis/mingw_w64/install.sh | 4 +-- gdal/ci/travis/mingw_w64/script.sh | 15 ++++++++++- gdal/ci/travis/osx/script.sh | 10 +++++-- gdal/ci/travis/python3/script.sh | 19 +++++++++----- gdal/ci/travis/trusty_32bit/before_install.sh | 1 + gdal/ci/travis/trusty_32bit/script.sh | 7 ++++- gdal/ci/travis/trusty_clang/script.sh | 18 +++++++++---- gdal/ci/travis/ubuntu_1604/before_install.sh | 12 ++++++--- gdal/ci/travis/ubuntu_1604/script.sh | 10 ++++--- gdal/ci/travis/ubuntu_1804/script.sh | 20 +++++++++----- 13 files changed, 110 insertions(+), 50 deletions(-) create mode 100644 autotest/requirements.txt diff --git a/autotest/requirements.txt b/autotest/requirements.txt new file mode 100644 index 000000000000..e2f6c9d29d3f --- /dev/null +++ b/autotest/requirements.txt @@ -0,0 +1,2 @@ +pytest>=3,<3.10 +pytest-sugar diff --git a/gdal/ci/travis/gcc52_stdcpp14_sanitize/script.sh b/gdal/ci/travis/gcc52_stdcpp14_sanitize/script.sh index 6261ee566cf4..e0671307622c 100755 --- a/gdal/ci/travis/gcc52_stdcpp14_sanitize/script.sh +++ b/gdal/ci/travis/gcc52_stdcpp14_sanitize/script.sh @@ -7,6 +7,7 @@ export LD_LIBRARY_PATH=$PWD/install-gcc-5.2.0/lib64 export PRELOAD=$PWD/install-gcc-5.2.0/lib64/libasan.so.2.0.0:$PWD/install-gcc-5.2.0/lib64/libubsan.so.0.0.0 #export PRELOAD=$PWD/install-gcc-5.2.0/lib64/libubsan.so.0.0.0 export ASAN_OPTIONS=allocator_may_return_null=1 +export PYTEST="pytest -v -p no:sugar --color=no" cd gdal @@ -33,24 +34,27 @@ cd ../autotest #wget http://download.osgeo.org/gdal/data/pgeo/PGeoTest.zip #unzip PGeoTest.zip #cd ../../.. -# Run ogr_fgdb.py in isolation from the rest -(cd ogr - mkdir disabled - mv ogr_fgdb.* disabled -) -# Run ogr_pgeo.py in isolation from the rest -(cd ogr && mv ogr_pgeo.* disabled) +# Don't run these +PYTESTARGS="--ignore ogr/ogr_fgdb.py --ignore ogr/ogr_pgeo.py" # Too old spatialite version -(cd ogr && mv ogr_sqlite.* disabled) -(cd gdrivers && mkdir disabled && mv rasterlite.* disabled) +PYTESTARGS="$PYTESTARGS --ignore ogr/ogr_sqlite.py --ignore gdrivers/rasterlite.py" + +# install test dependencies +# note: pip 9 is installed on the box, but it hits a strange error after upgrading setuptools. +# so we install a newer pip first. +sudo -H pip install -U pip +sudo -H pip install -U -r ./requirements.txt # Run all the Python autotests -SKIP_MEM_INTENSIVE_TEST=YES SKIP_VIRTUALMEM=YES LD_PRELOAD=$PRELOAD ASAN_OPTIONS=detect_leaks=0 GDALTEST_ASAN_OPTIONS=detect_leaks=1,print_suppressions=0,suppressions=$PWD/asan_suppressions.txt python run_all.py -run_as_external +SKIP_MEM_INTENSIVE_TEST=YES SKIP_VIRTUALMEM=YES LD_PRELOAD=$PRELOAD ASAN_OPTIONS=detect_leaks=0 \ + GDALTEST_ASAN_OPTIONS=detect_leaks=1,print_suppressions=0,suppressions=$PWD/asan_suppressions.txt \ + $PYTEST $PYTESTARGS + # A bit messy, but force testing with libspatialite 4.0dev (that has been patched a bit to remove any hard-coded SRS definition so it is very small) #cd ogr #wget http://s3.amazonaws.com/etc-data.koordinates.com/gdal-travisci/libspatialite4.0dev_ubuntu12.04-64bit_srs_stripped.tar.gz #tar xzf libspatialite4.0dev_ubuntu12.04-64bit_srs_stripped.tar.gz #ln -s install-libspatialite-4.0dev/lib/libspatialite.so.5.0.1 libspatialite.so.3 -#LD_PRELOAD=$PRELOAD LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD python ogr_sqlite.py +#LD_PRELOAD=$PRELOAD LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD $PYTEST ogr_sqlite.py #cd .. diff --git a/gdal/ci/travis/mingw_w64/before_install.sh b/gdal/ci/travis/mingw_w64/before_install.sh index 2deb734238b2..8134a1b1b02f 100755 --- a/gdal/ci/travis/mingw_w64/before_install.sh +++ b/gdal/ci/travis/mingw_w64/before_install.sh @@ -5,10 +5,12 @@ set -e cat /etc/apt/sources.list ls -al /etc/apt/sources.list.d sudo apt-get update -qq -sudo apt-get install ccache -sudo apt-get install binutils-mingw-w64-x86-64 -sudo apt-get install gcc-mingw-w64-x86-64 -sudo apt-get install g++-mingw-w64-x86-64 -sudo apt-get install g++-mingw-w64 -sudo apt-get install mingw-w64-tools -sudo apt-get install -y wine1.4-amd64 +sudo apt-get install -y \ + ccache \ + binutils-mingw-w64-x86-64 \ + gcc-mingw-w64-x86-64 \ + g++-mingw-w64-x86-64 \ + g++-mingw-w64 \ + mingw-w64-tools \ + wine1.4-amd64 \ + curl diff --git a/gdal/ci/travis/mingw_w64/install.sh b/gdal/ci/travis/mingw_w64/install.sh index 47f5a9395828..026c126db2ad 100755 --- a/gdal/ci/travis/mingw_w64/install.sh +++ b/gdal/ci/travis/mingw_w64/install.sh @@ -31,8 +31,8 @@ cd .. ln -sf $PWD/.libs/libgdal-20.dll $HOME/.wine/drive_c/windows ln -sf $PWD/../proj-4.9.2/src/.libs/libproj-9.dll $HOME/.wine/drive_c/windows # Python bindings -wget http://www.python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi -wine64 msiexec /i python-2.7.3.amd64.msi +wget https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64.msi +wine64 msiexec /i python-2.7.15.amd64.msi cd swig/python gendef $HOME/.wine/drive_c/Python27/python27.dll x86_64-w64-mingw32-dlltool --dllname $HOME/.wine/drive_c/Python27/python27.dll --input-def python27.def --output-lib $HOME/.wine/drive_c/Python27/libs/libpython27.a diff --git a/gdal/ci/travis/mingw_w64/script.sh b/gdal/ci/travis/mingw_w64/script.sh index 9758e3046297..d8a42e41d1b0 100755 --- a/gdal/ci/travis/mingw_w64/script.sh +++ b/gdal/ci/travis/mingw_w64/script.sh @@ -13,5 +13,18 @@ rm gcore/rfc30.py # For some reason this crashes in the matrix .travis.yml but not in standalone branch rm pyscripts/test_gdal2tiles.py +export PYTHON_DIR="$HOME/.wine/drive_c/Python27" + +# install test dependencies +curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +wine64 "$PYTHON_DIR/python.exe" get-pip.py +rm get-pip.py +wine64 "$PYTHON_DIR/Scripts/pip2.7.exe" install -U -r ./requirements.txt +export PYTEST="wine64 $PYTHON_DIR/Scripts/pytest.exe -v -p no:sugar --color=no" + + # Run all the Python autotests -GDAL_DATA=$PWD/../gdal/data PYTHONPATH=$PWD/../gdal/swig/python/build/lib.win-amd64-2.7 PATH=$PWD/../gdal:$PWD/../gdal/apps/.libs:$PWD:$PATH $HOME/.wine/drive_c/Python27/python.exe run_all.py +GDAL_DATA=$PWD/../gdal/data \ + PYTHONPATH=$PWD/../gdal/swig/python/build/lib.win-amd64-2.7 \ + PATH=$PWD/../gdal:$PWD/../gdal/apps/.libs:$PWD:$PATH \ + $PYTEST diff --git a/gdal/ci/travis/osx/script.sh b/gdal/ci/travis/osx/script.sh index 9f43d2014ef1..d18f90e9bd73 100755 --- a/gdal/ci/travis/osx/script.sh +++ b/gdal/ci/travis/osx/script.sh @@ -3,12 +3,18 @@ set -e export PYTHONPATH=$PWD/gdal/swig/python/build/lib.macosx-10.12-intel-2.7:$PWD/gdal/swig/python/build/lib.macosx-10.11-x86_64-2.7 +export PYTEST="pytest -v -p no:sugar --color=no" # CPP unit tests (cd autotest/cpp && GDAL_SKIP=JP2ECW make quick_test) +# install test dependencies +sudo -H pip install -U -r autotest/requirements.txt + # Run all the Python autotests +cd autotest +$PYTEST # For some reason, the tests crash at process exit -(cd autotest; python run_all.py 2>&1 | tee /tmp/log.txt || /bin/true) -tail /tmp/log.txt | grep "Failed: 0 (0 blew exceptions)" >/dev/null +# (cd autotest; $PYTEST 2>&1 | tee /tmp/log.txt || /bin/true) +# tail /tmp/log.txt | grep "Failed: 0 (0 blew exceptionss)" >/dev/null diff --git a/gdal/ci/travis/python3/script.sh b/gdal/ci/travis/python3/script.sh index 96585bb8c3f1..3d12b0ec5a45 100755 --- a/gdal/ci/travis/python3/script.sh +++ b/gdal/ci/travis/python3/script.sh @@ -31,20 +31,25 @@ cd ogr/tmp/cache/ wget http://download.osgeo.org/gdal/data/pgeo/PGeoTest.zip unzip PGeoTest.zip cd ../../.. + +# install test dependencies +curl -sSL 'https://bootstrap.pypa.io/get-pip.py' | sudo python3 +sudo -H pip3 install -U -r ./requirements.txt + +PYTEST="python3 $(which pytest) -v -p no:sugar --color=no" + # Run ogr_fgdb.py in isolation from the rest +$PYTEST ogr/ogr_fgdb.py +PYTESTARGS="--ignore ogr/ogr_fgdb.py" -(cd ogr && python3 ogr_fgdb.py) -(cd ogr && mkdir disabled && mv ogr_fgdb.* disabled) # Run ogr_pgeo.py in isolation from the rest # This crashes on Trusty since travis-ci upgraded their Trusty workers #python ogr_pgeo.py -(cd ogr && mv ogr_pgeo.* disabled) +PYTESTARGS="$PYTESTARGS --ignore ogr/ogr_pgeo.py" # Fails on test_validate_jp2_2 (erros not in expected order) -(cd gdrivers && mkdir disabled && mv test_validate_jp2.* disabled) +PYTESTARGS="$PYTESTARGS --ignore gdrivers/test_validate_jp2.py" # Run all the Python autotests -# For some reason, the tests crash at process exit -GDAL_SKIP="JP2ECW ECW" python3 run_all.py 2>&1 | tee /tmp/log.txt || /bin/true -tail /tmp/log.txt | grep "Failed: 0 (0 blew exceptions)" >/dev/null +GDAL_SKIP="JP2ECW ECW" $PYTEST $PYTESTARGS diff --git a/gdal/ci/travis/trusty_32bit/before_install.sh b/gdal/ci/travis/trusty_32bit/before_install.sh index 6768a39ecb2b..0ad4485f9f57 100755 --- a/gdal/ci/travis/trusty_32bit/before_install.sh +++ b/gdal/ci/travis/trusty_32bit/before_install.sh @@ -31,3 +31,4 @@ sudo i386 chroot "$chroot" apt-get install -y --force-yes python-numpy libpng12- sudo i386 chroot "$chroot" apt-get install -y make sudo i386 chroot "$chroot" apt-get install -y python-dev sudo i386 chroot "$chroot" apt-get install -y g++ +sudo i386 chroot "$chroot" apt-get install -y --force-yes curl diff --git a/gdal/ci/travis/trusty_32bit/script.sh b/gdal/ci/travis/trusty_32bit/script.sh index a9014fe5a39c..35d99a2d371c 100755 --- a/gdal/ci/travis/trusty_32bit/script.sh +++ b/gdal/ci/travis/trusty_32bit/script.sh @@ -4,6 +4,7 @@ set -e export chroot="$PWD"/buildroot.i386 export LC_ALL=en_US.utf8 +export PYTEST="pytest -v -p no:sugar --color=no" i386 chroot "$chroot" sh -c "cd $PWD/autotest/cpp && make quick_test" # Compile and test vsipreload @@ -17,8 +18,12 @@ i386 chroot "$chroot" sh -c "cd $PWD/autotest/cpp && make vsipreload.so" mv autotest/gcore/vsigs.py autotest/gcore/vsigs.py.disabled +# install pip and use it to install test dependencies +sudo i386 chroot "$chroot" sh -c "curl -sSL 'https://bootstrap.pypa.io/get-pip.py' | python" +sudo i386 chroot "$chroot" pip install -U -r "$PWD/autotest/requirements.txt" + # Run all the Python autotests -i386 chroot "$chroot" sh -c "cd $PWD/autotest && python run_all.py" +i386 chroot "$chroot" sh -c "cd $PWD/autotest && $PYTEST" # Run Shellcheck shellcheck -e SC2086,SC2046 $(find $PWD/gdal -name '*.sh' -a -not -name ltmain.sh) diff --git a/gdal/ci/travis/trusty_clang/script.sh b/gdal/ci/travis/trusty_clang/script.sh index e6378efaca89..20ff2a564bea 100755 --- a/gdal/ci/travis/trusty_clang/script.sh +++ b/gdal/ci/travis/trusty_clang/script.sh @@ -6,6 +6,7 @@ set -e # Run it in isolation export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH=$JAVA_HOME/jre/bin:$PATH +export PYTEST="pytest -v -p no:sugar --color=no" cd gdal # Perl unit tests @@ -34,13 +35,20 @@ cd ogr/tmp/cache/ wget http://download.osgeo.org/gdal/data/pgeo/PGeoTest.zip unzip PGeoTest.zip cd ../../.. -# Run ogr_fgdb.py in isolation from the rest + +# install test dependencies +sudo -H pip install -U -r ./requirements.txt + export PYTHONPATH=/usr/lib/python2.7/dist-packages -(cd ogr && python ogr_fgdb.py) -(cd ogr && mkdir disabled && mv ogr_fgdb.* disabled) + +# Run ogr_fgdb.py in isolation from the rest +$PYTEST ogr/ogr_fgdb.py +PYTESTARGS="--ignore ogr/ogr_fgdb.py" + # Run ogr_pgeo.py in isolation from the rest # This crashes on Trusty since travis-ci upgraded their Trusty workers #python ogr_pgeo.py -(cd ogr && mv ogr_pgeo.* disabled) +PYTESTARGS="$PYTESTARGS --ignore ogr/ogr_pgeo.py" + # Run all the Python autotests -GDAL_SKIP="JP2ECW ECW" python run_all.py +GDAL_SKIP="JP2ECW ECW" $PYTEST $PYTESTARGS diff --git a/gdal/ci/travis/ubuntu_1604/before_install.sh b/gdal/ci/travis/ubuntu_1604/before_install.sh index 4be2f75184bc..8673c063c453 100755 --- a/gdal/ci/travis/ubuntu_1604/before_install.sh +++ b/gdal/ci/travis/ubuntu_1604/before_install.sh @@ -55,9 +55,13 @@ tar xzf FileGDB_API_1_5_64gcc51.tar.gz sudo cp FileGDB_API-64gcc51/lib/* "$chroot/usr/lib" sudo chroot "$chroot" ldconfig -sudo chroot "$chroot" apt-get install -y pyflakes3 -chroot "$chroot" sh -c "cd $PWD && pyflakes3 autotest" -chroot "$chroot" sh -c "cd $PWD && pyflakes3 gdal/swig/python/scripts" -chroot "$chroot" sh -c "cd $PWD && pyflakes3 gdal/swig/python/samples" +sudo chroot "$chroot" sh -c "curl -sSL 'https://bootstrap.pypa.io/get-pip.py' | python" +sudo chroot "$chroot" pip install flake8 +# flake8 codes to just emulate pyflakes (http://flake8.pycqa.org/en/latest/user/error-codes.html) +FLAKE8="flake8 --select=F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F721,F722,F811,F812,F821,F822,F823,F831,F841,F901" + +chroot "$chroot" sh -c "cd $PWD && $FLAKE8 autotest" +chroot "$chroot" sh -c "cd $PWD && $FLAKE8 gdal/swig/python/scripts" +chroot "$chroot" sh -c "cd $PWD && $FLAKE8 gdal/swig/python/samples" sudo chroot "$chroot" apt-get install -y cppcheck bash diff --git a/gdal/ci/travis/ubuntu_1604/script.sh b/gdal/ci/travis/ubuntu_1604/script.sh index 2e34f04cbc17..7a6ed17900ad 100755 --- a/gdal/ci/travis/ubuntu_1604/script.sh +++ b/gdal/ci/travis/ubuntu_1604/script.sh @@ -4,17 +4,21 @@ set -e export chroot="$PWD"/xenial export LC_ALL=en_US.utf8 +export PYTEST="pytest -v -p no:sugar --color=no" chroot "$chroot" sh -c "cd $PWD/autotest/cpp && make quick_test" # Compile and test vsipreload chroot "$chroot" sh -c "cd $PWD/autotest/cpp && make vsipreload.so" + +sudo chroot "$chroot" pip install -U -r "$PWD/autotest/requirements.txt" + # Run all the Python autotests # Run ogr_fgdb test in isolation due to likely conflict with libxml2 -chroot "$chroot" sh -c "cd $PWD/autotest/ogr && python ogr_fgdb.py && cd ../../.." +chroot "$chroot" sh -c "cd $PWD/autotest/ogr && $PYTEST ogr_fgdb.py && cd ../../.." rm autotest/ogr/ogr_fgdb.py # for some reason connection to the DB requires sudo chroot -sudo chroot "$chroot" sh -c "cd $PWD/autotest/ogr && python ogr_mssqlspatial.py && cd ../../.." +sudo chroot "$chroot" sh -c "cd $PWD/autotest/ogr && $PYTEST ogr_mssqlspatial.py && cd ../../.." -chroot "$chroot" sh -c "cd $PWD/autotest && python run_all.py" \ No newline at end of file +chroot "$chroot" sh -c "cd $PWD/autotest && $PYTEST" \ No newline at end of file diff --git a/gdal/ci/travis/ubuntu_1804/script.sh b/gdal/ci/travis/ubuntu_1804/script.sh index aa962a4c283b..ec960477bcab 100755 --- a/gdal/ci/travis/ubuntu_1804/script.sh +++ b/gdal/ci/travis/ubuntu_1804/script.sh @@ -4,31 +4,37 @@ set -e export chroot="$PWD"/bionic export LC_ALL=en_US.utf8 +export PYTEST="pytest -v -p no:sugar --color=no" chroot "$chroot" sh -c "cd $PWD/autotest/cpp && make quick_test" # Compile and test vsipreload chroot "$chroot" sh -c "cd $PWD/autotest/cpp && make vsipreload.so" + +# install pip and use it to install test dependencies +sudo chroot "$chroot" sh -c "curl -sSL 'https://bootstrap.pypa.io/get-pip.py' | python" +sudo chroot "$chroot" pip install -U -r "$PWD/autotest/requirements.txt" + # Run all the Python autotests # Run ogr_fgdb test in isolation due to likely conflict with libxml2 -chroot "$chroot" sh -c "cd $PWD/autotest/ogr && python ogr_fgdb.py && cd ../../.." +chroot "$chroot" sh -c "cd $PWD/autotest/ogr && $PYTEST ogr_fgdb.py && cd ../../.." rm autotest/ogr/ogr_fgdb.py # MySQL 8 -chroot "$chroot" sh -c "cd $PWD/autotest/ogr && OGR_MYSQL_CONNECTION_STRING=mysql:test,user=root,password=passwd,port=33060,host=127.0.0.1 python ogr_mysql.py" +chroot "$chroot" sh -c "cd $PWD/autotest/ogr && OGR_MYSQL_CONNECTION_STRING=mysql:test,user=root,password=passwd,port=33060,host=127.0.0.1 $PYTEST ogr_mysql.py" # MariaDB 10.3.9 -chroot "$chroot" sh -c "cd $PWD/autotest/ogr && OGR_MYSQL_CONNECTION_STRING=mysql:test,user=root,password=passwd,port=33061,host=127.0.0.1 python ogr_mysql.py" +chroot "$chroot" sh -c "cd $PWD/autotest/ogr && OGR_MYSQL_CONNECTION_STRING=mysql:test,user=root,password=passwd,port=33061,host=127.0.0.1 $PYTEST ogr_mysql.py" # PostGIS tests -chroot "$chroot" sh -c "cd $PWD/autotest/ogr && OGR_PG_CONNECTION_STRING='host=127.0.0.1 port=25432 dbname=autotest user=docker password=docker' python ogr_pg.py" -chroot "$chroot" sh -c "cd $PWD/autotest/gdrivers && PGHOST=127.0.0.1 PGPORT=25432 PGUSER=docker PGPASSWORD=docker python postgisraster.py" +chroot "$chroot" sh -c "cd $PWD/autotest/ogr && OGR_PG_CONNECTION_STRING='host=127.0.0.1 port=25432 dbname=autotest user=docker password=docker' $PYTEST ogr_pg.py" +chroot "$chroot" sh -c "cd $PWD/autotest/gdrivers && PGHOST=127.0.0.1 PGPORT=25432 PGUSER=docker PGPASSWORD=docker $PYTEST postgisraster.py" # for some reason connection to the DB requires sudo chroot # WARNING: unfortunately this doesn't even work from the ubuntu 18.04 chroot, but it # does from the ubuntu 16.04 one -sudo chroot "$chroot" sh -c "cd $PWD/autotest/ogr && python ogr_mssqlspatial.py && cd ../../.." +sudo chroot "$chroot" sh -c "cd $PWD/autotest/ogr && $PYTEST ogr_mssqlspatial.py && cd ../../.." # Fails with ERROR 1: OGDI DataSource Open Failed: Could not find the dynamic library "vrf" rm autotest/ogr/ogr_ogdi.py -chroot "$chroot" sh -c "cd $PWD/autotest && python run_all.py" \ No newline at end of file +chroot "$chroot" sh -c "cd $PWD/autotest && $PYTEST" \ No newline at end of file From 1232bb6f7f57eb60440ae41648c96f1585d1d81a Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Fri, 5 Oct 2018 15:49:32 +1300 Subject: [PATCH 125/488] Remove double-parenthesized things in gdaltest_list.append calls Pointless, confuses the auto refactoring code --- autotest/gcore/hfa_read.py | 2 +- autotest/gcore/tiff_read.py | 250 +++++++++++++++--------------- autotest/gdrivers/jpeg_profile.py | 6 +- autotest/gdrivers/png_profile.py | 10 +- autotest/gdrivers/tiff_profile.py | 14 +- 5 files changed, 141 insertions(+), 141 deletions(-) diff --git a/autotest/gcore/hfa_read.py b/autotest/gcore/hfa_read.py index d904e5da6b27..20ab0109a41d 100755 --- a/autotest/gcore/hfa_read.py +++ b/autotest/gcore/hfa_read.py @@ -69,7 +69,7 @@ def hfa_read_completedefn_recursion(): gdaltest_list.append((ut.testOpen, item[0])) -gdaltest_list.append((hfa_read_completedefn_recursion)) +gdaltest_list.append(hfa_read_completedefn_recursion) if __name__ == '__main__': diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index 9312e50a9c62..82eb4024b937 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -3860,131 +3860,131 @@ def tiff_read_overview_of_external_mask(): print('GTiff tests skipped') sys.exit() gdaltest_list.append((ut.testOpen, item[0])) -gdaltest_list.append((tiff_read_off)) -gdaltest_list.append((tiff_check_alpha)) -gdaltest_list.append((tiff_read_cmyk_rgba)) -gdaltest_list.append((tiff_read_cmyk_raw)) -gdaltest_list.append((tiff_read_ojpeg)) -gdaltest_list.append((tiff_read_gzip)) -gdaltest_list.append((tiff_read_zip_1)) -gdaltest_list.append((tiff_read_zip_2)) -gdaltest_list.append((tiff_read_zip_3)) -gdaltest_list.append((tiff_read_zip_4)) -gdaltest_list.append((tiff_read_zip_5)) -gdaltest_list.append((tiff_read_tar_1)) -gdaltest_list.append((tiff_read_tar_2)) -gdaltest_list.append((tiff_read_tgz_1)) -gdaltest_list.append((tiff_read_tgz_2)) -gdaltest_list.append((tiff_grads)) -gdaltest_list.append((tiff_citation)) -gdaltest_list.append((tiff_linearparmunits)) -gdaltest_list.append((tiff_linearparmunits2)) -gdaltest_list.append((tiff_g4_split)) -gdaltest_list.append((tiff_multi_images)) -gdaltest_list.append((tiff_vsimem)) -gdaltest_list.append((tiff_vsizip_and_mem)) -gdaltest_list.append((tiff_ProjectedCSTypeGeoKey_only)) -gdaltest_list.append((tiff_GTModelTypeGeoKey_only)) -gdaltest_list.append((tiff_12bitjpeg)) -gdaltest_list.append((tiff_read_stats_from_pam)) -gdaltest_list.append((tiff_read_from_tab)) -gdaltest_list.append((tiff_read_pixelispoint)) -gdaltest_list.append((tiff_read_geomatrix)) -gdaltest_list.append((tiff_read_corrupted_gtiff)) -gdaltest_list.append((tiff_read_tag_without_null_byte)) -gdaltest_list.append((tiff_read_buggy_packbits)) -gdaltest_list.append((tiff_read_rpc_txt)) -gdaltest_list.append((tiff_read_rpc_tif)) -gdaltest_list.append((tiff_small)) -gdaltest_list.append((tiff_dos_strip_chop)) -gdaltest_list.append((tiff_read_exif_and_gps)) -gdaltest_list.append((tiff_jpeg_rgba_pixel_interleaved)) -gdaltest_list.append((tiff_jpeg_rgba_band_interleaved)) -gdaltest_list.append((tiff_read_huge4GB)) -gdaltest_list.append((tiff_read_bigtiff)) -gdaltest_list.append((tiff_read_tiff_metadata)) -gdaltest_list.append((tiff_read_irregular_tile_size_jpeg_in_tiff)) -gdaltest_list.append((tiff_direct_and_virtual_mem_io)) -gdaltest_list.append((tiff_read_empty_nodata_tag)) -gdaltest_list.append((tiff_read_strace_check)) -gdaltest_list.append((tiff_read_readdir_limit_on_open)) -gdaltest_list.append((tiff_read_minisblack_as_rgba)) -gdaltest_list.append((tiff_read_colortable_as_rgba)) -gdaltest_list.append((tiff_read_logl_as_rgba)) -gdaltest_list.append((tiff_read_strip_separate_as_rgba)) -gdaltest_list.append((tiff_read_tiled_separate_as_rgba)) -gdaltest_list.append((tiff_read_scanline_more_than_2GB)) -gdaltest_list.append((tiff_read_wrong_number_extrasamples)) -gdaltest_list.append((tiff_read_one_strip_no_bytecount)) - -gdaltest_list.append((tiff_read_md1)) -gdaltest_list.append((tiff_read_md2)) -gdaltest_list.append((tiff_read_md3)) -gdaltest_list.append((tiff_read_md4)) -gdaltest_list.append((tiff_read_md5)) -gdaltest_list.append((tiff_read_md6)) -gdaltest_list.append((tiff_read_md7)) -gdaltest_list.append((tiff_read_md8)) -gdaltest_list.append((tiff_read_md9)) -gdaltest_list.append((tiff_read_md10)) -gdaltest_list.append((tiff_read_md11)) -gdaltest_list.append((tiff_read_md12)) - -gdaltest_list.append((tiff_read_nogeoref)) -gdaltest_list.append((tiff_read_inconsistent_georef)) -gdaltest_list.append((tiff_read_gcp_internal_and_auxxml)) - -gdaltest_list.append((tiff_read_aux)) - -gdaltest_list.append((tiff_read_one_band_from_two_bands)) - -gdaltest_list.append((tiff_read_jpeg_cloud_optimized)) -gdaltest_list.append((tiff_read_corrupted_jpeg_cloud_optimized)) - -gdaltest_list.append((tiff_read_ycbcr_lzw)) -gdaltest_list.append((tiff_read_ycbcr_int12)) - -gdaltest_list.append((tiff_read_unit_from_srs)) -gdaltest_list.append((tiff_read_arcgis93_geodataxform_gcp)) -gdaltest_list.append((tiff_read_block_width_above_32bit)) -gdaltest_list.append((tiff_read_image_width_above_32bit)) -gdaltest_list.append((tiff_read_second_image_width_above_32bit)) -gdaltest_list.append((tiff_read_minimum_tiff_tags_no_warning)) -gdaltest_list.append((tiff_read_minimum_tiff_tags_with_warning)) -gdaltest_list.append((tiff_read_unknown_compression)) -gdaltest_list.append((tiff_read_leak_ZIPSetupDecode)) -gdaltest_list.append((tiff_read_excessive_memory_TIFFFillStrip)) -gdaltest_list.append((tiff_read_excessive_memory_TIFFFillStrip2)) -gdaltest_list.append((tiff_read_excessive_memory_TIFFFillTile)) -gdaltest_list.append((tiff_read_big_strip)) -gdaltest_list.append((tiff_read_big_strip_chunky_way)) -gdaltest_list.append((tiff_read_big_tile)) -gdaltest_list.append((tiff_read_huge_tile)) -gdaltest_list.append((tiff_read_huge_number_strips)) -gdaltest_list.append((tiff_read_huge_implied_number_strips)) -gdaltest_list.append((tiff_read_many_blocks)) -gdaltest_list.append((tiff_read_many_blocks_truncated)) -gdaltest_list.append((tiff_read_uint33)) -gdaltest_list.append((tiff_read_corrupted_deflate_singlestrip)) -gdaltest_list.append((tiff_read_packbits_not_enough_data)) -gdaltest_list.append((tiff_read_toomanyblocks)) -gdaltest_list.append((tiff_read_toomanyblocks_separate)) -gdaltest_list.append((tiff_read_size_of_stripbytecount_lower_than_stripcount)) -gdaltest_list.append((tiff_read_stripoffset_types)) -gdaltest_list.append((tiff_read_progressive_jpeg_denial_of_service)) -gdaltest_list.append((tiff_read_old_style_lzw)) -gdaltest_list.append((tiff_read_mmap_interface)) -gdaltest_list.append((tiff_read_jpeg_too_big_last_stripe)) -gdaltest_list.append((tiff_read_negative_scaley)) -gdaltest_list.append((tiff_read_zstd)) -gdaltest_list.append((tiff_read_zstd_corrupted)) -gdaltest_list.append((tiff_read_zstd_corrupted2)) -gdaltest_list.append((tiff_read_1bit_2bands)) -gdaltest_list.append((tiff_read_lerc)) -gdaltest_list.append((tiff_read_overview_of_external_mask)) - -gdaltest_list.append((tiff_read_online_1)) -gdaltest_list.append((tiff_read_online_2)) +gdaltest_list.append(tiff_read_off) +gdaltest_list.append(tiff_check_alpha) +gdaltest_list.append(tiff_read_cmyk_rgba) +gdaltest_list.append(tiff_read_cmyk_raw) +gdaltest_list.append(tiff_read_ojpeg) +gdaltest_list.append(tiff_read_gzip) +gdaltest_list.append(tiff_read_zip_1) +gdaltest_list.append(tiff_read_zip_2) +gdaltest_list.append(tiff_read_zip_3) +gdaltest_list.append(tiff_read_zip_4) +gdaltest_list.append(tiff_read_zip_5) +gdaltest_list.append(tiff_read_tar_1) +gdaltest_list.append(tiff_read_tar_2) +gdaltest_list.append(tiff_read_tgz_1) +gdaltest_list.append(tiff_read_tgz_2) +gdaltest_list.append(tiff_grads) +gdaltest_list.append(tiff_citation) +gdaltest_list.append(tiff_linearparmunits) +gdaltest_list.append(tiff_linearparmunits2) +gdaltest_list.append(tiff_g4_split) +gdaltest_list.append(tiff_multi_images) +gdaltest_list.append(tiff_vsimem) +gdaltest_list.append(tiff_vsizip_and_mem) +gdaltest_list.append(tiff_ProjectedCSTypeGeoKey_only) +gdaltest_list.append(tiff_GTModelTypeGeoKey_only) +gdaltest_list.append(tiff_12bitjpeg) +gdaltest_list.append(tiff_read_stats_from_pam) +gdaltest_list.append(tiff_read_from_tab) +gdaltest_list.append(tiff_read_pixelispoint) +gdaltest_list.append(tiff_read_geomatrix) +gdaltest_list.append(tiff_read_corrupted_gtiff) +gdaltest_list.append(tiff_read_tag_without_null_byte) +gdaltest_list.append(tiff_read_buggy_packbits) +gdaltest_list.append(tiff_read_rpc_txt) +gdaltest_list.append(tiff_read_rpc_tif) +gdaltest_list.append(tiff_small) +gdaltest_list.append(tiff_dos_strip_chop) +gdaltest_list.append(tiff_read_exif_and_gps) +gdaltest_list.append(tiff_jpeg_rgba_pixel_interleaved) +gdaltest_list.append(tiff_jpeg_rgba_band_interleaved) +gdaltest_list.append(tiff_read_huge4GB) +gdaltest_list.append(tiff_read_bigtiff) +gdaltest_list.append(tiff_read_tiff_metadata) +gdaltest_list.append(tiff_read_irregular_tile_size_jpeg_in_tiff) +gdaltest_list.append(tiff_direct_and_virtual_mem_io) +gdaltest_list.append(tiff_read_empty_nodata_tag) +gdaltest_list.append(tiff_read_strace_check) +gdaltest_list.append(tiff_read_readdir_limit_on_open) +gdaltest_list.append(tiff_read_minisblack_as_rgba) +gdaltest_list.append(tiff_read_colortable_as_rgba) +gdaltest_list.append(tiff_read_logl_as_rgba) +gdaltest_list.append(tiff_read_strip_separate_as_rgba) +gdaltest_list.append(tiff_read_tiled_separate_as_rgba) +gdaltest_list.append(tiff_read_scanline_more_than_2GB) +gdaltest_list.append(tiff_read_wrong_number_extrasamples) +gdaltest_list.append(tiff_read_one_strip_no_bytecount) + +gdaltest_list.append(tiff_read_md1) +gdaltest_list.append(tiff_read_md2) +gdaltest_list.append(tiff_read_md3) +gdaltest_list.append(tiff_read_md4) +gdaltest_list.append(tiff_read_md5) +gdaltest_list.append(tiff_read_md6) +gdaltest_list.append(tiff_read_md7) +gdaltest_list.append(tiff_read_md8) +gdaltest_list.append(tiff_read_md9) +gdaltest_list.append(tiff_read_md10) +gdaltest_list.append(tiff_read_md11) +gdaltest_list.append(tiff_read_md12) + +gdaltest_list.append(tiff_read_nogeoref) +gdaltest_list.append(tiff_read_inconsistent_georef) +gdaltest_list.append(tiff_read_gcp_internal_and_auxxml) + +gdaltest_list.append(tiff_read_aux) + +gdaltest_list.append(tiff_read_one_band_from_two_bands) + +gdaltest_list.append(tiff_read_jpeg_cloud_optimized) +gdaltest_list.append(tiff_read_corrupted_jpeg_cloud_optimized) + +gdaltest_list.append(tiff_read_ycbcr_lzw) +gdaltest_list.append(tiff_read_ycbcr_int12) + +gdaltest_list.append(tiff_read_unit_from_srs) +gdaltest_list.append(tiff_read_arcgis93_geodataxform_gcp) +gdaltest_list.append(tiff_read_block_width_above_32bit) +gdaltest_list.append(tiff_read_image_width_above_32bit) +gdaltest_list.append(tiff_read_second_image_width_above_32bit) +gdaltest_list.append(tiff_read_minimum_tiff_tags_no_warning) +gdaltest_list.append(tiff_read_minimum_tiff_tags_with_warning) +gdaltest_list.append(tiff_read_unknown_compression) +gdaltest_list.append(tiff_read_leak_ZIPSetupDecode) +gdaltest_list.append(tiff_read_excessive_memory_TIFFFillStrip) +gdaltest_list.append(tiff_read_excessive_memory_TIFFFillStrip2) +gdaltest_list.append(tiff_read_excessive_memory_TIFFFillTile) +gdaltest_list.append(tiff_read_big_strip) +gdaltest_list.append(tiff_read_big_strip_chunky_way) +gdaltest_list.append(tiff_read_big_tile) +gdaltest_list.append(tiff_read_huge_tile) +gdaltest_list.append(tiff_read_huge_number_strips) +gdaltest_list.append(tiff_read_huge_implied_number_strips) +gdaltest_list.append(tiff_read_many_blocks) +gdaltest_list.append(tiff_read_many_blocks_truncated) +gdaltest_list.append(tiff_read_uint33) +gdaltest_list.append(tiff_read_corrupted_deflate_singlestrip) +gdaltest_list.append(tiff_read_packbits_not_enough_data) +gdaltest_list.append(tiff_read_toomanyblocks) +gdaltest_list.append(tiff_read_toomanyblocks_separate) +gdaltest_list.append(tiff_read_size_of_stripbytecount_lower_than_stripcount) +gdaltest_list.append(tiff_read_stripoffset_types) +gdaltest_list.append(tiff_read_progressive_jpeg_denial_of_service) +gdaltest_list.append(tiff_read_old_style_lzw) +gdaltest_list.append(tiff_read_mmap_interface) +gdaltest_list.append(tiff_read_jpeg_too_big_last_stripe) +gdaltest_list.append(tiff_read_negative_scaley) +gdaltest_list.append(tiff_read_zstd) +gdaltest_list.append(tiff_read_zstd_corrupted) +gdaltest_list.append(tiff_read_zstd_corrupted2) +gdaltest_list.append(tiff_read_1bit_2bands) +gdaltest_list.append(tiff_read_lerc) +gdaltest_list.append(tiff_read_overview_of_external_mask) + +gdaltest_list.append(tiff_read_online_1) +gdaltest_list.append(tiff_read_online_2) gdaltest_list.append((tiff_read_webp)) gdaltest_list.append((tiff_read_webp_huge_single_strip)) diff --git a/autotest/gdrivers/jpeg_profile.py b/autotest/gdrivers/jpeg_profile.py index 8a75bb843ff2..13fe6982d721 100755 --- a/autotest/gdrivers/jpeg_profile.py +++ b/autotest/gdrivers/jpeg_profile.py @@ -215,9 +215,9 @@ def jpeg_copy_icc_64K(): ############################################################################################### -gdaltest_list.append((jpeg_copy_icc)) -gdaltest_list.append((jpeg_copy_options_icc)) -gdaltest_list.append((jpeg_copy_icc_64K)) +gdaltest_list.append(jpeg_copy_icc) +gdaltest_list.append(jpeg_copy_options_icc) +gdaltest_list.append(jpeg_copy_icc_64K) if __name__ == '__main__': diff --git a/autotest/gdrivers/png_profile.py b/autotest/gdrivers/png_profile.py index 6ec7dd3a9a2d..30b64709e948 100755 --- a/autotest/gdrivers/png_profile.py +++ b/autotest/gdrivers/png_profile.py @@ -365,11 +365,11 @@ def png_sRGB(): ############################################################################ -gdaltest_list.append((png_copy_icc)) -gdaltest_list.append((png_copy_options_icc)) -gdaltest_list.append((png_copy_options_colorimetric_data)) -gdaltest_list.append((png_copy_colorimetric_data)) -gdaltest_list.append((png_sRGB)) +gdaltest_list.append(png_copy_icc) +gdaltest_list.append(png_copy_options_icc) +gdaltest_list.append(png_copy_options_colorimetric_data) +gdaltest_list.append(png_copy_colorimetric_data) +gdaltest_list.append(png_sRGB) if __name__ == '__main__': diff --git a/autotest/gdrivers/tiff_profile.py b/autotest/gdrivers/tiff_profile.py index 2e41363e960f..5ec39e65ee60 100755 --- a/autotest/gdrivers/tiff_profile.py +++ b/autotest/gdrivers/tiff_profile.py @@ -519,13 +519,13 @@ def tiff_update_colorimetric(): ############################################################################ -gdaltest_list.append((tiff_write_icc)) -gdaltest_list.append((tiff_copy_icc)) -gdaltest_list.append((tiff_copy_options_icc)) -gdaltest_list.append((tiff_copy_options_colorimetric_data)) -gdaltest_list.append((tiff_copy_colorimetric_data)) -gdaltest_list.append((tiff_update_icc)) -gdaltest_list.append((tiff_update_colorimetric)) +gdaltest_list.append(tiff_write_icc) +gdaltest_list.append(tiff_copy_icc) +gdaltest_list.append(tiff_copy_options_icc) +gdaltest_list.append(tiff_copy_options_colorimetric_data) +gdaltest_list.append(tiff_copy_colorimetric_data) +gdaltest_list.append(tiff_update_icc) +gdaltest_list.append(tiff_update_colorimetric) if __name__ == '__main__': From 9b42234b08ad21614d1d77443d3616271f7f2032 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Fri, 5 Oct 2018 21:37:13 +1300 Subject: [PATCH 126/488] Use pytest parametrize for dynamically generated tests --- autotest/gcore/aaigrid_read.py | 34 +++--- autotest/gcore/aaigrid_write.py | 41 +++---- autotest/gcore/bmp_read.py | 27 +++-- autotest/gcore/bmp_write.py | 36 ++++-- autotest/gcore/envi_read.py | 40 ++++--- autotest/gcore/gtiff_write.py | 75 ++++++------ autotest/gcore/hdf4_read.py | 52 ++++---- autotest/gcore/hdf4_write.py | 77 +++++------- autotest/gcore/hfa_read.py | 39 +++--- autotest/gcore/hfa_write.py | 117 +++++++++++------- autotest/gcore/pnm_read.py | 35 +++--- autotest/gcore/pnm_write.py | 41 ++++--- autotest/gcore/tiff_ovr.py | 205 ++++++++++++-------------------- autotest/gcore/tiff_read.py | 74 +++++++----- autotest/gcore/vrt_read.py | 127 +++++++++++--------- autotest/gdrivers/gta.py | 49 ++++---- autotest/gdrivers/netcdf.py | 58 +++++---- autotest/ogr/ogr_gml_geom.py | 53 ++++----- autotest/ogr/ogr_wkbwkt_geom.py | 124 ++++++++++--------- autotest/osr/osr_ct_proj.py | 197 ++++++++++++++---------------- autotest/osr/osr_metacrs.py | 128 +++++++++----------- 21 files changed, 802 insertions(+), 827 deletions(-) diff --git a/autotest/gcore/aaigrid_read.py b/autotest/gcore/aaigrid_read.py index cda5cd771321..fe3adea4a01a 100755 --- a/autotest/gcore/aaigrid_read.py +++ b/autotest/gcore/aaigrid_read.py @@ -25,30 +25,24 @@ # Boston, MA 02111-1307, USA. ############################################################################### -import sys - +import pytest import gdaltest ############################################################################### # When imported build a list of units based on the files available. -gdaltest_list = [] - init_list = [ - ('byte.tif.grd', 1, 4672, None)] - -for item in init_list: - ut = gdaltest.GDALTest('AAIGrid', item[0], item[1], item[2]) - if ut is None: - print('AAIGrid tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) - -if __name__ == '__main__': - - gdaltest.setup_run('aaigrid_read') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + ('byte.tif.grd', 4672), +] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('AAIGrid') +def test_aaigrid_open(filename, checksum): + ut = gdaltest.GDALTest('AAIGrid', filename, 1, checksum) + ut.testOpen() diff --git a/autotest/gcore/aaigrid_write.py b/autotest/gcore/aaigrid_write.py index ad78630a7a0d..5a3b784cb83b 100755 --- a/autotest/gcore/aaigrid_write.py +++ b/autotest/gcore/aaigrid_write.py @@ -26,34 +26,27 @@ # Boston, MA 02111-1307, USA. ############################################################################### -import sys - +import pytest import gdaltest ############################################################################### # When imported build a list of units based on the files available. -gdaltest_list = [] - init_list = [ - ('byte.tif', 1, 4672, None), - ('int16.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None), - ('float32.tif', 1, 4672, None), - ('utmsmall.tif', 1, 50054, None)] - -for item in init_list: - ut = gdaltest.GDALTest('AAIGrid', item[0], item[1], item[2]) - if ut is None: - print('AAIGrid tests skipped') - sys.exit() - gdaltest_list.append((ut.testCreateCopy, item[0])) - -if __name__ == '__main__': - - gdaltest.setup_run('aaigrid_write') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + ('byte.tif', 4672), + ('int16.tif', 4672), + ('uint16.tif', 4672), + ('float32.tif', 4672), + ('utmsmall.tif', 50054)] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('AAIGrid') +def test_aaigrid_create(filename, checksum): + ut = gdaltest.GDALTest('AAIGrid', filename, 1, checksum) + ut.testCreateCopy() diff --git a/autotest/gcore/bmp_read.py b/autotest/gcore/bmp_read.py index 074b9ce9397e..da95e519a692 100755 --- a/autotest/gcore/bmp_read.py +++ b/autotest/gcore/bmp_read.py @@ -28,6 +28,7 @@ import sys +import pytest import gdaltest @@ -37,10 +38,21 @@ gdaltest_list = [] init_list = [ - ('1bit.bmp', 1, 200, None), - ('4bit_pal.bmp', 1, 2587, None), - ('8bit_pal.bmp', 1, 4672, None), - ('byte_rle8.bmp', 1, 4672, None)] + ('1bit.bmp', 200), + ('4bit_pal.bmp', 2587), + ('8bit_pal.bmp', 4672), + ('byte_rle8.bmp', 4672)] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('BMP') +def test_bmp_open(filename, checksum): + ut = gdaltest.GDALTest('BMP', filename, 1, checksum) + ut.testOpen() def bmp_online_1(): @@ -65,13 +77,6 @@ def bmp_online_2(): return tst.testOpen() -for item in init_list: - ut = gdaltest.GDALTest('BMP', item[0], item[1], item[2]) - if ut is None: - print('BMP tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) - gdaltest_list.append(bmp_online_1) gdaltest_list.append(bmp_online_2) diff --git a/autotest/gcore/bmp_write.py b/autotest/gcore/bmp_write.py index b2d842d29ec7..35da731b5319 100755 --- a/autotest/gcore/bmp_write.py +++ b/autotest/gcore/bmp_write.py @@ -29,6 +29,7 @@ import sys +import pytest import gdaltest @@ -48,20 +49,29 @@ def bmp_vsimem(): gdaltest_list = [bmp_vsimem] + init_list = [ - ('byte.tif', 1, 4672, None), - ('utmsmall.tif', 1, 50054, None), - ('8bit_pal.bmp', 1, 4672, None), ] - -for item in init_list: - ut = gdaltest.GDALTest('BMP', item[0], item[1], item[2]) - if ut is None: - print('BMP tests skipped') - sys.exit() - gdaltest_list.append((ut.testCreateCopy, item[0])) - gdaltest_list.append((ut.testCreate, item[0])) - -gdaltest_list.append((gdaltest.clean_tmp, 'bmp_cleanup')) + ('byte.tif', 4672), + ('utmsmall.tif', 50054), + ('8bit_pal.bmp', 4672), ] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + ] +) +@pytest.mark.require_driver('BMP') +def test_bmp_create(filename, checksum, testfunction): + ut = gdaltest.GDALTest('BMP', filename, 1, checksum) + getattr(ut, testfunction)() + if __name__ == '__main__': diff --git a/autotest/gcore/envi_read.py b/autotest/gcore/envi_read.py index 99ac328eabea..ef620ff044f1 100755 --- a/autotest/gcore/envi_read.py +++ b/autotest/gcore/envi_read.py @@ -29,6 +29,7 @@ import sys +import pytest from osgeo import gdal import gdaltest @@ -59,23 +60,28 @@ def envi_1(): gdaltest_list = [] init_list = [ - ('byte.raw', 1, 4672, None), - ('int16.raw', 1, 4672, None), - ('uint16.raw', 1, 4672, None), - ('int32.raw', 1, 4672, None), - ('uint32.raw', 1, 4672, None), - ('float32.raw', 1, 4672, None), - ('float64.raw', 1, 4672, None)] -# ('cfloat32.raw', 1, 5028, None), -# ('cfloat64.raw', 1, 5028, None)] - - -for item in init_list: - ut = gdaltest.GDALTest('ENVI', item[0], item[1], item[2]) - if ut is None: - print('ENVI tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) + ('byte.raw', 4672), + ('int16.raw', 4672), + ('uint16.raw', 4672), + ('int32.raw', 4672), + ('uint32.raw', 4672), + ('float32.raw', 4672), + ('float64.raw', 4672), + # ('cfloat32.raw', 5028), + # ('cfloat64.raw', 5028), +] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('ENVI') +def test_envi_open(filename, checksum): + ut = gdaltest.GDALTest('ENVI', filename, 1, checksum) + ut.testOpen() + gdaltest_list.append(envi_1) diff --git a/autotest/gcore/gtiff_write.py b/autotest/gcore/gtiff_write.py index 0997de9bdcfa..bf7f7a887229 100755 --- a/autotest/gcore/gtiff_write.py +++ b/autotest/gcore/gtiff_write.py @@ -25,47 +25,52 @@ # Boston, MA 02111-1307, USA. ############################################################################### -import sys - +import pytest import gdaltest init_list = [ - ('byte.tif', 1, 4672, None), - ('int16.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None), - ('int32.tif', 1, 4672, None), - ('uint32.tif', 1, 4672, None), - ('float32.tif', 1, 4672, None), - ('float64.tif', 1, 4672, None), - ('cint16.tif', 1, 5028, None), - ('cint32.tif', 1, 5028, None), - ('cfloat32.tif', 1, 5028, None), - ('cfloat64.tif', 1, 5028, None)] + ('byte.tif', 4672), + ('int16.tif', 4672), + ('uint16.tif', 4672), + ('int32.tif', 4672), + ('uint32.tif', 4672), + ('float32.tif', 4672), + ('float64.tif', 4672), + ('cint16.tif', 5028), + ('cint32.tif', 5028), + ('cfloat32.tif', 5028), + ('cfloat64.tif', 5028)] -gdaltest_list = [] # Some tests we don't need to do for each type. -item = init_list[0] -ut = gdaltest.GDALTest('GTiff', item[0], item[1], item[2]) -gdaltest_list.append((ut.testSetGeoTransform, item[0])) -gdaltest_list.append((ut.testSetProjection, item[0])) -gdaltest_list.append((ut.testSetMetadata, item[0])) - -# Others we do for each pixel type. -for item in init_list: - ut = gdaltest.GDALTest('GTiff', item[0], item[1], item[2]) - if ut is None: - print('GTiff tests skipped') - gdaltest_list.append((ut.testCreateCopy, item[0])) - gdaltest_list.append((ut.testCreate, item[0])) - gdaltest_list.append((ut.testSetNoDataValue, item[0])) - +@pytest.mark.parametrize( + 'testfunction', [ + 'testSetGeoTransform', + 'testSetProjection', + 'testSetMetadata', + ] +) +@pytest.mark.require_driver('GTiff') +def test_gtiff_set(testfunction): + ut = gdaltest.GDALTest('GTiff', 'byte.tif', 1, 4672) + getattr(ut, testfunction)() -if __name__ == '__main__': - gdaltest.setup_run('gtiff_write') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) +# Others we do for each pixel type. +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + 'testSetNoDataValue', + ] +) +@pytest.mark.require_driver('GTiff') +def test_gtiff_create(filename, checksum, testfunction): + ut = gdaltest.GDALTest('GTiff', filename, 1, checksum) + getattr(ut, testfunction)() diff --git a/autotest/gcore/hdf4_read.py b/autotest/gcore/hdf4_read.py index ed37cdd94538..1ba71e4174c1 100755 --- a/autotest/gcore/hdf4_read.py +++ b/autotest/gcore/hdf4_read.py @@ -28,6 +28,7 @@ import sys +import pytest import gdaltest from osgeo import gdal @@ -38,22 +39,34 @@ gdaltest_list = [] init_list = [ - ('byte_3.hdf', 1, 4672, None), - ('int16_3.hdf', 1, 4672, None), - ('uint16_3.hdf', 1, 4672, None), - ('int32_3.hdf', 1, 4672, None), - ('uint32_3.hdf', 1, 4672, None), - ('float32_3.hdf', 1, 4672, None), - ('float64_3.hdf', 1, 4672, None), - ('utmsmall_3.hdf', 1, 50054, None), - ('byte_2.hdf', 1, 4672, None), - ('int16_2.hdf', 1, 4672, None), - ('uint16_2.hdf', 1, 4672, None), - ('int32_2.hdf', 1, 4672, None), - ('uint32_2.hdf', 1, 4672, None), - ('float32_2.hdf', 1, 4672, None), - ('float64_2.hdf', 1, 4672, None), - ('utmsmall_2.hdf', 1, 50054, None)] + ('byte_3.hdf', 4672), + ('int16_3.hdf', 4672), + ('uint16_3.hdf', 4672), + ('int32_3.hdf', 4672), + ('uint32_3.hdf', 4672), + ('float32_3.hdf', 4672), + ('float64_3.hdf', 4672), + ('utmsmall_3.hdf', 50054), + ('byte_2.hdf', 4672), + ('int16_2.hdf', 4672), + ('uint16_2.hdf', 4672), + ('int32_2.hdf', 4672), + ('uint32_2.hdf', 4672), + ('float32_2.hdf', 4672), + ('float64_2.hdf', 4672), + ('utmsmall_2.hdf', 50054)] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('HDF4Image') +def test_hdf4_open(filename, checksum): + ut = gdaltest.GDALTest('HDF4Image', filename, 1, checksum) + ut.testOpen() + ############################################################################### # Test HDF4_SDS with single subdataset @@ -359,13 +372,6 @@ def hdf4_read_online_10(): return 'success' -for item in init_list: - ut = gdaltest.GDALTest('HDF4Image', item[0], item[1], item[2]) - if ut is None: - print('HDF4 tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) - gdaltest_list.append(hdf4_read_online_1) gdaltest_list.append(hdf4_read_online_2) gdaltest_list.append(hdf4_read_online_3) diff --git a/autotest/gcore/hdf4_write.py b/autotest/gcore/hdf4_write.py index a75f68c3ffbf..e46cfdc2bf8e 100755 --- a/autotest/gcore/hdf4_write.py +++ b/autotest/gcore/hdf4_write.py @@ -25,50 +25,39 @@ # Boston, MA 02111-1307, USA. ############################################################################### -import sys - - +import pytest import gdaltest init_list = [ - ('byte.tif', 1, 4672, None), - ('int16.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None), - ('int32.tif', 1, 4672, None), - ('uint32.tif', 1, 4672, None), - ('float32.tif', 1, 4672, None), - ('float64.tif', 1, 4672, None), - ('utmsmall.tif', 1, 50054, None)] - -gdaltest_list = [] - -for item in init_list: - ut = gdaltest.GDALTest('HDF4Image', item[0], item[1], item[2], - options=['RANK=3']) - if ut is None: - print('HDF4 tests skipped') - gdaltest_list.append((ut.testCreateCopy, item[0] + " rank=3")) - gdaltest_list.append((ut.testCreate, item[0] + " rank=3")) - gdaltest_list.append((ut.testSetGeoTransform, item[0] + " rank=3")) - gdaltest_list.append((ut.testSetProjection, item[0] + " rank=3")) - gdaltest_list.append((ut.testSetMetadata, item[0] + " rank=3")) - gdaltest_list.append((ut.testSetNoDataValue, item[0] + " rank=3")) - gdaltest_list.append((ut.testSetDescription, item[0] + " rank=3")) - ut = gdaltest.GDALTest('HDF4Image', item[0], item[1], item[2], - options=['RANK=2']) - if ut is None: - print('HDF4 tests skipped') - gdaltest_list.append((ut.testCreateCopy, item[0] + " rank=2")) - gdaltest_list.append((ut.testSetGeoTransform, item[0] + " rank=2")) - gdaltest_list.append((ut.testSetProjection, item[0] + " rank=2")) - gdaltest_list.append((ut.testSetMetadata, item[0] + " rank=2")) - gdaltest_list.append((ut.testSetNoDataValue, item[0] + " rank=2")) - gdaltest_list.append((ut.testSetDescription, item[0] + " rank=2")) - -if __name__ == '__main__': - - gdaltest.setup_run('hdf_write') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + ('byte.tif', 4672), + ('int16.tif', 4672), + ('uint16.tif', 4672), + ('int32.tif', 4672), + ('uint32.tif', 4672), + ('float32.tif', 4672), + ('float64.tif', 4672), + ('utmsmall.tif', 50054) +] + + +@pytest.mark.parametrize( + 'rank', [2, 3], ids=lambda x: 'rank%d' % x +) +@pytest.mark.parametrize( + 'filename,checksum', init_list, ids=[arg[0].split('.')[0] for arg in init_list] +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + 'testSetGeoTransform', + 'testSetProjection', + 'testSetMetadata', + 'testSetNoDataValue', + 'testSetDescription', + ] +) +@pytest.mark.require_driver('HDF4Image') +def test_hdf4_write(filename, checksum, testfunction, rank): + ut = gdaltest.GDALTest('HDF4Image', filename, 1, checksum, options=['RANK=%d' % rank]) + getattr(ut, testfunction)() diff --git a/autotest/gcore/hfa_read.py b/autotest/gcore/hfa_read.py index 20ab0109a41d..f572ddb5ca0d 100755 --- a/autotest/gcore/hfa_read.py +++ b/autotest/gcore/hfa_read.py @@ -30,6 +30,7 @@ import sys +import pytest from osgeo import gdal import gdaltest @@ -40,16 +41,26 @@ gdaltest_list = [] init_list = [ - ('byte.img', 1, 4672, None), - ('int16.img', 1, 4672, None), - ('uint16.img', 1, 4672, None), - ('int32.img', 1, 4672, None), - ('uint32.img', 1, 4672, None), - ('float32.img', 1, 4672, None), - ('float64.img', 1, 4672, None), - ('utmsmall.img', 1, 50054, None), - ('2bit_compressed.img', 1, 11918, None)] - + ('byte.img', 4672), + ('int16.img', 4672), + ('uint16.img', 4672), + ('int32.img', 4672), + ('uint32.img', 4672), + ('float32.img', 4672), + ('float64.img', 4672), + ('utmsmall.img', 50054), + ('2bit_compressed.img', 11918)] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('HFA') +def test_hfa_open(filename, checksum): + ut = gdaltest.GDALTest('HFA', filename, 1, checksum) + ut.testOpen() ############################################################################### # Test bugfix for https://oss-fuzz.com/v2/testcase-detail/6053338875428864 @@ -61,14 +72,6 @@ def hfa_read_completedefn_recursion(): return 'success' -for item in init_list: - ut = gdaltest.GDALTest('HFA', item[0], item[1], item[2]) - if ut is None: - print('HFA tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) - - gdaltest_list.append(hfa_read_completedefn_recursion) if __name__ == '__main__': diff --git a/autotest/gcore/hfa_write.py b/autotest/gcore/hfa_write.py index 5b63ccb3ab19..2abc40331094 100755 --- a/autotest/gcore/hfa_write.py +++ b/autotest/gcore/hfa_write.py @@ -33,8 +33,10 @@ import os import sys import shutil -from osgeo import gdal +import pytest + +from osgeo import gdal import gdaltest @@ -402,16 +404,77 @@ def hfa_write_invalid_wkt(): init_list = [ - ('byte.tif', 1, 4672, None), - ('int16.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None), - ('int32.tif', 1, 4672, None), - ('uint32.tif', 1, 4672, None), - ('float32.tif', 1, 4672, None), - ('float64.tif', 1, 4672, None), - ('cfloat32.tif', 1, 5028, None), - ('cfloat64.tif', 1, 5028, None), - ('utmsmall.tif', 1, 50054, None)] + ('byte.tif', 4672), + ('int16.tif', 4672), + ('uint16.tif', 4672), + ('int32.tif', 4672), + ('uint32.tif', 4672), + ('float32.tif', 4672), + ('float64.tif', 4672), + ('cfloat32.tif', 5028), + ('cfloat64.tif', 5028), + ('utmsmall.tif', 50054)] + +# full set of tests for normal mode. + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + 'testSetGeoTransform', + 'testSetMetadata', + ] +) +@pytest.mark.require_driver('HFA') +def test_hfa_create_normal(filename, checksum, testfunction): + ut = gdaltest.GDALTest('HFA', filename, 1, checksum) + getattr(ut, testfunction)() + + +# Just a few for spill file, and compressed support. +short_list = [ + ('byte.tif', 4672), + ('uint16.tif', 4672), + ('float64.tif', 4672)] + +@pytest.mark.parametrize( + 'filename,checksum', + short_list, + ids=[tup[0].split('.')[0] for tup in short_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + ] +) +@pytest.mark.require_driver('HFA') +def test_hfa_create_spill(filename, checksum, testfunction): + ut = gdaltest.GDALTest('HFA', filename, 1, checksum, options=['USE_SPILL=YES']) + getattr(ut, testfunction)() + + +@pytest.mark.parametrize( + 'filename,checksum', + short_list, + ids=[tup[0].split('.')[0] for tup in short_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + # 'testCreateCopy', + 'testCreate', + ] +) +@pytest.mark.require_driver('HFA') +def test_hfa_create_compress(filename, checksum, testfunction): + ut = gdaltest.GDALTest('HFA', filename, 1, checksum, options=['COMPRESS=YES']) + getattr(ut, testfunction)() + gdaltest_list = [hfa_write_desc, hfa_write_4bit, @@ -424,38 +487,6 @@ def hfa_write_invalid_wkt(): hfa_update_existing_aux_overviews, hfa_write_invalid_wkt] -# full set of tests for normal mode. - -for item in init_list: - ut1 = gdaltest.GDALTest('HFA', item[0], item[1], item[2]) - if ut1 is None: - print('HFA tests skipped') - gdaltest_list.append((ut1.testCreateCopy, item[0])) - gdaltest_list.append((ut1.testCreate, item[0])) - gdaltest_list.append((ut1.testSetGeoTransform, item[0])) - gdaltest_list.append((ut1.testSetMetadata, item[0])) - -# Just a few for spill file, and compressed support. -short_list = [ - ('byte.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None), - ('float64.tif', 1, 4672, None)] - -for item in short_list: - ut2 = gdaltest.GDALTest('HFA', item[0], item[1], item[2], - options=['USE_SPILL=YES']) - if ut2 is None: - print('HFA tests skipped') - gdaltest_list.append((ut2.testCreateCopy, item[0] + ' (spill)')) - gdaltest_list.append((ut2.testCreate, item[0] + ' (spill)')) - - ut2 = gdaltest.GDALTest('HFA', item[0], item[1], item[2], - options=['COMPRESS=YES']) - if ut2 is None: - print('HFA tests skipped') -# gdaltest_list.append( (ut2.testCreateCopy, item[0] + ' (compressed)') ) - gdaltest_list.append((ut2.testCreate, item[0] + ' (compressed)')) - if __name__ == '__main__': diff --git a/autotest/gcore/pnm_read.py b/autotest/gcore/pnm_read.py index 7857312ab410..c5d8ab41cb24 100755 --- a/autotest/gcore/pnm_read.py +++ b/autotest/gcore/pnm_read.py @@ -28,31 +28,24 @@ # DEALINGS IN THE SOFTWARE. ############################################################################### -import sys - +import pytest import gdaltest ############################################################################### # When imported build a list of units based on the files available. -gdaltest_list = [] - init_list = [ - ('byte.pnm', 1, 4672, None), - ('uint16.pnm', 1, 4672, None)] - -for item in init_list: - ut = gdaltest.GDALTest('PNM', item[0], item[1], item[2]) - if ut is None: - print('PNM tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) - -if __name__ == '__main__': - - gdaltest.setup_run('pnm_read') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + ('byte.pnm', 4672), + ('uint16.pnm', 4672)] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('PNM') +def test_pnm_open(filename, checksum): + ut = gdaltest.GDALTest('PNM', filename, 1, checksum) + ut.testOpen() diff --git a/autotest/gcore/pnm_write.py b/autotest/gcore/pnm_write.py index 3086f303a330..3f8fb0e01f63 100755 --- a/autotest/gcore/pnm_write.py +++ b/autotest/gcore/pnm_write.py @@ -25,28 +25,27 @@ # Boston, MA 02111-1307, USA. ############################################################################### -import sys - +import pytest import gdaltest init_list = [ - ('byte.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None)] - -gdaltest_list = [] - -for item in init_list: - ut = gdaltest.GDALTest('PNM', item[0], item[1], item[2]) - if ut is None: - print('PNM tests skipped') - gdaltest_list.append((ut.testCreateCopy, item[0])) - gdaltest_list.append((ut.testCreate, item[0])) - -if __name__ == '__main__': - - gdaltest.setup_run('pnm_write') - - gdaltest.run_tests(gdaltest_list) - - sys.exit(gdaltest.summarize()) + ('byte.tif', 4672), + ('uint16.tif', 4672)] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + ] +) +@pytest.mark.require_driver('PNM') +def test_pnm_create(filename, checksum, testfunction): + ut = gdaltest.GDALTest('PNM', filename, 1, checksum) + getattr(ut, testfunction)() diff --git a/autotest/gcore/tiff_ovr.py b/autotest/gcore/tiff_ovr.py index 1f606648d7b8..bc2c458658b9 100755 --- a/autotest/gcore/tiff_ovr.py +++ b/autotest/gcore/tiff_ovr.py @@ -38,10 +38,25 @@ from osgeo import osr from osgeo import gdal +import pytest import gdaltest +@pytest.fixture(params=['invert', 'dont-invert']) +def both_endian(request): + """ + Runs tests with both values of GDAL_TIFF_ENDIANNESS + """ + if request.param == 'invert': + original = gdal.GetConfigOption('GDAL_TIFF_ENDIANNESS', "NATIVE") + gdal.SetConfigOption('GDAL_TIFF_ENDIANNESS', 'INVERTED') + yield + gdal.SetConfigOption('GDAL_TIFF_ENDIANNESS', original) + else: + yield + + ############################################################################### # Check the overviews @@ -79,7 +94,7 @@ def tiff_ovr_check(src_ds): # later. Build overviews on it. -def tiff_ovr_1(): +def tiff_ovr_1(both_endian): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') @@ -115,7 +130,7 @@ def tiff_ovr_1(): ############################################################################### # Open file and verify some characteristics of the overviews. -def tiff_ovr_2(): +def tiff_ovr_2(both_endian): src_ds = gdal.Open('tmp/mfloat32.tif') @@ -133,7 +148,7 @@ def tiff_ovr_2(): # Open target file in update mode, and create internal overviews. -def tiff_ovr_3(): +def tiff_ovr_3(both_endian): os.unlink('tmp/mfloat32.tif.ovr') @@ -158,14 +173,14 @@ def tiff_ovr_3(): # Re-open target file and check overviews -def tiff_ovr_3bis(): - return tiff_ovr_2() +def tiff_ovr_3bis(both_endian): + return tiff_ovr_2(both_endian) ############################################################################### # Test generation -def tiff_ovr_4(): +def tiff_ovr_4(both_endian): shutil.copyfile('data/oddsize_1bit2b.tif', 'tmp/ovr4.tif') @@ -241,7 +256,7 @@ def tiff_ovr_4(): ############################################################################### # Test average overview generation with nodata. -def tiff_ovr_5(): +def tiff_ovr_5(both_endian): shutil.copyfile('data/nodata_byte.tif', 'tmp/ovr5.tif') @@ -267,7 +282,7 @@ def tiff_ovr_5(): # Same as tiff_ovr_5 but with USE_RDD=YES to force external overview -def tiff_ovr_6(): +def tiff_ovr_6(both_endian): shutil.copyfile('data/nodata_byte.tif', 'tmp/ovr6.tif') @@ -304,7 +319,7 @@ def tiff_ovr_6(): ############################################################################### # Check nearest resampling on a dataset with a raster band that has a color table -def tiff_ovr_7(): +def tiff_ovr_7(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/test_average_palette.tif') @@ -334,7 +349,7 @@ def tiff_ovr_7(): # Check average resampling on a dataset with a raster band that has a color table -def tiff_ovr_8(): +def tiff_ovr_8(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/test_average_palette.tif') @@ -366,7 +381,7 @@ def tiff_ovr_8(): # Will also check that pixel interleaving is automatically selected (#3064) -def tiff_ovr_9(): +def tiff_ovr_9(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -418,7 +433,7 @@ def tiff_ovr_9(): # Similar to tiff_ovr_9 but with internal overviews. -def tiff_ovr_10(): +def tiff_ovr_10(both_endian): src_ds = gdal.Open('data/rgbsmall.tif', gdal.GA_ReadOnly) @@ -458,7 +473,7 @@ def tiff_ovr_10(): # Overview on a dataset with NODATA_VALUES -def tiff_ovr_11(): +def tiff_ovr_11(both_endian): src_ds = gdal.Open('data/test_nodatavalues.tif', gdal.GA_ReadOnly) @@ -505,7 +520,7 @@ def tiff_ovr_11(): # code -def tiff_ovr_12(): +def tiff_ovr_12(both_endian): src_ds = gdal.Open('data/test_nodatavalues.tif', gdal.GA_ReadOnly) @@ -551,7 +566,7 @@ def tiff_ovr_12(): ############################################################################### # Test gaussian resampling -def tiff_ovr_13(): +def tiff_ovr_13(both_endian): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') @@ -589,7 +604,7 @@ def tiff_ovr_13(): # Check gauss resampling on a dataset with a raster band that has a color table -def tiff_ovr_14(): +def tiff_ovr_14(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/test_gauss_palette.tif') @@ -618,7 +633,7 @@ def tiff_ovr_14(): # code -def tiff_ovr_15(): +def tiff_ovr_15(both_endian): src_ds = gdal.Open('data/test_nodatavalues.tif', gdal.GA_ReadOnly) @@ -664,7 +679,7 @@ def tiff_ovr_15(): ############################################################################### # Test mode resampling on non-byte dataset -def tiff_ovr_16(): +def tiff_ovr_16(both_endian): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') @@ -705,7 +720,7 @@ def tiff_ovr_16(): ############################################################################### # Test mode resampling on a byte dataset -def tiff_ovr_17(): +def tiff_ovr_17(both_endian): shutil.copyfile('data/byte.tif', 'tmp/ovr17.tif') @@ -736,7 +751,7 @@ def tiff_ovr_17(): # Check mode resampling on a dataset with a raster band that has a color table -def tiff_ovr_18(): +def tiff_ovr_18(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/ovr18.tif') @@ -766,7 +781,7 @@ def tiff_ovr_18(): # if BigTIFF is not supported (this is a sign of an older libtiff...) -def tiff_ovr_19(): +def tiff_ovr_19(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -804,7 +819,7 @@ def tiff_ovr_19(): ############################################################################### # Test BIGTIFF_OVERVIEW=YES option -def tiff_ovr_20(): +def tiff_ovr_20(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -842,7 +857,7 @@ def tiff_ovr_20(): ############################################################################### # Test BIGTIFF_OVERVIEW=IF_NEEDED option -def tiff_ovr_21(): +def tiff_ovr_21(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -880,7 +895,7 @@ def tiff_ovr_21(): # Test BIGTIFF_OVERVIEW=NO option when BigTIFF is really needed -def tiff_ovr_22(): +def tiff_ovr_22(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -915,7 +930,7 @@ def tiff_ovr_22(): # method for the overviews. -def tiff_ovr_23(): +def tiff_ovr_23(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -955,7 +970,7 @@ def tiff_ovr_23(): # Test BIGTIFF_OVERVIEW=IF_SAFER option -def tiff_ovr_24(): +def tiff_ovr_24(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -996,7 +1011,7 @@ def tiff_ovr_24(): # band and actually flushed -def tiff_ovr_25(): +def tiff_ovr_25(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr25.tif', 100, 100, 1) ds.GetRasterBand(1).Fill(1) @@ -1023,7 +1038,7 @@ def tiff_ovr_25(): # Test gdal.RegenerateOverview() -def tiff_ovr_26(): +def tiff_ovr_26(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr26.tif', 100, 100, 1) ds.GetRasterBand(1).Fill(1) @@ -1046,7 +1061,7 @@ def tiff_ovr_26(): # Test gdal.RegenerateOverviews() -def tiff_ovr_27(): +def tiff_ovr_27(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr27.tif', 100, 100, 1) ds.GetRasterBand(1).Fill(1) @@ -1075,7 +1090,7 @@ def tiff_ovr_27(): # Test cleaning overviews. -def tiff_ovr_28(): +def tiff_ovr_28(both_endian): ds = gdal.Open('tmp/ovr25.tif', gdal.GA_Update) if ds.BuildOverviews(overviewlist=[]) != 0: @@ -1099,7 +1114,7 @@ def tiff_ovr_28(): # Test cleaning external overviews (ovr) on a non-TIFF format. -def tiff_ovr_29(): +def tiff_ovr_29(both_endian): src_ds = gdal.Open('data/byte.tif') png_ds = gdal.GetDriverByName('PNG').CreateCopy('tmp/ovr29.png', src_ds) @@ -1147,7 +1162,7 @@ def tiff_ovr_29(): # Test fix for #2988. -def tiff_ovr_30(): +def tiff_ovr_30(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr30.tif', 20, 20, 1) ds.BuildOverviews(overviewlist=[2]) @@ -1177,7 +1192,7 @@ def tiff_ovr_30(): # Test fix for #3033 -def tiff_ovr_31(): +def tiff_ovr_31(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr31.tif', 100, 100, 4) ds.GetRasterBand(1).Fill(255) @@ -1198,7 +1213,7 @@ def tiff_ovr_31(): # Test Cubic sampling. -def tiff_ovr_32(): +def tiff_ovr_32(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -1357,7 +1372,7 @@ def tiff_ovr_32(): ############################################################################### # Test creation of overviews on a 1x1 dataset (fix for #3069) -def tiff_ovr_33(): +def tiff_ovr_33(both_endian): try: os.remove('tmp/ovr33.tif.ovr') @@ -1378,7 +1393,7 @@ def tiff_ovr_33(): ############################################################################### # Confirm that overviews are used on a Band.RasterIO(). -def tiff_ovr_34(): +def tiff_ovr_34(both_endian): ds_in = gdal.Open('data/byte.tif') ds = gdaltest.tiff_drv.CreateCopy('tmp/ovr34.tif', ds_in) @@ -1404,7 +1419,7 @@ def tiff_ovr_34(): # Confirm that overviews are used on a Band.RasterIO(). -def tiff_ovr_35(): +def tiff_ovr_35(both_endian): ds_in = gdal.Open('data/byte.tif') ds = gdaltest.tiff_drv.CreateCopy('tmp/ovr35.tif', ds_in) @@ -1430,12 +1445,12 @@ def tiff_ovr_35(): # Confirm that overviews are used on a Band.RasterIO() when using BlockBasedRasterIO() (#3124) -def tiff_ovr_36(): +def tiff_ovr_36(both_endian): oldval = gdal.GetConfigOption('GDAL_FORCE_CACHING', 'NO') gdal.SetConfigOption('GDAL_FORCE_CACHING', 'YES') - ret = tiff_ovr_35() + ret = tiff_ovr_35(both_endian) gdal.SetConfigOption('GDAL_FORCE_CACHING', oldval) @@ -1445,7 +1460,7 @@ def tiff_ovr_36(): # Test PREDICTOR_OVERVIEW=2 option. (#3414) -def tiff_ovr_37(): +def tiff_ovr_37(both_endian): shutil.copy('../gdrivers/data/n43.dt0', 'tmp/ovr37.dt0') @@ -1485,7 +1500,7 @@ def tiff_ovr_37(): # Test that the predictor flag gets well propagated to internal overviews -def tiff_ovr_38(): +def tiff_ovr_38(both_endian): # Skip with old libtiff (crash with 3.8.2) md = gdaltest.tiff_drv.GetMetadata() @@ -1510,7 +1525,7 @@ def tiff_ovr_38(): # Test external overviews on all datatypes -def tiff_ovr_39(): +def tiff_ovr_39(both_endian): for datatype in [gdal.GDT_Byte, gdal.GDT_Int16, @@ -1562,7 +1577,7 @@ def tiff_ovr_39(): # Test external overviews on 1 bit datasets with AVERAGE_BIT2GRAYSCALE (similar to tiff_ovr_4) -def tiff_ovr_40(): +def tiff_ovr_40(both_endian): shutil.copyfile('data/oddsize_1bit2b.tif', 'tmp/ovr40.tif') @@ -1638,7 +1653,7 @@ def tiff_ovr_40(): # Test external overviews on 1 bit datasets with NEAREST -def tiff_ovr_41(): +def tiff_ovr_41(both_endian): shutil.copyfile('data/oddsize_1bit2b.tif', 'tmp/ovr41.tif') @@ -1666,7 +1681,7 @@ def tiff_ovr_41(): # Test external overviews on dataset with color table -def tiff_ovr_42(): +def tiff_ovr_42(both_endian): ct_data = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)] @@ -1702,7 +1717,7 @@ def tiff_ovr_42(): # jpeg-in-tiff (#3539) -def tiff_ovr_43(): +def tiff_ovr_43(both_endian): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -1766,7 +1781,7 @@ def tiff_ovr_43(): # option -def tiff_ovr_44(): +def tiff_ovr_44(both_endian): shutil.copyfile('data/byte.tif', 'tmp/ovr44.tif') gdal.SetConfigOption('GDAL_TIFF_OVR_BLOCKSIZE', '256') @@ -1798,7 +1813,7 @@ def tiff_ovr_44(): # Same as tiff_ovr_44, but with external overviews -def tiff_ovr_45(): +def tiff_ovr_45(both_endian): shutil.copyfile('data/byte.tif', 'tmp/ovr45.tif') gdal.SetConfigOption('GDAL_TIFF_OVR_BLOCKSIZE', '256') @@ -1927,7 +1942,7 @@ def tiff_ovr_46(): # Test workaround with libtiff 3.X when creating interleaved overviews -def tiff_ovr_47(): +def tiff_ovr_47(both_endian): mem_drv = gdal.GetDriverByName('MEM') mem_ds = mem_drv.Create('', 852, 549, 3) @@ -1958,7 +1973,7 @@ def tiff_ovr_47(): # Test that we don't average 0's in alpha band -def tiff_ovr_48(): +def tiff_ovr_48(both_endian): shutil.copy('data/rgba_with_alpha_0_and_255.tif', 'tmp') ds = gdal.Open('tmp/rgba_with_alpha_0_and_255.tif') @@ -1994,7 +2009,7 @@ def tiff_ovr_48(): # Test possible stride computation issue in GDALRegenerateOverviewsMultiBand (#5653) -def tiff_ovr_49(): +def tiff_ovr_49(both_endian): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_ovr_49.tif', 1023, 1023, 1) ds.GetRasterBand(1).Fill(0) @@ -2021,7 +2036,7 @@ def tiff_ovr_49(): # Test overviews when X dimension is smaller than Y (#5794) -def tiff_ovr_50(): +def tiff_ovr_50(both_endian): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_ovr_50.tif', 6, 8192, 3, options=['COMPRESS=DEFLATE']) @@ -2324,52 +2339,8 @@ def tiff_ovr_average_multiband_vs_singleband(): return 'success' -############################################################################### -# Cleanup - - -def tiff_ovr_cleanup(): - gdaltest.tiff_drv.Delete('tmp/mfloat32.tif') - gdaltest.tiff_drv.Delete('tmp/ovr4.tif') - gdaltest.tiff_drv.Delete('tmp/ovr5.tif') - gdaltest.tiff_drv.Delete('tmp/ovr6.tif') - gdaltest.tiff_drv.Delete('tmp/test_average_palette.tif') - gdaltest.tiff_drv.Delete('tmp/ovr9.tif') - gdaltest.tiff_drv.Delete('tmp/ovr10.tif') - gdaltest.tiff_drv.Delete('tmp/ovr11.tif') - gdaltest.tiff_drv.Delete('tmp/ovr12.tif') - gdaltest.tiff_drv.Delete('tmp/test_gauss_palette.tif') - gdaltest.tiff_drv.Delete('tmp/ovr15.tif') - gdaltest.tiff_drv.Delete('tmp/ovr16.tif') - gdaltest.tiff_drv.Delete('tmp/ovr17.tif') - gdaltest.tiff_drv.Delete('tmp/ovr18.tif') - md = gdaltest.tiff_drv.GetMetadata() - if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') != -1: - gdaltest.tiff_drv.Delete('tmp/ovr19.tif') - gdaltest.tiff_drv.Delete('tmp/ovr20.tif') - gdaltest.tiff_drv.Delete('tmp/ovr21.tif') - gdaltest.tiff_drv.Delete('tmp/ovr22.tif') - gdaltest.tiff_drv.Delete('tmp/ovr23.tif') - gdaltest.tiff_drv.Delete('tmp/ovr24.tif') - gdaltest.tiff_drv.Delete('tmp/ovr25.tif') - gdaltest.tiff_drv.Delete('tmp/ovr26.tif') - gdaltest.tiff_drv.Delete('tmp/ovr27.tif') - gdaltest.tiff_drv.Delete('tmp/ovr30.tif') - gdaltest.tiff_drv.Delete('tmp/ovr31.tif') - gdaltest.tiff_drv.Delete('tmp/ovr37.dt0') - if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') != -1: - gdaltest.tiff_drv.Delete('tmp/ovr38.tif') - gdaltest.tiff_drv.Delete('tmp/ovr39.tif') - gdaltest.tiff_drv.Delete('tmp/ovr40.tif') - gdaltest.tiff_drv.Delete('tmp/ovr41.tif') - gdaltest.tiff_drv.Delete('tmp/ovr42.tif') - gdaltest.tiff_drv.Delete('tmp/rgba_with_alpha_0_and_255.tif') - gdaltest.tiff_drv = None - - return 'success' - -gdaltest_list_internal = [ +gdaltest_list = [ tiff_ovr_1, tiff_ovr_2, tiff_ovr_3, @@ -2421,37 +2392,15 @@ def tiff_ovr_cleanup(): tiff_ovr_48, tiff_ovr_49, tiff_ovr_50, - tiff_ovr_cleanup] - - -def tiff_ovr_invert_endianness(): - gdaltest.tiff_endianness = gdal.GetConfigOption('GDAL_TIFF_ENDIANNESS', "NATIVE") - gdal.SetConfigOption('GDAL_TIFF_ENDIANNESS', 'INVERTED') - return 'success' - - -def tiff_ovr_restore_endianness(): - gdal.SetConfigOption('GDAL_TIFF_ENDIANNESS', gdaltest.tiff_endianness) - return 'success' - - -gdaltest_list = [] -for item in gdaltest_list_internal: - gdaltest_list.append(item) -gdaltest_list.append(tiff_ovr_invert_endianness) -for item in gdaltest_list_internal: - if item.__name__ != 'tiff_ovr_46': - gdaltest_list.append((item, item.__name__ + '_inverted')) -gdaltest_list.append(tiff_ovr_restore_endianness) - -gdaltest_list += [tiff_ovr_51, - tiff_ovr_52, - tiff_ovr_53, - tiff_ovr_54, - tiff_ovr_too_many_levels_contig, - tiff_ovr_too_many_levels_separate, - tiff_ovr_too_many_levels_external, - tiff_ovr_average_multiband_vs_singleband ] + tiff_ovr_51, + tiff_ovr_52, + tiff_ovr_53, + tiff_ovr_54, + tiff_ovr_too_many_levels_contig, + tiff_ovr_too_many_levels_separate, + tiff_ovr_too_many_levels_external, + tiff_ovr_average_multiband_vs_singleband +] if __name__ == '__main__': diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index 82eb4024b937..0b3c64222925 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -31,6 +31,7 @@ import sys import shutil +import pytest import gdaltest from osgeo import gdal, osr @@ -41,34 +42,47 @@ gdaltest_list = [] init_list = [ - ('byte.tif', 1, 4672, None), - ('uint16_sgilog.tif', 1, 4672, None), - ('next_literalrow.tif', 1, 4, None), - ('next_literalspan.tif', 1, 4, None), - ('next_default_case.tif', 1, 4, None), - ('thunder.tif', 1, 3, None), - ('int10.tif', 1, 4672, None), - ('int12.tif', 1, 4672, None), - ('int16.tif', 1, 4672, None), - ('uint16.tif', 1, 4672, None), - ('int24.tif', 1, 4672, None), - ('int32.tif', 1, 4672, None), - ('uint32.tif', 1, 4672, None), - ('float16.tif', 1, 4672, None), - ('float24.tif', 1, 4672, None), - ('float32.tif', 1, 4672, None), - ('float32_minwhite.tif', 1, 1, None), - ('float64.tif', 1, 4672, None), - ('cint16.tif', 1, 5028, None), - ('cint32.tif', 1, 5028, None), - ('cfloat32.tif', 1, 5028, None), - ('cfloat64.tif', 1, 5028, None), + ('byte.tif', 1, 4672), + ('uint16_sgilog.tif', 1, 4672), + ('next_literalrow.tif', 1, 4), + ('next_literalspan.tif', 1, 4), + ('next_default_case.tif', 1, 4), + ('thunder.tif', 1, 3), + ('int10.tif', 1, 4672), + ('int12.tif', 1, 4672), + ('int16.tif', 1, 4672), + ('uint16.tif', 1, 4672), + ('int24.tif', 1, 4672), + ('int32.tif', 1, 4672), + ('uint32.tif', 1, 4672), + ('float16.tif', 1, 4672), + ('float24.tif', 1, 4672), + ('float32.tif', 1, 4672), + ('float32_minwhite.tif', 1, 1), + ('float64.tif', 1, 4672), + ('cint16.tif', 1, 5028), + ('cint32.tif', 1, 5028), + ('cfloat32.tif', 1, 5028), + ('cfloat64.tif', 1, 5028), # The following four related partial final strip/tiles (#1179) - ('separate_tiled.tif', 2, 15234, None), - ('seperate_strip.tif', 2, 15234, None), # TODO: Spelling. - ('contig_tiled.tif', 2, 15234, None), - ('contig_strip.tif', 2, 15234, None), - ('empty1bit.tif', 1, 0, None)] + ('separate_tiled.tif', 2, 15234), + ('seperate_strip.tif', 2, 15234), # TODO: Spelling. + ('contig_tiled.tif', 2, 15234), + ('contig_strip.tif', 2, 15234), + ('empty1bit.tif', 1, 0) +] + + +@pytest.mark.parametrize( + 'filename,band,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('GTiff') +def test_tiff_open(filename, band, checksum): + ut = gdaltest.GDALTest('GTiff', filename, band, checksum) + ut.testOpen() + ############################################################################### # Test absolute/offset && index directory access @@ -3854,12 +3868,6 @@ def tiff_read_overview_of_external_mask(): ############################################################################### -for item in init_list: - ut = gdaltest.GDALTest('GTiff', item[0], item[1], item[2]) - if ut is None: - print('GTiff tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) gdaltest_list.append(tiff_read_off) gdaltest_list.append(tiff_check_alpha) gdaltest_list.append(tiff_read_cmyk_rgba) diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index 0894e5c66d4a..e1894cc73bc9 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -35,6 +35,7 @@ import shutil import struct +import pytest import gdaltest from osgeo import gdal @@ -46,23 +47,36 @@ gdaltest_list = [] init_list = [ - ('byte.vrt', 1, 4672, None), - ('int16.vrt', 1, 4672, None), - ('uint16.vrt', 1, 4672, None), - ('int32.vrt', 1, 4672, None), - ('uint32.vrt', 1, 4672, None), - ('float32.vrt', 1, 4672, None), - ('float64.vrt', 1, 4672, None), - ('cint16.vrt', 1, 5028, None), - ('cint32.vrt', 1, 5028, None), - ('cfloat32.vrt', 1, 5028, None), - ('cfloat64.vrt', 1, 5028, None), - ('msubwinbyte.vrt', 2, 2699, None), - ('utmsmall.vrt', 1, 50054, None), - ('byte_nearest_50pct.vrt', 1, 1192, None), - ('byte_averaged_50pct.vrt', 1, 1152, None), - ('byte_nearest_200pct.vrt', 1, 18784, None), - ('byte_averaged_200pct.vrt', 1, 18784, None)] + ('byte.vrt', 4672), + ('int16.vrt', 4672), + ('uint16.vrt', 4672), + ('int32.vrt', 4672), + ('uint32.vrt', 4672), + ('float32.vrt', 4672), + ('float64.vrt', 4672), + ('cint16.vrt', 5028), + ('cint32.vrt', 5028), + ('cfloat32.vrt', 5028), + ('cfloat64.vrt', 5028), + ('msubwinbyte.vrt', 2699), + ('utmsmall.vrt', 50054), + ('byte_nearest_50pct.vrt', 1192), + ('byte_averaged_50pct.vrt', 1152), + ('byte_nearest_200pct.vrt', 18784), + ('byte_averaged_200pct.vrt', 18784) +] + + +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('VRT') +def test_vrt_open(filename, checksum): + ut = gdaltest.GDALTest('VRT', filename, 1, checksum) + ut.testOpen() + ############################################################################### # The VRT references a non existing TIF file @@ -1454,47 +1468,44 @@ def vrt_dstsize_larger_than_source(): return 'success' -for item in init_list: - ut = gdaltest.GDALTest('VRT', item[0], item[1], item[2]) - if ut is None: - print('VRT tests skipped') - sys.exit() - gdaltest_list.append((ut.testOpen, item[0])) - -gdaltest_list.append(vrt_read_1) -gdaltest_list.append(vrt_read_2) -gdaltest_list.append(vrt_read_3) -gdaltest_list.append(vrt_read_4) -gdaltest_list.append(vrt_read_5) -gdaltest_list.append(vrt_read_6) -gdaltest_list.append(vrt_read_7) -gdaltest_list.append(vrt_read_8) -gdaltest_list.append(vrt_read_9) -gdaltest_list.append(vrt_read_10) -gdaltest_list.append(vrt_read_11) -gdaltest_list.append(vrt_read_12) -gdaltest_list.append(vrt_read_13) -gdaltest_list.append(vrt_read_14) -gdaltest_list.append(vrt_read_15) -gdaltest_list.append(vrt_read_16) -gdaltest_list.append(vrt_read_17) -gdaltest_list.append(vrt_read_18) -gdaltest_list.append(vrt_read_19) -gdaltest_list.append(vrt_read_20) -gdaltest_list.append(vrt_read_21) -gdaltest_list.append(vrt_read_22) -gdaltest_list.append(vrt_read_23) -gdaltest_list.append(vrt_read_24) -gdaltest_list.append(vrt_read_25) -gdaltest_list.append(vrt_read_26) -gdaltest_list.append(vrt_read_27) -gdaltest_list.append(vrt_read_28) -gdaltest_list.append(vrt_read_29) -gdaltest_list.append(vrt_read_30) -gdaltest_list.append(vrt_read_31) -gdaltest_list.append(vrt_float32_with_nodata_slightly_below_float_min) -gdaltest_list.append(vrt_subpixel_offset) -gdaltest_list.append(vrt_dstsize_larger_than_source) + +gdaltest_list = [ + vrt_read_1, + vrt_read_2, + vrt_read_3, + vrt_read_4, + vrt_read_5, + vrt_read_6, + vrt_read_7, + vrt_read_8, + vrt_read_9, + vrt_read_10, + vrt_read_11, + vrt_read_12, + vrt_read_13, + vrt_read_14, + vrt_read_15, + vrt_read_16, + vrt_read_17, + vrt_read_18, + vrt_read_19, + vrt_read_20, + vrt_read_21, + vrt_read_22, + vrt_read_23, + vrt_read_24, + vrt_read_25, + vrt_read_26, + vrt_read_27, + vrt_read_28, + vrt_read_29, + vrt_read_30, + vrt_read_31, + vrt_float32_with_nodata_slightly_below_float_min, + vrt_subpixel_offset, + vrt_dstsize_larger_than_source, +] + if __name__ == '__main__': diff --git a/autotest/gdrivers/gta.py b/autotest/gdrivers/gta.py index 3fe6e417d65a..d9685d522e4c 100755 --- a/autotest/gdrivers/gta.py +++ b/autotest/gdrivers/gta.py @@ -30,6 +30,7 @@ import sys +import pytest import gdaltest from osgeo import gdal @@ -38,19 +39,19 @@ gdaltest_list = [] init_list = [ - ('byte.tif', 1, 4672, []), - ('byte_signed.tif', 1, 4672, []), - ('int16.tif', 1, 4672, []), - ('uint16.tif', 1, 4672, []), - ('int32.tif', 1, 4672, []), - ('uint32.tif', 1, 4672, []), - ('float32.tif', 1, 4672, []), - ('float64.tif', 1, 4672, []), - ('cint16.tif', 1, 5028, []), - ('cint32.tif', 1, 5028, []), - ('cfloat32.tif', 1, 5028, []), - ('cfloat64.tif', 1, 5028, []), - ('rgbsmall.tif', 1, 21212, [])] + ('byte.tif', 4672), + ('byte_signed.tif', 4672), + ('int16.tif', 4672), + ('uint16.tif', 4672), + ('int32.tif', 4672), + ('uint32.tif', 4672), + ('float32.tif', 4672), + ('float64.tif', 4672), + ('cint16.tif', 5028), + ('cint32.tif', 5028), + ('cfloat32.tif', 5028), + ('cfloat64.tif', 5028), + ('rgbsmall.tif', 21212)] ############################################################################### # Verify we have the driver. @@ -264,16 +265,18 @@ def gta_5(): return 'success' -for item in init_list: - if item[0] == 'byte_signed.tif': - filename = item[0] - else: - filename = '../../gcore/data/' + item[0] - ut = gdaltest.GDALTest('GTA', filename, item[1], item[2], options=item[3]) - if ut is None: - print('GTA tests skipped') - sys.exit() - gdaltest_list.append((ut.testCreateCopy, item[0])) +@pytest.mark.parametrize( + 'filename,checksum', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.require_driver('GTA') +def test_gta_create(filename, checksum): + if filename != 'byte_signed.tif': + filename = '../../gcore/data/' + filename + ut = gdaltest.GDALTest('GTA', filename, 1, checksum, options=[]) + ut.testCreateCopy() + gdaltest_list.append(gta_1) gdaltest_list.append(gta_2) diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index d8563e357bcb..42db3b34edac 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -3449,35 +3449,49 @@ def netcdf_uffd(): # basic file creation tests init_list = [ - ('byte.tif', 1, 4672, None, []), - ('byte_signed.tif', 1, 4672, None, ['PIXELTYPE=SIGNEDBYTE']), - ('int16.tif', 1, 4672, None, []), - ('int32.tif', 1, 4672, None, []), - ('float32.tif', 1, 4672, None, []), - ('float64.tif', 1, 4672, None, []) + ('byte.tif', 4672, []), + ('byte_signed.tif', 4672, ['PIXELTYPE=SIGNEDBYTE']), + ('int16.tif', 4672, []), + ('int32.tif', 4672, []), + ('float32.tif', 4672, []), + ('float64.tif', 4672, []) ] -# Some tests we don't need to do for each type. -item = init_list[0] -ut = gdaltest.GDALTest('netcdf', item[0], item[1], item[2], options=item[4]) -# test geotransform and projection -gdaltest_list.append((ut.testSetGeoTransform, item[0])) -gdaltest_list.append((ut.testSetProjection, item[0])) +# Some tests we don't need to do for each type. -# SetMetadata() not supported -# gdaltest_list.append( (ut.testSetMetadata, item[0]) ) +@pytest.mark.parametrize( + 'testfunction', [ + 'testSetGeoTransform', + 'testSetProjection', + # SetMetadata() not supported + # 'testSetMetadata' + ] +) +@pytest.mark.require_driver('netcdf') +def test_netcdf_functions_1(testfunction): + ut = gdaltest.GDALTest('netcdf', 'byte.tif', 1, 4672, options=[]) + getattr(ut, testfunction)() -# gdaltest_list = [ netcdf_1, netcdf_82 ] # Others we do for each pixel type. -for item in init_list: - ut = gdaltest.GDALTest('netcdf', item[0], item[1], item[2], options=item[4]) - if ut is None: - print('GTiff tests skipped') - gdaltest_list.append((ut.testCreateCopy, item[0])) - gdaltest_list.append((ut.testCreate, item[0])) - gdaltest_list.append((ut.testSetNoDataValue, item[0])) + +@pytest.mark.parametrize( + 'filename,checksum,options', + init_list, + ids=[tup[0].split('.')[0] for tup in init_list], +) +@pytest.mark.parametrize( + 'testfunction', [ + 'testCreateCopy', + 'testCreate', + 'testSetNoDataValue' + ] +) +@pytest.mark.require_driver('netcdf') +def test_netcdf_functions_2(filename, checksum, options, testfunction): + ut = gdaltest.GDALTest('netcdf', filename, 1, checksum, options=options) + getattr(ut, testfunction)() ############################################################################### # other tests diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index 7cf7b2fe68eb..9f035f713827 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -30,6 +30,7 @@ import os import sys +import pytest import gdaltest import ogrtest @@ -40,36 +41,39 @@ ############################################################################### -class gml_geom_unit(object): - def __init__(self, unit): - self.unit = unit - - def gml_geom(self): - raw_wkt = open('data/wkb_wkt/' + self.unit + '.wkt').read() +@pytest.mark.parametrize( + 'unit', + [ + f[:-4] for f in os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt')) + if f[-4:] == '.wkt' + ] +) +def test_gml_geom(unit): + raw_wkt = open('data/wkb_wkt/' + unit + '.wkt').read() - ###################################################################### - # Convert WKT to GML. + ###################################################################### + # Convert WKT to GML. - geom_wkt = ogr.CreateGeometryFromWkt(raw_wkt) + geom_wkt = ogr.CreateGeometryFromWkt(raw_wkt) - gml = geom_wkt.ExportToGML() + gml = geom_wkt.ExportToGML() - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + if gml is None or not gml: + gdaltest.post_reason('Conversion to GML failed.') + return 'fail' - ###################################################################### - # Create geometry from GML. + ###################################################################### + # Create geometry from GML. - geom_gml = ogr.CreateGeometryFromGML(gml) + geom_gml = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom_wkt, geom_gml, 0.0000000000001) == 1: - clean_wkt = geom_wkt.ExportToWkt() - gml_wkt = geom_gml.ExportToWkt() - gdaltest.post_reason('WKT from GML (%s) does not match clean WKT (%s).\ngml was (%s)' % (gml_wkt, clean_wkt, gml)) - return 'fail' + if ogrtest.check_feature_geometry(geom_wkt, geom_gml, 0.0000000000001) == 1: + clean_wkt = geom_wkt.ExportToWkt() + gml_wkt = geom_gml.ExportToWkt() + gdaltest.post_reason('WKT from GML (%s) does not match clean WKT (%s).\ngml was (%s)' % (gml_wkt, clean_wkt, gml)) + return 'fail' - return 'success' + return 'success' ############################################################################### # Test geometries with extra spaces at the end, as sometimes are generated @@ -2440,11 +2444,6 @@ def gml_write_gml_ns(): gdaltest_list = [] -files = os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt')) -for filename in files: - if filename[-4:] == '.wkt': - ut = gml_geom_unit(filename[:-4]) - gdaltest_list.append((ut.gml_geom, ut.unit)) gdaltest_list.append(gml_space_test) gdaltest_list.append(gml_pos_point) diff --git a/autotest/ogr/ogr_wkbwkt_geom.py b/autotest/ogr/ogr_wkbwkt_geom.py index 1daef0149608..a16fd49b7299 100755 --- a/autotest/ogr/ogr_wkbwkt_geom.py +++ b/autotest/ogr/ogr_wkbwkt_geom.py @@ -30,6 +30,7 @@ import os import sys +import pytest import gdaltest from osgeo import ogr @@ -38,46 +39,49 @@ ############################################################################### -class wkb_wkt_unit(object): - def __init__(self, unit): - self.unit = unit - - def wkbwkt_geom(self): - raw_wkb = open('data/wkb_wkt/' + self.unit + '.wkb', 'rb').read() - raw_wkt = open('data/wkb_wkt/' + self.unit + '.wkt').read() - - ###################################################################### - # Compare the WKT derived from the WKB file to the WKT provided - # but reformatted (normalized). - - geom_wkb = ogr.CreateGeometryFromWkb(raw_wkb) - wkb_wkt = geom_wkb.ExportToWkt() - - geom_wkt = ogr.CreateGeometryFromWkt(raw_wkt) - normal_wkt = geom_wkt.ExportToWkt() - - # print(wkb_wkt) - # print(normal_wkt) - # print(raw_wkt) - if wkb_wkt != normal_wkt: - gdaltest.post_reason('WKT from WKB (%s) does not match clean WKT (%s).' % (wkb_wkt, normal_wkt)) - return 'fail' +@pytest.mark.parametrize( + 'unit', + [ + f[:-4] for f in os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt')) + if f[-4:] == '.wkb' + ] +) +def test_wkbwkt_geom(unit): + raw_wkb = open('data/wkb_wkt/' + unit + '.wkb', 'rb').read() + raw_wkt = open('data/wkb_wkt/' + unit + '.wkt').read() + + ###################################################################### + # Compare the WKT derived from the WKB file to the WKT provided + # but reformatted (normalized). + + geom_wkb = ogr.CreateGeometryFromWkb(raw_wkb) + wkb_wkt = geom_wkb.ExportToWkt() + + geom_wkt = ogr.CreateGeometryFromWkt(raw_wkt) + normal_wkt = geom_wkt.ExportToWkt() + + # print(wkb_wkt) + # print(normal_wkt) + # print(raw_wkt) + if wkb_wkt != normal_wkt: + gdaltest.post_reason('WKT from WKB (%s) does not match clean WKT (%s).' % (wkb_wkt, normal_wkt)) + return 'fail' - ###################################################################### - # Verify that the geometries appear to be the same. This is - # intended to catch problems with the encoding too WKT that might - # cause passes above but that are mistaken. - if geom_wkb.GetCoordinateDimension() != geom_wkt.GetCoordinateDimension(): - gdaltest.post_reason('Coordinate dimension differs!') - return 'fail' + ###################################################################### + # Verify that the geometries appear to be the same. This is + # intended to catch problems with the encoding too WKT that might + # cause passes above but that are mistaken. + if geom_wkb.GetCoordinateDimension() != geom_wkt.GetCoordinateDimension(): + gdaltest.post_reason('Coordinate dimension differs!') + return 'fail' - if geom_wkb.GetGeometryType() != geom_wkt.GetGeometryType(): - gdaltest.post_reason('Geometry type differs!') - return 'fail' + if geom_wkb.GetGeometryType() != geom_wkt.GetGeometryType(): + gdaltest.post_reason('Geometry type differs!') + return 'fail' - if geom_wkb.GetGeometryName() != geom_wkt.GetGeometryName(): - gdaltest.post_reason('Geometry name differs!') - return 'fail' + if geom_wkb.GetGeometryName() != geom_wkt.GetGeometryName(): + gdaltest.post_reason('Geometry name differs!') + return 'fail' # It turns out this test is too picky about coordinate precision. skip. # if geom_wkb.Equal( geom_wkt ) == 0: @@ -86,35 +90,35 @@ def wkbwkt_geom(self): # print geom_wkt.ExportToWkt() # return 'fail' - geom_wkb.Destroy() + geom_wkb.Destroy() - ###################################################################### - # Convert geometry to WKB and back to verify that WKB encoding is - # working smoothly. + ###################################################################### + # Convert geometry to WKB and back to verify that WKB encoding is + # working smoothly. - wkb_xdr = geom_wkt.ExportToWkb(ogr.wkbXDR) - geom_wkb = ogr.CreateGeometryFromWkb(wkb_xdr) + wkb_xdr = geom_wkt.ExportToWkb(ogr.wkbXDR) + geom_wkb = ogr.CreateGeometryFromWkb(wkb_xdr) - if str(geom_wkb) != str(geom_wkt): - print(geom_wkb) - print(geom_wkt) - gdaltest.post_reason('XDR WKB encoding/decoding failure.') - return 'fail' + if str(geom_wkb) != str(geom_wkt): + print(geom_wkb) + print(geom_wkt) + gdaltest.post_reason('XDR WKB encoding/decoding failure.') + return 'fail' - geom_wkb.Destroy() + geom_wkb.Destroy() - wkb_ndr = geom_wkt.ExportToWkb(ogr.wkbNDR) - geom_wkb = ogr.CreateGeometryFromWkb(wkb_ndr) + wkb_ndr = geom_wkt.ExportToWkb(ogr.wkbNDR) + geom_wkb = ogr.CreateGeometryFromWkb(wkb_ndr) - if str(geom_wkb) != str(geom_wkt): - gdaltest.post_reason('NDR WKB encoding/decoding failure.') - return 'fail' + if str(geom_wkb) != str(geom_wkt): + gdaltest.post_reason('NDR WKB encoding/decoding failure.') + return 'fail' - geom_wkb.Destroy() + geom_wkb.Destroy() - geom_wkt.Destroy() + geom_wkt.Destroy() - return 'success' + return 'success' ############################################################################### # Test geometry with very large exponents of coordinate values. @@ -678,12 +682,6 @@ def ogr_wkt_multipolygon_corrupted(): gdaltest_list = [] -files = os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt')) -for filename in files: - if filename[-4:] == '.wkb': - ut = wkb_wkt_unit(filename[:-4]) - gdaltest_list.append((ut.wkbwkt_geom, ut.unit)) - gdaltest_list.append(ogr_wkbwkt_geom_bigexponents) gdaltest_list.append(ogr_wkbwkt_test_broken_geom) gdaltest_list.append(ogr_wkbwkt_test_import_wkt_sf12) diff --git a/autotest/osr/osr_ct_proj.py b/autotest/osr/osr_ct_proj.py index 21652be4e08b..55f6eab7a37d 100755 --- a/autotest/osr/osr_ct_proj.py +++ b/autotest/osr/osr_ct_proj.py @@ -31,114 +31,14 @@ ############################################################################### import os -import sys +import pytest import gdaltest from osgeo import osr, gdal bonne = 'PROJCS["bonne",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["bonne"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",60.0],UNIT["Meter",1.0]]' -############################################################################### -# Class to perform the tests. - - -class ProjTest(object): - def __init__(self, src_srs, src_xyz, src_error, - dst_srs, dst_xyz, dst_error, options, requirements): - self.src_srs = src_srs - self.src_xyz = src_xyz - self.src_error = src_error - self.dst_srs = dst_srs - self.dst_xyz = dst_xyz - self.dst_error = dst_error - self.options = options - self.requirements = requirements - - def testProj(self): - - import osr_ct - osr_ct.osr_ct_1() - if gdaltest.have_proj4 == 0: - return 'skip' - - if self.requirements is not None and self.requirements[:5] == 'GRID:': - proj_lib = os.getenv('PROJ_LIB') - if proj_lib is None: - # print( 'PROJ_LIB unset, skipping test.' ) - return 'skip' - - try: - open(proj_lib + '/' + self.requirements[5:]) - except IOError: - # print( 'Did not find GRID:%s' % self.requirements[5:] ) - return 'skip' - - src = osr.SpatialReference() - if src.SetFromUserInput(self.src_srs) != 0: - gdaltest.post_reason('SetFromUserInput(%s) failed.' % self.src_srs) - return 'fail' - - dst = osr.SpatialReference() - if dst.SetFromUserInput(self.dst_srs) != 0: - gdaltest.post_reason('SetFromUserInput(%s) failed.' % self.dst_srs) - return 'fail' - - if self.requirements is not None and self.requirements[0] != 'G': - additionnal_error_str = ' Check that proj version is >= %s ' % self.requirements - else: - additionnal_error_str = '' - - try: - gdal.PushErrorHandler('CPLQuietErrorHandler') - ct = osr.CoordinateTransformation(src, dst) - gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('Unable to load PROJ.4') != -1: - gdaltest.post_reason('PROJ.4 missing, transforms not available.') - return 'skip' - except ValueError: - gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('Unable to load PROJ.4') != -1: - gdaltest.post_reason('PROJ.4 missing, transforms not available.') - return 'skip' - gdaltest.post_reason('failed to create coordinate transformation. %s' % gdal.GetLastErrorMsg()) - return 'fail' - except: - gdal.PopErrorHandler() - gdaltest.post_reason('failed to create coordinate transformation. %s' % gdal.GetLastErrorMsg()) - return 'fail' - - ###################################################################### - # Transform source point to destination SRS. - - result = ct.TransformPoint(self.src_xyz[0], self.src_xyz[1], self.src_xyz[2]) - - error = abs(result[0] - self.dst_xyz[0]) \ - + abs(result[1] - self.dst_xyz[1]) \ - + abs(result[2] - self.dst_xyz[2]) - - if error > self.dst_error: - gdaltest.post_reason('Dest error is %g, got (%.15g,%.15g,%.15g)%s' - % (error, result[0], result[1], result[2], additionnal_error_str)) - return 'fail' - - ###################################################################### - # Now transform back. - - ct = osr.CoordinateTransformation(dst, src) - - result = ct.TransformPoint(result[0], result[1], result[2]) - - error = abs(result[0] - self.src_xyz[0]) \ - + abs(result[1] - self.src_xyz[1]) \ - + abs(result[2] - self.src_xyz[2]) - - if error > self.src_error: - gdaltest.post_reason('Back to source error is %g.%s' % (error, additionnal_error_str)) - return 'fail' - - return 'success' - ############################################################################### # Table of transformations, inputs and expected results (with a threshold) # @@ -232,18 +132,93 @@ def testProj(self): ############################################################################### # When imported build a list of units based on the files available. -gdaltest_list = [] -for item in transform_list: - ut = ProjTest(item[0], item[1], item[2], - item[3], item[4], item[5], - item[7], item[8]) - gdaltest_list.append((ut.testProj, item[6])) +@pytest.mark.parametrize( + 'src_srs,src_xyz,src_error,dst_srs,dst_xyz,dst_error,unit_name,options,requirements', + transform_list, + ids=[row[6] for row in transform_list] +) +def test_proj(src_srs, src_xyz, src_error, + dst_srs, dst_xyz, dst_error, unit_name, options, requirements): + + import osr_ct + osr_ct.osr_ct_1() + if gdaltest.have_proj4 == 0: + return 'skip' + + if requirements is not None and requirements[:5] == 'GRID:': + proj_lib = os.getenv('PROJ_LIB') + if proj_lib is None: + # print( 'PROJ_LIB unset, skipping test.' ) + return 'skip' + + try: + open(proj_lib + '/' + requirements[5:]) + except IOError: + # print( 'Did not find GRID:%s' % requirements[5:] ) + return 'skip' + + src = osr.SpatialReference() + if src.SetFromUserInput(src_srs) != 0: + gdaltest.post_reason('SetFromUserInput(%s) failed.' % src_srs) + return 'fail' + + dst = osr.SpatialReference() + if dst.SetFromUserInput(dst_srs) != 0: + gdaltest.post_reason('SetFromUserInput(%s) failed.' % dst_srs) + return 'fail' + + if requirements is not None and requirements[0] != 'G': + additionnal_error_str = ' Check that proj version is >= %s ' % requirements + else: + additionnal_error_str = '' + + try: + gdal.PushErrorHandler('CPLQuietErrorHandler') + ct = osr.CoordinateTransformation(src, dst) + gdal.PopErrorHandler() + if gdal.GetLastErrorMsg().find('Unable to load PROJ.4') != -1: + gdaltest.post_reason('PROJ.4 missing, transforms not available.') + return 'skip' + except ValueError: + gdal.PopErrorHandler() + if gdal.GetLastErrorMsg().find('Unable to load PROJ.4') != -1: + gdaltest.post_reason('PROJ.4 missing, transforms not available.') + return 'skip' + gdaltest.post_reason('failed to create coordinate transformation. %s' % gdal.GetLastErrorMsg()) + return 'fail' + except: + gdal.PopErrorHandler() + gdaltest.post_reason('failed to create coordinate transformation. %s' % gdal.GetLastErrorMsg()) + return 'fail' + + ###################################################################### + # Transform source point to destination SRS. + + result = ct.TransformPoint(src_xyz[0], src_xyz[1], src_xyz[2]) + + error = abs(result[0] - dst_xyz[0]) \ + + abs(result[1] - dst_xyz[1]) \ + + abs(result[2] - dst_xyz[2]) + + if error > dst_error: + gdaltest.post_reason('Dest error is %g, got (%.15g,%.15g,%.15g)%s' + % (error, result[0], result[1], result[2], additionnal_error_str)) + return 'fail' + + ###################################################################### + # Now transform back. + + ct = osr.CoordinateTransformation(dst, src) -if __name__ == '__main__': + result = ct.TransformPoint(result[0], result[1], result[2]) - gdaltest.setup_run('osr_ct_proj') + error = abs(result[0] - src_xyz[0]) \ + + abs(result[1] - src_xyz[1]) \ + + abs(result[2] - src_xyz[2]) - gdaltest.run_tests(gdaltest_list) + if error > src_error: + gdaltest.post_reason('Back to source error is %g.%s' % (error, additionnal_error_str)) + return 'fail' - sys.exit(gdaltest.summarize()) + return 'success' diff --git a/autotest/osr/osr_metacrs.py b/autotest/osr/osr_metacrs.py index 2f7d4fee1191..4f9638b99894 100755 --- a/autotest/osr/osr_metacrs.py +++ b/autotest/osr/osr_metacrs.py @@ -31,20 +31,26 @@ ############################################################################### import os -import sys import csv +import pytest import gdaltest from osgeo import osr, gdal + ############################################################################### -# Class to perform the tests. +# When imported build a list of units based on the files available. +csv_rows = list(csv.DictReader(open(os.path.join(os.path.dirname(__file__), 'data/Test_Data_File.csv'), 'rt'))) -class MetaCRSTest(object): - def __init__(self, test_line): + +class TestMetaCRS(object): + @pytest.mark.parametrize( + 'test_line', csv_rows, ids=[row['testName'] for row in csv_rows] + ) + def test_metacrs(self, test_line): self.test_line = test_line self.src_xyz = None self.dst_xyz = None @@ -52,59 +58,6 @@ def __init__(self, test_line): self.dst_srs = None self.dst_error = None - def parse_line(self): - test_line = self.test_line - - self.src_srs = self.build_srs(test_line['srcCrsAuth'], - test_line['srcCrs']) - try: - self.dst_srs = self.build_srs(test_line['tgtCrsAuth'], - test_line['tgtCrs']) - except: - # Old style - self.dst_srs = self.build_srs(test_line['tgtCrsType'], - test_line['tgtCrs']) - - if self.src_srs is None or self.dst_srs is None: - return 'fail' - - try: - self.src_xyz = (float(test_line['srcOrd1']), - float(test_line['srcOrd2']), - float(test_line['srcOrd3'])) - except: - self.src_xyz = (float(test_line['srcOrd1']), - float(test_line['srcOrd2']), - 0.0) - try: - self.dst_xyz = (float(test_line['tgtOrd1']), - float(test_line['tgtOrd2']), - float(test_line['tgtOrd3'])) - except: - self.dst_xyz = (float(test_line['tgtOrd1']), - float(test_line['tgtOrd2']), - 0.0) - try: - self.dst_error = max(float(test_line['tolOrd1']), - float(test_line['tolOrd2']), - float(test_line['tolOrd3'])) - except: - self.dst_error = max(float(test_line['tolOrd1']), - float(test_line['tolOrd2'])) - - return 'success' - - def build_srs(self, typ, crstext): - if typ == 'EPSG': - srs = osr.SpatialReference() - if srs.ImportFromEPSGA(int(crstext)) == 0: - return srs - gdaltest.post_reason('failed to translate EPSG:' + crstext) - return None - gdaltest.post_reason('unsupported srs type: ' + typ) - return None - - def testMetaCRS(self): result = self.parse_line() if result != 'success': return result @@ -162,23 +115,54 @@ def testMetaCRS(self): return 'fail' return 'success' + def parse_line(self): + test_line = self.test_line -############################################################################### -# When imported build a list of units based on the files available. - - -gdaltest_list = [] - -csv_reader = csv.DictReader(open(os.path.join(os.path.dirname(__file__), 'data/Test_Data_File.csv'), 'rt')) - -for test in csv_reader: - ut = MetaCRSTest(test) - gdaltest_list.append((ut.testMetaCRS, test['testName'])) + self.src_srs = self.build_srs(test_line['srcCrsAuth'], + test_line['srcCrs']) + try: + self.dst_srs = self.build_srs(test_line['tgtCrsAuth'], + test_line['tgtCrs']) + except: + # Old style + self.dst_srs = self.build_srs(test_line['tgtCrsType'], + test_line['tgtCrs']) -if __name__ == '__main__': + if self.src_srs is None or self.dst_srs is None: + return 'fail' - gdaltest.setup_run('osr_metacrs') + try: + self.src_xyz = (float(test_line['srcOrd1']), + float(test_line['srcOrd2']), + float(test_line['srcOrd3'])) + except: + self.src_xyz = (float(test_line['srcOrd1']), + float(test_line['srcOrd2']), + 0.0) + try: + self.dst_xyz = (float(test_line['tgtOrd1']), + float(test_line['tgtOrd2']), + float(test_line['tgtOrd3'])) + except: + self.dst_xyz = (float(test_line['tgtOrd1']), + float(test_line['tgtOrd2']), + 0.0) + try: + self.dst_error = max(float(test_line['tolOrd1']), + float(test_line['tolOrd2']), + float(test_line['tolOrd3'])) + except: + self.dst_error = max(float(test_line['tolOrd1']), + float(test_line['tolOrd2'])) - gdaltest.run_tests(gdaltest_list) + return 'success' - sys.exit(gdaltest.summarize()) + def build_srs(self, typ, crstext): + if typ == 'EPSG': + srs = osr.SpatialReference() + if srs.ImportFromEPSGA(int(crstext)) == 0: + return srs + gdaltest.post_reason('failed to translate EPSG:' + crstext) + return None + gdaltest.post_reason('unsupported srs type: ' + typ) + return None From e45ca89ac191163af32f28756ad69907f5bd38c6 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Fri, 5 Oct 2018 22:08:41 +1300 Subject: [PATCH 127/488] Manual fixes for a strange syntax error in the automation --- autotest/ogr/ogr_dxf.py | 2 +- autotest/osr/osr_metacrs.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/autotest/ogr/ogr_dxf.py b/autotest/ogr/ogr_dxf.py index 4f77d0329964..c415d7aa9e22 100644 --- a/autotest/ogr/ogr_dxf.py +++ b/autotest/ogr/ogr_dxf.py @@ -2487,7 +2487,7 @@ def ogr_dxf_33(): geom = feat.GetGeometryRef() if geom.GetGeometryType() != ogr.wkbPolyhedralSurfaceZ: - gdaltest.post_reason('did not get expected geometry type; got %s instead of wkbPolyhedralSurface', geom.GetGeometryType()) + gdaltest.post_reason('did not get expected geometry type; got %s instead of wkbPolyhedralSurface' % geom.GetGeometryType()) return 'fail' wkt_string = geom.ExportToIsoWkt() diff --git a/autotest/osr/osr_metacrs.py b/autotest/osr/osr_metacrs.py index 4f9638b99894..517cb4a32682 100755 --- a/autotest/osr/osr_metacrs.py +++ b/autotest/osr/osr_metacrs.py @@ -114,7 +114,6 @@ def test_metacrs(self, test_line): return 'fail' - return 'success' def parse_line(self): test_line = self.test_line @@ -155,8 +154,6 @@ def parse_line(self): self.dst_error = max(float(test_line['tolOrd1']), float(test_line['tolOrd2'])) - return 'success' - def build_srs(self, typ, crstext): if typ == 'EPSG': srs = osr.SpatialReference() From 06456cd5a1612b4ce4c4faac956fc033a39536e2 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Fri, 5 Oct 2018 22:39:18 +1300 Subject: [PATCH 128/488] Simplify gdaltest_list usage Easier for the automation to handle --- autotest/gcore/bmp_read.py | 7 +- autotest/gcore/envi_read.py | 4 +- autotest/gcore/hdf4_read.py | 26 ++- autotest/gcore/hfa_read.py | 6 +- autotest/gcore/tiff_read.py | 266 +++++++++++++++--------------- autotest/gcore/vrt_read.py | 1 - autotest/gdrivers/gta.py | 14 +- autotest/gdrivers/jpeg_profile.py | 13 +- autotest/gdrivers/mrf.py | 37 ++--- autotest/gdrivers/png_profile.py | 17 +- autotest/gdrivers/tiff_profile.py | 21 +-- autotest/ogr/ogr_cloudant.py | 19 +-- autotest/ogr/ogr_gml_geom.py | 126 +++++++------- autotest/ogr/ogr_wkbwkt_geom.py | 26 +-- autotest/ogr/ogr_wktempty.py | 4 +- 15 files changed, 277 insertions(+), 310 deletions(-) diff --git a/autotest/gcore/bmp_read.py b/autotest/gcore/bmp_read.py index da95e519a692..b73b81c5ea2b 100755 --- a/autotest/gcore/bmp_read.py +++ b/autotest/gcore/bmp_read.py @@ -32,10 +32,6 @@ import gdaltest -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] init_list = [ ('1bit.bmp', 200), @@ -77,8 +73,7 @@ def bmp_online_2(): return tst.testOpen() -gdaltest_list.append(bmp_online_1) -gdaltest_list.append(bmp_online_2) +gdaltest_list = [bmp_online_1, bmp_online_2] if __name__ == '__main__': diff --git a/autotest/gcore/envi_read.py b/autotest/gcore/envi_read.py index ef620ff044f1..51091916f214 100755 --- a/autotest/gcore/envi_read.py +++ b/autotest/gcore/envi_read.py @@ -57,8 +57,6 @@ def envi_1(): # When imported build a list of units based on the files available. -gdaltest_list = [] - init_list = [ ('byte.raw', 4672), ('int16.raw', 4672), @@ -83,7 +81,7 @@ def test_envi_open(filename, checksum): ut.testOpen() -gdaltest_list.append(envi_1) +gdaltest_list = [envi_1] if __name__ == '__main__': diff --git a/autotest/gcore/hdf4_read.py b/autotest/gcore/hdf4_read.py index 1ba71e4174c1..c6e3dcbf2737 100755 --- a/autotest/gcore/hdf4_read.py +++ b/autotest/gcore/hdf4_read.py @@ -33,10 +33,6 @@ import gdaltest from osgeo import gdal -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] init_list = [ ('byte_3.hdf', 4672), @@ -372,16 +368,18 @@ def hdf4_read_online_10(): return 'success' -gdaltest_list.append(hdf4_read_online_1) -gdaltest_list.append(hdf4_read_online_2) -gdaltest_list.append(hdf4_read_online_3) -gdaltest_list.append(hdf4_read_online_4) -gdaltest_list.append(hdf4_read_online_5) -gdaltest_list.append(hdf4_read_online_6) -gdaltest_list.append(hdf4_read_online_7) -gdaltest_list.append(hdf4_read_online_8) -gdaltest_list.append(hdf4_read_online_9) -gdaltest_list.append(hdf4_read_online_10) +gdaltest_list = [ + hdf4_read_online_1, + hdf4_read_online_2, + hdf4_read_online_3, + hdf4_read_online_4, + hdf4_read_online_5, + hdf4_read_online_6, + hdf4_read_online_7, + hdf4_read_online_8, + hdf4_read_online_9, + hdf4_read_online_10, +] if __name__ == '__main__': diff --git a/autotest/gcore/hfa_read.py b/autotest/gcore/hfa_read.py index f572ddb5ca0d..ebaafc433d58 100755 --- a/autotest/gcore/hfa_read.py +++ b/autotest/gcore/hfa_read.py @@ -35,10 +35,6 @@ from osgeo import gdal import gdaltest -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] init_list = [ ('byte.img', 4672), @@ -72,7 +68,7 @@ def hfa_read_completedefn_recursion(): return 'success' -gdaltest_list.append(hfa_read_completedefn_recursion) +gdaltest_list = [hfa_read_completedefn_recursion] if __name__ == '__main__': diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index 0b3c64222925..d6704c8c51ad 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -36,11 +36,6 @@ import gdaltest from osgeo import gdal, osr -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] - init_list = [ ('byte.tif', 1, 4672), ('uint16_sgilog.tif', 1, 4672), @@ -3868,136 +3863,137 @@ def tiff_read_overview_of_external_mask(): ############################################################################### -gdaltest_list.append(tiff_read_off) -gdaltest_list.append(tiff_check_alpha) -gdaltest_list.append(tiff_read_cmyk_rgba) -gdaltest_list.append(tiff_read_cmyk_raw) -gdaltest_list.append(tiff_read_ojpeg) -gdaltest_list.append(tiff_read_gzip) -gdaltest_list.append(tiff_read_zip_1) -gdaltest_list.append(tiff_read_zip_2) -gdaltest_list.append(tiff_read_zip_3) -gdaltest_list.append(tiff_read_zip_4) -gdaltest_list.append(tiff_read_zip_5) -gdaltest_list.append(tiff_read_tar_1) -gdaltest_list.append(tiff_read_tar_2) -gdaltest_list.append(tiff_read_tgz_1) -gdaltest_list.append(tiff_read_tgz_2) -gdaltest_list.append(tiff_grads) -gdaltest_list.append(tiff_citation) -gdaltest_list.append(tiff_linearparmunits) -gdaltest_list.append(tiff_linearparmunits2) -gdaltest_list.append(tiff_g4_split) -gdaltest_list.append(tiff_multi_images) -gdaltest_list.append(tiff_vsimem) -gdaltest_list.append(tiff_vsizip_and_mem) -gdaltest_list.append(tiff_ProjectedCSTypeGeoKey_only) -gdaltest_list.append(tiff_GTModelTypeGeoKey_only) -gdaltest_list.append(tiff_12bitjpeg) -gdaltest_list.append(tiff_read_stats_from_pam) -gdaltest_list.append(tiff_read_from_tab) -gdaltest_list.append(tiff_read_pixelispoint) -gdaltest_list.append(tiff_read_geomatrix) -gdaltest_list.append(tiff_read_corrupted_gtiff) -gdaltest_list.append(tiff_read_tag_without_null_byte) -gdaltest_list.append(tiff_read_buggy_packbits) -gdaltest_list.append(tiff_read_rpc_txt) -gdaltest_list.append(tiff_read_rpc_tif) -gdaltest_list.append(tiff_small) -gdaltest_list.append(tiff_dos_strip_chop) -gdaltest_list.append(tiff_read_exif_and_gps) -gdaltest_list.append(tiff_jpeg_rgba_pixel_interleaved) -gdaltest_list.append(tiff_jpeg_rgba_band_interleaved) -gdaltest_list.append(tiff_read_huge4GB) -gdaltest_list.append(tiff_read_bigtiff) -gdaltest_list.append(tiff_read_tiff_metadata) -gdaltest_list.append(tiff_read_irregular_tile_size_jpeg_in_tiff) -gdaltest_list.append(tiff_direct_and_virtual_mem_io) -gdaltest_list.append(tiff_read_empty_nodata_tag) -gdaltest_list.append(tiff_read_strace_check) -gdaltest_list.append(tiff_read_readdir_limit_on_open) -gdaltest_list.append(tiff_read_minisblack_as_rgba) -gdaltest_list.append(tiff_read_colortable_as_rgba) -gdaltest_list.append(tiff_read_logl_as_rgba) -gdaltest_list.append(tiff_read_strip_separate_as_rgba) -gdaltest_list.append(tiff_read_tiled_separate_as_rgba) -gdaltest_list.append(tiff_read_scanline_more_than_2GB) -gdaltest_list.append(tiff_read_wrong_number_extrasamples) -gdaltest_list.append(tiff_read_one_strip_no_bytecount) - -gdaltest_list.append(tiff_read_md1) -gdaltest_list.append(tiff_read_md2) -gdaltest_list.append(tiff_read_md3) -gdaltest_list.append(tiff_read_md4) -gdaltest_list.append(tiff_read_md5) -gdaltest_list.append(tiff_read_md6) -gdaltest_list.append(tiff_read_md7) -gdaltest_list.append(tiff_read_md8) -gdaltest_list.append(tiff_read_md9) -gdaltest_list.append(tiff_read_md10) -gdaltest_list.append(tiff_read_md11) -gdaltest_list.append(tiff_read_md12) - -gdaltest_list.append(tiff_read_nogeoref) -gdaltest_list.append(tiff_read_inconsistent_georef) -gdaltest_list.append(tiff_read_gcp_internal_and_auxxml) - -gdaltest_list.append(tiff_read_aux) - -gdaltest_list.append(tiff_read_one_band_from_two_bands) - -gdaltest_list.append(tiff_read_jpeg_cloud_optimized) -gdaltest_list.append(tiff_read_corrupted_jpeg_cloud_optimized) - -gdaltest_list.append(tiff_read_ycbcr_lzw) -gdaltest_list.append(tiff_read_ycbcr_int12) - -gdaltest_list.append(tiff_read_unit_from_srs) -gdaltest_list.append(tiff_read_arcgis93_geodataxform_gcp) -gdaltest_list.append(tiff_read_block_width_above_32bit) -gdaltest_list.append(tiff_read_image_width_above_32bit) -gdaltest_list.append(tiff_read_second_image_width_above_32bit) -gdaltest_list.append(tiff_read_minimum_tiff_tags_no_warning) -gdaltest_list.append(tiff_read_minimum_tiff_tags_with_warning) -gdaltest_list.append(tiff_read_unknown_compression) -gdaltest_list.append(tiff_read_leak_ZIPSetupDecode) -gdaltest_list.append(tiff_read_excessive_memory_TIFFFillStrip) -gdaltest_list.append(tiff_read_excessive_memory_TIFFFillStrip2) -gdaltest_list.append(tiff_read_excessive_memory_TIFFFillTile) -gdaltest_list.append(tiff_read_big_strip) -gdaltest_list.append(tiff_read_big_strip_chunky_way) -gdaltest_list.append(tiff_read_big_tile) -gdaltest_list.append(tiff_read_huge_tile) -gdaltest_list.append(tiff_read_huge_number_strips) -gdaltest_list.append(tiff_read_huge_implied_number_strips) -gdaltest_list.append(tiff_read_many_blocks) -gdaltest_list.append(tiff_read_many_blocks_truncated) -gdaltest_list.append(tiff_read_uint33) -gdaltest_list.append(tiff_read_corrupted_deflate_singlestrip) -gdaltest_list.append(tiff_read_packbits_not_enough_data) -gdaltest_list.append(tiff_read_toomanyblocks) -gdaltest_list.append(tiff_read_toomanyblocks_separate) -gdaltest_list.append(tiff_read_size_of_stripbytecount_lower_than_stripcount) -gdaltest_list.append(tiff_read_stripoffset_types) -gdaltest_list.append(tiff_read_progressive_jpeg_denial_of_service) -gdaltest_list.append(tiff_read_old_style_lzw) -gdaltest_list.append(tiff_read_mmap_interface) -gdaltest_list.append(tiff_read_jpeg_too_big_last_stripe) -gdaltest_list.append(tiff_read_negative_scaley) -gdaltest_list.append(tiff_read_zstd) -gdaltest_list.append(tiff_read_zstd_corrupted) -gdaltest_list.append(tiff_read_zstd_corrupted2) -gdaltest_list.append(tiff_read_1bit_2bands) -gdaltest_list.append(tiff_read_lerc) -gdaltest_list.append(tiff_read_overview_of_external_mask) - -gdaltest_list.append(tiff_read_online_1) -gdaltest_list.append(tiff_read_online_2) - -gdaltest_list.append((tiff_read_webp)) -gdaltest_list.append((tiff_read_webp_huge_single_strip)) - -# gdaltest_list = [ tiff_read_mmap_interface ] +gdaltest_list = [ + tiff_read_off, + tiff_check_alpha, + tiff_read_cmyk_rgba, + tiff_read_cmyk_raw, + tiff_read_ojpeg, + tiff_read_gzip, + tiff_read_zip_1, + tiff_read_zip_2, + tiff_read_zip_3, + tiff_read_zip_4, + tiff_read_zip_5, + tiff_read_tar_1, + tiff_read_tar_2, + tiff_read_tgz_1, + tiff_read_tgz_2, + tiff_grads, + tiff_citation, + tiff_linearparmunits, + tiff_linearparmunits2, + tiff_g4_split, + tiff_multi_images, + tiff_vsimem, + tiff_vsizip_and_mem, + tiff_ProjectedCSTypeGeoKey_only, + tiff_GTModelTypeGeoKey_only, + tiff_12bitjpeg, + tiff_read_stats_from_pam, + tiff_read_from_tab, + tiff_read_pixelispoint, + tiff_read_geomatrix, + tiff_read_corrupted_gtiff, + tiff_read_tag_without_null_byte, + tiff_read_buggy_packbits, + tiff_read_rpc_txt, + tiff_read_rpc_tif, + tiff_small, + tiff_dos_strip_chop, + tiff_read_exif_and_gps, + tiff_jpeg_rgba_pixel_interleaved, + tiff_jpeg_rgba_band_interleaved, + tiff_read_huge4GB, + tiff_read_bigtiff, + tiff_read_tiff_metadata, + tiff_read_irregular_tile_size_jpeg_in_tiff, + tiff_direct_and_virtual_mem_io, + tiff_read_empty_nodata_tag, + tiff_read_strace_check, + tiff_read_readdir_limit_on_open, + tiff_read_minisblack_as_rgba, + tiff_read_colortable_as_rgba, + tiff_read_logl_as_rgba, + tiff_read_strip_separate_as_rgba, + tiff_read_tiled_separate_as_rgba, + tiff_read_scanline_more_than_2GB, + tiff_read_wrong_number_extrasamples, + tiff_read_one_strip_no_bytecount, + + tiff_read_md1, + tiff_read_md2, + tiff_read_md3, + tiff_read_md4, + tiff_read_md5, + tiff_read_md6, + tiff_read_md7, + tiff_read_md8, + tiff_read_md9, + tiff_read_md10, + tiff_read_md11, + tiff_read_md12, + + tiff_read_nogeoref, + tiff_read_inconsistent_georef, + tiff_read_gcp_internal_and_auxxml, + + tiff_read_aux, + + tiff_read_one_band_from_two_bands, + + tiff_read_jpeg_cloud_optimized, + tiff_read_corrupted_jpeg_cloud_optimized, + + tiff_read_ycbcr_lzw, + tiff_read_ycbcr_int12, + + tiff_read_unit_from_srs, + tiff_read_arcgis93_geodataxform_gcp, + tiff_read_block_width_above_32bit, + tiff_read_image_width_above_32bit, + tiff_read_second_image_width_above_32bit, + tiff_read_minimum_tiff_tags_no_warning, + tiff_read_minimum_tiff_tags_with_warning, + tiff_read_unknown_compression, + tiff_read_leak_ZIPSetupDecode, + tiff_read_excessive_memory_TIFFFillStrip, + tiff_read_excessive_memory_TIFFFillStrip2, + tiff_read_excessive_memory_TIFFFillTile, + tiff_read_big_strip, + tiff_read_big_strip_chunky_way, + tiff_read_big_tile, + tiff_read_huge_tile, + tiff_read_huge_number_strips, + tiff_read_huge_implied_number_strips, + tiff_read_many_blocks, + tiff_read_many_blocks_truncated, + tiff_read_uint33, + tiff_read_corrupted_deflate_singlestrip, + tiff_read_packbits_not_enough_data, + tiff_read_toomanyblocks, + tiff_read_toomanyblocks_separate, + tiff_read_size_of_stripbytecount_lower_than_stripcount, + tiff_read_stripoffset_types, + tiff_read_progressive_jpeg_denial_of_service, + tiff_read_old_style_lzw, + tiff_read_mmap_interface, + tiff_read_jpeg_too_big_last_stripe, + tiff_read_negative_scaley, + tiff_read_zstd, + tiff_read_zstd_corrupted, + tiff_read_zstd_corrupted2, + tiff_read_1bit_2bands, + tiff_read_lerc, + tiff_read_overview_of_external_mask, + + tiff_read_online_1, + tiff_read_online_2, + + tiff_read_webp, + tiff_read_webp_huge_single_strip, +] + if __name__ == '__main__': diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index e1894cc73bc9..53b0cbc0b76f 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -44,7 +44,6 @@ ############################################################################### # When imported build a list of units based on the files available. -gdaltest_list = [] init_list = [ ('byte.vrt', 4672), diff --git a/autotest/gdrivers/gta.py b/autotest/gdrivers/gta.py index d9685d522e4c..1be1a356d050 100755 --- a/autotest/gdrivers/gta.py +++ b/autotest/gdrivers/gta.py @@ -36,8 +36,6 @@ from osgeo import gdal -gdaltest_list = [] - init_list = [ ('byte.tif', 4672), ('byte_signed.tif', 4672), @@ -278,11 +276,13 @@ def test_gta_create(filename, checksum): ut.testCreateCopy() -gdaltest_list.append(gta_1) -gdaltest_list.append(gta_2) -gdaltest_list.append(gta_3) -gdaltest_list.append(gta_4) -gdaltest_list.append(gta_5) +gdaltest_list = [ + gta_1, + gta_2, + gta_3, + gta_4, + gta_5, +] if __name__ == '__main__': diff --git a/autotest/gdrivers/jpeg_profile.py b/autotest/gdrivers/jpeg_profile.py index 13fe6982d721..c0bb8c7a77ba 100755 --- a/autotest/gdrivers/jpeg_profile.py +++ b/autotest/gdrivers/jpeg_profile.py @@ -38,11 +38,6 @@ import gdaltest from osgeo import gdal -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] - ############################################################################### # Test writing and reading of ICC profile in CreateCopy() @@ -215,9 +210,11 @@ def jpeg_copy_icc_64K(): ############################################################################################### -gdaltest_list.append(jpeg_copy_icc) -gdaltest_list.append(jpeg_copy_options_icc) -gdaltest_list.append(jpeg_copy_icc_64K) +gdaltest_list = [ + jpeg_copy_icc, + jpeg_copy_options_icc, + jpeg_copy_icc_64K, +] if __name__ == '__main__': diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index e15fa7385d13..355a13087d58 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -747,25 +747,24 @@ def mrf_cleanup(): return 'success' -gdaltest_list = [] - - -gdaltest_list += [mrf_overview_near_fact_2] -gdaltest_list += [mrf_overview_near_with_nodata_fact_2] -gdaltest_list += [mrf_overview_avg_fact_2] -gdaltest_list += [mrf_overview_avg_with_nodata_fact_2] -gdaltest_list += [mrf_overview_near_fact_3] -gdaltest_list += [mrf_overview_avg_fact_3] -gdaltest_list += [mrf_overview_avg_with_nodata_fact_3] -gdaltest_list += [mrf_overview_partial_block] -gdaltest_list += [mrf_overview_near_implicit_level] -gdaltest_list += [mrf_overview_external] -gdaltest_list += [mrf_lerc_nodata] -gdaltest_list += [mrf_lerc_with_huffman] -gdaltest_list += [mrf_cached_source] -gdaltest_list += [mrf_versioned] -gdaltest_list += [mrf_zen_test] -gdaltest_list += [mrf_cleanup] +gdaltest_list = [ + mrf_overview_near_fact_2, + mrf_overview_near_with_nodata_fact_2, + mrf_overview_avg_fact_2, + mrf_overview_avg_with_nodata_fact_2, + mrf_overview_near_fact_3, + mrf_overview_avg_fact_3, + mrf_overview_avg_with_nodata_fact_3, + mrf_overview_partial_block, + mrf_overview_near_implicit_level, + mrf_overview_external, + mrf_lerc_nodata, + mrf_lerc_with_huffman, + mrf_cached_source, + mrf_versioned, + mrf_zen_test, + mrf_cleanup, +] if __name__ == '__main__': diff --git a/autotest/gdrivers/png_profile.py b/autotest/gdrivers/png_profile.py index 30b64709e948..eccbf8182c99 100755 --- a/autotest/gdrivers/png_profile.py +++ b/autotest/gdrivers/png_profile.py @@ -38,11 +38,6 @@ import gdaltest from osgeo import gdal -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] - ############################################################################### # Test writing and reading of ICC profile in CreateCopy() @@ -365,11 +360,13 @@ def png_sRGB(): ############################################################################ -gdaltest_list.append(png_copy_icc) -gdaltest_list.append(png_copy_options_icc) -gdaltest_list.append(png_copy_options_colorimetric_data) -gdaltest_list.append(png_copy_colorimetric_data) -gdaltest_list.append(png_sRGB) +gdaltest_list = [ + png_copy_icc, + png_copy_options_icc, + png_copy_options_colorimetric_data, + png_copy_colorimetric_data, + png_sRGB, +] if __name__ == '__main__': diff --git a/autotest/gdrivers/tiff_profile.py b/autotest/gdrivers/tiff_profile.py index 5ec39e65ee60..8279108ce530 100755 --- a/autotest/gdrivers/tiff_profile.py +++ b/autotest/gdrivers/tiff_profile.py @@ -38,11 +38,6 @@ import gdaltest from osgeo import gdal -############################################################################### -# When imported build a list of units based on the files available. - -gdaltest_list = [] - ############################################################################### # Test writing and reading of ICC profile in Create() options @@ -519,13 +514,15 @@ def tiff_update_colorimetric(): ############################################################################ -gdaltest_list.append(tiff_write_icc) -gdaltest_list.append(tiff_copy_icc) -gdaltest_list.append(tiff_copy_options_icc) -gdaltest_list.append(tiff_copy_options_colorimetric_data) -gdaltest_list.append(tiff_copy_colorimetric_data) -gdaltest_list.append(tiff_update_icc) -gdaltest_list.append(tiff_update_colorimetric) +gdaltest_list = [ + tiff_write_icc, + tiff_copy_icc, + tiff_copy_options_icc, + tiff_copy_options_colorimetric_data, + tiff_copy_colorimetric_data, + tiff_update_icc, + tiff_update_colorimetric, +] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_cloudant.py b/autotest/ogr/ogr_cloudant.py index 443dd0ebc6f6..6b8eb8dced25 100755 --- a/autotest/ogr/ogr_cloudant.py +++ b/autotest/ogr/ogr_cloudant.py @@ -205,17 +205,14 @@ def ogr_cloudant_SetSpatialFilter(): return 'success' -if gdaltest.skip_on_travis(): - gdaltest_list = [] -else: - gdaltest_list = [ - ogr_cloudant_init, - ogr_cloudant_GetFeatureCount, - ogr_cloudant_GetNextFeature, - ogr_cloudant_GetSpatialRef, - ogr_cloudant_GetExtent, - ogr_cloudant_SetSpatialFilter - ] +gdaltest_list = [ + ogr_cloudant_init, + ogr_cloudant_GetFeatureCount, + ogr_cloudant_GetNextFeature, + ogr_cloudant_GetSpatialRef, + ogr_cloudant_GetExtent, + ogr_cloudant_SetSpatialFilter +] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index 9f035f713827..43b68000ae6a 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -2442,69 +2442,69 @@ def gml_write_gml_ns(): # sys.stdin.readline() -gdaltest_list = [] - - -gdaltest_list.append(gml_space_test) -gdaltest_list.append(gml_pos_point) -gdaltest_list.append(gml_pos_polygon) -gdaltest_list.append(gml_posList_line) -gdaltest_list.append(gml_posList_line3d) -gdaltest_list.append(gml_posList_line3d_2) -gdaltest_list.append(gml_polygon) -gdaltest_list.append(gml_out_point_srs) -gdaltest_list.append(gml_out_point3d_srs) -gdaltest_list.append(gml_out_linestring_srs) -gdaltest_list.append(gml_out_polygon_srs) -gdaltest_list.append(gml_out_multipoint_srs) -gdaltest_list.append(gml_out_multilinestring_srs) -gdaltest_list.append(gml_out_multipolygon_srs) -gdaltest_list.append(gml_out_geometrycollection_srs) -gdaltest_list.append(gml_Box) -gdaltest_list.append(gml_Envelope) -gdaltest_list.append(gml_Curve) -gdaltest_list.append(gml_Curve_with_pointProperty) -gdaltest_list.append(gml_MultiCurve) -gdaltest_list.append(gml_MultiSurface) -gdaltest_list.append(gml_MultiSurface_surfaceMembers) -gdaltest_list.append(gml_MultiCurve_curveMembers) -gdaltest_list.append(gml_MultiGeometry_geometryMembers) -gdaltest_list.append(gml_CompositeCurve_curveMembers) -gdaltest_list.append(gml_MultiCurve_pointMembers) -gdaltest_list.append(gml_Solid) -gdaltest_list.append(gml_OrientableSurface) -gdaltest_list.append(gml_Triangle) -gdaltest_list.append(gml_Rectangle) -gdaltest_list.append(gml_Tin) -gdaltest_list.append(gml_PolyhedralSurface) -gdaltest_list.append(gml_ConcatenatedDeduplication) -# gdaltest_list.append( gml_out_precision ) -gdaltest_list.append(gml_invalid_geoms) -gdaltest_list.append(gml_write_gml3_geometries) -gdaltest_list.append(gml_write_gml3_srs) -gdaltest_list.append(gml_nested) -gdaltest_list.append(gml_SimplePolygon) -gdaltest_list.append(gml_SimpleRectangle) -gdaltest_list.append(gml_SimpleTriangle) -gdaltest_list.append(gml_SimpleMultiPoint) -gdaltest_list.append(gml_CompositeCurveInRing) -gdaltest_list.append(gml_CompositeSurface_in_surfaceMembers) -gdaltest_list.append(gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing) -gdaltest_list.append(gml_Coordinates_ts_cs_decimal) -gdaltest_list.append(gml_with_xml_header_and_comments) -gdaltest_list.append(gml_srsDimension_topgeometry) -gdaltest_list.append(gml_Arc) -gdaltest_list.append(gml_ArcByBulge) -gdaltest_list.append(gml_ArcByCenterPoint) -gdaltest_list.append(gml_CompoundCurve_of_ArcByCenterPoint) -gdaltest_list.append(gml_CircleByCenterPoint) -gdaltest_list.append(gml_Circle) -gdaltest_list.append(gml_ArcString) -gdaltest_list.append(gml_OGRCompoundCurve) -gdaltest_list.append(gml_OGRCurvePolygon) -gdaltest_list.append(gml_OGRMultiSurface) -gdaltest_list.append(gml_OGRMultiCurve) -gdaltest_list.append(gml_write_gml_ns) +gdaltest_list = [ + gml_space_test, + gml_pos_point, + gml_pos_polygon, + gml_posList_line, + gml_posList_line3d, + gml_posList_line3d_2, + gml_polygon, + gml_out_point_srs, + gml_out_point3d_srs, + gml_out_linestring_srs, + gml_out_polygon_srs, + gml_out_multipoint_srs, + gml_out_multilinestring_srs, + gml_out_multipolygon_srs, + gml_out_geometrycollection_srs, + gml_Box, + gml_Envelope, + gml_Curve, + gml_Curve_with_pointProperty, + gml_MultiCurve, + gml_MultiSurface, + gml_MultiSurface_surfaceMembers, + gml_MultiCurve_curveMembers, + gml_MultiGeometry_geometryMembers, + gml_CompositeCurve_curveMembers, + gml_MultiCurve_pointMembers, + gml_Solid, + gml_OrientableSurface, + gml_Triangle, + gml_Rectangle, + gml_Tin, + gml_PolyhedralSurface, + gml_ConcatenatedDeduplication, + # gml_out_precision, + gml_invalid_geoms, + gml_write_gml3_geometries, + gml_write_gml3_srs, + gml_nested, + gml_SimplePolygon, + gml_SimpleRectangle, + gml_SimpleTriangle, + gml_SimpleMultiPoint, + gml_CompositeCurveInRing, + gml_CompositeSurface_in_surfaceMembers, + gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing, + gml_Coordinates_ts_cs_decimal, + gml_with_xml_header_and_comments, + gml_srsDimension_topgeometry, + gml_Arc, + gml_ArcByBulge, + gml_ArcByCenterPoint, + gml_CompoundCurve_of_ArcByCenterPoint, + gml_CircleByCenterPoint, + gml_Circle, + gml_ArcString, + gml_OGRCompoundCurve, + gml_OGRCurvePolygon, + gml_OGRMultiSurface, + gml_OGRMultiCurve, + gml_write_gml_ns, +] + if __name__ == '__main__': diff --git a/autotest/ogr/ogr_wkbwkt_geom.py b/autotest/ogr/ogr_wkbwkt_geom.py index a16fd49b7299..763a70d1ff87 100755 --- a/autotest/ogr/ogr_wkbwkt_geom.py +++ b/autotest/ogr/ogr_wkbwkt_geom.py @@ -680,19 +680,19 @@ def ogr_wkt_multipolygon_corrupted(): # sys.stdin.readline() -gdaltest_list = [] - -gdaltest_list.append(ogr_wkbwkt_geom_bigexponents) -gdaltest_list.append(ogr_wkbwkt_test_broken_geom) -gdaltest_list.append(ogr_wkbwkt_test_import_wkt_sf12) -gdaltest_list.append(ogr_wkbwkt_test_import_bad_multipoint_wkb) -gdaltest_list.append(ogr_wkbwkt_test_geometrycollection_wktwkb) -gdaltest_list.append(ogr_wkbwkt_test_geometrycollection_wkt_recursion) -gdaltest_list.append(ogr_wkbwkt_test_geometrycollection_wkb_recursion) -gdaltest_list.append(ogr_wkbwkt_export_wkt_iso_multipoint) -gdaltest_list.append(ogr_wkt_inf_nan) -gdaltest_list.append(ogr_wkt_multicurve_compoundcurve_corrupted) -gdaltest_list.append(ogr_wkt_multipolygon_corrupted) +gdaltest_list = [ + ogr_wkbwkt_geom_bigexponents, + ogr_wkbwkt_test_broken_geom, + ogr_wkbwkt_test_import_wkt_sf12, + ogr_wkbwkt_test_import_bad_multipoint_wkb, + ogr_wkbwkt_test_geometrycollection_wktwkb, + ogr_wkbwkt_test_geometrycollection_wkt_recursion, + ogr_wkbwkt_test_geometrycollection_wkb_recursion, + ogr_wkbwkt_export_wkt_iso_multipoint, + ogr_wkt_inf_nan, + ogr_wkt_multicurve_compoundcurve_corrupted, + ogr_wkt_multipolygon_corrupted, +] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_wktempty.py b/autotest/ogr/ogr_wktempty.py index 3e37eede4d19..4c429cd28122 100755 --- a/autotest/ogr/ogr_wktempty.py +++ b/autotest/ogr/ogr_wktempty.py @@ -150,9 +150,7 @@ def ogr_wktempty_test_partial_empty_geoms(): return 'success' -gdaltest_list = [] - -gdaltest_list.append(ogr_wktempty_test_partial_empty_geoms) +gdaltest_list = [ogr_wktempty_test_partial_empty_geoms] if __name__ == '__main__': From 0c7b2b34e8e3655bf34cc2c8aded94bf711f4cbe Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Wed, 17 Oct 2018 10:33:26 +1300 Subject: [PATCH 129/488] Remove some no-longer-necessary stuff from gdaltest module --- autotest/conftest.py | 9 +- autotest/pymod/gdaltest.py | 192 +------------------------------------ autotest/run_all.py | 76 --------------- 3 files changed, 13 insertions(+), 264 deletions(-) delete mode 100755 autotest/run_all.py diff --git a/autotest/conftest.py b/autotest/conftest.py index 75eebfef102e..15a7b9af9333 100644 --- a/autotest/conftest.py +++ b/autotest/conftest.py @@ -1,5 +1,5 @@ # coding: utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +from __future__ import absolute_import, division, print_function import os import sys @@ -15,6 +15,13 @@ # So we skip searching them during test collection. collect_ignore = ["gdrivers/netcdf_cfchecks.py"] +# we set ECW to not resolve projection and datum strings to get 3.x behavior. +gdal.SetConfigOption("ECW_DO_NOT_RESOLVE_DATUM_PROJECTION", "YES") + +if 'APPLY_LOCALE' in os.environ: + import locale + locale.setlocale(locale.LC_ALL, '') + @pytest.fixture(scope="module", autouse=True) def chdir_to_test_file(request): diff --git a/autotest/pymod/gdaltest.py b/autotest/pymod/gdaltest.py index 4f78f1b146de..05f346c1da6d 100644 --- a/autotest/pymod/gdaltest.py +++ b/autotest/pymod/gdaltest.py @@ -30,6 +30,7 @@ ############################################################################### import contextlib +import math import os import os.path import stat @@ -80,18 +81,6 @@ ############################################################################### -def setup_run(name): - - if 'APPLY_LOCALE' in os.environ: - import locale - locale.setlocale(locale.LC_ALL, '') - - global cur_name - cur_name = name - -############################################################################### - - def git_status(): out, _ = runexternal_out_and_err('git status --porcelain .') @@ -226,143 +215,6 @@ def post_reason(msg, frames=2): ############################################################################### -def summarize(): - global count_skipped_tests_download, count_skipped_tests_slow - global success_counter, failure_counter, blow_counter, skip_counter - global cur_name - global start_time, end_time - - print('') - if cur_name is not None: - print('Test Script: %s' % cur_name) - print('Succeeded: %d' % success_counter) - print('Failed: %d (%d blew exceptions)' - % (failure_counter + blow_counter, blow_counter)) - print('Skipped: %d' % skip_counter) - print('Expected fail:%d' % expected_failure_counter) - if start_time is not None: - duration = end_time - start_time - if duration >= 60: - print('Duration: %02dm%02.1fs' % (duration / 60., duration % 60.)) - else: - print('Duration: %02.2fs' % duration) - if count_skipped_tests_download != 0: - print('As GDAL_DOWNLOAD_TEST_DATA environment variable is not defined or set to NO, %d tests relying on data to downloaded from the Web have been skipped' % count_skipped_tests_download) - if count_skipped_tests_slow != 0: - print('As GDAL_RUN_SLOW_TESTS environment variable is not defined or set to NO, %d "slow" tests have been skipped' % count_skipped_tests_slow) - print('') - - sys.path.append('gcore') - sys.path.append('../gcore') - import testnonboundtoswig - # Do it twice to ensure that cleanup routines properly do their jobs - for _ in range(2): - testnonboundtoswig.OSRCleanup() - testnonboundtoswig.GDALDestroyDriverManager() - testnonboundtoswig.OGRCleanupAll() - - return failure_counter + blow_counter - -############################################################################### - - -def run_all(dirlist, run_as_external=False): - - global start_time, end_time - global cur_name - - start_time = time.time() - - for dir_name in dirlist: - files = os.listdir(dir_name) - - old_path = sys.path - # We prepend '.' rather than append it, so that "import rasterio" - # imports our rasterio.py and not another famous external package. - sys.path = ['.'] + sys.path - - for filename in files: - if not filename.endswith('.py'): - continue - - # Do not use rstrip here since 'test_ogr2ogr_py.py'.rstrip('.py') returns 'test_ogr2ogr_' - module = filename[0:-len('.py')] - try: - wd = os.getcwd() - os.chdir(dir_name) - - # Even try to import as module in run_as_external case - # so as to be able to detect ImportError and skip them - exec("import " + module) - - if run_as_external: - - exec("%s.gdaltest_list" % module) - - python_exe = sys.executable - if sys.platform == 'win32': - python_exe = python_exe.replace('\\', '/') - - print('Running %s/%s...' % (dir_name, filename)) - if 'GDALTEST_ASAN_OPTIONS' in os.environ: - if 'ASAN_OPTIONS' in os.environ: - backup_asan_options = os.environ['ASAN_OPTIONS'] - else: - backup_asan_options = None - os.environ['ASAN_OPTIONS'] = os.environ['GDALTEST_ASAN_OPTIONS'] - ret = runexternal(python_exe + """ -c "import %s; import sys; sys.path.append('../pymod'); import gdaltest; gdaltest.run_tests( %s.gdaltest_list ); gdaltest.summarize()" """ % (module, module), display_live_on_parent_stdout=True) - if 'GDALTEST_ASAN_OPTIONS' in os.environ: - if backup_asan_options is None: - del os.environ['ASAN_OPTIONS'] - else: - os.environ['ASAN_OPTIONS'] = backup_asan_options - - global success_counter, failure_counter, failure_summary - if ret.find('Failed: 0') < 0: - failure_counter += 1 - failure_summary.append(dir_name + '/' + filename) - else: - success_counter += 1 - else: - try: - print('Running tests from %s/%s' % (dir_name, filename)) - setup_run('%s/%s' % (dir_name, filename)) - exec("run_tests( " + module + ".gdaltest_list)") - except KeyboardInterrupt: - raise - except: - # import traceback - # traceback.print_exc(file=sys.stderr) - pass - - os.chdir(wd) - - except KeyboardInterrupt: - raise - except: - os.chdir(wd) - print('... failed to load %s ... skipping.' % filename) - - import traceback - traceback.print_exc() - - # We only add the tool directory to the python path long enough - # to load the tool files. - sys.path = old_path - - end_time = time.time() - cur_name = None - - if failure_summary: - print('') - print(' ------------ Failures ------------') - for item in failure_summary: - print(item) - print(' ----------------------------------') - -############################################################################### - - def clean_tmp(): all_files = os.listdir('tmp') for filename in all_files: @@ -373,7 +225,6 @@ def clean_tmp(): os.remove('tmp/' + filename) except OSError: pass - return 'success' ############################################################################### @@ -776,8 +627,6 @@ def testCreateCopy(self, check_minmax=1, check_gt=0, check_srs=None, if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON' and delete_copy == 1: self.driver.Delete(new_filename) - return 'success' - def testCreate(self, vsimem=0, new_filename=None, out_bands=1, check_minmax=1, dest_open_options=None): if self.testDriver() == 'fail': @@ -864,8 +713,6 @@ def testCreate(self, vsimem=0, new_filename=None, out_bands=1, if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def testSetGeoTransform(self): if self.testDriver() == 'fail': return 'skip' @@ -919,8 +766,6 @@ def testSetGeoTransform(self): if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def testSetProjection(self, prj=None, expected_prj=None): if self.testDriver() == 'fail': return 'skip' @@ -984,8 +829,6 @@ def testSetProjection(self, prj=None, expected_prj=None): if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def testSetMetadata(self): if self.testDriver() == 'fail': return 'skip' @@ -1037,8 +880,6 @@ def testSetMetadata(self): if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def testSetNoDataValue(self, delete=False): if self.testDriver() == 'fail': return 'skip' @@ -1101,8 +942,6 @@ def testSetNoDataValue(self, delete=False): if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def testSetNoDataValueAndDelete(self): return self.testSetNoDataValue(delete=True) @@ -1147,8 +986,6 @@ def testSetDescription(self): if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def testSetUnitType(self): if self.testDriver() == 'fail': return 'skip' @@ -1196,8 +1033,6 @@ def testSetUnitType(self): if gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON': self.driver.Delete(new_filename) - return 'success' - def approx_equal(a, b): a = float(a) @@ -1614,45 +1449,28 @@ def unzip(target_dir, zipfilename, verbose=False): return -############################################################################### -# Return if a number is the NaN number - - -def isnan(val): - return val != val +isnan = math.isnan ############################################################################### # Return NaN def NaN(): - try: - # Python >= 2.6 - return float('nan') - except NameError: - return 1e400 / 1e400 + return float('nan') ############################################################################### # Return positive infinity def posinf(): - try: - # Python >= 2.6 - return float('inf') - except NameError: - return 1e400 + return float('inf') ############################################################################### # Return negative infinity def neginf(): - try: - # Python >= 2.6 - return float('-inf') - except NameError: - return -1e400 + return float('-inf') ############################################################################### # Has the user requested to dowload test data diff --git a/autotest/run_all.py b/autotest/run_all.py deleted file mode 100755 index 3e3c8d8afe36..000000000000 --- a/autotest/run_all.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -############################################################################### -# $Id$ -# -# Project: GDAL/OGR Test Suite -# Purpose: High level test executive ... it runs sub test scripts. -# Author: Frank Warmerdam -# -############################################################################### -# Copyright (c) 2003, Frank Warmerdam -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -############################################################################### - -import sys -import os - -# Make sure we run from the directory of the script -if os.path.basename(sys.argv[0]) == os.path.basename(__file__): - if os.path.dirname(sys.argv[0]) != '': - os.chdir(os.path.dirname(sys.argv[0])) - -sys.path.append('pymod') -import gdaltest -from osgeo import gdal - -all_test_list = ['ogr', 'gcore', 'gdrivers', 'osr', 'alg', 'gnm', 'utilities', 'pyscripts'] - -run_as_external = False - -test_list = [] - -for arg in gdaltest.argv[1:]: - if arg == '-l': - print('List of GDAL Autotest modules') - for test in all_test_list: - print('* ' + test) - sys.exit(0) - elif arg == '-run_as_external': - run_as_external = True - elif arg == '-h' or arg[0] == '-': - print('Usage: ' + sys.argv[0] + ' [OPTION]') - print('\t - list of test modules to run, run all if none specified') - print('\t-l - list available test modules') - print('\t-h - print this usage message') - print('\t-run_as_external - run each test script in a dedicated Python instance') - sys.exit(0) - else: - test_list.append(arg) - -if not test_list: - test_list = all_test_list - -# we set ECW to not resolve projection and datum strings to get 3.x behavior. -gdal.SetConfigOption("ECW_DO_NOT_RESOLVE_DATUM_PROJECTION", "YES") - -gdaltest.setup_run('gdalautotest_all') - -gdaltest.run_all(test_list, run_as_external=run_as_external) - -errors = gdaltest.summarize() - -sys.exit(errors) From 53a3850f4025a88dd9d4f71f281c8edfb8602705 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Fri, 19 Oct 2018 17:06:16 +1300 Subject: [PATCH 130/488] Add a script to setup virtualenv --- autotest/virtualenv-setup.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 autotest/virtualenv-setup.sh diff --git a/autotest/virtualenv-setup.sh b/autotest/virtualenv-setup.sh new file mode 100755 index 000000000000..b3124df127b2 --- /dev/null +++ b/autotest/virtualenv-setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -eu + +# install pip +curl https://bootstrap.pypa.io/get-pip.py | sudo -H python + +# install virtualenv +sudo -H pip install virtualenv + +virtualenv ~/venv +rm -f ~/venv/lib/python2.7/no-global-site-packages.txt + +~/venv/bin/pip install -Ur /vagrant/autotest/requirements.txt + +# Set things up for gdb: https://stackoverflow.com/a/30430059/988527 +sudo apt-get install -y python2.7-dbg +mkdir ~/venv/bin/.debug +ln -s /usr/lib/debug/usr/bin/python2.7-gdb.py ~/venv/bin/.debug/python-gdb.py +ln -s /usr/lib/debug/usr/bin/python2.7 ~/venv/bin/.debug/ + +echo " + +created virtualenv in ~/venv. To activate it: + source ~/venv/bin/activate +" From 235004d3e412c44d7860a4f6ec3465f6f38d0bda Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Fri, 26 Oct 2018 15:19:33 +1300 Subject: [PATCH 131/488] Fix weird comparison in tiff_ovr breaking condition inversion --- autotest/gcore/tiff_ovr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotest/gcore/tiff_ovr.py b/autotest/gcore/tiff_ovr.py index bc2c458658b9..4c404f22d4ec 100755 --- a/autotest/gcore/tiff_ovr.py +++ b/autotest/gcore/tiff_ovr.py @@ -797,7 +797,7 @@ def tiff_ovr_19(both_endian): ds.FlushCache() ds.BuildOverviews('NEAR', overviewlist=[2, 4]) - if ds.GetRasterBand(1).GetOverviewCount() != 2 is None: + if ds.GetRasterBand(1).GetOverviewCount() != 2: print('Overview could not be generated') return 'fail' From a56395f610fac4f1c7b9af90d2ef47272747fe69 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Mon, 29 Oct 2018 17:46:07 +1300 Subject: [PATCH 132/488] Update `with_and_without_postgis` to a pytest fixture in ogr_pg.py --- autotest/ogr/ogr_pg.py | 552 +++++++++++++++++------------------------ 1 file changed, 230 insertions(+), 322 deletions(-) diff --git a/autotest/ogr/ogr_pg.py b/autotest/ogr/ogr_pg.py index 0aba6cc522e7..7c7273963b77 100755 --- a/autotest/ogr/ogr_pg.py +++ b/autotest/ogr/ogr_pg.py @@ -31,6 +31,7 @@ import sys import shutil +import pytest import gdaltest import ogrtest @@ -38,6 +39,10 @@ from osgeo import osr from osgeo import gdal + +pytestmark = pytest.mark.require_driver('PostgreSQL') + + ############################################################################### # Return true if 'layer_name' is one of the reported layers of pg_ds @@ -59,11 +64,33 @@ def ogr_pg_check_layer_in_list(ds, layer_name): # ############################################################################### -# Open Database. +# Run gdaltest_list_internal with PostGIS enabled and then with PostGIS disabled + + +@pytest.fixture( + scope='module', + params=['postgis', 'no-postgis'], +) +def with_and_without_postgis(request): + test_ogr_pg_1() + if gdaltest.pg_ds is None: + return 'skip' + + with_postgis = request.param == 'postgis' + + if with_postgis and not gdaltest.pg_has_postgis: + pytest.skip() + + gdal.SetConfigOption("PG_USE_POSTGIS", 'YES' if with_postgis else 'NO') + yield with_postgis + gdal.SetConfigOption("PG_USE_POSTGIS", "YES") -def ogr_pg_1(): +############################################################################### +# Open Database. + +def test_ogr_pg_1(): gdaltest.pg_ds = None gdaltest.pg_use_copy = gdal.GetConfigOption('PG_USE_COPY', None) val = gdal.GetConfigOption('OGR_PG_CONNECTION_STRING', None) @@ -80,10 +107,6 @@ def ogr_pg_1(): # 7.4 # gdaltest.pg_connection_string='dbname=autotest port=5436 user=postgres' - gdaltest.pg_dr = ogr.GetDriverByName('PostgreSQL') - if gdaltest.pg_dr is None: - return 'skip' - try: gdal.PushErrorHandler('CPLQuietErrorHandler') gdaltest.pg_ds = ogr.Open('PG:' + gdaltest.pg_connection_string, update=1) @@ -142,7 +165,7 @@ def ogr_pg_1(): # Create table from data/poly.shp -def ogr_pg_2(): +def ogr_pg_2(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -233,11 +256,81 @@ def ogr_pg_2(): return 'success' + +############################################################################### +# Test reading a layer extent + + +def ogr_pg_19(with_and_without_postgis): + + if gdaltest.pg_ds is None: + return 'skip' + + layer = gdaltest.pg_ds.GetLayerByName('tpoly') + if layer is None: + gdaltest.post_reason('did not get tpoly layer') + return 'fail' + + extent = layer.GetExtent() + expect = (478315.53125, 481645.3125, 4762880.5, 4765610.5) + + minx = abs(extent[0] - expect[0]) + maxx = abs(extent[1] - expect[1]) + miny = abs(extent[2] - expect[2]) + maxy = abs(extent[3] - expect[3]) + + if max(minx, maxx, miny, maxy) > 0.0001: + gdaltest.post_reason('Extents do not match') + print(extent) + return 'fail' + + estimated_extent = layer.GetExtent(force=0) + if not gdaltest.pg_has_postgis: + # The OGRLayer default implementation in force = 0 returns error + if estimated_extent != (0, 0, 0, 0): + gdaltest.post_reason('Wrong estimated extent') + print(extent) + return 'fail' + else: + # Better testing needed ? + if estimated_extent == (0, 0, 0, 0): + gdaltest.post_reason('Wrong estimated extent') + print(extent) + return 'fail' + + return 'success' + +############################################################################### +# Test reading a SQL result layer extent + + +def ogr_pg_19_2(with_and_without_postgis): + + if gdaltest.pg_ds is None: + return 'skip' + + sql_lyr = gdaltest.pg_ds.ExecuteSQL('select * from tpoly') + + extent = sql_lyr.GetExtent() + expect = (478315.53125, 481645.3125, 4762880.5, 4765610.5) + + minx = abs(extent[0] - expect[0]) + maxx = abs(extent[1] - expect[1]) + miny = abs(extent[2] - expect[2]) + maxy = abs(extent[3] - expect[3]) + + if max(minx, maxx, miny, maxy) > 0.0001: + gdaltest.post_reason('Extents do not match') + return 'fail' + + gdaltest.pg_ds.ReleaseResultSet(sql_lyr) + + ############################################################################### # Verify that stuff we just wrote is still OK. -def ogr_pg_3(): +def ogr_pg_3(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -282,7 +375,7 @@ def ogr_pg_3(): # geometries are still OK. -def ogr_pg_4(): +def ogr_pg_4(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -327,7 +420,7 @@ def ogr_pg_4(): # Test ExecuteSQL() results layers without geometry. -def ogr_pg_5(): +def ogr_pg_5(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -350,7 +443,7 @@ def ogr_pg_5(): # Test ExecuteSQL() results layers with geometry. -def ogr_pg_6(): +def ogr_pg_6(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -388,7 +481,7 @@ def ogr_pg_6(): # Test spatial filtering. -def ogr_pg_7(): +def ogr_pg_7(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -428,7 +521,7 @@ def ogr_pg_7(): # No geometry in this test. -def ogr_pg_8(): +def ogr_pg_8(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -460,7 +553,7 @@ def ogr_pg_8(): # Verify inplace update of a feature with SetFeature(). -def ogr_pg_9(): +def ogr_pg_9(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -536,7 +629,7 @@ def ogr_pg_9(): # Verify that DeleteFeature() works properly. -def ogr_pg_10(): +def ogr_pg_10(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -572,7 +665,7 @@ def ogr_pg_10(): # Create table from data/poly.shp in INSERT mode. -def ogr_pg_11(): +def ogr_pg_11(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -626,7 +719,7 @@ def ogr_pg_11(): # Verify that stuff we just wrote is still OK. -def ogr_pg_12(): +def ogr_pg_12(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -658,7 +751,7 @@ def ogr_pg_12(): # Create a table with some date fields. -def ogr_pg_13(): +def ogr_pg_13(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -695,7 +788,7 @@ def ogr_pg_13(): # Fetch in several timezones to test our timezone processing. -def ogr_pg_14(): +def ogr_pg_14(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -760,7 +853,7 @@ def ogr_pg_14(): # Test very large query. -def ogr_pg_15(): +def ogr_pg_15(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -783,7 +876,7 @@ def ogr_pg_15(): ############################################################################### # Test very large statement. -def ogr_pg_16(): +def ogr_pg_16(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -809,7 +902,7 @@ def ogr_pg_16(): # Test requesting a non-existent table by name (bug 1480). -def ogr_pg_17(): +def ogr_pg_17(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -834,7 +927,7 @@ def ogr_pg_17(): # Test getting a layer by name that was not previously a layer. -def ogr_pg_18(): +def ogr_pg_18(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -851,81 +944,12 @@ def ogr_pg_18(): return 'success' -############################################################################### -# Test reading a layer extent - - -def ogr_pg_19(): - - if gdaltest.pg_ds is None: - return 'skip' - - layer = gdaltest.pg_ds.GetLayerByName('tpoly') - if layer is None: - gdaltest.post_reason('did not get tpoly layer') - return 'fail' - - extent = layer.GetExtent() - expect = (478315.53125, 481645.3125, 4762880.5, 4765610.5) - - minx = abs(extent[0] - expect[0]) - maxx = abs(extent[1] - expect[1]) - miny = abs(extent[2] - expect[2]) - maxy = abs(extent[3] - expect[3]) - - if max(minx, maxx, miny, maxy) > 0.0001: - gdaltest.post_reason('Extents do not match') - print(extent) - return 'fail' - - estimated_extent = layer.GetExtent(force=0) - if not gdaltest.pg_has_postgis: - # The OGRLayer default implementation in force = 0 returns error - if estimated_extent != (0, 0, 0, 0): - gdaltest.post_reason('Wrong estimated extent') - print(extent) - return 'fail' - else: - # Better testing needed ? - if estimated_extent == (0, 0, 0, 0): - gdaltest.post_reason('Wrong estimated extent') - print(extent) - return 'fail' - - return 'success' - -############################################################################### -# Test reading a SQL result layer extent - - -def ogr_pg_19_2(): - - if gdaltest.pg_ds is None: - return 'skip' - - sql_lyr = gdaltest.pg_ds.ExecuteSQL('select * from tpoly') - - extent = sql_lyr.GetExtent() - expect = (478315.53125, 481645.3125, 4762880.5, 4765610.5) - - minx = abs(extent[0] - expect[0]) - maxx = abs(extent[1] - expect[1]) - miny = abs(extent[2] - expect[2]) - maxy = abs(extent[3] - expect[3]) - - if max(minx, maxx, miny, maxy) > 0.0001: - gdaltest.post_reason('Extents do not match') - return 'fail' - - gdaltest.pg_ds.ReleaseResultSet(sql_lyr) - - return 'success' ############################################################################### # Test reading 4-dim geometry in EWKT format -def ogr_pg_20(): +def ogr_pg_20(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -1013,7 +1037,7 @@ def ogr_pg_20(): # Test reading 4-dimension geometries in EWKB format -def ogr_pg_21(): +def ogr_pg_21(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -1047,7 +1071,7 @@ def ogr_pg_21(): # Check if the sub geometries of TIN and POLYHEDRALSURFACE are valid -def ogr_pg_21_subgeoms(): +def ogr_pg_21_subgeoms(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -1094,7 +1118,7 @@ def ogr_pg_21_subgeoms(): def ogr_pg_21_3d_geometries(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' gdaltest.pg_ds = ogr.Open('PG:' + gdaltest.pg_connection_string, update=1) @@ -1144,7 +1168,7 @@ def ogr_pg_21_3d_geometries(): # This test checks if schema support and schema name quoting works well. -def ogr_pg_22(): +def ogr_pg_22(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1203,18 +1227,18 @@ def ogr_pg_22(): # Create table with all data types -def ogr_pg_23(layer_name='datatypetest', include_timestamptz=True): +def ogr_pg_23(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' gdal.PushErrorHandler('CPLQuietErrorHandler') - gdaltest.pg_ds.ExecuteSQL('DELLAYER:' + layer_name) + gdaltest.pg_ds.ExecuteSQL('DELLAYER:datatypetest') gdal.PopErrorHandler() ###################################################### # Create Table - lyr = gdaltest.pg_ds.CreateLayer(layer_name) + lyr = gdaltest.pg_ds.CreateLayer('datatypetest') ###################################################### # Setup Schema @@ -1222,50 +1246,49 @@ def ogr_pg_23(layer_name='datatypetest', include_timestamptz=True): ###################################################### # add some custom date fields. - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_numeric numeric') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_numeric5 numeric(5)') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_numeric5_3 numeric(5,3)') - # gdaltest.pg_ds.ExecuteSQL( 'ALTER TABLE ' + layer_name + ' ADD COLUMN my_bool bool' ) + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_numeric numeric') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_numeric5 numeric(5)') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_numeric5_3 numeric(5,3)') + # gdaltest.pg_ds.ExecuteSQL( 'ALTER TABLE datatypetest ADD COLUMN my_bool bool' ) fld = ogr.FieldDefn('my_bool', ogr.OFTInteger) fld.SetSubType(ogr.OFSTBoolean) lyr.CreateField(fld) - # gdaltest.pg_ds.ExecuteSQL( 'ALTER TABLE ' + layer_name + ' ADD COLUMN my_int2 int2' ) + # gdaltest.pg_ds.ExecuteSQL( 'ALTER TABLE datatypetest ADD COLUMN my_int2 int2' ) fld = ogr.FieldDefn('my_int2', ogr.OFTInteger) fld.SetSubType(ogr.OFSTInt16) lyr.CreateField(fld) - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_int4 int4') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_int4 int4') lyr.CreateField(ogr.FieldDefn('my_int8', ogr.OFTInteger64)) - # gdaltest.pg_ds.ExecuteSQL( 'ALTER TABLE ' + layer_name + ' ADD COLUMN my_float4 float4' ) + # gdaltest.pg_ds.ExecuteSQL( 'ALTER TABLE datatypetest ADD COLUMN my_float4 float4' ) fld = ogr.FieldDefn('my_float4', ogr.OFTReal) fld.SetSubType(ogr.OFSTFloat32) lyr.CreateField(fld) - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_float8 float8') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_real real') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_char char') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_varchar character varying') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_varchar10 character varying(10)') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_text text') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_bytea bytea') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_time time') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_date date') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_timestamp timestamp without time zone') - if include_timestamptz: - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_timestamptz timestamp with time zone') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_chararray char(1)[]') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_textarray text[]') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_varchararray character varying[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_float8 float8') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_real real') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_char char') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_varchar character varying') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_varchar10 character varying(10)') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_text text') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_bytea bytea') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_time time') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_date date') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_timestamp timestamp without time zone') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_timestamptz timestamp with time zone') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_chararray char(1)[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_textarray text[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_varchararray character varying[]') fld = ogr.FieldDefn('my_int2array', ogr.OFTIntegerList) fld.SetSubType(ogr.OFSTInt16) lyr.CreateField(fld) - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_int4array int4[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_int4array int4[]') lyr.CreateField(ogr.FieldDefn('my_int8array', ogr.OFTInteger64List)) fld = ogr.FieldDefn('my_float4array', ogr.OFTRealList) fld.SetSubType(ogr.OFSTFloat32) lyr.CreateField(fld) - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_float8array float8[]') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_numericarray numeric[]') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_numeric5array numeric(5)[]') - gdaltest.pg_ds.ExecuteSQL('ALTER TABLE ' + layer_name + ' ADD COLUMN my_numeric5_3array numeric(5,3)[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_float8array float8[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_numericarray numeric[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_numeric5array numeric(5)[]') + gdaltest.pg_ds.ExecuteSQL('ALTER TABLE datatypetest ADD COLUMN my_numeric5_3array numeric(5,3)[]') fld = ogr.FieldDefn('my_boolarray', ogr.OFTIntegerList) fld.SetSubType(ogr.OFSTBoolean) lyr.CreateField(fld) @@ -1278,18 +1301,14 @@ def ogr_pg_23(layer_name='datatypetest', include_timestamptz=True): geom_str = "'\\\\001\\\\001\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000$@\\\\000\\\\000\\\\000\\\\000\\\\000\\\\0004@'" if gdaltest.pg_quote_with_E: geom_str = "E" + geom_str - sql = "INSERT INTO " + layer_name + " ( my_numeric, my_numeric5, my_numeric5_3, my_bool, my_int2, " + sql = "INSERT INTO datatypetest ( my_numeric, my_numeric5, my_numeric5_3, my_bool, my_int2, " sql += "my_int4, my_int8, my_float4, my_float8, my_real, my_char, my_varchar, " - sql += "my_varchar10, my_text, my_bytea, my_time, my_date, my_timestamp, " - if include_timestamptz: - sql += "my_timestamptz, " + sql += "my_varchar10, my_text, my_bytea, my_time, my_date, my_timestamp, my_timestamptz, " sql += "my_chararray, my_textarray, my_varchararray, my_int2array, my_int4array, " sql += "my_int8array, my_float4array, my_float8array, my_numericarray, my_numeric5array, my_numeric5_3array, my_boolarray, wkb_geometry) " sql += "VALUES ( 1.2, 12345, 0.123, 'T', 12345, 12345678, 1234567901234, 0.123, " sql += "0.12345678, 0.876, 'a', 'ab', 'varchar10 ', 'abc', 'xyz', '12:34:56', " - sql += "'2000-01-01', '2000-01-01 00:00:00', " - if include_timestamptz: - sql += "'2000-01-01 00:00:00+00', " + sql += "'2000-01-01', '2000-01-01 00:00:00', '2000-01-01 00:00:00+00', " sql += "'{a,b}', " sql += "'{aa,bb}', '{cc,dd}', '{100,200}', '{100,200}', '{1234567901234}', " sql += "'{100.1,200.1}', '{100.12,200.12}', ARRAY[100.12,200.12], ARRAY[10,20], ARRAY[10.12,20.12], '{1,0}', " + geom_str + " )" @@ -1300,7 +1319,7 @@ def ogr_pg_23(layer_name='datatypetest', include_timestamptz=True): ############################################################################### -def test_val_test_23(layer_defn, feat): +def check_value_23(layer_defn, feat): field_defn = layer_defn.GetFieldDefn(layer_defn.GetFieldIndex("my_numeric5")) if field_defn.GetWidth() != 5 or field_defn.GetPrecision() != 0 or field_defn.GetType() != ogr.OFTInteger: @@ -1398,7 +1417,7 @@ def test_val_test_23(layer_defn, feat): # Test with PG: connection -def ogr_pg_24(): +def ogr_pg_24(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1410,7 +1429,7 @@ def ogr_pg_24(): lyr = ds.GetLayerByName('datatypetest') feat = lyr.GetNextFeature() - if test_val_test_23(lyr.GetLayerDefn(), feat) != 'success': + if check_value_23(lyr.GetLayerDefn(), feat) != 'success': return 'fail' feat = None @@ -1423,7 +1442,7 @@ def ogr_pg_24(): # Test with PG: connection and SELECT query -def ogr_pg_25(): +def ogr_pg_25(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1435,7 +1454,7 @@ def ogr_pg_25(): sql_lyr = ds.ExecuteSQL('select * from datatypetest') feat = sql_lyr.GetNextFeature() - if test_val_test_23(sql_lyr.GetLayerDefn(), feat) != 'success': + if check_value_23(sql_lyr.GetLayerDefn(), feat) != 'success': return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -1446,85 +1465,11 @@ def ogr_pg_25(): return 'success' -############################################################################### -# Test with PGB: connection - - -def ogr_pg_26_DISABLED_AS_BINARY_CURSOR_NO_LONGER_SUPPORTED(): - - if gdaltest.pg_ds is None: - return 'skip' - - # The presence of timestamptz field currently disables binary cursor - if ogr_pg_23(layer_name='datatypetest_withouttimestamptz', include_timestamptz=False) != 'success': - return 'fail' - - ds = ogr.Open('PGB:' + gdaltest.pg_connection_string, update=1) - - ds.ExecuteSQL('set timezone to "UTC"') - - lyr = ds.GetLayerByName('datatypetest') - - feat = lyr.GetNextFeature() - if test_val_test_23(lyr.GetLayerDefn(), feat) != 'success': - return 'fail' - - feat = None - - lyr = ds.GetLayerByName('datatypetest_withouttimestamptz') - - feat = lyr.GetNextFeature() - if test_val_test_23(lyr.GetLayerDefn(), feat) != 'success': - return 'fail' - - feat = None - - ds = None - - return 'success' - -############################################################################### -# Test with PGB: connection and SELECT query - - -def ogr_pg_27_DISABLED_AS_BINARY_CURSOR_NO_LONGER_SUPPORTED(): - - if gdaltest.pg_ds is None: - return 'skip' - - ds = ogr.Open('PGB:' + gdaltest.pg_connection_string, update=1) - - ds.ExecuteSQL('set timezone to "UTC"') - - sql_lyr = ds.ExecuteSQL('select * from datatypetest') - - feat = sql_lyr.GetNextFeature() - if test_val_test_23(sql_lyr.GetLayerDefn(), feat) != 'success': - return 'fail' - - ds.ReleaseResultSet(sql_lyr) - - feat = None - - sql_lyr = ds.ExecuteSQL('select * from datatypetest_withouttimestamptz') - - feat = sql_lyr.GetNextFeature() - if test_val_test_23(sql_lyr.GetLayerDefn(), feat) != 'success': - return 'fail' - - ds.ReleaseResultSet(sql_lyr) - - feat = None - - ds = None - - return 'success' - ############################################################################### # Duplicate all data types in INSERT mode -def ogr_pg_28(): +def ogr_pg_28(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1575,7 +1520,7 @@ def ogr_pg_28(): # Test with PG: connection -def ogr_pg_29(): +def ogr_pg_29(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1588,7 +1533,7 @@ def ogr_pg_29(): # my_timestamp has now a time zone... feat = lyr.GetNextFeature() - if test_val_test_23(lyr.GetLayerDefn(), feat) != 'success': + if check_value_23(lyr.GetLayerDefn(), feat) != 'success': return 'fail' geom = feat.GetGeometryRef() @@ -1607,7 +1552,7 @@ def ogr_pg_29(): # Duplicate all data types in PG_USE_COPY mode -def ogr_pg_30(): +def ogr_pg_30(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1655,7 +1600,7 @@ def ogr_pg_30(): ############################################################################### # Test the tables= connection string option -def ogr_pg_31(): +def ogr_pg_31(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1696,7 +1641,7 @@ def ogr_pg_31(): # Test approximate srtext (#2123, #3508) -def ogr_pg_32(): +def ogr_pg_32(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -1837,7 +1782,7 @@ def ogr_pg_32(): # Test encoding as UTF8 -def ogr_pg_33(): +def ogr_pg_33(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1859,7 +1804,7 @@ def ogr_pg_33(): # Test encoding as Latin1 -def ogr_pg_34(): +def ogr_pg_34(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1868,14 +1813,14 @@ def ogr_pg_34(): # is not guaranteed to have effects on system not supporting putenv if sys.platform.startswith('linux'): os.environ['PGCLIENTENCODING'] = 'LATIN1' - ogr_pg_1() + test_ogr_pg_1() del os.environ['PGCLIENTENCODING'] # For some unknown reasons, some servers don't like forcing LATIN1 # but prefer LATIN9 instead... if gdaltest.pg_ds is None: os.environ['PGCLIENTENCODING'] = 'LATIN9' - ogr_pg_1() + test_ogr_pg_1() del os.environ['PGCLIENTENCODING'] else: gdaltest.pg_ds.ExecuteSQL('SET client_encoding = LATIN1') @@ -1897,7 +1842,7 @@ def ogr_pg_34(): ############################################################################### # Test for buffer overflows -def ogr_pg_35(): +def ogr_pg_35(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1929,7 +1874,7 @@ def ogr_pg_35(): # Test support for inherited tables : tables inherited from a Postgis Table -def ogr_pg_36(): +def ogr_pg_36(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -1984,7 +1929,7 @@ def ogr_pg_36(): return 'success' -def ogr_pg_36_bis(): +def ogr_pg_36_bis(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2010,7 +1955,7 @@ def ogr_pg_36_bis(): # Test support for inherited tables : Postgis table inherited from a non-Postgis table -def ogr_pg_37(): +def ogr_pg_37(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -2041,7 +1986,7 @@ def ogr_pg_37(): # Test support for multiple geometry columns (RFC 41) -def ogr_pg_38(): +def ogr_pg_38(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' @@ -2129,7 +2074,7 @@ def ogr_pg_38(): # Test support for named views -def ogr_pg_39(): +def ogr_pg_39(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2220,7 +2165,7 @@ def ogr_pg_39(): # Test GetFeature() with an invalid id -def ogr_pg_40(): +def ogr_pg_40(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2234,7 +2179,7 @@ def ogr_pg_40(): # Test active_schema= option -def ogr_pg_41(): +def ogr_pg_41(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2305,7 +2250,7 @@ def ogr_pg_41(): # Test schemas= option -def ogr_pg_42(): +def ogr_pg_42(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2370,7 +2315,7 @@ def ogr_pg_42(): ############################################################################### # Test schemas= option -def ogr_pg_43(): +def ogr_pg_43(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2407,7 +2352,7 @@ def ogr_pg_43(): # Test for table and column names that need quoting (#2945) -def ogr_pg_44(): +def ogr_pg_44(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2455,7 +2400,7 @@ def ogr_pg_44(): # Test SetNextByIndex (#3117) -def ogr_pg_45(): +def ogr_pg_45(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2489,7 +2434,7 @@ def ogr_pg_45(): # with SetFeature() -def ogr_pg_46(): +def ogr_pg_46(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2551,7 +2496,7 @@ def ogr_pg_46(): # Test that we can handle 'geography' column type introduced in PostGIS 1.5 -def ogr_pg_47(): +def ogr_pg_47(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2668,7 +2613,7 @@ def ogr_pg_47(): # PostGIS DB. -def ogr_pg_48(): +def ogr_pg_48(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2753,7 +2698,7 @@ def ogr_pg_48(): # Go on with previous test but set PGSQL_OGR_FID this time -def ogr_pg_49(): +def ogr_pg_49(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2784,7 +2729,7 @@ def ogr_pg_49(): # This tests writing using COPY and INSERT -def ogr_pg_50(): +def ogr_pg_50(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2853,7 +2798,7 @@ def ogr_pg_50(): # Run test_ogrsf -def ogr_pg_51(): +def ogr_pg_51(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2874,7 +2819,7 @@ def ogr_pg_51(): # Run test_ogrsf with -sql -def ogr_pg_52(): +def ogr_pg_52(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2895,7 +2840,7 @@ def ogr_pg_52(): # Test creating a layer with explicitly wkbNone geometry type. -def ogr_pg_53(): +def ogr_pg_53(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -2956,7 +2901,7 @@ def ogr_pg_53(): # Check that we can overwrite a non-spatial geometry table (#4012) -def ogr_pg_53_bis(): +def ogr_pg_53_bis(with_and_without_postgis): import test_cli_utilities if test_cli_utilities.get_ogr2ogr_path() is None: return 'skip' @@ -2981,7 +2926,7 @@ def ogr_pg_53_bis(): # Test reading AsEWKB() -def ogr_pg_54(): +def ogr_pg_54(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3006,7 +2951,7 @@ def ogr_pg_54(): # Test reading geoms as Base64 encoded strings -def ogr_pg_55(): +def ogr_pg_55(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3039,7 +2984,7 @@ def ogr_pg_55(): # non-spatial table and without FID in COPY mode (#4040) -def ogr_pg_56(): +def ogr_pg_56(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3128,7 +3073,7 @@ def ogr_pg_56(): # Test inserting an empty feature -def ogr_pg_57(): +def ogr_pg_57(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3148,7 +3093,7 @@ def ogr_pg_57(): # Test RFC35 -def ogr_pg_58(): +def ogr_pg_58(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3209,7 +3154,7 @@ def ogr_pg_58(): # but which is not the layer name. -def ogr_pg_59(): +def ogr_pg_59(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3239,7 +3184,7 @@ def ogr_pg_59(): # non-incrementing PK. -def ogr_pg_60(): +def ogr_pg_60(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3277,7 +3222,7 @@ def ogr_pg_60(): # Test insertion of features with FID set in COPY mode (#4495) -def ogr_pg_61(): +def ogr_pg_61(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3325,7 +3270,7 @@ def ogr_pg_61(): # Test ExecuteSQL() and getting SRID of the request (#4699) -def ogr_pg_62(): +def ogr_pg_62(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3360,7 +3305,7 @@ def ogr_pg_62(): # Test COLUMN_TYPES layer creation option (#4788) -def ogr_pg_63(): +def ogr_pg_63(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3405,7 +3350,7 @@ def ogr_pg_63(): # Test OGR_TRUNCATE config. option (#5091) -def ogr_pg_64(): +def ogr_pg_64(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3448,7 +3393,7 @@ def ogr_pg_64(): # Test RFC 41 -def ogr_pg_65(): +def ogr_pg_65(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3610,7 +3555,7 @@ def ogr_pg_65(): # Run test_ogrsf -def ogr_pg_66(): +def ogr_pg_66(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3634,7 +3579,7 @@ def ogr_pg_66(): # Test retrieving SRID from values (#5131) -def ogr_pg_67(): +def ogr_pg_67(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3685,7 +3630,7 @@ def ogr_pg_67(): # Test retrieving SRID from values even if we don't have select rights on geometry_columns (#5131) -def ogr_pg_68(): +def ogr_pg_68(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3743,7 +3688,7 @@ def has_run_load_tables(ds): return int(ds.GetMetadataItem("bHasLoadTables", "_DEBUG_")) -def ogr_pg_69(): +def ogr_pg_69(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3786,7 +3731,7 @@ def ogr_pg_69(): # Test historical non-differed creation of tables (#5547) -def ogr_pg_70(): +def ogr_pg_70(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3848,7 +3793,7 @@ def ogr_pg_70(): # Test interoperability of WKT/WKB with PostGIS. -def ogr_pg_71(): +def ogr_pg_71(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -3985,7 +3930,7 @@ def ogr_pg_71(): # Test 64 bit FID -def ogr_pg_72(): +def ogr_pg_72(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -4054,7 +3999,7 @@ def ogr_pg_72(): # Test not nullable fields -def ogr_pg_73(): +def ogr_pg_73(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -4163,7 +4108,7 @@ def ogr_pg_73(): # Test default values -def ogr_pg_74(): +def ogr_pg_74(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -4335,7 +4280,7 @@ def ogr_pg_74(): # Test creating a field with the fid name -def ogr_pg_75(): +def ogr_pg_75(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -4456,7 +4401,7 @@ def ogr_pg_76_get_transaction_state(ds): int(ds.GetMetadataItem("bUserTransactionActive", "_DEBUG_"))) -def ogr_pg_76(): +def ogr_pg_76(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -4624,7 +4569,7 @@ def ogr_pg_76_scenario1(lyr1, lyr2): # Scenario 2 : a CreateFeature done in the middle of GetNextFeature(), themselves between a user transaction -def ogr_pg_76_scenario2(lyr1, lyr2): +def ogr_pg_76_scenario2(lyr1, lyr2with_and_without_postgis): if gdaltest.pg_ds.StartTransaction() != 0: gdaltest.post_reason('fail') @@ -4758,7 +4703,7 @@ def ogr_pg_76_scenario2(lyr1, lyr2): # Scenario 3 : StartTransaction(), GetNextFeature(), CommitTransaction(), GetNextFeature() -def ogr_pg_76_scenario3(lyr1, lyr2): +def ogr_pg_76_scenario3(lyr1, lyr2with_and_without_postgis): if gdaltest.pg_ds.StartTransaction() != 0: gdaltest.post_reason('fail') @@ -4823,7 +4768,7 @@ def ogr_pg_76_scenario3(lyr1, lyr2): # Scenario 4 : GetNextFeature(), StartTransaction(), CreateFeature(), CommitTransaction(), GetNextFeature(), ResetReading() -def ogr_pg_76_scenario4(lyr1, lyr2): +def ogr_pg_76_scenario4(lyr1, lyr2with_and_without_postgis): (lastcmd, level, savepoint, usertransac) = ogr_pg_76_get_transaction_state(gdaltest.pg_ds) if (lastcmd, level, savepoint, usertransac) != ('', 0, 0, 0): @@ -4931,7 +4876,7 @@ def ogr_pg_76_scenario4(lyr1, lyr2): # Test ogr2ogr can insert multiple layers at once -def ogr_pg_77(): +def ogr_pg_77(with_and_without_postgis): import test_cli_utilities if test_cli_utilities.get_ogr2ogr_path() is None: return 'skip' @@ -4989,7 +4934,7 @@ def ogr_pg_77(): # Test manually added geometry constraints -def ogr_pg_78(): +def ogr_pg_78(with_and_without_postgis): if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis_2: return 'skip' @@ -5087,7 +5032,7 @@ def ogr_pg_78(): # Test PRELUDE_STATEMENTS and CLOSING_STATEMENTS open options -def ogr_pg_79(): +def ogr_pg_79(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -5173,7 +5118,7 @@ def ogr_pg_79(): def ogr_pg_80(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' gdal.ErrorReset() @@ -5194,7 +5139,7 @@ def ogr_pg_80(): def ogr_pg_81(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' gdaltest.pg_ds.ReleaseResultSet(gdaltest.pg_ds.ExecuteSQL("create table ogr_pg_81_1(id varchar unique, foo varchar); SELECT AddGeometryColumn('ogr_pg_81_1','dummy',-1,'POINT',2);")) @@ -5243,7 +5188,7 @@ def ogr_pg_81(): def ogr_pg_82(): - if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' lyr = gdaltest.pg_ds.CreateLayer('ogr_pg_82', geom_type=ogr.wkbNone, options=['GEOMETRY_NAME=another_name']) @@ -5261,7 +5206,7 @@ def ogr_pg_82(): def ogr_pg_83(): - if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None or not gdaltest.pg_has_postgis: return 'skip' tests = [[ogr.wkbUnknown, [], 'POINT ZM (1 2 3 4)', 'POINT (1 2)'], @@ -5330,7 +5275,7 @@ def ogr_pg_83(): def ogr_pg_84(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' ds = ogr.Open('PG:' + gdaltest.pg_connection_string, update=1) @@ -5411,7 +5356,7 @@ def ogr_pg_84(): def ogr_pg_85(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' gdaltest.pg_ds.CreateLayer('ogr_pg_85_1') @@ -5472,7 +5417,7 @@ def ogr_pg_85(): def ogr_pg_86(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' old_val = gdal.GetConfigOption('PG_USE_COPY') @@ -5515,7 +5460,7 @@ def ogr_pg_86(): def ogr_pg_87(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' lyr = gdaltest.pg_ds.CreateLayer('ogr_pg_87') @@ -5550,7 +5495,7 @@ def ogr_pg_87(): def ogr_pg_json(): - if gdaltest.pg_ds is None or gdaltest.ogr_pg_second_run: + if gdaltest.pg_ds is None: return 'skip' lyr = gdaltest.pg_ds.CreateLayer('ogr_pg_json') @@ -5584,7 +5529,7 @@ def ogr_pg_json(): # -def ogr_pg_table_cleanup(): +def ogr_pg_table_cleanup(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -5663,7 +5608,7 @@ def ogr_pg_table_cleanup(): return 'success' -def ogr_pg_cleanup(): +def ogr_pg_cleanup(with_and_without_postgis): if gdaltest.pg_ds is None: return 'skip' @@ -5679,7 +5624,7 @@ def ogr_pg_cleanup(): # NOTE: The ogr_pg_19 intentionally executed after ogr_pg_2 -gdaltest_list_internal = [ +gdaltest_list = [ ogr_pg_table_cleanup, ogr_pg_2, ogr_pg_19, @@ -5708,12 +5653,9 @@ def ogr_pg_cleanup(): ogr_pg_23, ogr_pg_24, ogr_pg_25, - # ogr_pg_26, - # ogr_pg_27, ogr_pg_28, ogr_pg_29, ogr_pg_30, - ogr_pg_29, ogr_pg_31, ogr_pg_32, ogr_pg_33, @@ -5777,40 +5719,6 @@ def ogr_pg_cleanup(): ogr_pg_cleanup ] -disabled_gdaltest_list_internal = [ - ogr_pg_table_cleanup, - ogr_pg_json, - ogr_pg_cleanup] - -############################################################################### -# Run gdaltest_list_internal with PostGIS enabled and then with PostGIS disabled - - -def ogr_pg_with_and_without_postgis(): - - gdaltest.ogr_pg_second_run = False - gdaltest.run_tests([ogr_pg_1]) - if gdaltest.pg_ds is None: - return 'skip' - # gdaltest.run_tests( [ ogr_pg_71 ] ) - # gdaltest.run_tests( [ ogr_pg_cleanup ] ) - if True: # pylint: disable=using-constant-test - gdaltest.run_tests(gdaltest_list_internal) - - if gdaltest.pg_has_postgis: - gdal.SetConfigOption("PG_USE_POSTGIS", "NO") - gdaltest.ogr_pg_second_run = True - gdaltest.run_tests([ogr_pg_1]) - gdaltest.run_tests(gdaltest_list_internal) - gdal.SetConfigOption("PG_USE_POSTGIS", "YES") - gdaltest.ogr_pg_second_run = False - - return 'success' - - -gdaltest_list = [ - ogr_pg_with_and_without_postgis -] if __name__ == '__main__': From 19b48ca2c3ee62677aefe8959559197cd6d26be1 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Tue, 6 Nov 2018 12:38:48 +1300 Subject: [PATCH 133/488] Fix builds on OSX --- autotest/gcore/hfa_rfc40.py | 34 ++++++++++++++++++---------- gdal/ci/travis/osx/before_install.sh | 3 +-- gdal/ci/travis/osx/script.sh | 3 ++- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/autotest/gcore/hfa_rfc40.py b/autotest/gcore/hfa_rfc40.py index 0042476918d0..2366b3c20ecd 100755 --- a/autotest/gcore/hfa_rfc40.py +++ b/autotest/gcore/hfa_rfc40.py @@ -31,23 +31,33 @@ ############################################################################### import sys -import numpy from osgeo import gdal +import pytest import gdaltest -INT_DATA = numpy.array([197, 83, 46, 29, 1, 78, 23, 90, 12, 45]) -DOUBLE_DATA = numpy.array([0.1, 43.2, 78.1, 9.9, 23.0, 0.92, 82.5, 0.0, 1.0, 99.0]) -STRING_DATA = numpy.array(["sddf", "wess", "grbgr", "dewd", "ddww", "qwsqw", - "gbfgbf", "wwqw3", "e", ""]) -STRING_DATA_INTS = numpy.array(["197", "83", "46", "29", "1", "78", - "23", "90", "12", "45"]) -STRING_DATA_DOUBLES = numpy.array(["0.1", "43.2", "78.1", "9.9", "23.0", "0.92", - "82.5", "0.0", "1.0", "99.0"]) -LONG_STRING_DATA = numpy.array(["sdfsdfsdfs", "sdweddw", "sdewdweee", "3423dedd", - "jkejjjdjd", "edcdcdcdc", "fcdkmk4m534m", "edwededdd", - "dedwedew", "wdedefrfrfrf"]) +try: + import numpy + array = numpy.array +except ImportError: + numpy = None + array = list + +pytestmark = pytest.mark.skipif(numpy is None, reason="numpy not available") + + +INT_DATA = array([197, 83, 46, 29, 1, 78, 23, 90, 12, 45]) +DOUBLE_DATA = array([0.1, 43.2, 78.1, 9.9, 23.0, 0.92, 82.5, 0.0, 1.0, 99.0]) +STRING_DATA = array(["sddf", "wess", "grbgr", "dewd", "ddww", "qwsqw", + "gbfgbf", "wwqw3", "e", ""]) +STRING_DATA_INTS = array(["197", "83", "46", "29", "1", "78", + "23", "90", "12", "45"]) +STRING_DATA_DOUBLES = array(["0.1", "43.2", "78.1", "9.9", "23.0", "0.92", + "82.5", "0.0", "1.0", "99.0"]) +LONG_STRING_DATA = array(["sdfsdfsdfs", "sdweddw", "sdewdweee", "3423dedd", + "jkejjjdjd", "edcdcdcdc", "fcdkmk4m534m", "edwededdd", + "dedwedew", "wdedefrfrfrf"]) class HFATestError(Exception): diff --git a/gdal/ci/travis/osx/before_install.sh b/gdal/ci/travis/osx/before_install.sh index 7ef1badf6851..bc0656647160 100755 --- a/gdal/ci/travis/osx/before_install.sh +++ b/gdal/ci/travis/osx/before_install.sh @@ -4,5 +4,4 @@ set -e brew update brew uninstall postgis gdal -brew install sqlite3 -brew install ccache +brew install sqlite3 ccache diff --git a/gdal/ci/travis/osx/script.sh b/gdal/ci/travis/osx/script.sh index d18f90e9bd73..df2adccaaf4d 100755 --- a/gdal/ci/travis/osx/script.sh +++ b/gdal/ci/travis/osx/script.sh @@ -5,9 +5,10 @@ set -e export PYTHONPATH=$PWD/gdal/swig/python/build/lib.macosx-10.12-intel-2.7:$PWD/gdal/swig/python/build/lib.macosx-10.11-x86_64-2.7 export PYTEST="pytest -v -p no:sugar --color=no" -# CPP unit tests +echo 'Running CPP unit tests' (cd autotest/cpp && GDAL_SKIP=JP2ECW make quick_test) +echo 'Running Python unit tests' # install test dependencies sudo -H pip install -U -r autotest/requirements.txt From 1cdd430d2b6e6bf64a911f5e4a319aceaaf85a4b Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Thu, 29 Nov 2018 16:36:41 +1300 Subject: [PATCH 134/488] Manual fixes for wfs/csw tests --- autotest/ogr/ogr_csw.py | 79 +----- autotest/ogr/ogr_wfs.py | 526 +++++++++++++--------------------------- 2 files changed, 171 insertions(+), 434 deletions(-) diff --git a/autotest/ogr/ogr_csw.py b/autotest/ogr/ogr_csw.py index b86252f88cee..4a1ff2cc8417 100755 --- a/autotest/ogr/ogr_csw.py +++ b/autotest/ogr/ogr_csw.py @@ -31,6 +31,7 @@ import sys +import pytest import gdaltest from osgeo import ogr @@ -40,18 +41,12 @@ # Test underlying OGR drivers # +pytestmark = pytest.mark.require_driver('CSW') -def ogr_csw_init(): - - gdaltest.csw_drv = None - - try: - gdaltest.csw_drv = ogr.GetDriverByName('CSW') - except: - pass - if gdaltest.csw_drv is None: - return 'skip' +@pytest.fixture(autouse=True, scope='module') +def ogr_csw_init(): + gdaltest.csw_drv = ogr.GetDriverByName('CSW') gml_ds = ogr.Open('data/ionic_wfs.gml') if gml_ds is None: @@ -67,10 +62,8 @@ def ogr_csw_init(): # Test reading a pyCSW server -def ogr_csw_pycsw(): - if gdaltest.csw_drv is None: - return 'skip' - +@pytest.mark.skip() +def test_ogr_csw_pycsw(): ds = ogr.Open('CSW:http://catalog.data.gov/csw') if ds is None: if gdaltest.gdalurlopen('http://catalog.data.gov/csw') is None: @@ -90,10 +83,6 @@ def ogr_csw_pycsw(): def ogr_csw_vsimem_fail_because_not_enabled(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() @@ -105,10 +94,6 @@ def ogr_csw_vsimem_fail_because_not_enabled(): ############################################################################### def ogr_csw_vsimem_fail_because_no_get_capabilities(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.PushErrorHandler() @@ -123,10 +108,6 @@ def ogr_csw_vsimem_fail_because_no_get_capabilities(): def ogr_csw_vsimem_fail_because_empty_response(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -148,10 +129,6 @@ def ogr_csw_vsimem_fail_because_empty_response(): def ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -173,10 +150,6 @@ def ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): def ogr_csw_vsimem_fail_because_exception(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -198,10 +171,6 @@ def ogr_csw_vsimem_fail_because_exception(): def ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -223,10 +192,6 @@ def ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): def ogr_csw_vsimem_fail_because_missing_version(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -250,10 +215,6 @@ def ogr_csw_vsimem_fail_because_missing_version(): def ogr_csw_vsimem_csw_minimal_instance(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') # Invalid response, but enough for use @@ -573,10 +534,6 @@ def ogr_csw_vsimem_csw_minimal_instance(): def ogr_csw_vsimem_csw_output_schema_csw(): - - if gdaltest.csw_drv is None: - return 'skip' - ds = gdal.OpenEx('CSW:/vsimem/csw_endpoint', open_options=['OUTPUT_SCHEMA=CSW']) lyr = ds.GetLayer(0) @@ -638,10 +595,6 @@ def ogr_csw_vsimem_csw_output_schema_csw(): def ogr_csw_vsimem_csw_output_schema_gmd(): - - if gdaltest.csw_drv is None: - return 'skip' - ds = gdal.OpenEx('CSW:/vsimem/csw_endpoint', open_options=['OUTPUT_SCHEMA=GMD']) lyr = ds.GetLayer(0) @@ -684,10 +637,6 @@ def ogr_csw_vsimem_csw_output_schema_gmd(): def ogr_csw_vsimem_csw_output_schema_fgdc(): - - if gdaltest.csw_drv is None: - return 'skip' - ds = gdal.OpenEx('CSW:/vsimem/csw_endpoint', open_options=['OUTPUT_SCHEMA=http://www.opengis.net/cat/csw/csdgm']) lyr = ds.GetLayer(0) @@ -732,10 +681,6 @@ def ogr_csw_vsimem_csw_output_schema_fgdc(): def ogr_csw_vsimem_cleanup(): - - if gdaltest.csw_drv is None: - return 'skip' - gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', None) for f in gdal.ReadDir('/vsimem/'): @@ -744,11 +689,7 @@ def ogr_csw_vsimem_cleanup(): return 'success' -gdaltest_live_list = [ - ogr_csw_pycsw -] - -gdaltest_vsimem_list = [ +gdaltest_list = [ ogr_csw_vsimem_fail_because_not_enabled, ogr_csw_vsimem_fail_because_no_get_capabilities, ogr_csw_vsimem_fail_because_empty_response, @@ -763,10 +704,6 @@ def ogr_csw_vsimem_cleanup(): ogr_csw_vsimem_cleanup, ] -gdaltest_list = [ogr_csw_init] -gdaltest_list += gdaltest_vsimem_list -# gdaltest_list += gdaltest_live_list - if __name__ == '__main__': gdaltest.setup_run('ogr_csw') diff --git a/autotest/ogr/ogr_wfs.py b/autotest/ogr/ogr_wfs.py index 748973331744..4859ee5554c2 100755 --- a/autotest/ogr/ogr_wfs.py +++ b/autotest/ogr/ogr_wfs.py @@ -35,8 +35,8 @@ from http.server import BaseHTTPRequestHandler import os -import sys +import pytest import gdaltest import ogrtest @@ -44,19 +44,19 @@ from osgeo import osr from osgeo import gdal import webserver +from osr import osr_ct ############################################################################### # Test underlying OGR drivers # -def ogr_wfs_init(): +pytestmark = pytest.mark.require_driver('WFS') - gdaltest.wfs_drv = None +@pytest.fixture(autouse=True, scope='module') +def ogr_wfs_init(): gdaltest.wfs_drv = ogr.GetDriverByName('WFS') - if gdaltest.wfs_drv is None: - return 'skip' gdaltest.geoserver_wfs = None gdaltest.deegree_wfs = None @@ -66,17 +66,22 @@ def ogr_wfs_init(): if gml_ds is None: gdaltest.wfs_drv = None if gdal.GetLastErrorMsg().find('Xerces') != -1: - return 'skip' - gdaltest.post_reason('failed to open test file.') - return 'skip' + pytest.skip() + pytest.skip('failed to open test file.') + + +@pytest.fixture(params=['NO', None], scope='module') +def with_and_without_streaming(request): + with gdaltest.config_option('OGR_WFS_USE_STREAMING', request.param): + yield - return 'success' ############################################################################### # Test reading a MapServer WFS server -def ogr_wfs_mapserver(): +@pytest.mark.skip() +def test_ogr_wfs_mapserver(): if gdaltest.wfs_drv is None: return 'skip' @@ -128,7 +133,8 @@ def ogr_wfs_mapserver(): ############################################################################### # Test reading a GeoServer WFS server -def ogr_wfs_geoserver(): +@pytest.mark.skip('FIXME: re-enable after adapting test') +def test_ogr_wfs_geoserver(): if gdaltest.wfs_drv is None: return 'skip' @@ -251,7 +257,8 @@ def ogr_wfs_geoserver(): # Test reading a GeoServer WFS server with OUTPUTFORMAT=json -def ogr_wfs_geoserver_json(): +@pytest.mark.skip('FIXME: re-enable after adapting test') +def test_ogr_wfs_geoserver_json(): if gdaltest.wfs_drv is None: return 'skip' @@ -298,7 +305,8 @@ def ogr_wfs_geoserver_json(): ############################################################################### # Test reading a GeoServer WFS server with OUTPUTFORMAT=SHAPE-ZIP -def ogr_wfs_geoserver_shapezip(): +@pytest.mark.skip('FIXME: re-enable after adapting test') +def test_ogr_wfs_geoserver_shapezip(): if gdaltest.wfs_drv is None: return 'skip' @@ -345,7 +353,8 @@ def ogr_wfs_geoserver_shapezip(): # Test WFS paging -def ogr_wfs_geoserver_paging(): +@pytest.mark.skip('FIXME: re-enable after adapting test') +def test_ogr_wfs_geoserver_paging(): if gdaltest.wfs_drv is None: return 'skip' @@ -416,7 +425,8 @@ def ogr_wfs_geoserver_paging(): # Test reading a Deegree WFS server -def ogr_wfs_deegree(): +@pytest.mark.skip() +def test_ogr_wfs_deegree(): if gdaltest.wfs_drv is None: return 'skip' @@ -481,7 +491,8 @@ def ogr_wfs_deegree(): # Run test_ogrsf -def ogr_wfs_test_ogrsf(): +@pytest.mark.skip() +def test_ogr_wfs_test_ogrsf(): if gdaltest.wfs_drv is None: return 'skip' @@ -561,7 +572,7 @@ def do_GET(self): # Test reading a local fake WFS server -def ogr_wfs_fake_wfs_server(): +def test_ogr_wfs_fake_wfs_server(): if gdaltest.wfs_drv is None: return 'skip' @@ -610,7 +621,8 @@ def ogr_wfs_fake_wfs_server(): # Test CreateFeature() / UpdateFeature() / DeleteFeature() (WFS-T) -def ogr_wfs_geoserver_wfst(): +@pytest.mark.skip('FIXME: re-enable after adapting test') +def test_ogr_wfs_geoserver_wfst(): if gdaltest.wfs_drv is None: return 'skip' @@ -703,10 +715,8 @@ def ogr_wfs_geoserver_wfst(): # Test CreateFeature() / UpdateFeature() / DeleteFeature() with expected # failure due to server not allowing insert & delete -def ogr_wfs_deegree_wfst(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip() +def test_ogr_wfs_deegree_wfst(): if gdaltest.gdalurlopen('http://testing.deegree.org/deegree-wfs/services') is None: print('cannot open URL') @@ -746,10 +756,8 @@ def ogr_wfs_deegree_wfst(): # Test CreateFeature() / UpdateFeature() / DeleteFeature() on a WFS 1.0.0 server -def ogr_wfs_ionic_wfst(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip() +def test_ogr_wfs_ionic_wfst(): if gdaltest.gdalurlopen('http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA') is None: print('cannot open URL') @@ -791,10 +799,8 @@ def ogr_wfs_ionic_wfst(): # Test ExecuteSQL() where SQL should be turned into PROPERTYNAME and FILTER parameters -def ogr_wfs_ionic_sql(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip() +def test_ogr_wfs_ionic_sql(): if not gdaltest.ionic_wfs: return 'skip' @@ -818,10 +824,7 @@ def ogr_wfs_ionic_sql(): # The following test should issue 0 WFS http request -def ogr_wfs_xmldescriptionfile(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_xmldescriptionfile(): ds = ogr.Open('data/testwfs.xml') lyr = ds.GetLayer(0) @@ -862,10 +865,8 @@ def ogr_wfs_xmldescriptionfile(): # Test opening a datasource from a XML description file that has just the URL -def ogr_wfs_xmldescriptionfile_to_be_updated(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip('FIXME: re-enable after adapting test') +def test_ogr_wfs_xmldescriptionfile_to_be_updated(): if not gdaltest.geoserver_wfs: return 'skip' @@ -918,10 +919,7 @@ def ogr_wfs_xmldescriptionfile_to_be_updated(): # The following test should issue 0 WFS http request -def ogr_wfs_getcapabilitiesfile(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_getcapabilitiesfile(): ds = ogr.Open('data/getcapabilities_wfs.xml') @@ -939,10 +937,8 @@ def ogr_wfs_getcapabilitiesfile(): # Test opening a datastore which only support GML 3.2.1 output -def ogr_wfs_deegree_gml321(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip() +def test_ogr_wfs_deegree_gml321(): ds = ogr.Open('WFS:http://demo.deegree.org:80/inspire-workspace/services/wfs?ACCEPTVERSIONS=1.1.0&MAXFEATURES=10') if ds is None: @@ -965,10 +961,8 @@ def ogr_wfs_deegree_gml321(): # Test WFS 2.0.0 support -def ogr_wfs_deegree_wfs200(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip() +def test_ogr_wfs_deegree_wfs200(): ds = ogr.Open('WFS:http://demo.deegree.org:80/utah-workspace/services/wfs?ACCEPTVERSIONS=2.0.0') if ds is None: @@ -1024,10 +1018,8 @@ def ogr_wfs_deegree_wfs200(): # Test WFS SORTBY support -def ogr_wfs_deegree_sortby(): - - if gdaltest.wfs_drv is None: - return 'skip' +@pytest.mark.skip() +def test_ogr_wfs_deegree_sortby(): ds = ogr.Open('WFS:http://demo.deegree.org:80/utah-workspace/services/wfs?MAXFEATURES=10&VERSION=1.1.0') if ds is None: @@ -1057,9 +1049,6 @@ def ogr_wfs_deegree_sortby(): def ogr_wfs_get_multiple_layer_defn(url): - if gdaltest.wfs_drv is None: - return 'skip' - if not gdaltest.run_slow_tests(): return 'skip' @@ -1081,71 +1070,57 @@ def ogr_wfs_get_multiple_layer_defn(url): # Test a ESRI server -def ogr_wfs_esri(): +@pytest.mark.skip() +def test_ogr_wfs_esri(): return ogr_wfs_get_multiple_layer_defn('http://map.ngdc.noaa.gov/wfsconnector/com.esri.wfs.Esrimap/dart_atlantic_f') ############################################################################### # Test a ESRI server -def ogr_wfs_esri_2(): +def test_ogr_wfs_esri_2(): return ogr_wfs_get_multiple_layer_defn('http://sentinel.ga.gov.au/wfsconnector/com.esri.wfs.Esrimap') ############################################################################### # Test a CubeWerx server -def ogr_wfs_cubewerx(): +def test_ogr_wfs_cubewerx(): return ogr_wfs_get_multiple_layer_defn('http://portal.cubewerx.com/cubewerx/cubeserv/cubeserv.cgi?CONFIG=haiti_vgi&DATASTORE=vgi') ############################################################################### # Test a TinyOWS server -def ogr_wfs_tinyows(): +def test_ogr_wfs_tinyows(): return ogr_wfs_get_multiple_layer_defn('http://www.tinyows.org/cgi-bin/tinyows') ############################################################################### # Test a ERDAS Apollo server -def ogr_wfs_erdas_apollo(): +def test_ogr_wfs_erdas_apollo(): return ogr_wfs_get_multiple_layer_defn('http://apollo.erdas.com/erdas-apollo/vector/Cherokee') ############################################################################### # Test a Integraph server -def ogr_wfs_intergraph(): +def test_ogr_wfs_intergraph(): return ogr_wfs_get_multiple_layer_defn('http://ideg.xunta.es/WFS_POL/request.aspx') ############################################################################### # Test a MapInfo server -def ogr_wfs_mapinfo(): +def test_ogr_wfs_mapinfo(): return ogr_wfs_get_multiple_layer_defn('http://www.mapinfo.com/miwfs') -############################################################################### -# Test with OGR_WFS_USE_STREAMING=NO - - -def ogr_wfs_turn_streaming_off(): - gdal.SetConfigOption('OGR_WFS_USE_STREAMING', 'NO') - return 'success' - - -def ogr_wfs_turn_streaming_on(): - gdal.SetConfigOption('OGR_WFS_USE_STREAMING', None) - return 'success' ############################################################################### -def ogr_wfs_vsimem_fail_because_not_enabled(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_not_enabled(with_and_without_streaming): gdal.PushErrorHandler() ds = ogr.Open('WFS:/vsimem/wfs_endpoint') @@ -1157,10 +1132,7 @@ def ogr_wfs_vsimem_fail_because_not_enabled(): ############################################################################### -def ogr_wfs_vsimem_fail_because_no_get_capabilities(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_no_get_capabilities(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') @@ -1175,10 +1147,7 @@ def ogr_wfs_vsimem_fail_because_no_get_capabilities(): ############################################################################### -def ogr_wfs_vsimem_fail_because_empty_response(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_empty_response(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') @@ -1200,10 +1169,7 @@ def ogr_wfs_vsimem_fail_because_empty_response(): ############################################################################### -def ogr_wfs_vsimem_fail_because_no_WFS_Capabilities(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_no_WFS_Capabilities(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') @@ -1225,10 +1191,7 @@ def ogr_wfs_vsimem_fail_because_no_WFS_Capabilities(): ############################################################################### -def ogr_wfs_vsimem_fail_because_exception(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_exception(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') @@ -1250,10 +1213,7 @@ def ogr_wfs_vsimem_fail_because_exception(): ############################################################################### -def ogr_wfs_vsimem_fail_because_invalid_xml_capabilities(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_invalid_xml_capabilities(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') @@ -1275,10 +1235,7 @@ def ogr_wfs_vsimem_fail_because_invalid_xml_capabilities(): ############################################################################### -def ogr_wfs_vsimem_fail_because_missing_featuretypelist(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_fail_because_missing_featuretypelist(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') @@ -1302,10 +1259,7 @@ def ogr_wfs_vsimem_fail_because_missing_featuretypelist(): ############################################################################### -def ogr_wfs_vsimem_wfs110_open_getcapabilities_file(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs110_open_getcapabilities_file(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/caps.xml', """ @@ -4076,10 +3929,7 @@ def ogr_wfs_vsimem_wfs110_multiple_layers(): ############################################################################### -def ogr_wfs_vsimem_wfs110_multiple_layers_same_name_different_ns(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs110_multiple_layers_same_name_different_ns(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs110_multiple_layers_different_ns?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -4182,10 +4032,7 @@ def ogr_wfs_vsimem_wfs110_multiple_layers_same_name_different_ns(): ############################################################################### -def ogr_wfs_vsimem_wfs200_paging(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs200_paging(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs200_endpoint_paging?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -4393,10 +4240,7 @@ def ogr_wfs_vsimem_wfs200_paging(): ############################################################################### -def ogr_wfs_vsimem_wfs200_json(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs200_json(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs200_endpoint_json?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -4534,10 +4378,7 @@ def ogr_wfs_vsimem_wfs200_json(): ############################################################################### -def ogr_wfs_vsimem_wfs200_multipart(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs200_multipart(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs200_endpoint_multipart?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -4671,10 +4512,7 @@ def ogr_wfs_vsimem_wfs200_multipart(): ############################################################################### -def ogr_wfs_vsimem_wfs200_join(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs200_join(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs200_endpoint_join?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -5167,10 +5005,7 @@ def ogr_wfs_vsimem_wfs200_join(): ############################################################################### -def ogr_wfs_vsimem_wfs200_join_layer_with_namespace_prefix(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs200_join_layer_with_namespace_prefix(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs200_endpoint_join?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -5287,10 +5122,7 @@ def ogr_wfs_vsimem_wfs200_join_layer_with_namespace_prefix(): ############################################################################### -def ogr_wfs_vsimem_wfs200_join_distinct(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_wfs200_join_distinct(with_and_without_streaming): gdal.FileFromMemBuffer('/vsimem/wfs200_endpoint_join?SERVICE=WFS&REQUEST=GetCapabilities', """ @@ -5454,10 +5286,7 @@ def ogr_wfs_vsimem_wfs200_join_distinct(): ############################################################################### -def ogr_wfs_vsimem_cleanup(): - - if gdaltest.wfs_drv is None: - return 'skip' +def test_ogr_wfs_vsimem_cleanup(with_and_without_streaming): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', None) @@ -5467,96 +5296,67 @@ def ogr_wfs_vsimem_cleanup(): return 'success' -gdaltest_live_list = [ - # ogr_wfs_mapserver, - # ogr_wfs_geoserver, #FIXME: re-enable after adapting test - # ogr_wfs_geoserver_json, #FIXME: re-enable after adapting test - # ogr_wfs_geoserver_shapezip, #FIXME: re-enable after adapting test - # ogr_wfs_geoserver_paging, #FIXME: re-enable after adapting test - # ogr_wfs_deegree, - # ogr_wfs_test_ogrsf, - ogr_wfs_fake_wfs_server, - # ogr_wfs_geoserver_wfst, #FIXME: re-enable after adapting test - # ogr_wfs_deegree_wfst, - # ogr_wfs_ionic_wfst, - # ogr_wfs_ionic_sql, - ogr_wfs_xmldescriptionfile, - # ogr_wfs_xmldescriptionfile_to_be_updated, #FIXME: re-enable after adapting test - ogr_wfs_getcapabilitiesfile, - # ogr_wfs_deegree_gml321, - # ogr_wfs_deegree_wfs200, - # ogr_wfs_deegree_sortby, - # ogr_wfs_esri, - ogr_wfs_esri_2, - ogr_wfs_cubewerx, - ogr_wfs_tinyows, - ogr_wfs_erdas_apollo, - ogr_wfs_intergraph, - ogr_wfs_mapinfo, - ogr_wfs_turn_streaming_off, - # ogr_wfs_deegree, - # ogr_wfs_test_ogrsf, +gdaltest_list = [ + test_ogr_wfs_vsimem_fail_because_not_enabled, + test_ogr_wfs_vsimem_fail_because_no_get_capabilities, + test_ogr_wfs_vsimem_fail_because_empty_response, + test_ogr_wfs_vsimem_fail_because_no_WFS_Capabilities, + test_ogr_wfs_vsimem_fail_because_exception, + test_ogr_wfs_vsimem_fail_because_invalid_xml_capabilities, + test_ogr_wfs_vsimem_fail_because_missing_featuretypelist, + test_ogr_wfs_vsimem_wfs110_open_getcapabilities_file, + test_ogr_wfs_vsimem_wfs110_minimal_instance, + test_ogr_wfs_vsimem_wfs110_one_layer_missing_describefeaturetype, + test_ogr_wfs_vsimem_wfs110_one_layer_invalid_describefeaturetype, + test_ogr_wfs_vsimem_wfs110_one_layer_describefeaturetype_missing_schema, + test_ogr_wfs_vsimem_wfs110_one_layer_describefeaturetype, + test_ogr_wfs_vsimem_wfs110_one_layer_xmldescriptionfile_to_be_updated, + test_ogr_wfs_vsimem_wfs110_one_layer_missing_getfeaturecount_no_hits, + test_ogr_wfs_vsimem_wfs110_one_layer_missing_getfeaturecount_with_hits, + test_ogr_wfs_vsimem_wfs110_one_layer_invalid_getfeaturecount_with_hits, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_missing_FeatureCollection, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_invalid_xml, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_ServiceExceptionReport, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_missing_numberOfFeatures, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits, + test_ogr_wfs_vsimem_wfs110_one_layer_missing_getfeature, + test_ogr_wfs_vsimem_wfs110_one_layer_invalid_getfeature, + test_ogr_wfs_vsimem_wfs110_one_layer_exception_getfeature, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeature, + test_ogr_wfs_vsimem_wfs110_one_layer_getextent, + test_ogr_wfs_vsimem_wfs110_one_layer_getextent_without_getfeature, + test_ogr_wfs_vsimem_wfs110_one_layer_getextent_optimized, + test_ogr_wfs_vsimem_wfs110_one_layer_getfeature_ogr_getfeature, + test_ogr_wfs_vsimem_wfs110_one_layer_filter_gml_id_failed, + test_ogr_wfs_vsimem_wfs110_one_layer_filter_gml_id_success, + test_ogr_wfs_vsimem_wfs110_one_layer_filter, + test_ogr_wfs_vsimem_wfs110_one_layer_filter_spatial_ops, + test_ogr_wfs_vsimem_wfs110_one_layer_spatial_filter, + test_ogr_wfs_vsimem_wfs110_one_layer_spatial_filter_and_attribute_filter, + test_ogr_wfs_vsimem_wfs110_insertfeature, + test_ogr_wfs_vsimem_wfs110_updatefeature, + test_ogr_wfs_vsimem_wfs110_deletefeature, + test_ogr_wfs_vsimem_wfs110_schema_not_understood, + test_ogr_wfs_vsimem_wfs110_multiple_layers, + test_ogr_wfs_vsimem_wfs110_multiple_layers_same_name_different_ns, + test_ogr_wfs_vsimem_wfs200_paging, + test_ogr_wfs_vsimem_wfs200_json, + test_ogr_wfs_vsimem_wfs200_multipart, + test_ogr_wfs_vsimem_wfs200_join, + test_ogr_wfs_vsimem_wfs200_join_layer_with_namespace_prefix, + test_ogr_wfs_vsimem_wfs200_join_distinct, + test_ogr_wfs_vsimem_cleanup, + test_ogr_wfs_fake_wfs_server, + test_ogr_wfs_xmldescriptionfile, + test_ogr_wfs_getcapabilitiesfile, + test_ogr_wfs_esri_2, + test_ogr_wfs_cubewerx, + test_ogr_wfs_tinyows, + test_ogr_wfs_erdas_apollo, + test_ogr_wfs_intergraph, + test_ogr_wfs_mapinfo, ] -gdaltest_vsimem_list = [ - ogr_wfs_vsimem_fail_because_not_enabled, - ogr_wfs_vsimem_fail_because_no_get_capabilities, - ogr_wfs_vsimem_fail_because_empty_response, - ogr_wfs_vsimem_fail_because_no_WFS_Capabilities, - ogr_wfs_vsimem_fail_because_exception, - ogr_wfs_vsimem_fail_because_invalid_xml_capabilities, - ogr_wfs_vsimem_fail_because_missing_featuretypelist, - ogr_wfs_vsimem_wfs110_open_getcapabilities_file, - ogr_wfs_vsimem_wfs110_minimal_instance, - ogr_wfs_vsimem_wfs110_one_layer_missing_describefeaturetype, - ogr_wfs_vsimem_wfs110_one_layer_invalid_describefeaturetype, - ogr_wfs_vsimem_wfs110_one_layer_describefeaturetype_missing_schema, - ogr_wfs_vsimem_wfs110_one_layer_describefeaturetype, - ogr_wfs_vsimem_wfs110_one_layer_xmldescriptionfile_to_be_updated, - ogr_wfs_vsimem_wfs110_one_layer_missing_getfeaturecount_no_hits, - ogr_wfs_vsimem_wfs110_one_layer_missing_getfeaturecount_with_hits, - ogr_wfs_vsimem_wfs110_one_layer_invalid_getfeaturecount_with_hits, - ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_missing_FeatureCollection, - ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_invalid_xml, - ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_ServiceExceptionReport, - ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits_missing_numberOfFeatures, - ogr_wfs_vsimem_wfs110_one_layer_getfeaturecount_with_hits, - ogr_wfs_vsimem_wfs110_one_layer_missing_getfeature, - ogr_wfs_vsimem_wfs110_one_layer_invalid_getfeature, - ogr_wfs_vsimem_wfs110_one_layer_exception_getfeature, - ogr_wfs_vsimem_wfs110_one_layer_getfeature, - ogr_wfs_vsimem_wfs110_one_layer_getextent, - ogr_wfs_vsimem_wfs110_one_layer_getextent_without_getfeature, - ogr_wfs_vsimem_wfs110_one_layer_getextent_optimized, - ogr_wfs_vsimem_wfs110_one_layer_getfeature_ogr_getfeature, - ogr_wfs_vsimem_wfs110_one_layer_filter_gml_id_failed, - ogr_wfs_vsimem_wfs110_one_layer_filter_gml_id_success, - ogr_wfs_vsimem_wfs110_one_layer_filter, - ogr_wfs_vsimem_wfs110_one_layer_filter_spatial_ops, - ogr_wfs_vsimem_wfs110_one_layer_spatial_filter, - ogr_wfs_vsimem_wfs110_one_layer_spatial_filter_and_attribute_filter, - ogr_wfs_vsimem_wfs110_insertfeature, - ogr_wfs_vsimem_wfs110_updatefeature, - ogr_wfs_vsimem_wfs110_deletefeature, - ogr_wfs_vsimem_wfs110_schema_not_understood, - ogr_wfs_vsimem_wfs110_multiple_layers, - ogr_wfs_vsimem_wfs110_multiple_layers_same_name_different_ns, - ogr_wfs_vsimem_wfs200_paging, - ogr_wfs_vsimem_wfs200_json, - ogr_wfs_vsimem_wfs200_multipart, - ogr_wfs_vsimem_wfs200_join, - ogr_wfs_vsimem_wfs200_join_layer_with_namespace_prefix, - ogr_wfs_vsimem_wfs200_join_distinct, - ogr_wfs_vsimem_cleanup, -] - -gdaltest_list = [ogr_wfs_init] -gdaltest_list += gdaltest_vsimem_list -gdaltest_list += [ogr_wfs_turn_streaming_off] -gdaltest_list += gdaltest_vsimem_list -gdaltest_list += [ogr_wfs_turn_streaming_on] -gdaltest_list += gdaltest_live_list - if __name__ == '__main__': gdaltest.setup_run('ogr_wfs') From b195f511db1a22e3b2ac4acf4e63c704f842a710 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Mon, 10 Dec 2018 09:20:52 +1300 Subject: [PATCH 135/488] Automated: Rename all python tests to test_* Pytest learns what tests are by what it's called. This change was generated by looking at `gdaltest_list` in autotest/ modules, and renaming all mentioned tests if they weren't already called `test_*` --- autotest/alg/applyverticalshiftgrid.py | 28 +- autotest/alg/contour.py | 20 +- autotest/alg/cutline.py | 16 +- autotest/alg/dither.py | 4 +- autotest/alg/polygonize.py | 22 +- autotest/alg/proximity.py | 12 +- autotest/alg/rasterize.py | 24 +- autotest/alg/reproject.py | 16 +- autotest/alg/sieve.py | 32 +- autotest/alg/tps.py | 4 +- autotest/alg/transformgeoloc.py | 4 +- autotest/alg/warp.py | 290 ++++---- autotest/gcore/asyncreader.py | 4 +- autotest/gcore/basic_test.py | 72 +- autotest/gcore/bmp_read.py | 6 +- autotest/gcore/bmp_write.py | 4 +- autotest/gcore/colortable.py | 16 +- autotest/gcore/envi_read.py | 4 +- autotest/gcore/gcps2geotransform.py | 32 +- autotest/gcore/gdal_api_proxy.py | 28 +- autotest/gcore/gdal_stats.py | 110 +-- autotest/gcore/geoloc.py | 4 +- autotest/gcore/hdf4_read.py | 40 +- autotest/gcore/hfa_read.py | 4 +- autotest/gcore/hfa_rfc40.py | 56 +- autotest/gcore/hfa_write.py | 40 +- autotest/gcore/histogram.py | 24 +- autotest/gcore/identify.py | 16 +- autotest/gcore/mask.py | 124 ++-- autotest/gcore/minixml.py | 36 +- autotest/gcore/misc.py | 64 +- autotest/gcore/nodatamaskband.py | 4 +- autotest/gcore/numpy_rw.py | 76 +-- autotest/gcore/overviewds.py | 28 +- autotest/gcore/pam.py | 56 +- autotest/gcore/pixfun.py | 120 ++-- autotest/gcore/rasterio.py | 72 +- autotest/gcore/rat.py | 12 +- autotest/gcore/rfc30.py | 6 +- autotest/gcore/testnonboundtoswig.py | 18 +- autotest/gcore/thread_test.py | 4 +- autotest/gcore/tiff_ovr.py | 240 +++---- autotest/gcore/tiff_read.py | 494 +++++++------- autotest/gcore/tiff_srs.py | 48 +- autotest/gcore/tiff_write.py | 818 +++++++++++------------ autotest/gcore/transformer.py | 70 +- autotest/gcore/virtualmem.py | 16 +- autotest/gcore/vrt_read.py | 136 ++-- autotest/gcore/vrtmisc.py | 88 +-- autotest/gcore/vsiaz.py | 46 +- autotest/gcore/vsicrypt.py | 24 +- autotest/gcore/vsicurl.py | 56 +- autotest/gcore/vsicurl_streaming.py | 4 +- autotest/gcore/vsifile.py | 104 +-- autotest/gcore/vsigs.py | 66 +- autotest/gcore/vsihdfs.py | 28 +- autotest/gcore/vsioss.py | 54 +- autotest/gcore/vsis3.py | 94 +-- autotest/gcore/vsistdin.py | 10 +- autotest/gcore/vsiswift.py | 50 +- autotest/gcore/vsiwebhdfs.py | 42 +- autotest/gcore/vsizip.py | 76 +-- autotest/gdrivers/aaigrid.py | 68 +- autotest/gdrivers/ace2.py | 4 +- autotest/gdrivers/adrg.py | 32 +- autotest/gdrivers/aigrid.py | 32 +- autotest/gdrivers/arg.py | 36 +- autotest/gdrivers/bag.py | 40 +- autotest/gdrivers/blx.py | 20 +- autotest/gdrivers/bsb.py | 28 +- autotest/gdrivers/bt.py | 28 +- autotest/gdrivers/byn.py | 8 +- autotest/gdrivers/cals.py | 20 +- autotest/gdrivers/ceos.py | 4 +- autotest/gdrivers/cpg.py | 4 +- autotest/gdrivers/ctg.py | 4 +- autotest/gdrivers/db2.py | 8 +- autotest/gdrivers/derived.py | 12 +- autotest/gdrivers/dimap.py | 8 +- autotest/gdrivers/dipex.py | 4 +- autotest/gdrivers/doq1.py | 4 +- autotest/gdrivers/doq2.py | 4 +- autotest/gdrivers/dted.py | 64 +- autotest/gdrivers/e00grid.py | 8 +- autotest/gdrivers/ecrgtoc.py | 20 +- autotest/gdrivers/ecw.py | 236 +++---- autotest/gdrivers/eedai.py | 36 +- autotest/gdrivers/ehdr.py | 64 +- autotest/gdrivers/eir.py | 4 +- autotest/gdrivers/elas.py | 8 +- autotest/gdrivers/envi.py | 64 +- autotest/gdrivers/ers.py | 48 +- autotest/gdrivers/fast.py | 36 +- autotest/gdrivers/fujibas.py | 4 +- autotest/gdrivers/gdalhttp.py | 42 +- autotest/gdrivers/genbin.py | 4 +- autotest/gdrivers/georaster.py | 60 +- autotest/gdrivers/gff.py | 4 +- autotest/gdrivers/gif.py | 44 +- autotest/gdrivers/gmt.py | 8 +- autotest/gdrivers/gpkg.py | 238 +++---- autotest/gdrivers/grass.py | 8 +- autotest/gdrivers/grassasciigrid.py | 4 +- autotest/gdrivers/grib.py | 128 ++-- autotest/gdrivers/gsc.py | 4 +- autotest/gdrivers/gsg.py | 32 +- autotest/gdrivers/gta.py | 20 +- autotest/gdrivers/gtx.py | 4 +- autotest/gdrivers/gxf.py | 6 +- autotest/gdrivers/hdf5.py | 72 +- autotest/gdrivers/hf2.py | 20 +- autotest/gdrivers/hfa.py | 172 ++--- autotest/gdrivers/ida.py | 28 +- autotest/gdrivers/idrisi.py | 20 +- autotest/gdrivers/ignfheightasciigrid.py | 48 +- autotest/gdrivers/ilwis.py | 24 +- autotest/gdrivers/ingr.py | 76 +-- autotest/gdrivers/iris.py | 8 +- autotest/gdrivers/isce.py | 16 +- autotest/gdrivers/isis.py | 124 ++-- autotest/gdrivers/isis2.py | 12 +- autotest/gdrivers/jdem.py | 4 +- autotest/gdrivers/jp2kak.py | 84 +-- autotest/gdrivers/jp2lura.py | 212 +++--- autotest/gdrivers/jp2metadata.py | 20 +- autotest/gdrivers/jp2openjpeg.py | 252 +++---- autotest/gdrivers/jpeg.py | 116 ++-- autotest/gdrivers/jpeg2000.py | 72 +- autotest/gdrivers/jpeg_profile.py | 12 +- autotest/gdrivers/jpegls.py | 8 +- autotest/gdrivers/jpipkak.py | 20 +- autotest/gdrivers/kea.py | 60 +- autotest/gdrivers/kmlsuperoverlay.py | 36 +- autotest/gdrivers/kro.py | 20 +- autotest/gdrivers/l1b.py | 28 +- autotest/gdrivers/lan.py | 8 +- autotest/gdrivers/lcp.py | 92 +-- autotest/gdrivers/leveller.py | 4 +- autotest/gdrivers/loslas.py | 4 +- autotest/gdrivers/mbtiles.py | 76 +-- autotest/gdrivers/mem.py | 64 +- autotest/gdrivers/mff.py | 12 +- autotest/gdrivers/mff2.py | 4 +- autotest/gdrivers/mg4lidar.py | 4 +- autotest/gdrivers/mrf.py | 64 +- autotest/gdrivers/mrsid.py | 64 +- autotest/gdrivers/ndf.py | 4 +- autotest/gdrivers/netcdf.py | 356 +++++----- autotest/gdrivers/netcdf_cf.py | 20 +- autotest/gdrivers/ngsgeoid.py | 8 +- autotest/gdrivers/nitf.py | 484 +++++++------- autotest/gdrivers/ntv1.py | 4 +- autotest/gdrivers/ntv2.py | 40 +- autotest/gdrivers/nwt_grc.py | 4 +- autotest/gdrivers/nwt_grd.py | 6 +- autotest/gdrivers/ozi.py | 4 +- autotest/gdrivers/paux.py | 16 +- autotest/gdrivers/pcidsk.py | 72 +- autotest/gdrivers/pcraster.py | 8 +- autotest/gdrivers/pdf.py | 4 +- autotest/gdrivers/pds.py | 48 +- autotest/gdrivers/pds4.py | 72 +- autotest/gdrivers/plmosaic.py | 100 +-- autotest/gdrivers/png.py | 56 +- autotest/gdrivers/png_profile.py | 20 +- autotest/gdrivers/pnm.py | 16 +- autotest/gdrivers/postgisraster.py | 96 +-- autotest/gdrivers/prf.py | 16 +- autotest/gdrivers/r.py | 16 +- autotest/gdrivers/rasdaman.py | 12 +- autotest/gdrivers/rasterlite.py | 56 +- autotest/gdrivers/rda.py | 60 +- autotest/gdrivers/rik.py | 8 +- autotest/gdrivers/rl2.py | 100 +-- autotest/gdrivers/rmf.py | 180 ++--- autotest/gdrivers/roipac.py | 24 +- autotest/gdrivers/rpftoc.py | 16 +- autotest/gdrivers/rraster.py | 70 +- autotest/gdrivers/rs2.py | 12 +- autotest/gdrivers/safe.py | 20 +- autotest/gdrivers/saga.py | 32 +- autotest/gdrivers/sar_ceos.py | 4 +- autotest/gdrivers/sdts.py | 4 +- autotest/gdrivers/sentinel2.py | 112 ++-- autotest/gdrivers/sgi.py | 12 +- autotest/gdrivers/sigdem.py | 12 +- autotest/gdrivers/snodas.py | 4 +- autotest/gdrivers/srp.py | 32 +- autotest/gdrivers/srtmhgt.py | 20 +- autotest/gdrivers/terragen.py | 8 +- autotest/gdrivers/tiff_profile.py | 28 +- autotest/gdrivers/til.py | 12 +- autotest/gdrivers/usgsdem.py | 48 +- autotest/gdrivers/vicar.py | 4 +- autotest/gdrivers/vrtderived.py | 64 +- autotest/gdrivers/vrtfilt.py | 28 +- autotest/gdrivers/vrtlut.py | 8 +- autotest/gdrivers/vrtmask.py | 48 +- autotest/gdrivers/vrtovr.py | 20 +- autotest/gdrivers/vrtpansharpen.py | 48 +- autotest/gdrivers/vrtrawlink.py | 44 +- autotest/gdrivers/vrtwarp.py | 48 +- autotest/gdrivers/wcs.py | 20 +- autotest/gdrivers/webp.py | 20 +- autotest/gdrivers/wms.py | 56 +- autotest/gdrivers/wmts.py | 124 ++-- autotest/gdrivers/xpm.py | 4 +- autotest/gdrivers/xyz.py | 36 +- autotest/gdrivers/zmap.py | 4 +- autotest/gnm/gnm_test.py | 32 +- autotest/ogr/ogr_arcgen.py | 24 +- autotest/ogr/ogr_avc.py | 20 +- autotest/ogr/ogr_basic_test.py | 76 +-- autotest/ogr/ogr_bna.py | 28 +- autotest/ogr/ogr_cad.py | 40 +- autotest/ogr/ogr_carto.py | 16 +- autotest/ogr/ogr_cloudant.py | 24 +- autotest/ogr/ogr_couchdb.py | 16 +- autotest/ogr/ogr_csv.py | 222 +++--- autotest/ogr/ogr_csw.py | 48 +- autotest/ogr/ogr_db2.py | 32 +- autotest/ogr/ogr_db2_hack.py | 12 +- autotest/ogr/ogr_dgn.py | 40 +- autotest/ogr/ogr_dgnv8.py | 24 +- autotest/ogr/ogr_dxf.py | 224 +++---- autotest/ogr/ogr_edigeo.py | 4 +- autotest/ogr/ogr_eeda.py | 20 +- autotest/ogr/ogr_elasticsearch.py | 60 +- autotest/ogr/ogr_factory.py | 32 +- autotest/ogr/ogr_feature.py | 84 +-- autotest/ogr/ogr_fgdb.py | 128 ++-- autotest/ogr/ogr_geoconcept.py | 32 +- autotest/ogr/ogr_geojson.py | 312 ++++----- autotest/ogr/ogr_geojsonseq.py | 36 +- autotest/ogr/ogr_geom.py | 276 ++++---- autotest/ogr/ogr_georss.py | 80 +-- autotest/ogr/ogr_geos.py | 128 ++-- autotest/ogr/ogr_gft.py | 20 +- autotest/ogr/ogr_gml_fgd_read.py | 8 +- autotest/ogr/ogr_gml_geom.py | 236 +++---- autotest/ogr/ogr_gml_read.py | 368 +++++----- autotest/ogr/ogr_gmlas.py | 232 +++---- autotest/ogr/ogr_gmt.py | 24 +- autotest/ogr/ogr_gpkg.py | 258 +++---- autotest/ogr/ogr_gpsbabel.py | 16 +- autotest/ogr/ogr_gpx.py | 50 +- autotest/ogr/ogr_grass.py | 8 +- autotest/ogr/ogr_gtm.py | 24 +- autotest/ogr/ogr_htf.py | 8 +- autotest/ogr/ogr_idrisi.py | 12 +- autotest/ogr/ogr_ili.py | 84 +-- autotest/ogr/ogr_index_test.py | 48 +- autotest/ogr/ogr_ingres.py | 36 +- autotest/ogr/ogr_jml.py | 28 +- autotest/ogr/ogr_join_test.py | 96 +-- autotest/ogr/ogr_kml.py | 112 ++-- autotest/ogr/ogr_layer_algebra.py | 40 +- autotest/ogr/ogr_libkml.py | 224 +++---- autotest/ogr/ogr_mem.py | 72 +- autotest/ogr/ogr_mitab.py | 218 +++--- autotest/ogr/ogr_mongodb.py | 20 +- autotest/ogr/ogr_mssqlspatial.py | 28 +- autotest/ogr/ogr_mvt.py | 160 ++--- autotest/ogr/ogr_mysql.py | 96 +-- autotest/ogr/ogr_nas.py | 20 +- autotest/ogr/ogr_ntf.py | 8 +- autotest/ogr/ogr_oci.py | 88 +-- autotest/ogr/ogr_odbc.py | 12 +- autotest/ogr/ogr_ods.py | 44 +- autotest/ogr/ogr_ogdi.py | 24 +- autotest/ogr/ogr_openair.py | 4 +- autotest/ogr/ogr_openfilegdb.py | 116 ++-- autotest/ogr/ogr_osm.py | 108 +-- autotest/ogr/ogr_pcidsk.py | 40 +- autotest/ogr/ogr_pdf.py | 42 +- autotest/ogr/ogr_pds.py | 8 +- autotest/ogr/ogr_pg.py | 370 +++++----- autotest/ogr/ogr_pgdump.py | 70 +- autotest/ogr/ogr_pgeo.py | 4 +- autotest/ogr/ogr_plscenes.py | 24 +- autotest/ogr/ogr_rec.py | 4 +- autotest/ogr/ogr_refcount.py | 20 +- autotest/ogr/ogr_rfc30.py | 6 +- autotest/ogr/ogr_rfc35_mem.py | 24 +- autotest/ogr/ogr_rfc35_mitab.py | 24 +- autotest/ogr/ogr_rfc35_shape.py | 24 +- autotest/ogr/ogr_rfc35_sqlite.py | 24 +- autotest/ogr/ogr_rfc41.py | 32 +- autotest/ogr/ogr_s57.py | 74 +- autotest/ogr/ogr_sde.py | 38 +- autotest/ogr/ogr_sdts.py | 4 +- autotest/ogr/ogr_segukooa.py | 16 +- autotest/ogr/ogr_segy.py | 8 +- autotest/ogr/ogr_selafin.py | 22 +- autotest/ogr/ogr_shape.py | 452 ++++++------- autotest/ogr/ogr_shape_qix.py | 16 +- autotest/ogr/ogr_shape_sbn.py | 8 +- autotest/ogr/ogr_sosi.py | 4 +- autotest/ogr/ogr_sql_rfc28.py | 216 +++--- autotest/ogr/ogr_sql_sqlite.py | 150 ++--- autotest/ogr/ogr_sql_test.py | 200 +++--- autotest/ogr/ogr_sqlite.py | 256 +++---- autotest/ogr/ogr_style.py | 4 +- autotest/ogr/ogr_sua.py | 4 +- autotest/ogr/ogr_svg.py | 12 +- autotest/ogr/ogr_sxf.py | 12 +- autotest/ogr/ogr_tiger.py | 20 +- autotest/ogr/ogr_vdv.py | 58 +- autotest/ogr/ogr_vfk.py | 48 +- autotest/ogr/ogr_virtualogr.py | 20 +- autotest/ogr/ogr_vrt.py | 176 ++--- autotest/ogr/ogr_wasp.py | 56 +- autotest/ogr/ogr_wfs3.py | 36 +- autotest/ogr/ogr_wkbwkt_geom.py | 44 +- autotest/ogr/ogr_wktempty.py | 4 +- autotest/ogr/ogr_xls.py | 16 +- autotest/ogr/ogr_xlsx.py | 64 +- autotest/ogr/ogr_xplane.py | 20 +- autotest/ogr/ograpispy.py | 12 +- autotest/osr/osr_basic.py | 104 +-- autotest/osr/osr_compd.py | 32 +- autotest/osr/osr_ct.py | 36 +- autotest/osr/osr_epsg.py | 60 +- autotest/osr/osr_erm.py | 8 +- autotest/osr/osr_esri.py | 132 ++-- autotest/osr/osr_getprojectionmethods.py | 4 +- autotest/osr/osr_micoordsys.py | 12 +- autotest/osr/osr_ozi.py | 12 +- autotest/osr/osr_pci.py | 28 +- autotest/osr/osr_pm.py | 12 +- autotest/osr/osr_proj4.py | 122 ++-- autotest/osr/osr_url.py | 8 +- autotest/osr/osr_usgs.py | 8 +- autotest/osr/osr_validate.py | 24 +- autotest/osr/osr_xml.py | 8 +- 335 files changed, 9495 insertions(+), 9495 deletions(-) diff --git a/autotest/alg/applyverticalshiftgrid.py b/autotest/alg/applyverticalshiftgrid.py index 8aa3b39b0b07..82c459452881 100755 --- a/autotest/alg/applyverticalshiftgrid.py +++ b/autotest/alg/applyverticalshiftgrid.py @@ -39,7 +39,7 @@ # Rather dummy test: grid = DEM -def applyverticalshiftgrid_1(): +def test_applyverticalshiftgrid_1(): src_ds = gdal.Open('../gcore/data/byte.tif') src_ds = gdal.Translate('', src_ds, format='MEM', @@ -108,7 +108,7 @@ def applyverticalshiftgrid_1(): # Error cases -def applyverticalshiftgrid_2(): +def test_applyverticalshiftgrid_2(): sr = osr.SpatialReference() sr.SetFromUserInput("WGS84") @@ -209,7 +209,7 @@ def applyverticalshiftgrid_2(): # Test with grid and src not in same projection -def applyverticalshiftgrid_3(): +def test_applyverticalshiftgrid_3(): src_ds = gdal.Open('../gcore/data/byte.tif') grid_ds = gdal.Warp('', src_ds, format='MEM', dstSRS='EPSG:4326', @@ -260,7 +260,7 @@ def applyverticalshiftgrid_3(): # Test nodata -def applyverticalshiftgrid_4(): +def test_applyverticalshiftgrid_4(): sr = osr.SpatialReference() sr.SetFromUserInput("WGS84") @@ -346,7 +346,7 @@ def applyverticalshiftgrid_4(): # Test scaling parameters -def applyverticalshiftgrid_5(): +def test_applyverticalshiftgrid_5(): src_ds = gdal.Open('../gcore/data/byte.tif') grid_ds = gdal.Translate('', src_ds, format='MEM') @@ -380,7 +380,7 @@ def applyverticalshiftgrid_5(): # Simulate EGM grids -def applyverticalshiftgrid_6(): +def test_applyverticalshiftgrid_6(): grid_ds = gdal.GetDriverByName('GTX').Create( '/vsimem/applyverticalshiftgrid_6.gtx', 1440, 721, 1, gdal.GDT_Float32) @@ -404,7 +404,7 @@ def applyverticalshiftgrid_6(): # Simulate USA geoid grids with long origin > 180 -def applyverticalshiftgrid_7(): +def test_applyverticalshiftgrid_7(): grid_ds = gdal.GetDriverByName('GTX').Create( '/vsimem/applyverticalshiftgrid_7.gtx', 700, 721, 1, gdal.GDT_Float32) @@ -426,13 +426,13 @@ def applyverticalshiftgrid_7(): gdaltest_list = [ - applyverticalshiftgrid_1, - applyverticalshiftgrid_2, - applyverticalshiftgrid_3, - applyverticalshiftgrid_4, - applyverticalshiftgrid_5, - applyverticalshiftgrid_6, - applyverticalshiftgrid_7 + test_applyverticalshiftgrid_1, + test_applyverticalshiftgrid_2, + test_applyverticalshiftgrid_3, + test_applyverticalshiftgrid_4, + test_applyverticalshiftgrid_5, + test_applyverticalshiftgrid_6, + test_applyverticalshiftgrid_7 ] if __name__ == '__main__': diff --git a/autotest/alg/contour.py b/autotest/alg/contour.py index 3a7f8ce958e1..fa8664e58298 100755 --- a/autotest/alg/contour.py +++ b/autotest/alg/contour.py @@ -42,7 +42,7 @@ # Test with -a and -i options -def contour_1(): +def test_contour_1(): try: os.remove('tmp/contour.shp') @@ -132,7 +132,7 @@ def contour_1(): # Test with -fl option and -3d option -def contour_2(): +def test_contour_2(): try: os.remove('tmp/contour.shp') @@ -201,7 +201,7 @@ def contour_2(): # -def contour_real_world_case(): +def test_contour_real_world_case(): ogr_ds = ogr.GetDriverByName('Memory').CreateDataSource('') ogr_lyr = ogr_ds.CreateLayer('contour', geom_type=ogr.wkbLineString) @@ -225,7 +225,7 @@ def contour_real_world_case(): # Test with -p option (polygonize) -def contour_3(): +def test_contour_3(): try: os.remove('tmp/contour.shp') @@ -303,7 +303,7 @@ def contour_3(): # Cleanup -def contour_cleanup(): +def test_contour_cleanup(): ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/contour.shp') try: os.remove('tmp/gdal_contour.tif') @@ -314,11 +314,11 @@ def contour_cleanup(): gdaltest_list = [ - contour_1, - contour_2, - contour_real_world_case, - contour_3, - contour_cleanup + test_contour_1, + test_contour_2, + test_contour_real_world_case, + test_contour_3, + test_contour_cleanup ] diff --git a/autotest/alg/cutline.py b/autotest/alg/cutline.py index 5fb297351126..ca0e60ae5054 100755 --- a/autotest/alg/cutline.py +++ b/autotest/alg/cutline.py @@ -40,7 +40,7 @@ ############################################################################### -def cutline_1(): +def test_cutline_1(): tst = gdaltest.GDALTest('VRT', 'cutline_noblend.vrt', 1, 11409) return tst.testOpen() @@ -48,7 +48,7 @@ def cutline_1(): ############################################################################### -def cutline_2(): +def test_cutline_2(): if not ogrtest.have_geos(): return 'skip' @@ -59,7 +59,7 @@ def cutline_2(): ############################################################################### -def cutline_3(): +def test_cutline_3(): if not ogrtest.have_geos(): return 'skip' @@ -70,7 +70,7 @@ def cutline_3(): ############################################################################### -def cutline_4(): +def test_cutline_4(): if not ogrtest.have_geos(): return 'skip' @@ -124,10 +124,10 @@ def cutline_4(): gdaltest_list = [ - cutline_1, - cutline_2, - cutline_3, - cutline_4 + test_cutline_1, + test_cutline_2, + test_cutline_3, + test_cutline_4 ] if __name__ == '__main__': diff --git a/autotest/alg/dither.py b/autotest/alg/dither.py index 372f8df50018..79e4b824c230 100755 --- a/autotest/alg/dither.py +++ b/autotest/alg/dither.py @@ -40,7 +40,7 @@ # Test -def dither_1(): +def test_dither_1(): drv = gdal.GetDriverByName('GTiff') @@ -100,7 +100,7 @@ def dither_1(): gdaltest_list = [ - dither_1 + test_dither_1 ] diff --git a/autotest/alg/polygonize.py b/autotest/alg/polygonize.py index 29fda58e8302..f8375d255cce 100755 --- a/autotest/alg/polygonize.py +++ b/autotest/alg/polygonize.py @@ -41,7 +41,7 @@ # Test a fairly simple case, with nodata masking. -def polygonize_1(is_int_polygonize=True): +def test_polygonize_1(is_int_polygonize=True): src_ds = gdal.Open('data/polygonize_in.grd') src_band = src_ds.GetRasterBand(1) @@ -87,14 +87,14 @@ def polygonize_1(is_int_polygonize=True): return 'success' if tr else 'fail' -def polygonize_1_float(): - return polygonize_1(is_int_polygonize=False) +def test_polygonize_1_float(): + return test_polygonize_1(is_int_polygonize=False) ############################################################################### # Test a simple case without masking. -def polygonize_2(): +def test_polygonize_2(): src_ds = gdal.Open('data/polygonize_in.grd') src_band = src_ds.GetRasterBand(1) @@ -132,7 +132,7 @@ def polygonize_2(): # A more involved case with a complex looping. -def polygonize_3(): +def test_polygonize_3(): src_ds = gdal.Open('data/polygonize_in_2.grd') src_band = src_ds.GetRasterBand(1) @@ -175,7 +175,7 @@ def polygonize_3(): # Test a simple case without masking but with 8-connectedness. -def polygonize_4(): +def test_polygonize_4(): src_ds = gdal.Open('data/polygonize_in.grd') src_band = src_ds.GetRasterBand(1) @@ -211,11 +211,11 @@ def polygonize_4(): gdaltest_list = [ - polygonize_1, - polygonize_1_float, - polygonize_2, - polygonize_3, - polygonize_4 + test_polygonize_1, + test_polygonize_1_float, + test_polygonize_2, + test_polygonize_3, + test_polygonize_4 ] if __name__ == '__main__': diff --git a/autotest/alg/proximity.py b/autotest/alg/proximity.py index d92f06acf975..bfc3dbdb232d 100755 --- a/autotest/alg/proximity.py +++ b/autotest/alg/proximity.py @@ -39,7 +39,7 @@ # Test a fairly default case. -def proximity_1(): +def test_proximity_1(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/pat.tif') @@ -70,7 +70,7 @@ def proximity_1(): # Try several options -def proximity_2(): +def test_proximity_2(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/pat.tif') @@ -105,7 +105,7 @@ def proximity_2(): # Try input nodata option -def proximity_3(): +def test_proximity_3(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/pat.tif') @@ -138,9 +138,9 @@ def proximity_3(): gdaltest_list = [ - proximity_1, - proximity_2, - proximity_3 + test_proximity_1, + test_proximity_2, + test_proximity_3 ] if __name__ == '__main__': diff --git a/autotest/alg/rasterize.py b/autotest/alg/rasterize.py index b0c2fb1bf54e..2815e40f8927 100755 --- a/autotest/alg/rasterize.py +++ b/autotest/alg/rasterize.py @@ -41,7 +41,7 @@ # Simple polygon rasterization. -def rasterize_1(): +def test_rasterize_1(): # Setup working spatial reference sr_wkt = 'LOCAL_CS["arbitrary"]' @@ -105,7 +105,7 @@ def rasterize_1(): # Test rasterization with ALL_TOUCHED. -def rasterize_2(): +def test_rasterize_2(): # Setup working spatial reference sr_wkt = 'LOCAL_CS["arbitrary"]' @@ -151,7 +151,7 @@ def rasterize_2(): # Rasterization with BURN_VALUE_FROM. -def rasterize_3(): +def test_rasterize_3(): # Setup working spatial reference sr_wkt = 'LOCAL_CS["arbitrary"]' @@ -207,7 +207,7 @@ def rasterize_3(): # Rasterization with ATTRIBUTE. -def rasterize_4(): +def test_rasterize_4(): # Setup working spatial reference sr_wkt = 'LOCAL_CS["arbitrary"]' @@ -266,7 +266,7 @@ def rasterize_4(): # Rasterization with MERGE_ALG=ADD. -def rasterize_5(): +def test_rasterize_5(): # Setup working spatial reference sr_wkt = 'LOCAL_CS["arbitrary"]' @@ -337,7 +337,7 @@ def rasterize_5(): ############################################################################### # Test bug fix for #5580 (used to hang) -def rasterize_6(): +def test_rasterize_6(): # Setup working spatial reference sr_wkt = 'LOCAL_CS["arbitrary"]' @@ -361,12 +361,12 @@ def rasterize_6(): gdaltest_list = [ - rasterize_1, - rasterize_2, - rasterize_3, - rasterize_4, - rasterize_5, - rasterize_6 + test_rasterize_1, + test_rasterize_2, + test_rasterize_3, + test_rasterize_4, + test_rasterize_5, + test_rasterize_6 ] if __name__ == '__main__': diff --git a/autotest/alg/reproject.py b/autotest/alg/reproject.py index 4cc7ca0473ee..c01495cf058a 100755 --- a/autotest/alg/reproject.py +++ b/autotest/alg/reproject.py @@ -41,7 +41,7 @@ # Test a trivial case. -def reproject_1(): +def test_reproject_1(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('../gcore/data/byte.tif') @@ -69,7 +69,7 @@ def reproject_1(): # Test a real reprojection case. -def reproject_2(): +def test_reproject_2(): sr = osr.SpatialReference() sr.ImportFromEPSG(32611) @@ -102,7 +102,7 @@ def reproject_2(): # Test nodata values -def reproject_3(): +def test_reproject_3(): data = '\x02\x7f\x7f\x02\x02\x7f\x7f\x02\x02\x7f\x7f\x02' src_ds = gdal.GetDriverByName('MEM').Create('', 4, 3) @@ -130,7 +130,7 @@ def reproject_3(): # Test warp options -def reproject_4(): +def test_reproject_4(): data = '\x02\x7f\x7f\x02\x02\x7f\x7f\x02\x02\x7f\x7f\x02' src_ds = gdal.GetDriverByName('MEM').Create('', 4, 3) @@ -155,10 +155,10 @@ def reproject_4(): gdaltest_list = [ - reproject_1, - reproject_2, - reproject_3, - reproject_4 + test_reproject_1, + test_reproject_2, + test_reproject_3, + test_reproject_4 ] if __name__ == '__main__': diff --git a/autotest/alg/sieve.py b/autotest/alg/sieve.py index 889c54d39444..e007c9227b4f 100755 --- a/autotest/alg/sieve.py +++ b/autotest/alg/sieve.py @@ -40,7 +40,7 @@ # Test a fairly default case. -def sieve_1(): +def test_sieve_1(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/sieve_src.grd') @@ -71,7 +71,7 @@ def sieve_1(): # Try eight connected. -def sieve_2(): +def test_sieve_2(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/sieve_src.grd') @@ -102,7 +102,7 @@ def sieve_2(): # Do a sieve resulting in unmergable polygons. -def sieve_3(): +def test_sieve_3(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/unmergable.grd') @@ -134,7 +134,7 @@ def sieve_3(): # Try the bug 2634 simplified data. -def sieve_4(): +def test_sieve_4(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/sieve_2634.grd') @@ -166,7 +166,7 @@ def sieve_4(): # Same as sieve_1, but we provide a mask band # This should yield the same result as we use an opaque band -def sieve_5(): +def test_sieve_5(): drv = gdal.GetDriverByName('GTiff') src_ds = gdal.Open('data/sieve_src.grd') @@ -198,7 +198,7 @@ def sieve_5(): # should stay roughly linear with the number of pixels (i.e. size^2) -def sieve_6(): +def test_sieve_6(): try: import numpy @@ -237,7 +237,7 @@ def sieve_6(): # Test with nodata -def sieve_7(): +def test_sieve_7(): gdal.FileFromMemBuffer('/vsimem/sieve_7.asc', """ncols 7 nrows 7 @@ -294,7 +294,7 @@ def sieve_7(): # Test propagation in our search of biggest neighbour -def sieve_8(): +def test_sieve_8(): gdal.FileFromMemBuffer('/vsimem/sieve_8.asc', """ncols 7 @@ -341,14 +341,14 @@ def sieve_8(): gdaltest_list = [ - sieve_1, - sieve_2, - sieve_3, - sieve_4, - sieve_5, - sieve_6, - sieve_7, - sieve_8 + test_sieve_1, + test_sieve_2, + test_sieve_3, + test_sieve_4, + test_sieve_5, + test_sieve_6, + test_sieve_7, + test_sieve_8 ] if __name__ == '__main__': diff --git a/autotest/alg/tps.py b/autotest/alg/tps.py index 5875c11b7921..c55e0b1b99eb 100755 --- a/autotest/alg/tps.py +++ b/autotest/alg/tps.py @@ -39,7 +39,7 @@ # Test error case (#5586) -def tps_1(): +def test_tps_1(): drv = gdal.GetDriverByName('MEM') ds = drv.Create('foo', 2, 2) @@ -64,7 +64,7 @@ def tps_1(): gdaltest_list = [ - tps_1, + test_tps_1, ] if __name__ == '__main__': diff --git a/autotest/alg/transformgeoloc.py b/autotest/alg/transformgeoloc.py index d1dc9836dfc3..0dac4d2af1c3 100755 --- a/autotest/alg/transformgeoloc.py +++ b/autotest/alg/transformgeoloc.py @@ -41,7 +41,7 @@ # Test a fairly default case. -def transformgeoloc_1(): +def test_transformgeoloc_1(): try: import numpy @@ -85,7 +85,7 @@ def transformgeoloc_1(): gdaltest_list = [ - transformgeoloc_1, + test_transformgeoloc_1, ] if __name__ == '__main__': diff --git a/autotest/alg/warp.py b/autotest/alg/warp.py index db2eedae5358..8100815ff267 100755 --- a/autotest/alg/warp.py +++ b/autotest/alg/warp.py @@ -49,7 +49,7 @@ # Upsampling -def warp_1(): +def test_warp_1(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -68,7 +68,7 @@ def warp_1(): return 'success' -def warp_1_short(): +def test_warp_1_short(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -87,7 +87,7 @@ def warp_1_short(): return 'success' -def warp_1_ushort(): +def test_warp_1_ushort(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -106,7 +106,7 @@ def warp_1_ushort(): return 'success' -def warp_1_float(): +def test_warp_1_float(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -125,7 +125,7 @@ def warp_1_float(): return 'success' -def warp_2(): +def test_warp_2(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -144,7 +144,7 @@ def warp_2(): return 'success' -def warp_2_short(): +def test_warp_2_short(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -163,7 +163,7 @@ def warp_2_short(): return 'success' -def warp_2_ushort(): +def test_warp_2_ushort(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -182,7 +182,7 @@ def warp_2_ushort(): return 'success' -def warp_2_downsize(): +def test_warp_2_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -201,7 +201,7 @@ def warp_2_downsize(): return 'success' -def warp_3(): +def test_warp_3(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -220,7 +220,7 @@ def warp_3(): return 'success' -def warp_3_short(): +def test_warp_3_short(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -239,7 +239,7 @@ def warp_3_short(): return 'success' -def warp_3_ushort(): +def test_warp_3_ushort(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -258,7 +258,7 @@ def warp_3_ushort(): return 'success' -def warp_3_downsize(): +def test_warp_3_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -277,7 +277,7 @@ def warp_3_downsize(): return 'success' -def warp_3_float_downsize(): +def test_warp_3_float_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -296,7 +296,7 @@ def warp_3_float_downsize(): return 'success' -def warp_4(): +def test_warp_4(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -315,7 +315,7 @@ def warp_4(): return 'success' -def warp_4_short(): +def test_warp_4_short(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -334,7 +334,7 @@ def warp_4_short(): return 'success' -def warp_4_ushort(): +def test_warp_4_ushort(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -353,7 +353,7 @@ def warp_4_ushort(): return 'success' -def warp_4_downsize(): +def test_warp_4_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -372,7 +372,7 @@ def warp_4_downsize(): return 'success' -def warp_4_short_downsize(): +def test_warp_4_short_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -391,7 +391,7 @@ def warp_4_short_downsize(): return 'success' -def warp_4_float_downsize(): +def test_warp_4_float_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -410,7 +410,7 @@ def warp_4_float_downsize(): return 'success' -def warp_5(): +def test_warp_5(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -429,7 +429,7 @@ def warp_5(): return 'success' -def warp_5_downsize(): +def test_warp_5_downsize(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -450,7 +450,7 @@ def warp_5_downsize(): # Downsampling -def warp_6(): +def test_warp_6(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -461,7 +461,7 @@ def warp_6(): return tst.testOpen() -def warp_7(): +def test_warp_7(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -472,7 +472,7 @@ def warp_7(): return tst.testOpen() -def warp_8(): +def test_warp_8(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -483,7 +483,7 @@ def warp_8(): return tst.testOpen() -def warp_9(): +def test_warp_9(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -502,7 +502,7 @@ def warp_9(): return 'success' -def warp_10(): +def test_warp_10(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -521,7 +521,7 @@ def warp_10(): return 'success' -def warp_11(): +def test_warp_11(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -534,7 +534,7 @@ def warp_11(): # Test warping an empty RGBA with bilinear resampling -def warp_12(): +def test_warp_12(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -559,7 +559,7 @@ def warp_12(): # Test warping an empty RGBA with cubic resampling -def warp_13(): +def test_warp_13(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -584,7 +584,7 @@ def warp_13(): # Test warping an empty RGBA with cubic spline resampling -def warp_14(): +def test_warp_14(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -609,7 +609,7 @@ def warp_14(): # Test GWKNearestFloat with transparent source alpha band -def warp_15(): +def test_warp_15(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -634,7 +634,7 @@ def warp_15(): # Test GWKNearestFloat with opaque source alpha band -def warp_16(): +def test_warp_16(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -659,7 +659,7 @@ def warp_16(): # Test GWKNearestShort with transparent source alpha band -def warp_17(): +def test_warp_17(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -684,7 +684,7 @@ def warp_17(): # Test GWKNearestShort with opaque source alpha band -def warp_18(): +def test_warp_18(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -738,7 +738,7 @@ def warp_19_internal(size, datatype, resampling_string): # Test all data types and resampling methods for very small images # to test edge behaviour -def warp_19(): +def test_warp_19(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -772,7 +772,7 @@ def warp_19(): # Test fix for #2724 (initialization of destination area to nodata in warped VRT) -def warp_20(): +def test_warp_20(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -786,7 +786,7 @@ def warp_20(): # Test overviews on warped VRT files -def warp_21(): +def test_warp_21(): shutil.copy('data/utmsmall_near.vrt', 'tmp/warp_21.vrt') @@ -811,7 +811,7 @@ def warp_21(): # Would have detected issue of #3458 -def warp_22(): +def test_warp_22(): # Generate source image with non uniform data w = 1001 @@ -865,7 +865,7 @@ def warp_22(): # Test warping with datasets where some RasterIO() requests involve nBufXSize == 0 (#3582) -def warp_23(): +def test_warp_23(): gcp1 = gdal.GCP() gcp1.GCPPixel = 3213 @@ -942,7 +942,7 @@ def warp_23(): # left pixel being not set in GWKBilinearResample() case) -def warp_24(): +def test_warp_24(): ds_ref = gdal.Open('data/test3658.tif') cs_ref = ds_ref.GetRasterBand(1).Checksum() @@ -959,7 +959,7 @@ def warp_24(): # Test -refine_gcps (#4143) -def warp_25(): +def test_warp_25(): ds = gdal.Open('data/refine_gcps.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -975,7 +975,7 @@ def warp_25(): # Test serializing and deserializing TPS transformer -def warp_26(): +def test_warp_26(): gdal.Translate('tmp/warp_25_gcp.vrt', '../gcore/data/byte.tif', options='-of VRT -gcp 0 0 0 20 -gcp 0 20 0 0 ' @@ -1006,7 +1006,7 @@ def warp_27_progress_callback(pct, message, user_data): return 1 # 1 to continue, 0 to stop -def warp_27(): +def test_warp_27(): # Open source dataset src_ds = gdal.Open('../gcore/data/byte.tif') @@ -1076,7 +1076,7 @@ def warp_27(): # INIT_DEST setting -def warp_28(): +def test_warp_28(): ds = gdal.Open('data/utm_alpha_noinit.vrt') cs1 = ds.GetRasterBand(1).Checksum() @@ -1094,7 +1094,7 @@ def warp_28(): # Test multi-thread computations -def warp_29(): +def test_warp_29(): ds = gdal.Open('data/white_nodata.vrt') cs_monothread = ds.GetRasterBand(1).Checksum() @@ -1167,7 +1167,7 @@ def warp_30_progress_callback(pct, message, user_data): return bool(pct <= 0.2) -def warp_30(): +def test_warp_30(): # Open source dataset src_ds = gdal.Open('../gcore/data/byte.tif') @@ -1244,7 +1244,7 @@ def warp_30(): # Average (Byte) -def warp_31(): +def test_warp_31(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1265,7 +1265,7 @@ def warp_31(): # Average (Float) -def warp_32(): +def test_warp_32(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1286,7 +1286,7 @@ def warp_32(): # Mode (Byte) -def warp_33(): +def test_warp_33(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1307,7 +1307,7 @@ def warp_33(): # Mode (Int16) -def warp_34(): +def test_warp_34(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1328,7 +1328,7 @@ def warp_34(): # Mode (Int16 - signed with negative values) -def warp_35(): +def test_warp_35(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1349,7 +1349,7 @@ def warp_35(): # Mode (Int32) - this uses algorithm 2 (inefficient) -def warp_36(): +def test_warp_36(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1371,7 +1371,7 @@ def warp_36(): # Test a few error cases -def warp_37(): +def test_warp_37(): # Open source dataset src_ds = gdal.Open('../gcore/data/byte.tif') @@ -1409,7 +1409,7 @@ def warp_37(): # Test a warp with GCPs on the *destination* image. -def warp_38(): +def test_warp_38(): # Create an output file with GCPs. out_file = 'tmp/warp_38.tif' @@ -1445,7 +1445,7 @@ def warp_38(): # Test a warp with GCPs for TPS on the *destination* image. -def warp_39(): +def test_warp_39(): # Create an output file with GCPs. out_file = 'tmp/warp_39.tif' @@ -1481,7 +1481,7 @@ def warp_39(): # test average (#5311) -def warp_40(): +def test_warp_40(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1503,7 +1503,7 @@ def warp_40(): # test GDALSuggestedWarpOutput (#5693) -def warp_41(): +def test_warp_41(): src_ds = gdal.Open(""" -2.0037508340000000e+07, 5.9716428339481353e-01, 0.0000000000000000e+00, 2.0037508340000000e+07, 0.0000000000000000e+00, -5.9716428339481353e-01 @@ -1539,7 +1539,7 @@ def warp_41(): # Maximum -def warp_42(): +def test_warp_42(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1560,7 +1560,7 @@ def warp_42(): # Minimum -def warp_43(): +def test_warp_43(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1581,7 +1581,7 @@ def warp_43(): # Median -def warp_44(): +def test_warp_44(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1602,7 +1602,7 @@ def warp_44(): # Quartile 1 -def warp_45(): +def test_warp_45(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1623,7 +1623,7 @@ def warp_45(): # Quartile 3 -def warp_46(): +def test_warp_46(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1644,7 +1644,7 @@ def warp_46(): # Maximum (Int16 - signed with negative values) -def warp_47(): +def test_warp_47(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1665,7 +1665,7 @@ def warp_47(): # Minimum (Int16 - signed with negative values) -def warp_48(): +def test_warp_48(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1686,7 +1686,7 @@ def warp_48(): # Median (Int16 - signed with negative values) -def warp_49(): +def test_warp_49(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1707,7 +1707,7 @@ def warp_49(): # Quartile 1 (Int16 - signed with negative values) -def warp_50(): +def test_warp_50(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1728,7 +1728,7 @@ def warp_50(): # Quartile 3 (Int16 - signed with negative values) -def warp_51(): +def test_warp_51(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -1750,7 +1750,7 @@ def warp_51(): # Test fix for #6182 -def warp_52(): +def test_warp_52(): src_ds = gdal.GetDriverByName('MEM').Create('', 4096, 4096, 3, gdal.GDT_UInt16) rpc = [ @@ -1802,7 +1802,7 @@ def warp_52(): # Test Grey+Alpha -def warp_53(): +def test_warp_53(): for typestr in ('Byte', 'UInt16', 'Int16'): src_ds = gdal.Translate('', '../gcore/data/byte.tif', @@ -1843,7 +1843,7 @@ def warp_53(): # Test Alpha on UInt16/Int16 -def warp_54(): +def test_warp_54(): # UInt16 src_ds = gdal.Translate('', '../gcore/data/stefan_full_rgba.tif', @@ -1899,7 +1899,7 @@ def warp_54(): # and subsampling (#6972) -def warp_55(): +def test_warp_55(): ds = gdal.Open('data/warpedvrt_with_ovr.vrt') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() @@ -1916,7 +1916,7 @@ def warp_55(): # same size). This test crops a single pixel out of a 3-by-3 image. -def warp_56(): +def test_warp_56(): try: from osgeo import gdalnumeric @@ -1948,79 +1948,79 @@ def warp_56(): gdaltest_list = [ - warp_1, - warp_1_short, - warp_1_ushort, - warp_1_float, - warp_2, - warp_2_short, - warp_2_ushort, - warp_2_downsize, - warp_3, - warp_3_short, - warp_3_ushort, - warp_3_downsize, - warp_3_float_downsize, - warp_4, - warp_4_short, - warp_4_ushort, - warp_4_downsize, - warp_4_short_downsize, - warp_4_float_downsize, - warp_5, - warp_5_downsize, - warp_6, - warp_7, - warp_8, - warp_9, - warp_10, - warp_11, - warp_12, - warp_13, - warp_14, - warp_15, - warp_16, - warp_17, - warp_18, - warp_19, - warp_20, - warp_21, - warp_22, - warp_23, - warp_24, - warp_25, - warp_26, - warp_27, - warp_28, - warp_29, - warp_30, - warp_31, - warp_32, - warp_33, - warp_34, - warp_35, - warp_36, - warp_37, - warp_38, - warp_39, - warp_39, - warp_40, - warp_41, - warp_42, - warp_43, - warp_44, - warp_45, - warp_46, - warp_47, - warp_48, - warp_49, - warp_50, - warp_51, - warp_52, - warp_53, - warp_54, - warp_55, - warp_56 + test_warp_1, + test_warp_1_short, + test_warp_1_ushort, + test_warp_1_float, + test_warp_2, + test_warp_2_short, + test_warp_2_ushort, + test_warp_2_downsize, + test_warp_3, + test_warp_3_short, + test_warp_3_ushort, + test_warp_3_downsize, + test_warp_3_float_downsize, + test_warp_4, + test_warp_4_short, + test_warp_4_ushort, + test_warp_4_downsize, + test_warp_4_short_downsize, + test_warp_4_float_downsize, + test_warp_5, + test_warp_5_downsize, + test_warp_6, + test_warp_7, + test_warp_8, + test_warp_9, + test_warp_10, + test_warp_11, + test_warp_12, + test_warp_13, + test_warp_14, + test_warp_15, + test_warp_16, + test_warp_17, + test_warp_18, + test_warp_19, + test_warp_20, + test_warp_21, + test_warp_22, + test_warp_23, + test_warp_24, + test_warp_25, + test_warp_26, + test_warp_27, + test_warp_28, + test_warp_29, + test_warp_30, + test_warp_31, + test_warp_32, + test_warp_33, + test_warp_34, + test_warp_35, + test_warp_36, + test_warp_37, + test_warp_38, + test_warp_39, + test_warp_39, + test_warp_40, + test_warp_41, + test_warp_42, + test_warp_43, + test_warp_44, + test_warp_45, + test_warp_46, + test_warp_47, + test_warp_48, + test_warp_49, + test_warp_50, + test_warp_51, + test_warp_52, + test_warp_53, + test_warp_54, + test_warp_55, + test_warp_56 ] # gdaltest_list = [ warp_55 ] diff --git a/autotest/gcore/asyncreader.py b/autotest/gcore/asyncreader.py index 24f4c59daeb8..c666a1be700f 100755 --- a/autotest/gcore/asyncreader.py +++ b/autotest/gcore/asyncreader.py @@ -38,7 +38,7 @@ # Test AsyncReader interface on the default (synchronous) implementation -def asyncreader_1(): +def test_asyncreader_1(): ds = gdal.Open('data/rgbsmall.tif') asyncreader = ds.BeginAsyncReader(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -71,7 +71,7 @@ def asyncreader_1(): return 'success' -gdaltest_list = [asyncreader_1] +gdaltest_list = [test_asyncreader_1] if __name__ == '__main__': diff --git a/autotest/gcore/basic_test.py b/autotest/gcore/basic_test.py index 5f5a6f32c699..0756ac2fdea0 100755 --- a/autotest/gcore/basic_test.py +++ b/autotest/gcore/basic_test.py @@ -47,7 +47,7 @@ def matches_non_existing_error_msg(msg): return m1 or m2 or m3 -def basic_test_1(): +def test_basic_test_1(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('non_existing_ds', gdal.GA_ReadOnly) gdal.PopErrorHandler() @@ -57,7 +57,7 @@ def basic_test_1(): return 'fail' -def basic_test_strace_non_existing_file(): +def test_basic_test_strace_non_existing_file(): if not sys.platform.startswith('linux'): return 'skip' @@ -84,7 +84,7 @@ def basic_test_strace_non_existing_file(): return 'success' -def basic_test_2(): +def test_basic_test_2(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('non_existing_ds', gdal.GA_Update) gdal.PopErrorHandler() @@ -94,7 +94,7 @@ def basic_test_2(): return 'fail' -def basic_test_3(): +def test_basic_test_3(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('', gdal.GA_ReadOnly) gdal.PopErrorHandler() @@ -104,7 +104,7 @@ def basic_test_3(): return 'fail' -def basic_test_4(): +def test_basic_test_4(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('', gdal.GA_Update) gdal.PopErrorHandler() @@ -114,7 +114,7 @@ def basic_test_4(): return 'fail' -def basic_test_5(): +def test_basic_test_5(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('data/doctype.xml', gdal.GA_ReadOnly) gdal.PopErrorHandler() @@ -128,7 +128,7 @@ def basic_test_5(): # Issue several AllRegister() to check that GDAL drivers are good citizens -def basic_test_6(): +def test_basic_test_6(): gdal.AllRegister() gdal.AllRegister() gdal.AllRegister() @@ -165,7 +165,7 @@ def basic_test_7_internal(): return 'success' -def basic_test_7(): +def test_basic_test_7(): old_use_exceptions_status = gdal.GetUseExceptions() gdal.UseExceptions() ret = basic_test_7_internal() @@ -177,7 +177,7 @@ def basic_test_7(): # Test gdal.VersionInfo('RELEASE_DATE') and gdal.VersionInfo('LICENSE') -def basic_test_8(): +def test_basic_test_8(): ret = gdal.VersionInfo('RELEASE_DATE') if len(ret) != 8: @@ -217,7 +217,7 @@ def my_python_error_handler(eErrClass, err_no, msg): gdaltest.msg = msg -def basic_test_9(): +def test_basic_test_9(): gdaltest.eErrClass = 0 gdaltest.err_no = 0 @@ -256,7 +256,7 @@ def handler(self, eErrClass, err_no, msg): self.msg = msg -def basic_test_10(): +def test_basic_test_10(): # Check that reference counting works OK gdal.PushErrorHandler(my_python_error_handler_class().handler) @@ -286,7 +286,7 @@ def basic_test_10(): # Test gdal.OpenEx() -def basic_test_11(): +def test_basic_test_11(): ds = gdal.OpenEx('data/byte.tif') if ds is None: @@ -408,7 +408,7 @@ def basic_test_11(): # Test GDAL layer API -def basic_test_12(): +def test_basic_test_12(): ds = gdal.GetDriverByName('MEMORY').Create('bar', 0, 0, 0) if ds.GetDescription() != 'bar': @@ -466,7 +466,7 @@ def basic_test_12(): # Test correct sorting of StringList / metadata (#5540, #5557) -def basic_test_13(): +def test_basic_test_13(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) for i in range(3): @@ -514,7 +514,7 @@ def basic_test_13(): # Test SetMetadata() -def basic_test_14(): +def test_basic_test_14(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) @@ -617,7 +617,7 @@ def basic_test_15_cbk_bad_ret(a, b, c): return 'ok' -def basic_test_15(): +def test_basic_test_15(): try: with gdaltest.error_handler(): @@ -651,7 +651,7 @@ def basic_test_15(): # Test unrecognized and recognized open options prefixed by @ -def basic_test_16(): +def test_basic_test_16(): gdal.ErrorReset() gdal.OpenEx('data/byte.tif', open_options=['@UNRECOGNIZED=FOO']) @@ -675,7 +675,7 @@ def basic_test_16(): # Test mix of gdal/ogr.UseExceptions()/DontUseExceptions() -def basic_test_17(): +def test_basic_test_17(): from osgeo import ogr @@ -723,24 +723,24 @@ def basic_test_17(): return 'success' -gdaltest_list = [basic_test_1, - basic_test_strace_non_existing_file, - basic_test_2, - basic_test_3, - basic_test_4, - basic_test_5, - basic_test_6, - basic_test_7, - basic_test_8, - basic_test_9, - basic_test_10, - basic_test_11, - basic_test_12, - basic_test_13, - basic_test_14, - basic_test_15, - basic_test_16, - basic_test_17] +gdaltest_list = [test_basic_test_1, + test_basic_test_strace_non_existing_file, + test_basic_test_2, + test_basic_test_3, + test_basic_test_4, + test_basic_test_5, + test_basic_test_6, + test_basic_test_7, + test_basic_test_8, + test_basic_test_9, + test_basic_test_10, + test_basic_test_11, + test_basic_test_12, + test_basic_test_13, + test_basic_test_14, + test_basic_test_15, + test_basic_test_16, + test_basic_test_17] if __name__ == '__main__': diff --git a/autotest/gcore/bmp_read.py b/autotest/gcore/bmp_read.py index b73b81c5ea2b..d874c58692e1 100755 --- a/autotest/gcore/bmp_read.py +++ b/autotest/gcore/bmp_read.py @@ -51,7 +51,7 @@ def test_bmp_open(filename, checksum): ut.testOpen() -def bmp_online_1(): +def test_bmp_online_1(): if not gdaltest.download_file('http://download.osgeo.org/gdal/data/bmp/8bit_pal_rle.bmp', '8bit_pal_rle.bmp'): return 'skip' @@ -61,7 +61,7 @@ def bmp_online_1(): return tst.testOpen() -def bmp_online_2(): +def test_bmp_online_2(): if not gdaltest.download_file('http://download.osgeo.org/gdal/data/bmp/24bit.bmp', '24bit.bmp'): return 'skip' @@ -73,7 +73,7 @@ def bmp_online_2(): return tst.testOpen() -gdaltest_list = [bmp_online_1, bmp_online_2] +gdaltest_list = [test_bmp_online_1, test_bmp_online_2] if __name__ == '__main__': diff --git a/autotest/gcore/bmp_write.py b/autotest/gcore/bmp_write.py index 35da731b5319..a68e90c89288 100755 --- a/autotest/gcore/bmp_write.py +++ b/autotest/gcore/bmp_write.py @@ -37,7 +37,7 @@ # Test creating an in memory copy. -def bmp_vsimem(): +def test_bmp_vsimem(): tst = gdaltest.GDALTest('BMP', 'byte.tif', 1, 4672) @@ -47,7 +47,7 @@ def bmp_vsimem(): ############################################################################### # When imported build a list of units based on the files available. -gdaltest_list = [bmp_vsimem] +gdaltest_list = [test_bmp_vsimem] init_list = [ diff --git a/autotest/gcore/colortable.py b/autotest/gcore/colortable.py index 4f8dc3ea3413..158059c200c2 100755 --- a/autotest/gcore/colortable.py +++ b/autotest/gcore/colortable.py @@ -40,7 +40,7 @@ # Create a color table. -def colortable_1(): +def test_colortable_1(): gdaltest.test_ct_data = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255, 0)] @@ -54,7 +54,7 @@ def colortable_1(): # verify contents. -def colortable_2(): +def test_colortable_2(): for i in range(len(gdaltest.test_ct_data)): g_data = gdaltest.test_ct.GetColorEntry(i) @@ -76,7 +76,7 @@ def colortable_2(): # Test CreateColorRamp() -def colortable_3(): +def test_colortable_3(): ct = gdal.ColorTable() try: @@ -98,16 +98,16 @@ def colortable_3(): # Cleanup. -def colortable_cleanup(): +def test_colortable_cleanup(): gdaltest.test_ct = None return 'success' gdaltest_list = [ - colortable_1, - colortable_2, - colortable_3, - colortable_cleanup] + test_colortable_1, + test_colortable_2, + test_colortable_3, + test_colortable_cleanup] if __name__ == '__main__': diff --git a/autotest/gcore/envi_read.py b/autotest/gcore/envi_read.py index 51091916f214..37860ba43bfc 100755 --- a/autotest/gcore/envi_read.py +++ b/autotest/gcore/envi_read.py @@ -38,7 +38,7 @@ # Test GDAL_READDIR_LIMIT_ON_OPEN -def envi_1(): +def test_envi_1(): gdal.SetConfigOption('GDAL_READDIR_LIMIT_ON_OPEN', '1') @@ -81,7 +81,7 @@ def test_envi_open(filename, checksum): ut.testOpen() -gdaltest_list = [envi_1] +gdaltest_list = [test_envi_1] if __name__ == '__main__': diff --git a/autotest/gcore/gcps2geotransform.py b/autotest/gcore/gcps2geotransform.py index 8f5d87cafd15..17a9d00a4043 100755 --- a/autotest/gcore/gcps2geotransform.py +++ b/autotest/gcore/gcps2geotransform.py @@ -54,7 +54,7 @@ def _list2gcps(src_list): ############################################################################### # Test simple exact case of turning GCPs into a GeoTransform. -def gcps2gt_1(): +def test_gcps2gt_1(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), @@ -71,7 +71,7 @@ def gcps2gt_1(): # Similar but non-exact. -def gcps2gt_2(): +def test_gcps2gt_2(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), @@ -89,7 +89,7 @@ def gcps2gt_2(): # bApproxOK false, and no good solution. -def gcps2gt_3(): +def test_gcps2gt_3(): approx_ok = 0 gt = gdal.GCPsToGeoTransform(_list2gcps([ @@ -108,7 +108,7 @@ def gcps2gt_3(): # Single point - Should return None. -def gcps2gt_4(): +def test_gcps2gt_4(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), @@ -123,7 +123,7 @@ def gcps2gt_4(): # Two points - simple offset and scale, no rotation. -def gcps2gt_5(): +def test_gcps2gt_5(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), @@ -139,7 +139,7 @@ def gcps2gt_5(): # Special case for four points in a particular order. Exact result. -def gcps2gt_6(): +def test_gcps2gt_6(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (400000, 370000, 400000, 370000), @@ -157,7 +157,7 @@ def gcps2gt_6(): # Try a case that is hard to do without normalization. -def gcps2gt_7(): +def test_gcps2gt_7(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (400000, 370000, 400000, 370000), @@ -175,7 +175,7 @@ def gcps2gt_7(): # A fairly messy real world case without a easy to predict result. -def gcps2gt_8(): +def test_gcps2gt_8(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.01, 0.04, -87.05528672907, 39.22759504228), @@ -194,14 +194,14 @@ def gcps2gt_8(): gdaltest_list = [ - gcps2gt_1, - gcps2gt_2, - gcps2gt_3, - gcps2gt_4, - gcps2gt_5, - gcps2gt_6, - gcps2gt_7, - gcps2gt_8, + test_gcps2gt_1, + test_gcps2gt_2, + test_gcps2gt_3, + test_gcps2gt_4, + test_gcps2gt_5, + test_gcps2gt_6, + test_gcps2gt_7, + test_gcps2gt_8, ] if __name__ == '__main__': diff --git a/autotest/gcore/gdal_api_proxy.py b/autotest/gcore/gdal_api_proxy.py index 7b3e656e3366..9b886389d6cb 100755 --- a/autotest/gcore/gdal_api_proxy.py +++ b/autotest/gcore/gdal_api_proxy.py @@ -41,7 +41,7 @@ # Test forked gdalserver -def gdal_api_proxy_1(): +def test_gdal_api_proxy_1(): import test_py_scripts import test_cli_utilities @@ -60,7 +60,7 @@ def gdal_api_proxy_1(): # Test connection to TCP server -def gdal_api_proxy_2(): +def test_gdal_api_proxy_2(): if sys.version_info < (2, 6, 0): return 'skip' @@ -77,7 +77,7 @@ def gdal_api_proxy_2(): # Test connection to Unix socket server -def gdal_api_proxy_3(): +def test_gdal_api_proxy_3(): if sys.version_info < (2, 6, 0): return 'skip' @@ -101,7 +101,7 @@ def gdal_api_proxy_3(): # Test -nofork mode -def gdal_api_proxy_4(): +def test_gdal_api_proxy_4(): if sys.version_info < (2, 6, 0): return 'skip' @@ -125,7 +125,7 @@ def gdal_api_proxy_4(): # -def gdal_api_proxy_sub(): +def test_gdal_api_proxy_sub(): src_ds = gdal.Open('data/byte.tif') src_cs = src_ds.GetRasterBand(1).Checksum() @@ -601,7 +601,7 @@ def gdal_api_proxy_sub(): # -def gdal_api_proxy_sub_clean(): +def test_gdal_api_proxy_sub_clean(): if gdaltest.api_proxy_server_p is not None: try: gdaltest.api_proxy_server_p.terminate() @@ -613,10 +613,10 @@ def gdal_api_proxy_sub_clean(): return 'success' -gdaltest_list = [gdal_api_proxy_1, - gdal_api_proxy_2, - gdal_api_proxy_3, - gdal_api_proxy_4] +gdaltest_list = [test_gdal_api_proxy_1, + test_gdal_api_proxy_2, + test_gdal_api_proxy_3, + test_gdal_api_proxy_4] if __name__ == '__main__': @@ -628,7 +628,7 @@ def gdal_api_proxy_sub_clean(): gdal.SetConfigOption('GDAL_API_PROXY_SERVER', gdalserver_path) gdaltest.api_proxy_server_p = None - gdaltest_list = [gdal_api_proxy_sub] + gdaltest_list = [test_gdal_api_proxy_sub] elif len(sys.argv) >= 3 and sys.argv[2] == '-2': @@ -652,7 +652,7 @@ def gdal_api_proxy_sub_clean(): gdal.SetConfigOption('GDAL_API_PROXY_SERVER', 'localhost:%d' % port) print('port = %d' % port) gdaltest.api_proxy_server_p = p - gdaltest_list = [gdal_api_proxy_sub, gdal_api_proxy_sub_clean] + gdaltest_list = [test_gdal_api_proxy_sub, test_gdal_api_proxy_sub_clean] else: gdaltest_list = [] @@ -666,7 +666,7 @@ def gdal_api_proxy_sub_clean(): gdal.SetConfigOption('GDAL_API_PROXY', 'YES') gdal.SetConfigOption('GDAL_API_PROXY_SERVER', 'tmp/gdalapiproxysocket') gdaltest.api_proxy_server_p = p - gdaltest_list = [gdal_api_proxy_sub, gdal_api_proxy_sub_clean] + gdaltest_list = [test_gdal_api_proxy_sub, test_gdal_api_proxy_sub_clean] else: try: p.terminate() @@ -685,7 +685,7 @@ def gdal_api_proxy_sub_clean(): gdal.SetConfigOption('GDAL_API_PROXY', 'YES') gdal.SetConfigOption('GDAL_API_PROXY_SERVER', 'tmp/gdalapiproxysocket') gdaltest.api_proxy_server_p = p - gdaltest_list = [gdal_api_proxy_sub, gdal_api_proxy_sub_clean] + gdaltest_list = [test_gdal_api_proxy_sub, test_gdal_api_proxy_sub_clean] else: try: p.terminate() diff --git a/autotest/gcore/gdal_stats.py b/autotest/gcore/gdal_stats.py index 9325410b586a..75631c61072f 100755 --- a/autotest/gcore/gdal_stats.py +++ b/autotest/gcore/gdal_stats.py @@ -40,7 +40,7 @@ # Test handling NaN with GDT_Float32 data -def stats_nan_1(): +def test_stats_nan_1(): gdaltest.gtiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.gtiff_drv is None: @@ -61,7 +61,7 @@ def stats_nan_1(): # Test handling NaN with GDT_Float64 data -def stats_nan_2(): +def test_stats_nan_2(): if gdaltest.gtiff_drv is None: return 'skip' @@ -81,7 +81,7 @@ def stats_nan_2(): # Test stats on signed byte (#3151) -def stats_signedbyte(): +def test_stats_signedbyte(): if gdaltest.gtiff_drv is None: return 'skip' @@ -102,7 +102,7 @@ def stats_signedbyte(): # Test return of GetStatistics() when we don't have stats and don't # force their computation (#3572) -def stats_dont_force(): +def test_stats_dont_force(): gdal.Unlink('data/byte.tif.aux.xml') ds = gdal.Open('data/byte.tif') @@ -119,7 +119,7 @@ def stats_dont_force(): # Test statistics when stored nodata value doesn't accurately match the nodata # value used in the imagery (#3573) -def stats_approx_nodata(): +def test_stats_approx_nodata(): shutil.copyfile('data/minfloat.tif', 'tmp/minfloat.tif') try: @@ -167,7 +167,7 @@ def stats_approx_nodata(): ############################################################################### # Test read and copy of dataset with nan as nodata value (#3576) -def stats_nan_3(): +def test_stats_nan_3(): src_ds = gdal.Open('data/nan32_nodata.tif') nodata = src_ds.GetRasterBand(1).GetNoDataValue() @@ -201,7 +201,7 @@ def stats_nan_3(): # and complex source nodata (#3576) -def stats_nan_4(): +def test_stats_nan_4(): ds = gdal.Open('data/nan32_nodata.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -224,7 +224,7 @@ def stats_nan_4(): # and complex source nodata (nan must be translated to 0 then) (#3576) -def stats_nan_5(): +def test_stats_nan_5(): ds = gdal.Open('data/nan32_nodata_nan_to_zero.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -246,7 +246,7 @@ def stats_nan_5(): ############################################################################### # Test reading a warped VRT with nan as src nodata and dest nodata (#3576) -def stats_nan_6(): +def test_stats_nan_6(): ds = gdal.Open('data/nan32_nodata_warp.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -268,7 +268,7 @@ def stats_nan_6(): # Test reading a warped VRT with nan as src nodata and 0 as dest nodata (#3576) -def stats_nan_7(): +def test_stats_nan_7(): ds = gdal.Open('data/nan32_nodata_warp_nan_to_zero.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -290,7 +290,7 @@ def stats_nan_7(): ############################################################################### # Test reading a warped VRT with zero as src nodata and nan as dest nodata (#3576) -def stats_nan_8(): +def test_stats_nan_8(): ds = gdal.Open('data/nan32_nodata_warp_zero_to_nan.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -317,7 +317,7 @@ def stats_nodata_inf_progress_cbk(value, string, extra): extra[0] = value -def stats_nodata_inf(): +def test_stats_nodata_inf(): ds = gdal.GetDriverByName('HFA').Create('/vsimem/stats_nodata_inf.img', 3, 1, 1, gdal.GDT_Float32) ds.GetRasterBand(1).SetNoDataValue(gdaltest.neginf()) @@ -360,26 +360,26 @@ def stats_nodata_check(filename, expected_nodata): return 'success' -def stats_nodata_neginf_linux(): +def test_stats_nodata_neginf_linux(): return stats_nodata_check('data/stats_nodata_neginf.tif', gdaltest.neginf()) -def stats_nodata_neginf_msvc(): +def test_stats_nodata_neginf_msvc(): return stats_nodata_check('data/stats_nodata_neginf_msvc.tif', gdaltest.neginf()) -def stats_nodata_posinf_linux(): +def test_stats_nodata_posinf_linux(): return stats_nodata_check('data/stats_nodata_posinf.tif', gdaltest.posinf()) -def stats_nodata_posinf_msvc(): +def test_stats_nodata_posinf_msvc(): return stats_nodata_check('data/stats_nodata_posinf_msvc.tif', gdaltest.posinf()) ############################################################################### # Test standard deviation computation on huge values -def stats_stddev_huge_values(): +def test_stats_stddev_huge_values(): gdal.FileFromMemBuffer('/vsimem/stats_stddev_huge_values.asc', """ncols 4 @@ -407,7 +407,7 @@ def stats_stddev_huge_values(): # of blocks is nodata only -def stats_square_shape(): +def test_stats_square_shape(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/stats_square_shape.tif', 32, 32, options=['TILED=YES', 'BLOCKXSIZE=16', 'BLOCKYSIZE=16']) ds.GetRasterBand(1).SetNoDataValue(0) @@ -438,7 +438,7 @@ def stats_square_shape(): # Test when nodata = FLT_MIN (#6578) -def stats_flt_min(): +def test_stats_flt_min(): shutil.copyfile('data/flt_min.tif', 'tmp/flt_min.tif') try: @@ -481,7 +481,7 @@ def stats_flt_min(): # Test when nodata = DBL_MIN (#6578) -def stats_dbl_min(): +def test_stats_dbl_min(): shutil.copyfile('data/dbl_min.tif', 'tmp/dbl_min.tif') try: @@ -524,7 +524,7 @@ def stats_dbl_min(): # Test stats on a tiled Byte with partial tiles -def stats_byte_partial_tiles(): +def test_stats_byte_partial_tiles(): ds = gdal.Translate('/vsimem/stats_byte_tiled.tif', '../gdrivers/data/small_world.tif', creationOptions=['TILED=YES', 'BLOCKXSIZE=64', 'BLOCKYSIZE=64']) @@ -649,7 +649,7 @@ def stats_byte_partial_tiles(): # Test stats on uint16 -def stats_uint16(): +def test_stats_uint16(): ds = gdal.Translate('/vsimem/stats_uint16_tiled.tif', '../gdrivers/data/small_world.tif', outputType=gdal.GDT_UInt16, @@ -776,7 +776,7 @@ def stats_uint16(): # Test a case where the nodata value is almost the maximum value of float32 -def stats_nodata_almost_max_float32(): +def test_stats_nodata_almost_max_float32(): gdal.FileFromMemBuffer('/vsimem/float32_almost_nodata_max_float32.tif', open('data/float32_almost_nodata_max_float32.tif', 'rb').read()) @@ -808,7 +808,7 @@ def stats_nodata_almost_max_float32(): # Test STATISTICS_APPROXIMATE -def stats_approx_stats_flag(dt=gdal.GDT_Byte, struct_frmt='B'): +def test_stats_approx_stats_flag(dt=gdal.GDT_Byte, struct_frmt='B'): ds = gdal.GetDriverByName('MEM').Create('', 2000, 2000, 1, dt) ds.GetRasterBand(1).WriteRaster(1000, 1000, 1, 1, struct.pack(struct_frmt * 1, 20)) @@ -850,11 +850,11 @@ def stats_approx_stats_flag(dt=gdal.GDT_Byte, struct_frmt='B'): return 'success' -def stats_approx_stats_flag_float(): - return stats_approx_stats_flag(dt=gdal.GDT_Float32, struct_frmt='f') +def test_stats_approx_stats_flag_float(): + return test_stats_approx_stats_flag(dt=gdal.GDT_Float32, struct_frmt='f') -def stats_all_nodata(): +def test_stats_all_nodata(): ds = gdal.GetDriverByName('MEM').Create('', 2000, 2000) ds.GetRasterBand(1).SetNoDataValue(0) @@ -882,7 +882,7 @@ def stats_all_nodata(): return 'success' -def stats_float32_with_nodata_slightly_above_float_max(): +def test_stats_float32_with_nodata_slightly_above_float_max(): ds = gdal.Open('data/float32_with_nodata_slightly_above_float_max.tif') my_min, my_max = ds.GetRasterBand(1).ComputeRasterMinMax() @@ -899,33 +899,33 @@ def stats_float32_with_nodata_slightly_above_float_max(): gdaltest_list = [ - stats_nan_1, - stats_nan_2, - stats_signedbyte, - stats_dont_force, - stats_approx_nodata, - stats_nan_3, - stats_nan_4, - stats_nan_5, - stats_nan_6, - stats_nan_7, - stats_nan_8, - stats_nodata_inf, - stats_nodata_neginf_linux, - stats_nodata_neginf_msvc, - stats_nodata_posinf_linux, - stats_nodata_posinf_msvc, - stats_stddev_huge_values, - stats_square_shape, - stats_flt_min, - stats_dbl_min, - stats_byte_partial_tiles, - stats_uint16, - stats_nodata_almost_max_float32, - stats_approx_stats_flag, - stats_approx_stats_flag_float, - stats_all_nodata, - stats_float32_with_nodata_slightly_above_float_max, + test_stats_nan_1, + test_stats_nan_2, + test_stats_signedbyte, + test_stats_dont_force, + test_stats_approx_nodata, + test_stats_nan_3, + test_stats_nan_4, + test_stats_nan_5, + test_stats_nan_6, + test_stats_nan_7, + test_stats_nan_8, + test_stats_nodata_inf, + test_stats_nodata_neginf_linux, + test_stats_nodata_neginf_msvc, + test_stats_nodata_posinf_linux, + test_stats_nodata_posinf_msvc, + test_stats_stddev_huge_values, + test_stats_square_shape, + test_stats_flt_min, + test_stats_dbl_min, + test_stats_byte_partial_tiles, + test_stats_uint16, + test_stats_nodata_almost_max_float32, + test_stats_approx_stats_flag, + test_stats_approx_stats_flag_float, + test_stats_all_nodata, + test_stats_float32_with_nodata_slightly_above_float_max, ] if __name__ == '__main__': diff --git a/autotest/gcore/geoloc.py b/autotest/gcore/geoloc.py index 2ad2e6e5b730..72649bb88aeb 100755 --- a/autotest/gcore/geoloc.py +++ b/autotest/gcore/geoloc.py @@ -38,14 +38,14 @@ # Verify warped result. -def geoloc_1(): +def test_geoloc_1(): tst = gdaltest.GDALTest('VRT', 'warpsst.vrt', 1, 61818) return tst.testOpen(check_filelist=False) gdaltest_list = [ - geoloc_1] + test_geoloc_1] if __name__ == '__main__': diff --git a/autotest/gcore/hdf4_read.py b/autotest/gcore/hdf4_read.py index c6e3dcbf2737..cb52da4dc9b3 100755 --- a/autotest/gcore/hdf4_read.py +++ b/autotest/gcore/hdf4_read.py @@ -68,7 +68,7 @@ def test_hdf4_open(filename, checksum): # Test HDF4_SDS with single subdataset -def hdf4_read_online_1(): +def test_hdf4_read_online_1(): gdaltest.hdf4_drv = gdal.GetDriverByName('HDF4') @@ -86,7 +86,7 @@ def hdf4_read_online_1(): # Test HDF4_SDS with GEOLOCATION info -def hdf4_read_online_2(): +def test_hdf4_read_online_2(): if gdaltest.hdf4_drv is None: return 'skip' @@ -114,7 +114,7 @@ def hdf4_read_online_2(): ############################################################################### # Test HDF4_EOS:EOS_GRID -def hdf4_read_online_3(): +def test_hdf4_read_online_3(): if gdaltest.hdf4_drv is None: return 'skip' @@ -150,7 +150,7 @@ def hdf4_read_online_3(): # Test HDF4_SDS:SEAWIFS_L1A -def hdf4_read_online_4(): +def test_hdf4_read_online_4(): if gdaltest.hdf4_drv is None: return 'skip' @@ -177,7 +177,7 @@ def hdf4_read_online_4(): # Test fix for #2208 -def hdf4_read_online_5(): +def test_hdf4_read_online_5(): if gdaltest.hdf4_drv is None: return 'skip' @@ -198,7 +198,7 @@ def hdf4_read_online_5(): # Test fix for #3386 where block size is dataset size -def hdf4_read_online_6(): +def test_hdf4_read_online_6(): if gdaltest.hdf4_drv is None: return 'skip' @@ -236,7 +236,7 @@ def hdf4_read_online_6(): # Test fix for #3386 where block size is smaller than dataset size -def hdf4_read_online_7(): +def test_hdf4_read_online_7(): if gdaltest.hdf4_drv is None: return 'skip' @@ -274,7 +274,7 @@ def hdf4_read_online_7(): # Test reading a HDF4_EOS:EOS_GRID where preferred block height reported would be 1 # but that will lead to very poor performance (#3386) -def hdf4_read_online_8(): +def test_hdf4_read_online_8(): if gdaltest.hdf4_drv is None: return 'skip' @@ -312,7 +312,7 @@ def hdf4_read_online_8(): # Test reading L1G MTL metadata metadata -def hdf4_read_online_9(): +def test_hdf4_read_online_9(): if gdaltest.hdf4_drv is None: return 'skip' @@ -341,7 +341,7 @@ def hdf4_read_online_9(): # Test that non-tiled access works (#4672) -def hdf4_read_online_10(): +def test_hdf4_read_online_10(): if gdaltest.hdf4_drv is None: return 'skip' @@ -369,16 +369,16 @@ def hdf4_read_online_10(): gdaltest_list = [ - hdf4_read_online_1, - hdf4_read_online_2, - hdf4_read_online_3, - hdf4_read_online_4, - hdf4_read_online_5, - hdf4_read_online_6, - hdf4_read_online_7, - hdf4_read_online_8, - hdf4_read_online_9, - hdf4_read_online_10, + test_hdf4_read_online_1, + test_hdf4_read_online_2, + test_hdf4_read_online_3, + test_hdf4_read_online_4, + test_hdf4_read_online_5, + test_hdf4_read_online_6, + test_hdf4_read_online_7, + test_hdf4_read_online_8, + test_hdf4_read_online_9, + test_hdf4_read_online_10, ] if __name__ == '__main__': diff --git a/autotest/gcore/hfa_read.py b/autotest/gcore/hfa_read.py index ebaafc433d58..87f7d846ddaa 100755 --- a/autotest/gcore/hfa_read.py +++ b/autotest/gcore/hfa_read.py @@ -61,14 +61,14 @@ def test_hfa_open(filename, checksum): ############################################################################### # Test bugfix for https://oss-fuzz.com/v2/testcase-detail/6053338875428864 -def hfa_read_completedefn_recursion(): +def test_hfa_read_completedefn_recursion(): with gdaltest.error_handler(): gdal.Open('data/hfa_completedefn_recursion.img') return 'success' -gdaltest_list = [hfa_read_completedefn_recursion] +gdaltest_list = [test_hfa_read_completedefn_recursion] if __name__ == '__main__': diff --git a/autotest/gcore/hfa_rfc40.py b/autotest/gcore/hfa_rfc40.py index 2366b3c20ecd..6433f8b1a439 100755 --- a/autotest/gcore/hfa_rfc40.py +++ b/autotest/gcore/hfa_rfc40.py @@ -412,103 +412,103 @@ def CheckClone(fname): # basic tests -def hfa_rfc40_1(): +def test_hfa_rfc40_1(): return CreateAndWriteRAT("tmp/test.img") -def hfa_rfc40_2(): +def test_hfa_rfc40_2(): return ReadAndCheckValues("tmp/test.img", 10) # the older interface -def hfa_rfc40_3(): +def test_hfa_rfc40_3(): return CheckSetGetValues("tmp/test.img") # make sure original data not changed -def hfa_rfc40_4(): +def test_hfa_rfc40_4(): return ReadAndCheckValues("tmp/test.img", 10) # make it longer - data will be re-written -def hfa_rfc40_5(): +def test_hfa_rfc40_5(): return ExtendAndWrite("tmp/test.img") # make sure old data not changed -def hfa_rfc40_6(): +def test_hfa_rfc40_6(): return ReadAndCheckValues("tmp/test.img", 20) # new data at the end ok? -def hfa_rfc40_7(): +def test_hfa_rfc40_7(): return CheckExtension("tmp/test.img") # write some longer strings - string column will # have to be re-written -def hfa_rfc40_8(): +def test_hfa_rfc40_8(): return WriteLongStrings("tmp/test.img") # make sure old data not changed -def hfa_rfc40_9(): +def test_hfa_rfc40_9(): return ReadAndCheckValues("tmp/test.img", 20) # check new data ok -def hfa_rfc40_10(): +def test_hfa_rfc40_10(): return CheckLongStrings("tmp/test.img") # linear binning -def hfa_rfc40_11(): +def test_hfa_rfc40_11(): return SetLinearBinning("tmp/test.img") # linear binning -def hfa_rfc40_12(): +def test_hfa_rfc40_12(): return CheckLinearBinning("tmp/test.img") # clone -def hfa_rfc40_13(): +def test_hfa_rfc40_13(): return CheckClone("tmp/test.img") # serialize not available from Python... -def hfa_rfc40_cleanup(): +def test_hfa_rfc40_cleanup(): gdal.GetDriverByName('HFA').Delete("tmp/test.img") return 'success' gdaltest_list = [ - hfa_rfc40_1, - hfa_rfc40_2, - hfa_rfc40_3, - hfa_rfc40_4, - hfa_rfc40_5, - hfa_rfc40_6, - hfa_rfc40_7, - hfa_rfc40_8, - hfa_rfc40_9, - hfa_rfc40_10, - hfa_rfc40_11, - hfa_rfc40_12, - hfa_rfc40_13, - hfa_rfc40_cleanup, + test_hfa_rfc40_1, + test_hfa_rfc40_2, + test_hfa_rfc40_3, + test_hfa_rfc40_4, + test_hfa_rfc40_5, + test_hfa_rfc40_6, + test_hfa_rfc40_7, + test_hfa_rfc40_8, + test_hfa_rfc40_9, + test_hfa_rfc40_10, + test_hfa_rfc40_11, + test_hfa_rfc40_12, + test_hfa_rfc40_13, + test_hfa_rfc40_cleanup, ] if __name__ == '__main__': diff --git a/autotest/gcore/hfa_write.py b/autotest/gcore/hfa_write.py index 2abc40331094..5e7524c6057b 100755 --- a/autotest/gcore/hfa_write.py +++ b/autotest/gcore/hfa_write.py @@ -44,7 +44,7 @@ # test that we can write a small file with a custom layer name. -def hfa_write_desc(): +def test_hfa_write_desc(): src_ds = gdal.Open('data/byte.tif') @@ -75,7 +75,7 @@ def hfa_write_desc(): # test writing 4 bit files. -def hfa_write_4bit(): +def test_hfa_write_4bit(): drv = gdal.GetDriverByName('HFA') src_ds = gdal.Open('data/byte.tif') ds = drv.CreateCopy('tmp/4bit.img', src_ds, options=['NBITS=1']) @@ -100,7 +100,7 @@ def hfa_write_4bit(): # test writing 4 bit files compressed. -def hfa_write_4bit_compressed(): +def test_hfa_write_4bit_compressed(): drv = gdal.GetDriverByName('HFA') src_ds = gdal.Open('data/byte.tif') ds = drv.CreateCopy('tmp/4bitc.img', src_ds, @@ -127,7 +127,7 @@ def hfa_write_4bit_compressed(): # blocks and verifying they are the nodata value. (#2427) -def hfa_write_nd_invalid(): +def test_hfa_write_nd_invalid(): drv = gdal.GetDriverByName('HFA') ds = drv.Create('tmp/ndinvalid.img', 512, 512, 1, gdal.GDT_Byte, []) @@ -152,7 +152,7 @@ def hfa_write_nd_invalid(): # Test updating .rrd overviews in place (#2524). -def hfa_update_overviews(): +def test_hfa_update_overviews(): shutil.copyfile('data/small_ov.img', 'tmp/small.img') shutil.copyfile('data/small_ov.rrd', 'tmp/small.rrd') @@ -172,7 +172,7 @@ def hfa_update_overviews(): # Test cleaning external overviews. -def hfa_clean_external_overviews(): +def test_hfa_clean_external_overviews(): ds = gdal.Open('tmp/small.img', gdal.GA_Update) result = ds.BuildOverviews(overviewlist=[]) @@ -207,7 +207,7 @@ def hfa_clean_external_overviews(): # Test writing high frequency data (#2525). -def hfa_bug_2525(): +def test_hfa_bug_2525(): drv = gdal.GetDriverByName('HFA') ds = drv.Create('tmp/test_hfa.img', 64, 64, 1, gdal.GDT_UInt16, options=['COMPRESSED=YES']) import struct @@ -224,7 +224,7 @@ def hfa_bug_2525(): # Test building external overviews with HFA_USE_RRD=YES -def hfa_use_rrd(): +def test_hfa_use_rrd(): shutil.copyfile('data/small_ov.img', 'tmp/small.img') @@ -262,7 +262,7 @@ def hfa_use_rrd(): ############################################################################### # Test fix for #4831 -def hfa_update_existing_aux_overviews(): +def test_hfa_update_existing_aux_overviews(): gdal.SetConfigOption('USE_RRD', 'YES') @@ -343,7 +343,7 @@ def hfa_update_existing_aux_overviews(): # Test writing invalid WKT (#5258) -def hfa_write_invalid_wkt(): +def test_hfa_write_invalid_wkt(): # No GEOGCS ds = gdal.GetDriverByName('HFA').Create('/vsimem/hfa_write_invalid_wkt.img', 1, 1) @@ -476,16 +476,16 @@ def test_hfa_create_compress(filename, checksum, testfunction): getattr(ut, testfunction)() -gdaltest_list = [hfa_write_desc, - hfa_write_4bit, - hfa_write_4bit_compressed, - hfa_write_nd_invalid, - hfa_update_overviews, - hfa_clean_external_overviews, - hfa_bug_2525, - hfa_use_rrd, - hfa_update_existing_aux_overviews, - hfa_write_invalid_wkt] +gdaltest_list = [test_hfa_write_desc, + test_hfa_write_4bit, + test_hfa_write_4bit_compressed, + test_hfa_write_nd_invalid, + test_hfa_update_overviews, + test_hfa_clean_external_overviews, + test_hfa_bug_2525, + test_hfa_use_rrd, + test_hfa_update_existing_aux_overviews, + test_hfa_write_invalid_wkt] if __name__ == '__main__': diff --git a/autotest/gcore/histogram.py b/autotest/gcore/histogram.py index 5ef38cde8dc4..751ec3335229 100755 --- a/autotest/gcore/histogram.py +++ b/autotest/gcore/histogram.py @@ -42,7 +42,7 @@ # Fetch simple histogram. -def histogram_1(): +def test_histogram_1(): ds = gdal.Open('data/utmsmall.tif') hist = ds.GetRasterBand(1).GetHistogram() @@ -60,7 +60,7 @@ def histogram_1(): # Fetch histogram with specified sampling, using keywords. -def histogram_2(): +def test_histogram_2(): ds = gdal.Open('data/utmsmall.tif') hist = ds.GetRasterBand(1).GetHistogram(buckets=16, max=255.5, min=-0.5) @@ -78,7 +78,7 @@ def histogram_2(): # try on a different data type with out of range values included. -def histogram_3(): +def test_histogram_3(): ds = gdal.Open('data/int32_withneg.grd') hist = ds.GetRasterBand(1).GetHistogram(buckets=21, max=100, min=-100, @@ -98,7 +98,7 @@ def histogram_3(): # try on a different data type without out of range values included. -def histogram_4(): +def test_histogram_4(): ds = gdal.Open('data/int32_withneg.grd') hist = ds.GetRasterBand(1).GetHistogram(buckets=21, max=100, min=-100, @@ -122,7 +122,7 @@ def histogram_4(): # Test GetDefaultHistogram() on the file. -def histogram_5(): +def test_histogram_5(): ds = gdal.Open('data/utmsmall.tif') hist = ds.GetRasterBand(1).GetDefaultHistogram(force=1) @@ -144,7 +144,7 @@ def histogram_5(): # Test GetDefaultHistogram( force = 0 ) on a JPG file (#3304) -def histogram_6(): +def test_histogram_6(): shutil.copy('../gdrivers/data/albania.jpg', 'tmp/albania.jpg') ds = gdal.Open('tmp/albania.jpg') @@ -160,12 +160,12 @@ def histogram_6(): gdaltest_list = [ - histogram_1, - histogram_2, - histogram_3, - histogram_4, - histogram_5, - histogram_6 + test_histogram_1, + test_histogram_2, + test_histogram_3, + test_histogram_4, + test_histogram_5, + test_histogram_6 ] if __name__ == '__main__': diff --git a/autotest/gcore/identify.py b/autotest/gcore/identify.py index 799b2a0c7642..0890ae9c146c 100755 --- a/autotest/gcore/identify.py +++ b/autotest/gcore/identify.py @@ -38,7 +38,7 @@ # Simple try of identify driver on a tiff file. -def identify_1(): +def test_identify_1(): file_list = gdal.ReadDir('data') @@ -53,7 +53,7 @@ def identify_1(): # Test a file that won't be recognised. -def identify_2(): +def test_identify_2(): file_list = gdal.ReadDir('data') @@ -68,7 +68,7 @@ def identify_2(): # Try identify on a directory. -def identify_3(): +def test_identify_3(): dr = gdal.IdentifyDriver('data') if dr is not None: @@ -81,7 +81,7 @@ def identify_3(): # Try IdentifyDriverEx -def identify_4(): +def test_identify_4(): dr = gdal.IdentifyDriverEx('data/byte.tif') if dr is None or dr.GetDescription() != 'GTiff': @@ -117,10 +117,10 @@ def identify_4(): gdaltest_list = [ - identify_1, - identify_2, - identify_3, - identify_4] + test_identify_1, + test_identify_2, + test_identify_3, + test_identify_4] if __name__ == '__main__': diff --git a/autotest/gcore/mask.py b/autotest/gcore/mask.py index acfbe6efa5b3..91ce1c0526c2 100755 --- a/autotest/gcore/mask.py +++ b/autotest/gcore/mask.py @@ -40,7 +40,7 @@ # Verify the checksum and flags for "all valid" case. -def mask_1(): +def test_mask_1(): ds = gdal.Open('data/byte.tif') @@ -72,7 +72,7 @@ def mask_1(): # Verify the checksum and flags for "nodata" case. -def mask_2(): +def test_mask_2(): ds = gdal.Open('data/byte.vrt') @@ -98,7 +98,7 @@ def mask_2(): # Verify the checksum and flags for "alpha" case. -def mask_3(): +def test_mask_3(): ds = gdal.Open('data/stefan_full_rgba.png') @@ -151,7 +151,7 @@ def mask_3(): # Copy a *real* masked dataset, and confirm masks copied properly. -def mask_4(): +def test_mask_4(): src_ds = gdal.Open('../gdrivers/data/masked.jpg') @@ -190,7 +190,7 @@ def mask_4(): # masks built for them. -def mask_5(): +def test_mask_5(): # This crashes with libtiff 3.8.2, so skip it md = gdal.GetDriverByName('GTiff').GetMetadata() @@ -260,7 +260,7 @@ def mask_5(): # Test a TIFF file with 1 band and an embedded mask of 1 bit -def mask_6(): +def test_mask_6(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK_TO_8BIT', 'FALSE') ds = gdal.Open('data/test_with_mask_1bit.tif') @@ -289,7 +289,7 @@ def mask_6(): # Test a TIFF file with 3 bands and an embedded mask of 1 band of 1 bit -def mask_7(): +def test_mask_7(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK_TO_8BIT', 'FALSE') ds = gdal.Open('data/test3_with_1mask_1bit.tif') @@ -320,7 +320,7 @@ def mask_7(): # Note : The TIFF6 specification, page 37, only allows 1 BitsPerSample && 1 SamplesPerPixel, -def mask_8(): +def test_mask_8(): ds = gdal.Open('data/test_with_mask_8bit.tif') @@ -347,7 +347,7 @@ def mask_8(): # Note : The TIFF6 specification, page 37, only allows 1 BitsPerSample && 1 SamplesPerPixel, -def mask_9(): +def test_mask_9(): ds = gdal.Open('data/test3_with_mask_1bit.tif') @@ -375,7 +375,7 @@ def mask_9(): # Note : The TIFF6 specification, page 37, only allows 1 BitsPerSample && 1 SamplesPerPixel, -def mask_10(): +def test_mask_10(): ds = gdal.Open('data/test3_with_mask_8bit.tif') @@ -403,7 +403,7 @@ def mask_10(): # mask for the overview -def mask_11(): +def test_mask_11(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK_TO_8BIT', 'FALSE') ds = gdal.Open('data/test_with_mask_1bit_and_ovr.tif') @@ -461,7 +461,7 @@ def mask_11(): # Test a TIFF file with 3 bands, an overview, an embedded mask of 1 bit, and an embedded # mask for the overview -def mask_12(): +def test_mask_12(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK_TO_8BIT', 'FALSE') ds = gdal.Open('data/test3_with_mask_1bit_and_ovr.tif') @@ -519,7 +519,7 @@ def mask_12(): # Test creation of external TIFF mask band -def mask_13(): +def test_mask_13(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK', 'NO') @@ -586,7 +586,7 @@ def mask_13(): # Test creation of internal TIFF mask band -def mask_14(): +def test_mask_14(): src_ds = gdal.Open('data/byte.tif') @@ -789,42 +789,42 @@ def mask_and_ovr(order, method): return 'success' -def mask_15(): +def test_mask_15(): return mask_and_ovr(1, 'NEAREST') -def mask_16(): +def test_mask_16(): return mask_and_ovr(2, 'NEAREST') -def mask_17(): +def test_mask_17(): return mask_and_ovr(3, 'NEAREST') -def mask_18(): +def test_mask_18(): return mask_and_ovr(4, 'NEAREST') -def mask_15_avg(): +def test_mask_15_avg(): return mask_and_ovr(1, 'AVERAGE') -def mask_16_avg(): +def test_mask_16_avg(): return mask_and_ovr(2, 'AVERAGE') -def mask_17_avg(): +def test_mask_17_avg(): return mask_and_ovr(3, 'AVERAGE') -def mask_18_avg(): +def test_mask_18_avg(): return mask_and_ovr(4, 'AVERAGE') ############################################################################### # Test NODATA_VALUES mask -def mask_19(): +def test_mask_19(): ds = gdal.Open('data/test_nodatavalues.tif') @@ -855,7 +855,7 @@ def mask_19(): # Extensive test of nodata mask for all data types -def mask_20(): +def test_mask_20(): types = [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, gdal.GDT_Float32, gdal.GDT_Float64, @@ -888,7 +888,7 @@ def mask_20(): # Extensive test of NODATA_VALUES mask for all data types -def mask_21(): +def test_mask_21(): types = [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, gdal.GDT_Float32, gdal.GDT_Float64, @@ -925,7 +925,7 @@ def mask_21(): # Test creation of external TIFF mask band just after Create() -def mask_22(): +def test_mask_22(): drv = gdal.GetDriverByName('GTiff') ds = drv.Create('tmp/mask_22.tif', 20, 20) @@ -983,7 +983,7 @@ def mask_22(): # internal mask (#3800) -def mask_23(): +def test_mask_23(): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -1018,7 +1018,7 @@ def mask_23(): # Test on a GDT_UInt16 RGBA (#5692) -def mask_24(): +def test_mask_24(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/mask_24.tif', 100, 100, 4, gdal.GDT_UInt16, options=['PHOTOMETRIC=RGB', 'ALPHA=YES']) @@ -1064,7 +1064,7 @@ def mask_24(): # Test various error conditions -def mask_25(): +def test_mask_25(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/mask_25.tif', 1, 1) if ds.GetRasterBand(1).GetMaskFlags() != gdal.GMF_ALL_VALID: @@ -1140,7 +1140,7 @@ def mask_25(): # Test on a GDT_UInt16 1band data -def mask_26(): +def test_mask_26(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/mask_26.tif', 100, 100, 2, gdal.GDT_UInt16, options=['ALPHA=YES']) @@ -1173,7 +1173,7 @@ def mask_26(): # Extensive test of nodata mask for all complex types using real part only -def mask_27(): +def test_mask_27(): types = [gdal.GDT_CFloat32, gdal.GDT_CFloat64] @@ -1204,37 +1204,37 @@ def mask_27(): # Extensive test of real NODATA_VALUES mask for all complex types gdaltest_list = [ - mask_1, - mask_2, - mask_3, - mask_4, - mask_5, - mask_6, - mask_7, - mask_8, - mask_9, - mask_10, - mask_11, - mask_12, - mask_13, - mask_14, - mask_15, - mask_16, - mask_17, - mask_18, - mask_15_avg, - mask_16_avg, - mask_17_avg, - mask_18_avg, - mask_19, - mask_20, - mask_21, - mask_22, - mask_23, - mask_24, - mask_25, - mask_26, - mask_27] + test_mask_1, + test_mask_2, + test_mask_3, + test_mask_4, + test_mask_5, + test_mask_6, + test_mask_7, + test_mask_8, + test_mask_9, + test_mask_10, + test_mask_11, + test_mask_12, + test_mask_13, + test_mask_14, + test_mask_15, + test_mask_16, + test_mask_17, + test_mask_18, + test_mask_15_avg, + test_mask_16_avg, + test_mask_17_avg, + test_mask_18_avg, + test_mask_19, + test_mask_20, + test_mask_21, + test_mask_22, + test_mask_23, + test_mask_24, + test_mask_25, + test_mask_26, + test_mask_27] if __name__ == '__main__': diff --git a/autotest/gcore/minixml.py b/autotest/gcore/minixml.py index 86937f4001c6..eb642bf91b37 100755 --- a/autotest/gcore/minixml.py +++ b/autotest/gcore/minixml.py @@ -39,7 +39,7 @@ # Parse a simple document into a tree of lists. -def minixml_1(): +def test_minixml_1(): tree = gdal.ParseXMLString('abc') @@ -114,7 +114,7 @@ def minixml_1(): # Serialize an XML Tree -def minixml_2(): +def test_minixml_2(): tree = [0, 'TestDoc', [2, 'style', [1, '123']], [0, 'sub1'], [0, 'sub2', [1, 'abc']]] doc_target = '\n \n abc\n\n' @@ -129,7 +129,7 @@ def minixml_2(): # Read XML document with complex DOCTYPE element. -def minixml_3(): +def test_minixml_3(): fp = open('data/doctype.xml', 'r') text = fp.read() @@ -194,7 +194,7 @@ def minixml_3(): # Parse and serialize an XML Tree with a prolog -def minixml_4(): +def test_minixml_4(): xml = """\n\n""" got_xml = gdal.SerializeXMLTree(gdal.ParseXMLString(xml)) @@ -209,7 +209,7 @@ def minixml_4(): # Parse malformed XML. Complains, but still makes a tree. -def minixml_5(): +def test_minixml_5(): test_pairs = ( ('', 'case'), @@ -238,7 +238,7 @@ def minixml_5(): # Parse malformed XML. -def minixml_6(): +def test_minixml_6(): test_pairs = ( ('<', 'element token after open angle bracket'), @@ -277,7 +277,7 @@ def minixml_6(): # Parse malformed XML. Pass without warning, but should not pass. -def minixml_7(): +def test_minixml_7(): test_strings = ( '<1>', @@ -305,7 +305,7 @@ def minixml_7(): # Parse XML with too many nesting -def minixml_8(): +def test_minixml_8(): xml_str = '' * 10001 xml_str += '' * 10001 @@ -326,20 +326,20 @@ def minixml_8(): ############################################################################### # Cleanup -def minixml_cleanup(): +def test_minixml_cleanup(): return 'success' gdaltest_list = [ - minixml_1, - minixml_2, - minixml_3, - minixml_4, - minixml_5, - minixml_6, - minixml_7, - minixml_8, - minixml_cleanup] + test_minixml_1, + test_minixml_2, + test_minixml_3, + test_minixml_4, + test_minixml_5, + test_minixml_6, + test_minixml_7, + test_minixml_8, + test_minixml_cleanup] if __name__ == '__main__': diff --git a/autotest/gcore/misc.py b/autotest/gcore/misc.py index 35d0a9e073c2..ec310958afb9 100755 --- a/autotest/gcore/misc.py +++ b/autotest/gcore/misc.py @@ -42,7 +42,7 @@ # Test that the constructor of GDALDataset() behaves well with a big number of # opened/created datasets -def misc_1(): +def test_misc_1(): tab_ds = [None] * 5000 drv = gdal.GetDriverByName('MEM') @@ -59,7 +59,7 @@ def misc_1(): # limit of maximum file descriptors opened at the same time -def misc_2(): +def test_misc_2(): tab_ds = [None for i in range(5000)] for i, _ in enumerate(tab_ds): @@ -73,7 +73,7 @@ def misc_2(): # Test OpenShared() with a dataset whose filename != description (#2797) -def misc_3(): +def test_misc_3(): with gdaltest.error_handler(): ds = gdal.OpenShared('../gdrivers/data/small16.aux') @@ -97,7 +97,7 @@ def misc_3(): # Test Create() with invalid arguments -def misc_4(): +def test_misc_4(): gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -195,7 +195,7 @@ def misc_5_internal(drv, datatype, nBands): return 1 -def misc_5(): +def test_misc_5(): gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -387,7 +387,7 @@ def misc_6_internal(datatype, nBands, setDriversDone): return 'success' -def misc_6(): +def test_misc_6(): gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -443,7 +443,7 @@ def misc_6(): # Test gdal.InvGeoTransform() -def misc_7(): +def test_misc_7(): try: gdal.InvGeoTransform @@ -464,7 +464,7 @@ def misc_7(): # Test gdal.ApplyGeoTransform() -def misc_8(): +def test_misc_8(): try: gdal.ApplyGeoTransform @@ -482,7 +482,7 @@ def misc_8(): # Test setting and retrieving > 2 GB values for GDAL max cache (#3689) -def misc_9(): +def test_misc_9(): old_val = gdal.GetCacheMax() gdal.SetCacheMax(3000000000) @@ -500,7 +500,7 @@ def misc_9(): ############################################################################### # Test VSIBufferedReaderHandle (fix done in r21358) -def misc_10(): +def test_misc_10(): try: os.remove('data/byte.tif.gz.properties') @@ -531,7 +531,7 @@ def misc_10(): # Test that we can open a symlink whose pointed filename isn't a real # file, but a filename that GDAL recognizes -def misc_11(): +def test_misc_11(): if not gdaltest.support_symlink(): return 'skip' @@ -559,7 +559,7 @@ def misc_11(): # Test CreateCopy() with a target filename in a non-existing dir -def misc_12(): +def test_misc_12(): if int(gdal.VersionInfo('VERSION_NUM')) < 1900: gdaltest.post_reason('would crash') @@ -629,7 +629,7 @@ def misc_12(): # Test CreateCopy() with incompatible driver types (#5912) -def misc_13(): +def test_misc_13(): # Raster-only -> vector-only ds = gdal.Open('data/byte.tif') @@ -654,7 +654,7 @@ def misc_13(): ############################################################################### # Test ConfigureLogging() -def misc_14(): +def test_misc_14(): import collections import logging @@ -729,7 +729,7 @@ def emit(self, record): ############################################################################### # Test SetErrorHandler -def misc_15(): +def test_misc_15(): messages0 = [] def handle0(ecls, ecode, emsg): messages0.append((ecls, ecode, emsg)) @@ -800,7 +800,7 @@ def handle1(ecls, ecode, emsg): ############################################################################### -def misc_cleanup(): +def test_misc_cleanup(): try: shutil.rmtree('tmp/tmp') @@ -810,22 +810,22 @@ def misc_cleanup(): return 'success' -gdaltest_list = [misc_1, - misc_2, - misc_3, - misc_4, - misc_5, - misc_6, - misc_7, - misc_8, - misc_9, - misc_10, - misc_11, - misc_12, - misc_13, - misc_14, - misc_15, - misc_cleanup] +gdaltest_list = [test_misc_1, + test_misc_2, + test_misc_3, + test_misc_4, + test_misc_5, + test_misc_6, + test_misc_7, + test_misc_8, + test_misc_9, + test_misc_10, + test_misc_11, + test_misc_12, + test_misc_13, + test_misc_14, + test_misc_15, + test_misc_cleanup] # gdaltest_list = [ misc_6 ] diff --git a/autotest/gcore/nodatamaskband.py b/autotest/gcore/nodatamaskband.py index 6a26923eccb4..8f76f08033d1 100755 --- a/autotest/gcore/nodatamaskband.py +++ b/autotest/gcore/nodatamaskband.py @@ -38,7 +38,7 @@ from osgeo import gdal -def nodatamaskband_1(): +def test_nodatamaskband_1(): for (dt, struct_type, v) in [(gdal.GDT_Byte, 'B', 255), (gdal.GDT_Int16, 'h', 32767), @@ -115,7 +115,7 @@ def nodatamaskband_1(): gdaltest_list = [ - nodatamaskband_1, + test_nodatamaskband_1, ] if __name__ == '__main__': diff --git a/autotest/gcore/numpy_rw.py b/autotest/gcore/numpy_rw.py index 3d70b42e9e7b..c03fe81983d2 100755 --- a/autotest/gcore/numpy_rw.py +++ b/autotest/gcore/numpy_rw.py @@ -39,7 +39,7 @@ # verify that we can load Numeric python, and find the Numpy driver. -def numpy_rw_1(): +def test_numpy_rw_1(): gdaltest.numpy_drv = None try: @@ -61,7 +61,7 @@ def numpy_rw_1(): # Load a test file into a memory Numpy array, and verify the checksum. -def numpy_rw_2(): +def test_numpy_rw_2(): if gdaltest.numpy_drv is None: return 'skip' @@ -90,7 +90,7 @@ def numpy_rw_2(): # Test loading complex data. -def numpy_rw_3(): +def test_numpy_rw_3(): if gdaltest.numpy_drv is None: return 'skip' @@ -109,7 +109,7 @@ def numpy_rw_3(): # Test a band read with downsampling. -def numpy_rw_4(): +def test_numpy_rw_4(): if gdaltest.numpy_drv is None: return 'skip' @@ -128,7 +128,7 @@ def numpy_rw_4(): # Test reading a multi-band file. -def numpy_rw_5(): +def test_numpy_rw_5(): if gdaltest.numpy_drv is None: return 'skip' @@ -177,7 +177,7 @@ def numpy_rw_5(): # Check that Band.ReadAsArray() can accept an already allocated array (#2658, #3028) -def numpy_rw_6(): +def test_numpy_rw_6(): if gdaltest.numpy_drv is None: return 'skip' @@ -202,7 +202,7 @@ def numpy_rw_6(): # Check that Dataset.ReadAsArray() can accept an already allocated array (#2658, #3028) -def numpy_rw_7(): +def test_numpy_rw_7(): if gdaltest.numpy_drv is None: return 'skip' @@ -250,7 +250,7 @@ def numpy_rw_7(): # Check that Dataset.ReadAsArray() with multi-band data -def numpy_rw_8(): +def test_numpy_rw_8(): if gdaltest.numpy_drv is None: return 'skip' @@ -273,7 +273,7 @@ def numpy_rw_8(): # Test Band.WriteArray() -def numpy_rw_9(): +def test_numpy_rw_9(): if gdaltest.numpy_drv is None: return 'skip' @@ -298,7 +298,7 @@ def numpy_rw_9(): # Test signed byte handling -def numpy_rw_10(): +def test_numpy_rw_10(): if gdaltest.numpy_drv is None: return 'skip' @@ -336,7 +336,7 @@ def numpy_rw_10(): # Test all datatypes -def numpy_rw_11(): +def test_numpy_rw_11(): if gdaltest.numpy_drv is None: return 'skip' @@ -411,7 +411,7 @@ def numpy_rw_11(): # Test array with slices (#3542) -def numpy_rw_12(): +def test_numpy_rw_12(): if gdaltest.numpy_drv is None: return 'skip' @@ -444,7 +444,7 @@ def numpy_rw_12(): # Test expected errors -def numpy_rw_13(): +def test_numpy_rw_13(): if gdaltest.numpy_drv is None: return 'skip' @@ -672,7 +672,7 @@ def numpy_rw_14_progress_callback_2(pct, message, user_data): return 1 # 1 to continue, 0 to stop -def numpy_rw_14(): +def test_numpy_rw_14(): if gdaltest.numpy_drv is None: return 'skip' @@ -756,7 +756,7 @@ def numpy_rw_14(): # Test NumPy GetGeoTransform/SetGeoTransform -def numpy_rw_15(): +def test_numpy_rw_15(): if gdaltest.numpy_drv is None: return 'skip' @@ -782,7 +782,7 @@ def numpy_rw_15(): # Test errors of OpenArray() -def numpy_rw_16(): +def test_numpy_rw_16(): if gdaltest.numpy_drv is None: return 'skip' @@ -820,7 +820,7 @@ def numpy_rw_16(): # Test old deprecated way with gdal_array.GetArrayFilename() -def numpy_rw_17(): +def test_numpy_rw_17(): if gdaltest.numpy_drv is None: return 'skip' @@ -856,7 +856,7 @@ def numpy_rw_17(): # Test the pixel interleave options -def numpy_rw_18(): +def test_numpy_rw_18(): if gdaltest.numpy_drv is None: return 'skip' @@ -886,32 +886,32 @@ def numpy_rw_18(): return 'success' -def numpy_rw_cleanup(): +def test_numpy_rw_cleanup(): gdaltest.numpy_drv = None return 'success' gdaltest_list = [ - numpy_rw_1, - numpy_rw_2, - numpy_rw_3, - numpy_rw_4, - numpy_rw_5, - numpy_rw_6, - numpy_rw_7, - numpy_rw_8, - numpy_rw_9, - numpy_rw_10, - numpy_rw_11, - numpy_rw_12, - numpy_rw_13, - numpy_rw_14, - numpy_rw_15, - numpy_rw_16, - numpy_rw_17, - numpy_rw_18, - numpy_rw_cleanup] + test_numpy_rw_1, + test_numpy_rw_2, + test_numpy_rw_3, + test_numpy_rw_4, + test_numpy_rw_5, + test_numpy_rw_6, + test_numpy_rw_7, + test_numpy_rw_8, + test_numpy_rw_9, + test_numpy_rw_10, + test_numpy_rw_11, + test_numpy_rw_12, + test_numpy_rw_13, + test_numpy_rw_14, + test_numpy_rw_15, + test_numpy_rw_16, + test_numpy_rw_17, + test_numpy_rw_18, + test_numpy_rw_cleanup] if __name__ == '__main__': diff --git a/autotest/gcore/overviewds.py b/autotest/gcore/overviewds.py index b100105d82a1..a641a328f652 100755 --- a/autotest/gcore/overviewds.py +++ b/autotest/gcore/overviewds.py @@ -41,7 +41,7 @@ # Error cases -def overviewds_1(): +def test_overviewds_1(): ds = gdal.OpenEx('data/byte.tif', open_options=['OVERVIEW_LEVEL=-1']) if ds is not None: return 'fail' @@ -55,7 +55,7 @@ def overviewds_1(): # Nominal cases -def overviewds_2(): +def test_overviewds_2(): shutil.copy('data/byte.tif', 'tmp') ds = gdal.Open('tmp/byte.tif') @@ -130,7 +130,7 @@ def overviewds_2(): # Test GCP -def overviewds_3(): +def test_overviewds_3(): src_ds = gdal.Open('data/byte.tif') ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/byte.tif', src_ds) @@ -192,7 +192,7 @@ def myfloat(s): return float(s) -def overviewds_4(): +def test_overviewds_4(): shutil.copy('data/byte.tif', 'tmp/byte.tif') shutil.copy('data/test_rpc.txt', 'tmp/byte_rpc.txt') @@ -250,7 +250,7 @@ def overviewds_4(): # Test GEOLOCATION -def overviewds_5(): +def test_overviewds_5(): shutil.copy('data/sstgeo.tif', 'tmp/sstgeo.tif') shutil.copy('data/sstgeo.vrt', 'tmp/sstgeo.vrt') @@ -311,7 +311,7 @@ def overviewds_5(): # Test VRT -def overviewds_6(): +def test_overviewds_6(): shutil.copy('data/byte.tif', 'tmp') ds = gdal.Open('tmp/byte.tif') @@ -340,7 +340,7 @@ def overviewds_6(): # Cleanup -def overviewds_cleanup(): +def test_overviewds_cleanup(): gdal.GetDriverByName('GTiff').Delete('tmp/byte.tif') try: @@ -361,13 +361,13 @@ def overviewds_cleanup(): return 'success' -gdaltest_list = [overviewds_1, - overviewds_2, - overviewds_3, - overviewds_4, - overviewds_5, - overviewds_6, - overviewds_cleanup] +gdaltest_list = [test_overviewds_1, + test_overviewds_2, + test_overviewds_3, + test_overviewds_4, + test_overviewds_5, + test_overviewds_6, + test_overviewds_cleanup] if __name__ == '__main__': diff --git a/autotest/gcore/pam.py b/autotest/gcore/pam.py index b48848e6bef1..271ac4c22afa 100755 --- a/autotest/gcore/pam.py +++ b/autotest/gcore/pam.py @@ -43,7 +43,7 @@ # Check that we can read PAM metadata for existing PNM file. -def pam_1(): +def test_pam_1(): gdaltest.pam_setting = gdal.GetConfigOption('GDAL_PAM_ENABLED', "NULL") gdal.SetConfigOption('GDAL_PAM_ENABLED', 'YES') @@ -81,7 +81,7 @@ def pam_1(): # Verify that we can write XML to a new file. -def pam_2(): +def test_pam_2(): driver = gdal.GetDriverByName('PNM') ds = driver.Create('tmp/pam.pnm', 10, 10) @@ -105,7 +105,7 @@ def pam_2(): # Check that we can read PAM metadata for existing PNM file. -def pam_3(): +def test_pam_3(): ds = gdal.Open("tmp/pam.pnm") @@ -158,7 +158,7 @@ def pam_3(): # -def pam_4(): +def test_pam_4(): # Copy test dataset to tmp directory so that the .aux.xml file # won't be rewritten with the statistics in the master dataset. @@ -182,7 +182,7 @@ def pam_4(): # -def pam_5(): +def test_pam_5(): ds = gdal.Open('data/sasha.tif') filelist = ds.GetFileList() @@ -201,7 +201,7 @@ def pam_5(): # -def pam_6(): +def test_pam_6(): ds = gdal.Open('data/f2r23.tif') if ds.GetRasterBand(1).GetNoDataValue() != 0: @@ -220,7 +220,7 @@ def pam_6(): # -def pam_7(): +def test_pam_7(): gdal.SetConfigOption('GDAL_PAM_ENABLED', 'NO') @@ -246,7 +246,7 @@ def pam_7(): # -def pam_8(): +def test_pam_8(): gdal.SetConfigOption('GDAL_PAM_ENABLED', 'YES') @@ -271,7 +271,7 @@ def pam_8(): # -def pam_9(): +def test_pam_9(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/pam_9.tif', 1, 1, 1) ds = None @@ -308,7 +308,7 @@ def pam_9(): # Test serializing and deserializing of various band metadata -def pam_10(): +def test_pam_10(): src_ds = gdal.Open('data/testserialization.asc') ds = gdal.GetDriverByName('AAIGRID').CreateCopy('/vsimem/pam_10.asc', src_ds) @@ -391,7 +391,7 @@ def pam_10(): # Test PamProxyDb mechanism -def pam_11(): +def test_pam_11(): # Create a read-only directory try: @@ -456,7 +456,7 @@ def pam_11(): # Test histogram with 64bit counts -def pam_12(): +def test_pam_12(): shutil.copy('data/byte.tif', 'tmp') open('tmp/byte.tif.aux.xml', 'wt').write(""" @@ -505,7 +505,7 @@ def pam_12(): # -def pam_13(): +def test_pam_13(): gdal.SetConfigOption('GDAL_PAM_ENABLED', 'NO') @@ -543,7 +543,7 @@ def pam_13(): ############################################################################### # Cleanup. -def pam_cleanup(): +def test_pam_cleanup(): gdaltest.clean_tmp() if gdaltest.pam_setting != 'NULL': gdal.SetConfigOption('GDAL_PAM_ENABLED', gdaltest.pam_setting) @@ -564,20 +564,20 @@ def pam_cleanup(): gdaltest_list = [ - pam_1, - pam_2, - pam_3, - pam_4, - pam_5, - pam_6, - pam_7, - pam_8, - pam_9, - pam_10, - pam_11, - pam_12, - pam_13, - pam_cleanup] + test_pam_1, + test_pam_2, + test_pam_3, + test_pam_4, + test_pam_5, + test_pam_6, + test_pam_7, + test_pam_8, + test_pam_9, + test_pam_10, + test_pam_11, + test_pam_12, + test_pam_13, + test_pam_cleanup] if __name__ == '__main__': diff --git a/autotest/gcore/pixfun.py b/autotest/gcore/pixfun.py index a277636b50f2..f721d310e5ff 100755 --- a/autotest/gcore/pixfun.py +++ b/autotest/gcore/pixfun.py @@ -45,7 +45,7 @@ # Verify real part extraction from a complex dataset. -def pixfun_real_c(): +def test_pixfun_real_c(): if not numpy_available: return 'skip' @@ -73,7 +73,7 @@ def pixfun_real_c(): ############################################################################### # Verify real part extraction from a complex dataset. -def pixfun_real_r(): +def test_pixfun_real_r(): if not numpy_available: return 'skip' @@ -101,7 +101,7 @@ def pixfun_real_r(): ############################################################################### # Verify imaginary part extraction from a complex dataset. -def pixfun_imag_c(): +def test_pixfun_imag_c(): if not numpy_available: return 'skip' @@ -139,7 +139,7 @@ def pixfun_imag_c(): ############################################################################### # Verify imaginary part extraction from a real dataset. -def pixfun_imag_r(): +def test_pixfun_imag_r(): if not numpy_available: return 'skip' @@ -160,7 +160,7 @@ def pixfun_imag_r(): ############################################################################### # Verify imaginary part extraction from a real dataset. -def pixfun_complex(): +def test_pixfun_complex(): if not numpy_available: return 'skip' @@ -188,7 +188,7 @@ def pixfun_complex(): ############################################################################### # Verify modulus extraction from a complex (float) dataset. -def pixfun_mod_c(): +def test_pixfun_mod_c(): if not numpy_available: return 'skip' @@ -216,7 +216,7 @@ def pixfun_mod_c(): ############################################################################### # Verify modulus extraction from a real (integer type) dataset. -def pixfun_mod_r(): +def test_pixfun_mod_r(): if not numpy_available: return 'skip' @@ -244,7 +244,7 @@ def pixfun_mod_r(): ############################################################################### # Verify phase extraction from a complex dataset. -def pixfun_phase_c(): +def test_pixfun_phase_c(): if not numpy_available: return 'skip' @@ -274,7 +274,7 @@ def pixfun_phase_c(): ############################################################################### # Verify phase extraction from a real dataset. -def pixfun_phase_r(): +def test_pixfun_phase_r(): if not numpy_available: return 'skip' @@ -302,7 +302,7 @@ def pixfun_phase_r(): ############################################################################### # Verify cmplex conjugare computation on a complex dataset. -def pixfun_conj_c(): +def test_pixfun_conj_c(): if not numpy_available: return 'skip' @@ -330,7 +330,7 @@ def pixfun_conj_c(): ############################################################################### # Verify cmplex conjugare computation on a real dataset. -def pixfun_conj_r(): +def test_pixfun_conj_r(): if not numpy_available: return 'skip' @@ -358,7 +358,7 @@ def pixfun_conj_r(): ############################################################################### # Verify the sum of 3 (real) datasets. -def pixfun_sum_r(): +def test_pixfun_sum_r(): if not numpy_available: return 'skip' @@ -389,7 +389,7 @@ def pixfun_sum_r(): ############################################################################### # Verify the sum of 3 (two complex and one real) datasets. -def pixfun_sum_c(): +def test_pixfun_sum_c(): if not numpy_available: return 'skip' @@ -420,7 +420,7 @@ def pixfun_sum_c(): ############################################################################### # Verify the difference of 2 (real) datasets. -def pixfun_diff_r(): +def test_pixfun_diff_r(): if not numpy_available: return 'skip' @@ -455,7 +455,7 @@ def pixfun_diff_r(): ############################################################################### # Verify the difference of 2 (complex) datasets. -def pixfun_diff_c(): +def test_pixfun_diff_c(): if not numpy_available: return 'skip' @@ -490,7 +490,7 @@ def pixfun_diff_c(): ############################################################################### # Verify the product of 3 (real) datasets. -def pixfun_mul_r(): +def test_pixfun_mul_r(): if not numpy_available: return 'skip' @@ -521,7 +521,7 @@ def pixfun_mul_r(): ############################################################################### # Verify the product of 2 (complex) datasets. -def pixfun_mul_c(): +def test_pixfun_mul_c(): if not numpy_available: return 'skip' @@ -549,7 +549,7 @@ def pixfun_mul_c(): ############################################################################### # Verify the product with complex conjugate of a complex datasets. -def pixfun_cmul_c(): +def test_pixfun_cmul_c(): if not numpy_available: return 'skip' @@ -577,7 +577,7 @@ def pixfun_cmul_c(): ############################################################################### # Verify the product with complex conjugate of two real datasets. -def pixfun_cmul_r(): +def test_pixfun_cmul_r(): if not numpy_available: return 'skip' @@ -614,7 +614,7 @@ def pixfun_cmul_r(): ############################################################################### # Verify computation of the inverse of a real datasets. -def pixfun_inv_r(): +def test_pixfun_inv_r(): if not numpy_available: return 'skip' @@ -643,7 +643,7 @@ def pixfun_inv_r(): ############################################################################### # Verify computation of the inverse of a complex datasets. -def pixfun_inv_c(): +def test_pixfun_inv_c(): if not numpy_available: return 'skip' @@ -675,7 +675,7 @@ def pixfun_inv_c(): ############################################################################### # Verify intensity computation of a complex dataset. -def pixfun_intensity_c(): +def test_pixfun_intensity_c(): if not numpy_available: return 'skip' @@ -703,7 +703,7 @@ def pixfun_intensity_c(): ############################################################################### # Verify intensity computation of real dataset. -def pixfun_intensity_r(): +def test_pixfun_intensity_r(): if not numpy_available: return 'skip' @@ -731,7 +731,7 @@ def pixfun_intensity_r(): ############################################################################### # Verify square root computation. -def pixfun_sqrt(): +def test_pixfun_sqrt(): if not numpy_available: return 'skip' @@ -759,7 +759,7 @@ def pixfun_sqrt(): ############################################################################### # Verify logarithm computation of real dataset. -def pixfun_log10_r(): +def test_pixfun_log10_r(): if not numpy_available: return 'skip' @@ -787,7 +787,7 @@ def pixfun_log10_r(): ############################################################################### # Verify logarithm computation of imag dataset. -def pixfun_log10_c(): +def test_pixfun_log10_c(): if not numpy_available: return 'skip' @@ -814,7 +814,7 @@ def pixfun_log10_c(): ############################################################################### # Verify dB computation of real dataset. -def pixfun_dB_r(): +def test_pixfun_dB_r(): if not numpy_available: return 'skip' @@ -842,7 +842,7 @@ def pixfun_dB_r(): ############################################################################### # Verify dB computation of imag dataset. -def pixfun_dB_c(): +def test_pixfun_dB_c(): if not numpy_available: return 'skip' @@ -869,7 +869,7 @@ def pixfun_dB_c(): ############################################################################### # Verify conversion from dB to amplitude. -def pixfun_dB2amp(): +def test_pixfun_dB2amp(): if not numpy_available: return 'skip' @@ -898,7 +898,7 @@ def pixfun_dB2amp(): ############################################################################### # Verify conversion from dB to power. -def pixfun_dB2pow(): +def test_pixfun_dB2pow(): if not numpy_available: return 'skip' @@ -927,36 +927,36 @@ def pixfun_dB2pow(): ############################################################################### gdaltest_list = [ - pixfun_real_c, - pixfun_real_r, - pixfun_imag_c, - pixfun_imag_r, - pixfun_complex, - pixfun_mod_c, - pixfun_mod_r, - pixfun_phase_c, - pixfun_phase_r, - pixfun_conj_c, - pixfun_conj_r, - pixfun_sum_r, - pixfun_sum_c, - pixfun_diff_r, - pixfun_diff_c, - pixfun_mul_r, - pixfun_mul_c, - pixfun_cmul_c, - pixfun_cmul_r, - pixfun_inv_r, - pixfun_inv_c, - pixfun_intensity_c, - pixfun_intensity_r, - pixfun_sqrt, - pixfun_log10_r, - pixfun_log10_c, - pixfun_dB_r, - pixfun_dB_c, - pixfun_dB2amp, - pixfun_dB2pow, + test_pixfun_real_c, + test_pixfun_real_r, + test_pixfun_imag_c, + test_pixfun_imag_r, + test_pixfun_complex, + test_pixfun_mod_c, + test_pixfun_mod_r, + test_pixfun_phase_c, + test_pixfun_phase_r, + test_pixfun_conj_c, + test_pixfun_conj_r, + test_pixfun_sum_r, + test_pixfun_sum_c, + test_pixfun_diff_r, + test_pixfun_diff_c, + test_pixfun_mul_r, + test_pixfun_mul_c, + test_pixfun_cmul_c, + test_pixfun_cmul_r, + test_pixfun_inv_r, + test_pixfun_inv_c, + test_pixfun_intensity_c, + test_pixfun_intensity_r, + test_pixfun_sqrt, + test_pixfun_log10_r, + test_pixfun_log10_c, + test_pixfun_dB_r, + test_pixfun_dB_c, + test_pixfun_dB2amp, + test_pixfun_dB2pow, ] diff --git a/autotest/gcore/rasterio.py b/autotest/gcore/rasterio.py index 5d7a9f2bdae7..d720c1816fae 100755 --- a/autotest/gcore/rasterio.py +++ b/autotest/gcore/rasterio.py @@ -40,7 +40,7 @@ # Test writing a 1x1 buffer to a 10x6 raster and read it back -def rasterio_1(): +def test_rasterio_1(): data = 'A'.encode('ascii') drv = gdal.GetDriverByName('GTiff') @@ -70,7 +70,7 @@ def rasterio_1(): # Test writing a 5x4 buffer to a 10x6 raster and read it back -def rasterio_2(): +def test_rasterio_2(): data = 'AAAAAAAAAAAAAAAAAAAA'.encode('ascii') drv = gdal.GetDriverByName('GTiff') @@ -100,7 +100,7 @@ def rasterio_2(): # Test extensive read & writes into a non tiled raster -def rasterio_3(): +def test_rasterio_3(): data = [['' for i in range(4)] for i in range(5)] for xsize in range(5): @@ -144,7 +144,7 @@ def rasterio_3(): # Test extensive read & writes into a tiled raster -def rasterio_4(): +def test_rasterio_4(): data = ['' for i in range(5 * 4)] for size in range(5 * 4): @@ -196,7 +196,7 @@ def rasterio_4(): # Test error cases of ReadRaster() -def rasterio_5(): +def test_rasterio_5(): ds = gdal.Open('data/byte.tif') @@ -282,7 +282,7 @@ def rasterio_5(): # Test error cases of WriteRaster() -def rasterio_6(): +def test_rasterio_6(): ds = gdal.GetDriverByName('MEM').Create('', 2, 2) @@ -332,7 +332,7 @@ def rasterio_6(): # Test that default window reading works via ReadRaster() -def rasterio_7(): +def test_rasterio_7(): ds = gdal.Open('data/byte.tif') @@ -378,7 +378,7 @@ def rasterio_8_progress_callback_2(pct, message, user_data): return 1 # 1 to continue, 0 to stop -def rasterio_8(): +def test_rasterio_8(): ds = gdal.Open('data/byte.tif') @@ -529,7 +529,7 @@ def rasterio_9_checksum(data, buf_xsize, buf_ysize, data_type=gdal.GDT_Byte): return cs -def rasterio_9(): +def test_rasterio_9(): ds = gdal.Open('data/byte.tif') # Test RasterBand.ReadRaster, with Bilinear @@ -806,7 +806,7 @@ def rasterio_9(): # Test error when getting a block -def rasterio_10(): +def test_rasterio_10(): ds = gdal.Open('data/byte_truncated.tif') gdal.PushErrorHandler() @@ -839,7 +839,7 @@ def rasterio_10(): # Test cubic resampling and nbits -def rasterio_11(): +def test_rasterio_11(): try: from osgeo import gdalnumeric @@ -882,7 +882,7 @@ def rasterio_12_progress_callback(pct, message, user_data): return 1 # 1 to continue, 0 to stop -def rasterio_12(): +def test_rasterio_12(): try: from osgeo import gdalnumeric @@ -944,7 +944,7 @@ def rasterio_12(): # Test cubic resampling with masking -def rasterio_13(): +def test_rasterio_13(): try: from osgeo import gdalnumeric @@ -975,7 +975,7 @@ def rasterio_13(): # Test average downsampling by a factor of 2 on exact boundaries -def rasterio_14(): +def test_rasterio_14(): gdal.FileFromMemBuffer('/vsimem/rasterio_14.asc', """ncols 6 @@ -1039,7 +1039,7 @@ def rasterio_14(): # Test average oversampling by an integer factor (should behave like nearest) -def rasterio_15(): +def test_rasterio_15(): gdal.FileFromMemBuffer('/vsimem/rasterio_15.asc', """ncols 2 @@ -1071,7 +1071,7 @@ def rasterio_15(): # Test mode downsampling by a factor of 2 on exact boundaries -def rasterio_16(): +def test_rasterio_16(): gdal.FileFromMemBuffer('/vsimem/rasterio_16.asc', """ncols 6 @@ -1102,7 +1102,7 @@ def rasterio_16(): ############################################################################### -def rasterio_lanczos_nodata(): +def test_rasterio_lanczos_nodata(): ds = gdal.Open('data/rasterio_lanczos_nodata.tif') @@ -1129,7 +1129,7 @@ def rasterio_lanczos_nodata(): ############################################################################### -def rasterio_resampled_value_is_nodata(): +def test_rasterio_resampled_value_is_nodata(): gdal.FileFromMemBuffer('/vsimem/in.asc', """ncols 4 @@ -1207,24 +1207,24 @@ def rasterio_resampled_value_is_nodata(): return 'success' gdaltest_list = [ - rasterio_1, - rasterio_2, - rasterio_3, - rasterio_4, - rasterio_5, - rasterio_6, - rasterio_7, - rasterio_8, - rasterio_9, - rasterio_10, - rasterio_11, - rasterio_12, - rasterio_13, - rasterio_14, - rasterio_15, - rasterio_16, - rasterio_lanczos_nodata, - rasterio_resampled_value_is_nodata, + test_rasterio_1, + test_rasterio_2, + test_rasterio_3, + test_rasterio_4, + test_rasterio_5, + test_rasterio_6, + test_rasterio_7, + test_rasterio_8, + test_rasterio_9, + test_rasterio_10, + test_rasterio_11, + test_rasterio_12, + test_rasterio_13, + test_rasterio_14, + test_rasterio_15, + test_rasterio_16, + test_rasterio_lanczos_nodata, + test_rasterio_resampled_value_is_nodata, ] # gdaltest_list = [ rasterio_16 ] diff --git a/autotest/gcore/rat.py b/autotest/gcore/rat.py index 752380dcb07a..288493c92180 100755 --- a/autotest/gcore/rat.py +++ b/autotest/gcore/rat.py @@ -40,7 +40,7 @@ # Create a raster attribute table. -def rat_1(): +def test_rat_1(): gdaltest.saved_rat = None @@ -98,7 +98,7 @@ def rat_1(): # Save a RAT in a file, written to .aux.xml, read it back and check it. -def rat_2(): +def test_rat_2(): if gdaltest.saved_rat is None: return 'skip' @@ -162,7 +162,7 @@ def rat_2(): # Save an empty RAT (#5451) -def rat_3(): +def test_rat_3(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/rat_3.tif', 1, 1) ds.GetRasterBand(1).SetDefaultRAT(gdal.RasterAttributeTable()) @@ -175,9 +175,9 @@ def rat_3(): gdaltest_list = [ - rat_1, - rat_2, - rat_3, + test_rat_1, + test_rat_2, + test_rat_3, None] if __name__ == '__main__': diff --git a/autotest/gcore/rfc30.py b/autotest/gcore/rfc30.py index d11fa0f6df57..8b04388963db 100755 --- a/autotest/gcore/rfc30.py +++ b/autotest/gcore/rfc30.py @@ -40,7 +40,7 @@ # Try opening a file with a Chinese name using the Python UTF-8 string. -def rfc30_1(): +def test_rfc30_1(): if version_info >= (3, 0, 0): filename = 'xx\u4E2D\u6587.\u4E2D\u6587' @@ -76,7 +76,7 @@ def rfc30_1(): # Try creating, then renaming a utf-8 named file. -def rfc30_2(): +def test_rfc30_2(): if version_info >= (3, 0, 0): filename = 'tmp/yy\u4E2D\u6587.\u4E2D\u6587' @@ -133,7 +133,7 @@ def rfc30_2(): return 'success' -gdaltest_list = [rfc30_1, rfc30_2] +gdaltest_list = [test_rfc30_1, test_rfc30_2] if __name__ == '__main__': diff --git a/autotest/gcore/testnonboundtoswig.py b/autotest/gcore/testnonboundtoswig.py index 3751c9de9f86..c230852740a4 100755 --- a/autotest/gcore/testnonboundtoswig.py +++ b/autotest/gcore/testnonboundtoswig.py @@ -56,7 +56,7 @@ def find_libgdal(): # Init -def testnonboundtoswig_init(): +def test_testnonboundtoswig_init(): global gdal_handle_init, gdal_handle, gdal_handle_stdcall @@ -114,7 +114,7 @@ def testnonboundtoswig_init(): def GDALDestroyDriverManager(): if gdal_handle is None: - testnonboundtoswig_init() + test_testnonboundtoswig_init() if gdal_handle is None: return 'skip' @@ -133,7 +133,7 @@ def GDALDestroyDriverManager(): def OGRCleanupAll(): if gdal_handle is None: - testnonboundtoswig_init() + test_testnonboundtoswig_init() if gdal_handle is None: return 'skip' @@ -152,7 +152,7 @@ def OGRCleanupAll(): def OSRCleanup(): if gdal_handle is None: - testnonboundtoswig_init() + test_testnonboundtoswig_init() if gdal_handle is None: return 'skip' @@ -168,7 +168,7 @@ def OSRCleanup(): # Test GDALSimpleImageWarp -def testnonboundtoswig_GDALSimpleImageWarp(): +def test_testnonboundtoswig_GDALSimpleImageWarp(): if gdal_handle is None: return 'skip' @@ -307,7 +307,7 @@ def my_pyDerivedPixelFunc(papoSources, nSources, pData, nBufXSize, nBufYSize, eS return 0 -def testnonboundtoswig_VRTDerivedBands(): +def test_testnonboundtoswig_VRTDerivedBands(): if gdal_handle is None: return 'skip' @@ -376,9 +376,9 @@ def testnonboundtoswig_VRTDerivedBands(): return 'success' -gdaltest_list = [testnonboundtoswig_init, - testnonboundtoswig_GDALSimpleImageWarp, - testnonboundtoswig_VRTDerivedBands] +gdaltest_list = [test_testnonboundtoswig_init, + test_testnonboundtoswig_GDALSimpleImageWarp, + test_testnonboundtoswig_VRTDerivedBands] if __name__ == '__main__': diff --git a/autotest/gcore/thread_test.py b/autotest/gcore/thread_test.py index 24ad6b8a37de..bfe07c8e0a6e 100755 --- a/autotest/gcore/thread_test.py +++ b/autotest/gcore/thread_test.py @@ -56,7 +56,7 @@ def thread_test_1_worker(args_dict): gdal.PopErrorHandler() -def thread_test_1(): +def test_thread_test_1(): try: from osgeo import gdalnumeric @@ -82,7 +82,7 @@ def thread_test_1(): return ret -gdaltest_list = [thread_test_1] +gdaltest_list = [test_thread_test_1] if __name__ == '__main__': diff --git a/autotest/gcore/tiff_ovr.py b/autotest/gcore/tiff_ovr.py index 4c404f22d4ec..9324d976606b 100755 --- a/autotest/gcore/tiff_ovr.py +++ b/autotest/gcore/tiff_ovr.py @@ -94,7 +94,7 @@ def tiff_ovr_check(src_ds): # later. Build overviews on it. -def tiff_ovr_1(both_endian): +def test_tiff_ovr_1(both_endian): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') @@ -130,7 +130,7 @@ def tiff_ovr_1(both_endian): ############################################################################### # Open file and verify some characteristics of the overviews. -def tiff_ovr_2(both_endian): +def test_tiff_ovr_2(both_endian): src_ds = gdal.Open('tmp/mfloat32.tif') @@ -148,7 +148,7 @@ def tiff_ovr_2(both_endian): # Open target file in update mode, and create internal overviews. -def tiff_ovr_3(both_endian): +def test_tiff_ovr_3(both_endian): os.unlink('tmp/mfloat32.tif.ovr') @@ -173,14 +173,14 @@ def tiff_ovr_3(both_endian): # Re-open target file and check overviews -def tiff_ovr_3bis(both_endian): - return tiff_ovr_2(both_endian) +def test_tiff_ovr_3bis(both_endian): + return test_tiff_ovr_2(both_endian) ############################################################################### # Test generation -def tiff_ovr_4(both_endian): +def test_tiff_ovr_4(both_endian): shutil.copyfile('data/oddsize_1bit2b.tif', 'tmp/ovr4.tif') @@ -256,7 +256,7 @@ def tiff_ovr_4(both_endian): ############################################################################### # Test average overview generation with nodata. -def tiff_ovr_5(both_endian): +def test_tiff_ovr_5(both_endian): shutil.copyfile('data/nodata_byte.tif', 'tmp/ovr5.tif') @@ -282,7 +282,7 @@ def tiff_ovr_5(both_endian): # Same as tiff_ovr_5 but with USE_RDD=YES to force external overview -def tiff_ovr_6(both_endian): +def test_tiff_ovr_6(both_endian): shutil.copyfile('data/nodata_byte.tif', 'tmp/ovr6.tif') @@ -319,7 +319,7 @@ def tiff_ovr_6(both_endian): ############################################################################### # Check nearest resampling on a dataset with a raster band that has a color table -def tiff_ovr_7(both_endian): +def test_tiff_ovr_7(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/test_average_palette.tif') @@ -349,7 +349,7 @@ def tiff_ovr_7(both_endian): # Check average resampling on a dataset with a raster band that has a color table -def tiff_ovr_8(both_endian): +def test_tiff_ovr_8(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/test_average_palette.tif') @@ -381,7 +381,7 @@ def tiff_ovr_8(both_endian): # Will also check that pixel interleaving is automatically selected (#3064) -def tiff_ovr_9(both_endian): +def test_tiff_ovr_9(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -433,7 +433,7 @@ def tiff_ovr_9(both_endian): # Similar to tiff_ovr_9 but with internal overviews. -def tiff_ovr_10(both_endian): +def test_tiff_ovr_10(both_endian): src_ds = gdal.Open('data/rgbsmall.tif', gdal.GA_ReadOnly) @@ -473,7 +473,7 @@ def tiff_ovr_10(both_endian): # Overview on a dataset with NODATA_VALUES -def tiff_ovr_11(both_endian): +def test_tiff_ovr_11(both_endian): src_ds = gdal.Open('data/test_nodatavalues.tif', gdal.GA_ReadOnly) @@ -520,7 +520,7 @@ def tiff_ovr_11(both_endian): # code -def tiff_ovr_12(both_endian): +def test_tiff_ovr_12(both_endian): src_ds = gdal.Open('data/test_nodatavalues.tif', gdal.GA_ReadOnly) @@ -566,7 +566,7 @@ def tiff_ovr_12(both_endian): ############################################################################### # Test gaussian resampling -def tiff_ovr_13(both_endian): +def test_tiff_ovr_13(both_endian): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') @@ -604,7 +604,7 @@ def tiff_ovr_13(both_endian): # Check gauss resampling on a dataset with a raster band that has a color table -def tiff_ovr_14(both_endian): +def test_tiff_ovr_14(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/test_gauss_palette.tif') @@ -633,7 +633,7 @@ def tiff_ovr_14(both_endian): # code -def tiff_ovr_15(both_endian): +def test_tiff_ovr_15(both_endian): src_ds = gdal.Open('data/test_nodatavalues.tif', gdal.GA_ReadOnly) @@ -679,7 +679,7 @@ def tiff_ovr_15(both_endian): ############################################################################### # Test mode resampling on non-byte dataset -def tiff_ovr_16(both_endian): +def test_tiff_ovr_16(both_endian): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') @@ -720,7 +720,7 @@ def tiff_ovr_16(both_endian): ############################################################################### # Test mode resampling on a byte dataset -def tiff_ovr_17(both_endian): +def test_tiff_ovr_17(both_endian): shutil.copyfile('data/byte.tif', 'tmp/ovr17.tif') @@ -751,7 +751,7 @@ def tiff_ovr_17(both_endian): # Check mode resampling on a dataset with a raster band that has a color table -def tiff_ovr_18(both_endian): +def test_tiff_ovr_18(both_endian): shutil.copyfile('data/test_average_palette.tif', 'tmp/ovr18.tif') @@ -781,7 +781,7 @@ def tiff_ovr_18(both_endian): # if BigTIFF is not supported (this is a sign of an older libtiff...) -def tiff_ovr_19(both_endian): +def test_tiff_ovr_19(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -819,7 +819,7 @@ def tiff_ovr_19(both_endian): ############################################################################### # Test BIGTIFF_OVERVIEW=YES option -def tiff_ovr_20(both_endian): +def test_tiff_ovr_20(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -857,7 +857,7 @@ def tiff_ovr_20(both_endian): ############################################################################### # Test BIGTIFF_OVERVIEW=IF_NEEDED option -def tiff_ovr_21(both_endian): +def test_tiff_ovr_21(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -895,7 +895,7 @@ def tiff_ovr_21(both_endian): # Test BIGTIFF_OVERVIEW=NO option when BigTIFF is really needed -def tiff_ovr_22(both_endian): +def test_tiff_ovr_22(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -930,7 +930,7 @@ def tiff_ovr_22(both_endian): # method for the overviews. -def tiff_ovr_23(both_endian): +def test_tiff_ovr_23(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -970,7 +970,7 @@ def tiff_ovr_23(both_endian): # Test BIGTIFF_OVERVIEW=IF_SAFER option -def tiff_ovr_24(both_endian): +def test_tiff_ovr_24(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -1011,7 +1011,7 @@ def tiff_ovr_24(both_endian): # band and actually flushed -def tiff_ovr_25(both_endian): +def test_tiff_ovr_25(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr25.tif', 100, 100, 1) ds.GetRasterBand(1).Fill(1) @@ -1038,7 +1038,7 @@ def tiff_ovr_25(both_endian): # Test gdal.RegenerateOverview() -def tiff_ovr_26(both_endian): +def test_tiff_ovr_26(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr26.tif', 100, 100, 1) ds.GetRasterBand(1).Fill(1) @@ -1061,7 +1061,7 @@ def tiff_ovr_26(both_endian): # Test gdal.RegenerateOverviews() -def tiff_ovr_27(both_endian): +def test_tiff_ovr_27(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr27.tif', 100, 100, 1) ds.GetRasterBand(1).Fill(1) @@ -1090,7 +1090,7 @@ def tiff_ovr_27(both_endian): # Test cleaning overviews. -def tiff_ovr_28(both_endian): +def test_tiff_ovr_28(both_endian): ds = gdal.Open('tmp/ovr25.tif', gdal.GA_Update) if ds.BuildOverviews(overviewlist=[]) != 0: @@ -1114,7 +1114,7 @@ def tiff_ovr_28(both_endian): # Test cleaning external overviews (ovr) on a non-TIFF format. -def tiff_ovr_29(both_endian): +def test_tiff_ovr_29(both_endian): src_ds = gdal.Open('data/byte.tif') png_ds = gdal.GetDriverByName('PNG').CreateCopy('tmp/ovr29.png', src_ds) @@ -1162,7 +1162,7 @@ def tiff_ovr_29(both_endian): # Test fix for #2988. -def tiff_ovr_30(both_endian): +def test_tiff_ovr_30(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr30.tif', 20, 20, 1) ds.BuildOverviews(overviewlist=[2]) @@ -1192,7 +1192,7 @@ def tiff_ovr_30(both_endian): # Test fix for #3033 -def tiff_ovr_31(both_endian): +def test_tiff_ovr_31(both_endian): ds = gdaltest.tiff_drv.Create('tmp/ovr31.tif', 100, 100, 4) ds.GetRasterBand(1).Fill(255) @@ -1213,7 +1213,7 @@ def tiff_ovr_31(both_endian): # Test Cubic sampling. -def tiff_ovr_32(both_endian): +def test_tiff_ovr_32(both_endian): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -1372,7 +1372,7 @@ def tiff_ovr_32(both_endian): ############################################################################### # Test creation of overviews on a 1x1 dataset (fix for #3069) -def tiff_ovr_33(both_endian): +def test_tiff_ovr_33(both_endian): try: os.remove('tmp/ovr33.tif.ovr') @@ -1393,7 +1393,7 @@ def tiff_ovr_33(both_endian): ############################################################################### # Confirm that overviews are used on a Band.RasterIO(). -def tiff_ovr_34(both_endian): +def test_tiff_ovr_34(both_endian): ds_in = gdal.Open('data/byte.tif') ds = gdaltest.tiff_drv.CreateCopy('tmp/ovr34.tif', ds_in) @@ -1419,7 +1419,7 @@ def tiff_ovr_34(both_endian): # Confirm that overviews are used on a Band.RasterIO(). -def tiff_ovr_35(both_endian): +def test_tiff_ovr_35(both_endian): ds_in = gdal.Open('data/byte.tif') ds = gdaltest.tiff_drv.CreateCopy('tmp/ovr35.tif', ds_in) @@ -1445,12 +1445,12 @@ def tiff_ovr_35(both_endian): # Confirm that overviews are used on a Band.RasterIO() when using BlockBasedRasterIO() (#3124) -def tiff_ovr_36(both_endian): +def test_tiff_ovr_36(both_endian): oldval = gdal.GetConfigOption('GDAL_FORCE_CACHING', 'NO') gdal.SetConfigOption('GDAL_FORCE_CACHING', 'YES') - ret = tiff_ovr_35(both_endian) + ret = test_tiff_ovr_35(both_endian) gdal.SetConfigOption('GDAL_FORCE_CACHING', oldval) @@ -1460,7 +1460,7 @@ def tiff_ovr_36(both_endian): # Test PREDICTOR_OVERVIEW=2 option. (#3414) -def tiff_ovr_37(both_endian): +def test_tiff_ovr_37(both_endian): shutil.copy('../gdrivers/data/n43.dt0', 'tmp/ovr37.dt0') @@ -1500,7 +1500,7 @@ def tiff_ovr_37(both_endian): # Test that the predictor flag gets well propagated to internal overviews -def tiff_ovr_38(both_endian): +def test_tiff_ovr_38(both_endian): # Skip with old libtiff (crash with 3.8.2) md = gdaltest.tiff_drv.GetMetadata() @@ -1525,7 +1525,7 @@ def tiff_ovr_38(both_endian): # Test external overviews on all datatypes -def tiff_ovr_39(both_endian): +def test_tiff_ovr_39(both_endian): for datatype in [gdal.GDT_Byte, gdal.GDT_Int16, @@ -1577,7 +1577,7 @@ def tiff_ovr_39(both_endian): # Test external overviews on 1 bit datasets with AVERAGE_BIT2GRAYSCALE (similar to tiff_ovr_4) -def tiff_ovr_40(both_endian): +def test_tiff_ovr_40(both_endian): shutil.copyfile('data/oddsize_1bit2b.tif', 'tmp/ovr40.tif') @@ -1653,7 +1653,7 @@ def tiff_ovr_40(both_endian): # Test external overviews on 1 bit datasets with NEAREST -def tiff_ovr_41(both_endian): +def test_tiff_ovr_41(both_endian): shutil.copyfile('data/oddsize_1bit2b.tif', 'tmp/ovr41.tif') @@ -1681,7 +1681,7 @@ def tiff_ovr_41(both_endian): # Test external overviews on dataset with color table -def tiff_ovr_42(both_endian): +def test_tiff_ovr_42(both_endian): ct_data = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)] @@ -1717,7 +1717,7 @@ def tiff_ovr_42(both_endian): # jpeg-in-tiff (#3539) -def tiff_ovr_43(both_endian): +def test_tiff_ovr_43(both_endian): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -1781,7 +1781,7 @@ def tiff_ovr_43(both_endian): # option -def tiff_ovr_44(both_endian): +def test_tiff_ovr_44(both_endian): shutil.copyfile('data/byte.tif', 'tmp/ovr44.tif') gdal.SetConfigOption('GDAL_TIFF_OVR_BLOCKSIZE', '256') @@ -1813,7 +1813,7 @@ def tiff_ovr_44(both_endian): # Same as tiff_ovr_44, but with external overviews -def tiff_ovr_45(both_endian): +def test_tiff_ovr_45(both_endian): shutil.copyfile('data/byte.tif', 'tmp/ovr45.tif') gdal.SetConfigOption('GDAL_TIFF_OVR_BLOCKSIZE', '256') @@ -1845,7 +1845,7 @@ def tiff_ovr_45(both_endian): # Test overview on a dataset where width * height > 2 billion -def tiff_ovr_46(): +def test_tiff_ovr_46(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -1942,7 +1942,7 @@ def tiff_ovr_46(): # Test workaround with libtiff 3.X when creating interleaved overviews -def tiff_ovr_47(both_endian): +def test_tiff_ovr_47(both_endian): mem_drv = gdal.GetDriverByName('MEM') mem_ds = mem_drv.Create('', 852, 549, 3) @@ -1973,7 +1973,7 @@ def tiff_ovr_47(both_endian): # Test that we don't average 0's in alpha band -def tiff_ovr_48(both_endian): +def test_tiff_ovr_48(both_endian): shutil.copy('data/rgba_with_alpha_0_and_255.tif', 'tmp') ds = gdal.Open('tmp/rgba_with_alpha_0_and_255.tif') @@ -2009,7 +2009,7 @@ def tiff_ovr_48(both_endian): # Test possible stride computation issue in GDALRegenerateOverviewsMultiBand (#5653) -def tiff_ovr_49(both_endian): +def test_tiff_ovr_49(both_endian): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_ovr_49.tif', 1023, 1023, 1) ds.GetRasterBand(1).Fill(0) @@ -2036,7 +2036,7 @@ def tiff_ovr_49(both_endian): # Test overviews when X dimension is smaller than Y (#5794) -def tiff_ovr_50(both_endian): +def test_tiff_ovr_50(both_endian): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_ovr_50.tif', 6, 8192, 3, options=['COMPRESS=DEFLATE']) @@ -2053,7 +2053,7 @@ def tiff_ovr_50(both_endian): # Test average overview on a color palette with nodata values (#6371) -def tiff_ovr_51(): +def test_tiff_ovr_51(): src_ds = gdal.Open('data/stefan_full_rgba_pct32.png') if src_ds is None: @@ -2078,7 +2078,7 @@ def tiff_ovr_51(): # Test unsorted external overview building (#6617) -def tiff_ovr_52(): +def test_tiff_ovr_52(): src_ds = gdal.Open('data/byte.tif') if src_ds is None: @@ -2141,7 +2141,7 @@ def tiff_ovr_52(): # Test external overviews building in several steps -def tiff_ovr_53(): +def test_tiff_ovr_53(): src_ds = gdal.Open('data/byte.tif') if src_ds is None: @@ -2208,7 +2208,7 @@ def tiff_ovr_53(): # Test external overviews building in several steps with jpeg compression -def tiff_ovr_54(): +def test_tiff_ovr_54(): drv = gdal.GetDriverByName('GTiff') md = drv.GetMetadata() @@ -2248,7 +2248,7 @@ def tiff_ovr_54(): ############################################################################### -def tiff_ovr_too_many_levels_contig(): +def test_tiff_ovr_too_many_levels_contig(): src_ds = gdal.Open('data/byte.tif') tmpfilename = '/vsimem/tiff_ovr_too_many_levels_contig.tif' @@ -2270,7 +2270,7 @@ def tiff_ovr_too_many_levels_contig(): ############################################################################### -def tiff_ovr_too_many_levels_separate(): +def test_tiff_ovr_too_many_levels_separate(): src_ds = gdal.Open('data/separate_tiled.tif') tmpfilename = '/vsimem/tiff_ovr_too_many_levels_separate.tif' @@ -2292,7 +2292,7 @@ def tiff_ovr_too_many_levels_separate(): ############################################################################### -def tiff_ovr_too_many_levels_external(): +def test_tiff_ovr_too_many_levels_external(): src_ds = gdal.Open('data/byte.tif') tmpfilename = '/vsimem/tiff_ovr_too_many_levels_contig.tif' @@ -2314,7 +2314,7 @@ def tiff_ovr_too_many_levels_external(): ############################################################################### -def tiff_ovr_average_multiband_vs_singleband(): +def test_tiff_ovr_average_multiband_vs_singleband(): gdal.Translate('/vsimem/tiff_ovr_average_multiband_band.tif', 'data/reproduce_average_issue.tif', creationOptions=['INTERLEAVE=BAND']) gdal.Translate('/vsimem/tiff_ovr_average_multiband_pixel.tif', 'data/reproduce_average_issue.tif', creationOptions=['INTERLEAVE=PIXEL']) @@ -2341,65 +2341,65 @@ def tiff_ovr_average_multiband_vs_singleband(): gdaltest_list = [ - tiff_ovr_1, - tiff_ovr_2, - tiff_ovr_3, - tiff_ovr_3bis, - tiff_ovr_4, - tiff_ovr_5, - tiff_ovr_6, - tiff_ovr_7, - tiff_ovr_8, - tiff_ovr_9, - tiff_ovr_10, - tiff_ovr_11, - tiff_ovr_12, - tiff_ovr_13, - tiff_ovr_14, - tiff_ovr_15, - tiff_ovr_16, - tiff_ovr_17, - tiff_ovr_18, - tiff_ovr_19, - tiff_ovr_20, - tiff_ovr_21, - tiff_ovr_22, - tiff_ovr_23, - tiff_ovr_24, - tiff_ovr_25, - tiff_ovr_26, - tiff_ovr_27, - tiff_ovr_28, - tiff_ovr_29, - tiff_ovr_30, - tiff_ovr_31, - tiff_ovr_32, - tiff_ovr_33, - tiff_ovr_34, - tiff_ovr_35, - tiff_ovr_36, - tiff_ovr_37, - tiff_ovr_38, - tiff_ovr_39, - tiff_ovr_40, - tiff_ovr_41, - tiff_ovr_42, - tiff_ovr_43, - tiff_ovr_44, - tiff_ovr_45, - tiff_ovr_46, - tiff_ovr_47, - tiff_ovr_48, - tiff_ovr_49, - tiff_ovr_50, - tiff_ovr_51, - tiff_ovr_52, - tiff_ovr_53, - tiff_ovr_54, - tiff_ovr_too_many_levels_contig, - tiff_ovr_too_many_levels_separate, - tiff_ovr_too_many_levels_external, - tiff_ovr_average_multiband_vs_singleband + test_tiff_ovr_1, + test_tiff_ovr_2, + test_tiff_ovr_3, + test_tiff_ovr_3bis, + test_tiff_ovr_4, + test_tiff_ovr_5, + test_tiff_ovr_6, + test_tiff_ovr_7, + test_tiff_ovr_8, + test_tiff_ovr_9, + test_tiff_ovr_10, + test_tiff_ovr_11, + test_tiff_ovr_12, + test_tiff_ovr_13, + test_tiff_ovr_14, + test_tiff_ovr_15, + test_tiff_ovr_16, + test_tiff_ovr_17, + test_tiff_ovr_18, + test_tiff_ovr_19, + test_tiff_ovr_20, + test_tiff_ovr_21, + test_tiff_ovr_22, + test_tiff_ovr_23, + test_tiff_ovr_24, + test_tiff_ovr_25, + test_tiff_ovr_26, + test_tiff_ovr_27, + test_tiff_ovr_28, + test_tiff_ovr_29, + test_tiff_ovr_30, + test_tiff_ovr_31, + test_tiff_ovr_32, + test_tiff_ovr_33, + test_tiff_ovr_34, + test_tiff_ovr_35, + test_tiff_ovr_36, + test_tiff_ovr_37, + test_tiff_ovr_38, + test_tiff_ovr_39, + test_tiff_ovr_40, + test_tiff_ovr_41, + test_tiff_ovr_42, + test_tiff_ovr_43, + test_tiff_ovr_44, + test_tiff_ovr_45, + test_tiff_ovr_46, + test_tiff_ovr_47, + test_tiff_ovr_48, + test_tiff_ovr_49, + test_tiff_ovr_50, + test_tiff_ovr_51, + test_tiff_ovr_52, + test_tiff_ovr_53, + test_tiff_ovr_54, + test_tiff_ovr_too_many_levels_contig, + test_tiff_ovr_too_many_levels_separate, + test_tiff_ovr_too_many_levels_external, + test_tiff_ovr_average_multiband_vs_singleband ] if __name__ == '__main__': diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index d6704c8c51ad..fc56fe63006b 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -83,7 +83,7 @@ def test_tiff_open(filename, band, checksum): # Test absolute/offset && index directory access -def tiff_read_off(): +def test_tiff_read_off(): # Test absolute/offset directory access. ds = gdal.Open('GTIFF_DIR:off:408:data/byte.tif') @@ -158,7 +158,7 @@ def tiff_read_off(): # Confirm we interpret bands as alpha when we should, and not when we # should not. -def tiff_check_alpha(): +def test_tiff_check_alpha(): # Grey + alpha @@ -236,7 +236,7 @@ def tiff_check_alpha(): ############################################################################### # Test reading a CMYK tiff as RGBA image -def tiff_read_cmyk_rgba(): +def test_tiff_read_cmyk_rgba(): ds = gdal.Open('data/rgbsmall_cmyk.tif') @@ -265,7 +265,7 @@ def tiff_read_cmyk_rgba(): # Test reading a CMYK tiff as a raw image -def tiff_read_cmyk_raw(): +def test_tiff_read_cmyk_raw(): ds = gdal.Open('GTIFF_RAW:data/rgbsmall_cmyk.tif') @@ -284,7 +284,7 @@ def tiff_read_cmyk_raw(): # Test reading a OJPEG image -def tiff_read_ojpeg(): +def test_tiff_read_ojpeg(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -321,7 +321,7 @@ def tiff_read_ojpeg(): # Read a .tif.gz file -def tiff_read_gzip(): +def test_tiff_read_gzip(): try: os.remove('data/byte.tif.gz.properties') @@ -345,7 +345,7 @@ def tiff_read_gzip(): # Read a .tif.zip file (with explicit filename) -def tiff_read_zip_1(): +def test_tiff_read_zip_1(): ds = gdal.Open('/vsizip/./data/byte.tif.zip/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: @@ -359,7 +359,7 @@ def tiff_read_zip_1(): # Read a .tif.zip file (with implicit filename) -def tiff_read_zip_2(): +def test_tiff_read_zip_2(): ds = gdal.Open('/vsizip/./data/byte.tif.zip') if ds.GetRasterBand(1).Checksum() != 4672: @@ -373,7 +373,7 @@ def tiff_read_zip_2(): # Read a .tif.zip file with a single file in a subdirectory (with explicit filename) -def tiff_read_zip_3(): +def test_tiff_read_zip_3(): ds = gdal.Open('/vsizip/./data/onefileinsubdir.zip/onefileinsubdir/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: @@ -387,7 +387,7 @@ def tiff_read_zip_3(): # Read a .tif.zip file with a single file in a subdirectory(with implicit filename) -def tiff_read_zip_4(): +def test_tiff_read_zip_4(): ds = gdal.Open('/vsizip/./data/onefileinsubdir.zip') if ds.GetRasterBand(1).Checksum() != 4672: @@ -401,7 +401,7 @@ def tiff_read_zip_4(): # Read a .tif.zip file with 2 files in a subdirectory -def tiff_read_zip_5(): +def test_tiff_read_zip_5(): ds = gdal.Open('/vsizip/./data/twofileinsubdir.zip/twofileinsubdir/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: @@ -415,7 +415,7 @@ def tiff_read_zip_5(): # Read a .tar file (with explicit filename) -def tiff_read_tar_1(): +def test_tiff_read_tar_1(): ds = gdal.Open('/vsitar/./data/byte.tar/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: @@ -429,7 +429,7 @@ def tiff_read_tar_1(): # Read a .tar file (with implicit filename) -def tiff_read_tar_2(): +def test_tiff_read_tar_2(): ds = gdal.Open('/vsitar/./data/byte.tar') if ds.GetRasterBand(1).Checksum() != 4672: @@ -443,7 +443,7 @@ def tiff_read_tar_2(): # Read a .tgz file (with explicit filename) -def tiff_read_tgz_1(): +def test_tiff_read_tgz_1(): ds = gdal.Open('/vsitar/./data/byte.tgz/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: @@ -459,7 +459,7 @@ def tiff_read_tgz_1(): # Read a .tgz file (with implicit filename) -def tiff_read_tgz_2(): +def test_tiff_read_tgz_2(): ds = gdal.Open('/vsitar/./data/byte.tgz') if ds.GetRasterBand(1).Checksum() != 4672: @@ -475,7 +475,7 @@ def tiff_read_tgz_2(): # Check handling of non-degree angular units (#601) -def tiff_grads(): +def test_tiff_grads(): ds = gdal.Open('data/test_gf.tif') srs = ds.GetProjectionRef() @@ -491,7 +491,7 @@ def tiff_grads(): # Check Erdas Citation Parsing for coordinate system. -def tiff_citation(): +def test_tiff_citation(): build_info = gdal.VersionInfo('BUILD_INFO') if build_info.find('ESRI_BUILD=YES') == -1: @@ -513,7 +513,7 @@ def tiff_citation(): # Check that we can read linear projection parameters properly (#3901) -def tiff_linearparmunits(): +def test_tiff_linearparmunits(): # Test the file with the correct formulation. @@ -560,7 +560,7 @@ def tiff_linearparmunits(): # Check that the GTIFF_LINEAR_UNITS handling works properly (#3901) -def tiff_linearparmunits2(): +def test_tiff_linearparmunits2(): gdal.SetConfigOption('GTIFF_LINEAR_UNITS', 'BROKEN') @@ -611,7 +611,7 @@ def tiff_linearparmunits2(): # Test GTiffSplitBitmapBand to treat one row 1bit files as scanline blocks (#2622) -def tiff_g4_split(): +def test_tiff_g4_split(): if 'GetBlockSize' not in dir(gdal.Band): return 'skip' @@ -636,7 +636,7 @@ def tiff_g4_split(): # Test reading a tiff with multiple images in it -def tiff_multi_images(): +def test_tiff_multi_images(): # Implicitly get the content of the first image (backward compatibility). ds = gdal.Open('data/twoimages.tif') @@ -673,7 +673,7 @@ def tiff_multi_images(): # Test reading a tiff from a memory buffer (#2931) -def tiff_vsimem(): +def test_tiff_vsimem(): try: gdal.FileFromMemBuffer @@ -714,7 +714,7 @@ def tiff_vsimem(): # Test reading a tiff from inside a zip in a memory buffer ! -def tiff_vsizip_and_mem(): +def test_tiff_vsizip_and_mem(): try: gdal.FileFromMemBuffer @@ -740,7 +740,7 @@ def tiff_vsizip_and_mem(): # Test reading a GeoTIFF with only ProjectedCSTypeGeoKey defined (ticket #3019) -def tiff_ProjectedCSTypeGeoKey_only(): +def test_tiff_ProjectedCSTypeGeoKey_only(): ds = gdal.Open('data/ticket3019.tif') if ds.GetProjectionRef().find('WGS 84 / UTM zone 31N') == -1: @@ -754,7 +754,7 @@ def tiff_ProjectedCSTypeGeoKey_only(): # Test reading a GeoTIFF with only GTModelTypeGeoKey defined -def tiff_GTModelTypeGeoKey_only(): +def test_tiff_GTModelTypeGeoKey_only(): ds = gdal.Open('data/GTModelTypeGeoKey_only.tif') if ds.GetProjectionRef().find('LOCAL_CS["unnamed",GEOGCS["unknown",DATUM["unknown",SPHEROID["unretrievable - using WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT[,0.0174532925199433]],UNIT["unknown",1]]') != 0: @@ -768,7 +768,7 @@ def tiff_GTModelTypeGeoKey_only(): # Test reading a 12bit jpeg compressed geotiff. -def tiff_12bitjpeg(): +def test_tiff_12bitjpeg(): old_accum = gdal.GetConfigOption('CPL_ACCUM_ERROR_MSG', 'OFF') gdal.SetConfigOption('CPL_ACCUM_ERROR_MSG', 'ON') @@ -813,7 +813,7 @@ def tiff_12bitjpeg(): # Test that statistics for TIFF files are stored and correctly read from .aux.xml -def tiff_read_stats_from_pam(): +def test_tiff_read_stats_from_pam(): try: os.remove('data/byte.tif.aux.xml') @@ -858,7 +858,7 @@ def tiff_read_stats_from_pam(): # Test extracting georeferencing from a .TAB file -def tiff_read_from_tab(): +def test_tiff_read_from_tab(): ds = gdal.GetDriverByName('GTiff').Create('tmp/tiff_read_from_tab.tif', 1, 1) ds = None @@ -910,7 +910,7 @@ def tiff_read_from_tab(): # Test reading PixelIsPoint file. -def tiff_read_pixelispoint(): +def test_tiff_read_pixelispoint(): gdal.SetConfigOption('GTIFF_POINT_GEO_IGNORE', 'FALSE') @@ -946,7 +946,7 @@ def tiff_read_pixelispoint(): # Test reading a GeoTIFF file with a geomatrix in PixelIsPoint format. -def tiff_read_geomatrix(): +def test_tiff_read_geomatrix(): gdal.SetConfigOption('GTIFF_POINT_GEO_IGNORE', 'FALSE') @@ -982,7 +982,7 @@ def tiff_read_geomatrix(): # Test that we don't crash when reading a TIFF with corrupted GeoTIFF tags -def tiff_read_corrupted_gtiff(): +def test_tiff_read_corrupted_gtiff(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('data/corrupted_gtiff_tags.tif') @@ -1002,7 +1002,7 @@ def tiff_read_corrupted_gtiff(): # Test that we don't crash when reading a TIFF with corrupted GeoTIFF tags -def tiff_read_tag_without_null_byte(): +def test_tiff_read_tag_without_null_byte(): gdal.ErrorReset() oldval = gdal.GetConfigOption('CPL_DEBUG') @@ -1020,7 +1020,7 @@ def tiff_read_tag_without_null_byte(): ############################################################################### # Test the effect of the GTIFF_IGNORE_READ_ERRORS configuration option (#3994) -def tiff_read_buggy_packbits(): +def test_tiff_read_buggy_packbits(): old_val = gdal.GetConfigOption('GTIFF_IGNORE_READ_ERRORS') gdal.SetConfigOption('GTIFF_IGNORE_READ_ERRORS', None) @@ -1051,7 +1051,7 @@ def tiff_read_buggy_packbits(): ############################################################################### # Test reading a GeoEye _rpc.txt (#3639) -def tiff_read_rpc_txt(): +def test_tiff_read_rpc_txt(): shutil.copy('data/byte.tif', 'tmp/test.tif') shutil.copy('data/test_rpc.txt', 'tmp/test_rpc.txt') @@ -1078,7 +1078,7 @@ def tiff_read_rpc_txt(): # http://geotiff.maptools.org/rpc_prop.html -def tiff_read_rpc_tif(): +def test_tiff_read_rpc_tif(): ds = gdal.Open('data/byte_rpc.tif') rpc_md = ds.GetMetadata('RPC') @@ -1105,7 +1105,7 @@ def tiff_read_rpc_tif(): # StripByteCounts (279) LONG (4) 1<1> -def tiff_small(): +def test_tiff_small(): content = '\x49\x49\x2A\x00\x08\x00\x00\x00\x04\x00\x00\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x11\x01\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x17\x01\x04\x00\x01\x00\x00\x00\x01\x00\x00\x00' @@ -1126,7 +1126,7 @@ def tiff_small(): # Test that we can workaround a DoS with -def tiff_dos_strip_chop(): +def test_tiff_dos_strip_chop(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('data/tiff_dos_strip_chop.tif') @@ -1139,7 +1139,7 @@ def tiff_dos_strip_chop(): # Test reading EXIF and GPS metadata -def tiff_read_exif_and_gps(): +def test_tiff_read_exif_and_gps(): ds = gdal.Open('data/exif_and_gps.tif') exif_md = ds.GetMetadata('EXIF') @@ -1172,7 +1172,7 @@ def tiff_read_exif_and_gps(): # Test reading a pixel interleaved RGBA JPEG-compressed TIFF -def tiff_jpeg_rgba_pixel_interleaved(): +def test_tiff_jpeg_rgba_pixel_interleaved(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: return 'skip' @@ -1202,7 +1202,7 @@ def tiff_jpeg_rgba_pixel_interleaved(): # Test reading a band interleaved RGBA JPEG-compressed TIFF -def tiff_jpeg_rgba_band_interleaved(): +def test_tiff_jpeg_rgba_band_interleaved(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: return 'skip' @@ -1232,7 +1232,7 @@ def tiff_jpeg_rgba_band_interleaved(): # Test reading a YCbCr JPEG all-in-one-strip multiband TIFF (#3259, #3894) -def tiff_read_online_1(): +def test_tiff_read_online_1(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: return 'skip' @@ -1259,7 +1259,7 @@ def tiff_read_online_1(): # support -def tiff_read_online_2(): +def test_tiff_read_online_2(): if gdal.GetDriverByName('HTTP') is None: return 'skip' @@ -1301,7 +1301,7 @@ def tiff_read_online_2(): # Test reading a TIFF made of a single-strip that is more than 2GB (#5403) -def tiff_read_huge4GB(): +def test_tiff_read_huge4GB(): # Need libtiff 4.X anyway md = gdal.GetDriverByName('GTiff').GetMetadata() @@ -1331,7 +1331,7 @@ def tiff_read_huge4GB(): # Test reading a (small) BigTIFF. Tests GTiffCacheOffsetOrCount8() -def tiff_read_bigtiff(): +def test_tiff_read_bigtiff(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -1350,7 +1350,7 @@ def tiff_read_bigtiff(): # Test reading in TIFF metadata domain -def tiff_read_tiff_metadata(): +def test_tiff_read_tiff_metadata(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -1393,7 +1393,7 @@ def tiff_read_tiff_metadata(): # Test reading a JPEG-in-TIFF with tiles of irregular size (corrupted image) -def tiff_read_irregular_tile_size_jpeg_in_tiff(): +def test_tiff_read_irregular_tile_size_jpeg_in_tiff(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -1423,7 +1423,7 @@ def tiff_read_irregular_tile_size_jpeg_in_tiff(): # Test GTIFF_DIRECT_IO and GTIFF_VIRTUAL_MEM_IO optimizations -def tiff_direct_and_virtual_mem_io(): +def test_tiff_direct_and_virtual_mem_io(): # Test with pixel-interleaved and band-interleaved datasets for dt in [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_CInt16]: @@ -1857,7 +1857,7 @@ def tiff_direct_and_virtual_mem_io(): # Check read Digital Globe metadata IMD & RPB format -def tiff_read_md1(): +def test_tiff_read_md1(): try: os.remove('data/md_dg.tif.aux.xml') @@ -1907,7 +1907,7 @@ def tiff_read_md1(): # Check read Digital Globe metadata XML format -def tiff_read_md2(): +def test_tiff_read_md2(): try: os.remove('data/md_dg_2.tif.aux.xml') @@ -1957,7 +1957,7 @@ def tiff_read_md2(): # Check read GeoEye metadata format -def tiff_read_md3(): +def test_tiff_read_md3(): try: os.remove('data/md_ge_rgb_0010000.tif.aux.xml') @@ -2007,7 +2007,7 @@ def tiff_read_md3(): # Check read OrbView metadata format -def tiff_read_md4(): +def test_tiff_read_md4(): try: os.remove('data/md_ov.tif.aux.xml') @@ -2057,7 +2057,7 @@ def tiff_read_md4(): # Check read Resurs-DK1 metadata format -def tiff_read_md5(): +def test_tiff_read_md5(): try: os.remove('data/md_rdk1.tif.aux.xml') @@ -2107,7 +2107,7 @@ def tiff_read_md5(): # Check read Landsat metadata format -def tiff_read_md6(): +def test_tiff_read_md6(): try: os.remove('data/md_ls_b1.tif.aux.xml') @@ -2157,7 +2157,7 @@ def tiff_read_md6(): # Check read Spot metadata format -def tiff_read_md7(): +def test_tiff_read_md7(): try: os.remove('data/spot/md_spot.tif.aux.xml') @@ -2207,7 +2207,7 @@ def tiff_read_md7(): # Check read RapidEye metadata format -def tiff_read_md8(): +def test_tiff_read_md8(): try: os.remove('data/md_re.tif.aux.xml') @@ -2257,7 +2257,7 @@ def tiff_read_md8(): # Check read Alos metadata format -def tiff_read_md9(): +def test_tiff_read_md9(): try: os.remove('data/alos/IMG-md_alos.tif.aux.xml') @@ -2304,7 +2304,7 @@ def tiff_read_md9(): # Check read Eros metadata format -def tiff_read_md10(): +def test_tiff_read_md10(): try: os.remove('data/md_eros.tif.aux.xml') @@ -2354,7 +2354,7 @@ def tiff_read_md10(): # Check read Kompsat metadata format -def tiff_read_md11(): +def test_tiff_read_md11(): try: os.remove('data/md_kompsat.tif.aux.xml') @@ -2404,7 +2404,7 @@ def tiff_read_md11(): # Check read Dimap metadata format -def tiff_read_md12(): +def test_tiff_read_md12(): ds = gdal.Open('../gdrivers/data/dimap2/IMG_foo_R2C1.TIF', gdal.GA_ReadOnly) filelist = ds.GetFileList() @@ -2471,7 +2471,7 @@ def tiff_read_md12(): # Test reading a TIFFTAG_GDAL_NODATA with empty text -def tiff_read_empty_nodata_tag(): +def test_tiff_read_empty_nodata_tag(): ds = gdal.Open('data/empty_nodata.tif') if ds.GetRasterBand(1).GetNoDataValue() is not None: @@ -2486,7 +2486,7 @@ def tiff_read_empty_nodata_tag(): # imagery and getting IMAGE_STRUCTURE metadata -def tiff_read_strace_check(): +def test_tiff_read_strace_check(): if not sys.platform.startswith('linux'): return 'skip' @@ -2521,7 +2521,7 @@ def tiff_read_strace_check(): # Test GDAL_READDIR_LIMIT_ON_OPEN -def tiff_read_readdir_limit_on_open(): +def test_tiff_read_readdir_limit_on_open(): gdal.SetConfigOption('GDAL_READDIR_LIMIT_ON_OPEN', '1') @@ -2540,7 +2540,7 @@ def tiff_read_readdir_limit_on_open(): # -def tiff_read_minisblack_as_rgba(): +def test_tiff_read_minisblack_as_rgba(): if not gdaltest.supports_force_rgba: return 'skip' @@ -2561,7 +2561,7 @@ def tiff_read_minisblack_as_rgba(): # -def tiff_read_colortable_as_rgba(): +def test_tiff_read_colortable_as_rgba(): if not gdaltest.supports_force_rgba: return 'skip' @@ -2582,7 +2582,7 @@ def tiff_read_colortable_as_rgba(): # -def tiff_read_logl_as_rgba(): +def test_tiff_read_logl_as_rgba(): if not gdaltest.supports_force_rgba: return 'skip' @@ -2604,7 +2604,7 @@ def tiff_read_logl_as_rgba(): # -def tiff_read_strip_separate_as_rgba(): +def test_tiff_read_strip_separate_as_rgba(): if not gdaltest.supports_force_rgba: return 'skip' @@ -2648,7 +2648,7 @@ def tiff_read_strip_separate_as_rgba(): # -def tiff_read_tiled_separate_as_rgba(): +def test_tiff_read_tiled_separate_as_rgba(): if not gdaltest.supports_force_rgba: return 'skip' @@ -2691,7 +2691,7 @@ def tiff_read_tiled_separate_as_rgba(): # -def tiff_read_scanline_more_than_2GB(): +def test_tiff_read_scanline_more_than_2GB(): with gdaltest.error_handler(): ds = gdal.Open('data/scanline_more_than_2GB.tif') @@ -2704,7 +2704,7 @@ def tiff_read_scanline_more_than_2GB(): # about it -def tiff_read_wrong_number_extrasamples(): +def test_tiff_read_wrong_number_extrasamples(): gdal.ErrorReset() with gdaltest.error_handler(): @@ -2724,7 +2724,7 @@ def tiff_read_wrong_number_extrasamples(): # Test that we can read a one-trip TIFF without StripByteCounts tag -def tiff_read_one_strip_no_bytecount(): +def test_tiff_read_one_strip_no_bytecount(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('data/one_strip_nobytecount.tif') @@ -2740,7 +2740,7 @@ def tiff_read_one_strip_no_bytecount(): # Test GDAL_GEOREF_SOURCES -def tiff_read_nogeoref(): +def test_tiff_read_nogeoref(): tests = [(None, True, True, False, 'LOCAL_CS["PAM"]', (1.0, 2.0, 3.0, 4.0, 5.0, 6.0)), (None, True, True, True, 'LOCAL_CS["PAM"]', (1.0, 2.0, 3.0, 4.0, 5.0, 6.0)), @@ -2809,7 +2809,7 @@ def tiff_read_nogeoref(): # Test GDAL_GEOREF_SOURCES -def tiff_read_inconsistent_georef(): +def test_tiff_read_inconsistent_georef(): tests = [(None, True, True, True, 'LOCAL_CS["PAM"]', (1.0, 2.0, 3.0, 4.0, 5.0, 6.0)), (None, False, True, True, '26711', (440720.0, 60.0, 0.0, 3751320.0, 0.0, -60.0)), @@ -2870,7 +2870,7 @@ def tiff_read_inconsistent_georef(): # Test GDAL_GEOREF_SOURCES -def tiff_read_gcp_internal_and_auxxml(): +def test_tiff_read_gcp_internal_and_auxxml(): tests = [(None, True, 'LOCAL_CS["PAM"]', 1), (None, False, '4326', 2), @@ -2931,7 +2931,7 @@ def handler(self, eErrClass, err_no, msg): self.msg = msg -def tiff_read_aux(): +def test_tiff_read_aux(): gdal.ErrorReset() ds = gdal.Open('data/f2r23.tif') @@ -2946,7 +2946,7 @@ def tiff_read_aux(): return 'success' -def tiff_read_one_band_from_two_bands(): +def test_tiff_read_one_band_from_two_bands(): gdal.Translate('/vsimem/tiff_read_one_band_from_two_bands.tif', 'data/byte.tif', options='-b 1 -b 1') gdal.Translate('/vsimem/tiff_read_one_band_from_two_bands_dst.tif', '/vsimem/tiff_read_one_band_from_two_bands.tif', options='-b 1') @@ -2963,7 +2963,7 @@ def tiff_read_one_band_from_two_bands(): return 'success' -def tiff_read_jpeg_cloud_optimized(): +def test_tiff_read_jpeg_cloud_optimized(): for i in range(4): ds = gdal.Open('data/byte_ovr_jpeg_tablesmode%d.tif' % i) @@ -2985,7 +2985,7 @@ def tiff_read_jpeg_cloud_optimized(): # error while jpeg-8 works fine -def tiff_read_corrupted_jpeg_cloud_optimized(): +def test_tiff_read_corrupted_jpeg_cloud_optimized(): ds = gdal.Open('data/byte_ovr_jpeg_tablesmode_not_correctly_set_on_ovr.tif') cs0 = ds.GetRasterBand(1).Checksum() @@ -3009,7 +3009,7 @@ def tiff_read_corrupted_jpeg_cloud_optimized(): # Test reading YCbCr images with LZW compression -def tiff_read_ycbcr_lzw(): +def test_tiff_read_ycbcr_lzw(): tests = [('ycbcr_11_lzw.tif', 13459, 12939, 12414), ('ycbcr_12_lzw.tif', 13565, 13105, 12660), @@ -3043,7 +3043,7 @@ def tiff_read_ycbcr_lzw(): # Test reading YCbCr images with nbits > 8 -def tiff_read_ycbcr_int12(): +def test_tiff_read_ycbcr_int12(): with gdaltest.error_handler(): ds = gdal.Open('data/int12_ycbcr_contig.tif') @@ -3061,7 +3061,7 @@ def tiff_read_ycbcr_int12(): # Test reading band unit from VERT_CS unit (#6675) -def tiff_read_unit_from_srs(): +def test_tiff_read_unit_from_srs(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_read_unit_from_srs.tif', 1, 1) sr = osr.SpatialReference() @@ -3085,7 +3085,7 @@ def tiff_read_unit_from_srs(): # Test reading ArcGIS 9.3 .aux.xml -def tiff_read_arcgis93_geodataxform_gcp(): +def test_tiff_read_arcgis93_geodataxform_gcp(): ds = gdal.Open('data/arcgis93_geodataxform_gcp.tif') if ds.GetGCPProjection().find('26712') < 0: @@ -3108,7 +3108,7 @@ def tiff_read_arcgis93_geodataxform_gcp(): # Test reading file with block size > signed int 32 bit -def tiff_read_block_width_above_32bit(): +def test_tiff_read_block_width_above_32bit(): with gdaltest.error_handler(): ds = gdal.Open('data/block_width_above_32bit.tif') @@ -3121,7 +3121,7 @@ def tiff_read_block_width_above_32bit(): # Test reading file with image size > signed int 32 bit -def tiff_read_image_width_above_32bit(): +def test_tiff_read_image_width_above_32bit(): with gdaltest.error_handler(): ds = gdal.Open('data/image_width_above_32bit.tif') @@ -3134,7 +3134,7 @@ def tiff_read_image_width_above_32bit(): # Test reading file with image size > signed int 32 bit -def tiff_read_second_image_width_above_32bit(): +def test_tiff_read_second_image_width_above_32bit(): ds = gdal.Open('data/second_image_width_above_32bit.tif') with gdaltest.error_handler(): @@ -3154,7 +3154,7 @@ def tiff_read_second_image_width_above_32bit(): # Test reading file with minimal number of warnings without warning -def tiff_read_minimum_tiff_tags_no_warning(): +def test_tiff_read_minimum_tiff_tags_no_warning(): gdal.ErrorReset() ds = gdal.Open('data/minimum_tiff_tags_no_warning.tif') @@ -3172,7 +3172,7 @@ def tiff_read_minimum_tiff_tags_no_warning(): # Test reading file with minimal number of warnings but warning -def tiff_read_minimum_tiff_tags_with_warning(): +def test_tiff_read_minimum_tiff_tags_with_warning(): gdal.ErrorReset() with gdaltest.error_handler(): @@ -3217,7 +3217,7 @@ def check_libtiff_internal_or_at_least(expected_maj, expected_min, expected_micr ############################################################################### -def tiff_read_unknown_compression(): +def test_tiff_read_unknown_compression(): with gdaltest.error_handler(): ds = gdal.Open('data/unknown_compression.tif') @@ -3229,7 +3229,7 @@ def tiff_read_unknown_compression(): ############################################################################### -def tiff_read_leak_ZIPSetupDecode(): +def test_tiff_read_leak_ZIPSetupDecode(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3244,7 +3244,7 @@ def tiff_read_leak_ZIPSetupDecode(): ############################################################################### -def tiff_read_excessive_memory_TIFFFillStrip(): +def test_tiff_read_excessive_memory_TIFFFillStrip(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3259,7 +3259,7 @@ def tiff_read_excessive_memory_TIFFFillStrip(): ############################################################################### -def tiff_read_excessive_memory_TIFFFillStrip2(): +def test_tiff_read_excessive_memory_TIFFFillStrip2(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3273,7 +3273,7 @@ def tiff_read_excessive_memory_TIFFFillStrip2(): ############################################################################### -def tiff_read_excessive_memory_TIFFFillTile(): +def test_tiff_read_excessive_memory_TIFFFillTile(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3287,7 +3287,7 @@ def tiff_read_excessive_memory_TIFFFillTile(): ############################################################################### -def tiff_read_big_strip(): +def test_tiff_read_big_strip(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3307,7 +3307,7 @@ def tiff_read_big_strip(): # (Potentially) test libtiff CHUNKY_STRIP_READ_SUPPORT -def tiff_read_big_strip_chunky_way(): +def test_tiff_read_big_strip_chunky_way(): gdal.Translate('/vsimem/test.tif', 'data/byte.tif', options='-co compress=lzw -outsize 1000 2001 -co blockysize=2001 -r bilinear') ds = gdal.Open('/vsimem/test.tif') @@ -3323,7 +3323,7 @@ def tiff_read_big_strip_chunky_way(): ############################################################################### -def tiff_read_big_tile(): +def test_tiff_read_big_tile(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3342,7 +3342,7 @@ def tiff_read_big_tile(): ############################################################################### -def tiff_read_huge_tile(): +def test_tiff_read_huge_tile(): with gdaltest.error_handler(): ds = gdal.Open('data/hugeblocksize.tif') @@ -3354,7 +3354,7 @@ def tiff_read_huge_tile(): ############################################################################### -def tiff_read_huge_number_strips(): +def test_tiff_read_huge_number_strips(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['LIBTIFF'] != 'INTERNAL': @@ -3369,7 +3369,7 @@ def tiff_read_huge_number_strips(): ############################################################################### -def tiff_read_huge_implied_number_strips(): +def test_tiff_read_huge_implied_number_strips(): if not check_libtiff_internal_or_at_least(4, 0, 10): return 'skip' @@ -3382,7 +3382,7 @@ def tiff_read_huge_implied_number_strips(): ############################################################################### -def tiff_read_many_blocks(): +def test_tiff_read_many_blocks(): # Runs super slow on some Windows configs if sys.platform == 'win32': @@ -3405,7 +3405,7 @@ def tiff_read_many_blocks(): ############################################################################### -def tiff_read_many_blocks_truncated(): +def test_tiff_read_many_blocks_truncated(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['LIBTIFF'] != 'INTERNAL': @@ -3424,7 +3424,7 @@ def tiff_read_many_blocks_truncated(): # Test reading images with nbits > 32 -def tiff_read_uint33(): +def test_tiff_read_uint33(): with gdaltest.error_handler(): ds = gdal.Open('data/uint33.tif') @@ -3442,7 +3442,7 @@ def tiff_read_uint33(): # Test fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1545 -def tiff_read_corrupted_deflate_singlestrip(): +def test_tiff_read_corrupted_deflate_singlestrip(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3457,7 +3457,7 @@ def tiff_read_corrupted_deflate_singlestrip(): # Test fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1563 -def tiff_read_packbits_not_enough_data(): +def test_tiff_read_packbits_not_enough_data(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3472,7 +3472,7 @@ def tiff_read_packbits_not_enough_data(): # Test reading images with more than 2billion blocks for a single band -def tiff_read_toomanyblocks(): +def test_tiff_read_toomanyblocks(): with gdaltest.error_handler(): ds = gdal.Open('data/toomanyblocks.tif') @@ -3486,7 +3486,7 @@ def tiff_read_toomanyblocks(): ############################################################################### # Test reading images with more than 2billion blocks for all bands -def tiff_read_toomanyblocks_separate(): +def test_tiff_read_toomanyblocks_separate(): with gdaltest.error_handler(): ds = gdal.Open('data/toomanyblocks_separate.tif') @@ -3501,7 +3501,7 @@ def tiff_read_toomanyblocks_separate(): # tag is lesser than the number of strips -def tiff_read_size_of_stripbytecount_lower_than_stripcount(): +def test_tiff_read_size_of_stripbytecount_lower_than_stripcount(): ds = gdal.Open('data/size_of_stripbytecount_lower_than_stripcount.tif') # There are 3 strips but StripByteCounts has just two elements; @@ -3530,7 +3530,7 @@ def tiff_read_size_of_stripbytecount_lower_than_stripcount(): ############################################################################### # Test different datatypes for StripOffsets tag with little/big, classic/bigtiff -def tiff_read_stripoffset_types(): +def test_tiff_read_stripoffset_types(): tests = [ ('data/classictiff_one_block_byte.tif', []), # unsupported @@ -3583,7 +3583,7 @@ def tiff_read_stripoffset_types(): # http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf -def tiff_read_progressive_jpeg_denial_of_service(): +def test_tiff_read_progressive_jpeg_denial_of_service(): if not check_libtiff_internal_or_at_least(4, 0, 9): return 'skip' @@ -3617,7 +3617,7 @@ def tiff_read_progressive_jpeg_denial_of_service(): ############################################################################### # Test reading old-style LZW -def tiff_read_old_style_lzw(): +def test_tiff_read_old_style_lzw(): if not check_libtiff_internal_or_at_least(4, 0, 8): return 'skip' @@ -3637,7 +3637,7 @@ def tiff_read_old_style_lzw(): # mmap emulation) -def tiff_read_mmap_interface(): +def test_tiff_read_mmap_interface(): src_ds = gdal.Open('data/byte.tif') tmpfile = '/vsimem/tiff_read_mmap_interface.tif' @@ -3682,7 +3682,7 @@ def tiff_read_mmap_interface(): # strip height, instead of just the number of lines needed to reach the # image height. -def tiff_read_jpeg_too_big_last_stripe(): +def test_tiff_read_jpeg_too_big_last_stripe(): if not check_libtiff_internal_or_at_least(4, 0, 9): return 'skip' @@ -3709,7 +3709,7 @@ def tiff_read_jpeg_too_big_last_stripe(): ############################################################################### # Test reading GeoTIFF file with negative ScaleY in GeoPixelScale tag -def tiff_read_negative_scaley(): +def test_tiff_read_negative_scaley(): ds = gdal.Open('data/negative_scaley.tif') with gdaltest.error_handler(): @@ -3735,7 +3735,7 @@ def tiff_read_negative_scaley(): # Test ZSTD compression -def tiff_read_zstd(): +def test_tiff_read_zstd(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('ZSTD') == -1: @@ -3748,7 +3748,7 @@ def tiff_read_zstd(): # Test ZSTD compression -def tiff_read_zstd_corrupted(): +def test_tiff_read_zstd_corrupted(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('ZSTD') == -1: @@ -3762,7 +3762,7 @@ def tiff_read_zstd_corrupted(): # Test ZSTD compression -def tiff_read_zstd_corrupted2(): +def test_tiff_read_zstd_corrupted2(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('ZSTD') == -1: @@ -3777,7 +3777,7 @@ def tiff_read_zstd_corrupted2(): # Test WEBP compression -def tiff_read_webp(): +def test_tiff_read_webp(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('WEBP') == -1: @@ -3792,7 +3792,7 @@ def tiff_read_webp(): # Test WEBP compression -def tiff_read_webp_huge_single_strip(): +def test_tiff_read_webp_huge_single_strip(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('WEBP') == -1: @@ -3806,7 +3806,7 @@ def tiff_read_webp_huge_single_strip(): ############################################################################### -def tiff_read_1bit_2bands(): +def test_tiff_read_1bit_2bands(): ds = gdal.Open('data/1bit_2bands.tif') cs = (ds.GetRasterBand(1).Checksum(), ds.GetRasterBand(2).Checksum()) if cs != (200, 824): @@ -3818,7 +3818,7 @@ def tiff_read_1bit_2bands(): # Test LERC compression -def tiff_read_lerc(): +def test_tiff_read_lerc(): md = gdal.GetDriverByName('GTiff').GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -3830,7 +3830,7 @@ def tiff_read_lerc(): ############################################################################### -def tiff_read_overview_of_external_mask(): +def test_tiff_read_overview_of_external_mask(): filename = '/vsimem/tiff_read_overview_of_external_mask.tif' gdal.Translate(filename, 'data/byte.tif', options='-b 1 -mask 1') @@ -3864,134 +3864,134 @@ def tiff_read_overview_of_external_mask(): gdaltest_list = [ - tiff_read_off, - tiff_check_alpha, - tiff_read_cmyk_rgba, - tiff_read_cmyk_raw, - tiff_read_ojpeg, - tiff_read_gzip, - tiff_read_zip_1, - tiff_read_zip_2, - tiff_read_zip_3, - tiff_read_zip_4, - tiff_read_zip_5, - tiff_read_tar_1, - tiff_read_tar_2, - tiff_read_tgz_1, - tiff_read_tgz_2, - tiff_grads, - tiff_citation, - tiff_linearparmunits, - tiff_linearparmunits2, - tiff_g4_split, - tiff_multi_images, - tiff_vsimem, - tiff_vsizip_and_mem, - tiff_ProjectedCSTypeGeoKey_only, - tiff_GTModelTypeGeoKey_only, - tiff_12bitjpeg, - tiff_read_stats_from_pam, - tiff_read_from_tab, - tiff_read_pixelispoint, - tiff_read_geomatrix, - tiff_read_corrupted_gtiff, - tiff_read_tag_without_null_byte, - tiff_read_buggy_packbits, - tiff_read_rpc_txt, - tiff_read_rpc_tif, - tiff_small, - tiff_dos_strip_chop, - tiff_read_exif_and_gps, - tiff_jpeg_rgba_pixel_interleaved, - tiff_jpeg_rgba_band_interleaved, - tiff_read_huge4GB, - tiff_read_bigtiff, - tiff_read_tiff_metadata, - tiff_read_irregular_tile_size_jpeg_in_tiff, - tiff_direct_and_virtual_mem_io, - tiff_read_empty_nodata_tag, - tiff_read_strace_check, - tiff_read_readdir_limit_on_open, - tiff_read_minisblack_as_rgba, - tiff_read_colortable_as_rgba, - tiff_read_logl_as_rgba, - tiff_read_strip_separate_as_rgba, - tiff_read_tiled_separate_as_rgba, - tiff_read_scanline_more_than_2GB, - tiff_read_wrong_number_extrasamples, - tiff_read_one_strip_no_bytecount, - - tiff_read_md1, - tiff_read_md2, - tiff_read_md3, - tiff_read_md4, - tiff_read_md5, - tiff_read_md6, - tiff_read_md7, - tiff_read_md8, - tiff_read_md9, - tiff_read_md10, - tiff_read_md11, - tiff_read_md12, - - tiff_read_nogeoref, - tiff_read_inconsistent_georef, - tiff_read_gcp_internal_and_auxxml, - - tiff_read_aux, - - tiff_read_one_band_from_two_bands, - - tiff_read_jpeg_cloud_optimized, - tiff_read_corrupted_jpeg_cloud_optimized, - - tiff_read_ycbcr_lzw, - tiff_read_ycbcr_int12, - - tiff_read_unit_from_srs, - tiff_read_arcgis93_geodataxform_gcp, - tiff_read_block_width_above_32bit, - tiff_read_image_width_above_32bit, - tiff_read_second_image_width_above_32bit, - tiff_read_minimum_tiff_tags_no_warning, - tiff_read_minimum_tiff_tags_with_warning, - tiff_read_unknown_compression, - tiff_read_leak_ZIPSetupDecode, - tiff_read_excessive_memory_TIFFFillStrip, - tiff_read_excessive_memory_TIFFFillStrip2, - tiff_read_excessive_memory_TIFFFillTile, - tiff_read_big_strip, - tiff_read_big_strip_chunky_way, - tiff_read_big_tile, - tiff_read_huge_tile, - tiff_read_huge_number_strips, - tiff_read_huge_implied_number_strips, - tiff_read_many_blocks, - tiff_read_many_blocks_truncated, - tiff_read_uint33, - tiff_read_corrupted_deflate_singlestrip, - tiff_read_packbits_not_enough_data, - tiff_read_toomanyblocks, - tiff_read_toomanyblocks_separate, - tiff_read_size_of_stripbytecount_lower_than_stripcount, - tiff_read_stripoffset_types, - tiff_read_progressive_jpeg_denial_of_service, - tiff_read_old_style_lzw, - tiff_read_mmap_interface, - tiff_read_jpeg_too_big_last_stripe, - tiff_read_negative_scaley, - tiff_read_zstd, - tiff_read_zstd_corrupted, - tiff_read_zstd_corrupted2, - tiff_read_1bit_2bands, - tiff_read_lerc, - tiff_read_overview_of_external_mask, - - tiff_read_online_1, - tiff_read_online_2, - - tiff_read_webp, - tiff_read_webp_huge_single_strip, + test_tiff_read_off, + test_tiff_check_alpha, + test_tiff_read_cmyk_rgba, + test_tiff_read_cmyk_raw, + test_tiff_read_ojpeg, + test_tiff_read_gzip, + test_tiff_read_zip_1, + test_tiff_read_zip_2, + test_tiff_read_zip_3, + test_tiff_read_zip_4, + test_tiff_read_zip_5, + test_tiff_read_tar_1, + test_tiff_read_tar_2, + test_tiff_read_tgz_1, + test_tiff_read_tgz_2, + test_tiff_grads, + test_tiff_citation, + test_tiff_linearparmunits, + test_tiff_linearparmunits2, + test_tiff_g4_split, + test_tiff_multi_images, + test_tiff_vsimem, + test_tiff_vsizip_and_mem, + test_tiff_ProjectedCSTypeGeoKey_only, + test_tiff_GTModelTypeGeoKey_only, + test_tiff_12bitjpeg, + test_tiff_read_stats_from_pam, + test_tiff_read_from_tab, + test_tiff_read_pixelispoint, + test_tiff_read_geomatrix, + test_tiff_read_corrupted_gtiff, + test_tiff_read_tag_without_null_byte, + test_tiff_read_buggy_packbits, + test_tiff_read_rpc_txt, + test_tiff_read_rpc_tif, + test_tiff_small, + test_tiff_dos_strip_chop, + test_tiff_read_exif_and_gps, + test_tiff_jpeg_rgba_pixel_interleaved, + test_tiff_jpeg_rgba_band_interleaved, + test_tiff_read_huge4GB, + test_tiff_read_bigtiff, + test_tiff_read_tiff_metadata, + test_tiff_read_irregular_tile_size_jpeg_in_tiff, + test_tiff_direct_and_virtual_mem_io, + test_tiff_read_empty_nodata_tag, + test_tiff_read_strace_check, + test_tiff_read_readdir_limit_on_open, + test_tiff_read_minisblack_as_rgba, + test_tiff_read_colortable_as_rgba, + test_tiff_read_logl_as_rgba, + test_tiff_read_strip_separate_as_rgba, + test_tiff_read_tiled_separate_as_rgba, + test_tiff_read_scanline_more_than_2GB, + test_tiff_read_wrong_number_extrasamples, + test_tiff_read_one_strip_no_bytecount, + + test_tiff_read_md1, + test_tiff_read_md2, + test_tiff_read_md3, + test_tiff_read_md4, + test_tiff_read_md5, + test_tiff_read_md6, + test_tiff_read_md7, + test_tiff_read_md8, + test_tiff_read_md9, + test_tiff_read_md10, + test_tiff_read_md11, + test_tiff_read_md12, + + test_tiff_read_nogeoref, + test_tiff_read_inconsistent_georef, + test_tiff_read_gcp_internal_and_auxxml, + + test_tiff_read_aux, + + test_tiff_read_one_band_from_two_bands, + + test_tiff_read_jpeg_cloud_optimized, + test_tiff_read_corrupted_jpeg_cloud_optimized, + + test_tiff_read_ycbcr_lzw, + test_tiff_read_ycbcr_int12, + + test_tiff_read_unit_from_srs, + test_tiff_read_arcgis93_geodataxform_gcp, + test_tiff_read_block_width_above_32bit, + test_tiff_read_image_width_above_32bit, + test_tiff_read_second_image_width_above_32bit, + test_tiff_read_minimum_tiff_tags_no_warning, + test_tiff_read_minimum_tiff_tags_with_warning, + test_tiff_read_unknown_compression, + test_tiff_read_leak_ZIPSetupDecode, + test_tiff_read_excessive_memory_TIFFFillStrip, + test_tiff_read_excessive_memory_TIFFFillStrip2, + test_tiff_read_excessive_memory_TIFFFillTile, + test_tiff_read_big_strip, + test_tiff_read_big_strip_chunky_way, + test_tiff_read_big_tile, + test_tiff_read_huge_tile, + test_tiff_read_huge_number_strips, + test_tiff_read_huge_implied_number_strips, + test_tiff_read_many_blocks, + test_tiff_read_many_blocks_truncated, + test_tiff_read_uint33, + test_tiff_read_corrupted_deflate_singlestrip, + test_tiff_read_packbits_not_enough_data, + test_tiff_read_toomanyblocks, + test_tiff_read_toomanyblocks_separate, + test_tiff_read_size_of_stripbytecount_lower_than_stripcount, + test_tiff_read_stripoffset_types, + test_tiff_read_progressive_jpeg_denial_of_service, + test_tiff_read_old_style_lzw, + test_tiff_read_mmap_interface, + test_tiff_read_jpeg_too_big_last_stripe, + test_tiff_read_negative_scaley, + test_tiff_read_zstd, + test_tiff_read_zstd_corrupted, + test_tiff_read_zstd_corrupted2, + test_tiff_read_1bit_2bands, + test_tiff_read_lerc, + test_tiff_read_overview_of_external_mask, + + test_tiff_read_online_1, + test_tiff_read_online_2, + + test_tiff_read_webp, + test_tiff_read_webp_huge_single_strip, ] diff --git a/autotest/gcore/tiff_srs.py b/autotest/gcore/tiff_srs.py index 3b2e15d9dfec..03fed36f28d6 100755 --- a/autotest/gcore/tiff_srs.py +++ b/autotest/gcore/tiff_srs.py @@ -43,7 +43,7 @@ # Test fix for #4677: -def tiff_srs_without_linear_units(): +def test_tiff_srs_without_linear_units(): sr = osr.SpatialReference() sr.ImportFromProj4('+proj=vandg +datum=WGS84') @@ -73,7 +73,7 @@ def tiff_srs_without_linear_units(): # Test COMPDCS without VerticalCSType -def tiff_srs_compd_cs(): +def test_tiff_srs_compd_cs(): sr = osr.SpatialReference() # EPSG:7400 without the Authority @@ -121,7 +121,7 @@ def tiff_srs_compd_cs(): # Test reading a GeoTIFF with both StdParallel1 and ScaleAtNatOrigin defined (#5791) -def tiff_srs_weird_mercator_2sp(): +def test_tiff_srs_weird_mercator_2sp(): ds = gdal.Open('data/weird_mercator_2sp.tif') gdal.PushErrorHandler() @@ -167,7 +167,7 @@ def tiff_srs_weird_mercator_2sp(): # Test reading ESRI WGS_1984_Web_Mercator_Auxiliary_Sphere -def tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere(): +def test_tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere(): ds = gdal.Open('data/WGS_1984_Web_Mercator_Auxiliary_Sphere.tif') wkt = ds.GetProjectionRef() @@ -200,7 +200,7 @@ def tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere(): # Test writing and reading various angular units -def tiff_srs_angular_units(): +def test_tiff_srs_angular_units(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_srs_angular_units.tif', 1, 1) ds.SetProjection("""GEOGCS["WGS 84 (arc-second)", @@ -301,7 +301,7 @@ def tiff_srs_angular_units(): # Test writing and reading a unknown datum but with a known ellipsoid -def tiff_custom_datum_known_ellipsoid(): +def test_tiff_custom_datum_known_ellipsoid(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_custom_datum_known_ellipsoid.tif', 1, 1) ds.SetProjection("""GEOGCS["WGS 84 based", @@ -327,7 +327,7 @@ def tiff_custom_datum_known_ellipsoid(): # override to another unit (us-feet) ... (#6210) -def tiff_srs_epsg_2853_with_us_feet(): +def test_tiff_srs_epsg_2853_with_us_feet(): old_val = gdal.GetConfigOption('GTIFF_IMPORT_FROM_EPSG') gdal.SetConfigOption('GTIFF_IMPORT_FROM_EPSG', 'YES') @@ -354,7 +354,7 @@ def tiff_srs_epsg_2853_with_us_feet(): # Test reading a SRS with a PCSCitationGeoKey = "LUnits = ..." -def tiff_srs_PCSCitationGeoKey_LUnits(): +def test_tiff_srs_PCSCitationGeoKey_LUnits(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_srs_PCSCitationGeoKey_LUnits.tif', 1, 1) ds.SetProjection("""PROJCS["UTM Zone 32, Northern Hemisphere", @@ -388,7 +388,7 @@ def tiff_srs_PCSCitationGeoKey_LUnits(): # Test reading a geotiff key ProjectionGeoKey (Short,1): Unknown-3856 -def tiff_srs_projection_3856(): +def test_tiff_srs_projection_3856(): ds = gdal.Open('data/projection_3856.tif') wkt = ds.GetProjectionRef() @@ -405,7 +405,7 @@ def tiff_srs_projection_3856(): # Test reading a geotiff with a LOCAL_CS and a Imagine citation -def tiff_srs_imagine_localcs_citation(): +def test_tiff_srs_imagine_localcs_citation(): ds = gdal.Open('data/imagine_localcs_citation.tif') wkt = ds.GetProjectionRef() @@ -423,7 +423,7 @@ def tiff_srs_imagine_localcs_citation(): # override the default coming from EPSG -def tiff_srs_towgs84_override(): +def test_tiff_srs_towgs84_override(): ds = gdal.Open('data/gtiff_towgs84_override.tif') wkt = ds.GetProjectionRef() @@ -440,7 +440,7 @@ def tiff_srs_towgs84_override(): # Test reading PCSCitationGeoKey (#7199) -def tiff_srs_pcscitation(): +def test_tiff_srs_pcscitation(): ds = gdal.Open('data/pcscitation.tif') wkt = ds.GetProjectionRef() @@ -560,18 +560,18 @@ def test_tiff_srs_proj4(proj4): gdaltest_list = [ - tiff_srs_without_linear_units, - tiff_srs_compd_cs, - tiff_srs_weird_mercator_2sp, - tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere, - tiff_srs_angular_units, - tiff_custom_datum_known_ellipsoid, - tiff_srs_epsg_2853_with_us_feet, - tiff_srs_PCSCitationGeoKey_LUnits, - tiff_srs_projection_3856, - tiff_srs_imagine_localcs_citation, - tiff_srs_towgs84_override, - tiff_srs_pcscitation, + test_tiff_srs_without_linear_units, + test_tiff_srs_compd_cs, + test_tiff_srs_weird_mercator_2sp, + test_tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere, + test_tiff_srs_angular_units, + test_tiff_custom_datum_known_ellipsoid, + test_tiff_srs_epsg_2853_with_us_feet, + test_tiff_srs_PCSCitationGeoKey_LUnits, + test_tiff_srs_projection_3856, + test_tiff_srs_imagine_localcs_citation, + test_tiff_srs_towgs84_override, + test_tiff_srs_pcscitation, ] if __name__ == '__main__': diff --git a/autotest/gcore/tiff_write.py b/autotest/gcore/tiff_write.py index 5d4039f4e644..787725d740ff 100755 --- a/autotest/gcore/tiff_write.py +++ b/autotest/gcore/tiff_write.py @@ -45,7 +45,7 @@ # Get the GeoTIFF driver, and verify a few things about it. -def tiff_write_1(): +def test_tiff_write_1(): gdaltest.tiff_drv = gdal.GetDriverByName('GTiff') if gdaltest.tiff_drv is None: @@ -63,7 +63,7 @@ def tiff_write_1(): # Create a simple file by copying from an existing one. -def tiff_write_2(): +def test_tiff_write_2(): src_ds = gdal.Open('data/cfloat64.tif') @@ -100,7 +100,7 @@ def tiff_write_2(): # Create a simple file by copying from an existing one. -def tiff_write_3(): +def test_tiff_write_3(): src_ds = gdal.Open('data/utmsmall.tif') @@ -125,7 +125,7 @@ def tiff_write_3(): # Create a tiled file. -def tiff_write_4(): +def test_tiff_write_4(): try: from osgeo import gdalnumeric @@ -218,7 +218,7 @@ def tiff_write_4(): # Write a file with GCPs. -def tiff_write_5(): +def test_tiff_write_5(): src_ds = gdal.Open('data/gcps.vrt') @@ -260,7 +260,7 @@ def tiff_write_5(): # (this is a sign of an older libtiff...) -def tiff_write_6(): +def test_tiff_write_6(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -298,7 +298,7 @@ def tiff_write_6(): # if BigTIFF is not supported (this is a sign of an older libtiff...) -def tiff_write_7(): +def test_tiff_write_7(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -331,7 +331,7 @@ def tiff_write_7(): # Test a mixture of reading and writing on a PACKBITS compressed file. -def tiff_write_8(): +def test_tiff_write_8(): options = ['TILED=YES', 'BLOCKXSIZE=32', 'BLOCKYSIZE=32', 'COMPRESS=PACKBITS'] ds = gdaltest.tiff_drv.Create('tmp/test_8.tif', 200, 200, 1, @@ -361,7 +361,7 @@ def tiff_write_8(): # Create a simple file by copying from an existing one. -def tiff_write_9(): +def test_tiff_write_9(): src_ds = gdal.Open('data/byte.tif') new_ds = gdaltest.tiff_drv.CreateCopy('tmp/test_9.tif', src_ds, @@ -386,7 +386,7 @@ def tiff_write_9(): # 1bit file but with band interleaving, and odd size (not multiple of 8) #1957 -def tiff_write_10(): +def test_tiff_write_10(): ut = gdaltest.GDALTest('GTiff', 'oddsize_1bit2b.tif', 2, 5918, options=['NBITS=1', 'INTERLEAVE=BAND']) @@ -396,7 +396,7 @@ def tiff_write_10(): # Simple 1 bit file, treated through the GTiffBitmapBand class. -def tiff_write_11(): +def test_tiff_write_11(): ut = gdaltest.GDALTest('GTiff', 'oddsize1bit.tif', 1, 5918, options=['NBITS=1', 'COMPRESS=CCITTFAX4']) @@ -406,7 +406,7 @@ def tiff_write_11(): # Read JPEG Compressed YCbCr subsampled image. -def tiff_write_12(): +def test_tiff_write_12(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -423,7 +423,7 @@ def tiff_write_12(): # Write JPEG Compressed YCbCr subsampled image. -def tiff_write_13(): +def test_tiff_write_13(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -461,7 +461,7 @@ def tiff_write_13(): # Test creating an in memory copy. -def tiff_write_14(): +def test_tiff_write_14(): tst = gdaltest.GDALTest('GTiff', 'byte.tif', 1, 4672) @@ -472,7 +472,7 @@ def tiff_write_14(): # Test that we can restrict metadata and georeferencing in the output # file using the PROFILE creation option with CreateCopy() -def tiff_write_15(): +def test_tiff_write_15(): ds_in = gdal.Open('data/byte.vrt') @@ -524,7 +524,7 @@ def tiff_write_15(): # file using the PROFILE creation option with Create() -def tiff_write_16(): +def test_tiff_write_16(): ds_in = gdal.Open('data/byte.vrt') @@ -590,7 +590,7 @@ def tiff_write_16(): # Test writing a TIFF with an RPC tag. -def tiff_write_17(): +def test_tiff_write_17(): # Translate RPC controlled data to GeoTIFF. @@ -657,10 +657,10 @@ def tiff_write_17(): # case (#3996) -def tiff_write_17_disable_readdir(): +def test_tiff_write_17_disable_readdir(): oldval = gdal.GetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN') gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', 'TRUE') - ret = tiff_write_17() + ret = test_tiff_write_17() gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', oldval) return ret @@ -668,7 +668,7 @@ def tiff_write_17_disable_readdir(): # Test writing a TIFF with an RPB file and IMD file. -def tiff_write_18(): +def test_tiff_write_18(): # Translate RPC controlled data to GeoTIFF. @@ -753,10 +753,10 @@ def tiff_write_18(): # case (#3996) -def tiff_write_18_disable_readdir(): +def test_tiff_write_18_disable_readdir(): oldval = gdal.GetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN') gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', 'TRUE') - ret = tiff_write_18() + ret = test_tiff_write_18() gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', oldval) return ret @@ -764,7 +764,7 @@ def tiff_write_18_disable_readdir(): # Test writing a TIFF with an _RPC.TXT -def tiff_write_rpc_txt(): +def test_tiff_write_rpc_txt(): # Translate RPC controlled data to GeoTIFF. @@ -829,7 +829,7 @@ def tiff_write_rpc_txt(): # Test writing a TIFF with an RPC in .aux.xml -def tiff_write_rpc_in_pam(): +def test_tiff_write_rpc_in_pam(): ds_in = gdal.Open('data/rpc.vrt') rpc_md = ds_in.GetMetadata('RPC') @@ -870,7 +870,7 @@ def tiff_write_rpc_in_pam(): # Test the write of a pixel-interleaved image with NBITS = 7 -def tiff_write_19(): +def test_tiff_write_19(): src_ds = gdal.Open('data/contig_strip.tif') @@ -901,7 +901,7 @@ def tiff_write_19(): # Also test unsetting those tags (#5619) -def tiff_write_20(): +def test_tiff_write_20(): new_ds = gdaltest.tiff_drv.Create('tmp/tags.tif', 1, 1, 1) @@ -989,7 +989,7 @@ def tiff_write_20(): # Test RGBA images with TIFFTAG_EXTRASAMPLES=EXTRASAMPLE_ASSOCALPHA -def tiff_write_21(): +def test_tiff_write_21(): src_ds = gdal.Open('data/stefan_full_rgba.tif') @@ -1017,7 +1017,7 @@ def tiff_write_21(): # Test RGBA images with TIFFTAG_EXTRASAMPLES=EXTRASAMPLE_UNSPECIFIED -def tiff_write_22(): +def test_tiff_write_22(): src_ds = gdal.Open('data/stefan_full_rgba_photometric_rgb.tif') @@ -1045,7 +1045,7 @@ def tiff_write_22(): # Test grey+alpha images with ALPHA=YES -def tiff_write_23(): +def test_tiff_write_23(): src_ds = gdal.Open('data/stefan_full_greyalpha.tif') @@ -1073,7 +1073,7 @@ def tiff_write_23(): # Test grey+alpha images without ALPHA=YES -def tiff_write_24(): +def test_tiff_write_24(): src_ds = gdal.Open('data/stefan_full_greyalpha.tif') @@ -1101,7 +1101,7 @@ def tiff_write_24(): # Read a CIELAB image to test the RGBA image TIFF interface -def tiff_write_25(): +def test_tiff_write_25(): src_ds = gdal.Open('data/cielab.tif') if src_ds.RasterCount != 4: @@ -1130,7 +1130,7 @@ def tiff_write_25(): ############################################################################### # Test color table in a 8 bit image -def tiff_write_26(): +def test_tiff_write_26(): ds = gdaltest.tiff_drv.Create('tmp/ct8.tif', 1, 1, 1, gdal.GDT_Byte) @@ -1167,7 +1167,7 @@ def tiff_write_26(): # Test color table in a 16 bit image -def tiff_write_27(): +def test_tiff_write_27(): ds = gdaltest.tiff_drv.Create('tmp/ct16.tif', 1, 1, 1, gdal.GDT_UInt16) @@ -1210,7 +1210,7 @@ def tiff_write_27(): # Test SetRasterColorInterpretation on a 2 channel image -def tiff_write_28(): +def test_tiff_write_28(): ds = gdaltest.tiff_drv.Create('tmp/greyalpha.tif', 1, 1, 2) @@ -1238,7 +1238,7 @@ def tiff_write_28(): # Test SetRasterColorInterpretation on a 4 channel image -def tiff_write_29(): +def test_tiff_write_29(): # When creating a 4 channel image with PHOTOMETRIC=RGB, # TIFFTAG_EXTRASAMPLES=EXTRASAMPLE_UNSPECIFIED @@ -1321,7 +1321,7 @@ def tiff_write_29(): ############################################################################### # Create a BigTIFF image with BigTIFF=YES -def tiff_write_30(): +def test_tiff_write_30(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -1353,7 +1353,7 @@ def tiff_write_30(): # Create a BigTIFF image implicitly (more than 4Gb). -def tiff_write_31(): +def test_tiff_write_31(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -1386,7 +1386,7 @@ def tiff_write_31(): # Create a rotated image -def tiff_write_32(): +def test_tiff_write_32(): ds_in = gdal.Open('data/byte.vrt') @@ -1428,7 +1428,7 @@ def tiff_write_32(): # (BASELINE is tested by tiff_write_15) -def tiff_write_33(): +def test_tiff_write_33(): ds_in = gdal.Open('data/byte.vrt') @@ -1484,7 +1484,7 @@ def tiff_write_33(): # (BASELINE is tested by tiff_write_16) -def tiff_write_34(): +def test_tiff_write_34(): ds = gdaltest.tiff_drv.Create('tmp/tw_34.tif', 1, 1, gdal.GDT_Byte, options=['PROFILE=GeoTIFF']) @@ -1539,7 +1539,7 @@ def tiff_write_34(): # when metadata is too big to fit into the GDALGeotiff tag -def tiff_write_35(): +def test_tiff_write_35(): # I've no idea why this works, and why this rolled in a # loop doesn't work... Python gurus please fix that ! @@ -1643,63 +1643,63 @@ def tiff_write_big_odd_bits(vrtfilename, tmpfilename, nbits, interleaving): ############################################################################### # Test copy with NBITS=9, INTERLEAVE=PIXEL -def tiff_write_36(): +def test_tiff_write_36(): return tiff_write_big_odd_bits('data/uint16_3band.vrt', 'tmp/tw_36.tif', 9, 'PIXEL') ############################################################################### # Test copy with NBITS=9, INTERLEAVE=BAND -def tiff_write_37(): +def test_tiff_write_37(): return tiff_write_big_odd_bits('data/uint16_3band.vrt', 'tmp/tw_37.tif', 9, 'BAND') ############################################################################### # Test copy with NBITS=12, INTERLEAVE=PIXEL -def tiff_write_38(): +def test_tiff_write_38(): return tiff_write_big_odd_bits('data/uint16_3band.vrt', 'tmp/tw_38.tif', 12, 'PIXEL') ############################################################################### # Test copy with NBITS=12, INTERLEAVE=BAND -def tiff_write_39(): +def test_tiff_write_39(): return tiff_write_big_odd_bits('data/uint16_3band.vrt', 'tmp/tw_39.tif', 12, 'BAND') ############################################################################### # Test copy with NBITS=17, INTERLEAVE=PIXEL -def tiff_write_40(): +def test_tiff_write_40(): return tiff_write_big_odd_bits('data/uint32_3band.vrt', 'tmp/tw_40tif', 17, 'PIXEL') ############################################################################### # Test copy with NBITS=17, INTERLEAVE=BAND -def tiff_write_41(): +def test_tiff_write_41(): return tiff_write_big_odd_bits('data/uint32_3band.vrt', 'tmp/tw_41.tif', 17, 'BAND') ############################################################################### # Test copy with NBITS=24, INTERLEAVE=PIXEL -def tiff_write_42(): +def test_tiff_write_42(): return tiff_write_big_odd_bits('data/uint32_3band.vrt', 'tmp/tw_42.tif', 24, 'PIXEL') ############################################################################### # Test copy with NBITS=24, INTERLEAVE=BAND -def tiff_write_43(): +def test_tiff_write_43(): return tiff_write_big_odd_bits('data/uint32_3band.vrt', 'tmp/tw_43.tif', 24, 'BAND') ############################################################################### # Test create with NBITS=9 and preservation through CreateCopy of NBITS -def tiff_write_44(): +def test_tiff_write_44(): ds = gdaltest.tiff_drv.Create('tmp/tw_44.tif', 1, 1, 1, gdal.GDT_UInt16, options=['NBITS=9']) ds = None @@ -1734,7 +1734,7 @@ def tiff_write_44(): # Test create with NBITS=17 and preservation through CreateCopy of NBITS -def tiff_write_45(): +def test_tiff_write_45(): ds = gdaltest.tiff_drv.Create('tmp/tw_45.tif', 1, 1, 1, gdal.GDT_UInt32, options=['NBITS=17']) ds = None @@ -1769,7 +1769,7 @@ def tiff_write_45(): ############################################################################### # Test correct round-tripping of ReadBlock/WriteBlock -def tiff_write_46(): +def test_tiff_write_46(): import struct with gdaltest.SetCacheMax(0): @@ -1814,17 +1814,17 @@ def tiff_write_46(): # Test #2457 -def tiff_write_47(): +def test_tiff_write_47(): with gdaltest.SetCacheMax(0): - ret = tiff_write_3() + ret = test_tiff_write_3() return ret ############################################################################### # Test #2457 with nYOff of RasterIO not aligned on the block height -def tiff_write_48(): +def test_tiff_write_48(): with gdaltest.SetCacheMax(0): @@ -1852,7 +1852,7 @@ def tiff_write_48(): ############################################################################### # Test copying a CMYK TIFF into another CMYK TIFF -def tiff_write_49(): +def test_tiff_write_49(): # We open the source as RAW to get the CMYK bands src_ds = gdal.Open('GTIFF_RAW:data/rgbsmall_cmyk.tif') @@ -1885,7 +1885,7 @@ def tiff_write_49(): ############################################################################### # Test creating a CMYK TIFF from another CMYK TIFF -def tiff_write_50(): +def test_tiff_write_50(): # We open the source as RAW to get the CMYK bands src_ds = gdal.Open('GTIFF_RAW:data/rgbsmall_cmyk.tif') @@ -1921,7 +1921,7 @@ def tiff_write_50(): # Test proper clearing of existing GeoTIFF tags when updating the projection. # http://trac.osgeo.org/gdal/ticket/2546 -def tiff_write_51(): +def test_tiff_write_51(): shutil.copyfile('data/utmsmall.tif', 'tmp/tiff_write_51.tif') ds = gdal.Open('tmp/tiff_write_51.tif', gdal.GA_Update) @@ -1966,7 +1966,7 @@ def tiff_write_51(): # Test the ability to update a paletted TIFF files color table. -def tiff_write_52(): +def test_tiff_write_52(): shutil.copyfile('data/test_average_palette.tif', 'tmp/tiff_write_52.tif') test_ct_data = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255, 0)] @@ -1998,7 +1998,7 @@ def tiff_write_52(): # Test the ability to create a paletted image and then update later. -def tiff_write_53(): +def test_tiff_write_53(): test_ct_data = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255, 0)] test_ct = gdal.ColorTable() @@ -2035,7 +2035,7 @@ def tiff_write_53(): # Same as before except we create an overview before reopening the file and # adding the color table -def tiff_write_53_bis(): +def test_tiff_write_53_bis(): test_ct_data = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255, 0)] test_ct = gdal.ColorTable() @@ -2073,7 +2073,7 @@ def tiff_write_53_bis(): # and write data into it without closing it and re-opening it (#2645) -def tiff_write_54(): +def test_tiff_write_54(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -2103,7 +2103,7 @@ def tiff_write_54(): ############################################################################### # Test creating and reading an equirectangular file with all parameters (#2706) -def tiff_write_55(): +def test_tiff_write_55(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_55.tif', 256, 256, 1) @@ -2131,7 +2131,7 @@ def tiff_write_55(): # Test clearing the colormap from an existing paletted TIFF file. -def tiff_write_56(): +def test_tiff_write_56(): md = gdaltest.tiff_drv.GetMetadata() # Expected to fail with libtiff < 4.0 as it needs TIFFUnsetField, so skip it @@ -2174,7 +2174,7 @@ def tiff_write_56(): # Test replacing normal norm up georef with rotated georef (#2625) -def tiff_write_57(): +def test_tiff_write_57(): md = gdaltest.tiff_drv.GetMetadata() # Expected to fail with libtiff < 4.0 as it needs TIFFUnsetField, so skip it @@ -2207,7 +2207,7 @@ def tiff_write_57(): # Test writing partial end strips (#2748) -def tiff_write_58(): +def test_tiff_write_58(): md = gdaltest.tiff_drv.GetMetadata() @@ -2234,7 +2234,7 @@ def tiff_write_58(): # Test fix for #2759 -def tiff_write_59(): +def test_tiff_write_59(): import struct ret = 'success' @@ -2284,7 +2284,7 @@ def tiff_write_59(): # Test fix for #2760 -def tiff_write_60(): +def test_tiff_write_60(): tuples = [('TFW=YES', 'tmp/tiff_write_60.tfw'), ('WORLDFILE=YES', 'tmp/tiff_write_60.wld')] @@ -2343,7 +2343,7 @@ def tiff_write_60(): # Test BigTIFF=IF_NEEDED creation option -def tiff_write_61(): +def test_tiff_write_61(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -2376,7 +2376,7 @@ def tiff_write_61(): # Test BigTIFF=IF_SAFER creation option -def tiff_write_62(): +def test_tiff_write_62(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -2409,7 +2409,7 @@ def tiff_write_62(): # Test BigTIFF=NO creation option when creating a BigTIFF file would be required -def tiff_write_63(): +def test_tiff_write_63(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -2431,7 +2431,7 @@ def tiff_write_63(): # Test returned projection in WKT format for a WGS84 GeoTIFF (#2787) -def tiff_write_64(): +def test_tiff_write_64(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_64.tif', 1, 1, 1) srs = osr.SpatialReference() @@ -2459,7 +2459,7 @@ def tiff_write_64(): # Verify that we can write XML metadata. -def tiff_write_65(): +def test_tiff_write_65(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_65.tif', 10, 10) @@ -2484,7 +2484,7 @@ def tiff_write_65(): ############################################################################### # Verify that we can write and read a band-interleaved GeoTIFF with 65535 bands (#2838) -def tiff_write_66(): +def test_tiff_write_66(): if gdal.GetConfigOption('SKIP_MEM_INTENSIVE_TEST') is not None: return 'skip' @@ -2512,7 +2512,7 @@ def tiff_write_66(): ############################################################################### # Verify that we can write and read a pixel-interleaved GeoTIFF with 65535 bands (#2838) -def tiff_write_67(): +def test_tiff_write_67(): if gdal.GetConfigOption('SKIP_MEM_INTENSIVE_TEST') is not None: return 'skip' @@ -2540,7 +2540,7 @@ def tiff_write_67(): # Verify that we can set the color table after a Create() (scenario hit by map.tif in #2820) -def tiff_write_68(): +def test_tiff_write_68(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_68.tif', 151, 161, options=['COMPRESS=LZW']) ct = gdal.ColorTable() @@ -2565,7 +2565,7 @@ def tiff_write_68(): # Verify GTiffRasterBand::NullBlock() when reading empty block without any nodata value set -def tiff_write_69(): +def test_tiff_write_69(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_69.tif', 32, 32, 1, gdal.GDT_Int16, options=['SPARSE_OK=YES']) ds = None @@ -2584,7 +2584,7 @@ def tiff_write_69(): # Verify GTiffRasterBand::NullBlock() when reading empty block with nodata value set -def tiff_write_70(): +def test_tiff_write_70(): ref_ds = gdaltest.tiff_drv.Create('tmp/tiff_write_70_ref.tif', 32, 32, 1, gdal.GDT_Int16) ref_ds.GetRasterBand(1).Fill(-32768) @@ -2645,7 +2645,7 @@ def tiff_write_70(): ############################################################################### # Test reading in a real BigTIFF file (on filesystems supporting sparse files) -def tiff_write_71(): +def test_tiff_write_71(): import struct @@ -2694,7 +2694,7 @@ def tiff_write_71(): # and has not been rewritten later (#3021) -def tiff_write_72(): +def test_tiff_write_72(): shutil.copyfile('data/byte.tif', 'tmp/byte.tif') ds = gdal.Open('tmp/byte.tif', gdal.GA_Update) @@ -2731,7 +2731,7 @@ def tiff_write_72(): # and has not been rewritten later (#3021) -def tiff_write_73(): +def test_tiff_write_73(): out_ds = gdaltest.tiff_drv.Create('tmp/tiff_write_73.tif', 10, 10, options=['ENDIANNESS=LITTLE']) out_ds.SetGeoTransform([1, 0.01, 0, 1, 0, -0.01]) @@ -2782,7 +2782,7 @@ def tiff_write_73(): # Verify we can write 12bit jpeg encoded tiff. -def tiff_write_74(): +def test_tiff_write_74(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -2859,7 +2859,7 @@ def tiff_write_74(): # Verify that FlushCache() alone doesn't cause crash (#3067 ) -def tiff_write_75(): +def test_tiff_write_75(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_75.tif', 1, 1, 1) ds.FlushCache() @@ -2873,7 +2873,7 @@ def tiff_write_75(): # Test generating a G4 band to use the TIFFWriteScanline() -def tiff_write_76(): +def test_tiff_write_76(): src_ds = gdal.Open('data/slim_g4.tif') compression = src_ds.GetMetadata('IMAGE_STRUCTURE')['COMPRESSION'] @@ -2898,7 +2898,7 @@ def tiff_write_76(): # Test generating & reading a 8bit all-in-one-strip multiband TIFF (#3904) -def tiff_write_77(): +def test_tiff_write_77(): src_ds = gdaltest.tiff_drv.Create('tmp/tiff_write_77_src.tif', 1, 5000, 3) src_ds.GetRasterBand(2).Fill(255) @@ -2951,7 +2951,7 @@ def tiff_write_77(): # Test generating & reading a YCbCr JPEG all-in-one-strip multiband TIFF (#3259) -def tiff_write_78(): +def test_tiff_write_78(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -3021,7 +3021,7 @@ def tiff_write_78(): # Test reading & updating GDALMD_AREA_OR_POINT (#3522) -def tiff_write_79(): +def test_tiff_write_79(): ds = gdaltest.tiff_drv.Create('tmp/tiff_write_79.tif', 1, 1) srs = osr.SpatialReference() @@ -3132,7 +3132,7 @@ def tiff_write_79(): # Test SetOffset() & SetScale() -def tiff_write_80(): +def test_tiff_write_80(): # First part : test storing and retrieving scale & offsets from internal metadata ds = gdaltest.tiff_drv.Create('tmp/tiff_write_80.tif', 1, 1) @@ -3253,7 +3253,7 @@ def tiff_write_80(): # Test retrieving GCP from PAM -def tiff_write_81(): +def test_tiff_write_81(): shutil.copyfile('data/byte.tif', 'tmp/tiff_write_81.tif') f = open('tmp/tiff_write_81.tif.aux.xml', 'wt') @@ -3290,7 +3290,7 @@ def tiff_write_81(): # Test writing & reading a signedbyte 8 bit geotiff -def tiff_write_82(): +def test_tiff_write_82(): src_ds = gdal.Open('data/byte.tif') ds = gdaltest.tiff_drv.CreateCopy('tmp/tiff_write_82.tif', src_ds, options=['PIXELTYPE=SIGNEDBYTE']) @@ -3312,7 +3312,7 @@ def tiff_write_82(): ############################################################################### # Test writing & reading an indexed GeoTIFF with an extra transparency band (#3547) -def tiff_write_83(): +def test_tiff_write_83(): # Test Create() method ds = gdaltest.tiff_drv.Create('tmp/tiff_write_83.tif', 1, 1, 2) @@ -3355,7 +3355,7 @@ def tiff_write_83(): # changes in the midst of encoding of tiles (#3539) -def tiff_write_84(): +def test_tiff_write_84(): md = gdaltest.tiff_drv.GetMetadata() @@ -3397,7 +3397,7 @@ def tiff_write_84(): # Test SetUnitType() -def tiff_write_85(): +def test_tiff_write_85(): # First part : test storing and retrieving unittype from internal metadata ds = gdaltest.tiff_drv.Create('tmp/tiff_write_85.tif', 1, 1) @@ -3507,7 +3507,7 @@ def tiff_write_85(): # properly with earlier versions of ArcGIS, requested by ESRI. -def tiff_write_86(): +def test_tiff_write_86(): gdal.SetConfigOption('ESRI_XML_PAM', 'YES') @@ -3599,7 +3599,7 @@ def tiff_write_86(): ############################################################################### # Test COPY_SRC_OVERVIEWS creation option -def tiff_write_87(): +def test_tiff_write_87(): gdal.Translate('tmp/tiff_write_87_src.tif', 'data/utmsmall.tif', options='-a_nodata 0') @@ -3666,7 +3666,7 @@ def tiff_write_87(): # on BIGTIFF creation -def tiff_write_88(): +def test_tiff_write_88(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -3729,7 +3729,7 @@ def tiff_write_88(): # Test JPEG_QUALITY propagation while creating a (default compressed) mask band -def tiff_write_89(): +def test_tiff_write_89(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -3787,7 +3787,7 @@ def tiff_write_89(): # Test JPEG_QUALITY propagation while creating (internal) overviews -def tiff_write_90(): +def test_tiff_write_90(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -3835,7 +3835,7 @@ def tiff_write_90(): ############################################################################### # Test JPEG_QUALITY propagation while creating (internal) overviews after re-opening -def tiff_write_91(): +def test_tiff_write_91(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -3889,7 +3889,7 @@ def tiff_write_91(): # Test the effect of JPEG_QUALITY_OVERVIEW while creating (internal) overviews after re-opening # This will test that we correctly guess the quality of the main dataset -def tiff_write_92(): +def test_tiff_write_92(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -3950,7 +3950,7 @@ def tiff_write_92(): # Test JPEG_QUALITY_OVERVIEW propagation while creating external overviews -def tiff_write_93(): +def test_tiff_write_93(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -4018,7 +4018,7 @@ def tiff_write_93(): # Test CreateCopy() of a dataset with a mask into a JPEG compressed dataset # and check JPEG_QUALITY propagation without warning -def tiff_write_94(): +def test_tiff_write_94(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -4059,7 +4059,7 @@ def tiff_write_94(): # overview levels from the overview size -def tiff_write_95(): +def test_tiff_write_95(): src_ds = gdaltest.tiff_drv.Create('tmp/tiff_write_95_src.tif', 7171, 6083, options=['SPARSE_OK=YES']) src_ds.BuildOverviews('NONE', overviewlist=[2, 4, 8, 16, 32, 64]) @@ -4082,7 +4082,7 @@ def tiff_write_95(): # Test that COPY_SRC_OVERVIEWS combined with GDAL_TIFF_INTERNAL_MASK=YES work well -def tiff_write_96(): +def test_tiff_write_96(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK', 'YES') src_ds = gdaltest.tiff_drv.Create('tmp/tiff_write_96_src.tif', 100, 100) @@ -4132,7 +4132,7 @@ def tiff_write_96(): # Create a simple file by copying from an existing one - PixelIsPoint -def tiff_write_97(): +def test_tiff_write_97(): gdal.SetConfigOption('GTIFF_POINT_GEO_IGNORE', 'FALSE') @@ -4208,7 +4208,7 @@ def tiff_write_97(): # Create a rotated geotiff file (uses a geomatrix) with - PixelIsPoint -def tiff_write_98(): +def test_tiff_write_98(): gdal.SetConfigOption('GTIFF_POINT_GEO_IGNORE', 'FALSE') @@ -4262,7 +4262,7 @@ def tiff_write_98(): # Create copy into a RGB JPEG-IN-TIFF (#3887) -def tiff_write_99(): +def test_tiff_write_99(): src_ds = gdal.Open('data/rgbsmall.tif') new_ds = gdaltest.tiff_drv.CreateCopy('tmp/test_99.tif', src_ds, options=['COMPRESS=JPEG']) @@ -4287,7 +4287,7 @@ def tiff_write_99(): # Create copy into a 2 band JPEG-IN-TIFF (#3887) -def tiff_write_100(): +def test_tiff_write_100(): src_ds = gdaltest.tiff_drv.Create('/vsimem/test_100_src.tif', 16, 16, 2) src_ds.GetRasterBand(1).Fill(255) @@ -4315,7 +4315,7 @@ def tiff_write_100(): # reloading. tiff_write_78 doesn't produce enough big data to trigger this... -def tiff_write_101(): +def test_tiff_write_101(): if not gdaltest.run_slow_tests(): return 'skip' @@ -4393,7 +4393,7 @@ def tiff_write_101(): # Test writing and reading back COMPD_CS -def tiff_write_102(): +def test_tiff_write_102(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_102.tif', 1, 1) sr = osr.SpatialReference() @@ -4439,7 +4439,7 @@ def tiff_write_102(): # Test -co COPY_SRC_OVERVIEWS=YES on a multiband source with external overviews (#3938) -def tiff_write_103(): +def test_tiff_write_103(): import test_cli_utilities if test_cli_utilities.get_gdaladdo_path() is None: return 'skip' @@ -4471,7 +4471,7 @@ def tiff_write_103(): # Confirm as best we can that we can write geotiff files with detailed # projection parameters with the correct linear units set. (#3901) -def tiff_write_104(): +def test_tiff_write_104(): src_ds = gdal.Open('data/spaf27_correct.tif') dst_ds = gdaltest.tiff_drv.CreateCopy('tmp/test_104.tif', src_ds) @@ -4498,7 +4498,7 @@ def tiff_write_104(): # projection parameters with the correct linear units set. (#3901) -def tiff_write_105(): +def test_tiff_write_105(): # This hangs forever with libtiff 3.8.2, so skip it md = gdaltest.tiff_drv.GetMetadata() @@ -4531,7 +4531,7 @@ def tiff_write_105(): # Test the direct copy mechanism of JPEG source -def tiff_write_106(filename='../gdrivers/data/byte_with_xmp.jpg', options=None, check_cs=True): +def test_tiff_write_106(filename='../gdrivers/data/byte_with_xmp.jpg', options=None, check_cs=True): if options is None: options = ['COMPRESS=JPEG'] @@ -4573,54 +4573,54 @@ def tiff_write_106(filename='../gdrivers/data/byte_with_xmp.jpg', options=None, return 'success' -def tiff_write_107(): - return tiff_write_106(options=['COMPRESS=JPEG', 'BLOCKYSIZE=8']) +def test_tiff_write_107(): + return test_tiff_write_106(options=['COMPRESS=JPEG', 'BLOCKYSIZE=8']) -def tiff_write_108(): - return tiff_write_106(options=['COMPRESS=JPEG', 'BLOCKYSIZE=20']) +def test_tiff_write_108(): + return test_tiff_write_106(options=['COMPRESS=JPEG', 'BLOCKYSIZE=20']) -def tiff_write_109(): - return tiff_write_106(options=['COMPRESS=JPEG', 'TILED=YES', 'BLOCKYSIZE=16', 'BLOCKXSIZE=16']) +def test_tiff_write_109(): + return test_tiff_write_106(options=['COMPRESS=JPEG', 'TILED=YES', 'BLOCKYSIZE=16', 'BLOCKXSIZE=16']) # Strip organization of YCbCr does *NOT* give exact pixels w.r.t. original image -def tiff_write_110(): - return tiff_write_106(filename='../gdrivers/data/albania.jpg', check_cs=False) +def test_tiff_write_110(): + return test_tiff_write_106(filename='../gdrivers/data/albania.jpg', check_cs=False) # Whole copy of YCbCr *DOES* give exact pixels w.r.t. original image -def tiff_write_111(): - return tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=260']) +def test_tiff_write_111(): + return test_tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=260']) -def tiff_write_111_bis(): - return tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=260', 'INTERLEAVE=PIXEL']) +def test_tiff_write_111_bis(): + return test_tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=260', 'INTERLEAVE=PIXEL']) -def tiff_write_111_ter(): - return tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=260', 'INTERLEAVE=BAND'], check_cs=False) +def test_tiff_write_111_ter(): + return test_tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=260', 'INTERLEAVE=BAND'], check_cs=False) # Tiled organization of YCbCr does *NOT* give exact pixels w.r.t. original image -def tiff_write_112(): - return tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'TILED=YES'], check_cs=False) +def test_tiff_write_112(): + return test_tiff_write_106(filename='../gdrivers/data/albania.jpg', options=['COMPRESS=JPEG', 'TILED=YES'], check_cs=False) # The source is a JPEG in RGB colorspace (usually it is YCbCr). -def tiff_write_113(): - return tiff_write_106(filename='../gdrivers/data/rgbsmall_rgb.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=8']) +def test_tiff_write_113(): + return test_tiff_write_106(filename='../gdrivers/data/rgbsmall_rgb.jpg', options=['COMPRESS=JPEG', 'BLOCKYSIZE=8']) ############################################################################### # Test CreateCopy() interruption -def tiff_write_114(): +def test_tiff_write_114(): tst = gdaltest.GDALTest('GTiff', 'byte.tif', 1, 4672) @@ -4630,7 +4630,7 @@ def tiff_write_114(): # Test writing a pixel interleaved RGBA JPEG-compressed TIFF -def tiff_write_115(): +def test_tiff_write_115(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: return 'skip' @@ -4682,7 +4682,7 @@ def tiff_write_115(): # Test writing a band interleaved RGBA JPEG-compressed TIFF -def tiff_write_116(): +def test_tiff_write_116(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: return 'skip' @@ -4734,7 +4734,7 @@ def tiff_write_116(): # Test bugfix for ticket #4771 (rewriting of a deflate compressed tile, libtiff bug) -def tiff_write_117(): +def test_tiff_write_117(): # This will also fail with a libtiff 4.x older than 2012-08-13 # Might be good to be able to test internal libtiff presence md = gdaltest.tiff_drv.GetMetadata() @@ -4787,7 +4787,7 @@ def tiff_write_117(): # Test bugfix for ticket #4816 -def tiff_write_118(): +def test_tiff_write_118(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_write_118.tif', 1, 1) # Should be rejected in a non-XML domain @@ -4810,7 +4810,7 @@ def tiff_write_118(): # Test bugfix for ticket #4816 -def tiff_write_119(): +def test_tiff_write_119(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_write_119.tif', 1, 1) ds.SetMetadata('foo=bar', 'foo') @@ -4832,7 +4832,7 @@ def tiff_write_119(): # Test bugfix for ticket #4816 -def tiff_write_120(): +def test_tiff_write_120(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tiff_write_120.tif', 1, 1) ds.SetMetadata('', 'xml:foo') @@ -4857,7 +4857,7 @@ def tiff_write_120(): # Test error cases of COPY_SRC_OVERVIEWS creation option -def tiff_write_121(): +def test_tiff_write_121(): # Test when the overview band is NULL src_ds = gdal.Open(""" @@ -4946,7 +4946,7 @@ def tiff_write_121(): # Expected to fail (properly) with older libtiff versions (<=3.8.2 for sure) -def tiff_write_122(): +def test_tiff_write_122(): new_ds = gdaltest.tiff_drv.Create('tmp/tags122.tif', 1, 1, 1) new_ds.SetMetadata({ @@ -4977,7 +4977,7 @@ def tiff_write_122(): # Test implicit photometric interpretation -def tiff_write_123(): +def test_tiff_write_123(): src_ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_123_src.tif', 1, 1, 5, gdal.GDT_Int16) src_ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_GreenBand) @@ -5261,7 +5261,7 @@ def tiff_write_123(): # Test error cases with palette creation -def tiff_write_124(): +def test_tiff_write_124(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_124.tif', 1, 1, 3, gdal.GDT_Byte) @@ -5304,7 +5304,7 @@ def tiff_write_124(): # Test out-of-memory conditions with SplitBand and SplitBitmapBand -def tiff_write_125(): +def test_tiff_write_125(): if gdal.GetConfigOption('SKIP_MEM_INTENSIVE_TEST') is not None: return 'skip' @@ -5337,7 +5337,7 @@ def tiff_write_125(): # Test implicit JPEG-in-TIFF overviews -def tiff_write_126(): +def test_tiff_write_126(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -5533,7 +5533,7 @@ def tiff_write_126(): # Test setting/unsetting metadata in update mode (#5628) -def tiff_write_127(): +def test_tiff_write_127(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_127.tif', 1, 1) ds = None @@ -5600,7 +5600,7 @@ def tiff_write_127(): # Test lossless copying of a CMYK JPEG into JPEG-in-TIFF (#5712) -def tiff_write_128(): +def test_tiff_write_128(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -5677,7 +5677,7 @@ def tiff_write_128(): # Check effective guessing of existing JPEG quality -def tiff_write_129(): +def test_tiff_write_129(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -5723,7 +5723,7 @@ def tiff_write_129(): # Test cases where JPEG quality will fail -def tiff_write_130(): +def test_tiff_write_130(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: return 'skip' @@ -5773,7 +5773,7 @@ def tiff_write_130(): # Test LZMA compression -def tiff_write_131(level=1): +def test_tiff_write_131(level=1): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LZMA') == -1: @@ -5804,15 +5804,15 @@ def tiff_write_131(level=1): return 'success' -def tiff_write_131_level_9(): - return tiff_write_131(level=9) +def test_tiff_write_131_level_9(): + return test_tiff_write_131(level=9) ############################################################################### # Test that PAM metadata is cleared when internal metadata is set (#5807) -def tiff_write_132(): +def test_tiff_write_132(): for i in range(2): @@ -5860,7 +5860,7 @@ def tiff_write_132(): # Test streaming capabilities -def tiff_write_133(): +def test_tiff_write_133(): src_ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_133.tif', 1024, 1000, 3, options=['STREAMABLE_OUTPUT=YES']) src_ds.SetGeoTransform([1, 2, 0, 3, 0, -2]) @@ -6143,7 +6143,7 @@ def tiff_write_133(): # Test DISCARD_LSB -def tiff_write_134(): +def test_tiff_write_134(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_134.tif', 1, 1, 3, options=['DISCARD_LSB=0,1,3']) ds.GetRasterBand(1).Fill(127) @@ -6207,7 +6207,7 @@ def tiff_write_134(): # Test clearing GCPs (#5945) -def tiff_write_135(): +def test_tiff_write_135(): # Simple clear src_ds = gdal.Open('data/gcps.vrt') @@ -6279,7 +6279,7 @@ def tiff_write_135(): # Test writing a single-strip mono-bit dataset -def tiff_write_136(): +def test_tiff_write_136(): src_ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_136_src.tif', 8, 2001) src_ds.GetRasterBand(1).Fill(1) @@ -6305,7 +6305,7 @@ def tiff_write_136(): # Test multi-threaded writing -def tiff_write_137(): +def test_tiff_write_137(): src_ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_137_src.tif', 4000, 4000) src_ds.GetRasterBand(1).Fill(1) @@ -6393,7 +6393,7 @@ def tiff_write_137(): # Test that pixel-interleaved writing generates optimal size -def tiff_write_138(): +def test_tiff_write_138(): # Test that consecutive IWriteBlock() calls for the same block but in # different bands only generate a single tile write, and not 3 rewrites @@ -6446,7 +6446,7 @@ def tiff_write_138(): # Test that pixel-interleaved writing generates optimal size -def tiff_write_139(): +def test_tiff_write_139(): import struct drv = gdal.GetDriverByName('GTiff') @@ -6561,7 +6561,7 @@ def tiff_write_139(): # Test setting a band to alpha -def tiff_write_140(): +def test_tiff_write_140(): # Nominal case: set alpha to last band ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_140.tif', 1, 1, 5) @@ -6643,7 +6643,7 @@ def tiff_write_140(): # Test GEOTIFF_KEYS_FLAVOR=ESRI_PE with EPSG:3857 -def tiff_write_141(): +def test_tiff_write_141(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_141.tif', 1, 1, options=['GEOTIFF_KEYS_FLAVOR=ESRI_PE']) srs = osr.SpatialReference() @@ -6673,7 +6673,7 @@ def tiff_write_141(): ############################################################################### # Test PixelIsPoint without SRS (#6225) -def tiff_write_142(): +def test_tiff_write_142(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_142.tif', 1, 1) ds.SetMetadataItem('AREA_OR_POINT', 'Point') @@ -6708,7 +6708,7 @@ def tiff_write_142(): # Check that we detect that free space isn't sufficient -def tiff_write_143(): +def test_tiff_write_143(): with gdaltest.error_handler(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_143.tif', 1000000000, 1000000000) @@ -6722,7 +6722,7 @@ def tiff_write_143(): # Test creating a real BigTIFF file > 4 GB with multiple directories (on filesystems supporting sparse files) -def tiff_write_144(): +def test_tiff_write_144(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('BigTIFF') == -1: @@ -6766,7 +6766,7 @@ def tiff_write_144(): # Test various warnings / errors of Create() -def tiff_write_145(): +def test_tiff_write_145(): options_list = [{'bands': 65536, 'expected_failure': True}, {'creation_options': ['INTERLEAVE=foo'], 'expected_failure': True}, @@ -6827,7 +6827,7 @@ def tiff_write_145(): # is a legal formulation since 4 bands should probably be seen as CMYK) -def tiff_write_146(): +def test_tiff_write_146(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -6857,7 +6857,7 @@ def tiff_write_146(): # to RGBA -def tiff_write_147(): +def test_tiff_write_147(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -6881,7 +6881,7 @@ def tiff_write_147(): # Test that we can use implicit JPEG-in-TIFF overviews with CMYK in raw mode -def tiff_write_148(): +def test_tiff_write_148(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -6916,7 +6916,7 @@ def tiff_write_148(): # Test filling missing blocks with nodata -def tiff_write_149(): +def test_tiff_write_149(): # Power-of-two bit depth ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_149.tif', 1, 1) @@ -6980,7 +6980,7 @@ def tiff_write_149(): # Test failure when loading block from disk in IWriteBlock() -def tiff_write_150(): +def test_tiff_write_150(): shutil.copy('data/tiled_bad_offset.tif', 'tmp/tiled_bad_offset.tif') ds = gdal.Open('tmp/tiled_bad_offset.tif', gdal.GA_Update) @@ -7000,7 +7000,7 @@ def tiff_write_150(): # Test IWriteBlock() with more than 10 bands -def tiff_write_151(): +def test_tiff_write_151(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_151.tif', 1, 1, 11) ds = None @@ -7031,7 +7031,7 @@ def tiff_write_151(): # Test flushing of blocks in a contig multi band file with Create() -def tiff_write_152(): +def test_tiff_write_152(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_152.tif', 1, 1, 2, options=['NBITS=2']) ds.GetRasterBand(2).SetNoDataValue(3) @@ -7055,7 +7055,7 @@ def tiff_write_152(): # Test that empty blocks are created in a filesystem sparse way -def tiff_write_153(): +def test_tiff_write_153(): target_dir = 'tmp' @@ -7081,7 +7081,7 @@ def tiff_write_153(): # Test empty block writing skipping and SPARSE_OK in CreateCopy() and Open() -def tiff_write_154(): +def test_tiff_write_154(): import struct @@ -7230,7 +7230,7 @@ def tiff_write_154(): # Test reading and writing band description -def tiff_write_155(): +def test_tiff_write_155(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_155.tif', 1, 1) ds.GetRasterBand(1).SetDescription('foo') @@ -7268,7 +7268,7 @@ def tiff_write_155(): # Test GetDataCoverageStatus() -def tiff_write_156(): +def test_tiff_write_156(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_156.tif', 64, 64, options=['SPARSE_OK=YES', 'TILED=YES', 'BLOCKXSIZE=32', 'BLOCKYSIZE=32']) ds.GetRasterBand(1).WriteRaster(0, 0, 1, 1, 'X') @@ -7316,7 +7316,7 @@ def tiff_write_156(): # Test Float16 -def tiff_write_157(): +def test_tiff_write_157(): import struct @@ -7464,7 +7464,7 @@ def tiff_write_157(): # Test GetActualBlockSize() (perhaps not the best place for that...) -def tiff_write_158(): +def test_tiff_write_158(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_158.tif', 20, 40, 1, options=['TILED=YES', 'BLOCKXSIZE=16', 'BLOCKYSIZE=32']) (w, h) = ds.GetRasterBand(1).GetActualBlockSize(0, 0) @@ -7504,7 +7504,7 @@ def tiff_write_158(): # result in a https://trac.osgeo.org/gdal/wiki/CloudOptimizedGeoTIFF -def tiff_write_159(): +def test_tiff_write_159(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('JPEG') == -1: @@ -7589,7 +7589,7 @@ def tiff_write_159(): ############################################################################### # Test the Create() interface with a BLOCKYSIZE > image height -def tiff_write_160(): +def test_tiff_write_160(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_160.tif', 10, 10, options=['BLOCKYSIZE=11']) ds.GetRasterBand(1).Fill(255) @@ -7611,7 +7611,7 @@ def tiff_write_160(): # Test setting GCPs on an image with already a geotransform and vice-versa (#6751) -def tiff_write_161(): +def test_tiff_write_161(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_161.tif', 1, 1) ds.SetGeoTransform([0, 1, 2, 3, 4, 5]) @@ -7664,7 +7664,7 @@ def tiff_write_161(): # Test creating a JPEG compressed file with big tiles (#6757) -def tiff_write_162(): +def test_tiff_write_162(): src_ds = gdal.GetDriverByName('MEM').Create('', 512, 512, 3) @@ -7684,7 +7684,7 @@ def tiff_write_162(): # Test creating a file that would trigger strip chopping (#6924) -def tiff_write_163(): +def test_tiff_write_163(): # Was a libtiff 4.0.8 regression if gdaltest.tiff_drv.GetMetadataItem('LIBTIFF').find('4.0.8') >= 0: @@ -7715,7 +7715,7 @@ def tiff_write_163(): # Test that we handle [0,1,0,0,0,1] geotransform as a regular geotransform -def tiff_write_164(): +def test_tiff_write_164(): ds = gdaltest.tiff_drv.Create('/vsimem/test.tif', 1, 1) ds.SetGeoTransform([0, 1, 0, 0, 0, 1]) @@ -7752,7 +7752,7 @@ def tiff_write_164(): # Test the current behaviour of per-band nodata vs per-dataset serialization -def tiff_write_165(): +def test_tiff_write_165(): ds = gdaltest.tiff_drv.Create('/vsimem/test.tif', 1, 1, 3) ret = ds.GetRasterBand(1).SetNoDataValue(100) @@ -7800,7 +7800,7 @@ def tiff_write_165(): # Test reading & writing Z dimension for ModelTiepointTag and ModelPixelScaleTag (#7093) -def tiff_write_166(): +def test_tiff_write_166(): ds = gdal.Open('data/tiff_vertcs_scale_offset.tif') if ds.GetRasterBand(1).GetScale() != 2.0: @@ -7931,7 +7931,7 @@ def tiff_write_166(): ############################################################################### -def tiff_write_167_deflate_zlevel(): +def test_tiff_write_167_deflate_zlevel(): src_ds = gdal.Open('data/byte.tif') gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/out.tif', src_ds, @@ -7973,7 +7973,7 @@ def tiff_write_167_deflate_zlevel(): # Test CCITTFAX3 -def tiff_write_168_ccitfax3(): +def test_tiff_write_168_ccitfax3(): ut = gdaltest.GDALTest('GTiff', 'oddsize1bit.tif', 1, 5918, options=['NBITS=1', 'COMPRESS=CCITTFAX3']) @@ -7983,7 +7983,7 @@ def tiff_write_168_ccitfax3(): # Test CCITTRLE -def tiff_write_169_ccitrle(): +def test_tiff_write_169_ccitrle(): ut = gdaltest.GDALTest('GTiff', 'oddsize1bit.tif', 1, 5918, options=['NBITS=1', 'COMPRESS=CCITTRLE']) @@ -7993,7 +7993,7 @@ def tiff_write_169_ccitrle(): # Test invalid compression method -def tiff_write_170_invalid_compresion(): +def test_tiff_write_170_invalid_compresion(): src_ds = gdal.Open('data/byte.tif') with gdaltest.error_handler(): @@ -8008,7 +8008,7 @@ def tiff_write_170_invalid_compresion(): # Test ZSTD compression -def tiff_write_171_zstd(): +def test_tiff_write_171_zstd(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('ZSTD') == -1: @@ -8022,7 +8022,7 @@ def tiff_write_171_zstd(): # Test ZSTD compression with PREDICTOR = 2 -def tiff_write_171_zstd_predictor(): +def test_tiff_write_171_zstd_predictor(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('ZSTD') == -1: @@ -8036,7 +8036,7 @@ def tiff_write_171_zstd_predictor(): # Test WEBP compression -def tiff_write_webp(): +def test_tiff_write_webp(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('WEBP') == -1: @@ -8050,7 +8050,7 @@ def tiff_write_webp(): # Test WEBP compression with internal tiling -def tiff_write_tiled_webp(): +def test_tiff_write_tiled_webp(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('WEBP') == -1: @@ -8081,7 +8081,7 @@ def tiff_write_tiled_webp(): # Test WEBP compression with huge single strip -def tiff_write_webp_huge_single_strip(): +def test_tiff_write_webp_huge_single_strip(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('WEBP') == -1: @@ -8117,7 +8117,7 @@ def tiff_write_webp_huge_single_strip(): # GeoTIFF DGIWG tags -def tiff_write_172_geometadata_tiff_rsid(): +def test_tiff_write_172_geometadata_tiff_rsid(): tmpfilename = '/vsimem/tiff_write_172_geometadata_tiff_rsid.tiff' ds = gdal.GetDriverByName('GTiff').Create(tmpfilename, 1, 1) @@ -8155,7 +8155,7 @@ def tiff_write_172_geometadata_tiff_rsid(): # Test LERC compression -def tiff_write_173_lerc(): +def test_tiff_write_173_lerc(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8169,7 +8169,7 @@ def tiff_write_173_lerc(): # Test LERC_DEFLATE compression -def tiff_write_174_lerc_deflate(): +def test_tiff_write_174_lerc_deflate(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC_DEFLATE') == -1: @@ -8183,7 +8183,7 @@ def tiff_write_174_lerc_deflate(): # Test LERC_DEFLATE compression -def tiff_write_174_lerc_deflate_with_level(): +def test_tiff_write_174_lerc_deflate_with_level(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC_DEFLATE') == -1: @@ -8197,7 +8197,7 @@ def tiff_write_174_lerc_deflate_with_level(): # Test LERC_ZSTD compression -def tiff_write_175_lerc_zstd(): +def test_tiff_write_175_lerc_zstd(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC_ZSTD') == -1: @@ -8211,7 +8211,7 @@ def tiff_write_175_lerc_zstd(): # Test LERC_ZSTD compression -def tiff_write_175_lerc_zstd_with_level(): +def test_tiff_write_175_lerc_zstd_with_level(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC_ZSTD') == -1: @@ -8225,7 +8225,7 @@ def tiff_write_175_lerc_zstd_with_level(): # Test LERC compression with MAX_Z_ERROR -def tiff_write_176_lerc_max_z_error(): +def test_tiff_write_176_lerc_max_z_error(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8239,7 +8239,7 @@ def tiff_write_176_lerc_max_z_error(): # Test LERC compression with several bands and tiling -def tiff_write_177_lerc_several_bands_tiling(): +def test_tiff_write_177_lerc_several_bands_tiling(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8263,7 +8263,7 @@ def tiff_write_177_lerc_several_bands_tiling(): # Test LERC compression with alpha band -def tiff_write_178_lerc_with_alpha(): +def test_tiff_write_178_lerc_with_alpha(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8287,7 +8287,7 @@ def tiff_write_178_lerc_with_alpha(): # Test LERC compression with alpha band with only 0 and 255 -def tiff_write_178_lerc_with_alpha_0_and_255(): +def test_tiff_write_178_lerc_with_alpha_0_and_255(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8311,7 +8311,7 @@ def tiff_write_178_lerc_with_alpha_0_and_255(): # Test LERC compression with different data types -def tiff_write_179_lerc_data_types(): +def test_tiff_write_179_lerc_data_types(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8359,7 +8359,7 @@ def tiff_write_179_lerc_data_types(): # Test LERC compression with several bands and separate -def tiff_write_180_lerc_separate(): +def test_tiff_write_180_lerc_separate(): md = gdaltest.tiff_drv.GetMetadata() if md['DMD_CREATIONOPTIONLIST'].find('LERC') == -1: @@ -8383,7 +8383,7 @@ def tiff_write_180_lerc_separate(): # Test set XMP metadata -def tiff_write_181_xmp(): +def test_tiff_write_181_xmp(): src_ds = gdal.Open('data/utmsmall.tif') @@ -8417,7 +8417,7 @@ def tiff_write_181_xmp(): # Test delete XMP from a dataset -def tiff_write_182_xmp_delete(): +def test_tiff_write_182_xmp_delete(): shutil.copyfile('../gdrivers/data/byte_with_xmp.tif', 'tmp/test_182.tif') @@ -8460,212 +8460,212 @@ def tiff_write_api_proxy(): ############################################################################### -def tiff_write_cleanup(): +def test_tiff_write_cleanup(): gdaltest.tiff_drv = None return 'success' gdaltest_list = [ - tiff_write_1, - tiff_write_2, - tiff_write_3, - tiff_write_4, - tiff_write_5, - tiff_write_6, - tiff_write_7, - tiff_write_8, - tiff_write_9, - tiff_write_10, - tiff_write_11, - tiff_write_12, - tiff_write_13, - tiff_write_14, - tiff_write_15, - tiff_write_16, - tiff_write_17, - tiff_write_17_disable_readdir, - tiff_write_18, - tiff_write_18_disable_readdir, - tiff_write_rpc_txt, - tiff_write_rpc_in_pam, - tiff_write_19, - tiff_write_20, - tiff_write_21, - tiff_write_22, - tiff_write_23, - tiff_write_24, - tiff_write_25, - tiff_write_26, - tiff_write_27, - tiff_write_28, - tiff_write_29, - tiff_write_30, - tiff_write_31, - tiff_write_32, - tiff_write_33, - tiff_write_34, - tiff_write_35, - tiff_write_36, - tiff_write_37, - tiff_write_38, - tiff_write_39, - tiff_write_40, - tiff_write_41, - tiff_write_42, - tiff_write_43, - tiff_write_44, - tiff_write_45, - tiff_write_46, - tiff_write_47, - tiff_write_48, - tiff_write_49, - tiff_write_50, - tiff_write_51, - tiff_write_52, - tiff_write_53, - tiff_write_53_bis, - tiff_write_54, - tiff_write_55, - tiff_write_56, - tiff_write_57, - tiff_write_58, - tiff_write_59, - tiff_write_60, - tiff_write_61, - tiff_write_62, - tiff_write_63, - tiff_write_64, - tiff_write_65, - tiff_write_66, - tiff_write_67, - tiff_write_68, - tiff_write_69, - tiff_write_70, - tiff_write_71, - tiff_write_72, - tiff_write_73, - tiff_write_74, - tiff_write_75, - tiff_write_76, - tiff_write_77, - tiff_write_78, - tiff_write_79, - tiff_write_80, - tiff_write_81, - tiff_write_82, - tiff_write_83, - tiff_write_84, - tiff_write_85, - tiff_write_86, - tiff_write_87, - tiff_write_88, - tiff_write_89, # leaks mem - tiff_write_90, # leaks mem - tiff_write_91, # leaks mem - tiff_write_92, # leaks mem - tiff_write_93, # leaks mem - tiff_write_94, # leaks mem - tiff_write_95, - tiff_write_96, # leaks mem - tiff_write_97, - tiff_write_98, - tiff_write_99, - tiff_write_100, - tiff_write_101, - tiff_write_102, - tiff_write_103, - tiff_write_104, - tiff_write_105, - tiff_write_106, - tiff_write_107, - tiff_write_108, - tiff_write_109, - tiff_write_110, - tiff_write_111, - tiff_write_111_bis, - tiff_write_111_ter, - tiff_write_112, - tiff_write_113, - tiff_write_114, - tiff_write_115, - tiff_write_116, - tiff_write_117, - tiff_write_118, - tiff_write_119, - tiff_write_120, - tiff_write_121, - tiff_write_122, - tiff_write_123, - tiff_write_124, - tiff_write_125, - tiff_write_126, - tiff_write_127, - tiff_write_128, - tiff_write_129, - tiff_write_130, - tiff_write_131, - tiff_write_131_level_9, - tiff_write_132, - tiff_write_133, - tiff_write_134, - tiff_write_135, - tiff_write_136, - tiff_write_137, - tiff_write_138, - tiff_write_139, - tiff_write_140, - tiff_write_141, - tiff_write_142, - tiff_write_143, - tiff_write_144, - tiff_write_145, - tiff_write_146, - tiff_write_147, - tiff_write_148, - tiff_write_149, - tiff_write_150, - tiff_write_151, - tiff_write_152, - tiff_write_153, - tiff_write_154, - tiff_write_155, - tiff_write_156, - tiff_write_157, - tiff_write_158, - tiff_write_159, - tiff_write_160, - tiff_write_161, - tiff_write_162, - tiff_write_163, - tiff_write_164, - tiff_write_165, - tiff_write_166, - tiff_write_167_deflate_zlevel, - tiff_write_168_ccitfax3, - tiff_write_169_ccitrle, - tiff_write_170_invalid_compresion, - tiff_write_171_zstd, - tiff_write_171_zstd_predictor, - tiff_write_172_geometadata_tiff_rsid, - tiff_write_173_lerc, - tiff_write_174_lerc_deflate, - tiff_write_174_lerc_deflate_with_level, - tiff_write_175_lerc_zstd, - tiff_write_175_lerc_zstd_with_level, - tiff_write_176_lerc_max_z_error, - tiff_write_177_lerc_several_bands_tiling, - tiff_write_178_lerc_with_alpha, - tiff_write_178_lerc_with_alpha_0_and_255, - tiff_write_179_lerc_data_types, - tiff_write_180_lerc_separate, - tiff_write_181_xmp, - tiff_write_182_xmp_delete, + test_tiff_write_1, + test_tiff_write_2, + test_tiff_write_3, + test_tiff_write_4, + test_tiff_write_5, + test_tiff_write_6, + test_tiff_write_7, + test_tiff_write_8, + test_tiff_write_9, + test_tiff_write_10, + test_tiff_write_11, + test_tiff_write_12, + test_tiff_write_13, + test_tiff_write_14, + test_tiff_write_15, + test_tiff_write_16, + test_tiff_write_17, + test_tiff_write_17_disable_readdir, + test_tiff_write_18, + test_tiff_write_18_disable_readdir, + test_tiff_write_rpc_txt, + test_tiff_write_rpc_in_pam, + test_tiff_write_19, + test_tiff_write_20, + test_tiff_write_21, + test_tiff_write_22, + test_tiff_write_23, + test_tiff_write_24, + test_tiff_write_25, + test_tiff_write_26, + test_tiff_write_27, + test_tiff_write_28, + test_tiff_write_29, + test_tiff_write_30, + test_tiff_write_31, + test_tiff_write_32, + test_tiff_write_33, + test_tiff_write_34, + test_tiff_write_35, + test_tiff_write_36, + test_tiff_write_37, + test_tiff_write_38, + test_tiff_write_39, + test_tiff_write_40, + test_tiff_write_41, + test_tiff_write_42, + test_tiff_write_43, + test_tiff_write_44, + test_tiff_write_45, + test_tiff_write_46, + test_tiff_write_47, + test_tiff_write_48, + test_tiff_write_49, + test_tiff_write_50, + test_tiff_write_51, + test_tiff_write_52, + test_tiff_write_53, + test_tiff_write_53_bis, + test_tiff_write_54, + test_tiff_write_55, + test_tiff_write_56, + test_tiff_write_57, + test_tiff_write_58, + test_tiff_write_59, + test_tiff_write_60, + test_tiff_write_61, + test_tiff_write_62, + test_tiff_write_63, + test_tiff_write_64, + test_tiff_write_65, + test_tiff_write_66, + test_tiff_write_67, + test_tiff_write_68, + test_tiff_write_69, + test_tiff_write_70, + test_tiff_write_71, + test_tiff_write_72, + test_tiff_write_73, + test_tiff_write_74, + test_tiff_write_75, + test_tiff_write_76, + test_tiff_write_77, + test_tiff_write_78, + test_tiff_write_79, + test_tiff_write_80, + test_tiff_write_81, + test_tiff_write_82, + test_tiff_write_83, + test_tiff_write_84, + test_tiff_write_85, + test_tiff_write_86, + test_tiff_write_87, + test_tiff_write_88, + test_tiff_write_89, # leaks mem + test_tiff_write_90, # leaks mem + test_tiff_write_91, # leaks mem + test_tiff_write_92, # leaks mem + test_tiff_write_93, # leaks mem + test_tiff_write_94, # leaks mem + test_tiff_write_95, + test_tiff_write_96, # leaks mem + test_tiff_write_97, + test_tiff_write_98, + test_tiff_write_99, + test_tiff_write_100, + test_tiff_write_101, + test_tiff_write_102, + test_tiff_write_103, + test_tiff_write_104, + test_tiff_write_105, + test_tiff_write_106, + test_tiff_write_107, + test_tiff_write_108, + test_tiff_write_109, + test_tiff_write_110, + test_tiff_write_111, + test_tiff_write_111_bis, + test_tiff_write_111_ter, + test_tiff_write_112, + test_tiff_write_113, + test_tiff_write_114, + test_tiff_write_115, + test_tiff_write_116, + test_tiff_write_117, + test_tiff_write_118, + test_tiff_write_119, + test_tiff_write_120, + test_tiff_write_121, + test_tiff_write_122, + test_tiff_write_123, + test_tiff_write_124, + test_tiff_write_125, + test_tiff_write_126, + test_tiff_write_127, + test_tiff_write_128, + test_tiff_write_129, + test_tiff_write_130, + test_tiff_write_131, + test_tiff_write_131_level_9, + test_tiff_write_132, + test_tiff_write_133, + test_tiff_write_134, + test_tiff_write_135, + test_tiff_write_136, + test_tiff_write_137, + test_tiff_write_138, + test_tiff_write_139, + test_tiff_write_140, + test_tiff_write_141, + test_tiff_write_142, + test_tiff_write_143, + test_tiff_write_144, + test_tiff_write_145, + test_tiff_write_146, + test_tiff_write_147, + test_tiff_write_148, + test_tiff_write_149, + test_tiff_write_150, + test_tiff_write_151, + test_tiff_write_152, + test_tiff_write_153, + test_tiff_write_154, + test_tiff_write_155, + test_tiff_write_156, + test_tiff_write_157, + test_tiff_write_158, + test_tiff_write_159, + test_tiff_write_160, + test_tiff_write_161, + test_tiff_write_162, + test_tiff_write_163, + test_tiff_write_164, + test_tiff_write_165, + test_tiff_write_166, + test_tiff_write_167_deflate_zlevel, + test_tiff_write_168_ccitfax3, + test_tiff_write_169_ccitrle, + test_tiff_write_170_invalid_compresion, + test_tiff_write_171_zstd, + test_tiff_write_171_zstd_predictor, + test_tiff_write_172_geometadata_tiff_rsid, + test_tiff_write_173_lerc, + test_tiff_write_174_lerc_deflate, + test_tiff_write_174_lerc_deflate_with_level, + test_tiff_write_175_lerc_zstd, + test_tiff_write_175_lerc_zstd_with_level, + test_tiff_write_176_lerc_max_z_error, + test_tiff_write_177_lerc_several_bands_tiling, + test_tiff_write_178_lerc_with_alpha, + test_tiff_write_178_lerc_with_alpha_0_and_255, + test_tiff_write_179_lerc_data_types, + test_tiff_write_180_lerc_separate, + test_tiff_write_181_xmp, + test_tiff_write_182_xmp_delete, # tiff_write_api_proxy, - tiff_write_webp, - tiff_write_tiled_webp, - tiff_write_webp_huge_single_strip, - tiff_write_cleanup] + test_tiff_write_webp, + test_tiff_write_tiled_webp, + test_tiff_write_webp_huge_single_strip, + test_tiff_write_cleanup] # gdaltest_list = [ tiff_write_1, tiff_write_176_lerc_max_z_error ] diff --git a/autotest/gcore/transformer.py b/autotest/gcore/transformer.py index 119da9099ef9..32ec5d22bb1a 100755 --- a/autotest/gcore/transformer.py +++ b/autotest/gcore/transformer.py @@ -41,7 +41,7 @@ # Test simple Geotransform based transformer. -def transformer_1(): +def test_transformer_1(): ds = gdal.Open('data/byte.tif') tr = gdal.Transformer(ds, None, []) @@ -72,7 +72,7 @@ def transformer_1(): # Test GCP based transformer with polynomials. -def transformer_2(): +def test_transformer_2(): ds = gdal.Open('data/gcps.vrt') tr = gdal.Transformer(ds, None, ['METHOD=GCP_POLYNOMIAL']) @@ -103,7 +103,7 @@ def transformer_2(): # Test GCP based transformer with thin plate splines. -def transformer_3(): +def test_transformer_3(): ds = gdal.Open('data/gcps.vrt') tr = gdal.Transformer(ds, None, ['METHOD=GCP_TPS']) @@ -134,7 +134,7 @@ def transformer_3(): # Test geolocation based transformer. -def transformer_4(): +def test_transformer_4(): ds = gdal.Open('data/sstgeo.vrt') tr = gdal.Transformer(ds, None, ['METHOD=GEOLOC_ARRAY']) @@ -165,7 +165,7 @@ def transformer_4(): # Test RPC based transformer. -def transformer_5(): +def test_transformer_5(): ds = gdal.Open('data/rpc.vrt') tr = gdal.Transformer(ds, None, ['METHOD=RPC', 'RPC_PIXEL_ERROR_THRESHOLD=0.05']) @@ -363,7 +363,7 @@ def transformer_5(): ############################################################################### # Test RPC convergence bug (bug # 5395) -def transformer_6(): +def test_transformer_6(): ds = gdal.Open('data/rpc_5395.vrt') tr = gdal.Transformer(ds, None, ['METHOD=RPC']) @@ -384,7 +384,7 @@ def transformer_6(): # Test Transformer.TransformPoints -def transformer_7(): +def test_transformer_7(): ds = gdal.Open('data/byte.tif') tr = gdal.Transformer(ds, None, []) @@ -405,7 +405,7 @@ def transformer_7(): # Test handling of nodata in RPC DEM (#5680) -def transformer_8(): +def test_transformer_8(): ds = gdal.Open('data/rpc.vrt') @@ -444,7 +444,7 @@ def transformer_8(): # Test RPC DEM line optimization -def transformer_9(): +def test_transformer_9(): ds = gdal.Open('data/rpc.vrt') @@ -492,7 +492,7 @@ def transformer_9(): # Test RPC DEM transform from geoid height to ellipsoidal height -def transformer_10(): +def test_transformer_10(): # Create fake vertical shift grid out_ds = gdal.GetDriverByName('GTX').Create('tmp/fake.gtx', 10, 10, 1, gdal.GDT_Float32) @@ -580,7 +580,7 @@ def transformer_10(): # Test failed inverse RPC transform (#6162) -def transformer_11(): +def test_transformer_11(): ds = gdal.GetDriverByName('MEM').Create('', 6600, 4400) rpc = [ @@ -620,7 +620,7 @@ def transformer_11(): # Test degenerate cases of TPS transformer -def transformer_12(): +def test_transformer_12(): ds = gdal.Open(""" @@ -698,7 +698,7 @@ def transformer_12(): # Test inverse RPC transform at DEM edge (#6377) -def transformer_13(): +def test_transformer_13(): ds = gdal.GetDriverByName('MEM').Create('', 6600, 4400) rpc = [ @@ -731,7 +731,7 @@ def transformer_13(): # Test inverse RPC transform when iterations do oscillations (#6377) -def transformer_14(): +def test_transformer_14(): ds = gdal.GetDriverByName('MEM').Create('', 4032, 2688) rpc = ["MIN_LAT=0", "MAX_LAT=0", @@ -796,7 +796,7 @@ def transformer_14(): # beyond -def transformer_15(): +def test_transformer_15(): ds = gdal.GetDriverByName('MEM').Create('', 6600, 4400) rpc = [ @@ -893,7 +893,7 @@ def transformer_15(): # (we mostly test that the parameters are well recognized and serialized) -def transformer_16(): +def test_transformer_16(): gdal.Translate('/vsimem/transformer_16.tif', 'data/byte.tif', options="-gcp 0 0 440720.000 3751320.000 -gcp 0 20 440720.000 3750120.000 -gcp 20 0 441920.000 3751320.000 -gcp 20 20 441920.000 3750120.000 -a_srs EPSG:26711") gdal.Warp('/vsimem/transformer_16.vrt', '/vsimem/transformer_16.tif', options='-of VRT -t_srs EPSG:4326 -et 0 -to SRC_APPROX_ERROR_IN_SRS_UNIT=6.05 -to SRC_APPROX_ERROR_IN_PIXEL=0.1 -to REPROJECTION_APPROX_ERROR_IN_SRC_SRS_UNIT=6.1 -to REPROJECTION_APPROX_ERROR_IN_DST_SRS_UNIT=0.0001') @@ -923,7 +923,7 @@ def transformer_16(): ############################################################################### # Test RPC DEM with unexisting RPC DEM file -def transformer_17(): +def test_transformer_17(): ds = gdal.Open('data/rpc.vrt') with gdaltest.error_handler(): @@ -934,27 +934,27 @@ def transformer_17(): gdaltest_list = [ - transformer_1, - transformer_2, - transformer_3, - transformer_4, - transformer_5, - transformer_6, - transformer_7, - transformer_8, - transformer_9, - transformer_10, - transformer_11, - transformer_12, - transformer_13, - transformer_14, - transformer_15, - transformer_16, - transformer_17 + test_transformer_1, + test_transformer_2, + test_transformer_3, + test_transformer_4, + test_transformer_5, + test_transformer_6, + test_transformer_7, + test_transformer_8, + test_transformer_9, + test_transformer_10, + test_transformer_11, + test_transformer_12, + test_transformer_13, + test_transformer_14, + test_transformer_15, + test_transformer_16, + test_transformer_17 ] disabled_gdaltest_list = [ - transformer_11 + test_transformer_11 ] diff --git a/autotest/gcore/virtualmem.py b/autotest/gcore/virtualmem.py index c2e13340fa01..b284d54aaa97 100755 --- a/autotest/gcore/virtualmem.py +++ b/autotest/gcore/virtualmem.py @@ -39,7 +39,7 @@ # Test linear and tiled virtual mem interfaces in read-only mode -def virtualmem_1(): +def test_virtualmem_1(): if gdal.GetConfigOption('SKIP_VIRTUALMEM'): return 'skip' @@ -127,7 +127,7 @@ def virtualmem_1(): # Test write mode -def virtualmem_2(): +def test_virtualmem_2(): if gdal.GetConfigOption('SKIP_VIRTUALMEM'): return 'skip' @@ -159,7 +159,7 @@ def virtualmem_2(): # Test virtual mem auto with a raw driver -def virtualmem_3(): +def test_virtualmem_3(): if gdal.GetConfigOption('SKIP_VIRTUALMEM'): return 'skip' @@ -210,7 +210,7 @@ def virtualmem_3(): # Test virtual mem auto with GTiff -def virtualmem_4(): +def test_virtualmem_4(): if gdal.GetConfigOption('SKIP_VIRTUALMEM'): return 'skip' @@ -280,10 +280,10 @@ def virtualmem_4(): return 'success' -gdaltest_list = [virtualmem_1, - virtualmem_2, - virtualmem_3, - virtualmem_4] +gdaltest_list = [test_virtualmem_1, + test_virtualmem_2, + test_virtualmem_3, + test_virtualmem_4] if __name__ == '__main__': diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index 53b0cbc0b76f..dd03513e2b3b 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -81,7 +81,7 @@ def test_vrt_open(filename, checksum): # The VRT references a non existing TIF file -def vrt_read_1(): +def test_vrt_read_1(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('data/idontexist.vrt') @@ -96,7 +96,7 @@ def vrt_read_1(): # The VRT references a non existing TIF file, but using the proxy pool dataset API (#2837) -def vrt_read_2(): +def test_vrt_read_2(): ds = gdal.Open('data/idontexist2.vrt') if ds is None: @@ -120,7 +120,7 @@ def vrt_read_2(): # Test init of band data in case of cascaded VRT (ticket #2867) -def vrt_read_3(): +def test_vrt_read_3(): driver_tif = gdal.GetDriverByName("GTIFF") @@ -152,7 +152,7 @@ def vrt_read_3(): ############################################################################### # Test complex source with complex data (#3977) -def vrt_read_4(): +def test_vrt_read_4(): try: import numpy as np @@ -196,7 +196,7 @@ def vrt_read_4(): # Test serializing and deserializing of various band metadata -def vrt_read_5(): +def test_vrt_read_5(): src_ds = gdal.Open('data/testserialization.asc') ds = gdal.GetDriverByName('VRT').CreateCopy('/vsimem/vrt_read_5.vrt', src_ds) @@ -278,7 +278,7 @@ def vrt_read_5(): # Test GetMinimum() and GetMaximum() -def vrt_read_6(): +def test_vrt_read_6(): gdal.Unlink('data/byte.tif.aux.xml') src_ds = gdal.Open('data/byte.tif') @@ -318,7 +318,7 @@ def vrt_read_6(): # Test GDALOpen() anti-recursion mechanism -def vrt_read_7(): +def test_vrt_read_7(): filename = "/vsimem/vrt_read_7.vrt" @@ -354,7 +354,7 @@ def vrt_read_7(): # Test ComputeRasterMinMax() -def vrt_read_8(): +def test_vrt_read_8(): src_ds = gdal.Open('data/byte.tif') mem_ds = gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/vrt_read_8.tif', src_ds) @@ -380,7 +380,7 @@ def vrt_read_8(): # Test ComputeStatistics() -def vrt_read_9(): +def test_vrt_read_9(): src_ds = gdal.Open('data/byte.tif') mem_ds = gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/vrt_read_9.tif', src_ds) @@ -406,7 +406,7 @@ def vrt_read_9(): # Test GetHistogram() & GetDefaultHistogram() -def vrt_read_10(): +def test_vrt_read_10(): src_ds = gdal.Open('data/byte.tif') mem_ds = gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/vrt_read_10.tif', src_ds) @@ -499,7 +499,7 @@ def vrt_read_10(): # Test resolving files from a symlinked vrt using relativeToVRT with an absolute symlink -def vrt_read_11(): +def test_vrt_read_11(): if not gdaltest.support_symlink(): return 'skip' @@ -526,7 +526,7 @@ def vrt_read_11(): # with a relative symlink pointing to a relative symlink -def vrt_read_12(): +def test_vrt_read_12(): if not gdaltest.support_symlink(): return 'skip' @@ -552,7 +552,7 @@ def vrt_read_12(): # Test resolving files from a symlinked vrt using relativeToVRT with a relative symlink -def vrt_read_13(): +def test_vrt_read_13(): if not gdaltest.support_symlink(): return 'skip' @@ -585,7 +585,7 @@ def vrt_read_13(): # Test ComputeStatistics() when the VRT is a subwindow of the source dataset (#5468) -def vrt_read_14(): +def test_vrt_read_14(): src_ds = gdal.Open('data/byte.tif') mem_ds = gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/vrt_read_14.tif', src_ds) @@ -620,7 +620,7 @@ def vrt_read_14(): # Test RasterIO() with resampling on SimpleSource -def vrt_read_15(): +def test_vrt_read_15(): vrt_ds = gdal.Open(""" @@ -652,7 +652,7 @@ def vrt_read_15(): # Test RasterIO() with resampling on ComplexSource -def vrt_read_16(): +def test_vrt_read_16(): vrt_ds = gdal.Open(""" @@ -684,7 +684,7 @@ def vrt_read_16(): # Test RasterIO() with resampling on AveragedSource -def vrt_read_17(): +def test_vrt_read_17(): vrt_ds = gdal.Open(""" @@ -711,7 +711,7 @@ def vrt_read_17(): # Test that relative path is correctly VRT-in-VRT -def vrt_read_18(): +def test_vrt_read_18(): vrt_ds = gdal.Open('data/vrtinvrt.vrt') cs = vrt_ds.GetRasterBand(1).Checksum() @@ -725,7 +725,7 @@ def vrt_read_18(): # Test shared="0" -def vrt_read_19(): +def test_vrt_read_19(): vrt_ds = gdal.Open(""" @@ -762,7 +762,7 @@ def vrt_read_19(): ############################################################################### # Test 2 level of VRT with shared="0" -def vrt_read_20(): +def test_vrt_read_20(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' @@ -820,7 +820,7 @@ def vrt_read_20(): # Test implicit virtual overviews -def vrt_read_21(): +def test_vrt_read_21(): ds = gdal.Open('data/byte.tif') data = ds.ReadRaster(0, 0, 20, 20, 400, 400) @@ -940,7 +940,7 @@ def vrt_read_21(): # Test that we honour NBITS with SimpleSource and ComplexSource -def vrt_read_22(): +def test_vrt_read_22(): ds = gdal.Open('data/byte.tif') data = ds.ReadRaster() @@ -1052,7 +1052,7 @@ def vrt_read_22(): # an underlying dataset without nodata -def vrt_read_23(): +def test_vrt_read_23(): try: from osgeo import gdalnumeric @@ -1115,7 +1115,7 @@ def vrt_read_23(): # Test floating point rounding issues when the VRT does a zoom-in -def vrt_read_24(): +def test_vrt_read_24(): ds = gdal.Open('data/zoom_in.vrt') data = ds.ReadRaster(34, 5, 66, 87) @@ -1140,7 +1140,7 @@ def vrt_read_24(): # Test GetDataCoverageStatus() -def vrt_read_25(): +def test_vrt_read_25(): import ogrtest if not ogrtest.have_geos(): @@ -1204,7 +1204,7 @@ def vrt_read_25(): # Test consistency of RasterIO() with resampling, that is extracting different # sub-windows give consistent results -def vrt_read_26(): +def test_vrt_read_26(): vrt_ds = gdal.Open(""" @@ -1237,7 +1237,7 @@ def vrt_read_26(): # Test fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1553 -def vrt_read_27(): +def test_vrt_read_27(): gdal.Open('data/empty_gcplist.vrt') @@ -1247,7 +1247,7 @@ def vrt_read_27(): # Test fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1551 -def vrt_read_28(): +def test_vrt_read_28(): with gdaltest.error_handler(): ds = gdal.Open('') @@ -1260,7 +1260,7 @@ def vrt_read_28(): ############################################################################### # Check VRT source sharing and non-sharing situations (#6949) -def vrt_read_29(): +def test_vrt_read_29(): f = open('data/byte.tif') lst_before = gdaltest.get_opened_files() @@ -1337,7 +1337,7 @@ def vrt_read_29(): # Check VRT reading with DatasetRasterIO -def vrt_read_30(): +def test_vrt_read_30(): ds = gdal.Open(""" @@ -1362,7 +1362,7 @@ def vrt_read_30(): # Check that we take into account intermediate data type demotion -def vrt_read_31(): +def test_vrt_read_31(): gdal.FileFromMemBuffer('/vsimem/in.asc', """ncols 2 @@ -1401,7 +1401,7 @@ def vrt_read_31(): # Test reading a VRT where the NODATA & NoDataValue are slighly below the # minimum float value (https://github.com/OSGeo/gdal/issues/1071) -def vrt_float32_with_nodata_slightly_below_float_min(): +def test_vrt_float32_with_nodata_slightly_below_float_min(): shutil.copyfile('data/minfloat.tif', 'tmp/minfloat.tif') shutil.copyfile('data/minfloat_nodata_slightly_out_of_float.vrt', @@ -1440,7 +1440,7 @@ def vrt_float32_with_nodata_slightly_below_float_min(): ############################################################################### # Fix issue raised in https://lists.osgeo.org/pipermail/gdal-dev/2018-December/049415.html -def vrt_subpixel_offset(): +def test_vrt_subpixel_offset(): ds = gdal.Open('data/vrt_subpixel_offset.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -1456,7 +1456,7 @@ def vrt_subpixel_offset(): # Check bug fix of bug fix of # https://lists.osgeo.org/pipermail/gdal-dev/2018-December/049415.html -def vrt_dstsize_larger_than_source(): +def test_vrt_dstsize_larger_than_source(): ds = gdal.Open('data/dstsize_larger_than_source.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -1469,40 +1469,40 @@ def vrt_dstsize_larger_than_source(): gdaltest_list = [ - vrt_read_1, - vrt_read_2, - vrt_read_3, - vrt_read_4, - vrt_read_5, - vrt_read_6, - vrt_read_7, - vrt_read_8, - vrt_read_9, - vrt_read_10, - vrt_read_11, - vrt_read_12, - vrt_read_13, - vrt_read_14, - vrt_read_15, - vrt_read_16, - vrt_read_17, - vrt_read_18, - vrt_read_19, - vrt_read_20, - vrt_read_21, - vrt_read_22, - vrt_read_23, - vrt_read_24, - vrt_read_25, - vrt_read_26, - vrt_read_27, - vrt_read_28, - vrt_read_29, - vrt_read_30, - vrt_read_31, - vrt_float32_with_nodata_slightly_below_float_min, - vrt_subpixel_offset, - vrt_dstsize_larger_than_source, + test_vrt_read_1, + test_vrt_read_2, + test_vrt_read_3, + test_vrt_read_4, + test_vrt_read_5, + test_vrt_read_6, + test_vrt_read_7, + test_vrt_read_8, + test_vrt_read_9, + test_vrt_read_10, + test_vrt_read_11, + test_vrt_read_12, + test_vrt_read_13, + test_vrt_read_14, + test_vrt_read_15, + test_vrt_read_16, + test_vrt_read_17, + test_vrt_read_18, + test_vrt_read_19, + test_vrt_read_20, + test_vrt_read_21, + test_vrt_read_22, + test_vrt_read_23, + test_vrt_read_24, + test_vrt_read_25, + test_vrt_read_26, + test_vrt_read_27, + test_vrt_read_28, + test_vrt_read_29, + test_vrt_read_30, + test_vrt_read_31, + test_vrt_float32_with_nodata_slightly_below_float_min, + test_vrt_subpixel_offset, + test_vrt_dstsize_larger_than_source, ] diff --git a/autotest/gcore/vrtmisc.py b/autotest/gcore/vrtmisc.py index 8ec5cdf31d85..84d2482f816b 100755 --- a/autotest/gcore/vrtmisc.py +++ b/autotest/gcore/vrtmisc.py @@ -39,7 +39,7 @@ # Test linear scaling -def vrtmisc_1(): +def test_vrtmisc_1(): ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale 74 255 0 255') cs = ds.GetRasterBand(1).Checksum() @@ -56,7 +56,7 @@ def vrtmisc_1(): # Test power scaling -def vrtmisc_2(): +def test_vrtmisc_2(): ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale 74 255 0 255 -exponent 2.2') cs = ds.GetRasterBand(1).Checksum() @@ -73,7 +73,7 @@ def vrtmisc_2(): # Test power scaling (not in VRT file) -def vrtmisc_3(): +def test_vrtmisc_3(): ds = gdal.Open(""" @@ -100,7 +100,7 @@ def vrtmisc_3(): # Test multi-band linear scaling with a single -scale occurrence. -def vrtmisc_4(): +def test_vrtmisc_4(): # -scale specified once applies to all bands ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale 74 255 0 255 -b 1 -b 1') @@ -123,7 +123,7 @@ def vrtmisc_4(): # Test multi-band linear scaling with -scale_XX syntax -def vrtmisc_5(): +def test_vrtmisc_5(): # -scale_2 applies to band 2 only ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale_2 74 255 0 255 -b 1 -b 1') @@ -146,7 +146,7 @@ def vrtmisc_5(): # Test multi-band linear scaling with repeated -scale syntax -def vrtmisc_6(): +def test_vrtmisc_6(): # -scale repeated as many times as output band number ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale 0 255 0 255 -scale 74 255 0 255 -b 1 -b 1') @@ -169,7 +169,7 @@ def vrtmisc_6(): # Test multi-band power scaling with a single -scale and -exponent occurrence. -def vrtmisc_7(): +def test_vrtmisc_7(): # -scale and -exponent, specified once, apply to all bands ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale 74 255 0 255 -exponent 2.2 -b 1 -b 1') @@ -192,7 +192,7 @@ def vrtmisc_7(): # Test multi-band power scaling with -scale_XX and -exponent_XX syntax -def vrtmisc_8(): +def test_vrtmisc_8(): # -scale_2 and -exponent_2 apply to band 2 only ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale_2 74 255 0 255 -exponent_2 2.2 -b 1 -b 1') @@ -215,7 +215,7 @@ def vrtmisc_8(): # Test multi-band linear scaling with repeated -scale and -exponent syntax -def vrtmisc_9(): +def test_vrtmisc_9(): # -scale and -exponent repeated as many times as output band number ds = gdal.Translate('', 'data/byte.tif', options='-of MEM -scale 0 255 0 255 -scale 74 255 0 255 -exponent 1 -exponent 2.2 -b 1 -b 1') @@ -238,7 +238,7 @@ def vrtmisc_9(): # Test metadata serialization (#5944) -def vrtmisc_10(): +def test_vrtmisc_10(): gdal.FileFromMemBuffer("/vsimem/vrtmisc_10.vrt", """ @@ -308,7 +308,7 @@ def vrtmisc_10(): # Test relativeToVRT is preserved during re-serialization (#5985) -def vrtmisc_11(): +def test_vrtmisc_11(): f = open('tmp/vrtmisc_11.vrt', 'wt') f.write( @@ -345,7 +345,7 @@ def vrtmisc_11(): # Test set/delete nodata -def vrtmisc_12(): +def test_vrtmisc_12(): gdal.FileFromMemBuffer("/vsimem/vrtmisc_12.vrt", """ @@ -388,7 +388,7 @@ def vrtmisc_12(): # Test CreateCopy() preserve NBITS -def vrtmisc_13(): +def test_vrtmisc_13(): ds = gdal.Open('data/oddsize1bit.tif') out_ds = gdal.GetDriverByName('VRT').CreateCopy('', ds) @@ -402,7 +402,7 @@ def vrtmisc_13(): # Test SrcRect/DstRect are serialized as integers -def vrtmisc_14(): +def test_vrtmisc_14(): src_ds = gdal.GetDriverByName('GTiff').Create('/vsimem/vrtmisc_14_src.tif', 123456789, 1, options=['SPARSE_OK=YES', 'TILED=YES']) gdal.GetDriverByName('VRT').CreateCopy('/vsimem/vrtmisc_14.vrt', src_ds) @@ -442,7 +442,7 @@ def vrtmisc_14(): # Test CreateCopy() preserve SIGNEDBYTE -def vrtmisc_15(): +def test_vrtmisc_15(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/vrtmisc_15.tif', 1, 1, options=['PIXELTYPE=SIGNEDBYTE']) out_ds = gdal.GetDriverByName('VRT').CreateCopy('', ds) @@ -458,7 +458,7 @@ def vrtmisc_15(): # Test rounding to closest int for coordinates -def vrtmisc_16(): +def test_vrtmisc_16(): gdal.BuildVRT('/vsimem/vrtmisc_16.vrt', ['data/vrtmisc16_tile1.tif', 'data/vrtmisc16_tile2.tif']) fp = gdal.VSIFOpenL('/vsimem/vrtmisc_16.vrt', 'rb') @@ -529,7 +529,7 @@ def vrtmisc_16(): # Check that the serialized xml:VRT doesn't include itself (#6767) -def vrtmisc_17(): +def test_vrtmisc_17(): ds = gdal.Open('data/byte.tif') vrt_ds = gdal.GetDriverByName('VRT').CreateCopy('/vsimem/vrtmisc_17.vrt', ds) @@ -547,7 +547,7 @@ def vrtmisc_17(): # Check GetMetadata('xml:VRT') behaviour on a in-memory VRT copied from a VRT -def vrtmisc_18(): +def test_vrtmisc_18(): ds = gdal.Open('data/byte.vrt') vrt_ds = gdal.GetDriverByName('VRT').CreateCopy('', ds) @@ -569,7 +569,7 @@ def vrtmisc_18(): # Check RAT support -def vrtmisc_rat(): +def test_vrtmisc_rat(): ds = gdal.Translate('/vsimem/vrtmisc_rat.tif', 'data/byte.tif', format='MEM') rat = gdal.RasterAttributeTable() @@ -626,7 +626,7 @@ def vrtmisc_rat(): # Check ColorTable support -def vrtmisc_colortable(): +def test_vrtmisc_colortable(): ds = gdal.Translate('', 'data/byte.tif', format='VRT') ct = gdal.ColorTable() @@ -646,7 +646,7 @@ def vrtmisc_colortable(): # Check histogram support -def vrtmisc_histogram(): +def test_vrtmisc_histogram(): tmpfile = '/vsimem/vrtmisc_histogram.vrt' ds = gdal.Translate(tmpfile, 'data/byte.tif', format='VRT') @@ -668,33 +668,33 @@ def vrtmisc_histogram(): # Cleanup. -def vrtmisc_cleanup(): +def test_vrtmisc_cleanup(): return 'success' gdaltest_list = [ - vrtmisc_1, - vrtmisc_2, - vrtmisc_3, - vrtmisc_4, - vrtmisc_5, - vrtmisc_6, - vrtmisc_7, - vrtmisc_8, - vrtmisc_9, - vrtmisc_10, - vrtmisc_11, - vrtmisc_12, - vrtmisc_13, - vrtmisc_14, - vrtmisc_15, - vrtmisc_16, - vrtmisc_17, - vrtmisc_18, - vrtmisc_rat, - vrtmisc_colortable, - vrtmisc_histogram, - vrtmisc_cleanup] + test_vrtmisc_1, + test_vrtmisc_2, + test_vrtmisc_3, + test_vrtmisc_4, + test_vrtmisc_5, + test_vrtmisc_6, + test_vrtmisc_7, + test_vrtmisc_8, + test_vrtmisc_9, + test_vrtmisc_10, + test_vrtmisc_11, + test_vrtmisc_12, + test_vrtmisc_13, + test_vrtmisc_14, + test_vrtmisc_15, + test_vrtmisc_16, + test_vrtmisc_17, + test_vrtmisc_18, + test_vrtmisc_rat, + test_vrtmisc_colortable, + test_vrtmisc_histogram, + test_vrtmisc_cleanup] if __name__ == '__main__': diff --git a/autotest/gcore/vsiaz.py b/autotest/gcore/vsiaz.py index 209e6a22a7c5..96a2cc3064ff 100755 --- a/autotest/gcore/vsiaz.py +++ b/autotest/gcore/vsiaz.py @@ -46,7 +46,7 @@ def open_for_read(uri): ############################################################################### -def vsiaz_init(): +def test_vsiaz_init(): gdaltest.az_vars = {} for var in ('AZURE_STORAGE_CONNECTION_STRING', 'AZURE_STORAGE_ACCOUNT', @@ -65,7 +65,7 @@ def vsiaz_init(): # Error cases -def vsiaz_real_server_errors(): +def test_vsiaz_real_server_errors(): if not gdaltest.built_against_curl(): return 'skip' @@ -135,7 +135,7 @@ def vsiaz_real_server_errors(): ############################################################################### -def vsiaz_start_webserver(): +def test_vsiaz_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -159,7 +159,7 @@ def vsiaz_start_webserver(): # Test with a fake Azure Blob server -def vsiaz_fake_basic(): +def test_vsiaz_fake_basic(): if gdaltest.webserver_port == 0: return 'skip' @@ -268,7 +268,7 @@ def method(request): # Test ReadDir() with a fake Azure Blob server -def vsiaz_fake_readdir(): +def test_vsiaz_fake_readdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -405,7 +405,7 @@ def vsiaz_fake_readdir(): # Test write -def vsiaz_fake_write(): +def test_vsiaz_fake_write(): if gdaltest.webserver_port == 0: return 'skip' @@ -688,7 +688,7 @@ def method(request): # Test Unlink() -def vsiaz_fake_unlink(): +def test_vsiaz_fake_unlink(): if gdaltest.webserver_port == 0: return 'skip' @@ -720,7 +720,7 @@ def vsiaz_fake_unlink(): # Test Mkdir() / Rmdir() -def vsiaz_fake_mkdir_rmdir(): +def test_vsiaz_fake_mkdir_rmdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -858,7 +858,7 @@ def vsiaz_fake_mkdir_rmdir(): ############################################################################### -def vsiaz_fake_test_BlobEndpointInConnectionString(): +def test_vsiaz_fake_test_BlobEndpointInConnectionString(): if gdaltest.webserver_port == 0: return 'skip' @@ -878,7 +878,7 @@ def vsiaz_fake_test_BlobEndpointInConnectionString(): ############################################################################### -def vsiaz_stop_webserver(): +def test_vsiaz_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -1075,7 +1075,7 @@ def vsiaz_extra_1(): ############################################################################### -def vsiaz_cleanup(): +def test_vsiaz_cleanup(): for var in gdaltest.az_vars: gdal.SetConfigOption(var, gdaltest.az_vars[var]) @@ -1083,17 +1083,17 @@ def vsiaz_cleanup(): return 'success' -gdaltest_list = [vsiaz_init, - vsiaz_real_server_errors, - vsiaz_start_webserver, - vsiaz_fake_basic, - vsiaz_fake_readdir, - vsiaz_fake_write, - vsiaz_fake_unlink, - vsiaz_fake_mkdir_rmdir, - vsiaz_fake_test_BlobEndpointInConnectionString, - vsiaz_stop_webserver, - vsiaz_cleanup] +gdaltest_list = [test_vsiaz_init, + test_vsiaz_real_server_errors, + test_vsiaz_start_webserver, + test_vsiaz_fake_basic, + test_vsiaz_fake_readdir, + test_vsiaz_fake_write, + test_vsiaz_fake_unlink, + test_vsiaz_fake_mkdir_rmdir, + test_vsiaz_fake_test_BlobEndpointInConnectionString, + test_vsiaz_stop_webserver, + test_vsiaz_cleanup] # gdaltest_list = [ vsiaz_init, vsiaz_start_webserver, vsiaz_fake_mkdir_rmdir, vsiaz_stop_webserver, vsiaz_cleanup ] @@ -1106,6 +1106,6 @@ def vsiaz_cleanup(): if gdal.GetConfigOption('RUN_MANUAL_ONLY', None): gdaltest.run_tests(gdaltest_list_extra) else: - gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [vsiaz_cleanup]) + gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [test_vsiaz_cleanup]) sys.exit(gdaltest.summarize()) diff --git a/autotest/gcore/vsicrypt.py b/autotest/gcore/vsicrypt.py index 0d5344f8ad07..efe79b9e9c75 100755 --- a/autotest/gcore/vsicrypt.py +++ b/autotest/gcore/vsicrypt.py @@ -40,7 +40,7 @@ # Use common test for /vsicrypt -def vsicrypt_1(): +def test_vsicrypt_1(): gdaltest.has_vsicrypt = False fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/vsimem/file.bin', 'wb+') @@ -57,7 +57,7 @@ def vsicrypt_1(): # Test various error cases -def vsicrypt_2(): +def test_vsicrypt_2(): if not gdaltest.has_vsicrypt: return 'skip' @@ -293,7 +293,7 @@ def vsicrypt_2(): # Test various options -def vsicrypt_3(): +def test_vsicrypt_3(): if not gdaltest.has_vsicrypt: return 'skip' @@ -414,7 +414,7 @@ def vsicrypt_3(): # Test "random" operations against reference filesystem -def vsicrypt_4(): +def test_vsicrypt_4(): if not gdaltest.has_vsicrypt: return 'skip' @@ -483,7 +483,7 @@ def vsicrypt_4(): # Test random filling of last sector -def vsicrypt_5(): +def test_vsicrypt_5(): if not gdaltest.has_vsicrypt: return 'skip' @@ -548,7 +548,7 @@ def vsicrypt_5(): # Test VSISetCryptKey -def vsicrypt_6(): +def test_vsicrypt_6(): try: import ctypes @@ -627,12 +627,12 @@ def vsicrypt_6(): return 'success' -gdaltest_list = [vsicrypt_1, - vsicrypt_2, - vsicrypt_3, - vsicrypt_4, - vsicrypt_5, - vsicrypt_6] +gdaltest_list = [test_vsicrypt_1, + test_vsicrypt_2, + test_vsicrypt_3, + test_vsicrypt_4, + test_vsicrypt_5, + test_vsicrypt_6] if __name__ == '__main__': diff --git a/autotest/gcore/vsicurl.py b/autotest/gcore/vsicurl.py index 7f5ff0ea4ee2..65990dc262c2 100755 --- a/autotest/gcore/vsicurl.py +++ b/autotest/gcore/vsicurl.py @@ -42,7 +42,7 @@ ############################################################################### # -def vsicurl_1(): +def test_vsicurl_1(): if not gdaltest.run_slow_tests(): return 'skip' @@ -93,7 +93,7 @@ def vsicurl_3(): # This server doesn't support range downloading -def vsicurl_4(): +def test_vsicurl_4(): if not gdaltest.run_slow_tests(): return 'skip' @@ -110,7 +110,7 @@ def vsicurl_4(): # Test URL unescaping when reading HTTP file list -def vsicurl_5(): +def test_vsicurl_5(): if not gdaltest.run_slow_tests(): return 'skip' @@ -144,7 +144,7 @@ def vsicurl_6_disabled(): ############################################################################### # Test Microsoft-IIS/6.0 listing -def vsicurl_7(): +def test_vsicurl_7(): if not gdaltest.run_slow_tests(): return 'skip' @@ -181,7 +181,7 @@ def vsicurl_8(): # returns escaped sequences instead of the Chinese characters. -def vsicurl_9(): +def test_vsicurl_9(): if not gdaltest.run_slow_tests(): return 'skip' @@ -204,7 +204,7 @@ def vsicurl_9(): # Test reading a file with escaped Chinese characters. -def vsicurl_10(): +def test_vsicurl_10(): if not gdaltest.run_slow_tests(): return 'skip' @@ -221,7 +221,7 @@ def vsicurl_10(): # Test ReadDir() after reading a file on the same server -def vsicurl_11(): +def test_vsicurl_11(): if not gdaltest.run_slow_tests(): return 'skip' @@ -244,7 +244,7 @@ def vsicurl_11(): ############################################################################### -def vsicurl_start_webserver(): +def test_vsicurl_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -261,7 +261,7 @@ def vsicurl_start_webserver(): ############################################################################### -def vsicurl_test_redirect(): +def test_vsicurl_test_redirect(): if gdaltest.is_travis_branch('trusty'): print('Skipped on trusty branch, but should be investigated') @@ -393,7 +393,7 @@ def method(request): # TODO: better testing -def vsicurl_test_clear_cache(): +def test_vsicurl_test_clear_cache(): gdal.VSICurlClearCache() gdal.VSICurlClearCache() @@ -403,7 +403,7 @@ def vsicurl_test_clear_cache(): ############################################################################### -def vsicurl_test_retry(): +def test_vsicurl_test_retry(): if gdaltest.webserver_port == 0: return 'skip' @@ -455,7 +455,7 @@ def vsicurl_test_retry(): ############################################################################### -def vsicurl_test_fallback_from_head_to_get(): +def test_vsicurl_test_fallback_from_head_to_get(): if gdaltest.webserver_port == 0: return 'skip' @@ -477,7 +477,7 @@ def vsicurl_test_fallback_from_head_to_get(): ############################################################################### -def vsicurl_test_parse_html_filelist_apache(): +def test_vsicurl_test_parse_html_filelist_apache(): if gdaltest.webserver_port == 0: return 'skip' @@ -520,7 +520,7 @@ def vsicurl_test_parse_html_filelist_apache(): ############################################################################### -def vsicurl_stop_webserver(): +def test_vsicurl_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -534,24 +534,24 @@ def vsicurl_stop_webserver(): return 'success' -gdaltest_list = [vsicurl_1, +gdaltest_list = [test_vsicurl_1, # vsicurl_2, # vsicurl_3, - vsicurl_4, - vsicurl_5, + test_vsicurl_4, + test_vsicurl_5, #vsicurl_6_disabled, - vsicurl_7, + test_vsicurl_7, # vsicurl_8, - vsicurl_9, - vsicurl_10, - vsicurl_11, - vsicurl_start_webserver, - vsicurl_test_redirect, - vsicurl_test_clear_cache, - vsicurl_test_retry, - vsicurl_test_fallback_from_head_to_get, - vsicurl_test_parse_html_filelist_apache, - vsicurl_stop_webserver] + test_vsicurl_9, + test_vsicurl_10, + test_vsicurl_11, + test_vsicurl_start_webserver, + test_vsicurl_test_redirect, + test_vsicurl_test_clear_cache, + test_vsicurl_test_retry, + test_vsicurl_test_fallback_from_head_to_get, + test_vsicurl_test_parse_html_filelist_apache, + test_vsicurl_stop_webserver] if __name__ == '__main__': diff --git a/autotest/gcore/vsicurl_streaming.py b/autotest/gcore/vsicurl_streaming.py index 9b37675b5eca..29f543692cbb 100755 --- a/autotest/gcore/vsicurl_streaming.py +++ b/autotest/gcore/vsicurl_streaming.py @@ -39,7 +39,7 @@ # -def vsicurl_streaming_1(): +def test_vsicurl_streaming_1(): drv = gdal.GetDriverByName('HTTP') if drv is None: @@ -139,7 +139,7 @@ def vsicurl_streaming_1(): return 'success' -gdaltest_list = [vsicurl_streaming_1] +gdaltest_list = [test_vsicurl_streaming_1] if __name__ == '__main__': diff --git a/autotest/gcore/vsifile.py b/autotest/gcore/vsifile.py index 8639cb1de51c..e5419a4b1871 100755 --- a/autotest/gcore/vsifile.py +++ b/autotest/gcore/vsifile.py @@ -150,14 +150,14 @@ def vsifile_generic(filename): # Test /vsimem -def vsifile_1(): +def test_vsifile_1(): return vsifile_generic('/vsimem/vsifile_1.bin') ############################################################################### # Test regular file system -def vsifile_2(): +def test_vsifile_2(): ret = vsifile_generic('tmp/vsifile_2.bin') if ret != 'success' and gdaltest.skip_on_travis(): @@ -171,7 +171,7 @@ def vsifile_2(): # Test ftruncate >= 32 bit -def vsifile_3(): +def test_vsifile_3(): if not gdaltest.filesystem_supports_sparse_files('tmp'): return 'skip' @@ -214,7 +214,7 @@ def vsifile_3(): # Test fix for #4583 (short reads) -def vsifile_4(): +def test_vsifile_4(): fp = gdal.VSIFOpenL('vsifile.py', 'rb') data = gdal.VSIFReadL(1000000, 1, fp) @@ -231,7 +231,7 @@ def vsifile_4(): # Test vsicache -def vsifile_5(): +def test_vsifile_5(): fp = gdal.VSIFOpenL('tmp/vsifile_5.bin', 'wb') ref_data = ''.join(['%08X' % i for i in range(5 * 32768)]) @@ -307,7 +307,7 @@ def vsifile_5(): # Test vsicache above 2 GB -def vsifile_6(): +def test_vsifile_6(): if not gdaltest.filesystem_supports_sparse_files('tmp'): return 'skip' @@ -350,7 +350,7 @@ def vsifile_6(): # Test limit cases on /vsimem -def vsifile_7(): +def test_vsifile_7(): if gdal.GetConfigOption('SKIP_MEM_INTENSIVE_TEST') is not None: return 'skip' @@ -401,7 +401,7 @@ def vsifile_7(): # Test renaming directory in /vsimem -def vsifile_8(): +def test_vsifile_8(): # octal 0666 = decimal 438 gdal.Mkdir('/vsimem/mydir', 438) @@ -423,7 +423,7 @@ def vsifile_8(): # Test ReadDir() -def vsifile_9(): +def test_vsifile_9(): lst = gdal.ReadDir('.') if len(lst) < 4: @@ -460,7 +460,7 @@ def vsifile_9(): # Test fuzzer friendly archive -def vsifile_10(): +def test_vsifile_10(): gdal.FileFromMemBuffer('/vsimem/vsifile_10.tar', """FUZZER_FRIENDLY_ARCHIVE @@ -565,7 +565,7 @@ def vsifile_10(): # Test generic Truncate implementation for file extension -def vsifile_11(): +def test_vsifile_11(): f = gdal.VSIFOpenL('/vsimem/vsifile_11', 'wb') gdal.VSIFCloseL(f) @@ -600,7 +600,7 @@ def vsifile_11(): # Test regular file system sparse file support -def vsifile_12(): +def test_vsifile_12(): target_dir = 'tmp' @@ -638,7 +638,7 @@ def vsifile_12(): # Test reading filename with prefixes without terminating slash -def vsifile_13(): +def test_vsifile_13(): gdal.VSIFOpenL('/vsigzip', 'rb') gdal.VSIFOpenL('/vsizip', 'rb') @@ -675,7 +675,7 @@ def vsifile_13(): # Check performance issue (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1673) -def vsifile_14(): +def test_vsifile_14(): with gdaltest.error_handler(): gdal.VSIFOpenL('/vsitar//vsitar//vsitar//vsitar//vsitar//vsitar//vsitar//vsitar/a.tgzb.tgzc.tgzd.tgze.tgzf.tgz.h.tgz.i.tgz', 'rb') @@ -685,7 +685,7 @@ def vsifile_14(): # Test issue with Eof() not detecting end of corrupted gzip stream (#6944) -def vsifile_15(): +def test_vsifile_15(): fp = gdal.VSIFOpenL('/vsigzip/data/corrupted_z_buf_error.gz', 'rb') if fp is None: @@ -727,7 +727,7 @@ def vsifile_15(): # Test failed gdal.Rename() with exceptions enabled -def vsifile_16(): +def test_vsifile_16(): old_val = gdal.GetUseExceptions() gdal.UseExceptions() @@ -744,7 +744,7 @@ def vsifile_16(): # Test gdal.GetActualURL() on a non-network based filesystem -def vsifile_17(): +def test_vsifile_17(): if gdal.GetActualURL('foo') is not None: gdaltest.post_reason('fail') @@ -760,7 +760,7 @@ def vsifile_17(): # Test gdal.GetFileSystemsPrefixes() -def vsifile_18(): +def test_vsifile_18(): prefixes = gdal.GetFileSystemsPrefixes() if '/vsimem/' not in prefixes: @@ -773,7 +773,7 @@ def vsifile_18(): # Test gdal.GetFileSystemOptions() -def vsifile_19(): +def test_vsifile_19(): for prefix in gdal.GetFileSystemsPrefixes(): options = gdal.GetFileSystemOptions(prefix) @@ -791,7 +791,7 @@ def vsifile_19(): # Test gdal.VSIFReadL with None fp -def vsifile_20(): +def test_vsifile_20(): try: gdal.VSIFReadL(1, 1, None) @@ -804,7 +804,7 @@ def vsifile_20(): # Test gdal.VSIGetMemFileBuffer_unsafe() and gdal.VSIFWriteL() reading buffers -def vsifile_21(): +def test_vsifile_21(): filename = '/vsimem/read.tif' filename_write = '/vsimem/write.tif' @@ -838,7 +838,7 @@ def vsifile_21(): return 'success' -def vsifile_22(): +def test_vsifile_22(): # VSIOpenL doesn't set errorno gdal.VSIErrorReset() if gdal.VSIGetLastErrorNo() != 0: @@ -876,7 +876,7 @@ def vsifile_22(): # Test bugfix for https://github.com/OSGeo/gdal/issues/675 -def vsitar_bug_675(): +def test_vsitar_bug_675(): content = gdal.ReadDir('/vsitar/data/tar_with_star_base256_fields.tar') if len(content) != 1: @@ -888,7 +888,7 @@ def vsitar_bug_675(): # Test multithreaded compression -def vsigzip_multi_thread(): +def test_vsigzip_multi_thread(): with gdaltest.config_options({'GDAL_NUM_THREADS': 'ALL_CPUS', 'CPL_VSIL_DEFLATE_CHUNK_SIZE': '32K'}): @@ -919,7 +919,7 @@ def vsigzip_multi_thread(): # Test vsisync() -def vsisync(): +def test_vsisync(): with gdaltest.error_handler(): if gdal.Sync('/i_do/not/exist', '/vsimem/'): @@ -1002,7 +1002,7 @@ def my_progress(pct, message, user_data): ############################################################################### # Test gdal.OpenDir() -def vsifile_opendir(): +def test_vsifile_opendir(): # Non existing dir d = gdal.OpenDir('/vsimem/i_dont_exist') @@ -1125,32 +1125,32 @@ def vsifile_opendir(): return 'success' -gdaltest_list = [vsifile_1, - vsifile_2, - vsifile_3, - vsifile_4, - vsifile_5, - vsifile_6, - vsifile_7, - vsifile_8, - vsifile_9, - vsifile_10, - vsifile_11, - vsifile_12, - vsifile_13, - vsifile_14, - vsifile_15, - vsifile_16, - vsifile_17, - vsifile_18, - vsifile_19, - vsifile_20, - vsifile_21, - vsifile_22, - vsitar_bug_675, - vsigzip_multi_thread, - vsifile_opendir, - vsisync] +gdaltest_list = [test_vsifile_1, + test_vsifile_2, + test_vsifile_3, + test_vsifile_4, + test_vsifile_5, + test_vsifile_6, + test_vsifile_7, + test_vsifile_8, + test_vsifile_9, + test_vsifile_10, + test_vsifile_11, + test_vsifile_12, + test_vsifile_13, + test_vsifile_14, + test_vsifile_15, + test_vsifile_16, + test_vsifile_17, + test_vsifile_18, + test_vsifile_19, + test_vsifile_20, + test_vsifile_21, + test_vsifile_22, + test_vsitar_bug_675, + test_vsigzip_multi_thread, + test_vsifile_opendir, + test_vsisync] if __name__ == '__main__': diff --git a/autotest/gcore/vsigs.py b/autotest/gcore/vsigs.py index cbc9dfd3675a..258e9acb08d3 100755 --- a/autotest/gcore/vsigs.py +++ b/autotest/gcore/vsigs.py @@ -46,7 +46,7 @@ def open_for_read(uri): ############################################################################### -def vsigs_init(): +def test_vsigs_init(): gdaltest.gs_vars = {} for var in ('GS_SECRET_ACCESS_KEY', 'GS_ACCESS_KEY_ID', @@ -77,7 +77,7 @@ def vsigs_init(): # Error cases -def vsigs_1(): +def test_vsigs_1(): if not gdaltest.built_against_curl(): return 'skip' @@ -165,7 +165,7 @@ def vsigs_1(): ############################################################################### -def vsigs_start_webserver(): +def test_vsigs_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -187,7 +187,7 @@ def vsigs_start_webserver(): # Test with a fake Google Cloud Storage server -def vsigs_2(): +def test_vsigs_2(): if gdaltest.webserver_port == 0: return 'skip' @@ -290,7 +290,7 @@ def vsigs_2(): # Test ReadDir() with a fake Google Cloud Storage server -def vsigs_readdir(): +def test_vsigs_readdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -380,7 +380,7 @@ def vsigs_readdir(): # Test write -def vsigs_write(): +def test_vsigs_write(): if gdaltest.webserver_port == 0: return 'skip' @@ -492,7 +492,7 @@ def method(request): # Read credentials with OAuth2 refresh_token -def vsigs_read_credentials_refresh_token_default_gdal_app(): +def test_vsigs_read_credentials_refresh_token_default_gdal_app(): if gdaltest.webserver_port == 0: return 'skip' @@ -574,7 +574,7 @@ def method(request): # Read credentials with OAuth2 refresh_token -def vsigs_read_credentials_refresh_token_custom_app(): +def test_vsigs_read_credentials_refresh_token_custom_app(): if gdaltest.webserver_port == 0: return 'skip' @@ -655,7 +655,7 @@ def method(request): # Read credentials with OAuth2 service account -def vsigs_read_credentials_oauth2_service_account(): +def test_vsigs_read_credentials_oauth2_service_account(): if gdaltest.webserver_port == 0: return 'skip' @@ -773,7 +773,7 @@ def method(request): # Read credentials with OAuth2 service account through a json configuration file -def vsigs_read_credentials_oauth2_service_account_json_file(): +def test_vsigs_read_credentials_oauth2_service_account_json_file(): if gdaltest.webserver_port == 0: return 'skip' @@ -876,7 +876,7 @@ def method(request): # Read credentials from simulated ~/.boto -def vsigs_read_credentials_file(): +def test_vsigs_read_credentials_file(): if gdaltest.webserver_port == 0: return 'skip' @@ -941,7 +941,7 @@ def method(request): # Read credentials from simulated ~/.boto -def vsigs_read_credentials_file_refresh_token(): +def test_vsigs_read_credentials_file_refresh_token(): if gdaltest.webserver_port == 0: return 'skip' @@ -1026,7 +1026,7 @@ def method(request): # Read credentials from simulated GCE instance -def vsigs_read_credentials_gce(): +def test_vsigs_read_credentials_gce(): if gdaltest.webserver_port == 0: return 'skip' @@ -1116,7 +1116,7 @@ def method(request): # cached credentials -def vsigs_read_credentials_gce_expiration(): +def test_vsigs_read_credentials_gce_expiration(): if gdaltest.webserver_port == 0: return 'skip' @@ -1189,7 +1189,7 @@ def method(request): ############################################################################### -def vsigs_stop_webserver(): +def test_vsigs_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -1393,7 +1393,7 @@ def vsigs_extra_1(): ############################################################################### -def vsigs_cleanup(): +def test_vsigs_cleanup(): for var in gdaltest.gs_vars: gdal.SetConfigOption(var, gdaltest.gs_vars[var]) @@ -1401,22 +1401,22 @@ def vsigs_cleanup(): return 'success' -gdaltest_list = [vsigs_init, - vsigs_1, - vsigs_start_webserver, - vsigs_2, - vsigs_readdir, - vsigs_write, - vsigs_read_credentials_refresh_token_default_gdal_app, - vsigs_read_credentials_refresh_token_custom_app, - vsigs_read_credentials_oauth2_service_account, - vsigs_read_credentials_oauth2_service_account_json_file, - vsigs_read_credentials_file, - vsigs_read_credentials_file_refresh_token, - vsigs_read_credentials_gce, - vsigs_read_credentials_gce_expiration, - vsigs_stop_webserver, - vsigs_cleanup] +gdaltest_list = [test_vsigs_init, + test_vsigs_1, + test_vsigs_start_webserver, + test_vsigs_2, + test_vsigs_readdir, + test_vsigs_write, + test_vsigs_read_credentials_refresh_token_default_gdal_app, + test_vsigs_read_credentials_refresh_token_custom_app, + test_vsigs_read_credentials_oauth2_service_account, + test_vsigs_read_credentials_oauth2_service_account_json_file, + test_vsigs_read_credentials_file, + test_vsigs_read_credentials_file_refresh_token, + test_vsigs_read_credentials_gce, + test_vsigs_read_credentials_gce_expiration, + test_vsigs_stop_webserver, + test_vsigs_cleanup] # gdaltest_list = [ vsigs_init, vsigs_start_webserver, vsigs_write, vsigs_stop_webserver, vsigs_cleanup ] @@ -1429,6 +1429,6 @@ def vsigs_cleanup(): if gdal.GetConfigOption('RUN_MANUAL_ONLY', None): gdaltest.run_tests(gdaltest_list_extra) else: - gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [vsigs_cleanup]) + gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [test_vsigs_cleanup]) sys.exit(gdaltest.summarize()) diff --git a/autotest/gcore/vsihdfs.py b/autotest/gcore/vsihdfs.py index 141b0b475e7c..3e4be7a55b35 100755 --- a/autotest/gcore/vsihdfs.py +++ b/autotest/gcore/vsihdfs.py @@ -38,7 +38,7 @@ import gdaltest # Read test -def vsihdfs_1(): +def test_vsihdfs_1(): filename = '/vsihdfs/file:' + os.getcwd() + '/data/text.txt' fp = gdal.VSIFOpenL(filename, 'rb') if fp is None: @@ -59,7 +59,7 @@ def vsihdfs_1(): return 'success' # Seek test -def vsihdfs_2(): +def test_vsihdfs_2(): if gdaltest.have_vsihdfs == False: return 'skip' @@ -88,7 +88,7 @@ def vsihdfs_2(): return 'success' # Tell test -def vsihdfs_3(): +def test_vsihdfs_3(): if gdaltest.have_vsihdfs == False: return 'skip' @@ -109,11 +109,11 @@ def vsihdfs_3(): return 'success' # Write test -def vsihdfs_4(): +def test_vsihdfs_4(): return 'skip' # EOF test -def vsihdfs_5(): +def test_vsihdfs_5(): if gdaltest.have_vsihdfs == False: return 'skip' @@ -146,7 +146,7 @@ def vsihdfs_5(): return 'success' # Stat test -def vsihdfs_6(): +def test_vsihdfs_6(): if gdaltest.have_vsihdfs == False: return 'skip' @@ -163,7 +163,7 @@ def vsihdfs_6(): return 'success' # ReadDir test -def vsihdfs_7(): +def test_vsihdfs_7(): if gdaltest.have_vsihdfs == False: return 'skip' @@ -175,13 +175,13 @@ def vsihdfs_7(): return 'success' -gdaltest_list = [vsihdfs_1, - vsihdfs_2, - vsihdfs_3, - vsihdfs_4, - vsihdfs_5, - vsihdfs_6, - vsihdfs_7] +gdaltest_list = [test_vsihdfs_1, + test_vsihdfs_2, + test_vsihdfs_3, + test_vsihdfs_4, + test_vsihdfs_5, + test_vsihdfs_6, + test_vsihdfs_7] if __name__ == '__main__': diff --git a/autotest/gcore/vsioss.py b/autotest/gcore/vsioss.py index bbc1c5885d28..a3311b4a7817 100755 --- a/autotest/gcore/vsioss.py +++ b/autotest/gcore/vsioss.py @@ -46,7 +46,7 @@ def open_for_read(uri): ############################################################################### -def visoss_init(): +def test_visoss_init(): gdaltest.oss_vars = {} for var in ('OSS_SECRET_ACCESS_KEY', 'OSS_ACCESS_KEY_ID', 'OSS_TIMESTAMP', 'OSS_HTTPS', 'OSS_VIRTUAL_HOSTING', 'OSS_ENDPOINT'): @@ -64,7 +64,7 @@ def visoss_init(): # Error cases -def visoss_1(): +def test_visoss_1(): if not gdaltest.built_against_curl(): return 'skip' @@ -102,7 +102,7 @@ def visoss_1(): return 'success' -def visoss_real_test(): +def test_visoss_real_test(): if not gdaltest.built_against_curl(): return 'skip' @@ -136,7 +136,7 @@ def visoss_real_test(): ############################################################################### -def visoss_start_webserver(): +def test_visoss_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -184,7 +184,7 @@ def get_oss_fake_bucket_resource_method(request): # Test with a fake OSS server -def visoss_2(): +def test_visoss_2(): if gdaltest.webserver_port == 0: return 'skip' @@ -414,7 +414,7 @@ def method(request): # Test ReadDir() with a fake OSS server -def visoss_3(): +def test_visoss_3(): if gdaltest.webserver_port == 0: return 'skip' @@ -658,7 +658,7 @@ def method(request): # Test simple PUT support with a fake OSS server -def visoss_4(): +def test_visoss_4(): if gdaltest.webserver_port == 0: return 'skip' @@ -817,7 +817,7 @@ def method(request): # Test simple DELETE support with a fake OSS server -def visoss_5(): +def test_visoss_5(): if gdaltest.webserver_port == 0: return 'skip' @@ -873,7 +873,7 @@ def visoss_5(): # Test multipart upload with a fake OSS server -def visoss_6(): +def test_visoss_6(): if gdaltest.webserver_port == 0: return 'skip' @@ -1097,7 +1097,7 @@ def method(request): # Test Mkdir() / Rmdir() -def visoss_7(): +def test_visoss_7(): if gdaltest.webserver_port == 0: return 'skip' @@ -1166,7 +1166,7 @@ def visoss_7(): # Test handling of file and directory with same name -def visoss_8(): +def test_visoss_8(): if gdaltest.webserver_port == 0: return 'skip' @@ -1212,7 +1212,7 @@ def visoss_8(): ############################################################################### -def visoss_stop_webserver(): +def test_visoss_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -1418,7 +1418,7 @@ def visoss_extra_1(): ############################################################################### -def visoss_cleanup(): +def test_visoss_cleanup(): for var in gdaltest.oss_vars: gdal.SetConfigOption(var, gdaltest.oss_vars[var]) @@ -1426,19 +1426,19 @@ def visoss_cleanup(): return 'success' -gdaltest_list = [visoss_init, - visoss_1, - visoss_real_test, - visoss_start_webserver, - visoss_2, - visoss_3, - visoss_4, - visoss_5, - visoss_6, - visoss_7, - visoss_8, - visoss_stop_webserver, - visoss_cleanup] +gdaltest_list = [test_visoss_init, + test_visoss_1, + test_visoss_real_test, + test_visoss_start_webserver, + test_visoss_2, + test_visoss_3, + test_visoss_4, + test_visoss_5, + test_visoss_6, + test_visoss_7, + test_visoss_8, + test_visoss_stop_webserver, + test_visoss_cleanup] # gdaltest_list = [ visoss_init, visoss_start_webserver, visoss_8, visoss_stop_webserver, visoss_cleanup ] @@ -1451,6 +1451,6 @@ def visoss_cleanup(): if gdal.GetConfigOption('RUN_MANUAL_ONLY', None): gdaltest.run_tests(gdaltest_list_extra) else: - gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [visoss_cleanup]) + gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [test_visoss_cleanup]) sys.exit(gdaltest.summarize()) diff --git a/autotest/gcore/vsis3.py b/autotest/gcore/vsis3.py index 87ae1faf9fc8..1dff8c9d98b2 100755 --- a/autotest/gcore/vsis3.py +++ b/autotest/gcore/vsis3.py @@ -47,7 +47,7 @@ def open_for_read(uri): ############################################################################### -def vsis3_init(): +def test_vsis3_init(): gdaltest.aws_vars = {} for var in ('AWS_SECRET_ACCESS_KEY', 'AWS_ACCESS_KEY_ID', 'AWS_TIMESTAMP', 'AWS_HTTPS', 'AWS_VIRTUAL_HOSTING', 'AWS_S3_ENDPOINT', 'AWS_REQUEST_PAYER', 'AWS_DEFAULT_REGION', 'AWS_DEFAULT_PROFILE', 'AWS_NO_SIGN_REQUEST'): @@ -71,7 +71,7 @@ def vsis3_init(): # Test AWS_NO_SIGN_REQUEST=YES -def vsis3_no_sign_request(): +def test_vsis3_no_sign_request(): if not gdaltest.built_against_curl(): return 'skip' @@ -103,7 +103,7 @@ def vsis3_no_sign_request(): # Error cases -def vsis3_1(): +def test_vsis3_1(): if not gdaltest.built_against_curl(): return 'skip' @@ -164,7 +164,7 @@ def vsis3_1(): ############################################################################### -def vsis3_start_webserver(): +def test_vsis3_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -211,7 +211,7 @@ def get_s3_fake_bucket_resource_method(request): # Test with a fake AWS server -def vsis3_2(): +def test_vsis3_2(): if gdaltest.webserver_port == 0: return 'skip' @@ -662,7 +662,7 @@ def method_req_2(self, request): # Test ReadDir() with a fake AWS server -def vsis3_readdir(): +def test_vsis3_readdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -1103,7 +1103,7 @@ def method_req_2(self, request): # Test OpenDir() with a fake AWS server -def vsis3_opendir(): +def test_vsis3_opendir(): if gdaltest.webserver_port == 0: return 'skip' @@ -1323,7 +1323,7 @@ def vsis3_opendir(): # Test simple PUT support with a fake AWS server -def vsis3_4(): +def test_vsis3_4(): if gdaltest.webserver_port == 0: return 'skip' @@ -1538,7 +1538,7 @@ def method(request): # Test simple DELETE support with a fake AWS server -def vsis3_5(): +def test_vsis3_5(): if gdaltest.webserver_port == 0: return 'skip' @@ -1628,7 +1628,7 @@ def method(request): # Test multipart upload with a fake AWS server -def vsis3_6(): +def test_vsis3_6(): if gdaltest.webserver_port == 0: return 'skip' @@ -1867,7 +1867,7 @@ def method(request): # Test Mkdir() / Rmdir() -def vsis3_7(): +def test_vsis3_7(): if gdaltest.webserver_port == 0: return 'skip' @@ -2024,7 +2024,7 @@ def vsis3_7(): # Test handling of file and directory with same name -def vsis3_8(): +def test_vsis3_8(): if gdaltest.webserver_port == 0: return 'skip' @@ -2071,7 +2071,7 @@ def vsis3_8(): # Test vsisync() with SYNC_STRATEGY=ETAG -def vsis3_sync_etag(): +def test_vsis3_sync_etag(): if gdaltest.webserver_port == 0: return 'skip' @@ -2237,7 +2237,7 @@ def method(request): # Test vsisync() with SYNC_STRATEGY=TIMESTAMP -def vsis3_sync_timestamp(): +def test_vsis3_sync_timestamp(): if gdaltest.webserver_port == 0: return 'skip' @@ -2312,7 +2312,7 @@ def vsis3_sync_timestamp(): # Read credentials from simulated ~/.aws/credentials -def vsis3_read_credentials_file(): +def test_vsis3_read_credentials_file(): if gdaltest.webserver_port == 0: return 'skip' @@ -2360,7 +2360,7 @@ def vsis3_read_credentials_file(): # Read credentials from simulated ~/.aws/config -def vsis3_read_config_file(): +def test_vsis3_read_config_file(): if gdaltest.webserver_port == 0: return 'skip' @@ -2409,7 +2409,7 @@ def vsis3_read_config_file(): # Read credentials from simulated ~/.aws/credentials and ~/.aws/config -def vsis3_read_credentials_config_file(): +def test_vsis3_read_credentials_config_file(): if gdaltest.webserver_port == 0: return 'skip' @@ -2474,7 +2474,7 @@ def vsis3_read_credentials_config_file(): # a non default profile -def vsis3_read_credentials_config_file_non_default(): +def test_vsis3_read_credentials_config_file_non_default(): if gdaltest.webserver_port == 0: return 'skip' @@ -2538,7 +2538,7 @@ def vsis3_read_credentials_config_file_non_default(): # Read credentials from simulated ~/.aws/credentials and ~/.aws/config -def vsis3_read_credentials_config_file_inconsistent(): +def test_vsis3_read_credentials_config_file_inconsistent(): if gdaltest.webserver_port == 0: return 'skip' @@ -2608,7 +2608,7 @@ def vsis3_read_credentials_config_file_inconsistent(): # Read credentials from simulated EC2 instance -def vsis3_read_credentials_ec2(): +def test_vsis3_read_credentials_ec2(): if gdaltest.webserver_port == 0: return 'skip' @@ -2678,7 +2678,7 @@ def vsis3_read_credentials_ec2(): # cached credentials -def vsis3_read_credentials_ec2_expiration(): +def test_vsis3_read_credentials_ec2_expiration(): if gdaltest.webserver_port == 0: return 'skip' @@ -2737,7 +2737,7 @@ def vsis3_read_credentials_ec2_expiration(): ############################################################################### -def vsis3_stop_webserver(): +def test_vsis3_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -2947,7 +2947,7 @@ def vsis3_extra_1(): ############################################################################### -def vsis3_cleanup(): +def test_vsis3_cleanup(): for var in gdaltest.aws_vars: gdal.SetConfigOption(var, gdaltest.aws_vars[var]) @@ -2959,29 +2959,29 @@ def vsis3_cleanup(): return 'success' -gdaltest_list = [vsis3_init, - vsis3_no_sign_request, - vsis3_1, - vsis3_start_webserver, - vsis3_2, - vsis3_readdir, - vsis3_opendir, - vsis3_4, - vsis3_5, - vsis3_6, - vsis3_7, - vsis3_8, - vsis3_sync_etag, - vsis3_sync_timestamp, - vsis3_read_credentials_file, - vsis3_read_config_file, - vsis3_read_credentials_config_file, - vsis3_read_credentials_config_file_non_default, - vsis3_read_credentials_config_file_inconsistent, - vsis3_read_credentials_ec2, - vsis3_read_credentials_ec2_expiration, - vsis3_stop_webserver, - vsis3_cleanup] +gdaltest_list = [test_vsis3_init, + test_vsis3_no_sign_request, + test_vsis3_1, + test_vsis3_start_webserver, + test_vsis3_2, + test_vsis3_readdir, + test_vsis3_opendir, + test_vsis3_4, + test_vsis3_5, + test_vsis3_6, + test_vsis3_7, + test_vsis3_8, + test_vsis3_sync_etag, + test_vsis3_sync_timestamp, + test_vsis3_read_credentials_file, + test_vsis3_read_config_file, + test_vsis3_read_credentials_config_file, + test_vsis3_read_credentials_config_file_non_default, + test_vsis3_read_credentials_config_file_inconsistent, + test_vsis3_read_credentials_ec2, + test_vsis3_read_credentials_ec2_expiration, + test_vsis3_stop_webserver, + test_vsis3_cleanup] # gdaltest_list = [ vsis3_init, vsis3_start_webserver, vsis3_opendir, vsis3_stop_webserver, vsis3_cleanup ] @@ -2994,6 +2994,6 @@ def vsis3_cleanup(): if gdal.GetConfigOption('RUN_MANUAL_ONLY', None): gdaltest.run_tests(gdaltest_list_extra) else: - gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [vsis3_cleanup]) + gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [test_vsis3_cleanup]) sys.exit(gdaltest.summarize()) diff --git a/autotest/gcore/vsistdin.py b/autotest/gcore/vsistdin.py index 87c7c3db39e4..6a9c0fe7ef59 100755 --- a/autotest/gcore/vsistdin.py +++ b/autotest/gcore/vsistdin.py @@ -40,7 +40,7 @@ # Test on a small file -def vsistdin_1(): +def test_vsistdin_1(): if test_cli_utilities.get_gdal_translate_path() is None: return 'skip' @@ -71,7 +71,7 @@ def vsistdin_1(): # Test on a bigger file (> 1 MB) -def vsistdin_2(): +def test_vsistdin_2(): if test_cli_utilities.get_gdal_translate_path() is None: return 'skip' @@ -96,7 +96,7 @@ def vsistdin_2(): # Test opening /vsistdin/ in write mode (failure expected) -def vsistdin_3(): +def test_vsistdin_3(): gdal.PushErrorHandler('CPLQuietErrorHandler') f = gdal.VSIFOpenL('/vsistdin/', 'wb') @@ -110,7 +110,7 @@ def vsistdin_3(): # Test fix for #6061 -def vsistdin_4(): +def test_vsistdin_4(): if test_cli_utilities.get_gdal_translate_path() is None: return 'skip' @@ -144,7 +144,7 @@ def vsistdin_4(): return 'success' -gdaltest_list = [vsistdin_1, vsistdin_2, vsistdin_3, vsistdin_4] +gdaltest_list = [test_vsistdin_1, test_vsistdin_2, test_vsistdin_3, test_vsistdin_4] if __name__ == '__main__': diff --git a/autotest/gcore/vsiswift.py b/autotest/gcore/vsiswift.py index 8c9ff60823f8..6c0cb2370f99 100644 --- a/autotest/gcore/vsiswift.py +++ b/autotest/gcore/vsiswift.py @@ -46,7 +46,7 @@ def open_for_read(uri): ############################################################################### -def vsiswift_init(): +def test_vsiswift_init(): gdaltest.swift_vars = {} for var in ('SWIFT_STORAGE_URL', 'SWIFT_AUTH_TOKEN', @@ -61,7 +61,7 @@ def vsiswift_init(): # Error cases -def vsiswift_real_server_errors(): +def test_vsiswift_real_server_errors(): if not gdaltest.built_against_curl(): return 'skip' @@ -119,7 +119,7 @@ def vsiswift_real_server_errors(): ############################################################################### -def vsiswift_start_webserver(): +def test_vsiswift_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -137,7 +137,7 @@ def vsiswift_start_webserver(): # Test authentication with SWIFT_AUTH_V1_URL + SWIFT_USER + SWIFT_KEY -def vsiswift_fake_auth_v1_url(): +def test_vsiswift_fake_auth_v1_url(): if gdaltest.webserver_port == 0: return 'skip' @@ -239,7 +239,7 @@ def method(request): # Test authentication with SWIFT_STORAGE_URL + SWIFT_AUTH_TOKEN -def vsiswift_fake_auth_storage_url_and_auth_token(): +def test_vsiswift_fake_auth_storage_url_and_auth_token(): if gdaltest.webserver_port == 0: return 'skip' @@ -302,7 +302,7 @@ def method(request): # Test VSIStatL() -def vsiswift_stat(): +def test_vsiswift_stat(): if gdaltest.webserver_port == 0: return 'skip' @@ -351,7 +351,7 @@ def vsiswift_stat(): # Test ReadDir() -def vsiswift_fake_readdir(): +def test_vsiswift_fake_readdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -481,7 +481,7 @@ def vsiswift_fake_readdir(): # Test write -def vsiswift_fake_write(): +def test_vsiswift_fake_write(): if gdaltest.webserver_port == 0: return 'skip' @@ -541,7 +541,7 @@ def method(request): # Test Unlink() -def vsiswift_fake_unlink(): +def test_vsiswift_fake_unlink(): if gdaltest.webserver_port == 0: return 'skip' @@ -577,7 +577,7 @@ def vsiswift_fake_unlink(): # Test Mkdir() / Rmdir() -def vsiswift_fake_mkdir_rmdir(): +def test_vsiswift_fake_mkdir_rmdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -683,7 +683,7 @@ def vsiswift_fake_mkdir_rmdir(): ############################################################################### -def vsiswift_stop_webserver(): +def test_vsiswift_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -853,7 +853,7 @@ def vsiswift_extra_1(): ############################################################################### -def vsiswift_cleanup(): +def test_vsiswift_cleanup(): for var in gdaltest.swift_vars: gdal.SetConfigOption(var, gdaltest.swift_vars[var]) @@ -861,18 +861,18 @@ def vsiswift_cleanup(): return 'success' -gdaltest_list = [vsiswift_init, - vsiswift_real_server_errors, - vsiswift_start_webserver, - vsiswift_fake_auth_v1_url, - vsiswift_fake_auth_storage_url_and_auth_token, - vsiswift_stat, - vsiswift_fake_readdir, - vsiswift_fake_write, - vsiswift_fake_unlink, - vsiswift_fake_mkdir_rmdir, - vsiswift_stop_webserver, - vsiswift_cleanup] +gdaltest_list = [test_vsiswift_init, + test_vsiswift_real_server_errors, + test_vsiswift_start_webserver, + test_vsiswift_fake_auth_v1_url, + test_vsiswift_fake_auth_storage_url_and_auth_token, + test_vsiswift_stat, + test_vsiswift_fake_readdir, + test_vsiswift_fake_write, + test_vsiswift_fake_unlink, + test_vsiswift_fake_mkdir_rmdir, + test_vsiswift_stop_webserver, + test_vsiswift_cleanup] # gdaltest_list = [ vsiswift_init, vsiswift_start_webserver, vsiswift_fake_mkdir_rmdir, vsiswift_stop_webserver, vsiswift_cleanup ] @@ -885,6 +885,6 @@ def vsiswift_cleanup(): if gdal.GetConfigOption('RUN_MANUAL_ONLY', None): gdaltest.run_tests(gdaltest_list_extra) else: - gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [vsiswift_cleanup]) + gdaltest.run_tests(gdaltest_list + gdaltest_list_extra + [test_vsiswift_cleanup]) sys.exit(gdaltest.summarize()) diff --git a/autotest/gcore/vsiwebhdfs.py b/autotest/gcore/vsiwebhdfs.py index 64b6fb9a58fa..ea79f7677366 100644 --- a/autotest/gcore/vsiwebhdfs.py +++ b/autotest/gcore/vsiwebhdfs.py @@ -46,7 +46,7 @@ def open_for_read(uri): ############################################################################### -def vsiwebhdfs_init(): +def test_vsiwebhdfs_init(): gdaltest.webhdfs_vars = {} for var in ('WEBHDFS_USERNAME', 'WEBHDFS_DELEGATION'): @@ -59,7 +59,7 @@ def vsiwebhdfs_init(): ############################################################################### -def vsiwebhdfs_start_webserver(): +def test_vsiwebhdfs_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 @@ -83,7 +83,7 @@ def vsiwebhdfs_start_webserver(): # Test VSIFOpenL() -def vsiwebhdfs_open(): +def test_vsiwebhdfs_open(): if gdaltest.webserver_port == 0: return 'skip' @@ -156,7 +156,7 @@ def vsiwebhdfs_open(): # Test VSIStatL() -def vsiwebhdfs_stat(): +def test_vsiwebhdfs_stat(): if gdaltest.webserver_port == 0: return 'skip' @@ -199,7 +199,7 @@ def vsiwebhdfs_stat(): # Test ReadDir() -def vsiwebhdfs_readdir(): +def test_vsiwebhdfs_readdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -248,7 +248,7 @@ def vsiwebhdfs_readdir(): # Test write -def vsiwebhdfs_write(): +def test_vsiwebhdfs_write(): if gdaltest.webserver_port == 0: return 'skip' @@ -399,7 +399,7 @@ def method(request): # Test Unlink() -def vsiwebhdfs_unlink(): +def test_vsiwebhdfs_unlink(): if gdaltest.webserver_port == 0: return 'skip' @@ -464,7 +464,7 @@ def vsiwebhdfs_unlink(): # Test Mkdir() / Rmdir() -def vsiwebhdfs_mkdir_rmdir(): +def test_vsiwebhdfs_mkdir_rmdir(): if gdaltest.webserver_port == 0: return 'skip' @@ -547,7 +547,7 @@ def vsiwebhdfs_mkdir_rmdir(): ############################################################################### -def vsiwebhdfs_stop_webserver(): +def test_vsiwebhdfs_stop_webserver(): if gdaltest.webserver_port == 0: return 'skip' @@ -697,7 +697,7 @@ def vsiwebhdfs_extra_1(): ############################################################################### -def vsiwebhdfs_cleanup(): +def test_vsiwebhdfs_cleanup(): for var in gdaltest.webhdfs_vars: gdal.SetConfigOption(var, gdaltest.webhdfs_vars[var]) @@ -705,16 +705,16 @@ def vsiwebhdfs_cleanup(): return 'success' -gdaltest_list = [vsiwebhdfs_init, - vsiwebhdfs_start_webserver, - vsiwebhdfs_open, - vsiwebhdfs_stat, - vsiwebhdfs_readdir, - vsiwebhdfs_write, - vsiwebhdfs_unlink, - vsiwebhdfs_mkdir_rmdir, - vsiwebhdfs_stop_webserver, - vsiwebhdfs_cleanup] +gdaltest_list = [test_vsiwebhdfs_init, + test_vsiwebhdfs_start_webserver, + test_vsiwebhdfs_open, + test_vsiwebhdfs_stat, + test_vsiwebhdfs_readdir, + test_vsiwebhdfs_write, + test_vsiwebhdfs_unlink, + test_vsiwebhdfs_mkdir_rmdir, + test_vsiwebhdfs_stop_webserver, + test_vsiwebhdfs_cleanup] gdaltest_list_extra = [vsiwebhdfs_extra_1] @@ -726,6 +726,6 @@ def vsiwebhdfs_cleanup(): gdaltest.run_tests(gdaltest_list_extra) else: gdaltest.run_tests( - gdaltest_list + gdaltest_list_extra + [vsiwebhdfs_cleanup]) + gdaltest_list + gdaltest_list_extra + [test_vsiwebhdfs_cleanup]) sys.exit(gdaltest.summarize()) diff --git a/autotest/gcore/vsizip.py b/autotest/gcore/vsizip.py index a96ae08942e9..81863b6cf737 100755 --- a/autotest/gcore/vsizip.py +++ b/autotest/gcore/vsizip.py @@ -40,7 +40,7 @@ # Test writing a ZIP with multiple files and directories -def vsizip_1(): +def test_vsizip_1(): # We can keep the handle open during all the ZIP writing hZIP = gdal.VSIFOpenL("/vsizip/vsimem/test.zip", "wb") @@ -222,7 +222,7 @@ def vsizip_1(): # Test writing 2 files in the ZIP by closing it completely between the 2 -def vsizip_2(): +def test_vsizip_2(): zip_name = '/vsimem/test2.zip' @@ -297,7 +297,7 @@ def vsizip_2(): ############################################################################### # Test opening in write mode a file inside a zip archive whose content has been listed before (testcase for fix of r22625) -def vsizip_3(): +def test_vsizip_3(): fmain = gdal.VSIFOpenL("/vsizip/vsimem/test3.zip", "wb") @@ -330,7 +330,7 @@ def vsizip_3(): # Test ReadRecursive on valid zip -def vsizip_4(): +def test_vsizip_4(): # read recursive and validate content res = gdal.ReadDirRecursive("/vsizip/data/testzip.zip") @@ -350,7 +350,7 @@ def vsizip_4(): # Test ReadRecursive on deep zip -def vsizip_5(): +def test_vsizip_5(): # make file in memory fmain = gdal.VSIFOpenL('/vsizip/vsimem/bigdepthzip.zip', 'wb') @@ -386,7 +386,7 @@ def vsizip_5(): # Test writing 2 files with same name in a ZIP (#4785) -def vsizip_6(): +def test_vsizip_6(): # Maintain ZIP file opened fmain = gdal.VSIFOpenL("/vsizip/vsimem/test6.zip", "wb") @@ -435,7 +435,7 @@ def vsizip_6(): # Test that we use the extended field for UTF-8 filenames (#5361). -def vsizip_7(): +def test_vsizip_7(): content = gdal.ReadDir("/vsizip/data/cp866_plus_utf8.zip") ok = 0 @@ -458,7 +458,7 @@ def vsizip_7(): # Basic test for ZIP64 support (5 GB file that compresses in less than 4 GB) -def vsizip_8(): +def test_vsizip_8(): if gdal.VSIStatL('/vsizip/vsizip/data/zero.bin.zip.zip/zero.bin.zip').size != 5000 * 1000 * 1000 + 1: return 'fail' @@ -469,7 +469,7 @@ def vsizip_8(): # Basic test for ZIP64 support (5 GB file that is stored) -def vsizip_9(): +def test_vsizip_9(): if gdal.VSIStatL('/vsizip//vsisparse/data/zero_stored.bin.xml.zip/zero.bin').size != 5000 * 1000 * 1000 + 1: gdaltest.post_reason('fail') @@ -501,7 +501,7 @@ def vsizip_9(): # Test that we recode filenames in ZIP (#5361) -def vsizip_10(): +def test_vsizip_10(): gdal.SetConfigOption('CPL_ZIP_ENCODING', 'CP866') content = gdal.ReadDir("/vsizip/data/cp866.zip") @@ -529,7 +529,7 @@ def vsizip_10(): # Test that we don't do anything with ZIP with filenames in UTF-8 already (#5361) -def vsizip_11(): +def test_vsizip_11(): content = gdal.ReadDir("/vsizip/data/utf8.zip") ok = 0 @@ -552,7 +552,7 @@ def vsizip_11(): # Test changing the content of a zip file (#6005) -def vsizip_12(): +def test_vsizip_12(): fmain = gdal.VSIFOpenL("/vsizip/vsimem/vsizip_12_src1.zip", "wb") f = gdal.VSIFOpenL("/vsizip/vsimem/vsizip_12_src1.zip/foo.bar", "wb") @@ -605,7 +605,7 @@ def vsizip_12(): # Test ReadDir() truncation -def vsizip_13(): +def test_vsizip_13(): fmain = gdal.VSIFOpenL("/vsizip/vsimem/vsizip_13.zip", "wb") for i in range(10): @@ -631,7 +631,7 @@ def vsizip_13(): # Test that we can recode filenames in ZIP when writing (#6631) -def vsizip_14(): +def test_vsizip_14(): fmain = gdal.VSIFOpenL('/vsizip//vsimem/vsizip_14.zip', 'wb') try: @@ -666,7 +666,7 @@ def vsizip_14(): # Test multithreaded compression -def vsizip_multi_thread(): +def test_vsizip_multi_thread(): with gdaltest.config_options({'GDAL_NUM_THREADS': 'ALL_CPUS', 'CPL_VSIL_DEFLATE_CHUNK_SIZE': '32K'}): @@ -699,7 +699,7 @@ def vsizip_multi_thread(): # Test multithreaded compression, below the threshold where it triggers -def vsizip_multi_thread_below_threshold(): +def test_vsizip_multi_thread_below_threshold(): with gdaltest.config_options({'GDAL_NUM_THREADS': 'ALL_CPUS'}): fmain = gdal.VSIFOpenL('/vsizip//vsimem/vsizip_multi_thread.zip', 'wb') @@ -726,7 +726,7 @@ def vsizip_multi_thread_below_threshold(): # data stream < 4 GB -def vsizip_create_zip64(): +def test_vsizip_create_zip64(): if not gdaltest.run_slow_tests(): return 'skip' @@ -769,7 +769,7 @@ def vsizip_create_zip64(): # Test creating ZIP64 file: compressed data stream > 4 GB -def vsizip_create_zip64_stream_larger_than_4G(): +def test_vsizip_create_zip64_stream_larger_than_4G(): if not gdaltest.run_slow_tests(): return 'skip' @@ -811,7 +811,7 @@ def vsizip_create_zip64_stream_larger_than_4G(): ############################################################################### -def vsizip_byte_zip64_local_header_zeroed(): +def test_vsizip_byte_zip64_local_header_zeroed(): size = gdal.VSIStatL('/vsizip/data/byte_zip64_local_header_zeroed.zip/byte.tif').size if size != 736: @@ -821,25 +821,25 @@ def vsizip_byte_zip64_local_header_zeroed(): return 'success' -gdaltest_list = [vsizip_1, - vsizip_2, - vsizip_3, - vsizip_4, - vsizip_5, - vsizip_6, - vsizip_7, - vsizip_8, - vsizip_9, - vsizip_10, - vsizip_11, - vsizip_12, - vsizip_13, - vsizip_14, - vsizip_multi_thread, - vsizip_multi_thread_below_threshold, - vsizip_create_zip64, - vsizip_create_zip64_stream_larger_than_4G, - vsizip_byte_zip64_local_header_zeroed, +gdaltest_list = [test_vsizip_1, + test_vsizip_2, + test_vsizip_3, + test_vsizip_4, + test_vsizip_5, + test_vsizip_6, + test_vsizip_7, + test_vsizip_8, + test_vsizip_9, + test_vsizip_10, + test_vsizip_11, + test_vsizip_12, + test_vsizip_13, + test_vsizip_14, + test_vsizip_multi_thread, + test_vsizip_multi_thread_below_threshold, + test_vsizip_create_zip64, + test_vsizip_create_zip64_stream_larger_than_4G, + test_vsizip_byte_zip64_local_header_zeroed, ] diff --git a/autotest/gdrivers/aaigrid.py b/autotest/gdrivers/aaigrid.py index 01e9271ff88b..89ee33e4c603 100755 --- a/autotest/gdrivers/aaigrid.py +++ b/autotest/gdrivers/aaigrid.py @@ -42,7 +42,7 @@ # Perform simple read test. -def aaigrid_1(): +def test_aaigrid_1(): tst = gdaltest.GDALTest('aaigrid', 'pixel_per_line.asc', 1, 1123) return tst.testOpen() @@ -51,7 +51,7 @@ def aaigrid_1(): # Verify some auxiliary data. -def aaigrid_2(): +def test_aaigrid_2(): ds = gdal.Open('data/pixel_per_line.asc') @@ -82,7 +82,7 @@ def aaigrid_2(): ############################################################################### # Test reading a file where decimal separator is comma (#3668) -def aaigrid_comma(): +def test_aaigrid_comma(): ds = gdal.Open('data/pixel_per_line_comma.asc') @@ -112,7 +112,7 @@ def aaigrid_comma(): # Create simple copy and check. -def aaigrid_3(): +def test_aaigrid_3(): tst = gdaltest.GDALTest('AAIGRID', 'byte.tif', 1, 4672) @@ -124,7 +124,7 @@ def aaigrid_3(): # Read subwindow. Tests the tail recursion problem. -def aaigrid_4(): +def test_aaigrid_4(): tst = gdaltest.GDALTest('aaigrid', 'pixel_per_line.asc', 1, 187, 5, 5, 5, 5) @@ -134,7 +134,7 @@ def aaigrid_4(): # Perform simple read test on mixed-case .PRJ filename -def aaigrid_5(): +def test_aaigrid_5(): # Mixed-case files pair used in the test: # - case_sensitive.ASC @@ -170,7 +170,7 @@ def aaigrid_5(): # Verify data type determination from type of nodata -def aaigrid_6(): +def test_aaigrid_6(): ds = gdal.Open('data/nodata_float.asc') @@ -189,7 +189,7 @@ def aaigrid_6(): # Verify data type determination from type of nodata -def aaigrid_6bis(): +def test_aaigrid_6bis(): ds = gdal.Open('data/nodata_int.asc') @@ -208,7 +208,7 @@ def aaigrid_6bis(): # Verify writing files with non-square pixels. -def aaigrid_7(): +def test_aaigrid_7(): tst = gdaltest.GDALTest('AAIGRID', 'nonsquare.vrt', 1, 12481) @@ -218,7 +218,7 @@ def aaigrid_7(): ############################################################################### # Test creating an in memory copy. -def aaigrid_8(): +def test_aaigrid_8(): tst = gdaltest.GDALTest('AAIGRID', 'byte.tif', 1, 4672) @@ -228,7 +228,7 @@ def aaigrid_8(): ############################################################################### # Test DECIMAL_PRECISION creation option -def aaigrid_9(): +def test_aaigrid_9(): ds = gdal.Open('data/float32.bil') ds2 = gdal.GetDriverByName('AAIGRID').CreateCopy('tmp/aaigrid.tmp', ds, options=['DECIMAL_PRECISION=2']) @@ -245,7 +245,7 @@ def aaigrid_9(): # Test AAIGRID_DATATYPE configuration option and DATATYPE open options -def aaigrid_10(): +def test_aaigrid_10(): # By default detected as 32bit float ds = gdal.Open('data/float64.asc') @@ -295,7 +295,7 @@ def aaigrid_10(): # Test SIGNIFICANT_DIGITS creation option (same as DECIMAL_PRECISION test) -def aaigrid_11(): +def test_aaigrid_11(): ds = gdal.Open('data/float32.bil') ds2 = gdal.GetDriverByName('AAIGRID').CreateCopy('tmp/aaigrid.tmp', ds, options=['SIGNIFICANT_DIGITS=2']) @@ -312,7 +312,7 @@ def aaigrid_11(): # Test no data is written to correct precision with DECIMAL_PRECISION. -def aaigrid_12(): +def test_aaigrid_12(): ds = gdal.Open('data/nodata_float.asc') ds2 = gdal.GetDriverByName('AAIGRID').CreateCopy('tmp/aaigrid.tmp', ds, @@ -341,7 +341,7 @@ def aaigrid_12(): # Test no data is written to correct precision WITH SIGNIFICANT_DIGITS. -def aaigrid_13(): +def test_aaigrid_13(): ds = gdal.Open('data/nodata_float.asc') ds2 = gdal.GetDriverByName('AAIGRID').CreateCopy('tmp/aaigrid.tmp', ds, @@ -370,7 +370,7 @@ def aaigrid_13(): # Test fix for #6060 -def aaigrid_14(): +def test_aaigrid_14(): ds = gdal.Open('data/byte.tif') mem_ds = gdal.GetDriverByName('MEM').Create('', 20, 20, 1, gdal.GDT_Float32) @@ -395,7 +395,7 @@ def aaigrid_14(): # Test Float64 detection when nodata = DBL_MIN -def aaigrid_15(): +def test_aaigrid_15(): gdal.FileFromMemBuffer('/vsimem/aaigrid_15.asc', """ncols 4 nrows 1 @@ -420,23 +420,23 @@ def aaigrid_15(): gdaltest_list = [ - aaigrid_1, - aaigrid_2, - aaigrid_comma, - aaigrid_3, - aaigrid_4, - aaigrid_5, - aaigrid_6, - aaigrid_6bis, - aaigrid_7, - aaigrid_8, - aaigrid_9, - aaigrid_10, - aaigrid_11, - aaigrid_12, - aaigrid_13, - aaigrid_14, - aaigrid_15] + test_aaigrid_1, + test_aaigrid_2, + test_aaigrid_comma, + test_aaigrid_3, + test_aaigrid_4, + test_aaigrid_5, + test_aaigrid_6, + test_aaigrid_6bis, + test_aaigrid_7, + test_aaigrid_8, + test_aaigrid_9, + test_aaigrid_10, + test_aaigrid_11, + test_aaigrid_12, + test_aaigrid_13, + test_aaigrid_14, + test_aaigrid_15] if __name__ == '__main__': diff --git a/autotest/gdrivers/ace2.py b/autotest/gdrivers/ace2.py index 59689598d8c7..be61f932cae4 100755 --- a/autotest/gdrivers/ace2.py +++ b/autotest/gdrivers/ace2.py @@ -38,7 +38,7 @@ # Test a fake ACE2 dataset -def ace2_1(): +def test_ace2_1(): f = gdal.VSIFOpenL('/vsimem/45N015E_5M.ACE2', 'wb') gdal.VSIFSeekL(f, 180 * 180 * 4 - 1, 0) @@ -66,7 +66,7 @@ def ace2_1(): gdaltest_list = [ - ace2_1] + test_ace2_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/adrg.py b/autotest/gdrivers/adrg.py index 56ee3499b10a..e61f8017f0ef 100755 --- a/autotest/gdrivers/adrg.py +++ b/autotest/gdrivers/adrg.py @@ -41,7 +41,7 @@ # Read test of simple byte reference data. -def adrg_read_gen(): +def test_adrg_read_gen(): tst = gdaltest.GDALTest('ADRG', 'SMALL_ADRG/ABCDEF01.GEN', 1, 62833) return tst.testOpen() @@ -50,7 +50,7 @@ def adrg_read_gen(): # Read test of simple byte reference data by the TRANSH01.THF file . -def adrg_read_transh(): +def test_adrg_read_transh(): tst = gdaltest.GDALTest('ADRG', 'SMALL_ADRG/TRANSH01.THF', 1, 62833) return tst.testOpen() @@ -59,7 +59,7 @@ def adrg_read_transh(): # Read test of simple byte reference data by a subdataset file -def adrg_read_subdataset_img(): +def test_adrg_read_subdataset_img(): tst = gdaltest.GDALTest('ADRG', 'ADRG:data/SMALL_ADRG/ABCDEF01.GEN,data/SMALL_ADRG/ABCDEF01.IMG', 1, 62833, filename_absolute=1) return tst.testOpen() @@ -68,7 +68,7 @@ def adrg_read_subdataset_img(): # Test copying. -def adrg_copy(): +def test_adrg_copy(): drv = gdal.GetDriverByName('ADRG') srcds = gdal.Open('data/SMALL_ADRG/ABCDEF01.GEN') @@ -91,7 +91,7 @@ def adrg_copy(): # Test creating a fake 2 subdataset image and reading it. -def adrg_2subdatasets(): +def test_adrg_2subdatasets(): drv = gdal.GetDriverByName('ADRG') srcds = gdal.Open('data/SMALL_ADRG/ABCDEF01.GEN') @@ -135,7 +135,7 @@ def adrg_2subdatasets(): # Test creating an in memory copy. -def adrg_copy_vsimem(): +def test_adrg_copy_vsimem(): drv = gdal.GetDriverByName('ADRG') srcds = gdal.Open('data/SMALL_ADRG/ABCDEF01.GEN') @@ -169,7 +169,7 @@ def adrg_copy_vsimem(): # Test reading a fake North Polar dataset (#6560) -def adrg_zna_9(): +def test_adrg_zna_9(): ds = gdal.Open('data/SMALL_ADRG_ZNA9/ABCDEF01.GEN') expected_gt = (-307675.73602473765, 100.09145391818853, 0.0, -179477.5051066006, 0.0, -100.09145391818853) @@ -190,7 +190,7 @@ def adrg_zna_9(): # Test reading a fake South Polar dataset (#6560) -def adrg_zna_18(): +def test_adrg_zna_18(): ds = gdal.Open('data/SMALL_ADRG_ZNA18/ABCDEF01.GEN') expected_gt = (-307675.73602473765, 100.09145391818853, 0.0, 179477.5051066006, 0.0, -100.09145391818853) @@ -210,14 +210,14 @@ def adrg_zna_18(): ############################################################################### gdaltest_list = [ - adrg_read_gen, - adrg_read_transh, - adrg_read_subdataset_img, - adrg_copy, - adrg_2subdatasets, - adrg_copy_vsimem, - adrg_zna_9, - adrg_zna_18] + test_adrg_read_gen, + test_adrg_read_transh, + test_adrg_read_subdataset_img, + test_adrg_copy, + test_adrg_2subdatasets, + test_adrg_copy_vsimem, + test_adrg_zna_9, + test_adrg_zna_18] if __name__ == '__main__': diff --git a/autotest/gdrivers/aigrid.py b/autotest/gdrivers/aigrid.py index 4fa1f4cc0290..09ce6c564407 100755 --- a/autotest/gdrivers/aigrid.py +++ b/autotest/gdrivers/aigrid.py @@ -40,7 +40,7 @@ # Read test of simple byte reference data. -def aigrid_1(): +def test_aigrid_1(): tst = gdaltest.GDALTest('AIG', 'abc3x1', 1, 3) return tst.testOpen() @@ -49,7 +49,7 @@ def aigrid_1(): # Verify some auxiliary data. -def aigrid_2(): +def test_aigrid_2(): ds = gdal.Open('data/abc3x1/prj.adf') @@ -80,7 +80,7 @@ def aigrid_2(): # Verify the colormap, and nodata setting for test file. -def aigrid_3(): +def test_aigrid_3(): ds = gdal.Open('data/abc3x1') cm = ds.GetRasterBand(1).GetRasterColorTable() @@ -101,7 +101,7 @@ def aigrid_3(): # Read test of simple byte reference data with data directory name in all uppercase -def aigrid_4(): +def test_aigrid_4(): tst = gdaltest.GDALTest('AIG', 'ABC3X1UC', 1, 3) return tst.testOpen() @@ -110,7 +110,7 @@ def aigrid_4(): # Verify the colormap, and nodata setting for test file with names of coverage directory and all files in it in all uppercase. Additionally also test for case where clr file resides in parent directory of coverage. -def aigrid_5(): +def test_aigrid_5(): ds = gdal.Open('data/ABC3X1UC') cm = ds.GetRasterBand(1).GetRasterColorTable() @@ -132,7 +132,7 @@ def aigrid_5(): # Verify dataset whose sta.adf is 24 bytes -def aigrid_6(): +def test_aigrid_6(): ds = gdal.Open('data/aigrid_sta_24bytes/teststa') @@ -150,7 +150,7 @@ def aigrid_6(): # Test on real dataset downloaded from http://download.osgeo.org/gdal/data/aig/nzdem -def aigrid_online_1(): +def test_aigrid_online_1(): list_files = ['info/arc.dir', 'info/arc0000.dat', @@ -246,7 +246,7 @@ def aigrid_online_1(): # Test on real dataset downloaded from http://download.osgeo.org/gdal/data/aig/nzdem -def aigrid_online_2(): +def test_aigrid_online_2(): if not gdaltest.download_file('http://download.osgeo.org/gdal/data/aig/ai_bug_6886.zip', 'ai_bug_6886.zip'): return 'skip' @@ -270,14 +270,14 @@ def aigrid_online_2(): gdaltest_list = [ - aigrid_1, - aigrid_2, - aigrid_3, - aigrid_4, - aigrid_5, - aigrid_6, - aigrid_online_1, - aigrid_online_2] + test_aigrid_1, + test_aigrid_2, + test_aigrid_3, + test_aigrid_4, + test_aigrid_5, + test_aigrid_6, + test_aigrid_online_1, + test_aigrid_online_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/arg.py b/autotest/gdrivers/arg.py index 1c48d3569b1c..60feb6b8dc86 100755 --- a/autotest/gdrivers/arg.py +++ b/autotest/gdrivers/arg.py @@ -56,7 +56,7 @@ def encode(fmt, nodata, values): # -def arg_init(): +def test_arg_init(): gdaltest.argDriver = gdal.GetDriverByName('ARG') if gdaltest.argDriver is None: return 'skip' @@ -124,7 +124,7 @@ def arg_init(): return 'success' -def arg_unsupported(): +def test_arg_unsupported(): if gdaltest.argDriver is None: return 'skip' @@ -144,7 +144,7 @@ def arg_unsupported(): return 'success' -def arg_getrastercount(): +def test_arg_getrastercount(): if gdaltest.argDriver is None: return 'skip' @@ -161,7 +161,7 @@ def arg_getrastercount(): return 'success' -def arg_getgeotransform(): +def test_arg_getgeotransform(): if gdaltest.argDriver is None: return 'skip' @@ -185,7 +185,7 @@ def arg_getgeotransform(): return 'success' -def arg_blocksize(): +def test_arg_blocksize(): if gdaltest.argDriver is None: return 'skip' @@ -218,7 +218,7 @@ def arg_blocksize(): return 'success' -def arg_layername(): +def test_arg_layername(): """ The layer name of the ARG in the .json file need not be the name of the .arg file. The original driver enforced this constraint, but that @@ -261,7 +261,7 @@ def arg_layername(): return 'success' -def arg_nodata(): +def test_arg_nodata(): """ Check that the NoData value for int8 images is 128, as per the ARG spec. See ticket #4610 @@ -277,7 +277,7 @@ def arg_nodata(): return 'success' -def arg_byteorder(): +def test_arg_byteorder(): """ Check that a roundtrip from ARG -> GTiff -> ARG has the same binary values. See ticket #4779 @@ -331,7 +331,7 @@ def arg_byteorder(): return 'success' -def arg_destroy(): +def test_arg_destroy(): if gdaltest.argDriver is None: return 'skip' @@ -344,15 +344,15 @@ def arg_destroy(): gdaltest_list = [ - arg_init, - arg_unsupported, - arg_getrastercount, - arg_getgeotransform, - arg_blocksize, - arg_layername, - arg_nodata, - arg_byteorder, - arg_destroy] + test_arg_init, + test_arg_unsupported, + test_arg_getrastercount, + test_arg_getgeotransform, + test_arg_blocksize, + test_arg_layername, + test_arg_nodata, + test_arg_byteorder, + test_arg_destroy] if __name__ == '__main__': diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index 583f5b38bab6..982455194738 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -123,7 +123,7 @@ def test_bag_2(): # Test a southern hemisphere falseNorthing sample file. -def bag_3(): +def test_bag_3(): if gdaltest.bag_drv is None: return 'skip' @@ -159,7 +159,7 @@ def bag_3(): # -def bag_vr_normal(): +def test_bag_vr_normal(): if gdaltest.bag_drv is None: return 'skip' @@ -231,7 +231,7 @@ def bag_vr_normal(): # -def bag_vr_list_supergrids(): +def test_bag_vr_list_supergrids(): if gdaltest.bag_drv is None: return 'skip' @@ -330,7 +330,7 @@ def bag_vr_list_supergrids(): # -def bag_vr_open_supergrids(): +def test_bag_vr_open_supergrids(): if gdaltest.bag_drv is None: return 'skip' @@ -413,7 +413,7 @@ def bag_vr_open_supergrids(): # -def bag_vr_resampled(): +def test_bag_vr_resampled(): if gdaltest.bag_drv is None: return 'skip' @@ -746,7 +746,7 @@ def bag_vr_resampled(): # -def bag_vr_resampled_mask(): +def test_bag_vr_resampled_mask(): if gdaltest.bag_drv is None: return 'skip' @@ -778,7 +778,7 @@ def bag_vr_resampled_mask(): # -def bag_vr_resampled_interpolated(): +def test_bag_vr_resampled_interpolated(): if gdaltest.bag_drv is None: return 'skip' @@ -817,7 +817,7 @@ def bag_vr_resampled_interpolated(): # -def bag_write_single_band(): +def test_bag_write_single_band(): if gdaltest.bag_drv is None: return 'skip' @@ -831,7 +831,7 @@ def bag_write_single_band(): # -def bag_write_two_bands(): +def test_bag_write_two_bands(): if gdaltest.bag_drv is None: return 'skip' @@ -865,7 +865,7 @@ def bag_write_two_bands(): # -def bag_write_south_up(): +def test_bag_write_south_up(): if gdaltest.bag_drv is None: return 'skip' @@ -899,16 +899,16 @@ def bag_write_south_up(): gdaltest_list = [test_bag_2, - bag_3, - bag_vr_normal, - bag_vr_list_supergrids, - bag_vr_open_supergrids, - bag_vr_resampled, - bag_vr_resampled_mask, - bag_vr_resampled_interpolated, - bag_write_single_band, - bag_write_two_bands, - bag_write_south_up, + test_bag_3, + test_bag_vr_normal, + test_bag_vr_list_supergrids, + test_bag_vr_open_supergrids, + test_bag_vr_resampled, + test_bag_vr_resampled_mask, + test_bag_vr_resampled_interpolated, + test_bag_write_single_band, + test_bag_write_two_bands, + test_bag_write_south_up, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/blx.py b/autotest/gdrivers/blx.py index 6a15d171ce64..23d6a163d6c6 100755 --- a/autotest/gdrivers/blx.py +++ b/autotest/gdrivers/blx.py @@ -38,7 +38,7 @@ ############################################################################### # Test reading a little-endian BLX -def blx_1(): +def test_blx_1(): prj = 'WGS84' gt = [20.0004166, 0.0008333, 0.0, 50.0004166, 0.0, -0.0008333] @@ -49,7 +49,7 @@ def blx_1(): ############################################################################### # Test reading a big-endian BLX -def blx_2(): +def test_blx_2(): prj = 'WGS84' gt = [20.0004166, 0.0008333, 0.0, 50.0004166, 0.0, -0.0008333] @@ -60,7 +60,7 @@ def blx_2(): ############################################################################### # Test writing a little-endian BLX -def blx_3(): +def test_blx_3(): tst = gdaltest.GDALTest('BLX', 's4103.xlb', 1, 47024) return tst.testCreateCopy(check_gt=1, check_srs=1) @@ -69,7 +69,7 @@ def blx_3(): ############################################################################### # Test writing a big-endian BLX -def blx_4(): +def test_blx_4(): tst = gdaltest.GDALTest('BLX', 's4103.blx', 1, 47024, options=['BIGENDIAN=YES']) return tst.testCreateCopy(check_gt=1, check_srs=1) @@ -78,7 +78,7 @@ def blx_4(): ############################################################################### # Test overviews -def blx_5(): +def test_blx_5(): ds = gdal.Open('data/s4103.blx') @@ -111,11 +111,11 @@ def blx_5(): gdaltest_list = [ - blx_1, - blx_2, - blx_3, - blx_4, - blx_5 + test_blx_1, + test_blx_2, + test_blx_3, + test_blx_4, + test_blx_5 ] diff --git a/autotest/gdrivers/bsb.py b/autotest/gdrivers/bsb.py index 793fc2e3162a..f081e747cfe7 100755 --- a/autotest/gdrivers/bsb.py +++ b/autotest/gdrivers/bsb.py @@ -38,7 +38,7 @@ # Test driver availability -def bsb_0(): +def test_bsb_0(): gdaltest.bsb_dr = gdal.GetDriverByName('BSB') if gdaltest.bsb_dr is None: return 'skip' @@ -49,7 +49,7 @@ def bsb_0(): # Test Read -def bsb_1(): +def test_bsb_1(): if gdaltest.bsb_dr is None: return 'skip' @@ -61,7 +61,7 @@ def bsb_1(): # Test CreateCopy -def bsb_2(): +def test_bsb_2(): if gdaltest.bsb_dr is None: return 'skip' @@ -80,7 +80,7 @@ def bsb_2(): # --> This is probably not a valid BSB file, but it proves that we can read the index table -def bsb_3(): +def test_bsb_3(): if gdaltest.bsb_dr is None: return 'skip' @@ -94,7 +94,7 @@ def bsb_3(): # adding a 0 character in the middle of line data -def bsb_4(): +def test_bsb_4(): if gdaltest.bsb_dr is None: return 'skip' @@ -106,7 +106,7 @@ def bsb_4(): # Read a truncated BSB (at the level of the written scanline number starting a new row) -def bsb_5(): +def test_bsb_5(): if gdaltest.bsb_dr is None: return 'skip' @@ -122,7 +122,7 @@ def bsb_5(): # Read another truncated BSB (in the middle of row data) -def bsb_6(): +def test_bsb_6(): if gdaltest.bsb_dr is None: return 'skip' @@ -136,13 +136,13 @@ def bsb_6(): gdaltest_list = [ - bsb_0, - bsb_1, - bsb_2, - bsb_3, - bsb_4, - bsb_5, - bsb_6 + test_bsb_0, + test_bsb_1, + test_bsb_2, + test_bsb_3, + test_bsb_4, + test_bsb_5, + test_bsb_6 ] diff --git a/autotest/gdrivers/bt.py b/autotest/gdrivers/bt.py index 3c9afe74beae..4a84a5bbaa04 100755 --- a/autotest/gdrivers/bt.py +++ b/autotest/gdrivers/bt.py @@ -39,7 +39,7 @@ # Test CreateCopy() of int16.tif -def bt_1(): +def test_bt_1(): tst = gdaltest.GDALTest('BT', 'int16.tif', 1, 4672) srs = osr.SpatialReference() @@ -51,7 +51,7 @@ def bt_1(): # Test CreateCopy() of int32.tif -def bt_2(): +def test_bt_2(): tst = gdaltest.GDALTest('BT', 'int32.tif', 1, 4672) srs = osr.SpatialReference() @@ -63,7 +63,7 @@ def bt_2(): # Test CreateCopy() of float32.tif -def bt_3(): +def test_bt_3(): tst = gdaltest.GDALTest('BT', 'float32.tif', 1, 4672) srs = osr.SpatialReference() @@ -75,7 +75,7 @@ def bt_3(): # Test Create() of float32.tif -def bt_4(): +def test_bt_4(): tst = gdaltest.GDALTest('BT', 'float32.tif', 1, 4672) return tst.testCreate(out_bands=1) @@ -84,7 +84,7 @@ def bt_4(): # Test testSetProjection() of float32.tif -def bt_5(): +def test_bt_5(): tst = gdaltest.GDALTest('BT', 'float32.tif', 1, 4672) return tst.testSetProjection() @@ -93,7 +93,7 @@ def bt_5(): # Test testSetGeoTransform() of float32.tif -def bt_6(): +def test_bt_6(): tst = gdaltest.GDALTest('BT', 'float32.tif', 1, 4672) return tst.testSetGeoTransform() @@ -102,7 +102,7 @@ def bt_6(): # Cleanup -def bt_cleanup(): +def test_bt_cleanup(): gdal.Unlink('/vsimem/int16.tif.prj') gdal.Unlink('tmp/int32.tif.prj') @@ -112,13 +112,13 @@ def bt_cleanup(): gdaltest_list = [ - bt_1, - bt_2, - bt_3, - bt_4, - bt_5, - bt_6, - bt_cleanup] + test_bt_1, + test_bt_2, + test_bt_3, + test_bt_4, + test_bt_5, + test_bt_6, + test_bt_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/byn.py b/autotest/gdrivers/byn.py index af67c11cf1b5..c583427d8fa9 100755 --- a/autotest/gdrivers/byn.py +++ b/autotest/gdrivers/byn.py @@ -39,7 +39,7 @@ # Read test of byte file. -def byn_1(): +def test_byn_1(): tst = gdaltest.GDALTest('BYN', 'cgg2013ai08_reduced.byn', 1, 64764) return tst.testOpen() @@ -47,7 +47,7 @@ def byn_1(): ############################################################################### # -def byn_2(): +def test_byn_2(): tst = gdaltest.GDALTest('BYN', 'cgg2013ai08_reduced.byn', 1, 64764) return tst.testCreateCopy(new_filename='tmp/byn_test_2.byn') @@ -56,8 +56,8 @@ def byn_2(): # gdaltest_list = [ - byn_1, - byn_2] + test_byn_1, + test_byn_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/cals.py b/autotest/gdrivers/cals.py index 3c9999ab072e..2c1790f30dbd 100755 --- a/autotest/gdrivers/cals.py +++ b/autotest/gdrivers/cals.py @@ -38,7 +38,7 @@ # Source has no color table -def cals_1(): +def test_cals_1(): tst = gdaltest.GDALTest('CALS', 'small1bit.img', 1, 9907) @@ -48,7 +48,7 @@ def cals_1(): # Source has a color table (0,0,0),(255,255,255) -def cals_2(): +def test_cals_2(): # Has no color table tst = gdaltest.GDALTest('CALS', '../../gcore/data/oddsize1bit.tif', 1, 3883) @@ -59,7 +59,7 @@ def cals_2(): # Source has a color table (255,255,255),(0,0,0) -def cals_3(): +def test_cals_3(): src_ds = gdal.Open('../gcore/data/oddsize1bit.tif') tmp_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_2_tmp.cal', src_ds) @@ -93,7 +93,7 @@ def cals_3(): # Test CreateCopy() error conditions -def cals_4(): +def test_cals_4(): # 0 band src_ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 0) @@ -148,7 +148,7 @@ def cals_4(): # Test PIXEL_PATH & LINE_PROGRESSION metadata item -def cals_5(): +def test_cals_5(): src_ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 1) src_ds.GetRasterBand(1).SetMetadataItem('NBITS', '1', 'IMAGE_STRUCTURE') @@ -173,11 +173,11 @@ def cals_5(): gdaltest_list = [ - cals_1, - cals_2, - cals_3, - cals_4, - cals_5, + test_cals_1, + test_cals_2, + test_cals_3, + test_cals_4, + test_cals_5, ] diff --git a/autotest/gdrivers/ceos.py b/autotest/gdrivers/ceos.py index d7bf9afcbc4a..ae124654e242 100755 --- a/autotest/gdrivers/ceos.py +++ b/autotest/gdrivers/ceos.py @@ -38,7 +38,7 @@ # contains 3 complete scanlines. Bizarre little endian CEOS variant. (#1862) -def ceos_1(): +def test_ceos_1(): tst = gdaltest.GDALTest('CEOS', 'IMAGERY-75K.L-3', 4, 9956, xoff=0, yoff=0, xsize=5932, ysize=3) @@ -46,7 +46,7 @@ def ceos_1(): gdaltest_list = [ - ceos_1] + test_ceos_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/cpg.py b/autotest/gdrivers/cpg.py index cf6ab753275b..34215b1d8e3e 100755 --- a/autotest/gdrivers/cpg.py +++ b/autotest/gdrivers/cpg.py @@ -37,14 +37,14 @@ # Test a fake CPG dataset -def cpg_1(): +def test_cpg_1(): tst = gdaltest.GDALTest('CPG', 'fakecpgSIRC.hdr', 1, 0) return tst.testOpen() gdaltest_list = [ - cpg_1] + test_cpg_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/ctg.py b/autotest/gdrivers/ctg.py index dddff6accde4..4fad78d50419 100755 --- a/autotest/gdrivers/ctg.py +++ b/autotest/gdrivers/ctg.py @@ -38,7 +38,7 @@ # Test a fake CTG dataset -def ctg_1(): +def test_ctg_1(): tst = gdaltest.GDALTest('CTG', 'fake_grid_cell', 1, 21) expected_gt = [421000.0, 200.0, 0.0, 5094400.0, 0.0, -200.0] @@ -84,7 +84,7 @@ def ctg_1(): gdaltest_list = [ - ctg_1] + test_ctg_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/db2.py b/autotest/gdrivers/db2.py index 34999b5e16c8..7648a34d109a 100755 --- a/autotest/gdrivers/db2.py +++ b/autotest/gdrivers/db2.py @@ -45,7 +45,7 @@ # Test if DB2 and tile drivers are available -def gpkg_init(): +def test_gpkg_init(): gdaltest.db2_drv = None @@ -169,7 +169,7 @@ def check_tile_format(out_ds, expected_format, expected_band_count, expected_ct, # Single band, PNG -def gpkg_1(): +def test_gpkg_1(): if gdaltest.db2_drv is None: return 'skip' @@ -224,8 +224,8 @@ def gpkg_1(): gdaltest_list = [ - gpkg_init, - gpkg_1 + test_gpkg_init, + test_gpkg_1 ] # gdaltest_list = [ gpkg_init, gpkg_26, gpkg_cleanup ] if __name__ == '__main__': diff --git a/autotest/gdrivers/derived.py b/autotest/gdrivers/derived.py index 410d0f95cdc0..a98946daf964 100755 --- a/autotest/gdrivers/derived.py +++ b/autotest/gdrivers/derived.py @@ -35,7 +35,7 @@ import gdaltest -def derived_test1(): +def test_derived_test1(): filename = "../gcore/data/cfloat64.tif" gdal.ErrorReset() ds = gdal.Open(filename) @@ -88,7 +88,7 @@ def derived_test1(): return 'success' -def derived_test2(): +def test_derived_test2(): filename = "../gcore/data/cint_sar.tif" gdal.ErrorReset() ds = gdal.Open(filename) @@ -144,7 +144,7 @@ def derived_test2(): # Error cases -def derived_test3(): +def test_derived_test3(): with gdaltest.error_handler(): # Missing filename @@ -183,9 +183,9 @@ def derived_test3(): gdaltest_list = [ - derived_test1, - derived_test2, - derived_test3 + test_derived_test1, + test_derived_test2, + test_derived_test3 ] if __name__ == '__main__': diff --git a/autotest/gdrivers/dimap.py b/autotest/gdrivers/dimap.py index a0724364cab0..60250ee54b60 100755 --- a/autotest/gdrivers/dimap.py +++ b/autotest/gdrivers/dimap.py @@ -40,7 +40,7 @@ # Open and verify a the GCPs and metadata. -def dimap_1(): +def test_dimap_1(): shutil.copy('data/dimap/METADATA.DIM', 'tmp') shutil.copy('data/dimap/IMAGERY.TIF', 'tmp') @@ -99,7 +99,7 @@ def dimap_1(): # Open DIMAP 2 -def dimap_2(): +def test_dimap_2(): for name in ['data/dimap2', 'data/dimap2/VOL_PHR.XML', 'data/dimap2/DIM_foo.XML']: ds = gdal.Open(name) @@ -135,8 +135,8 @@ def dimap_2(): gdaltest_list = [ - dimap_1, - dimap_2] + test_dimap_1, + test_dimap_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/dipex.py b/autotest/gdrivers/dipex.py index cec4ad8283cf..454b921faf66 100755 --- a/autotest/gdrivers/dipex.py +++ b/autotest/gdrivers/dipex.py @@ -37,14 +37,14 @@ # Test a fake DIPex dataset -def dipex_1(): +def test_dipex_1(): tst = gdaltest.GDALTest('DIPEx', 'fakedipex.dat', 1, 1) return tst.testOpen() gdaltest_list = [ - dipex_1] + test_dipex_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/doq1.py b/autotest/gdrivers/doq1.py index 4e1c3bd297da..3dbd3416ddd7 100755 --- a/autotest/gdrivers/doq1.py +++ b/autotest/gdrivers/doq1.py @@ -38,7 +38,7 @@ # Test a fake DOQ1 dataset -def doq1_1(): +def test_doq1_1(): tst = gdaltest.GDALTest('DOQ1', 'fakedoq1.doq', 1, 1) gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -48,7 +48,7 @@ def doq1_1(): gdaltest_list = [ - doq1_1] + test_doq1_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/doq2.py b/autotest/gdrivers/doq2.py index 23b540ec868c..0184f86202f6 100755 --- a/autotest/gdrivers/doq2.py +++ b/autotest/gdrivers/doq2.py @@ -39,7 +39,7 @@ # downloaded from http://edcftp.cr.usgs.gov/pub/data/samples/doq-clr-native.tar.gz -def doq2_1(): +def test_doq2_1(): ds = gdal.Open('data/C3607614_truncated.NWS') @@ -76,7 +76,7 @@ def doq2_1(): gdaltest_list = [ - doq2_1] + test_doq2_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/dted.py b/autotest/gdrivers/dted.py index fd036bc00347..3a32107f6d9c 100755 --- a/autotest/gdrivers/dted.py +++ b/autotest/gdrivers/dted.py @@ -41,7 +41,7 @@ # Perform simple read test. -def dted_1(): +def test_dted_1(): tst = gdaltest.GDALTest('dted', 'n43.dt0', 1, 49187) return tst.testOpen() @@ -50,7 +50,7 @@ def dted_1(): # Verify some auxiliary data. -def dted_2(): +def test_dted_2(): ds = gdal.Open('data/n43.dt0') @@ -84,7 +84,7 @@ def dted_2(): # Create simple copy and check. -def dted_3(): +def test_dted_3(): tst = gdaltest.GDALTest('DTED', 'n43.dt0', 1, 49187) @@ -96,7 +96,7 @@ def dted_3(): # Read subwindow. Tests the tail recursion problem. -def dted_4(): +def test_dted_4(): tst = gdaltest.GDALTest('dted', 'n43.dt0', 1, 305, 5, 5, 5, 5) @@ -106,7 +106,7 @@ def dted_4(): # Test a DTED Level 1 (made from a DTED Level 0) -def dted_5(): +def test_dted_5(): driver = gdal.GetDriverByName("GTiff") ds = driver.Create('tmp/n43.dt1.tif', 1201, 1201, 1, gdal.GDT_Int16) @@ -130,7 +130,7 @@ def dted_5(): # Test a DTED Level 2 (made from a DTED Level 0) -def dted_6(): +def test_dted_6(): driver = gdal.GetDriverByName("GTiff") ds = driver.Create('tmp/n43.dt2.tif', 3601, 3601, 1, gdal.GDT_Int16) @@ -154,7 +154,7 @@ def dted_6(): # Test a WGS72 georeferenced DTED -def dted_7(): +def test_dted_7(): ds = gdal.Open('data/n43_wgs72.dt0') # a warning is issued @@ -176,7 +176,7 @@ def dted_7(): # Test a file whose checksum is corrupted -def dted_8(): +def test_dted_8(): # this will enable DTED_VERIFY_CHECKSUM gdal.SetConfigOption('DTED_VERIFY_CHECKSUM', 'YES') @@ -206,7 +206,7 @@ def dted_8(): # Test a DTED Level 1 above latitude 50 (made from a DTED Level 0) -def dted_9(): +def test_dted_9(): ds = gdal.Open('data/n43.dt0') @@ -245,7 +245,7 @@ def dted_9(): # Test creating an in memory copy. -def dted_10(): +def test_dted_10(): tst = gdaltest.GDALTest('dted', 'n43.dt0', 1, 49187) return tst.testCreateCopy(vsimem=1) @@ -257,7 +257,7 @@ def dted_10(): # inverted. This was fixed in MIL-D-89020 Amendment 1, but some products may # be affected. -def dted_11(): +def test_dted_11(): ds = gdal.Open('data/n43_coord_inverted.dt0') @@ -291,7 +291,7 @@ def dted_11(): # Test a DTED file that begins with a HDR record, and not directly the UHL record (#2951) -def dted_12(): +def test_dted_12(): ds = gdal.Open('data/w118n033_trunc.dt1') if ds is None: @@ -304,7 +304,7 @@ def dted_12(): # a real-world DTED file -def dted_13(): +def test_dted_13(): tst = gdaltest.GDALTest('dted', 'n43_partial_cols.dt0', 1, 56006) return tst.testOpen() @@ -314,7 +314,7 @@ def dted_13(): # case for now. -def dted_14(): +def test_dted_14(): tst = gdaltest.GDALTest('dted', 'n43_sparse_cols.dt0', 1, 56369) return tst.testOpen() @@ -323,7 +323,7 @@ def dted_14(): # Perform simple read test with GDAL_DTED_SINGLE_BLOCK = YES -def dted_15(): +def test_dted_15(): gdal.SetConfigOption('GDAL_DTED_SINGLE_BLOCK', 'YES') tst = gdaltest.GDALTest('dted', 'n43.dt0', 1, 49187) @@ -335,7 +335,7 @@ def dted_15(): # Cleanup. -def dted_cleanup(): +def test_dted_cleanup(): try: os.remove('tmp/n43.dt1.tif') os.remove('tmp/n43.dt1.aux.xml') @@ -352,22 +352,22 @@ def dted_cleanup(): gdaltest_list = [ - dted_1, - dted_2, - dted_3, - dted_4, - dted_5, - dted_6, - dted_7, - dted_8, - dted_9, - dted_10, - dted_11, - dted_12, - dted_13, - dted_14, - dted_15, - dted_cleanup + test_dted_1, + test_dted_2, + test_dted_3, + test_dted_4, + test_dted_5, + test_dted_6, + test_dted_7, + test_dted_8, + test_dted_9, + test_dted_10, + test_dted_11, + test_dted_12, + test_dted_13, + test_dted_14, + test_dted_15, + test_dted_cleanup ] diff --git a/autotest/gdrivers/e00grid.py b/autotest/gdrivers/e00grid.py index 2983daa516bc..800550e75708 100755 --- a/autotest/gdrivers/e00grid.py +++ b/autotest/gdrivers/e00grid.py @@ -38,7 +38,7 @@ # Test a fake E00GRID dataset -def e00grid_1(): +def test_e00grid_1(): tst = gdaltest.GDALTest('E00GRID', 'fake_e00grid.e00', 1, 65359) expected_gt = [500000.0, 1000.0, 0.0, 4000000.0, 0.0, -1000.0] @@ -78,7 +78,7 @@ def e00grid_1(): # Test a fake E00GRID dataset, compressed and with statistics -def e00grid_2(): +def test_e00grid_2(): tst = gdaltest.GDALTest('E00GRID', 'fake_e00grid_compressed.e00', 1, 65347) expected_gt = [500000.0, 1000.0, 0.0, 4000000.0, 0.0, -1000.0] @@ -135,8 +135,8 @@ def e00grid_2(): gdaltest_list = [ - e00grid_1, - e00grid_2] + test_e00grid_1, + test_e00grid_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/ecrgtoc.py b/autotest/gdrivers/ecrgtoc.py index 8e5cde8aff4e..ebd2e3929484 100755 --- a/autotest/gdrivers/ecrgtoc.py +++ b/autotest/gdrivers/ecrgtoc.py @@ -39,7 +39,7 @@ ############################################################################### # Basic test -def ecrgtoc_1(): +def test_ecrgtoc_1(): toc_xml = """ @@ -130,7 +130,7 @@ def ecrgtoc_1(): # Test overviews -def ecrgtoc_2(): +def test_ecrgtoc_2(): ds = gdal.Open('/vsimem/TOC.xml') ds.BuildOverviews('NEAR', [2]) @@ -152,7 +152,7 @@ def ecrgtoc_2(): # Test opening subdataset -def ecrgtoc_3(): +def test_ecrgtoc_3(): # Try different errors for name in ['ECRG_TOC_ENTRY:', @@ -199,7 +199,7 @@ def ecrgtoc_3(): # Test dataset with 3 subdatasets -def ecrgtoc_4(): +def test_ecrgtoc_4(): toc_xml = """ @@ -320,7 +320,7 @@ def ecrgtoc_4(): ############################################################################### -def ecrgtoc_online_1(): +def test_ecrgtoc_online_1(): if not gdaltest.download_file('http://www.falconview.org/trac/FalconView/downloads/17', 'ECRG_Sample.zip'): return 'skip' @@ -357,11 +357,11 @@ def ecrgtoc_online_1(): gdaltest_list = [ - ecrgtoc_1, - ecrgtoc_2, - ecrgtoc_3, - ecrgtoc_4, - ecrgtoc_online_1] + test_ecrgtoc_1, + test_ecrgtoc_2, + test_ecrgtoc_3, + test_ecrgtoc_4, + test_ecrgtoc_online_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/ecw.py b/autotest/gdrivers/ecw.py index 45d58965d84d..8e7a8801456d 100755 --- a/autotest/gdrivers/ecw.py +++ b/autotest/gdrivers/ecw.py @@ -49,9 +49,9 @@ def has_write_support(): if hasattr(gdaltest, 'b_ecw_has_write_support'): return gdaltest.b_ecw_has_write_support gdaltest.b_ecw_has_write_support = False - if ecw_1() != 'success': + if test_ecw_1() != 'success': return False - if ecw_3() == 'success': + if test_ecw_3() == 'success': gdaltest.b_ecw_has_write_support = True try: os.remove('tmp/jrc_out.ecw') @@ -63,7 +63,7 @@ def has_write_support(): # -def ecw_init(): +def test_ecw_init(): gdaltest.deregister_all_jpeg2000_drivers_but('JP2ECW') return 'success' @@ -72,7 +72,7 @@ def ecw_init(): # Verify we have the driver. -def ecw_1(): +def test_ecw_1(): gdaltest.ecw_drv = gdal.GetDriverByName('ECW') gdaltest.jp2ecw_drv = gdal.GetDriverByName('JP2ECW') @@ -108,7 +108,7 @@ def ecw_1(): # Verify various information about our test image. -def ecw_2(): +def test_ecw_2(): if gdaltest.ecw_drv is None: return 'skip' @@ -146,7 +146,7 @@ def ecw_2(): # Verify that an write the imagery out to a new file. -def ecw_3(): +def test_ecw_3(): if gdaltest.ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -173,7 +173,7 @@ def ecw_3(): # Verify various information about our generated image. -def ecw_4(): +def test_ecw_4(): if gdaltest.ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -219,7 +219,7 @@ def ecw_4(): # Now try writing a JPEG2000 compressed version of the same with the ECW driver -def ecw_5(): +def test_ecw_5(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -239,7 +239,7 @@ def ecw_5(): # Verify various information about our generated image. -def ecw_6(): +def test_ecw_6(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -296,7 +296,7 @@ def ecw_6(): # Write the same image to NITF. -def ecw_7(): +def test_ecw_7(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -311,7 +311,7 @@ def ecw_7(): # Verify various information about our generated image. -def ecw_8(): +def test_ecw_8(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -350,7 +350,7 @@ def ecw_8(): # Try writing 16bit JP2 file directly using Create(). -def ecw_9(): +def test_ecw_9(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -377,7 +377,7 @@ def ecw_9(): # Verify previous 16bit file. -def ecw_10(): +def test_ecw_10(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -413,7 +413,7 @@ def ecw_10(): # Test direct creation of an NITF/JPEG2000 file. -def ecw_11(): +def test_ecw_11(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -442,7 +442,7 @@ def ecw_11(): # Verify previous file -def ecw_12(): +def test_ecw_12(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -482,7 +482,7 @@ def ecw_12(): # type and select an altered band list. -def ecw_13(): +def test_ecw_13(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -513,7 +513,7 @@ def ecw_13(): # Write out image with GCPs. -def ecw_14(): +def test_ecw_14(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -526,7 +526,7 @@ def ecw_14(): # Verify various information about our generated image. -def ecw_15(): +def test_ecw_15(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -560,7 +560,7 @@ def ecw_15(): # Open byte.jp2 -def ecw_16(): +def test_ecw_16(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -593,7 +593,7 @@ def ecw_16(): # Open int16.jp2 -def ecw_17(): +def test_ecw_17(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -621,7 +621,7 @@ def ecw_17(): # Open byte.jp2.gz (test use of the VSIL API) -def ecw_18(): +def test_ecw_18(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -654,7 +654,7 @@ def ecw_18(): # Test a JPEG2000 with the 3 bands having 13bit depth and the 4th one 1 bit -def ecw_19(): +def test_ecw_19(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -679,7 +679,7 @@ def ecw_19(): # are as expected. -def ecw_20(): +def test_ecw_20(): if gdaltest.ecw_drv is None: return 'skip' @@ -722,7 +722,7 @@ def ecw_20(): # line by line. -def ecw_21(): +def test_ecw_21(): if gdaltest.ecw_drv is None: return 'skip' @@ -752,7 +752,7 @@ def ecw_21(): # ECW file. -def ecw_22(): +def test_ecw_22(): if gdaltest.ecw_drv is None: return 'skip' @@ -774,7 +774,7 @@ def ecw_22(): # preserving the ecw derived georeferencing. -def ecw_23(): +def test_ecw_23(): if gdaltest.ecw_drv is None: return 'skip' @@ -811,7 +811,7 @@ def ecw_23(): # Test that we can alter geotransform on existing ECW -def ecw_24(): +def test_ecw_24(): if gdaltest.ecw_drv is None: return 'skip' @@ -861,7 +861,7 @@ def ecw_24(): # Test that we can alter projection info on existing ECW (through SetProjection()) -def ecw_25(): +def test_ecw_25(): if gdaltest.ecw_drv is None: return 'skip' @@ -932,7 +932,7 @@ def ecw_25(): # Test that we can alter projection info on existing ECW (through SetMetadataItem()) -def ecw_26(): +def test_ecw_26(): if gdaltest.ecw_drv is None: return 'skip' @@ -1006,7 +1006,7 @@ def ecw_26(): # Check that we can use .j2w world files (#4651) -def ecw_27(): +def test_ecw_27(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -1032,7 +1032,7 @@ def ecw_27(): # Check picking use case -def ecw_28(): +def test_ecw_28(): if gdaltest.ecw_drv is None: return 'skip' @@ -1062,7 +1062,7 @@ def ecw_28(): # Test supersampling -def ecw_29(): +def test_ecw_29(): if gdaltest.ecw_drv is None: return 'skip' @@ -1133,7 +1133,7 @@ def ecw_29(): # Test IReadBlock() -def ecw_30(): +def test_ecw_30(): if gdaltest.ecw_drv is None: return 'skip' @@ -1153,7 +1153,7 @@ def ecw_30(): # Test async reader interface ( SDK >= 4.x ) -def ecw_31(): +def test_ecw_31(): if gdaltest.ecw_drv is None: return 'skip' @@ -1203,7 +1203,7 @@ def ecw_31(): # It ignores the content of panBandMap. (#4234) -def ecw_32(): +def test_ecw_32(): if gdaltest.ecw_drv is None: return 'skip' @@ -1247,7 +1247,7 @@ def ecw_32(): # Test heuristics that detect successive band reading pattern -def ecw_33(): +def test_ecw_33(): if gdaltest.ecw_drv is None: return 'skip' @@ -1305,7 +1305,7 @@ def ecw_33(): # Check bugfix for #5262 -def ecw_33_bis(): +def test_ecw_33_bis(): if gdaltest.ecw_drv is None: return 'skip' @@ -1348,7 +1348,7 @@ def ecw_33_bis(): # Verify that an write the imagery out to a new ecw file. Source file is 16 bit. -def ecw_34(): +def test_ecw_34(): if gdaltest.ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -1380,7 +1380,7 @@ def ecw_34(): # Verify that an write the imagery out to a new JP2 file. Source file is 16 bit. -def ecw_35(): +def test_ecw_35(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -1403,7 +1403,7 @@ def ecw_35(): # Make sure that band descriptions are preserved for version 3 ECW files. -def ecw_36(): +def test_ecw_36(): if gdaltest.ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -1468,7 +1468,7 @@ def ecw_36(): # color space set implicitly to sRGB. -def ecw_37(): +def test_ecw_37(): if gdaltest.ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -1511,7 +1511,7 @@ def ecw_37(): # Check opening unicode files. -def ecw_38(): +def test_ecw_38(): if gdaltest.ecw_drv is None: return 'skip' @@ -1548,7 +1548,7 @@ def ecw_38(): ############################################################################### # Check writing histograms. -def ecw_39(): +def test_ecw_39(): if gdaltest.ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -1579,7 +1579,7 @@ def ecw_39(): # Check reading a ECW v3 file -def ecw_40(): +def test_ecw_40(): if gdaltest.ecw_drv is None: return 'skip' @@ -1636,7 +1636,7 @@ def ecw_40(): # Check generating statistics & histogram for a ECW v3 file -def ecw_41(): +def test_ecw_41(): if gdaltest.ecw_drv is None or gdaltest.ecw_drv.major_version < 5: return 'skip' @@ -1750,7 +1750,7 @@ def ecw_41(): # Test setting/unsetting file metadata of a ECW v3 file -def ecw_42(): +def test_ecw_42(): if gdaltest.ecw_drv is None or gdaltest.ecw_drv.major_version < 5: return 'skip' @@ -1837,7 +1837,7 @@ def ecw_42(): # Note: only works on reversible files like this one -def ecw_43(): +def test_ecw_43(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -1888,7 +1888,7 @@ def ecw_43(): # Test metadata retrieval from JP2 file -def ecw_44(): +def test_ecw_44(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -1941,7 +1941,7 @@ def RemoveDriverMetadata(md): return md -def ecw_45(): +def test_ecw_45(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -2043,7 +2043,7 @@ def ecw_45(): # Test non nearest upsampling -def ecw_46(): +def test_ecw_46(): if gdaltest.jp2ecw_drv is None or gdaltest.ecw_write == 0: return 'skip' @@ -2077,7 +2077,7 @@ def ecw_46(): # /vsi reading with ECW (#6482) -def ecw_47(): +def test_ecw_47(): if gdaltest.ecw_drv is None: return 'skip' @@ -2114,7 +2114,7 @@ def ecw_47(): # Test "Upward" orientation is forced by default -def ecw_48(): +def test_ecw_48(): if gdaltest.ecw_drv is None: return 'skip' @@ -2140,7 +2140,7 @@ def ecw_48(): # Test "Upward" orientation can be overridden with ECW_ALWAYS_UPWARD=FALSE -def ecw_49(): +def test_ecw_49(): if gdaltest.ecw_drv is None: return 'skip' @@ -2163,7 +2163,7 @@ def ecw_49(): ############################################################################### -def ecw_online_1(): +def test_ecw_online_1(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -2185,7 +2185,7 @@ def ecw_online_1(): ############################################################################### -def ecw_online_2(): +def test_ecw_online_2(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -2253,7 +2253,7 @@ def ecw_online_3(): ############################################################################### -def ecw_online_4(): +def test_ecw_online_4(): if gdaltest.jp2ecw_drv is None: return 'skip' @@ -2292,7 +2292,7 @@ def ecw_online_4(): ############################################################################### -def ecw_online_5(): +def test_ecw_online_5(): if gdaltest.ecw_drv is None: return 'skip' @@ -2326,7 +2326,7 @@ def ecw_online_5(): # and in particular the .ecw extension, to make the ECW driver happy -def ecw_online_6(): +def test_ecw_online_6(): if gdaltest.ecw_drv is None: return 'skip' @@ -2366,7 +2366,7 @@ def ecw_online_6(): # ECWv2 file with alpha channel (#6028) -def ecw_online_7(): +def test_ecw_online_7(): if gdaltest.ecw_drv is None: return 'skip' @@ -2388,7 +2388,7 @@ def ecw_online_7(): ############################################################################### -def ecw_cleanup(): +def test_ecw_cleanup(): # gdaltest.clean_tmp() @@ -2475,65 +2475,65 @@ def ecw_cleanup(): gdaltest_list = [ - ecw_init, - ecw_1, - ecw_2, - ecw_3, - ecw_4, - ecw_5, - ecw_6, - ecw_7, - ecw_8, - ecw_9, - ecw_10, - ecw_11, - ecw_12, - ecw_13, - ecw_14, - ecw_15, - ecw_16, - ecw_17, - ecw_18, - ecw_19, - ecw_20, - ecw_21, - ecw_22, - ecw_23, - ecw_24, - ecw_25, - ecw_26, - ecw_27, - ecw_28, - ecw_29, - ecw_30, - ecw_31, - ecw_32, - ecw_33, - ecw_33_bis, - ecw_34, - ecw_35, - ecw_36, - ecw_37, - ecw_38, - ecw_39, - ecw_40, - ecw_41, - ecw_42, - ecw_43, - ecw_44, - ecw_45, - ecw_46, - ecw_47, - ecw_48, - ecw_49, - ecw_online_1, - ecw_online_2, + test_ecw_init, + test_ecw_1, + test_ecw_2, + test_ecw_3, + test_ecw_4, + test_ecw_5, + test_ecw_6, + test_ecw_7, + test_ecw_8, + test_ecw_9, + test_ecw_10, + test_ecw_11, + test_ecw_12, + test_ecw_13, + test_ecw_14, + test_ecw_15, + test_ecw_16, + test_ecw_17, + test_ecw_18, + test_ecw_19, + test_ecw_20, + test_ecw_21, + test_ecw_22, + test_ecw_23, + test_ecw_24, + test_ecw_25, + test_ecw_26, + test_ecw_27, + test_ecw_28, + test_ecw_29, + test_ecw_30, + test_ecw_31, + test_ecw_32, + test_ecw_33, + test_ecw_33_bis, + test_ecw_34, + test_ecw_35, + test_ecw_36, + test_ecw_37, + test_ecw_38, + test_ecw_39, + test_ecw_40, + test_ecw_41, + test_ecw_42, + test_ecw_43, + test_ecw_44, + test_ecw_45, + test_ecw_46, + test_ecw_47, + test_ecw_48, + test_ecw_49, + test_ecw_online_1, + test_ecw_online_2, # JTO this test does not make sense. It tests difference between two files pixel by pixel but compression is lossy# ecw_online_3, - ecw_online_4, - ecw_online_5, - ecw_online_6, - ecw_online_7, - ecw_cleanup] + test_ecw_online_4, + test_ecw_online_5, + test_ecw_online_6, + test_ecw_online_7, + test_ecw_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/eedai.py b/autotest/gdrivers/eedai.py index 6778ec4f5944..d6fcf036cc96 100644 --- a/autotest/gdrivers/eedai.py +++ b/autotest/gdrivers/eedai.py @@ -44,7 +44,7 @@ # Find EEDAI driver -def eedai_1(): +def test_eedai_1(): gdaltest.eedai_drv = gdal.GetDriverByName('EEDAI') @@ -66,7 +66,7 @@ def eedai_1(): # Nominal case -def eedai_2(): +def test_eedai_2(): if gdaltest.eedai_drv is None: return 'skip' @@ -366,7 +366,7 @@ def eedai_2(): # Test OAuth2 with ServiceAccount -def eedai_3(): +def test_eedai_3(): if gdaltest.eedai_drv is None: return 'skip' @@ -419,7 +419,7 @@ def eedai_3(): # Test OAuth2 with GOOGLE_APPLICATION_CREDENTIALS -def eedai_GOOGLE_APPLICATION_CREDENTIALS(): +def test_eedai_GOOGLE_APPLICATION_CREDENTIALS(): if gdaltest.eedai_drv is None: return 'skip' @@ -477,7 +477,7 @@ def eedai_GOOGLE_APPLICATION_CREDENTIALS(): # Read credentials from simulated GCE instance -def eedai_gce_credentials(): +def test_eedai_gce_credentials(): if gdaltest.eedai_drv is None: return 'skip' @@ -546,7 +546,7 @@ def method(request): # Request in PNG mode -def eedai_4(): +def test_eedai_4(): if gdaltest.eedai_drv is None: return 'skip' @@ -695,7 +695,7 @@ def eedai_4(): # Request in AUTO GTIFF mode -def eedai_geotiff(): +def test_eedai_geotiff(): if gdaltest.eedai_drv is None: return 'skip' @@ -761,7 +761,7 @@ def eedai_geotiff(): # -def eedai_real_service(): +def test_eedai_real_service(): if gdaltest.eedai_drv is None: return 'skip' @@ -810,7 +810,7 @@ def eedai_real_service(): # -def eedai_cleanup(): +def test_eedai_cleanup(): if gdaltest.eedai_drv is None: return 'skip' @@ -831,15 +831,15 @@ def eedai_cleanup(): gdaltest_list = [ - eedai_1, - eedai_2, - eedai_3, - eedai_GOOGLE_APPLICATION_CREDENTIALS, - eedai_gce_credentials, - eedai_4, - eedai_geotiff, - eedai_cleanup, - eedai_real_service, + test_eedai_1, + test_eedai_2, + test_eedai_3, + test_eedai_GOOGLE_APPLICATION_CREDENTIALS, + test_eedai_gce_credentials, + test_eedai_4, + test_eedai_geotiff, + test_eedai_cleanup, + test_eedai_real_service, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/ehdr.py b/autotest/gdrivers/ehdr.py index a49bb466449d..1b797eb3fc10 100755 --- a/autotest/gdrivers/ehdr.py +++ b/autotest/gdrivers/ehdr.py @@ -43,7 +43,7 @@ # 16bit image. -def ehdr_1(): +def test_ehdr_1(): tst = gdaltest.GDALTest('EHDR', 'rgba16.png', 2, 2042) @@ -53,7 +53,7 @@ def ehdr_1(): # 8bit with geotransform and projection check. -def ehdr_2(): +def test_ehdr_2(): tst = gdaltest.GDALTest('EHDR', 'byte.tif', 1, 4672) @@ -63,7 +63,7 @@ def ehdr_2(): # 32bit floating point (read, and createcopy). -def ehdr_3(): +def test_ehdr_3(): tst = gdaltest.GDALTest('EHDR', 'float32.bil', 1, 27) @@ -73,7 +73,7 @@ def ehdr_3(): # create dataset with a nodata value and a color table. -def ehdr_4(): +def test_ehdr_4(): drv = gdal.GetDriverByName('EHdr') ds = drv.Create('tmp/test_4.bil', 200, 100, 1, gdal.GDT_Byte) @@ -106,7 +106,7 @@ def ehdr_4(): # verify last dataset's colortable and nodata value. -def ehdr_5(): +def test_ehdr_5(): ds = gdal.Open('tmp/test_4.bil') band = ds.GetRasterBand(1) @@ -136,7 +136,7 @@ def ehdr_5(): # Test creating an in memory copy. -def ehdr_6(): +def test_ehdr_6(): tst = gdaltest.GDALTest('EHDR', 'float32.bil', 1, 27) @@ -146,7 +146,7 @@ def ehdr_6(): # 32bit integer (read, and createcopy). -def ehdr_7(): +def test_ehdr_7(): tst = gdaltest.GDALTest('EHDR', 'int32.tif', 1, 4672) @@ -156,7 +156,7 @@ def ehdr_7(): # Test signed 8bit integer support. (#2717) -def ehdr_8(): +def test_ehdr_8(): drv = gdal.GetDriverByName('EHDR') src_ds = gdal.Open('data/8s.vrt') @@ -188,7 +188,7 @@ def ehdr_8(): # value. -def ehdr_9(): +def test_ehdr_9(): ds = gdal.Open('data/wc_10m_CCCMA_A2a_2020_tmin_9.bil') @@ -216,7 +216,7 @@ def ehdr_9(): # Test detecting floating point file based on image file size (#3933) -def ehdr_10(): +def test_ehdr_10(): tst = gdaltest.GDALTest('EHDR', 'ehdr10.bil', 1, 8202) return tst.testOpen() @@ -224,7 +224,7 @@ def ehdr_10(): # Test detecting floating point file based on .flt extension (#3933) -def ehdr_11(): +def test_ehdr_11(): tst = gdaltest.GDALTest('EHDR', 'ehdr11.flt', 1, 8202) return tst.testOpen() @@ -232,7 +232,7 @@ def ehdr_11(): # Test CreateCopy with 1bit data -def ehdr_12(): +def test_ehdr_12(): src_ds = gdal.Open('../gcore/data/1bit.bmp') ds = gdal.GetDriverByName('EHDR').CreateCopy('/vsimem/1bit.bil', src_ds, @@ -254,7 +254,7 @@ def ehdr_12(): # Test statistics -def ehdr_13(): +def test_ehdr_13(): gdal.Unlink('data/byte.tif.aux.xml') @@ -307,7 +307,7 @@ def ehdr_13(): # Test optimized RasterIO() (#5438) -def ehdr_14(): +def test_ehdr_14(): src_ds = gdal.Open('data/byte.tif') ds = gdal.GetDriverByName('EHDR').CreateCopy('/vsimem/byte.bil', src_ds) @@ -366,7 +366,7 @@ def ehdr_14(): # Test support for RAT (#3253) -def ehdr_rat(): +def test_ehdr_rat(): tmpfile = '/vsimem/rat.bil' gdal.Translate(tmpfile, 'data/int16_rat.bil', format='EHdr') @@ -423,7 +423,7 @@ def ehdr_rat(): # Test STATISTICS_APPROXIMATE -def ehdr_approx_stats_flag(): +def test_ehdr_approx_stats_flag(): src_ds = gdal.GetDriverByName('MEM').Create('', 2000, 2000) src_ds.GetRasterBand(1).WriteRaster(1000, 1000, 1, 1, struct.pack('B' * 1, 20)) @@ -481,22 +481,22 @@ def ehdr_approx_stats_flag(): gdaltest_list = [ - ehdr_1, - ehdr_2, - ehdr_3, - ehdr_4, - ehdr_5, - ehdr_6, - ehdr_7, - ehdr_8, - ehdr_9, - ehdr_10, - ehdr_11, - ehdr_12, - ehdr_13, - ehdr_14, - ehdr_rat, - ehdr_approx_stats_flag] + test_ehdr_1, + test_ehdr_2, + test_ehdr_3, + test_ehdr_4, + test_ehdr_5, + test_ehdr_6, + test_ehdr_7, + test_ehdr_8, + test_ehdr_9, + test_ehdr_10, + test_ehdr_11, + test_ehdr_12, + test_ehdr_13, + test_ehdr_14, + test_ehdr_rat, + test_ehdr_approx_stats_flag] if __name__ == '__main__': diff --git a/autotest/gdrivers/eir.py b/autotest/gdrivers/eir.py index 69a8fca98f27..93957037ac36 100755 --- a/autotest/gdrivers/eir.py +++ b/autotest/gdrivers/eir.py @@ -37,14 +37,14 @@ # Test a fake EIR dataset -def eir_1(): +def test_eir_1(): tst = gdaltest.GDALTest('EIR', 'fakeeir.hdr', 1, 1) return tst.testOpen() gdaltest_list = [ - eir_1] + test_eir_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/elas.py b/autotest/gdrivers/elas.py index c6daf36ff873..7284b5a729b4 100755 --- a/autotest/gdrivers/elas.py +++ b/autotest/gdrivers/elas.py @@ -37,7 +37,7 @@ # Test a dataset generated by Create() -def elas_1(): +def test_elas_1(): tst = gdaltest.GDALTest('ELAS', 'byte_elas.bin', 1, 4672) return tst.testOpen() @@ -46,15 +46,15 @@ def elas_1(): # Test Create() -def elas_2(): +def test_elas_2(): tst = gdaltest.GDALTest('ELAS', 'byte_elas.bin', 1, 4672) return tst.testCreate() gdaltest_list = [ - elas_1, - elas_2] + test_elas_1, + test_elas_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/envi.py b/autotest/gdrivers/envi.py index 91dc4ed218d4..a3c489ad2df3 100755 --- a/autotest/gdrivers/envi.py +++ b/autotest/gdrivers/envi.py @@ -42,7 +42,7 @@ # Perform simple read test. -def envi_1(): +def test_envi_1(): tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823) @@ -69,7 +69,7 @@ def envi_1(): # Verify this can be exported losslessly. -def envi_2(): +def test_envi_2(): tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823) return tst.testCreateCopy(check_gt=1) @@ -78,7 +78,7 @@ def envi_2(): # Try the Create interface with an RGB image. -def envi_3(): +def test_envi_3(): tst = gdaltest.GDALTest('envi', 'rgbsmall.tif', 2, 21053) return tst.testCreate() @@ -87,7 +87,7 @@ def envi_3(): # Test LCC Projection. -def envi_4(): +def test_envi_4(): tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24) @@ -112,7 +112,7 @@ def envi_4(): # Test TM Projection. -def envi_5(): +def test_envi_5(): tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24) prj = """PROJCS["OSGB 1936 / British National Grid", @@ -158,7 +158,7 @@ def envi_5(): # Test LAEA Projection. -def envi_6(): +def test_envi_6(): gdaltest.envi_tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24) @@ -180,7 +180,7 @@ def envi_6(): # Verify VSIF*L capacity -def envi_7(): +def test_envi_7(): tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823) return tst.testCreateCopy(check_gt=1, vsimem=1) @@ -189,7 +189,7 @@ def envi_7(): # Test fix for #3751 -def envi_8(): +def test_envi_8(): ds = gdal.GetDriverByName('ENVI').Create('/vsimem/foo.bsq', 10, 10, 1) set_gt = (50000, 1, 0, 4500000, 0, -1) @@ -209,7 +209,7 @@ def envi_8(): # Verify reading a compressed file -def envi_9(): +def test_envi_9(): tst = gdaltest.GDALTest('envi', 'aea_compressed.dat', 1, 14823) return tst.testCreateCopy(check_gt=1) @@ -218,7 +218,7 @@ def envi_9(): # Test RPC reading and writing -def envi_10(): +def test_envi_10(): src_ds = gdal.Open('data/envirpc.img') out_ds = gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/envirpc.img', src_ds) @@ -243,7 +243,7 @@ def envi_10(): # Check .sta reading -def envi_11(): +def test_envi_11(): ds = gdal.Open('data/envistat') val = ds.GetRasterBand(1).GetStatistics(0, 0) @@ -260,7 +260,7 @@ def envi_11(): # Test category names reading and writing -def envi_12(): +def test_envi_12(): src_ds = gdal.Open('data/testenviclasses') out_ds = gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/testenviclasses', src_ds) @@ -297,7 +297,7 @@ def envi_12(): # Test writing of metadata from the ENVI metadata domain and read it back (#4957) -def envi_13(): +def test_envi_13(): ds = gdal.GetDriverByName('ENVI').Create('/vsimem/envi_13.dat', 1, 1) ds.SetMetadata(['lines=100', 'sensor_type=Landsat TM', 'foo'], 'ENVI') @@ -323,7 +323,7 @@ def envi_13(): # Test that the image file is at the expected size on closing (#6662) -def envi_14(): +def test_envi_14(): gdal.GetDriverByName('ENVI').Create('/vsimem/envi_14.dat', 3, 4, 5, gdal.GDT_Int16) @@ -340,7 +340,7 @@ def envi_14(): # Test reading and writing geotransform matrix with rotation -def envi_15(): +def test_envi_15(): src_ds = gdal.Open('data/rotation.img') got_gt = src_ds.GetGeoTransform() @@ -368,7 +368,7 @@ def envi_15(): # Test reading a truncated ENVI dataset (see #915) -def envi_truncated(): +def test_envi_truncated(): gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/envi_truncated.dat', gdal.Open('data/byte.tif')) @@ -391,22 +391,22 @@ def envi_truncated(): gdaltest_list = [ - envi_1, - envi_2, - envi_3, - envi_4, - envi_5, - envi_6, - envi_7, - envi_8, - envi_9, - envi_10, - envi_11, - envi_12, - envi_13, - envi_14, - envi_15, - envi_truncated, + test_envi_1, + test_envi_2, + test_envi_3, + test_envi_4, + test_envi_5, + test_envi_6, + test_envi_7, + test_envi_8, + test_envi_9, + test_envi_10, + test_envi_11, + test_envi_12, + test_envi_13, + test_envi_14, + test_envi_15, + test_envi_truncated, ] diff --git a/autotest/gdrivers/ers.py b/autotest/gdrivers/ers.py index 285f7dc217e2..799df323a44c 100755 --- a/autotest/gdrivers/ers.py +++ b/autotest/gdrivers/ers.py @@ -41,7 +41,7 @@ # Perform simple read test. -def ers_1(): +def test_ers_1(): tst = gdaltest.GDALTest('ERS', 'srtm.ers', 1, 64074) if tst.testOpen() != 'success': @@ -59,7 +59,7 @@ def ers_1(): # Create simple copy and check. -def ers_2(): +def test_ers_2(): tst = gdaltest.GDALTest('ERS', 'float32.bil', 1, 27) return tst.testCreateCopy(new_filename='tmp/float32.ers', @@ -69,7 +69,7 @@ def ers_2(): # Test multi-band file. -def ers_3(): +def test_ers_3(): tst = gdaltest.GDALTest('ERS', 'rgbsmall.tif', 2, 21053) return tst.testCreate(new_filename='tmp/rgbsmall.ers') @@ -78,7 +78,7 @@ def ers_3(): # Test HeaderOffset case. -def ers_4(): +def test_ers_4(): gt = (143.59625, 0.025, 0.0, -39.38125, 0.0, -0.025) srs = """GEOGCS["GEOCENTRIC DATUM of AUSTRALIA", @@ -94,7 +94,7 @@ def ers_4(): # Confirm we can recognised signed 8bit data. -def ers_5(): +def test_ers_5(): ds = gdal.Open('data/8s.ers') md = ds.GetRasterBand(1).GetMetadata('IMAGE_STRUCTURE') @@ -111,7 +111,7 @@ def ers_5(): # Confirm a copy preserves the signed byte info. -def ers_6(): +def test_ers_6(): drv = gdal.GetDriverByName('ERS') @@ -135,7 +135,7 @@ def ers_6(): # Test opening a file with everything in lower case. -def ers_7(): +def test_ers_7(): ds = gdal.Open('data/caseinsensitive.ers') @@ -152,7 +152,7 @@ def ers_7(): # Test GCP support -def ers_8(): +def test_ers_8(): src_ds = gdal.Open('../gcore/data/gcps.vrt') drv = gdal.GetDriverByName('ERS') @@ -194,7 +194,7 @@ def ers_8(): # Test NoData support (#4207) -def ers_9(): +def test_ers_9(): drv = gdal.GetDriverByName('ERS') ds = drv.Create('/vsimem/ers_9.ers', 1, 1) @@ -225,7 +225,7 @@ def ers_9(): # Test PROJ, DATUM, UNITS support (#4229) -def ers_10(): +def test_ers_10(): drv = gdal.GetDriverByName('ERS') ds = drv.Create('/vsimem/ers_10.ers', 1, 1, options=['DATUM=GDA94', 'PROJ=MGA55', 'UNITS=METERS']) @@ -372,7 +372,7 @@ def ers_10(): # Test fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8744 -def ers_recursive_opening(): +def test_ers_recursive_opening(): ds = gdal.Open('/vsitar/data/test_ers_recursive.tar/test.ers') ds.GetFileList() return 'success' @@ -381,24 +381,24 @@ def ers_recursive_opening(): # Cleanup -def ers_cleanup(): +def test_ers_cleanup(): gdaltest.clean_tmp() return 'success' gdaltest_list = [ - ers_1, - ers_2, - ers_3, - ers_4, - ers_5, - ers_6, - ers_7, - ers_8, - ers_9, - ers_10, - ers_recursive_opening, - ers_cleanup + test_ers_1, + test_ers_2, + test_ers_3, + test_ers_4, + test_ers_5, + test_ers_6, + test_ers_7, + test_ers_8, + test_ers_9, + test_ers_10, + test_ers_recursive_opening, + test_ers_cleanup ] diff --git a/autotest/gdrivers/fast.py b/autotest/gdrivers/fast.py index ffc6355ea226..299d1513283d 100755 --- a/autotest/gdrivers/fast.py +++ b/autotest/gdrivers/fast.py @@ -39,7 +39,7 @@ # Verify we have the driver. -def fast_1(): +def test_fast_1(): gdaltest.fast_drv = gdal.GetDriverByName('FAST') if gdaltest.fast_drv is None: @@ -51,7 +51,7 @@ def fast_1(): # Perform simple read test. -def fast_2(): +def test_fast_2(): if gdaltest.fast_drv is None: return 'skip' @@ -67,7 +67,7 @@ def fast_2(): # Verify metadata. -def fast_3(): +def test_fast_3(): if gdaltest.fast_drv is None: return 'skip' @@ -114,7 +114,7 @@ def fast_3(): # Test geotransform data. -def fast_4(): +def test_fast_4(): if gdaltest.fast_drv is None: return 'skip' @@ -142,7 +142,7 @@ def fast_4(): ############################################################################### # Test 2 bands dataset with checking projections and geotransform. -def fast_5(): +def test_fast_5(): if gdaltest.fast_drv is None: return 'skip' @@ -182,7 +182,7 @@ def fast_5(): ############################################################################### # Test Euromap LISS3 dataset -def fast_6(): +def test_fast_6(): if gdaltest.fast_drv is None: return 'skip' @@ -203,7 +203,7 @@ def fast_6(): ############################################################################### # Test Euromap PAN dataset -def fast_7(): +def test_fast_7(): if gdaltest.fast_drv is None: return 'skip' @@ -235,7 +235,7 @@ def fast_7(): # Test Euromap WIFS dataset -def fast_8(): +def test_fast_8(): if gdaltest.fast_drv is None: return 'skip' @@ -269,7 +269,7 @@ def fast_8(): # Check some metadata and opening for a RevB L7 file (#3306, #3307). -def fast_9(): +def test_fast_9(): if gdaltest.fast_drv is None: return 'skip' @@ -290,15 +290,15 @@ def fast_9(): gdaltest_list = [ - fast_1, - fast_2, - fast_3, - fast_4, - fast_5, - fast_6, - fast_7, - fast_8, - fast_9] + test_fast_1, + test_fast_2, + test_fast_3, + test_fast_4, + test_fast_5, + test_fast_6, + test_fast_7, + test_fast_8, + test_fast_9] if __name__ == '__main__': diff --git a/autotest/gdrivers/fujibas.py b/autotest/gdrivers/fujibas.py index 6153a36e8bb7..4ea6859260c6 100755 --- a/autotest/gdrivers/fujibas.py +++ b/autotest/gdrivers/fujibas.py @@ -37,14 +37,14 @@ # Test a fake - and certainly incorrect - FUJIBAS dataset -def fujibas_1(): +def test_fujibas_1(): tst = gdaltest.GDALTest('FujiBAS', 'fakefujibas.pcb', 1, 1) return tst.testOpen() gdaltest_list = [ - fujibas_1] + test_fujibas_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/gdalhttp.py b/autotest/gdrivers/gdalhttp.py index 29a42d3e5397..ec1d5b216c7a 100755 --- a/autotest/gdrivers/gdalhttp.py +++ b/autotest/gdrivers/gdalhttp.py @@ -42,7 +42,7 @@ # Verify we have the driver. -def http_1(): +def test_http_1(): gdaltest.dods_drv = None @@ -70,7 +70,7 @@ def http_1(): # Verify /vsicurl (subversion file listing) -def http_2(): +def test_http_2(): drv = gdal.GetDriverByName('HTTP') if drv is None: @@ -92,7 +92,7 @@ def http_2(): # Verify /vsicurl (apache file listing) -def http_3(): +def test_http_3(): drv = gdal.GetDriverByName('HTTP') if drv is None: @@ -148,7 +148,7 @@ def http_4_old(): # Verify /vsicurl (ftp) -def http_4(): +def test_http_4(): # Too unreliable if gdaltest.skip_on_travis(): @@ -188,7 +188,7 @@ def http_4(): # Test HTTP driver with non VSIL driver -def http_5(): +def test_http_5(): drv = gdal.GetDriverByName('HTTP') if drv is None: @@ -224,7 +224,7 @@ def http_5(): # Test HTTP driver with OGR driver -def http_6(): +def test_http_6(): drv = gdal.GetDriverByName('HTTP') if drv is None: @@ -251,7 +251,7 @@ def http_6(): ############################################################################### -def http_test_ssl_verifystatus(): +def test_http_test_ssl_verifystatus(): if gdal.GetDriverByName('HTTP') is None: return 'skip' @@ -275,14 +275,14 @@ def http_test_ssl_verifystatus(): ############################################################################### -def http_test_use_capi_store(): +def test_http_test_use_capi_store(): if gdal.GetDriverByName('HTTP') is None: return 'skip' if sys.platform != 'win32': with gdaltest.error_handler(): - return http_test_use_capi_store_sub() + return test_http_test_use_capi_store_sub() import test_py_scripts ret = test_py_scripts.run_py_script_as_external_script('.', 'gdalhttp', ' -use_capi_store', display_live_on_parent_stdout=True) @@ -293,7 +293,7 @@ def http_test_use_capi_store(): return 'success' -def http_test_use_capi_store_sub(): +def test_http_test_use_capi_store_sub(): with gdaltest.config_option('GDAL_HTTP_USE_CAPI_STORE', 'YES'): gdal.OpenEx('https://google.com', allowed_drivers=['HTTP']) @@ -304,7 +304,7 @@ def http_test_use_capi_store_sub(): # -def http_cleanup(): +def test_http_cleanup(): if gdaltest.dods_drv is not None: gdaltest.dods_drv.Register() gdaltest.dods_drv = None @@ -312,16 +312,16 @@ def http_cleanup(): return 'success' -gdaltest_list = [http_1, - http_2, - http_3, +gdaltest_list = [test_http_1, + test_http_2, + test_http_3, # http_4_old, - http_4, - http_5, - http_6, - http_test_ssl_verifystatus, - http_test_use_capi_store, - http_cleanup] + test_http_4, + test_http_5, + test_http_6, + test_http_test_ssl_verifystatus, + test_http_test_use_capi_store, + test_http_cleanup] # gdaltest_list = [ http_test_use_capi_store ] @@ -330,7 +330,7 @@ def http_cleanup(): gdaltest.setup_run('http') if len(sys.argv) == 2 and sys.argv[1] == '-use_capi_store': - gdaltest_list = [http_test_use_capi_store_sub] + gdaltest_list = [test_http_test_use_capi_store_sub] gdaltest.run_tests(gdaltest_list) diff --git a/autotest/gdrivers/genbin.py b/autotest/gdrivers/genbin.py index 96f22e01294e..75db02c423b8 100755 --- a/autotest/gdrivers/genbin.py +++ b/autotest/gdrivers/genbin.py @@ -37,7 +37,7 @@ # Perform simple read test. -def genbin_1(): +def test_genbin_1(): tst = gdaltest.GDALTest('GenBin', 'tm4628_96.bil', 1, 5738, 0, 0, 500, 1) @@ -73,7 +73,7 @@ def genbin_1(): gdaltest_list = [ - genbin_1 + test_genbin_1 ] diff --git a/autotest/gdrivers/georaster.py b/autotest/gdrivers/georaster.py index 524d7a6086ed..8001ba12ea3e 100755 --- a/autotest/gdrivers/georaster.py +++ b/autotest/gdrivers/georaster.py @@ -53,7 +53,7 @@ def get_connection_str(): # -def georaster_init(): +def test_georaster_init(): gdaltest.oci_ds = None @@ -92,7 +92,7 @@ def georaster_init(): # -def georaster_byte(): +def test_georaster_byte(): if gdaltest.georasterDriver is None: return 'skip' @@ -119,7 +119,7 @@ def georaster_byte(): # -def georaster_int16(): +def test_georaster_int16(): if gdaltest.georasterDriver is None: return 'skip' @@ -148,7 +148,7 @@ def georaster_int16(): # -def georaster_int32(): +def test_georaster_int32(): if gdaltest.georasterDriver is None: return 'skip' @@ -177,7 +177,7 @@ def georaster_int32(): # -def georaster_rgb_b1(): +def test_georaster_rgb_b1(): if gdaltest.georasterDriver is None: return 'skip' @@ -205,7 +205,7 @@ def georaster_rgb_b1(): # -def georaster_rgb_b2(): +def test_georaster_rgb_b2(): if gdaltest.georasterDriver is None: return 'skip' @@ -233,7 +233,7 @@ def georaster_rgb_b2(): # -def georaster_rgb_b3_bsq(): +def test_georaster_rgb_b3_bsq(): if gdaltest.georasterDriver is None: return 'skip' @@ -261,7 +261,7 @@ def georaster_rgb_b3_bsq(): # -def georaster_rgb_b3_bip(): +def test_georaster_rgb_b3_bip(): if gdaltest.georasterDriver is None: return 'skip' @@ -289,7 +289,7 @@ def georaster_rgb_b3_bip(): # -def georaster_rgb_b3_bil(): +def test_georaster_rgb_b3_bil(): if gdaltest.georasterDriver is None: return 'skip' @@ -317,7 +317,7 @@ def georaster_rgb_b3_bil(): # -def georaster_byte_deflate(): +def test_georaster_byte_deflate(): if gdaltest.georasterDriver is None: return 'skip' @@ -345,7 +345,7 @@ def georaster_byte_deflate(): # -def georaster_rgb_deflate_b3(): +def test_georaster_rgb_deflate_b3(): if gdaltest.georasterDriver is None: return 'skip' @@ -373,7 +373,7 @@ def georaster_rgb_deflate_b3(): # -def georaster_1bit(): +def test_georaster_1bit(): if gdaltest.georasterDriver is None: return 'skip' @@ -401,7 +401,7 @@ def georaster_1bit(): # -def georaster_2bit(): +def test_georaster_2bit(): if gdaltest.georasterDriver is None: return 'skip' @@ -429,7 +429,7 @@ def georaster_2bit(): # -def georaster_4bit(): +def test_georaster_4bit(): if gdaltest.georasterDriver is None: return 'skip' @@ -457,7 +457,7 @@ def georaster_4bit(): # -def georaster_cleanup(): +def test_georaster_cleanup(): if gdaltest.georasterDriver is None: return 'skip' @@ -478,21 +478,21 @@ def georaster_cleanup(): gdaltest_list = [ - georaster_init, - georaster_byte, - georaster_int16, - georaster_int32, - georaster_rgb_b1, - georaster_rgb_b2, - georaster_rgb_b3_bsq, - georaster_rgb_b3_bip, - georaster_rgb_b3_bil, - georaster_byte_deflate, - georaster_rgb_deflate_b3, - georaster_1bit, - georaster_2bit, - georaster_4bit, - georaster_cleanup + test_georaster_init, + test_georaster_byte, + test_georaster_int16, + test_georaster_int32, + test_georaster_rgb_b1, + test_georaster_rgb_b2, + test_georaster_rgb_b3_bsq, + test_georaster_rgb_b3_bip, + test_georaster_rgb_b3_bil, + test_georaster_byte_deflate, + test_georaster_rgb_deflate_b3, + test_georaster_1bit, + test_georaster_2bit, + test_georaster_4bit, + test_georaster_cleanup ] if __name__ == '__main__': diff --git a/autotest/gdrivers/gff.py b/autotest/gdrivers/gff.py index 774d40c2da4c..8dc33ec73660 100755 --- a/autotest/gdrivers/gff.py +++ b/autotest/gdrivers/gff.py @@ -38,7 +38,7 @@ # Test an extract from a real dataset -def gff_1(): +def test_gff_1(): # 12088 = 2048 + 8 * 1255 if not gdaltest.download_file('http://sandia.gov/RADAR/complex_data/MiniSAR20050519p0001image008.gff', 'MiniSAR20050519p0001image008.gff', 12088): return 'skip' @@ -51,7 +51,7 @@ def gff_1(): gdaltest_list = [ - gff_1] + test_gff_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/gif.py b/autotest/gdrivers/gif.py index fdb7b10d2d74..10c379ab38bc 100755 --- a/autotest/gdrivers/gif.py +++ b/autotest/gdrivers/gif.py @@ -39,7 +39,7 @@ # Get the GIF driver, and verify a few things about it. -def gif_1(): +def test_gif_1(): gdaltest.gif_drv = gdal.GetDriverByName('GIF') if gdaltest.gif_drv is None: @@ -62,7 +62,7 @@ def gif_1(): # Read test of simple byte reference data. -def gif_2(): +def test_gif_2(): tst = gdaltest.GDALTest('GIF', 'bug407.gif', 1, 57921) return tst.testOpen() @@ -71,7 +71,7 @@ def gif_2(): # Test lossless copying. -def gif_3(): +def test_gif_3(): tst = gdaltest.GDALTest('GIF', 'bug407.gif', 1, 57921, options=['INTERLACING=NO']) @@ -82,7 +82,7 @@ def gif_3(): # Verify the colormap, and nodata setting for test file. -def gif_4(): +def test_gif_4(): ds = gdal.Open('data/bug407.gif') cm = ds.GetRasterBand(1).GetRasterColorTable() @@ -110,7 +110,7 @@ def gif_4(): # Test creating an in memory copy. -def gif_5(): +def test_gif_5(): tst = gdaltest.GDALTest('GIF', 'byte.tif', 1, 4672) @@ -120,7 +120,7 @@ def gif_5(): # Verify nodata support -def gif_6(): +def test_gif_6(): src_ds = gdal.Open('../gcore/data/nodata_byte.tif') @@ -162,7 +162,7 @@ def gif_6(): ############################################################################### # Confirm reading with the BIGGIF driver. -def gif_7(): +def test_gif_7(): # Move the GIF driver after the BIGGIF driver. drv = gdal.GetDriverByName('GIF') @@ -187,7 +187,7 @@ def gif_7(): # Confirm that BIGGIF driver is selected for huge gifs -def gif_8(): +def test_gif_8(): # Move the BIGGIF driver after the GIF driver. drv = gdal.GetDriverByName('BIGGIF') @@ -207,7 +207,7 @@ def gif_8(): # Test writing to /vsistdout/ -def gif_9(): +def test_gif_9(): src_ds = gdal.Open('data/byte.tif') ds = gdal.GetDriverByName('GIF').CreateCopy( @@ -231,7 +231,7 @@ def gif_9(): # Test interlacing -def gif_10(): +def test_gif_10(): tst = gdaltest.GDALTest('GIF', 'byte.tif', 1, 4672, options=['INTERLACING=YES']) @@ -242,23 +242,23 @@ def gif_10(): # Cleanup. -def gif_cleanup(): +def test_gif_cleanup(): gdaltest.clean_tmp() return 'success' gdaltest_list = [ - gif_1, - gif_2, - gif_3, - gif_4, - gif_5, - gif_6, - gif_7, - gif_8, - gif_9, - gif_10, - gif_cleanup] + test_gif_1, + test_gif_2, + test_gif_3, + test_gif_4, + test_gif_5, + test_gif_6, + test_gif_7, + test_gif_8, + test_gif_9, + test_gif_10, + test_gif_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/gmt.py b/autotest/gdrivers/gmt.py index 9efbd9613549..e54bc0f25116 100755 --- a/autotest/gdrivers/gmt.py +++ b/autotest/gdrivers/gmt.py @@ -38,7 +38,7 @@ # Perform simple read test. -def gmt_1(): +def test_gmt_1(): gdaltest.gmt_drv = gdal.GetDriverByName('GMT') @@ -56,7 +56,7 @@ def gmt_1(): # Verify a simple createcopy operation with 16bit data. -def gmt_2(): +def test_gmt_2(): if gdaltest.gmt_drv is None: return 'skip' @@ -68,8 +68,8 @@ def gmt_2(): gdaltest_list = [ - gmt_1, - gmt_2] + test_gmt_1, + test_gmt_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/gpkg.py b/autotest/gdrivers/gpkg.py index 413aafe3018d..8ec3494198ed 100755 --- a/autotest/gdrivers/gpkg.py +++ b/autotest/gdrivers/gpkg.py @@ -79,7 +79,7 @@ def validate(filename, quiet=False): # Test if GPKG and tile drivers are available -def gpkg_init(): +def test_gpkg_init(): gdaltest.gpkg_dr = None @@ -201,7 +201,7 @@ def check_tile_format(out_ds, expected_format, expected_band_count, expected_ct, # Single band, PNG -def gpkg_1(): +def test_gpkg_1(): if gdaltest.gpkg_dr is None: return 'skip' @@ -319,7 +319,7 @@ def gpkg_1(): # Single band, JPEG -def gpkg_2(): +def test_gpkg_2(): if gdaltest.gpkg_dr is None: return 'skip' @@ -421,7 +421,7 @@ def gpkg_2(): # Single band, WEBP -def gpkg_3(): +def test_gpkg_3(): if gdaltest.gpkg_dr is None: return 'skip' @@ -544,7 +544,7 @@ def gpkg_3(): # Three band, PNG -def gpkg_4(tile_drv_name='PNG'): +def test_gpkg_4(tile_drv_name='PNG'): if gdaltest.gpkg_dr is None: return 'skip' @@ -623,15 +623,15 @@ def gpkg_4(tile_drv_name='PNG'): # Three band, JPEG -def gpkg_5(): - return gpkg_4(tile_drv_name='JPEG') +def test_gpkg_5(): + return test_gpkg_4(tile_drv_name='JPEG') ############################################################################### # Three band, WEBP -def gpkg_6(): - return gpkg_4(tile_drv_name='WEBP') +def test_gpkg_6(): + return test_gpkg_4(tile_drv_name='WEBP') ############################################################################### # 4 band, PNG @@ -652,7 +652,7 @@ def get_georeferenced_rgba_ds(alpha_fully_transparent=False, alpha_fully_opaque= return tmp_ds -def gpkg_7(tile_drv_name='PNG'): +def test_gpkg_7(tile_drv_name='PNG'): if gdaltest.gpkg_dr is None: return 'skip' @@ -743,15 +743,15 @@ def gpkg_7(tile_drv_name='PNG'): # 4 band, JPEG -def gpkg_8(): - return gpkg_7(tile_drv_name='JPEG') +def test_gpkg_8(): + return test_gpkg_7(tile_drv_name='JPEG') ############################################################################### # 4 band, WEBP -def gpkg_9(): - return gpkg_7(tile_drv_name='WEBP') +def test_gpkg_9(): + return test_gpkg_7(tile_drv_name='WEBP') ############################################################################### # @@ -771,7 +771,7 @@ def get_georeferenced_ds_with_pct32(): # Single band with 32 bit color table, PNG -def gpkg_10(): +def test_gpkg_10(): if gdaltest.gpkg_dr is None: return 'skip' @@ -892,7 +892,7 @@ def gpkg_10(): # Single band with 32 bit color table, JPEG -def gpkg_11(tile_drv_name='JPEG'): +def test_gpkg_11(tile_drv_name='JPEG'): if gdaltest.gpkg_dr is None: return 'skip' @@ -948,14 +948,14 @@ def gpkg_11(tile_drv_name='JPEG'): # Single band with 32 bit color table, WEBP -def gpkg_12(): - return gpkg_11(tile_drv_name='WEBP') +def test_gpkg_12(): + return test_gpkg_11(tile_drv_name='WEBP') ############################################################################### # Single band with 24 bit color table, PNG -def gpkg_13(): +def test_gpkg_13(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1026,7 +1026,7 @@ def gpkg_13(): # Test creation and opening options -def gpkg_14(): +def test_gpkg_14(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1440,7 +1440,7 @@ def gpkg_14(): # Test error cases -def gpkg_15(): +def test_gpkg_15(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1605,7 +1605,7 @@ def gpkg_15(): # Test block/tile caching -def gpkg_16(): +def test_gpkg_16(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1651,7 +1651,7 @@ def gpkg_16(): # Test overviews with single band dataset -def gpkg_17(): +def test_gpkg_17(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1818,7 +1818,7 @@ def gpkg_17(): # Test overviews with 3 band dataset -def gpkg_18(): +def test_gpkg_18(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1973,7 +1973,7 @@ def gpkg_18(): # Test overviews with 24-bit color palette single band dataset -def gpkg_19(): +def test_gpkg_19(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2026,7 +2026,7 @@ def gpkg_19(): # Test PNG8 -def gpkg_20(): +def test_gpkg_20(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2129,7 +2129,7 @@ def gpkg_20(): # Test metadata -def gpkg_21(): +def test_gpkg_21(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2426,7 +2426,7 @@ def get_georeferenced_greyalpha_ds(): return tmp_ds -def gpkg_22(tile_drv_name='PNG'): +def test_gpkg_22(tile_drv_name='PNG'): if gdaltest.gpkg_dr is None: return 'skip' @@ -2504,28 +2504,28 @@ def gpkg_22(tile_drv_name='PNG'): # Two band, JPEG -def gpkg_23(): - return gpkg_22(tile_drv_name='JPEG') +def test_gpkg_23(): + return test_gpkg_22(tile_drv_name='JPEG') ############################################################################### # Two band, WEBP -def gpkg_24(): - return gpkg_22(tile_drv_name='WEBP') +def test_gpkg_24(): + return test_gpkg_22(tile_drv_name='WEBP') ############################################################################### # Two band, mixed -def gpkg_25(): - return gpkg_22(tile_drv_name=None) +def test_gpkg_25(): + return test_gpkg_22(tile_drv_name=None) ############################################################################### # Test TILING_SCHEME -def gpkg_26(): +def test_gpkg_26(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2660,7 +2660,7 @@ def gpkg_26(): # Test behaviour with low block cache max -def gpkg_27(): +def test_gpkg_27(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2689,7 +2689,7 @@ def gpkg_27(): # block that would have gone through the GPKG in-memory cache -def gpkg_28(): +def test_gpkg_28(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2732,7 +2732,7 @@ def gpkg_28(): # Variation of gpkg_28 with 2 blocks -def gpkg_29(x=0): +def test_gpkg_29(x=0): if gdaltest.gpkg_dr is None: return 'skip' @@ -2777,15 +2777,15 @@ def gpkg_29(x=0): # Variation of gpkg_29 where the read is done in another block -def gpkg_30(): +def test_gpkg_30(): - return gpkg_29(x=200) + return test_gpkg_29(x=200) ############################################################################### # 1 band to RGBA -def gpkg_31(): +def test_gpkg_31(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2816,7 +2816,7 @@ def gpkg_31(): # grey-alpha to RGBA -def gpkg_32(): +def test_gpkg_32(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2855,7 +2855,7 @@ def gpkg_32(): # Single band with 32 bit color table -> RGBA -def gpkg_33(): +def test_gpkg_33(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2888,7 +2888,7 @@ def gpkg_33(): # Test partial tiles with overviews (#6335) -def gpkg_34(): +def test_gpkg_34(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2917,7 +2917,7 @@ def gpkg_34(): # Test dirty block flushing while reading block (#6365) -def gpkg_35(): +def test_gpkg_35(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2968,7 +2968,7 @@ def gpkg_35(): # Single band with 24 bit color table, PNG, GoogleMapsCompatible -def gpkg_36(): +def test_gpkg_36(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3002,7 +3002,7 @@ def gpkg_36(): # factors -def gpkg_37(): +def test_gpkg_37(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3025,7 +3025,7 @@ def gpkg_37(): # Test generating more than 1000 tiles -def gpkg_38(): +def test_gpkg_38(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3068,7 +3068,7 @@ def gpkg_38(): # Test tile gridded coverage data -def gpkg_39(): +def test_gpkg_39(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3569,7 +3569,7 @@ def gpkg_39(): # Test VERSION -def gpkg_40(): +def test_gpkg_40(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3660,7 +3660,7 @@ def gpkg_40(): # Robustness test -def gpkg_41(): +def test_gpkg_41(): if gdaltest.gpkg_dr is None or gdal.GetConfigOption('TRAVIS') is not None or \ gdal.GetConfigOption('APPVEYOR') is not None: @@ -3681,7 +3681,7 @@ def gpkg_41(): # Test opening in vector mode a database without gpkg_geometry_columns -def gpkg_42(): +def test_gpkg_42(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3715,7 +3715,7 @@ def gpkg_42(): # Test adding raster to a database without pre-existing raster support tables. -def gpkg_43(): +def test_gpkg_43(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3758,7 +3758,7 @@ def gpkg_43(): # Test opening a .gpkg.sql file -def gpkg_44(): +def test_gpkg_44(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3776,7 +3776,7 @@ def gpkg_44(): # Test opening a .gpkg file -def gpkg_45(): +def test_gpkg_45(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3791,7 +3791,7 @@ def gpkg_45(): # Test fix for #6932 -def gpkg_46(): +def test_gpkg_46(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3835,7 +3835,7 @@ def gpkg_46(): # Test fix for #6976 -def gpkg_47(): +def test_gpkg_47(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3860,7 +3860,7 @@ def gpkg_47(): # subdatasets on Windows) -def gpkg_48(): +def test_gpkg_48(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3891,7 +3891,7 @@ def gpkg_48(): ############################################################################### -def gpkg_delete_raster_layer(): +def test_gpkg_delete_raster_layer(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3929,7 +3929,7 @@ def gpkg_delete_raster_layer(): ############################################################################### -def gpkg_delete_gridded_coverage_raster_layer(): +def test_gpkg_delete_gridded_coverage_raster_layer(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3957,7 +3957,7 @@ def gpkg_delete_gridded_coverage_raster_layer(): ############################################################################### -def gpkg_open_old_gpkg_elevation_tiles_extension(): +def test_gpkg_open_old_gpkg_elevation_tiles_extension(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3977,7 +3977,7 @@ def gpkg_open_old_gpkg_elevation_tiles_extension(): ############################################################################### -def gpkg_GeneralCmdLineProcessor(): +def test_gpkg_GeneralCmdLineProcessor(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3999,7 +3999,7 @@ def gpkg_GeneralCmdLineProcessor(): ############################################################################### -def gpkg_match_overview_factor(): +def test_gpkg_match_overview_factor(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4021,7 +4021,7 @@ def gpkg_match_overview_factor(): # -def gpkg_cleanup(): +def test_gpkg_cleanup(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4037,61 +4037,61 @@ def gpkg_cleanup(): gdaltest_list = [ - gpkg_init, - gpkg_1, - gpkg_2, - gpkg_3, - gpkg_4, - gpkg_5, - gpkg_6, - gpkg_7, - gpkg_8, - gpkg_9, - gpkg_10, - gpkg_11, - gpkg_12, - gpkg_13, - gpkg_14, - gpkg_15, - gpkg_16, - gpkg_17, - gpkg_18, - gpkg_19, - gpkg_20, - gpkg_21, - gpkg_22, - gpkg_23, - gpkg_24, - gpkg_25, - gpkg_26, - gpkg_27, - gpkg_28, - gpkg_29, - gpkg_30, - gpkg_31, - gpkg_32, - gpkg_33, - gpkg_34, - gpkg_35, - gpkg_36, - gpkg_37, - gpkg_38, - gpkg_39, - gpkg_40, - gpkg_41, - gpkg_42, - gpkg_43, - gpkg_44, - gpkg_45, - gpkg_46, - gpkg_47, - gpkg_48, - gpkg_delete_raster_layer, - gpkg_open_old_gpkg_elevation_tiles_extension, - gpkg_GeneralCmdLineProcessor, - gpkg_match_overview_factor, - gpkg_delete_gridded_coverage_raster_layer, - gpkg_cleanup, + test_gpkg_init, + test_gpkg_1, + test_gpkg_2, + test_gpkg_3, + test_gpkg_4, + test_gpkg_5, + test_gpkg_6, + test_gpkg_7, + test_gpkg_8, + test_gpkg_9, + test_gpkg_10, + test_gpkg_11, + test_gpkg_12, + test_gpkg_13, + test_gpkg_14, + test_gpkg_15, + test_gpkg_16, + test_gpkg_17, + test_gpkg_18, + test_gpkg_19, + test_gpkg_20, + test_gpkg_21, + test_gpkg_22, + test_gpkg_23, + test_gpkg_24, + test_gpkg_25, + test_gpkg_26, + test_gpkg_27, + test_gpkg_28, + test_gpkg_29, + test_gpkg_30, + test_gpkg_31, + test_gpkg_32, + test_gpkg_33, + test_gpkg_34, + test_gpkg_35, + test_gpkg_36, + test_gpkg_37, + test_gpkg_38, + test_gpkg_39, + test_gpkg_40, + test_gpkg_41, + test_gpkg_42, + test_gpkg_43, + test_gpkg_44, + test_gpkg_45, + test_gpkg_46, + test_gpkg_47, + test_gpkg_48, + test_gpkg_delete_raster_layer, + test_gpkg_open_old_gpkg_elevation_tiles_extension, + test_gpkg_GeneralCmdLineProcessor, + test_gpkg_match_overview_factor, + test_gpkg_delete_gridded_coverage_raster_layer, + test_gpkg_cleanup, ] # gdaltest_list = [ gpkg_init, gpkg_47, gpkg_cleanup ] if __name__ == '__main__': diff --git a/autotest/gdrivers/grass.py b/autotest/gdrivers/grass.py index ce69be146b5f..079bab0c90d1 100755 --- a/autotest/gdrivers/grass.py +++ b/autotest/gdrivers/grass.py @@ -38,7 +38,7 @@ ############################################################################### # Test if GRASS driver is present -def grass_1(): +def test_grass_1(): gdaltest.grass_drv = gdal.GetDriverByName('GRASS') if gdaltest.grass_drv is None: @@ -50,7 +50,7 @@ def grass_1(): # Read existing simple 1 band GRASS dataset. -def grass_2(): +def test_grass_2(): if gdaltest.grass_drv is None: return 'skip' @@ -79,8 +79,8 @@ def grass_2(): gdaltest_list = [ - grass_1, - grass_2 + test_grass_1, + test_grass_2 ] diff --git a/autotest/gdrivers/grassasciigrid.py b/autotest/gdrivers/grassasciigrid.py index c4f80dd0f8d6..0bd1d434ea9c 100755 --- a/autotest/gdrivers/grassasciigrid.py +++ b/autotest/gdrivers/grassasciigrid.py @@ -37,7 +37,7 @@ # Perform simple read test. -def grassasciigrid_1(): +def test_grassasciigrid_1(): tst = gdaltest.GDALTest('GRASSASCIIGrid', 'grassascii.txt', 1, 212) expected_gt = [-100.0, 62.5, 0.0, 250.0, 0.0, -41.666666666666664] @@ -47,7 +47,7 @@ def grassasciigrid_1(): gdaltest_list = [ - grassasciigrid_1 + test_grassasciigrid_1 ] if __name__ == '__main__': diff --git a/autotest/gdrivers/grib.py b/autotest/gdrivers/grib.py index 7892d815c2a7..3ae6b47dc364 100755 --- a/autotest/gdrivers/grib.py +++ b/autotest/gdrivers/grib.py @@ -52,7 +52,7 @@ def has_jp2kdrv(): # Do a simple checksum on our test file -def grib_1(): +def test_grib_1(): gdaltest.grib_drv = gdal.GetDriverByName('GRIB') if gdaltest.grib_drv is None: @@ -69,7 +69,7 @@ def grib_1(): ############################################################################### # Test a small GRIB 1 sample file. -def grib_2(): +def test_grib_2(): if gdaltest.grib_drv is None: return 'skip' @@ -82,7 +82,7 @@ def grib_2(): # we sort-of-support per ticket Test a small GRIB 1 sample file. -def grib_read_different_sizes_messages(): +def test_grib_read_different_sizes_messages(): if gdaltest.grib_drv is None: return 'skip' @@ -103,7 +103,7 @@ def grib_read_different_sizes_messages(): # Check nodata -def grib_grib2_read_nodata(): +def test_grib_grib2_read_nodata(): if gdaltest.grib_drv is None: return 'skip' @@ -127,7 +127,7 @@ def grib_grib2_read_nodata(): # Check grib units (#3606) -def grib_read_units(): +def test_grib_read_units(): if gdaltest.grib_drv is None: return 'skip' @@ -175,7 +175,7 @@ def grib_read_units(): # ticket #5532 -def grib_read_geotransform_one_n_or_n_one(): +def test_grib_read_geotransform_one_n_or_n_one(): if gdaltest.grib_drv is None: return 'skip' @@ -196,7 +196,7 @@ def grib_read_geotransform_one_n_or_n_one(): # case (#5530). -def grib_read_vsizip(): +def test_grib_read_vsizip(): if gdaltest.grib_drv is None: return 'skip' @@ -211,7 +211,7 @@ def grib_read_vsizip(): # Write PDS numbers to all bands -def grib_grib2_test_grib_pds_all_bands(): +def test_grib_grib2_test_grib_pds_all_bands(): if gdaltest.grib_drv is None: return 'skip' @@ -242,7 +242,7 @@ def grib_grib2_test_grib_pds_all_bands(): # Test support for template 4.15 (#5768) -def grib_grib2_read_template_4_15(): +def test_grib_grib2_read_template_4_15(): if gdaltest.grib_drv is None: return 'skip' @@ -270,7 +270,7 @@ def grib_grib2_read_template_4_15(): # Test support for PNG compressed -def grib_grib2_read_png(): +def test_grib_grib2_read_png(): if gdaltest.grib_drv is None: return 'skip' @@ -291,7 +291,7 @@ def grib_grib2_read_png(): # Test support for GRIB2 Section 4 Template 32, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for synthetic satellite data. -def grib_grib2_read_template_4_32(): +def test_grib_grib2_read_template_4_32(): if gdaltest.grib_drv is None: return 'skip' @@ -317,7 +317,7 @@ def grib_grib2_read_template_4_32(): # GRIB2 file with all 0 data -def grib_grib2_read_all_zero_data(): +def test_grib_grib2_read_all_zero_data(): if gdaltest.grib_drv is None: return 'skip' @@ -343,7 +343,7 @@ def grib_grib2_read_all_zero_data(): # GRIB1 file with rotate pole lonlat -def grib_grib2_read_rotated_pole_lonlat(): +def test_grib_grib2_read_rotated_pole_lonlat(): if gdaltest.grib_drv is None: return 'skip' @@ -384,7 +384,7 @@ def grib_grib2_read_rotated_pole_lonlat(): # Test support for GRIB2 Section 4 Template 40, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -def grib_grib2_read_template_4_40(): +def test_grib_grib2_read_template_4_40(): if gdaltest.grib_drv is None: return 'skip' @@ -410,7 +410,7 @@ def grib_grib2_read_template_4_40(): # Test support for a unhandled GRIB2 Section 4 Template -def grib_grib2_read_template_4_unhandled(): +def test_grib_grib2_read_template_4_unhandled(): if gdaltest.grib_drv is None: return 'skip' @@ -431,7 +431,7 @@ def grib_grib2_read_template_4_unhandled(): # Test reading GRIB2 Transverse Mercator grid -def grib_grib2_read_transverse_mercator(): +def test_grib_grib2_read_transverse_mercator(): if gdaltest.grib_drv is None: return 'skip' @@ -458,7 +458,7 @@ def grib_grib2_read_transverse_mercator(): # Test reading GRIB2 Mercator grid -def grib_grib2_read_mercator(): +def test_grib_grib2_read_mercator(): if gdaltest.grib_drv is None: return 'skip' @@ -488,7 +488,7 @@ def grib_grib2_read_mercator(): # Test reading GRIB2 Mercator grid -def grib_grib2_read_mercator_2sp(): +def test_grib_grib2_read_mercator_2sp(): if gdaltest.grib_drv is None: return 'skip' @@ -518,7 +518,7 @@ def grib_grib2_read_mercator_2sp(): # Test reading GRIB2 Lambert Conformal Conic grid -def grib_grib2_read_lcc(): +def test_grib_grib2_read_lcc(): if gdaltest.grib_drv is None: return 'skip' @@ -548,7 +548,7 @@ def grib_grib2_read_lcc(): # Test reading GRIB2 Polar Stereographic grid -def grib_grib2_read_polar_stereo(): +def test_grib_grib2_read_polar_stereo(): if gdaltest.grib_drv is None: return 'skip' @@ -578,7 +578,7 @@ def grib_grib2_read_polar_stereo(): # Test reading GRIB2 Albers Equal Area grid -def grib_grib2_read_aea(): +def test_grib_grib2_read_aea(): if gdaltest.grib_drv is None: return 'skip' @@ -608,7 +608,7 @@ def grib_grib2_read_aea(): # Test reading GRIB2 Lambert Azimuthal Equal Area grid -def grib_grib2_read_laea(): +def test_grib_grib2_read_laea(): if gdaltest.grib_drv is None: return 'skip' @@ -638,7 +638,7 @@ def grib_grib2_read_laea(): # Test reading GRIB2 with Grid point data - IEEE Floating Point Data (template 5.4) -def grib_grib2_read_template_5_4_grid_point_ieee_floating_point(): +def test_grib_grib2_read_template_5_4_grid_point_ieee_floating_point(): if gdaltest.grib_drv is None: return 'skip' @@ -663,7 +663,7 @@ def grib_grib2_read_template_5_4_grid_point_ieee_floating_point(): # Test reading GRIB2 with NBITS=0 and DECIMAL_SCALE !=0 -def grib_grib2_read_section_5_nbits_zero_decimal_scaled(): +def test_grib_grib2_read_section_5_nbits_zero_decimal_scaled(): if gdaltest.grib_drv is None: return 'skip' @@ -697,7 +697,7 @@ def grib_grib2_read_section_5_nbits_zero_decimal_scaled(): # Test reading GRIB2 with complex packing and spatial differencing of order 1 -def grib_grib2_read_spatial_differencing_order_1(): +def test_grib_grib2_read_spatial_differencing_order_1(): if gdaltest.grib_drv is None: return 'skip' @@ -714,7 +714,7 @@ def grib_grib2_read_spatial_differencing_order_1(): # Test GRIB2 creation options -def grib_grib2_write_creation_options(): +def test_grib_grib2_write_creation_options(): if gdaltest.grib_drv is None: return 'skip' @@ -981,7 +981,7 @@ def grib_grib2_write_creation_options(): # Test GRIB2 write support for projections -def grib_grib2_write_projections(): +def test_grib_grib2_write_projections(): if gdaltest.grib_drv is None: return 'skip' @@ -1147,7 +1147,7 @@ def _grib_read_section(filename, sect_num_to_read): # Test GRIB2 write support for data encodings -def grib_grib2_write_data_encodings(): +def test_grib_grib2_write_data_encodings(): if gdaltest.grib_drv is None: return 'skip' @@ -1400,7 +1400,7 @@ def grib_grib2_write_data_encodings(): # Test GRIB2 write support with warnings/errors -def grib_grib2_write_data_encodings_warnings_and_errors(): +def test_grib_grib2_write_data_encodings_warnings_and_errors(): if gdaltest.grib_drv is None: return 'skip' @@ -1486,7 +1486,7 @@ def grib_grib2_write_data_encodings_warnings_and_errors(): # Test writing temperatures with automatic Celsius -> Kelvin conversion -def grib_grib2_write_temperatures(): +def test_grib_grib2_write_temperatures(): for (src_type, data_encoding, input_unit) in [ (gdal.GDT_Float32, 'IEEE_FLOATING_POINT', None), @@ -1533,7 +1533,7 @@ def grib_grib2_write_temperatures(): ############################################################################### -def grib_grib2_write_nodata(): +def test_grib_grib2_write_nodata(): if gdaltest.grib_drv is None: return 'skip' @@ -1564,7 +1564,7 @@ def grib_grib2_write_nodata(): # Test GRIB2 file with JPEG2000 codestream on a single line (#6719) -def grib_online_grib2_jpeg2000_single_line(): +def test_grib_online_grib2_jpeg2000_single_line(): if gdaltest.grib_drv is None: return 'skip' @@ -1599,38 +1599,38 @@ def grib_online_grib2_jpeg2000_single_line(): gdaltest_list = [ - grib_1, - grib_2, - grib_read_different_sizes_messages, - grib_grib2_read_nodata, - grib_read_units, - grib_read_geotransform_one_n_or_n_one, - grib_read_vsizip, - grib_grib2_test_grib_pds_all_bands, - grib_grib2_read_template_4_15, - grib_grib2_read_png, - grib_grib2_read_template_4_32, - grib_grib2_read_all_zero_data, - grib_grib2_read_rotated_pole_lonlat, - grib_grib2_read_template_4_40, - grib_grib2_read_template_4_unhandled, - grib_grib2_read_transverse_mercator, - grib_grib2_read_mercator, - grib_grib2_read_mercator_2sp, - grib_grib2_read_lcc, - grib_grib2_read_polar_stereo, - grib_grib2_read_aea, - grib_grib2_read_laea, - grib_grib2_read_template_5_4_grid_point_ieee_floating_point, - grib_grib2_read_section_5_nbits_zero_decimal_scaled, - grib_grib2_read_spatial_differencing_order_1, - grib_grib2_write_creation_options, - grib_grib2_write_projections, - grib_grib2_write_data_encodings, - grib_grib2_write_data_encodings_warnings_and_errors, - grib_grib2_write_temperatures, - grib_grib2_write_nodata, - grib_online_grib2_jpeg2000_single_line + test_grib_1, + test_grib_2, + test_grib_read_different_sizes_messages, + test_grib_grib2_read_nodata, + test_grib_read_units, + test_grib_read_geotransform_one_n_or_n_one, + test_grib_read_vsizip, + test_grib_grib2_test_grib_pds_all_bands, + test_grib_grib2_read_template_4_15, + test_grib_grib2_read_png, + test_grib_grib2_read_template_4_32, + test_grib_grib2_read_all_zero_data, + test_grib_grib2_read_rotated_pole_lonlat, + test_grib_grib2_read_template_4_40, + test_grib_grib2_read_template_4_unhandled, + test_grib_grib2_read_transverse_mercator, + test_grib_grib2_read_mercator, + test_grib_grib2_read_mercator_2sp, + test_grib_grib2_read_lcc, + test_grib_grib2_read_polar_stereo, + test_grib_grib2_read_aea, + test_grib_grib2_read_laea, + test_grib_grib2_read_template_5_4_grid_point_ieee_floating_point, + test_grib_grib2_read_section_5_nbits_zero_decimal_scaled, + test_grib_grib2_read_spatial_differencing_order_1, + test_grib_grib2_write_creation_options, + test_grib_grib2_write_projections, + test_grib_grib2_write_data_encodings, + test_grib_grib2_write_data_encodings_warnings_and_errors, + test_grib_grib2_write_temperatures, + test_grib_grib2_write_nodata, + test_grib_online_grib2_jpeg2000_single_line ] if __name__ == '__main__': diff --git a/autotest/gdrivers/gsc.py b/autotest/gdrivers/gsc.py index 58bb8e78d267..d49863368799 100755 --- a/autotest/gdrivers/gsc.py +++ b/autotest/gdrivers/gsc.py @@ -37,14 +37,14 @@ # Test a fake - and certainly incorrect - GSC dataset -def gsc_1(): +def test_gsc_1(): tst = gdaltest.GDALTest('GSC', 'fakegsc.gsc', 1, 0) return tst.testOpen() gdaltest_list = [ - gsc_1] + test_gsc_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/gsg.py b/autotest/gdrivers/gsg.py index 1254a43856b6..5f352ffd00f8 100755 --- a/autotest/gdrivers/gsg.py +++ b/autotest/gdrivers/gsg.py @@ -37,19 +37,19 @@ # Perform simple read tests. -def gsg_1(): +def test_gsg_1(): tst = gdaltest.GDALTest('gsbg', 'gsg_binary.grd', 1, 4672) return tst.testOpen(check_gt=(440720, 60, 0, 3751320, 0, -60)) -def gsg_2(): +def test_gsg_2(): tst = gdaltest.GDALTest('gsag', 'gsg_ascii.grd', 1, 4672) return tst.testOpen(check_gt=(440720, 60, 0, 3751320, 0, -60)) -def gsg_3(): +def test_gsg_3(): tst = gdaltest.GDALTest('gs7bg', 'gsg_7binary.grd', 1, 4672) return tst.testOpen(check_gt=(440720, 60, 0, 3751320, 0, -60)) @@ -58,35 +58,35 @@ def gsg_3(): # Create simple copy and check. -def gsg_4(): +def test_gsg_4(): tst = gdaltest.GDALTest('gsbg', 'gsg_binary.grd', 1, 4672) return tst.testCreateCopy(check_gt=1) -def gsg_5(): +def test_gsg_5(): tst = gdaltest.GDALTest('gsag', 'gsg_ascii.grd', 1, 4672) return tst.testCreateCopy(check_gt=1) -def gsg_6(): +def test_gsg_6(): tst = gdaltest.GDALTest('gsbg', 'gsg_binary.grd', 1, 4672) return tst.testCreate(out_bands=1) -def gsg_7(): +def test_gsg_7(): tst = gdaltest.GDALTest('gs7bg', 'gsg_7binary.grd', 1, 4672) return tst.testCreate(out_bands=1) -def gsg_8(): +def test_gsg_8(): tst = gdaltest.GDALTest('gs7bg', 'gsg_7binary.grd', 1, 4672) @@ -96,14 +96,14 @@ def gsg_8(): gdaltest_list = [ - gsg_1, - gsg_2, - gsg_3, - gsg_4, - gsg_5, - gsg_6, - gsg_7, - gsg_8 + test_gsg_1, + test_gsg_2, + test_gsg_3, + test_gsg_4, + test_gsg_5, + test_gsg_6, + test_gsg_7, + test_gsg_8 ] diff --git a/autotest/gdrivers/gta.py b/autotest/gdrivers/gta.py index 1be1a356d050..ed4eb58a2589 100755 --- a/autotest/gdrivers/gta.py +++ b/autotest/gdrivers/gta.py @@ -55,7 +55,7 @@ # Verify we have the driver. -def gta_1(): +def test_gta_1(): gdaltest.gta_drv = gdal.GetDriverByName('GTA') if gdaltest.gta_drv is None: @@ -67,7 +67,7 @@ def gta_1(): # Test updating existing dataset, check srs, check gt -def gta_2(): +def test_gta_2(): if gdaltest.gta_drv is None: return 'skip' @@ -119,7 +119,7 @@ def gta_2(): # Test writing and readings GCPs -def gta_3(): +def test_gta_3(): if gdaltest.gta_drv is None: return 'skip' @@ -159,7 +159,7 @@ def gta_3(): # Test band metadata -def gta_4(): +def test_gta_4(): if gdaltest.gta_drv is None: return 'skip' @@ -233,7 +233,7 @@ def gta_4(): # Test compression algorithms -def gta_5(): +def test_gta_5(): if gdaltest.gta_drv is None: return 'skip' @@ -277,11 +277,11 @@ def test_gta_create(filename, checksum): gdaltest_list = [ - gta_1, - gta_2, - gta_3, - gta_4, - gta_5, + test_gta_1, + test_gta_2, + test_gta_3, + test_gta_4, + test_gta_5, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/gtx.py b/autotest/gdrivers/gtx.py index 620f6db4734a..eaa51597c2bf 100755 --- a/autotest/gdrivers/gtx.py +++ b/autotest/gdrivers/gtx.py @@ -37,7 +37,7 @@ # Test reading a small gtx file. -def gtx_1(): +def test_gtx_1(): tst = gdaltest.GDALTest('GTX', 'hydroc1.gtx', 1, 64183) gt = (276.725, 0.05, 0.0, 42.775, 0.0, -0.05) @@ -45,7 +45,7 @@ def gtx_1(): gdaltest_list = [ - gtx_1] + test_gtx_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/gxf.py b/autotest/gdrivers/gxf.py index 8b970146aaff..b45ff327ded8 100755 --- a/autotest/gdrivers/gxf.py +++ b/autotest/gdrivers/gxf.py @@ -42,7 +42,7 @@ # Test a small GXF sample -def gxf_1(): +def test_gxf_1(): tst = gdaltest.GDALTest('GXF', 'small.gxf', 1, 90) @@ -52,7 +52,7 @@ def gxf_1(): # Test an other GXF sample (with continuous line) -def gxf_2(): +def test_gxf_2(): tst = gdaltest.GDALTest('GXF', 'small2.gxf', 1, 65042) wkt = """PROJCS["NAD27 / Ohio North", @@ -96,7 +96,7 @@ def test_gxf(downloadURL, fileName, checksum, download_size): assert ds.GetRasterBand(1).Checksum() == checksum, 'Bad checksum. Expected %d, got %d' % (checksum, ds.GetRasterBand(1).Checksum()) -gdaltest_list = [gxf_1, gxf_2] +gdaltest_list = [test_gxf_1, test_gxf_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/hdf5.py b/autotest/gdrivers/hdf5.py index 0b18b46ac952..756ce5546898 100755 --- a/autotest/gdrivers/hdf5.py +++ b/autotest/gdrivers/hdf5.py @@ -62,7 +62,7 @@ def check_no_file_leaks(): # Confirm expected subdataset information. -def hdf5_2(): +def test_hdf5_2(): ds = gdal.Open('data/groups.h5') sds_list = ds.GetMetadata('SUBDATASETS') @@ -91,7 +91,7 @@ def hdf5_2(): # subdataset stuff. -def hdf5_3(): +def test_hdf5_3(): ds = gdal.Open('HDF5:"data/u8be.h5"://TestArray') @@ -112,7 +112,7 @@ def hdf5_3(): # Confirm subdataset access, and checksum. -def hdf5_4(): +def test_hdf5_4(): ds = gdal.Open('HDF5:"data/u8be.h5"://TestArray') @@ -127,7 +127,7 @@ def hdf5_4(): # Similar check on a 16bit dataset. -def hdf5_5(): +def test_hdf5_5(): ds = gdal.Open('HDF5:"data/groups.h5"://MyGroup/dset1') @@ -142,7 +142,7 @@ def hdf5_5(): # Test generating an overview on a subdataset. -def hdf5_6(): +def test_hdf5_6(): shutil.copyfile('data/groups.h5', 'tmp/groups.h5') @@ -181,7 +181,7 @@ def hdf5_6(): # Coarse metadata check (regression test for #2412). -def hdf5_7(): +def test_hdf5_7(): ds = gdal.Open('data/metadata.h5') metadata = ds.GetMetadata() @@ -209,7 +209,7 @@ def hdf5_7(): # Test metadata names. -def hdf5_8(): +def test_hdf5_8(): ds = gdal.Open('data/metadata.h5') metadata = ds.GetMetadata() @@ -273,7 +273,7 @@ def scanMetadata(parts): # Variable length string metadata check (regression test for #4228). -def hdf5_9(): +def test_hdf5_9(): if int(gdal.VersionInfo('VERSION_NUM')) < 1900: gdaltest.post_reason('would crash') @@ -318,7 +318,7 @@ def hdf5_9(): # Test CSK_DGM.h5 (#4160) -def hdf5_10(): +def test_hdf5_10(): # Try opening the QLK subdataset to check that no error is generated gdal.ErrorReset() @@ -356,7 +356,7 @@ def hdf5_10(): # Test CSK_GEC.h5 (#4160) -def hdf5_11(): +def test_hdf5_11(): # Try opening the QLK subdataset to check that no error is generated gdal.ErrorReset() @@ -393,7 +393,7 @@ def hdf5_11(): # Test ODIM_H5 (#5032) -def hdf5_12(): +def test_hdf5_12(): if not gdaltest.download_file('http://trac.osgeo.org/gdal/raw-attachment/ticket/5032/norsa.ss.ppi-00.5-dbz.aeqd-1000.20070601T000039Z.hdf', 'norsa.ss.ppi-00.5-dbz.aeqd-1000.20070601T000039Z.hdf'): return 'skip' @@ -422,7 +422,7 @@ def hdf5_12(): # Test MODIS L2 HDF5 GCPs (#6666) -def hdf5_13(): +def test_hdf5_13(): if not gdaltest.download_file('http://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A2016273115000.L2_LAC_OC.nc', 'A2016273115000.L2_LAC_OC.nc'): return 'skip' @@ -446,7 +446,7 @@ def hdf5_13(): # Test complex data subsets -def hdf5_14(): +def test_hdf5_14(): ds = gdal.Open('data/complex.h5') sds_list = ds.GetMetadata('SUBDATASETS') @@ -476,7 +476,7 @@ def hdf5_14(): # Start with Float32 -def hdf5_15(): +def test_hdf5_15(): ds = gdal.Open('HDF5:"data/complex.h5"://f32') @@ -490,7 +490,7 @@ def hdf5_15(): # Repeat for Float64 -def hdf5_16(): +def test_hdf5_16(): ds = gdal.Open('HDF5:"data/complex.h5"://f64') @@ -504,7 +504,7 @@ def hdf5_16(): # Repeat for Float16 -def hdf5_17(): +def test_hdf5_17(): ds = gdal.Open('HDF5:"data/complex.h5"://f16') @@ -516,7 +516,7 @@ def hdf5_17(): return 'success' -def hdf5_single_char_varname(): +def test_hdf5_single_char_varname(): ds = gdal.Open('HDF5:"data/single_char_varname.h5"://e') if ds is None: @@ -525,7 +525,7 @@ def hdf5_single_char_varname(): return 'success' -def hdf5_virtual_file(): +def test_hdf5_virtual_file(): hdf5_files = [ 'CSK_GEC.h5', 'vlstr_metadata.h5', @@ -569,24 +569,24 @@ def test_hdf5(downloadURL, fileName, subdatasetname, checksum, download_size): gdaltest_list = [ - hdf5_2, - hdf5_3, - hdf5_4, - hdf5_5, - hdf5_6, - hdf5_7, - hdf5_8, - hdf5_9, - hdf5_10, - hdf5_11, - hdf5_12, - hdf5_13, - hdf5_14, - hdf5_15, - hdf5_16, - hdf5_17, - hdf5_single_char_varname, - hdf5_virtual_file, + test_hdf5_2, + test_hdf5_3, + test_hdf5_4, + test_hdf5_5, + test_hdf5_6, + test_hdf5_7, + test_hdf5_8, + test_hdf5_9, + test_hdf5_10, + test_hdf5_11, + test_hdf5_12, + test_hdf5_13, + test_hdf5_14, + test_hdf5_15, + test_hdf5_16, + test_hdf5_17, + test_hdf5_single_char_varname, + test_hdf5_virtual_file, ] diff --git a/autotest/gdrivers/hf2.py b/autotest/gdrivers/hf2.py index a899006089ac..12b96b6996f9 100755 --- a/autotest/gdrivers/hf2.py +++ b/autotest/gdrivers/hf2.py @@ -38,7 +38,7 @@ # Test CreateCopy() of byte.tif -def hf2_1(): +def test_hf2_1(): tst = gdaltest.GDALTest('HF2', 'byte.tif', 1, 4672) return tst.testCreateCopy(vsimem=1, check_gt=(-67.00041667, 0.00083333, 0.0, 50.000416667, 0.0, -0.00083333)) @@ -47,7 +47,7 @@ def hf2_1(): # Test CreateCopy() of byte.tif with options -def hf2_2(): +def test_hf2_2(): tst = gdaltest.GDALTest('HF2', 'byte.tif', 1, 4672, options=['COMPRESS=YES', 'BLOCKSIZE=10']) ret = tst.testCreateCopy(new_filename='tmp/hf2_2.hfz') @@ -61,7 +61,7 @@ def hf2_2(): # Test CreateCopy() of float.img -def hf2_3(): +def test_hf2_3(): tst = gdaltest.GDALTest('HF2', 'float.img', 1, 23529) return tst.testCreateCopy(check_minmax=0) @@ -70,7 +70,7 @@ def hf2_3(): # Test CreateCopy() of n43.dt0 -def hf2_4(): +def test_hf2_4(): tst = gdaltest.GDALTest('HF2', 'n43.dt0', 1, 49187) return tst.testCreateCopy() @@ -79,17 +79,17 @@ def hf2_4(): # Cleanup -def hf2_cleanup(): +def test_hf2_cleanup(): return 'success' gdaltest_list = [ - hf2_1, - hf2_2, - hf2_3, - hf2_4, - hf2_cleanup] + test_hf2_1, + test_hf2_2, + test_hf2_3, + test_hf2_4, + test_hf2_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/hfa.py b/autotest/gdrivers/hfa.py index 7df7b3f43760..224a34f7b92c 100755 --- a/autotest/gdrivers/hfa.py +++ b/autotest/gdrivers/hfa.py @@ -41,7 +41,7 @@ # Verify we can read the special histogram metadata from a provided image. -def hfa_histread(): +def test_hfa_histread(): ds = gdal.Open('../gcore/data/utmsmall.img') md = ds.GetRasterBand(1).GetMetadata() @@ -82,7 +82,7 @@ def hfa_histread(): # info is preserved. -def hfa_histwrite(): +def test_hfa_histwrite(): drv = gdal.GetDriverByName('HFA') ds_src = gdal.Open('../gcore/data/utmsmall.img') @@ -124,7 +124,7 @@ def hfa_histwrite(): # histogram information, the new histogram can then be read back in. -def hfa_histrewrite(): +def test_hfa_histrewrite(): drv = gdal.GetDriverByName('HFA') ds_src = gdal.Open('../gcore/data/utmsmall.img') @@ -165,7 +165,7 @@ def hfa_histrewrite(): # Verify we can read metadata of int.img. -def hfa_int_stats_1(): +def test_hfa_int_stats_1(): ds = gdal.Open('data/int.img') md = ds.GetRasterBand(1).GetMetadata() @@ -205,7 +205,7 @@ def hfa_int_stats_1(): # Verify we can read band statistics of int.img. -def hfa_int_stats_2(): +def test_hfa_int_stats_2(): ds = gdal.Open('data/int.img') stats = ds.GetRasterBand(1).GetStatistics(False, True) @@ -235,7 +235,7 @@ def hfa_int_stats_2(): # Verify we can read metadata of float.img. -def hfa_float_stats_1(): +def test_hfa_float_stats_1(): ds = gdal.Open('data/float.img') md = ds.GetRasterBand(1).GetMetadata() @@ -283,7 +283,7 @@ def hfa_float_stats_1(): # Verify we can read band statistics of float.img. -def hfa_float_stats_2(): +def test_hfa_float_stats_2(): ds = gdal.Open('data/float.img') stats = ds.GetRasterBand(1).GetStatistics(False, True) @@ -313,7 +313,7 @@ def hfa_float_stats_2(): # Verify we can read image data. -def hfa_int_read(): +def test_hfa_int_read(): ds = gdal.Open('data/int.img') band = ds.GetRasterBand(1) @@ -331,7 +331,7 @@ def hfa_int_read(): # Verify we can read image data. -def hfa_float_read(): +def test_hfa_float_read(): ds = gdal.Open('data/float.img') band = ds.GetRasterBand(1) @@ -357,7 +357,7 @@ def hfa_float_read(): # verify we can read PE_STRING coordinate system. -def hfa_pe_read(): +def test_hfa_pe_read(): ds = gdal.Open('data/87test.img') wkt = ds.GetProjectionRef() @@ -374,7 +374,7 @@ def hfa_pe_read(): # Verify we can write PE_STRING nodes. -def hfa_pe_write(): +def test_hfa_pe_write(): drv = gdal.GetDriverByName('HFA') ds_src = gdal.Open('data/87test.img') @@ -402,7 +402,7 @@ def hfa_pe_write(): # Verify we can write and read large metadata items. -def hfa_metadata_1(): +def test_hfa_metadata_1(): drv = gdal.GetDriverByName('HFA') ds = drv.Create('tmp/md_1.img', 100, 150, 1, gdal.GDT_Byte) @@ -428,7 +428,7 @@ def hfa_metadata_1(): # nodes. -def hfa_metadata_2(): +def test_hfa_metadata_2(): ds = gdal.Open('tmp/md_1.img', gdal.GA_Update) md = ds.GetRasterBand(1).GetMetadata() @@ -458,7 +458,7 @@ def hfa_metadata_2(): # moving the HFAEntry to the end of the file. (bug #1109) -def hfa_grow_rrdlist(): +def test_hfa_grow_rrdlist(): import shutil @@ -490,7 +490,7 @@ def hfa_grow_rrdlist(): # Make sure an old .ige file is deleted when creating a new dataset. (#1784) -def hfa_clean_ige(): +def test_hfa_clean_ige(): # Create an imagine file, forcing creation of an .ige file. @@ -542,7 +542,7 @@ def hfa_clean_ige(): # Verify that we can read this corrupt .aux file without hanging (#1907) -def hfa_corrupt_aux(): +def test_hfa_corrupt_aux(): # NOTE: we depend on being able to open .aux files as a weak sort of # dataset. @@ -568,7 +568,7 @@ def hfa_corrupt_aux(): # support MapInformation for units (#1967) -def hfa_mapinformation_units(): +def test_hfa_mapinformation_units(): # NOTE: we depend on being able to open .aux files as a weak sort of # dataset. @@ -588,7 +588,7 @@ def hfa_mapinformation_units(): # Write nodata value. -def hfa_nodata_write(): +def test_hfa_nodata_write(): drv = gdal.GetDriverByName('HFA') ds = drv.Create('tmp/nodata.img', 7, 7, 1, gdal.GDT_Byte) @@ -611,7 +611,7 @@ def hfa_nodata_write(): # Verify written nodata value. -def hfa_nodata_read(): +def test_hfa_nodata_read(): ds = gdal.Open('tmp/nodata.img') b = ds.GetRasterBand(1) @@ -651,7 +651,7 @@ def hfa_nodata_read(): # Verify we read simple affine geotransforms properly. -def hfa_rotated_read(): +def test_hfa_rotated_read(): ds = gdal.Open('data/fg118-91.aux') @@ -676,7 +676,7 @@ def hfa_rotated_read(): # Verify we can write affine geotransforms. -def hfa_rotated_write(): +def test_hfa_rotated_write(): # make sure we aren't preserving info in .aux.xml file try: @@ -747,7 +747,7 @@ def hfa_rotated_write(): ############################################################################### # Test creating an in memory copy. -def hfa_vsimem(): +def test_hfa_vsimem(): tst = gdaltest.GDALTest('HFA', 'byte.tif', 1, 4672) @@ -758,7 +758,7 @@ def hfa_vsimem(): # the .img file. (#2422) -def hfa_proName(): +def test_hfa_proName(): drv = gdal.GetDriverByName('HFA') src_ds = gdal.Open('data/stateplane.vrt') @@ -793,7 +793,7 @@ def hfa_proName(): ############################################################################### # Read a compressed file where no block has been written (#2523) -def hfa_read_empty_compressed(): +def test_hfa_read_empty_compressed(): drv = gdal.GetDriverByName('HFA') ds = drv.Create('tmp/emptycompressed.img', 64, 64, 1, options=['COMPRESSED=YES']) @@ -815,7 +815,7 @@ def hfa_read_empty_compressed(): # Verify "unique values" based color table (#2419) -def hfa_unique_values_color_table(): +def test_hfa_unique_values_color_table(): ds = gdal.Open('data/i8u_c_i.img') @@ -846,7 +846,7 @@ def hfa_unique_values_color_table(): # Verify "unique values" based histogram. -def hfa_unique_values_hist(): +def test_hfa_unique_values_hist(): try: gdal.RasterAttributeTable() @@ -897,7 +897,7 @@ def hfa_unique_values_hist(): # Verify reading of 3rd order XFORM polynomials. -def hfa_xforms_3rd(): +def test_hfa_xforms_3rd(): ds = gdal.Open('data/42BW_420730_VT2.aux') @@ -954,7 +954,7 @@ def hfa_xforms_3rd(): # Verify that we can clear an existing color table -def hfa_delete_colortable(): +def test_hfa_delete_colortable(): # copy a file to tmp dir to modify. open('tmp/i8u.img', 'wb').write(open('data/i8u_c_i.img', 'rb').read()) @@ -990,7 +990,7 @@ def hfa_delete_colortable(): # Verify that we can clear an existing color table (#2842) -def hfa_delete_colortable2(): +def test_hfa_delete_colortable2(): # copy a file to tmp dir to modify. src_ds = gdal.Open('../gcore/data/8bit_pal.bmp') @@ -1030,7 +1030,7 @@ def hfa_delete_colortable2(): # Verify we can read the special histogram metadata from a provided image. -def hfa_excluded_values(): +def test_hfa_excluded_values(): ds = gdal.Open('data/dem10.img') md = ds.GetRasterBand(1).GetMetadata() @@ -1046,7 +1046,7 @@ def hfa_excluded_values(): # verify that we propagate nodata to overviews in .img/.rrd format. -def hfa_ov_nodata(): +def test_hfa_ov_nodata(): drv = gdal.GetDriverByName('HFA') src_ds = gdal.Open('data/nodata_int.asc') @@ -1088,7 +1088,7 @@ def hfa_ov_nodata(): # Confirm that we can read 8bit grayscale overviews for 1bit images. -def hfa_read_bit2grayscale(): +def test_hfa_read_bit2grayscale(): ds = gdal.Open('data/small1bit.img') band = ds.GetRasterBand(1) @@ -1110,7 +1110,7 @@ def hfa_read_bit2grayscale(): # the bit2grayscale algorithm (#2914) -def hfa_write_bit2grayscale(): +def test_hfa_write_bit2grayscale(): import shutil @@ -1151,7 +1151,7 @@ def hfa_write_bit2grayscale(): # Verify handling of camera model metadata (#2675) -def hfa_camera_md(): +def test_hfa_camera_md(): ds = gdal.Open('/vsisparse/data/251_sparse.xml') @@ -1205,7 +1205,7 @@ def hfa_verify_dataset_projection(dataset_path, exp_wkt): # Verify can read Transverse Mercator (South Orientated) projections -def hfa_read_tmso_projection(): +def test_hfa_read_tmso_projection(): exp_wkt = 'PROJCS["Transverse Mercator (South Orientated)",GEOGCS["Cape-1",DATUM["Cape-1",SPHEROID["Clarke 1880 Arc",6378249.145,293.4663077168331],TOWGS84[-136,-108,-292,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator_South_Orientated"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",21],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["meters",1]]' return hfa_verify_dataset_projection('../gcore/data/22281.aux', exp_wkt) @@ -1213,7 +1213,7 @@ def hfa_read_tmso_projection(): # Verify can write Transverse Mercator (South Orientated) projections to aux files -def hfa_write_tmso_projection(): +def test_hfa_write_tmso_projection(): dataset_path = 'tmp/tmso.img' out_ds = gdal.GetDriverByName('HFA').Create(dataset_path, 1, 1) gt = (0, 1, 0, 0, 0, 1) @@ -1229,7 +1229,7 @@ def hfa_write_tmso_projection(): # Verify can read Hotine Oblique Mercator (Variant A) projections -def hfa_read_homva_projection(): +def test_hfa_read_homva_projection(): exp_wkt = 'PROJCS["Hotine Oblique Mercator (Variant A)",GEOGCS["GDM 2000",DATUM["GDM 2000",SPHEROID["GRS 1980",6378137,298.2572220960422],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Hotine_Oblique_Mercator"],PARAMETER["latitude_of_center",4],PARAMETER["longitude_of_center",115],PARAMETER["azimuth",53.31580995],PARAMETER["rectified_grid_angle",53.13010236111111],PARAMETER["scale_factor",0.99984],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["meters",1]]' return hfa_verify_dataset_projection('../gcore/data/3376.tif', exp_wkt) @@ -1237,7 +1237,7 @@ def hfa_read_homva_projection(): # Verify can write Transverse Mercator (South Orientated) projections to aux files -def hfa_write_homva_projection(): +def test_hfa_write_homva_projection(): dataset_path = 'tmp/homva.img' out_ds = gdal.GetDriverByName('HFA').Create(dataset_path, 1, 1) gt = (0, 1, 0, 0, 0, 1) @@ -1254,7 +1254,7 @@ def hfa_write_homva_projection(): # and fetching actual overviews. -def hfa_rde_overviews(): +def test_hfa_rde_overviews(): # Create an imagine file, forcing creation of an .ige file. @@ -1293,7 +1293,7 @@ def hfa_rde_overviews(): # in the .img and .rrd seem to be updated properly. -def hfa_copyfiles(): +def test_hfa_copyfiles(): drv = gdal.GetDriverByName('HFA') drv.CopyFiles('tmp/newnamexxx_after_copy.img', 'data/spill.img') @@ -1349,7 +1349,7 @@ def hfa_copyfiles(): ############################################################################### # Test the ability to write a RAT (#999) -def hfa_write_rat(): +def test_hfa_write_rat(): drv = gdal.GetDriverByName('HFA') @@ -1399,7 +1399,7 @@ def hfa_write_rat(): # Test STATISTICS creation option -def hfa_createcopy_statistics(): +def test_hfa_createcopy_statistics(): tmpAuxXml = '../gcore/data/byte.tif.aux.xml' try: @@ -1432,7 +1432,7 @@ def hfa_createcopy_statistics(): # Test GetUnitType() -def hfa_read_elevation_units(): +def test_hfa_read_elevation_units(): ds = gdal.Open('../gcore/data/erdas_cm.img') unittype = ds.GetRasterBand(1).GetUnitType() @@ -1465,49 +1465,49 @@ def hfa_read_elevation_units(): gdaltest_list = [ - hfa_histread, - hfa_histwrite, - hfa_histrewrite, - hfa_int_stats_1, - hfa_int_stats_2, - hfa_float_stats_1, - hfa_float_stats_2, - hfa_int_read, - hfa_float_read, - hfa_pe_read, - hfa_pe_write, - hfa_metadata_1, - hfa_metadata_2, - hfa_grow_rrdlist, - hfa_clean_ige, - hfa_corrupt_aux, - hfa_mapinformation_units, - hfa_nodata_write, - hfa_nodata_read, - hfa_rotated_read, - hfa_rotated_write, - hfa_vsimem, - hfa_proName, - hfa_read_empty_compressed, - hfa_unique_values_color_table, - hfa_unique_values_hist, - hfa_xforms_3rd, - hfa_delete_colortable, - hfa_delete_colortable2, - hfa_excluded_values, - hfa_ov_nodata, - hfa_read_bit2grayscale, - hfa_write_bit2grayscale, - hfa_camera_md, - hfa_rde_overviews, - hfa_copyfiles, - hfa_write_rat, - hfa_createcopy_statistics, - hfa_read_tmso_projection, - hfa_read_homva_projection, - hfa_write_tmso_projection, - hfa_write_homva_projection, - hfa_read_elevation_units] + test_hfa_histread, + test_hfa_histwrite, + test_hfa_histrewrite, + test_hfa_int_stats_1, + test_hfa_int_stats_2, + test_hfa_float_stats_1, + test_hfa_float_stats_2, + test_hfa_int_read, + test_hfa_float_read, + test_hfa_pe_read, + test_hfa_pe_write, + test_hfa_metadata_1, + test_hfa_metadata_2, + test_hfa_grow_rrdlist, + test_hfa_clean_ige, + test_hfa_corrupt_aux, + test_hfa_mapinformation_units, + test_hfa_nodata_write, + test_hfa_nodata_read, + test_hfa_rotated_read, + test_hfa_rotated_write, + test_hfa_vsimem, + test_hfa_proName, + test_hfa_read_empty_compressed, + test_hfa_unique_values_color_table, + test_hfa_unique_values_hist, + test_hfa_xforms_3rd, + test_hfa_delete_colortable, + test_hfa_delete_colortable2, + test_hfa_excluded_values, + test_hfa_ov_nodata, + test_hfa_read_bit2grayscale, + test_hfa_write_bit2grayscale, + test_hfa_camera_md, + test_hfa_rde_overviews, + test_hfa_copyfiles, + test_hfa_write_rat, + test_hfa_createcopy_statistics, + test_hfa_read_tmso_projection, + test_hfa_read_homva_projection, + test_hfa_write_tmso_projection, + test_hfa_write_homva_projection, + test_hfa_read_elevation_units] if __name__ == '__main__': diff --git a/autotest/gdrivers/ida.py b/autotest/gdrivers/ida.py index f6c5125fc1f0..05eb52281cef 100755 --- a/autotest/gdrivers/ida.py +++ b/autotest/gdrivers/ida.py @@ -38,7 +38,7 @@ # Perform simple read test. -def ida_1(): +def test_ida_1(): tst = gdaltest.GDALTest('ida', 'DWI01012.AFC', 1, 4026) return tst.testOpen() @@ -47,7 +47,7 @@ def ida_1(): # Verify some auxiliary data. -def ida_2(): +def test_ida_2(): ds = gdal.Open('data/DWI01012.AFC') @@ -79,7 +79,7 @@ def ida_2(): # Create simple copy and check. -def ida_3(): +def test_ida_3(): tst = gdaltest.GDALTest('ida', 'DWI01012.AFC', 1, 4026) @@ -91,7 +91,7 @@ def ida_3(): # Test ACEA Projection. -def ida_4(): +def test_ida_4(): gdaltest.ida_tst = gdaltest.GDALTest('ida', 'DWI01012.AFC', 1, 4026) @@ -115,7 +115,7 @@ def ida_4(): # Test Goodes Projection. -def ida_5(): +def test_ida_5(): gdaltest.ida_tst = gdaltest.GDALTest('ida', 'DWI01012.AFC', 1, 4026) @@ -136,7 +136,7 @@ def ida_5(): # Test LCC Projection. -def ida_6(): +def test_ida_6(): gdaltest.ida_tst = gdaltest.GDALTest('ida', 'DWI01012.AFC', 1, 4026) @@ -160,7 +160,7 @@ def ida_6(): # Test LAEA Projection. -def ida_7(): +def test_ida_7(): gdaltest.ida_tst = gdaltest.GDALTest('ida', 'DWI01012.AFC', 1, 4026) @@ -180,13 +180,13 @@ def ida_7(): gdaltest_list = [ - ida_1, - ida_2, - ida_3, - ida_4, - ida_5, - ida_6, - ida_7 + test_ida_1, + test_ida_2, + test_ida_3, + test_ida_4, + test_ida_5, + test_ida_6, + test_ida_7 ] diff --git a/autotest/gdrivers/idrisi.py b/autotest/gdrivers/idrisi.py index 4f8a7795f3a9..83f929fed1cc 100755 --- a/autotest/gdrivers/idrisi.py +++ b/autotest/gdrivers/idrisi.py @@ -39,7 +39,7 @@ # Read test of byte file. -def idrisi_1(): +def test_idrisi_1(): tst = gdaltest.GDALTest('RST', 'byte.rst', 1, 5044) return tst.testOpen() @@ -48,7 +48,7 @@ def idrisi_1(): # Read test of byte file. -def idrisi_2(): +def test_idrisi_2(): tst = gdaltest.GDALTest('RST', 'real.rst', 1, 5275) return tst.testOpen() @@ -57,7 +57,7 @@ def idrisi_2(): # -def idrisi_3(): +def test_idrisi_3(): tst = gdaltest.GDALTest('RST', 'float32.bil', 1, 27) @@ -67,7 +67,7 @@ def idrisi_3(): # -def idrisi_4(): +def test_idrisi_4(): tst = gdaltest.GDALTest('RST', 'rgbsmall.tif', 2, 21053) @@ -78,7 +78,7 @@ def idrisi_4(): # Cleanup. -def idrisi_cleanup(): +def test_idrisi_cleanup(): gdaltest.clean_tmp() try: os.unlink('data/rgbsmall.tif.aux.xml') @@ -92,11 +92,11 @@ def idrisi_cleanup(): gdaltest_list = [ - idrisi_1, - idrisi_2, - idrisi_3, - idrisi_4, - idrisi_cleanup] + test_idrisi_1, + test_idrisi_2, + test_idrisi_3, + test_idrisi_4, + test_idrisi_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/ignfheightasciigrid.py b/autotest/gdrivers/ignfheightasciigrid.py index e2596b4b7db9..afe0b67d31b8 100755 --- a/autotest/gdrivers/ignfheightasciigrid.py +++ b/autotest/gdrivers/ignfheightasciigrid.py @@ -36,7 +36,7 @@ import gdaltest -def ignfheightasciigrid_1(): +def test_ignfheightasciigrid_1(): tst = gdaltest.GDALTest('IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar1.mnt', 1, 21) @@ -44,7 +44,7 @@ def ignfheightasciigrid_1(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_2(): +def test_ignfheightasciigrid_2(): tst = gdaltest.GDALTest('IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar2.mnt', 1, 21) @@ -52,7 +52,7 @@ def ignfheightasciigrid_2(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_3(): +def test_ignfheightasciigrid_3(): tst = gdaltest.GDALTest('IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar3.mnt', 1, 21) @@ -60,7 +60,7 @@ def ignfheightasciigrid_3(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_4(): +def test_ignfheightasciigrid_4(): tst = gdaltest.GDALTest('IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar4.mnt', 1, 21) @@ -68,7 +68,7 @@ def ignfheightasciigrid_4(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_5(): +def test_ignfheightasciigrid_5(): tst = gdaltest.GDALTest('IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar1_nocoords.mnt', 1, 21) @@ -76,7 +76,7 @@ def ignfheightasciigrid_5(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_6(): +def test_ignfheightasciigrid_6(): tst = gdaltest.GDALTest( 'IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar1_nocoords_noprec.mnt', 1, 21) @@ -84,7 +84,7 @@ def ignfheightasciigrid_6(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_7(): +def test_ignfheightasciigrid_7(): tst = gdaltest.GDALTest( 'IGNFHeightASCIIGrid', 'ignfheightasciigrid_ar1_noprec.mnt', 1, 21) @@ -92,7 +92,7 @@ def ignfheightasciigrid_7(): return tst.testOpen(check_gt=gt, check_prj='WGS84') -def ignfheightasciigrid_description_multiword(): +def test_ignfheightasciigrid_description_multiword(): filename = '/vsimem/ignfheightasciigrid_invalid' ok_content = '2 3 49 50 1 1 1 0 1 0 -0. MULTI WORD\r1 2 3 4' @@ -105,7 +105,7 @@ def ignfheightasciigrid_description_multiword(): return 'success' -def ignfheightasciigrid_invalid(): +def test_ignfheightasciigrid_invalid(): filename = '/vsimem/ignfheightasciigrid_invalid' ok_content = '2 3 49 50 1 1 1 0 1 0 -0. DESC\r1 2 3 4' @@ -158,7 +158,7 @@ def ignfheightasciigrid_invalid(): return 'success' -def ignfheightasciigrid_huge(): +def test_ignfheightasciigrid_huge(): filename = '/vsimem/ignfheightasciigrid_huge' ok_content = '2 3 49 50 1 1 1 0 1 0 -0. MULTI WORD\r1 2 3 4' @@ -176,7 +176,7 @@ def ignfheightasciigrid_huge(): return 'success' -def ignfheightasciigrid_gra(): +def test_ignfheightasciigrid_gra(): tst = gdaltest.GDALTest( 'IGNFHeightASCIIGrid', 'ignfheightasciigrid.gra', 1, 21) @@ -191,7 +191,7 @@ def ignfheightasciigrid_gra(): return 'success' -def ignfheightasciigrid_gra_invalid(): +def test_ignfheightasciigrid_gra_invalid(): contents = ['49 50\r\n2\r\n', # missing values '49 50\r\n2 3\r\n', # missing line @@ -213,18 +213,18 @@ def ignfheightasciigrid_gra_invalid(): gdaltest_list = [ - ignfheightasciigrid_1, - ignfheightasciigrid_2, - ignfheightasciigrid_3, - ignfheightasciigrid_4, - ignfheightasciigrid_5, - ignfheightasciigrid_6, - ignfheightasciigrid_7, - ignfheightasciigrid_description_multiword, - ignfheightasciigrid_invalid, - ignfheightasciigrid_huge, - ignfheightasciigrid_gra, - ignfheightasciigrid_gra_invalid, + test_ignfheightasciigrid_1, + test_ignfheightasciigrid_2, + test_ignfheightasciigrid_3, + test_ignfheightasciigrid_4, + test_ignfheightasciigrid_5, + test_ignfheightasciigrid_6, + test_ignfheightasciigrid_7, + test_ignfheightasciigrid_description_multiword, + test_ignfheightasciigrid_invalid, + test_ignfheightasciigrid_huge, + test_ignfheightasciigrid_gra, + test_ignfheightasciigrid_gra_invalid, ] diff --git a/autotest/gdrivers/ilwis.py b/autotest/gdrivers/ilwis.py index 46c40b2b7cab..e0c8c96fedca 100755 --- a/autotest/gdrivers/ilwis.py +++ b/autotest/gdrivers/ilwis.py @@ -37,7 +37,7 @@ # Perform simple read test. -def ilwis_1(): +def test_ilwis_1(): tst = gdaltest.GDALTest('ilwis', 'LanduseSmall.mpr', 1, 2351) @@ -69,7 +69,7 @@ def ilwis_1(): # copy byte data and verify. -def ilwis_2(): +def test_ilwis_2(): tst = gdaltest.GDALTest('ilwis', 'byte.tif', 1, 4672) @@ -80,7 +80,7 @@ def ilwis_2(): # copy floating point data and use Create interface. -def ilwis_3(): +def test_ilwis_3(): tst = gdaltest.GDALTest('ilwis', 'float.img', 1, 23529) @@ -90,7 +90,7 @@ def ilwis_3(): # Try multi band dataset. -def ilwis_4(): +def test_ilwis_4(): tst = gdaltest.GDALTest('ilwis', 'rgbsmall.tif', 2, 21053) @@ -101,7 +101,7 @@ def ilwis_4(): # Test vsi in-memory support. -def ilwis_5(): +def test_ilwis_5(): tst = gdaltest.GDALTest('ilwis', 'byte.tif', 1, 4672) @@ -117,18 +117,18 @@ def ilwis_5(): # properly. So we do the brute force approach... -def ilwis_cleanup(): +def test_ilwis_cleanup(): gdaltest.clean_tmp() return 'success' gdaltest_list = [ - ilwis_1, - ilwis_2, - ilwis_3, - ilwis_4, - ilwis_5, - ilwis_cleanup] + test_ilwis_1, + test_ilwis_2, + test_ilwis_3, + test_ilwis_4, + test_ilwis_5, + test_ilwis_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/ingr.py b/autotest/gdrivers/ingr.py index 787a2eb3f295..5407420332a0 100755 --- a/autotest/gdrivers/ingr.py +++ b/autotest/gdrivers/ingr.py @@ -41,7 +41,7 @@ # Read test of byte file. -def ingr_1(): +def test_ingr_1(): tst = gdaltest.GDALTest('INGR', '8bit_rgb.cot', 2, 4855) return tst.testOpen() @@ -50,7 +50,7 @@ def ingr_1(): # Read uint32 file. -def ingr_2(): +def test_ingr_2(): tst = gdaltest.GDALTest('INGR', 'uint32.cot', 1, 4672) return tst.testOpen() @@ -59,7 +59,7 @@ def ingr_2(): # Test paletted file, including checking the palette (format 02 I think). -def ingr_3(): +def test_ingr_3(): tst = gdaltest.GDALTest('INGR', '8bit_pal.cot', 1, 4855) result = tst.testOpen() @@ -78,7 +78,7 @@ def ingr_3(): # frmt02 is a plain byte format -def ingr_4(): +def test_ingr_4(): tst = gdaltest.GDALTest('INGR', 'frmt02.cot', 1, 26968) return tst.testOpen() @@ -87,7 +87,7 @@ def ingr_4(): # Test creation. -def ingr_5(): +def test_ingr_5(): tst = gdaltest.GDALTest('INGR', 'frmt02.cot', 1, 26968) return tst.testCreate() @@ -96,7 +96,7 @@ def ingr_5(): # Test createcopy. -def ingr_6(): +def test_ingr_6(): tst = gdaltest.GDALTest('INGR', 'frmt02.cot', 1, 26968) return tst.testCreate() @@ -105,7 +105,7 @@ def ingr_6(): # JPEG 8bit -def ingr_7(): +def test_ingr_7(): tst = gdaltest.GDALTest('INGR', 'frmt30.cot', 1, 29718) return tst.testOpen() @@ -114,7 +114,7 @@ def ingr_7(): # Read simple RLE -def ingr_8(): +def test_ingr_8(): tst = gdaltest.GDALTest('INGR', 'frmt09.cot', 1, 23035) return tst.testOpen() @@ -123,7 +123,7 @@ def ingr_8(): # Read Simple RLE Variable -def ingr_9(): +def test_ingr_9(): tst = gdaltest.GDALTest('INGR', 'frmt10.cot', 1, 47031) return tst.testOpen() @@ -132,7 +132,7 @@ def ingr_9(): # CCITT bitonal -def ingr_10(): +def test_ingr_10(): tst = gdaltest.GDALTest('INGR', 'frmt24.cit', 1, 23035) return tst.testOpen() @@ -141,7 +141,7 @@ def ingr_10(): # Adaptive RLE - 24 bit. -def ingr_11(): +def test_ingr_11(): tst = gdaltest.GDALTest('INGR', 'frmt27.cot', 2, 45616) return tst.testOpen() @@ -150,7 +150,7 @@ def ingr_11(): # Uncompressed RGB -def ingr_12(): +def test_ingr_12(): tst = gdaltest.GDALTest('INGR', 'frmt28.cot', 2, 45616) return tst.testOpen() @@ -159,7 +159,7 @@ def ingr_12(): # Adaptive RLE 8bit. -def ingr_13(): +def test_ingr_13(): tst = gdaltest.GDALTest('INGR', 'frmt29.cot', 1, 26968) return tst.testOpen() @@ -168,7 +168,7 @@ def ingr_13(): # JPEG RGB -def ingr_14(): +def test_ingr_14(): ds = gdal.Open('data/frmt31.cot') cs = ds.GetRasterBand(1).Checksum() @@ -184,7 +184,7 @@ def ingr_14(): # Same, but through vsimem all in memory. -def ingr_15(): +def test_ingr_15(): tst = gdaltest.GDALTest('INGR', 'frmt02.cot', 1, 26968) result = tst.testCreateCopy(vsimem=1) @@ -200,7 +200,7 @@ def ingr_15(): # Read simple RLE tiled -def ingr_16(): +def test_ingr_16(): tst = gdaltest.GDALTest('INGR', 'frmt09t.cot', 1, 3178) return tst.testOpen() @@ -209,7 +209,7 @@ def ingr_16(): # Test writing 9 RLE bitonal compression (#5030) -def ingr_17(): +def test_ingr_17(): src_ds = gdal.Open('data/frmt09.cot') out_ds = gdal.GetDriverByName('INGR').CreateCopy('/vsimem/ingr_17.rle', src_ds) @@ -235,7 +235,7 @@ def ingr_17(): # Test 'random access' in simple RLE -def ingr_18(): +def test_ingr_18(): ds = gdal.Open('data/frmt09.cot') for y in range(ds.RasterYSize): @@ -263,32 +263,32 @@ def ingr_18(): return 'success' -def ingr_cleanup(): +def test_ingr_cleanup(): gdal.Unlink('data/frmt09.cot.aux.xml') return 'success' gdaltest_list = [ - ingr_1, - ingr_2, - ingr_3, - ingr_4, - ingr_5, - ingr_6, - ingr_7, - ingr_8, - ingr_9, - ingr_10, - ingr_11, - ingr_12, - ingr_13, - ingr_14, - ingr_15, - ingr_16, - ingr_17, - ingr_18, - ingr_cleanup] + test_ingr_1, + test_ingr_2, + test_ingr_3, + test_ingr_4, + test_ingr_5, + test_ingr_6, + test_ingr_7, + test_ingr_8, + test_ingr_9, + test_ingr_10, + test_ingr_11, + test_ingr_12, + test_ingr_13, + test_ingr_14, + test_ingr_15, + test_ingr_16, + test_ingr_17, + test_ingr_18, + test_ingr_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/iris.py b/autotest/gdrivers/iris.py index 0f24d35adbfd..ffc6647202a5 100755 --- a/autotest/gdrivers/iris.py +++ b/autotest/gdrivers/iris.py @@ -39,7 +39,7 @@ # Test reading a - fake - IRIS dataset -def iris_1(): +def test_iris_1(): tst = gdaltest.GDALTest('IRIS', 'fakeiris.dat', 1, 65532) return tst.testOpen() @@ -48,7 +48,7 @@ def iris_1(): # Test reading a real world IRIS dataset. -def iris_2(): +def test_iris_2(): ds = gdal.Open('data/iristest.dat') if ds.GetRasterBand(1).Checksum() != 52872: @@ -121,8 +121,8 @@ def iris_2(): gdaltest_list = [ - iris_1, - iris_2] + test_iris_1, + test_iris_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/isce.py b/autotest/gdrivers/isce.py index e671e710d6d7..b546bfbabad8 100755 --- a/autotest/gdrivers/isce.py +++ b/autotest/gdrivers/isce.py @@ -39,7 +39,7 @@ # Perform simple read test. -def isce_1(): +def test_isce_1(): tst = gdaltest.GDALTest('isce', 'isce.slc', 1, 350) @@ -67,7 +67,7 @@ def isce_1(): # Test reading of metadata from the ISCE metadata domain -def isce_2(): +def test_isce_2(): ds = gdal.Open('data/isce.slc') val = ds.GetMetadataItem('IMAGE_TYPE', 'ISCE') @@ -80,7 +80,7 @@ def isce_2(): # Verify this can be exported losslessly. -def isce_3(): +def test_isce_3(): tst = gdaltest.GDALTest('isce', 'isce.slc', 1, 350) return tst.testCreateCopy(check_gt=0, new_filename='isce.tst.slc') @@ -89,17 +89,17 @@ def isce_3(): # Verify VSIF*L capacity -def isce_4(): +def test_isce_4(): tst = gdaltest.GDALTest('isce', 'isce.slc', 1, 350) return tst.testCreateCopy(check_gt=0, new_filename='isce.tst.slc', vsimem=1) gdaltest_list = [ - isce_1, - isce_2, - isce_3, - isce_4, + test_isce_1, + test_isce_2, + test_isce_3, + test_isce_4, ] diff --git a/autotest/gdrivers/isis.py b/autotest/gdrivers/isis.py index fdd1a46ac82f..5887ffdf8df2 100755 --- a/autotest/gdrivers/isis.py +++ b/autotest/gdrivers/isis.py @@ -42,7 +42,7 @@ # Perform simple read test on isis3 detached dataset. -def isis_1(): +def test_isis_1(): srs = """PROJCS["Equirectangular Mars", GEOGCS["GCS_Mars", DATUM["D_Mars", @@ -66,7 +66,7 @@ def isis_1(): # Perform simple read test on isis3 detached dataset. -def isis_2(): +def test_isis_2(): srs = """PROJCS["Equirectangular mars", GEOGCS["GCS_mars", DATUM["D_mars", @@ -90,7 +90,7 @@ def isis_2(): # Perform simple read test on isis3 detached dataset with GeoTIFF image file -def isis_3(): +def test_isis_3(): srs = """PROJCS["Equirectangular Mars", GEOGCS["GCS_Mars", DATUM["D_Mars", @@ -113,7 +113,7 @@ def isis_3(): # ISIS3 -> ISIS3 conversion -def isis_4(): +def test_isis_4(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', @@ -198,7 +198,7 @@ def isis_4(): # Label+image creation + WRITE_BOUNDING_DEGREES=NO option -def isis_5(): +def test_isis_5(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['USE_SRC_LABEL=NO', @@ -223,7 +223,7 @@ def isis_5(): # Detached label creation and COMMENT option -def isis_6(): +def test_isis_6(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['DATA_LOCATION=EXTERNAL', @@ -260,7 +260,7 @@ def isis_6(): # Uncompressed GeoTIFF creation -def isis_7(): +def test_isis_7(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['DATA_LOCATION=GEOTIFF', @@ -307,7 +307,7 @@ def isis_7(): # Compressed GeoTIFF creation -def isis_8(): +def test_isis_8(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['DATA_LOCATION=GEOTIFF', @@ -341,7 +341,7 @@ def isis_8(): # Tiled creation + EXTERNAL_FILENAME -def isis_9(): +def test_isis_9(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['DATA_LOCATION=EXTERNAL', @@ -372,7 +372,7 @@ def isis_9(): # Tiled creation + regular GeoTIFF + EXTERNAL_FILENAME -def isis_10(): +def test_isis_10(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['USE_SRC_LABEL=NO', @@ -399,7 +399,7 @@ def isis_10(): # Tiled creation + compressed GeoTIFF -def isis_11(): +def test_isis_11(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978, options=['USE_SRC_LABEL=NO', @@ -422,7 +422,7 @@ def isis_11(): # Multiband -def isis_12(): +def test_isis_12(): src_ds = gdal.Open('../gcore/data/stefan_full_rgba.tif') gdal.Translate('/vsimem/isis_tmp.lbl', src_ds, format='ISIS3') @@ -441,7 +441,7 @@ def isis_12(): # Multiband tiled -def isis_13(): +def test_isis_13(): src_ds = gdal.Open('../gcore/data/stefan_full_rgba.tif') gdal.Translate('/vsimem/isis_tmp.lbl', src_ds, format='ISIS3', @@ -462,7 +462,7 @@ def isis_13(): # Multiband with uncompressed GeoTIFF -def isis_14(): +def test_isis_14(): src_ds = gdal.Open('../gcore/data/stefan_full_rgba.tif') gdal.Translate('/vsimem/isis_tmp.lbl', src_ds, format='ISIS3', @@ -482,7 +482,7 @@ def isis_14(): # Multiband with uncompressed tiled GeoTIFF -def isis_15(): +def test_isis_15(): src_ds = gdal.Open('../gcore/data/stefan_full_rgba.tif') gdal.Translate('/vsimem/isis_tmp.lbl', src_ds, format='ISIS3', @@ -503,7 +503,7 @@ def isis_15(): # Test Create() without anything else -def isis_16(): +def test_isis_16(): for read_before_write in [False, True]: for init_nd in [False, True]: @@ -558,7 +558,7 @@ def isis_16(): # Test create copy through Create() -def isis_17(): +def test_isis_17(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978) return tst.testCreate(vsimem=1) @@ -566,7 +566,7 @@ def isis_17(): # Test SRS serialization and deserialization -def isis_18(): +def test_isis_18(): sr = osr.SpatialReference() sr.SetEquirectangular2(0, 1, 2, 0, 0) @@ -798,7 +798,7 @@ def isis_18(): # Test gdal.Info() with json:ISIS3 metadata domain -def isis_19(): +def test_isis_19(): ds = gdal.Open('data/isis3_detached.lbl') res = gdal.Info(ds, format='json', extraMDDomains=['json:ISIS3']) @@ -819,7 +819,7 @@ def isis_19(): # Test gdal.Translate() subsetting and label preservation -def isis_20(): +def test_isis_20(): with gdaltest.error_handler(): gdal.Translate('/vsimem/isis_tmp.lbl', 'data/isis3_detached.lbl', @@ -838,7 +838,7 @@ def isis_20(): # Test gdal.Warp() and label preservation -def isis_21(): +def test_isis_21(): with gdaltest.error_handler(): gdal.Warp('/vsimem/isis_tmp.lbl', 'data/isis3_detached.lbl', @@ -861,7 +861,7 @@ def isis_21(): # Test source JSon use -def isis_22(): +def test_isis_22(): ds = gdal.GetDriverByName('ISIS3').Create('/vsimem/isis_tmp.lbl', 1, 1) # Invalid Json @@ -959,7 +959,7 @@ def isis_22(): # Test nodata remapping -def isis_23(): +def test_isis_23(): mem_ds = gdal.Translate('', 'data/byte.tif', format='MEM') mem_ds.SetProjection('') @@ -1018,7 +1018,7 @@ def cancel_cbk(pct, msg, user_data): # Test error cases -def isis_24(): +def test_isis_24(): # For DATA_LOCATION=EXTERNAL, the main filename should have a .lbl extension with gdaltest.error_handler(): @@ -1405,7 +1405,7 @@ def isis_24(): # Test CreateCopy() and scale and offset -def isis_25(): +def test_isis_25(): mem_ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 1) mem_ds.GetRasterBand(1).SetScale(10) @@ -1426,7 +1426,7 @@ def isis_25(): # Test objects with same name -def isis_26(): +def test_isis_26(): gdal.FileFromMemBuffer('/vsimem/in.lbl', """Object = IsisCube Object = Core StartByte = 1 @@ -1506,7 +1506,7 @@ def isis_26(): # Test history -def isis_27(): +def test_isis_27(): for src_location in ['LABEL', 'EXTERNAL']: for dst_location in ['LABEL', 'EXTERNAL']: @@ -1591,7 +1591,7 @@ def isis_27(): # Test preservation of non-pixel sections -def isis_28(): +def test_isis_28(): gdal.FileFromMemBuffer('/vsimem/in_table', "FOO") gdal.FileFromMemBuffer('/vsimem/in.lbl', """Object = IsisCube @@ -1698,7 +1698,7 @@ def isis_28(): # Test complete removal of history -def isis_29(): +def test_isis_29(): with gdaltest.error_handler(): gdal.Translate('/vsimem/in.lbl', 'data/byte.tif', format='ISIS3') @@ -1740,7 +1740,7 @@ def isis_29(): # Test Fill() on a GeoTIFF file -def isis_30(): +def test_isis_30(): ds = gdal.GetDriverByName('ISIS3').Create('/vsimem/test.lbl', 1, 1, options=['DATA_LOCATION=GEOTIFF']) ds.GetRasterBand(1).Fill(1) @@ -1760,7 +1760,7 @@ def isis_30(): # Test correct working of block caching with a GeoTIFF file -def isis_31(): +def test_isis_31(): gdal.SetConfigOption('GDAL_FORCE_CACHING', 'YES') ds = gdal.GetDriverByName('ISIS3').Create('/vsimem/test.lbl', 1, 1, options=['DATA_LOCATION=GEOTIFF']) @@ -1781,37 +1781,37 @@ def isis_31(): gdaltest_list = [ - isis_1, - isis_2, - isis_3, - isis_4, - isis_5, - isis_6, - isis_7, - isis_8, - isis_9, - isis_10, - isis_11, - isis_12, - isis_13, - isis_14, - isis_15, - isis_16, - isis_17, - isis_18, - isis_19, - isis_20, - isis_21, - isis_22, - isis_23, - isis_24, - isis_25, - isis_26, - isis_27, - isis_28, - isis_29, - isis_30, - isis_31] + test_isis_1, + test_isis_2, + test_isis_3, + test_isis_4, + test_isis_5, + test_isis_6, + test_isis_7, + test_isis_8, + test_isis_9, + test_isis_10, + test_isis_11, + test_isis_12, + test_isis_13, + test_isis_14, + test_isis_15, + test_isis_16, + test_isis_17, + test_isis_18, + test_isis_19, + test_isis_20, + test_isis_21, + test_isis_22, + test_isis_23, + test_isis_24, + test_isis_25, + test_isis_26, + test_isis_27, + test_isis_28, + test_isis_29, + test_isis_30, + test_isis_31] if __name__ == '__main__': diff --git a/autotest/gdrivers/isis2.py b/autotest/gdrivers/isis2.py index 61326c66a52f..c4a6141aade1 100755 --- a/autotest/gdrivers/isis2.py +++ b/autotest/gdrivers/isis2.py @@ -38,7 +38,7 @@ # ftp://ftpflag.wr.usgs.gov/dist/pigpen/venus/venustopo_download/ovda_dtm.zip -def isis2_1(): +def test_isis2_1(): tst = gdaltest.GDALTest('ISIS2', 'arvidson_original_truncated.cub', 1, 382) expected_prj = """PROJCS["SIMPLE_CYLINDRICAL VENUS", @@ -61,7 +61,7 @@ def isis2_1(): ############################################################################### # Test simple creation on disk. -def isis2_2(): +def test_isis2_2(): tst = gdaltest.GDALTest('ISIS2', 'byte.tif', 1, 4672) @@ -71,7 +71,7 @@ def isis2_2(): # Test a different data type with some options. -def isis2_3(): +def test_isis2_3(): tst = gdaltest.GDALTest('ISIS2', 'float32.tif', 1, 4672, options=['LABELING_METHOD=DETACHED', 'IMAGE_EXTENSION=qub']) @@ -80,9 +80,9 @@ def isis2_3(): gdaltest_list = [ - isis2_1, - isis2_2, - isis2_3] + test_isis2_1, + test_isis2_2, + test_isis2_3] if __name__ == '__main__': diff --git a/autotest/gdrivers/jdem.py b/autotest/gdrivers/jdem.py index 219ae6e3c73a..bce9c65185e8 100755 --- a/autotest/gdrivers/jdem.py +++ b/autotest/gdrivers/jdem.py @@ -37,14 +37,14 @@ # Test reading a - fake - JDEM dataset -def jdem_1(): +def test_jdem_1(): tst = gdaltest.GDALTest('JDEM', 'fakejdem.mem', 1, 15) return tst.testOpen() gdaltest_list = [ - jdem_1] + test_jdem_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/jp2kak.py b/autotest/gdrivers/jp2kak.py index 8a9007cb673e..2b8bb446708f 100755 --- a/autotest/gdrivers/jp2kak.py +++ b/autotest/gdrivers/jp2kak.py @@ -40,7 +40,7 @@ # Read test of simple byte reference data. -def jp2kak_1(): +def test_jp2kak_1(): gdaltest.jp2kak_drv = gdal.GetDriverByName('JP2KAK') if gdaltest.jp2kak_drv is None: @@ -55,7 +55,7 @@ def jp2kak_1(): # Read test of simple 16bit reference data. -def jp2kak_2(): +def test_jp2kak_2(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -67,7 +67,7 @@ def jp2kak_2(): # Test lossless copying. -def jp2kak_3(): +def test_jp2kak_3(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -81,7 +81,7 @@ def jp2kak_3(): # Test GeoJP2 production with geotransform. -def jp2kak_4(): +def test_jp2kak_4(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -95,7 +95,7 @@ def jp2kak_4(): # Test GeoJP2 production with gcps. -def jp2kak_5(): +def test_jp2kak_5(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -110,7 +110,7 @@ def jp2kak_5(): # -def jp2kak_8(): +def test_jp2kak_8(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -126,7 +126,7 @@ def jp2kak_8(): # -def jp2kak_9(): +def test_jp2kak_9(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -140,7 +140,7 @@ def jp2kak_9(): # -def jp2kak_10(): +def test_jp2kak_10(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -168,7 +168,7 @@ def jp2kak_10(): # -def jp2kak_11(): +def test_jp2kak_11(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -186,7 +186,7 @@ def jp2kak_11(): # -def jp2kak_12(): +def test_jp2kak_12(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -204,7 +204,7 @@ def jp2kak_12(): # Test internal overviews. # -def jp2kak_13(): +def test_jp2kak_13(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -239,7 +239,7 @@ def jp2kak_13(): # -def jp2kak_14(): +def test_jp2kak_14(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -285,7 +285,7 @@ def jp2kak_14(): # -def jp2kak_15(): +def test_jp2kak_15(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -308,7 +308,7 @@ def jp2kak_15(): # -def jp2kak_16(): +def test_jp2kak_16(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -341,7 +341,7 @@ def jp2kak_16(): # This test case was adapted from the "jp2kak_7()" case above. -def jp2kak_17(): +def test_jp2kak_17(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -375,7 +375,7 @@ def jp2kak_17(): # Test lossless copying of Int16 -def jp2kak_18(): +def test_jp2kak_18(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -389,7 +389,7 @@ def jp2kak_18(): # Test lossless copying of UInt16 -def jp2kak_19(): +def test_jp2kak_19(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -403,7 +403,7 @@ def jp2kak_19(): # Test auto-promotion of 1bit alpha band to 8bit -def jp2kak_20(): +def test_jp2kak_20(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -461,7 +461,7 @@ def jp2kak_20(): # Test non nearest upsampling -def jp2kak_21(): +def test_jp2kak_21(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -499,7 +499,7 @@ def jp2kak_21(): # Test RGBA datasets -def jp2kak_22(): +def test_jp2kak_22(): if gdaltest.jp2kak_drv is None: return 'skip' @@ -530,7 +530,7 @@ def jp2kak_22(): ############################################################################### # Cleanup. -def jp2kak_cleanup(): +def test_jp2kak_cleanup(): gdaltest.reregister_all_jpeg2000_drivers() @@ -538,27 +538,27 @@ def jp2kak_cleanup(): gdaltest_list = [ - jp2kak_1, - jp2kak_2, - jp2kak_3, - jp2kak_4, - jp2kak_5, - jp2kak_8, - jp2kak_9, - jp2kak_10, - jp2kak_11, - jp2kak_12, - jp2kak_13, - jp2kak_14, - jp2kak_15, - jp2kak_16, - jp2kak_17, - jp2kak_18, - jp2kak_19, - jp2kak_20, - jp2kak_21, - jp2kak_22, - jp2kak_cleanup] + test_jp2kak_1, + test_jp2kak_2, + test_jp2kak_3, + test_jp2kak_4, + test_jp2kak_5, + test_jp2kak_8, + test_jp2kak_9, + test_jp2kak_10, + test_jp2kak_11, + test_jp2kak_12, + test_jp2kak_13, + test_jp2kak_14, + test_jp2kak_15, + test_jp2kak_16, + test_jp2kak_17, + test_jp2kak_18, + test_jp2kak_19, + test_jp2kak_20, + test_jp2kak_21, + test_jp2kak_22, + test_jp2kak_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/jp2lura.py b/autotest/gdrivers/jp2lura.py index f9c18b29b529..a584baf4295c 100755 --- a/autotest/gdrivers/jp2lura.py +++ b/autotest/gdrivers/jp2lura.py @@ -45,7 +45,7 @@ # Verify we have the driver. -def jp2lura_1(): +def test_jp2lura_1(): gdaltest.jp2lura_drv = gdal.GetDriverByName('JP2Lura') if gdaltest.jp2lura_drv is None: @@ -72,7 +72,7 @@ def jp2lura_1(): # -def jp2lura_missing_license_num(): +def test_jp2lura_missing_license_num(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -95,7 +95,7 @@ def jp2lura_missing_license_num(): # -def jp2lura_invalid_license_num(): +def test_jp2lura_invalid_license_num(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -151,7 +151,7 @@ def validate(filename, expected_gmljp2=True, return_error_count=False, oidoc=Non # Open byte.jp2 -def jp2lura_2(): +def test_jp2lura_2(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -184,7 +184,7 @@ def jp2lura_2(): # Open int16.jp2 -def jp2lura_3(): +def test_jp2lura_3(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -215,7 +215,7 @@ def jp2lura_3(): # Test copying byte.jp2 -def jp2lura_4(out_filename='tmp/jp2lura_4.jp2'): +def test_jp2lura_4(out_filename='tmp/jp2lura_4.jp2'): if gdaltest.jp2lura_drv is None: return 'skip' @@ -289,14 +289,14 @@ def jp2lura_4(out_filename='tmp/jp2lura_4.jp2'): return 'success' -def jp2lura_4_vsimem(): - return jp2lura_4('/vsimem/jp2lura_4.jp2') +def test_jp2lura_4_vsimem(): + return test_jp2lura_4('/vsimem/jp2lura_4.jp2') ############################################################################### # Test copying int16.jp2 -def jp2lura_5(): +def test_jp2lura_5(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -308,7 +308,7 @@ def jp2lura_5(): # Test reading ll.jp2 -def jp2lura_6(): +def test_jp2lura_6(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -328,7 +328,7 @@ def jp2lura_6(): # Open byte.jp2.gz (test use of the VSIL API) -def jp2lura_7(): +def test_jp2lura_7(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -340,7 +340,7 @@ def jp2lura_7(): # Test a JP2Lura with the 3 bands having 13bit depth and the 4th one 1 bit -def jp2lura_8(): +def test_jp2lura_8(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -364,7 +364,7 @@ def jp2lura_8(): # Check that we can use .j2w world files (#4651) -def jp2lura_9(): +def test_jp2lura_9(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -474,7 +474,7 @@ def DISABLED_jp2lura_11(): # Check that PAM overrides internal georeferencing (#5279) -def jp2lura_12(): +def test_jp2lura_12(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -523,7 +523,7 @@ def jp2lura_12(): # Check that PAM overrides internal GCPs (#5279) -def jp2lura_13(): +def test_jp2lura_13(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -587,7 +587,7 @@ def jp2lura_13(): # Check that we get GCPs even there's no projection info -def jp2lura_14(): +def test_jp2lura_14(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -603,7 +603,7 @@ def jp2lura_14(): # Test reading PixelIsPoint file (#5437) -def jp2lura_16(): +def test_jp2lura_16(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -643,7 +643,7 @@ def jp2lura_16(): # Test writing PixelIsPoint file (#5437) -def jp2lura_17(): +def test_jp2lura_17(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -680,7 +680,7 @@ def jp2lura_17(): # multiple of 1024 (#5480) -def jp2lura_18(): +def test_jp2lura_18(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -705,7 +705,7 @@ def jp2lura_18(): # Test reading file where GMLJP2 has nul character instead of \n (#5760) -def jp2lura_19(): +def test_jp2lura_19(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -722,7 +722,7 @@ def jp2lura_19(): # Validate GMLJP2 content against schema -def jp2lura_20(): +def test_jp2lura_20(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -794,7 +794,7 @@ def jp2lura_20(): # Test RGBA support -def jp2lura_22(): +def test_jp2lura_22(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1002,7 +1002,7 @@ def DISABLED_jp2lura_23(): # Test Grey+alpha support -def jp2lura_24(): +def test_jp2lura_24(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1073,7 +1073,7 @@ def jp2lura_24(): # Test multiband support -def jp2lura_25(): +def test_jp2lura_25(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1110,7 +1110,7 @@ def jp2lura_25(): # Test CreateCopy() from a JPEG2000 with a 2048x2048 tiling -def jp2lura_27(): +def test_jp2lura_27(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1196,7 +1196,7 @@ def jp2lura_test_codeblock(filename, codeblock_width, codeblock_height): return True -def jp2lura_28(): +def test_jp2lura_28(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1235,7 +1235,7 @@ def jp2lura_28(): # Test color table support -def jp2lura_30(): +def test_jp2lura_30(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1347,7 +1347,7 @@ def DISABLED_jp2lura_33(): # Test opening a file whose dimensions are > 2^31-1 -def jp2lura_34(): +def test_jp2lura_34(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1365,7 +1365,7 @@ def jp2lura_34(): ############################################################################### # Test opening a truncated file -def jp2lura_35(): +def test_jp2lura_35(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1383,7 +1383,7 @@ def jp2lura_35(): # Test we cannot create files with more than 16384 bands -def jp2lura_36(): +def test_jp2lura_36(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1402,7 +1402,7 @@ def jp2lura_36(): # Test metadata reading & writing -def jp2lura_37(): +def test_jp2lura_37(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1522,7 +1522,7 @@ def jp2lura_37(): # Test non-EPSG SRS (so written with a GML dictionary) -def jp2lura_38(): +def test_jp2lura_38(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1564,7 +1564,7 @@ def jp2lura_38(): # Test GMLJP2OVERRIDE configuration option and DGIWG GMLJP2 -def jp2lura_39(): +def test_jp2lura_39(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1638,7 +1638,7 @@ def jp2lura_39(): # Test we can parse GMLJP2 v2.0 -def jp2lura_40(): +def test_jp2lura_40(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1722,7 +1722,7 @@ def jp2lura_40(): # Test USE_SRC_CODESTREAM=YES -def jp2lura_41(): +def test_jp2lura_41(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1772,7 +1772,7 @@ def jp2lura_41(): # Get structure of a JPEG2000 file -def jp2lura_43(): +def test_jp2lura_43(): ret = gdal.GetJPEG2000StructureAsString('data/byte.jp2', ['ALL=YES']) if ret is None: @@ -1784,7 +1784,7 @@ def jp2lura_43(): # Test GMLJP2v2 -def jp2lura_45(): +def test_jp2lura_45(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1877,7 +1877,7 @@ def jp2lura_45(): # Test writing & reading RPC in GeoJP2 box -def jp2lura_47(): +def test_jp2lura_47(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1903,7 +1903,7 @@ def jp2lura_47(): # Test reading a dataset whose tile dimensions are larger than dataset ones -def jp2lura_48(): +def test_jp2lura_48(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1924,7 +1924,7 @@ def jp2lura_48(): ############################################################################### -def jp2lura_online_1(): +def test_jp2lura_online_1(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1947,7 +1947,7 @@ def jp2lura_online_1(): ############################################################################### -def jp2lura_online_2(): +def test_jp2lura_online_2(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -1979,7 +1979,7 @@ def jp2lura_online_2(): ############################################################################### -def jp2lura_online_3(): +def test_jp2lura_online_3(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2013,7 +2013,7 @@ def jp2lura_online_3(): ############################################################################### -def jp2lura_online_4(): +def test_jp2lura_online_4(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2048,7 +2048,7 @@ def jp2lura_online_4(): # Try reading JP2Lura with color table -def jp2lura_online_5(): +def test_jp2lura_online_5(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2073,7 +2073,7 @@ def jp2lura_online_5(): # Try reading YCbCr JP2Lura as RGB -def jp2lura_online_6(): +def test_jp2lura_online_6(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2099,7 +2099,7 @@ def jp2lura_online_6(): # Test GDAL_GEOREF_SOURCES -def jp2lura_49(): +def test_jp2lura_49(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2230,7 +2230,7 @@ def jp2lura_49(): ############################################################################### # Test reading split IEEE-754 Float32 -def jp2lura_50(): +def test_jp2lura_50(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2242,7 +2242,7 @@ def jp2lura_50(): # Test split IEEE-754 Float32 -def jp2lura_51(): +def test_jp2lura_51(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2324,7 +2324,7 @@ def jp2lura_51(): # Test other data types -def jp2lura_52(): +def test_jp2lura_52(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2365,7 +2365,7 @@ def jp2lura_52(): # Test RATE and QUALITY -def jp2lura_53(): +def test_jp2lura_53(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2424,7 +2424,7 @@ def jp2lura_53(): # Test RasterIO edge cases -def jp2lura_54(): +def test_jp2lura_54(): if gdaltest.jp2lura_drv is None: return 'skip' @@ -2461,7 +2461,7 @@ def jp2lura_54(): ############################################################################### -def jp2lura_cleanup(): +def test_jp2lura_cleanup(): gdaltest.reregister_all_jpeg2000_drivers() @@ -2469,74 +2469,74 @@ def jp2lura_cleanup(): gdaltest_list = [ - jp2lura_1, - jp2lura_missing_license_num, - jp2lura_invalid_license_num, - jp2lura_2, - jp2lura_3, - jp2lura_4, - jp2lura_4_vsimem, - jp2lura_5, - jp2lura_6, - jp2lura_7, - jp2lura_8, - jp2lura_9, + test_jp2lura_1, + test_jp2lura_missing_license_num, + test_jp2lura_invalid_license_num, + test_jp2lura_2, + test_jp2lura_3, + test_jp2lura_4, + test_jp2lura_4_vsimem, + test_jp2lura_5, + test_jp2lura_6, + test_jp2lura_7, + test_jp2lura_8, + test_jp2lura_9, # jp2lura_10, # jp2lura_11, - jp2lura_12, - jp2lura_13, - jp2lura_14, - jp2lura_16, - jp2lura_17, - jp2lura_18, - jp2lura_19, - jp2lura_20, + test_jp2lura_12, + test_jp2lura_13, + test_jp2lura_14, + test_jp2lura_16, + test_jp2lura_17, + test_jp2lura_18, + test_jp2lura_19, + test_jp2lura_20, # jp2lura_21, - jp2lura_22, + test_jp2lura_22, # jp2lura_23, - jp2lura_24, - jp2lura_25, + test_jp2lura_24, + test_jp2lura_25, # jp2lura_26, - jp2lura_27, - jp2lura_28, + test_jp2lura_27, + test_jp2lura_28, # jp2lura_29, - jp2lura_30, + test_jp2lura_30, # jp2lura_31, # jp2lura_32, # jp2lura_33, - jp2lura_34, - jp2lura_35, - jp2lura_36, - jp2lura_37, - jp2lura_38, - jp2lura_39, - jp2lura_40, - jp2lura_41, + test_jp2lura_34, + test_jp2lura_35, + test_jp2lura_36, + test_jp2lura_37, + test_jp2lura_38, + test_jp2lura_39, + test_jp2lura_40, + test_jp2lura_41, # jp2lura_42, - jp2lura_43, + test_jp2lura_43, # jp2lura_44, - jp2lura_45, + test_jp2lura_45, # jp2lura_46, - jp2lura_47, - jp2lura_48, - jp2lura_49, - jp2lura_50, - jp2lura_51, - jp2lura_52, - jp2lura_53, - jp2lura_54, - jp2lura_online_1, - jp2lura_online_2, - jp2lura_online_3, - jp2lura_online_4, - jp2lura_online_5, - jp2lura_online_6, - jp2lura_cleanup] + test_jp2lura_47, + test_jp2lura_48, + test_jp2lura_49, + test_jp2lura_50, + test_jp2lura_51, + test_jp2lura_52, + test_jp2lura_53, + test_jp2lura_54, + test_jp2lura_online_1, + test_jp2lura_online_2, + test_jp2lura_online_3, + test_jp2lura_online_4, + test_jp2lura_online_5, + test_jp2lura_online_6, + test_jp2lura_cleanup] disabled_gdaltest_list = [ - jp2lura_1, - jp2lura_53, - jp2lura_cleanup] + test_jp2lura_1, + test_jp2lura_53, + test_jp2lura_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/jp2metadata.py b/autotest/gdrivers/jp2metadata.py index 0d59f5cbc269..db9fd6fa9dd6 100755 --- a/autotest/gdrivers/jp2metadata.py +++ b/autotest/gdrivers/jp2metadata.py @@ -40,7 +40,7 @@ ############################################################################### # Test bugfix for #5249 (Irrelevant ERDAS GeoTIFF JP2Box read) -def jp2metadata_1(): +def test_jp2metadata_1(): ds = gdal.Open('data/erdas_foo.jp2') if ds is None: @@ -62,7 +62,7 @@ def jp2metadata_1(): # Test Pleiades imagery metadata -def jp2metadata_2(): +def test_jp2metadata_2(): # Pleiades product description http://www.cscrs.itu.edu.tr/assets/downloads/PleiadesUserGuide.pdf try: @@ -114,7 +114,7 @@ def jp2metadata_2(): # disabled. -def jp2metadata_3(): +def test_jp2metadata_3(): gdal.SetConfigOption('GDAL_IGNORE_AXIS_ORIENTATION', 'YES') @@ -153,7 +153,7 @@ def jp2metadata_3(): # axis order coordinate system (urn:...:EPSG::4326). -def jp2metadata_4(): +def test_jp2metadata_4(): exp_wkt = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]' @@ -190,7 +190,7 @@ def jp2metadata_4(): # but with explicit axisName being easting, northing (#5960) -def jp2metadata_5(): +def test_jp2metadata_5(): exp_wkt = 'PROJCS["ETRS89 / LAEA Europe",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",52],PARAMETER["longitude_of_center",10],PARAMETER["false_easting",4321000],PARAMETER["false_northing",3210000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","3035"]]' @@ -223,11 +223,11 @@ def jp2metadata_5(): gdaltest_list = [ - jp2metadata_1, - jp2metadata_2, - jp2metadata_3, - jp2metadata_4, - jp2metadata_5 + test_jp2metadata_1, + test_jp2metadata_2, + test_jp2metadata_3, + test_jp2metadata_4, + test_jp2metadata_5 ] diff --git a/autotest/gdrivers/jp2openjpeg.py b/autotest/gdrivers/jp2openjpeg.py index f380d2cc148f..b0e931fe03a9 100755 --- a/autotest/gdrivers/jp2openjpeg.py +++ b/autotest/gdrivers/jp2openjpeg.py @@ -45,7 +45,7 @@ # Verify we have the driver. -def jp2openjpeg_1(): +def test_jp2openjpeg_1(): gdaltest.jp2openjpeg_drv = gdal.GetDriverByName('JP2OpenJPEG') if gdaltest.jp2openjpeg_drv is None: @@ -59,7 +59,7 @@ def jp2openjpeg_1(): # Open byte.jp2 -def jp2openjpeg_2(): +def test_jp2openjpeg_2(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -92,7 +92,7 @@ def jp2openjpeg_2(): # Open int16.jp2 -def jp2openjpeg_3(): +def test_jp2openjpeg_3(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -123,7 +123,7 @@ def jp2openjpeg_3(): # Test copying byte.jp2 -def jp2openjpeg_4(out_filename='tmp/jp2openjpeg_4.jp2'): +def test_jp2openjpeg_4(out_filename='tmp/jp2openjpeg_4.jp2'): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -193,14 +193,14 @@ def jp2openjpeg_4(out_filename='tmp/jp2openjpeg_4.jp2'): return 'success' -def jp2openjpeg_4_vsimem(): - return jp2openjpeg_4('/vsimem/jp2openjpeg_4.jp2') +def test_jp2openjpeg_4_vsimem(): + return test_jp2openjpeg_4('/vsimem/jp2openjpeg_4.jp2') ############################################################################### # Test copying int16.jp2 -def jp2openjpeg_5(): +def test_jp2openjpeg_5(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -212,7 +212,7 @@ def jp2openjpeg_5(): # Test reading ll.jp2 -def jp2openjpeg_6(): +def test_jp2openjpeg_6(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -232,7 +232,7 @@ def jp2openjpeg_6(): # Open byte.jp2.gz (test use of the VSIL API) -def jp2openjpeg_7(): +def test_jp2openjpeg_7(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -244,7 +244,7 @@ def jp2openjpeg_7(): # Test a JP2OpenJPEG with the 3 bands having 13bit depth and the 4th one 1 bit -def jp2openjpeg_8(): +def test_jp2openjpeg_8(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -268,7 +268,7 @@ def jp2openjpeg_8(): # Check that we can use .j2w world files (#4651) -def jp2openjpeg_9(): +def test_jp2openjpeg_9(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -294,7 +294,7 @@ def jp2openjpeg_9(): # Test YCBCR420 creation option -def jp2openjpeg_10(): +def test_jp2openjpeg_10(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -326,7 +326,7 @@ def jp2openjpeg_10(): # Test auto-promotion of 1bit alpha band to 8bit -def jp2openjpeg_11(): +def test_jp2openjpeg_11(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -378,7 +378,7 @@ def jp2openjpeg_11(): # Check that PAM overrides internal georeferencing (#5279) -def jp2openjpeg_12(): +def test_jp2openjpeg_12(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -427,7 +427,7 @@ def jp2openjpeg_12(): # Check that PAM overrides internal GCPs (#5279) -def jp2openjpeg_13(): +def test_jp2openjpeg_13(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -491,7 +491,7 @@ def jp2openjpeg_13(): # Check that we get GCPs even there's no projection info -def jp2openjpeg_14(): +def test_jp2openjpeg_14(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -507,7 +507,7 @@ def jp2openjpeg_14(): # Test multi-threading reading -def jp2openjpeg_15(): +def test_jp2openjpeg_15(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -529,7 +529,7 @@ def jp2openjpeg_15(): # Test reading PixelIsPoint file (#5437) -def jp2openjpeg_16(): +def test_jp2openjpeg_16(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -569,7 +569,7 @@ def jp2openjpeg_16(): # Test writing PixelIsPoint file (#5437) -def jp2openjpeg_17(): +def test_jp2openjpeg_17(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -606,7 +606,7 @@ def jp2openjpeg_17(): # multiple of 1024 (#5480) -def jp2openjpeg_18(): +def test_jp2openjpeg_18(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -631,7 +631,7 @@ def jp2openjpeg_18(): # Test reading file where GMLJP2 has nul character instead of \n (#5760) -def jp2openjpeg_19(): +def test_jp2openjpeg_19(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -648,7 +648,7 @@ def jp2openjpeg_19(): # Validate GMLJP2 content against schema -def jp2openjpeg_20(): +def test_jp2openjpeg_20(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -720,7 +720,7 @@ def jp2openjpeg_20(): # Test YCC=NO creation option -def jp2openjpeg_21(): +def test_jp2openjpeg_21(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -743,7 +743,7 @@ def jp2openjpeg_21(): # Test RGBA support -def jp2openjpeg_22(): +def test_jp2openjpeg_22(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -907,7 +907,7 @@ def jp2openjpeg_22(): # Test NBITS support -def jp2openjpeg_23(): +def test_jp2openjpeg_23(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -945,7 +945,7 @@ def jp2openjpeg_23(): # Test Grey+alpha support -def jp2openjpeg_24(): +def test_jp2openjpeg_24(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1010,7 +1010,7 @@ def jp2openjpeg_24(): # Test multiband support -def jp2openjpeg_25(): +def test_jp2openjpeg_25(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1080,7 +1080,7 @@ def validate(filename, expected_gmljp2=True, return_error_count=False, oidoc=Non # Test INSPIRE_TG support -def jp2openjpeg_26(): +def test_jp2openjpeg_26(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1290,7 +1290,7 @@ def jp2openjpeg_26(): # Test CreateCopy() from a JPEG2000 with a 2048x2048 tiling -def jp2openjpeg_27(): +def test_jp2openjpeg_27(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1376,7 +1376,7 @@ def jp2openjpeg_test_codeblock(filename, codeblock_width, codeblock_height): return True -def jp2openjpeg_28(): +def test_jp2openjpeg_28(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1415,7 +1415,7 @@ def jp2openjpeg_28(): # Test TILEPARTS option -def jp2openjpeg_29(): +def test_jp2openjpeg_29(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1453,7 +1453,7 @@ def jp2openjpeg_29(): # Test color table support -def jp2openjpeg_30(): +def test_jp2openjpeg_30(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1555,7 +1555,7 @@ def jp2openjpeg_30(): # Test unusual band color interpretation order -def jp2openjpeg_31(): +def test_jp2openjpeg_31(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1617,7 +1617,7 @@ def jp2openjpeg_31(): # Test creation of "XLBoxes" for JP2C -def jp2openjpeg_32(): +def test_jp2openjpeg_32(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1638,7 +1638,7 @@ def jp2openjpeg_32(): # Test crazy tile size -def jp2openjpeg_33(): +def test_jp2openjpeg_33(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1664,7 +1664,7 @@ def jp2openjpeg_33(): # Test opening a file whose dimensions are > 2^31-1 -def jp2openjpeg_34(): +def test_jp2openjpeg_34(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1682,7 +1682,7 @@ def jp2openjpeg_34(): ############################################################################### # Test opening a truncated file -def jp2openjpeg_35(): +def test_jp2openjpeg_35(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1700,7 +1700,7 @@ def jp2openjpeg_35(): # Test we cannot create files with more than 16384 bands -def jp2openjpeg_36(): +def test_jp2openjpeg_36(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1719,7 +1719,7 @@ def jp2openjpeg_36(): # Test metadata reading & writing -def jp2openjpeg_37(): +def test_jp2openjpeg_37(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1850,7 +1850,7 @@ def jp2openjpeg_37(): # Test non-EPSG SRS (so written with a GML dictionary) -def jp2openjpeg_38(): +def test_jp2openjpeg_38(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1893,7 +1893,7 @@ def jp2openjpeg_38(): # Test GMLJP2OVERRIDE configuration option and DGIWG GMLJP2 -def jp2openjpeg_39(): +def test_jp2openjpeg_39(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -1967,7 +1967,7 @@ def jp2openjpeg_39(): # Test we can parse GMLJP2 v2.0 -def jp2openjpeg_40(): +def test_jp2openjpeg_40(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -2051,7 +2051,7 @@ def jp2openjpeg_40(): # Test USE_SRC_CODESTREAM=YES -def jp2openjpeg_41(): +def test_jp2openjpeg_41(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -2101,7 +2101,7 @@ def jp2openjpeg_41(): # Test update of existing file -def jp2openjpeg_42(): +def test_jp2openjpeg_42(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -2314,7 +2314,7 @@ def jp2openjpeg_42(): # Get structure of a JPEG2000 file -def jp2openjpeg_43(): +def test_jp2openjpeg_43(): ret = gdal.GetJPEG2000StructureAsString('data/byte.jp2', ['ALL=YES']) if ret is None: @@ -2326,7 +2326,7 @@ def jp2openjpeg_43(): # Check a file against a OrthoimageryCoverage document -def jp2openjpeg_44(): +def test_jp2openjpeg_44(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -2344,7 +2344,7 @@ def jp2openjpeg_44(): # Test GMLJP2v2 -def jp2openjpeg_45(): +def test_jp2openjpeg_45(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3137,7 +3137,7 @@ def jp2openjpeg_45(): # Test GMLJP2v2 metadata generator / XPath -def jp2openjpeg_46(): +def test_jp2openjpeg_46(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3307,7 +3307,7 @@ def jp2openjpeg_46(): # Test writing & reading RPC in GeoJP2 box -def jp2openjpeg_47(): +def test_jp2openjpeg_47(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3333,7 +3333,7 @@ def jp2openjpeg_47(): # Test reading a dataset whose tile dimensions are larger than dataset ones -def jp2openjpeg_48(): +def test_jp2openjpeg_48(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3354,7 +3354,7 @@ def jp2openjpeg_48(): ############################################################################### -def jp2openjpeg_online_1(): +def test_jp2openjpeg_online_1(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3377,7 +3377,7 @@ def jp2openjpeg_online_1(): ############################################################################### -def jp2openjpeg_online_2(): +def test_jp2openjpeg_online_2(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3409,7 +3409,7 @@ def jp2openjpeg_online_2(): ############################################################################### -def jp2openjpeg_online_3(): +def test_jp2openjpeg_online_3(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3443,7 +3443,7 @@ def jp2openjpeg_online_3(): ############################################################################### -def jp2openjpeg_online_4(): +def test_jp2openjpeg_online_4(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3478,7 +3478,7 @@ def jp2openjpeg_online_4(): # Try reading JP2OpenJPEG with color table -def jp2openjpeg_online_5(): +def test_jp2openjpeg_online_5(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3503,7 +3503,7 @@ def jp2openjpeg_online_5(): # Try reading YCbCr JP2OpenJPEG as RGB -def jp2openjpeg_online_6(): +def test_jp2openjpeg_online_6(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3528,7 +3528,7 @@ def jp2openjpeg_online_6(): # Test GDAL_GEOREF_SOURCES -def jp2openjpeg_49(): +def test_jp2openjpeg_49(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3659,7 +3659,7 @@ def jp2openjpeg_49(): # Test opening an image of small dimension with very small tiles (#7012) -def jp2openjpeg_50(): +def test_jp2openjpeg_50(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3682,7 +3682,7 @@ def jp2openjpeg_50(): # Test CODEBLOCK_STYLE -def jp2openjpeg_codeblock_style(): +def test_jp2openjpeg_codeblock_style(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3729,7 +3729,7 @@ def jp2openjpeg_codeblock_style(): # Test external overviews -def jp2openjpeg_external_overviews_single_band(): +def test_jp2openjpeg_external_overviews_single_band(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3758,7 +3758,7 @@ def jp2openjpeg_external_overviews_single_band(): # Test external overviews -def jp2openjpeg_external_overviews_multiple_band(): +def test_jp2openjpeg_external_overviews_multiple_band(): if gdaltest.jp2openjpeg_drv is None: return 'skip' @@ -3786,7 +3786,7 @@ def jp2openjpeg_external_overviews_multiple_band(): ############################################################################### -def jp2openjpeg_cleanup(): +def test_jp2openjpeg_cleanup(): gdaltest.reregister_all_jpeg2000_drivers() @@ -3794,72 +3794,72 @@ def jp2openjpeg_cleanup(): gdaltest_list = [ - jp2openjpeg_1, - jp2openjpeg_2, - jp2openjpeg_3, - jp2openjpeg_4, - jp2openjpeg_4_vsimem, - jp2openjpeg_5, - jp2openjpeg_6, - jp2openjpeg_7, - jp2openjpeg_8, - jp2openjpeg_9, - jp2openjpeg_10, - jp2openjpeg_11, - jp2openjpeg_12, - jp2openjpeg_13, - jp2openjpeg_14, - jp2openjpeg_15, - jp2openjpeg_16, - jp2openjpeg_17, - jp2openjpeg_18, - jp2openjpeg_19, - jp2openjpeg_20, - jp2openjpeg_21, - jp2openjpeg_22, - jp2openjpeg_23, - jp2openjpeg_24, - jp2openjpeg_25, - jp2openjpeg_26, - jp2openjpeg_27, - jp2openjpeg_28, - jp2openjpeg_29, - jp2openjpeg_30, - jp2openjpeg_31, - jp2openjpeg_32, - jp2openjpeg_33, - jp2openjpeg_34, - jp2openjpeg_35, - jp2openjpeg_36, - jp2openjpeg_37, - jp2openjpeg_38, - jp2openjpeg_39, - jp2openjpeg_40, - jp2openjpeg_41, - jp2openjpeg_42, - jp2openjpeg_43, - jp2openjpeg_44, - jp2openjpeg_45, - jp2openjpeg_46, - jp2openjpeg_47, - jp2openjpeg_48, - jp2openjpeg_49, - jp2openjpeg_50, - jp2openjpeg_codeblock_style, - jp2openjpeg_external_overviews_single_band, - jp2openjpeg_external_overviews_multiple_band, - jp2openjpeg_online_1, - jp2openjpeg_online_2, - jp2openjpeg_online_3, - jp2openjpeg_online_4, - jp2openjpeg_online_5, - jp2openjpeg_online_6, - jp2openjpeg_cleanup] + test_jp2openjpeg_1, + test_jp2openjpeg_2, + test_jp2openjpeg_3, + test_jp2openjpeg_4, + test_jp2openjpeg_4_vsimem, + test_jp2openjpeg_5, + test_jp2openjpeg_6, + test_jp2openjpeg_7, + test_jp2openjpeg_8, + test_jp2openjpeg_9, + test_jp2openjpeg_10, + test_jp2openjpeg_11, + test_jp2openjpeg_12, + test_jp2openjpeg_13, + test_jp2openjpeg_14, + test_jp2openjpeg_15, + test_jp2openjpeg_16, + test_jp2openjpeg_17, + test_jp2openjpeg_18, + test_jp2openjpeg_19, + test_jp2openjpeg_20, + test_jp2openjpeg_21, + test_jp2openjpeg_22, + test_jp2openjpeg_23, + test_jp2openjpeg_24, + test_jp2openjpeg_25, + test_jp2openjpeg_26, + test_jp2openjpeg_27, + test_jp2openjpeg_28, + test_jp2openjpeg_29, + test_jp2openjpeg_30, + test_jp2openjpeg_31, + test_jp2openjpeg_32, + test_jp2openjpeg_33, + test_jp2openjpeg_34, + test_jp2openjpeg_35, + test_jp2openjpeg_36, + test_jp2openjpeg_37, + test_jp2openjpeg_38, + test_jp2openjpeg_39, + test_jp2openjpeg_40, + test_jp2openjpeg_41, + test_jp2openjpeg_42, + test_jp2openjpeg_43, + test_jp2openjpeg_44, + test_jp2openjpeg_45, + test_jp2openjpeg_46, + test_jp2openjpeg_47, + test_jp2openjpeg_48, + test_jp2openjpeg_49, + test_jp2openjpeg_50, + test_jp2openjpeg_codeblock_style, + test_jp2openjpeg_external_overviews_single_band, + test_jp2openjpeg_external_overviews_multiple_band, + test_jp2openjpeg_online_1, + test_jp2openjpeg_online_2, + test_jp2openjpeg_online_3, + test_jp2openjpeg_online_4, + test_jp2openjpeg_online_5, + test_jp2openjpeg_online_6, + test_jp2openjpeg_cleanup] disabled_gdaltest_list = [ - jp2openjpeg_1, - jp2openjpeg_45, - jp2openjpeg_cleanup] + test_jp2openjpeg_1, + test_jp2openjpeg_45, + test_jp2openjpeg_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/jpeg.py b/autotest/gdrivers/jpeg.py index f9d1d42e0d35..baa2a2732d48 100755 --- a/autotest/gdrivers/jpeg.py +++ b/autotest/gdrivers/jpeg.py @@ -44,7 +44,7 @@ # Perform simple read test. -def jpeg_1(): +def test_jpeg_1(): ds = gdal.Open('data/albania.jpg') cs = ds.GetRasterBand(2).Checksum() @@ -68,7 +68,7 @@ def jpeg_1(): # Verify EXIF metadata, color interpretation and image_structure -def jpeg_2(): +def test_jpeg_2(): ds = gdal.Open('data/albania.jpg') @@ -114,7 +114,7 @@ def jpeg_2(): # Create simple copy and check (greyscale) using progressive option. -def jpeg_3(): +def test_jpeg_3(): ds = gdal.Open('data/byte.tif') @@ -184,7 +184,7 @@ def jpeg_3(): # Verify masked jpeg. -def jpeg_4(): +def test_jpeg_4(): try: gdalconst.GMF_ALL_VALID @@ -211,7 +211,7 @@ def jpeg_4(): # Verify CreateCopy() of masked jpeg. -def jpeg_5(): +def test_jpeg_5(): try: gdalconst.GMF_ALL_VALID @@ -246,7 +246,7 @@ def jpeg_5(): # not affect opening the file which just reads the header. -def jpeg_6(): +def test_jpeg_6(): ds = gdal.Open('data/vophead.jpg') @@ -280,7 +280,7 @@ def jpeg_6(): ############################################################################### # Test creating an in memory copy. -def jpeg_7(): +def test_jpeg_7(): ds = gdal.Open('data/byte.tif') @@ -306,7 +306,7 @@ def jpeg_7(): # Read a CMYK image as a RGB image -def jpeg_8(): +def test_jpeg_8(): ds = gdal.Open('data/rgb_ntf_cmyk.jpg') @@ -358,7 +358,7 @@ def jpeg_8(): # Read a CMYK image as a CMYK image -def jpeg_9(): +def test_jpeg_9(): gdal.SetConfigOption('GDAL_JPEG_TO_RGB', 'NO') ds = gdal.Open('data/rgb_ntf_cmyk.jpg') @@ -418,7 +418,7 @@ def jpeg_9(): # Check reading a 12-bit JPEG -def jpeg_10(): +def test_jpeg_10(): if gdaltest.jpeg_version == '9b': # Fails for some reason return 'skip' @@ -455,7 +455,7 @@ def jpeg_10(): # Check creating a 12-bit JPEG -def jpeg_11(): +def test_jpeg_11(): if gdaltest.jpeg_version == '9b': # Fails for some reason return 'skip' @@ -488,7 +488,7 @@ def jpeg_11(): # Test reading a stored JPEG in ZIP (#3908) -def jpeg_12(): +def test_jpeg_12(): ds = gdal.Open('/vsizip/data/byte_jpg.zip') if ds is None: @@ -512,7 +512,7 @@ def jpeg_12(): # Test writing to /vsistdout/ -def jpeg_13(): +def test_jpeg_13(): src_ds = gdal.Open('data/byte.tif') ds = gdal.GetDriverByName('JPEG').CreateCopy( @@ -535,7 +535,7 @@ def jpeg_13(): # Test writing to /vsistdout/ -def jpeg_14(): +def test_jpeg_14(): if gdaltest.jpeg_version == '9b': # Fails for some reason return 'skip' @@ -566,7 +566,7 @@ def jpeg_14(): # Test CreateCopy() interruption -def jpeg_15(): +def test_jpeg_15(): tst = gdaltest.GDALTest('JPEG', 'albania.jpg', 2, 17016) @@ -576,7 +576,7 @@ def jpeg_15(): # Test overview support -def jpeg_16(): +def test_jpeg_16(): shutil.copy('data/albania.jpg', 'tmp/albania.jpg') gdal.Unlink('tmp/albania.jpg.ovr') @@ -647,7 +647,7 @@ def jpeg_16(): # Test bogus files -def jpeg_17(): +def test_jpeg_17(): gdal.ErrorReset() with gdaltest.error_handler('CPLQuietErrorHandler'): ds = gdal.Open('data/bogus.jpg') @@ -701,7 +701,7 @@ def jpeg_17(): # Test situation where we cause a restart and need to reset scale -def jpeg_18(): +def test_jpeg_18(): height = 1024 width = 1024 src_ds = gdal.GetDriverByName('GTiff').Create('/vsimem/jpeg_18.tif', @@ -771,7 +771,7 @@ def jpeg_18(): # Test MSB ordering of bits in mask (#5102) -def jpeg_19(): +def test_jpeg_19(): for width, height, iX in [(32, 32, 12), (25, 25, 8), (24, 25, 8)]: src_ds = gdal.GetDriverByName('GTiff').Create('/vsimem/jpeg_19.tif', @@ -846,7 +846,7 @@ def jpeg_19(): # Test correct GCP reading with PAM (#5352) -def jpeg_20(): +def test_jpeg_20(): src_ds = gdal.Open('data/rgb_gcp.vrt') ds = gdal.GetDriverByName('JPEG').CreateCopy('/vsimem/jpeg_20.jpg', src_ds) @@ -873,7 +873,7 @@ def jpeg_20(): # Test implicit and EXIF overviews -def jpeg_21(): +def test_jpeg_21(): ds = gdal.Open('data/black_with_white_exif_ovr.jpg') if ds.GetRasterBand(1).GetOverviewCount() != 3: @@ -902,7 +902,7 @@ def jpeg_21(): # Test generation of EXIF overviews -def jpeg_22(): +def test_jpeg_22(): src_ds = gdal.GetDriverByName('Mem').Create('', 4096, 2048) src_ds.GetRasterBand(1).Fill(255) @@ -993,7 +993,7 @@ def jpeg_22(): # Test optimized JPEG IRasterIO -def jpeg_23(): +def test_jpeg_23(): ds = gdal.Open('data/albania.jpg') cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] @@ -1038,7 +1038,7 @@ def jpeg_23(): # in CreateCopy()) -def jpeg_24(): +def test_jpeg_24(): has_arithmetic = bool(gdal.GetDriverByName('JPEG').GetMetadataItem( 'DMD_CREATIONOPTIONLIST').find('ARITHMETIC') >= 0) @@ -1072,7 +1072,7 @@ def jpeg_24(): # Test COMMENT -def jpeg_25(): +def test_jpeg_25(): src_ds = gdal.Open('data/byte.tif') ds = gdal.GetDriverByName('JPEG').CreateCopy( @@ -1093,7 +1093,7 @@ def jpeg_25(): # Test creation error -def jpeg_26(): +def test_jpeg_26(): src_ds = gdal.GetDriverByName('Mem').Create('', 70000, 1) with gdaltest.error_handler(): @@ -1111,7 +1111,7 @@ def jpeg_26(): # http://www.libjpeg-jpeg_26.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf -def jpeg_27(): +def test_jpeg_27(): # Should error out with 'Reading this strip would require # libjpeg to allocate at least...' @@ -1142,7 +1142,7 @@ def jpeg_27(): # Test writing of EXIF and GPS tags -def jpeg_28(): +def test_jpeg_28(): tmpfilename = '/vsimem/jpeg_28.jpg' @@ -1320,42 +1320,42 @@ def jpeg_28(): # Cleanup -def jpeg_cleanup(): +def test_jpeg_cleanup(): gdal.Unlink('tmp/albania.jpg') gdal.Unlink('tmp/albania.jpg.ovr') return 'success' gdaltest_list = [ - jpeg_1, - jpeg_2, - jpeg_3, - jpeg_4, - jpeg_5, - jpeg_6, - jpeg_7, - jpeg_8, - jpeg_9, - jpeg_10, - jpeg_11, - jpeg_12, - jpeg_13, - jpeg_14, - jpeg_15, - jpeg_16, - jpeg_17, - jpeg_18, - jpeg_19, - jpeg_20, - jpeg_21, - jpeg_22, - jpeg_23, - jpeg_24, - jpeg_25, - jpeg_26, - jpeg_27, - jpeg_28, - jpeg_cleanup] + test_jpeg_1, + test_jpeg_2, + test_jpeg_3, + test_jpeg_4, + test_jpeg_5, + test_jpeg_6, + test_jpeg_7, + test_jpeg_8, + test_jpeg_9, + test_jpeg_10, + test_jpeg_11, + test_jpeg_12, + test_jpeg_13, + test_jpeg_14, + test_jpeg_15, + test_jpeg_16, + test_jpeg_17, + test_jpeg_18, + test_jpeg_19, + test_jpeg_20, + test_jpeg_21, + test_jpeg_22, + test_jpeg_23, + test_jpeg_24, + test_jpeg_25, + test_jpeg_26, + test_jpeg_27, + test_jpeg_28, + test_jpeg_cleanup] # gdaltest_list = [ jpeg_28 ] diff --git a/autotest/gdrivers/jpeg2000.py b/autotest/gdrivers/jpeg2000.py index 129d9a31b1f2..f357668eba81 100755 --- a/autotest/gdrivers/jpeg2000.py +++ b/autotest/gdrivers/jpeg2000.py @@ -63,7 +63,7 @@ def is_buggy_jasper(): # Verify we have the driver. -def jpeg2000_1(): +def test_jpeg2000_1(): gdaltest.jpeg2000_drv = gdal.GetDriverByName('JPEG2000') @@ -75,7 +75,7 @@ def jpeg2000_1(): # Open byte.jp2 -def jpeg2000_2(): +def test_jpeg2000_2(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -108,7 +108,7 @@ def jpeg2000_2(): # Open int16.jp2 -def jpeg2000_3(): +def test_jpeg2000_3(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -134,7 +134,7 @@ def jpeg2000_3(): # Test copying byte.jp2 -def jpeg2000_4(): +def test_jpeg2000_4(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -154,7 +154,7 @@ def jpeg2000_4(): # Test copying int16.jp2 -def jpeg2000_5(): +def test_jpeg2000_5(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -166,7 +166,7 @@ def jpeg2000_5(): # Test reading ll.jp2 -def jpeg2000_6(): +def test_jpeg2000_6(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -186,7 +186,7 @@ def jpeg2000_6(): # Open byte.jp2.gz (test use of the VSIL API) -def jpeg2000_7(): +def test_jpeg2000_7(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -198,7 +198,7 @@ def jpeg2000_7(): # Test a JPEG2000 with the 3 bands having 13bit depth and the 4th one 1 bit -def jpeg2000_8(): +def test_jpeg2000_8(): if gdaltest.jpeg2000_drv is None or is_buggy_jasper(): return 'skip' @@ -222,7 +222,7 @@ def jpeg2000_8(): # Check that we can use .j2w world files (#4651) -def jpeg2000_9(): +def test_jpeg2000_9(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -248,7 +248,7 @@ def jpeg2000_9(): # Check writing a file with more than 4 bands (#4686) -def jpeg2000_10(): +def test_jpeg2000_10(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -281,7 +281,7 @@ def jpeg2000_10(): # Test auto-promotion of 1bit alpha band to 8bit -def jpeg2000_11(): +def test_jpeg2000_11(): if gdaltest.jpeg2000_drv is None or is_buggy_jasper(): return 'skip' @@ -331,7 +331,7 @@ def jpeg2000_11(): ############################################################################### -def jpeg2000_online_1(): +def test_jpeg2000_online_1(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -354,7 +354,7 @@ def jpeg2000_online_1(): ############################################################################### -def jpeg2000_online_2(): +def test_jpeg2000_online_2(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -386,7 +386,7 @@ def jpeg2000_online_2(): ############################################################################### -def jpeg2000_online_3(): +def test_jpeg2000_online_3(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -421,7 +421,7 @@ def jpeg2000_online_3(): ############################################################################### -def jpeg2000_online_4(): +def test_jpeg2000_online_4(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -459,7 +459,7 @@ def jpeg2000_online_4(): # Try reading JPEG2000 with color table -def jpeg2000_online_5(): +def test_jpeg2000_online_5(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -484,7 +484,7 @@ def jpeg2000_online_5(): # Try reading YCbCr JPEG2000 as RGB -def jpeg2000_online_6(): +def test_jpeg2000_online_6(): if gdaltest.jpeg2000_drv is None: return 'skip' @@ -508,7 +508,7 @@ def jpeg2000_online_6(): ############################################################################### -def jpeg2000_cleanup(): +def test_jpeg2000_cleanup(): gdaltest.reregister_all_jpeg2000_drivers() @@ -516,24 +516,24 @@ def jpeg2000_cleanup(): gdaltest_list = [ - jpeg2000_1, - jpeg2000_2, - jpeg2000_3, - jpeg2000_4, - jpeg2000_5, - jpeg2000_6, - jpeg2000_7, - jpeg2000_8, - jpeg2000_9, - jpeg2000_10, - jpeg2000_11, - jpeg2000_online_1, - jpeg2000_online_2, - jpeg2000_online_3, - jpeg2000_online_4, - jpeg2000_online_5, - jpeg2000_online_6, - jpeg2000_cleanup] + test_jpeg2000_1, + test_jpeg2000_2, + test_jpeg2000_3, + test_jpeg2000_4, + test_jpeg2000_5, + test_jpeg2000_6, + test_jpeg2000_7, + test_jpeg2000_8, + test_jpeg2000_9, + test_jpeg2000_10, + test_jpeg2000_11, + test_jpeg2000_online_1, + test_jpeg2000_online_2, + test_jpeg2000_online_3, + test_jpeg2000_online_4, + test_jpeg2000_online_5, + test_jpeg2000_online_6, + test_jpeg2000_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/jpeg_profile.py b/autotest/gdrivers/jpeg_profile.py index c0bb8c7a77ba..08eabc5ea909 100755 --- a/autotest/gdrivers/jpeg_profile.py +++ b/autotest/gdrivers/jpeg_profile.py @@ -42,7 +42,7 @@ ############################################################################### # Test writing and reading of ICC profile in CreateCopy() -def jpeg_copy_icc(): +def test_jpeg_copy_icc(): f = open('data/sRGB.icc', 'rb') data = f.read() @@ -85,7 +85,7 @@ def jpeg_copy_icc(): # Test writing and reading of ICC profile in CreateCopy() options -def jpeg_copy_options_icc(): +def test_jpeg_copy_options_icc(): f = open('data/sRGB.icc', 'rb') data = f.read() @@ -128,7 +128,7 @@ def jpeg_copy_options_icc(): # Test writing and reading of 64K+ ICC profile in CreateCopy() -def jpeg_copy_icc_64K(): +def test_jpeg_copy_icc_64K(): # In JPEG, APP2 chunks can only be 64K, so they would be split up. # It will still work, but need to test that the segmented ICC profile @@ -211,9 +211,9 @@ def jpeg_copy_icc_64K(): gdaltest_list = [ - jpeg_copy_icc, - jpeg_copy_options_icc, - jpeg_copy_icc_64K, + test_jpeg_copy_icc, + test_jpeg_copy_options_icc, + test_jpeg_copy_icc_64K, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/jpegls.py b/autotest/gdrivers/jpegls.py index e1f06cc3ad06..75d7b5964790 100755 --- a/autotest/gdrivers/jpegls.py +++ b/autotest/gdrivers/jpegls.py @@ -37,7 +37,7 @@ ############################################################################### -def jpegls_1(): +def test_jpegls_1(): if gdal.GetDriverByName('JPEGLS') is None: return 'skip' @@ -48,7 +48,7 @@ def jpegls_1(): ############################################################################### -def jpegls_2(): +def test_jpegls_2(): if gdal.GetDriverByName('JPEGLS') is None: return 'skip' @@ -58,8 +58,8 @@ def jpegls_2(): gdaltest_list = [ - jpegls_1, - jpegls_2] + test_jpegls_1, + test_jpegls_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/jpipkak.py b/autotest/gdrivers/jpipkak.py index ff2faa332765..d9775334b55b 100755 --- a/autotest/gdrivers/jpipkak.py +++ b/autotest/gdrivers/jpipkak.py @@ -38,7 +38,7 @@ # Read test of simple byte reference data. -def jpipkak_1(): +def test_jpipkak_1(): return 'skip' @@ -67,7 +67,7 @@ def jpipkak_1(): # -def jpipkak_2(): +def test_jpipkak_2(): return 'skip' @@ -101,7 +101,7 @@ def jpipkak_2(): # Test an 11bit image. -def jpipkak_3(): +def test_jpipkak_3(): return 'skip' @@ -129,7 +129,7 @@ def jpipkak_3(): # Test a 20bit image, reduced to 16bit during processing. -def jpipkak_4(): +def test_jpipkak_4(): return 'skip' @@ -157,7 +157,7 @@ def jpipkak_4(): # Test an overview level that will result in multiple fetches with subwindows. -def jpipkak_5(): +def test_jpipkak_5(): return 'skip' @@ -183,11 +183,11 @@ def jpipkak_5(): gdaltest_list = [ - jpipkak_1, - jpipkak_2, - jpipkak_3, - jpipkak_4, - jpipkak_5 + test_jpipkak_1, + test_jpipkak_2, + test_jpipkak_3, + test_jpipkak_4, + test_jpipkak_5 ] if __name__ == '__main__': diff --git a/autotest/gdrivers/kea.py b/autotest/gdrivers/kea.py index 2c885e70dfb1..25990fc5f6f8 100755 --- a/autotest/gdrivers/kea.py +++ b/autotest/gdrivers/kea.py @@ -38,7 +38,7 @@ ############################################################################### -def kea_init(): +def test_kea_init(): gdaltest.kea_driver = gdal.GetDriverByName('KEA') return 'success' @@ -47,7 +47,7 @@ def kea_init(): # Test copying a reference sample with CreateCopy() -def kea_1(): +def test_kea_1(): if gdaltest.kea_driver is None: return 'skip' @@ -58,7 +58,7 @@ def kea_1(): # Test CreateCopy() for various data types -def kea_2(): +def test_kea_2(): if gdaltest.kea_driver is None: return 'skip' @@ -82,7 +82,7 @@ def kea_2(): # Test Create() for various data types -def kea_3(): +def test_kea_3(): if gdaltest.kea_driver is None: return 'skip' @@ -106,7 +106,7 @@ def kea_3(): # Test Create()/CreateCopy() error cases or limit cases -def kea_4(): +def test_kea_4(): if gdaltest.kea_driver is None: return 'skip' @@ -216,7 +216,7 @@ def kea_4(): # Test Create() creation options -def kea_5(): +def test_kea_5(): if gdaltest.kea_driver is None: return 'skip' @@ -255,7 +255,7 @@ def kea_5(): # Test metadata -def kea_6(): +def test_kea_6(): if gdaltest.kea_driver is None: return 'skip' @@ -360,7 +360,7 @@ def kea_6(): # Test georef -def kea_7(): +def test_kea_7(): if gdaltest.kea_driver is None: return 'skip' @@ -437,7 +437,7 @@ def kea_7(): # Test colortable -def kea_8(): +def test_kea_8(): if gdaltest.kea_driver is None: return 'skip' @@ -485,7 +485,7 @@ def kea_8(): # Test color interpretation -def kea_9(): +def test_kea_9(): if gdaltest.kea_driver is None: return 'skip' @@ -518,7 +518,7 @@ def kea_9(): # Test nodata -def kea_10(): +def test_kea_10(): if gdaltest.kea_driver is None: return 'skip' @@ -583,7 +583,7 @@ def kea_10(): # Test AddBand -def kea_11(): +def test_kea_11(): if gdaltest.kea_driver is None: return 'skip' @@ -619,7 +619,7 @@ def kea_11(): # Test RAT -def kea_12(): +def test_kea_12(): if gdaltest.kea_driver is None: return 'skip' @@ -783,7 +783,7 @@ def kea_12(): # Test overviews -def kea_13(): +def test_kea_13(): if gdaltest.kea_driver is None: return 'skip' @@ -824,7 +824,7 @@ def kea_13(): # Test mask bands -def kea_14(): +def test_kea_14(): if gdaltest.kea_driver is None: return 'skip' @@ -870,21 +870,21 @@ def kea_14(): gdaltest_list = [ - kea_init, - kea_1, - kea_2, - kea_3, - kea_4, - kea_5, - kea_6, - kea_7, - kea_8, - kea_9, - kea_10, - kea_11, - kea_12, - kea_13, - kea_14 + test_kea_init, + test_kea_1, + test_kea_2, + test_kea_3, + test_kea_4, + test_kea_5, + test_kea_6, + test_kea_7, + test_kea_8, + test_kea_9, + test_kea_10, + test_kea_11, + test_kea_12, + test_kea_13, + test_kea_14 ] if __name__ == '__main__': diff --git a/autotest/gdrivers/kmlsuperoverlay.py b/autotest/gdrivers/kmlsuperoverlay.py index d1d81084f5e4..be22f66c7231 100755 --- a/autotest/gdrivers/kmlsuperoverlay.py +++ b/autotest/gdrivers/kmlsuperoverlay.py @@ -41,7 +41,7 @@ # Test CreateCopy() to a KMZ file -def kmlsuperoverlay_1(): +def test_kmlsuperoverlay_1(): tst = gdaltest.GDALTest('KMLSUPEROVERLAY', 'small_world.tif', 1, 30111, options=['FORMAT=PNG']) @@ -51,7 +51,7 @@ def kmlsuperoverlay_1(): # Test CreateCopy() to a KML file -def kmlsuperoverlay_2(): +def test_kmlsuperoverlay_2(): tst = gdaltest.GDALTest('KMLSUPEROVERLAY', 'small_world.tif', 1, 30111, options=['FORMAT=PNG']) @@ -61,7 +61,7 @@ def kmlsuperoverlay_2(): # Test CreateCopy() to a KML file -def kmlsuperoverlay_3(): +def test_kmlsuperoverlay_3(): src_ds = gdal.Open('data/utm.tif') ds = gdal.GetDriverByName('KMLSUPEROVERLAY').CreateCopy('tmp/tmp.kml', src_ds) @@ -95,7 +95,7 @@ def kmlsuperoverlay_3(): # Test overviews -def kmlsuperoverlay_4(): +def test_kmlsuperoverlay_4(): vrt_xml = """ GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]] @@ -198,7 +198,7 @@ def kmlsuperoverlay_4(): # Test that a raster which crosses the anti-meridian will be able to be displayed correctly (#4528) -def kmlsuperoverlay_5(): +def test_kmlsuperoverlay_5(): try: from xml.etree import ElementTree @@ -267,7 +267,7 @@ def kmlsuperoverlay_5(): # Test raster KML with alternate structure (such as http://opentopo.sdsc.edu/files/Haiti/NGA_Haiti_LiDAR2.kmz)) -def kmlsuperoverlay_6(): +def test_kmlsuperoverlay_6(): ds = gdal.Open('data/kmlimage.kmz') if ds.GetProjectionRef().find('WGS_1984') < 0: @@ -304,7 +304,7 @@ def kmlsuperoverlay_6(): # Test raster KML with single Overlay (such as https://trac.osgeo.org/gdal/ticket/6712) -def kmlsuperoverlay_7(): +def test_kmlsuperoverlay_7(): ds = gdal.Open('data/small_world.kml') if ds.GetProjectionRef().find('WGS_1984') < 0: @@ -334,7 +334,7 @@ def kmlsuperoverlay_7(): # KML/PNG files in transparent areas -def kmlsuperoverlay_8(): +def test_kmlsuperoverlay_8(): # a large raster with actual data on each end and blank space in between src_ds = gdal.Open(""" @@ -441,7 +441,7 @@ def kmlsuperoverlay_8(): # Cleanup -def kmlsuperoverlay_cleanup(): +def test_kmlsuperoverlay_cleanup(): gdal.Unlink('/vsimem/0/0/0.png') gdal.Unlink('/vsimem/0/0/0.kml') @@ -454,15 +454,15 @@ def kmlsuperoverlay_cleanup(): gdaltest_list = [ - kmlsuperoverlay_1, - kmlsuperoverlay_2, - kmlsuperoverlay_3, - kmlsuperoverlay_4, - kmlsuperoverlay_5, - kmlsuperoverlay_6, - kmlsuperoverlay_7, - kmlsuperoverlay_8, - kmlsuperoverlay_cleanup] + test_kmlsuperoverlay_1, + test_kmlsuperoverlay_2, + test_kmlsuperoverlay_3, + test_kmlsuperoverlay_4, + test_kmlsuperoverlay_5, + test_kmlsuperoverlay_6, + test_kmlsuperoverlay_7, + test_kmlsuperoverlay_8, + test_kmlsuperoverlay_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/kro.py b/autotest/gdrivers/kro.py index 3a4d8bdba2d6..e1cca0b76541 100755 --- a/autotest/gdrivers/kro.py +++ b/autotest/gdrivers/kro.py @@ -39,7 +39,7 @@ # Create 3-band byte -def kro_1(): +def test_kro_1(): tst = gdaltest.GDALTest('KRO', 'rgbsmall.tif', 2, 21053) @@ -49,7 +49,7 @@ def kro_1(): # Create 1-band uint16 -def kro_2(): +def test_kro_2(): tst = gdaltest.GDALTest('KRO', '../../gcore/data/uint16.tif', 1, 4672) @@ -59,7 +59,7 @@ def kro_2(): # Create 1-band float32 -def kro_3(): +def test_kro_3(): tst = gdaltest.GDALTest('KRO', '../../gcore/data/float32.tif', 1, 4672) @@ -69,7 +69,7 @@ def kro_3(): # Create 4-band rgba uint16 -def kro_4(): +def test_kro_4(): tst = gdaltest.GDALTest('KRO', 'rgba16.png', 1, 1886) @@ -79,7 +79,7 @@ def kro_4(): # Test optimized IO -def kro_5(): +def test_kro_5(): # Determine if the filesystem supports sparse files (we don't want to create a real 10 GB # file ! @@ -99,11 +99,11 @@ def kro_5(): gdaltest_list = [ - kro_1, - kro_2, - kro_3, - kro_4, - kro_5, + test_kro_1, + test_kro_2, + test_kro_3, + test_kro_4, + test_kro_5, ] diff --git a/autotest/gdrivers/l1b.py b/autotest/gdrivers/l1b.py index 988d0ddab31e..4a58a632eeb5 100755 --- a/autotest/gdrivers/l1b.py +++ b/autotest/gdrivers/l1b.py @@ -76,7 +76,7 @@ def test_l1b(downloadURL, fileName, checksum, download_size, gcpNumber): assert len(ds.GetGCPs()) == gcpNumber -def l1b_geoloc(): +def test_l1b_geoloc(): try: os.stat('tmp/cache/n12gac8bit.l1b') except OSError: @@ -117,7 +117,7 @@ def l1b_geoloc(): # -def l1b_solar_zenith_angles_before_noaa_15(): +def test_l1b_solar_zenith_angles_before_noaa_15(): try: os.stat('tmp/cache/n12gac10bit.l1b') except OSError: @@ -148,7 +148,7 @@ def l1b_solar_zenith_angles_before_noaa_15(): # -def l1b_metadata_before_noaa_15(): +def test_l1b_metadata_before_noaa_15(): try: os.stat('tmp/cache/n12gac10bit.l1b') except OSError: @@ -180,7 +180,7 @@ def l1b_metadata_before_noaa_15(): # -def l1b_angles_after_noaa_15(): +def test_l1b_angles_after_noaa_15(): try: os.stat('tmp/cache/n16gac10bit.l1b') except OSError: @@ -221,7 +221,7 @@ def l1b_angles_after_noaa_15(): # -def l1b_clouds_after_noaa_15(): +def test_l1b_clouds_after_noaa_15(): try: os.stat('tmp/cache/n16gac10bit.l1b') except OSError: @@ -252,7 +252,7 @@ def l1b_clouds_after_noaa_15(): # -def l1b_metadata_after_noaa_15(): +def test_l1b_metadata_after_noaa_15(): try: os.stat('tmp/cache/n16gac10bit.l1b') except OSError: @@ -284,7 +284,7 @@ def l1b_metadata_after_noaa_15(): # -def l1b_little_endian(): +def test_l1b_little_endian(): ds = gdal.Open('/vsizip/data/hrpt_little_endian.l1b.zip') if ds.GetGCPProjection().find('GRS80') < 0: @@ -305,13 +305,13 @@ def l1b_little_endian(): gdaltest_list = [ - l1b_geoloc, - l1b_solar_zenith_angles_before_noaa_15, - l1b_metadata_before_noaa_15, - l1b_angles_after_noaa_15, - l1b_clouds_after_noaa_15, - l1b_metadata_after_noaa_15, - l1b_little_endian, + test_l1b_geoloc, + test_l1b_solar_zenith_angles_before_noaa_15, + test_l1b_metadata_before_noaa_15, + test_l1b_angles_after_noaa_15, + test_l1b_clouds_after_noaa_15, + test_l1b_metadata_after_noaa_15, + test_l1b_little_endian, ] diff --git a/autotest/gdrivers/lan.py b/autotest/gdrivers/lan.py index 89b33e8d72d8..9d1d5171ae61 100755 --- a/autotest/gdrivers/lan.py +++ b/autotest/gdrivers/lan.py @@ -37,7 +37,7 @@ # Test reading a - fake - LAN 8 bit dataset -def lan_1(): +def test_lan_1(): tst = gdaltest.GDALTest('LAN', 'fakelan.lan', 1, 10) return tst.testOpen() @@ -46,15 +46,15 @@ def lan_1(): # Test reading a - fake - LAN 4 bit dataset -def lan_2(): +def test_lan_2(): tst = gdaltest.GDALTest('LAN', 'fakelan4bit.lan', 1, 10) return tst.testOpen() gdaltest_list = [ - lan_1, - lan_2] + test_lan_1, + test_lan_2] if __name__ == '__main__': diff --git a/autotest/gdrivers/lcp.py b/autotest/gdrivers/lcp.py index 5bbbb0cd1429..b4f7595eb2c6 100755 --- a/autotest/gdrivers/lcp.py +++ b/autotest/gdrivers/lcp.py @@ -40,7 +40,7 @@ # Test test_FARSITE_UTM12.LCP -def lcp_1(): +def test_lcp_1(): ds = gdal.Open('data/test_FARSITE_UTM12.LCP') if ds.RasterCount != 8: @@ -140,7 +140,7 @@ def lcp_1(): # test test_USGS_LFNM_Alb83.lcp -def lcp_2(): +def test_lcp_2(): ds = gdal.Open('data/test_USGS_LFNM_Alb83.lcp') if ds.RasterCount != 8: @@ -236,7 +236,7 @@ def lcp_2(): # Test for empty prj -def lcp_3(): +def test_lcp_3(): ds = gdal.Open('data/test_USGS_LFNM_Alb83.lcp') if ds is None: @@ -251,7 +251,7 @@ def lcp_3(): # Test that the prj file isn't added to the sibling list if it isn't there. -def lcp_4(): +def test_lcp_4(): ds = gdal.Open('data/test_USGS_LFNM_Alb83.lcp') if ds is None: @@ -266,7 +266,7 @@ def lcp_4(): # Test for valid prj -def lcp_5(): +def test_lcp_5(): ds = gdal.Open('data/test_FARSITE_UTM12.LCP') if ds is None: @@ -281,7 +281,7 @@ def lcp_5(): # Test for valid sibling list -def lcp_6(): +def test_lcp_6(): retval = 'success' ds = gdal.Open('data/test_FARSITE_UTM12.LCP') @@ -303,7 +303,7 @@ def lcp_6(): # Test create copy that copies data over -def lcp_7(): +def test_lcp_7(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -339,7 +339,7 @@ def lcp_7(): # Test create copy with invalid bands -def lcp_8(): +def test_lcp_8(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -375,7 +375,7 @@ def lcp_8(): # Test create copy -def lcp_9(): +def test_lcp_9(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -403,7 +403,7 @@ def lcp_9(): # Test create copy and make sure all unit metadata co work -def lcp_10(): +def test_lcp_10(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -443,7 +443,7 @@ def lcp_10(): # Test create copy and make sure all unit metadata co work -def lcp_11(): +def test_lcp_11(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -483,7 +483,7 @@ def lcp_11(): # Test create copy and make sure all unit metadata co work -def lcp_12(): +def test_lcp_12(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -522,7 +522,7 @@ def lcp_12(): # Test create copy and make sure all unit metadata co work -def lcp_13(): +def test_lcp_13(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -562,7 +562,7 @@ def lcp_13(): # Test create copy and make sure all unit metadata co work -def lcp_14(): +def test_lcp_14(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -602,7 +602,7 @@ def lcp_14(): # Test create copy and make sure all unit metadata co work -def lcp_15(): +def test_lcp_15(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -642,7 +642,7 @@ def lcp_15(): # Test create copy and make sure all unit metadata co work -def lcp_16(): +def test_lcp_16(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -688,7 +688,7 @@ def lcp_16(): # documentation. Docs say mg/ha * 10 and tn/ac * 10, metadata is not * 10. -def lcp_17(): +def test_lcp_17(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -729,7 +729,7 @@ def lcp_17(): # Test create copy and make sure creation options work. -def lcp_18(): +def test_lcp_18(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -763,7 +763,7 @@ def lcp_18(): # Test create copy and make sure creation options work. -def lcp_19(): +def test_lcp_19(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -798,7 +798,7 @@ def lcp_19(): # Test create copy and make sure DESCRIPTION co works -def lcp_20(): +def test_lcp_20(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -833,7 +833,7 @@ def lcp_20(): # Test create copy and make data is copied over via checksums -def lcp_21(): +def test_lcp_21(): try: import random import struct @@ -877,7 +877,7 @@ def lcp_21(): # Test create copy and make data is copied over via numpy comparison. -def lcp_22(): +def test_lcp_22(): try: import random import struct @@ -924,7 +924,7 @@ def lcp_22(): ############################################################################### # Test create copy and make sure invalid creation options are caught. -def lcp_23(): +def test_lcp_23(): mem_drv = gdal.GetDriverByName('MEM') if mem_drv is None: @@ -960,29 +960,29 @@ def lcp_23(): gdaltest_list = [ - lcp_1, - lcp_2, - lcp_3, - lcp_4, - lcp_5, - lcp_6, - lcp_7, - lcp_8, - lcp_9, - lcp_10, - lcp_11, - lcp_12, - lcp_13, - lcp_14, - lcp_15, - lcp_16, - lcp_17, - lcp_18, - lcp_19, - lcp_20, - lcp_21, - lcp_22, - lcp_23] + test_lcp_1, + test_lcp_2, + test_lcp_3, + test_lcp_4, + test_lcp_5, + test_lcp_6, + test_lcp_7, + test_lcp_8, + test_lcp_9, + test_lcp_10, + test_lcp_11, + test_lcp_12, + test_lcp_13, + test_lcp_14, + test_lcp_15, + test_lcp_16, + test_lcp_17, + test_lcp_18, + test_lcp_19, + test_lcp_20, + test_lcp_21, + test_lcp_22, + test_lcp_23] if __name__ == '__main__': diff --git a/autotest/gdrivers/leveller.py b/autotest/gdrivers/leveller.py index 6489da027acc..99c425064406 100755 --- a/autotest/gdrivers/leveller.py +++ b/autotest/gdrivers/leveller.py @@ -37,14 +37,14 @@ # Perform simple read test. -def leveller_1(): +def test_leveller_1(): tst = gdaltest.GDALTest('Leveller', 'ter6test.ter', 1, 33441) return tst.testOpen() gdaltest_list = [ - leveller_1] + test_leveller_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/loslas.py b/autotest/gdrivers/loslas.py index 20de8dbf8034..7bc5ed77ce88 100755 --- a/autotest/gdrivers/loslas.py +++ b/autotest/gdrivers/loslas.py @@ -37,7 +37,7 @@ ############################################################################### -def loslas_online_1(): +def test_loslas_online_1(): if not gdaltest.download_file('http://www.ngs.noaa.gov/PC_PROD/NADCON/NADCON.zip', 'NADCON.zip'): return 'skip' @@ -62,7 +62,7 @@ def loslas_online_1(): gdaltest_list = [ - loslas_online_1, + test_loslas_online_1, ] diff --git a/autotest/gdrivers/mbtiles.py b/autotest/gdrivers/mbtiles.py index 94e67197ecab..afb2a9387778 100755 --- a/autotest/gdrivers/mbtiles.py +++ b/autotest/gdrivers/mbtiles.py @@ -41,7 +41,7 @@ # Get the mbtiles driver -def mbtiles_1(): +def test_mbtiles_1(): gdaltest.mbtiles_drv = gdal.GetDriverByName('MBTiles') @@ -51,7 +51,7 @@ def mbtiles_1(): # Basic test -def mbtiles_2(): +def test_mbtiles_2(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -120,7 +120,7 @@ def mbtiles_2(): # Open a /vsicurl/ DB -def mbtiles_3(): +def test_mbtiles_3(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -169,7 +169,7 @@ def mbtiles_3(): # -def mbtiles_start_webserver(): +def test_mbtiles_start_webserver(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -187,7 +187,7 @@ def mbtiles_start_webserver(): # -def mbtiles_http_jpeg_three_bands(): +def test_mbtiles_http_jpeg_three_bands(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -214,7 +214,7 @@ def mbtiles_http_jpeg_three_bands(): # -def mbtiles_http_jpeg_single_band(): +def test_mbtiles_http_jpeg_single_band(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -241,7 +241,7 @@ def mbtiles_http_jpeg_single_band(): # -def mbtiles_http_png(): +def test_mbtiles_http_png(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -268,7 +268,7 @@ def mbtiles_http_png(): # -def mbtiles_stop_webserver(): +def test_mbtiles_stop_webserver(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -285,7 +285,7 @@ def mbtiles_stop_webserver(): # Basic test without any option -def mbtiles_4(): +def test_mbtiles_4(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -328,7 +328,7 @@ def mbtiles_4(): # Test write support of a single band dataset -def mbtiles_5(): +def test_mbtiles_5(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -389,7 +389,7 @@ def mbtiles_5(): # Test write support with options -def mbtiles_6(): +def test_mbtiles_6(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -432,7 +432,7 @@ def mbtiles_6(): # Test building overview -def mbtiles_7(): +def test_mbtiles_7(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -503,7 +503,7 @@ def mbtiles_7(): # Single band with 24 bit color table, PNG -def mbtiles_8(): +def test_mbtiles_8(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -562,7 +562,7 @@ def mbtiles_8(): # Test we are robust to invalid bounds -def mbtiles_9(): +def test_mbtiles_9(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -595,7 +595,7 @@ def mbtiles_9(): # Test compaction of temporary database -def mbtiles_10(): +def test_mbtiles_10(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -624,7 +624,7 @@ def mbtiles_10(): # Test opening a .mbtiles.sql file -def mbtiles_11(): +def test_mbtiles_11(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -644,7 +644,7 @@ def mbtiles_11(): ############################################################################### -def mbtiles_raster_open_in_vector_mode(): +def test_mbtiles_raster_open_in_vector_mode(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -658,7 +658,7 @@ def mbtiles_raster_open_in_vector_mode(): ############################################################################### -def mbtiles_create(): +def test_mbtiles_create(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -738,7 +738,7 @@ def mbtiles_create(): ############################################################################### # Cleanup -def mbtiles_cleanup(): +def test_mbtiles_cleanup(): if gdaltest.mbtiles_drv is None: return 'skip' @@ -747,25 +747,25 @@ def mbtiles_cleanup(): gdaltest_list = [ - mbtiles_1, - mbtiles_2, - mbtiles_3, - mbtiles_start_webserver, - mbtiles_http_jpeg_three_bands, - mbtiles_http_jpeg_single_band, - mbtiles_http_png, - mbtiles_stop_webserver, - mbtiles_4, - mbtiles_5, - mbtiles_6, - mbtiles_7, - mbtiles_8, - mbtiles_9, - mbtiles_10, - mbtiles_11, - mbtiles_raster_open_in_vector_mode, - mbtiles_create, - mbtiles_cleanup] + test_mbtiles_1, + test_mbtiles_2, + test_mbtiles_3, + test_mbtiles_start_webserver, + test_mbtiles_http_jpeg_three_bands, + test_mbtiles_http_jpeg_single_band, + test_mbtiles_http_png, + test_mbtiles_stop_webserver, + test_mbtiles_4, + test_mbtiles_5, + test_mbtiles_6, + test_mbtiles_7, + test_mbtiles_8, + test_mbtiles_9, + test_mbtiles_10, + test_mbtiles_11, + test_mbtiles_raster_open_in_vector_mode, + test_mbtiles_create, + test_mbtiles_cleanup] # gdaltest_list = [ mbtiles_1, mbtiles_create ] diff --git a/autotest/gdrivers/mem.py b/autotest/gdrivers/mem.py index b3839e4cae88..b2c2d6837f7a 100755 --- a/autotest/gdrivers/mem.py +++ b/autotest/gdrivers/mem.py @@ -40,7 +40,7 @@ # Create a MEM dataset, and set some data, then test it. -def mem_1(): +def test_mem_1(): ####################################################### # Setup dataset @@ -126,7 +126,7 @@ def mem_1(): # Open an in-memory array. -def mem_2(): +def test_mem_2(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.Open('MEM:::') @@ -208,7 +208,7 @@ def mem_2(): # Test creating a MEM dataset with the "MEM:::" name -def mem_3(): +def test_mem_3(): drv = gdal.GetDriverByName('MEM') ds = drv.Create('MEM:::', 1, 1, 1) @@ -222,7 +222,7 @@ def mem_3(): # Test creating a band interleaved multi-band MEM dataset -def mem_4(): +def test_mem_4(): drv = gdal.GetDriverByName('MEM') @@ -252,7 +252,7 @@ def mem_4(): # Test creating a pixel interleaved multi-band MEM dataset -def mem_5(): +def test_mem_5(): drv = gdal.GetDriverByName('MEM') @@ -286,7 +286,7 @@ def mem_5(): # Test out-of-memory situations -def mem_6(): +def test_mem_6(): if gdal.GetConfigOption('SKIP_MEM_INTENSIVE_TEST') is not None: return 'skip' @@ -352,7 +352,7 @@ def mem_6(): # Test AddBand() -def mem_7(): +def test_mem_7(): drv = gdal.GetDriverByName('MEM') ds = drv.Create('MEM:::', 1, 1, 1) @@ -367,7 +367,7 @@ def mem_7(): # Test SetDefaultHistogram() / GetDefaultHistogram() -def mem_8(): +def test_mem_8(): drv = gdal.GetDriverByName('MEM') ds = drv.Create('MEM:::', 1, 1, 1) @@ -387,7 +387,7 @@ def mem_8(): # Test RasterIO() -def mem_9(): +def test_mem_9(): # Test IRasterIO(GF_Read,) src_ds = gdal.Open('data/rgbsmall.tif') @@ -510,7 +510,7 @@ def mem_9(): # Test BuildOverviews() -def mem_10(): +def test_mem_10(): # Error case: building overview on a 0 band dataset ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 0) @@ -671,7 +671,7 @@ def mem_10(): # Test CreateMaskBand() -def mem_11(): +def test_mem_11(): # Error case: building overview on a 0 band dataset ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 0) @@ -747,7 +747,7 @@ def mem_11(): # Test CreateMaskBand() and overviews. -def mem_12(): +def test_mem_12(): # Test on per-band mask ds = gdal.GetDriverByName('MEM').Create('', 10, 10, 2) @@ -789,7 +789,7 @@ def mem_12(): # Check RAT support -def mem_rat(): +def test_mem_rat(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) ds.GetRasterBand(1).SetDefaultRAT(gdal.RasterAttributeTable()) @@ -807,7 +807,7 @@ def mem_rat(): # Check CategoryNames support -def mem_categorynames(): +def test_mem_categorynames(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) ds.GetRasterBand(1).SetCategoryNames(['foo']) @@ -825,7 +825,7 @@ def mem_categorynames(): ############################################################################### # Check ColorTable support -def mem_colortable(): +def test_mem_colortable(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) ct = gdal.ColorTable() @@ -845,28 +845,28 @@ def mem_colortable(): ############################################################################### # cleanup -def mem_cleanup(): +def test_mem_cleanup(): gdaltest.mem_ds = None return 'success' gdaltest_list = [ - mem_1, - mem_2, - mem_3, - mem_4, - mem_5, - mem_6, - mem_7, - mem_8, - mem_9, - mem_10, - mem_11, - mem_12, - mem_rat, - mem_categorynames, - mem_colortable, - mem_cleanup] + test_mem_1, + test_mem_2, + test_mem_3, + test_mem_4, + test_mem_5, + test_mem_6, + test_mem_7, + test_mem_8, + test_mem_9, + test_mem_10, + test_mem_11, + test_mem_12, + test_mem_rat, + test_mem_categorynames, + test_mem_colortable, + test_mem_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/mff.py b/autotest/gdrivers/mff.py index 19e4821ad32a..5455dbd5afd1 100755 --- a/autotest/gdrivers/mff.py +++ b/autotest/gdrivers/mff.py @@ -37,7 +37,7 @@ # Test reading a - fake - MFF dataset -def mff_1(): +def test_mff_1(): tst = gdaltest.GDALTest('MFF', 'fakemff.hdr', 1, 1) return tst.testOpen() @@ -46,7 +46,7 @@ def mff_1(): # Test reading a - fake - tiled MFF dataset -def mff_2(): +def test_mff_2(): tst = gdaltest.GDALTest('MFF', 'fakemfftiled.hdr', 1, 1) return tst.testOpen() @@ -55,16 +55,16 @@ def mff_2(): ############################################################################### # Test reading a MFF file generated by CreateCopy() -def mff_3(): +def test_mff_3(): tst = gdaltest.GDALTest('MFF', 'bytemff.hdr', 1, 4672) return tst.testOpen() gdaltest_list = [ - mff_1, - mff_2, - mff_3] + test_mff_1, + test_mff_2, + test_mff_3] if __name__ == '__main__': diff --git a/autotest/gdrivers/mff2.py b/autotest/gdrivers/mff2.py index 5d6f59b864c7..c2ff923ec224 100755 --- a/autotest/gdrivers/mff2.py +++ b/autotest/gdrivers/mff2.py @@ -37,14 +37,14 @@ # Test reading a MFF2 file generated by CreateCopy() -def mff2_1(): +def test_mff2_1(): tst = gdaltest.GDALTest('MFF2', 'bytemff2', 1, 4672) return tst.testOpen() gdaltest_list = [ - mff2_1] + test_mff2_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/mg4lidar.py b/autotest/gdrivers/mg4lidar.py index b7a2b01d66db..3411d5ff4f6d 100755 --- a/autotest/gdrivers/mg4lidar.py +++ b/autotest/gdrivers/mg4lidar.py @@ -40,7 +40,7 @@ # -def mg4lidar_1(): +def test_mg4lidar_1(): drv = gdal.GetDriverByName('MG4Lidar') if drv is None: @@ -98,7 +98,7 @@ def mg4lidar_1(): gdaltest_list = [ - mg4lidar_1] + test_mg4lidar_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index 355a13087d58..7db5f2a9d7ec 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -97,7 +97,7 @@ def test_mrf(src_filename, chksum, chksum_after_reopening, options): return ut.testCreateCopy(check_minmax=check_minmax) -def mrf_zen_test(): +def test_mrf_zen_test(): result = 'success' expectedCS = 770 testvrt = ''' @@ -130,7 +130,7 @@ def mrf_zen_test(): return result -def mrf_overview_near_fact_2(): +def test_mrf_overview_near_fact_2(): ref_ds = gdal.Translate('/vsimem/out.tif', 'data/byte.tif') ref_ds.BuildOverviews('NEAR', [2]) @@ -168,7 +168,7 @@ def mrf_overview_near_fact_2(): return 'success' -def mrf_overview_near_with_nodata_fact_2(): +def test_mrf_overview_near_with_nodata_fact_2(): for dt in [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, @@ -202,7 +202,7 @@ def mrf_overview_near_with_nodata_fact_2(): return 'success' -def mrf_overview_avg_fact_2(): +def test_mrf_overview_avg_fact_2(): for dt in [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, @@ -236,7 +236,7 @@ def mrf_overview_avg_fact_2(): return 'success' -def mrf_overview_avg_with_nodata_fact_2(): +def test_mrf_overview_avg_with_nodata_fact_2(): for dt in [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, @@ -271,7 +271,7 @@ def mrf_overview_avg_with_nodata_fact_2(): return 'success' -def mrf_overview_near_fact_3(): +def test_mrf_overview_near_fact_3(): out_ds = gdal.Translate('/vsimem/out.mrf', 'data/byte.tif', format='MRF', @@ -298,7 +298,7 @@ def mrf_overview_near_fact_3(): return 'success' -def mrf_overview_avg_fact_3(): +def test_mrf_overview_avg_fact_3(): out_ds = gdal.Translate('/vsimem/out.mrf', 'data/byte.tif', format='MRF', @@ -325,7 +325,7 @@ def mrf_overview_avg_fact_3(): return 'success' -def mrf_overview_avg_with_nodata_fact_3(): +def test_mrf_overview_avg_with_nodata_fact_3(): for dt in [gdal.GDT_Byte, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, @@ -360,7 +360,7 @@ def mrf_overview_avg_with_nodata_fact_3(): return 'success' -def mrf_overview_partial_block(): +def test_mrf_overview_partial_block(): out_ds = gdal.Translate('/vsimem/out.mrf', 'data/byte.tif', format='MRF', creationOptions=['COMPRESS=NONE', 'BLOCKSIZE=8']) @@ -384,7 +384,7 @@ def mrf_overview_partial_block(): return 'success' -def mrf_overview_near_implicit_level(): +def test_mrf_overview_near_implicit_level(): # We ask only overview level 2, but MRF automatically creates 2 and 4 # so check that 4 is properly initialized @@ -424,7 +424,7 @@ def mrf_overview_near_implicit_level(): return 'success' -def mrf_overview_external(): +def test_mrf_overview_external(): gdal.Translate('/vsimem/out.mrf', 'data/byte.tif', format='MRF') ds = gdal.Open('/vsimem/out.mrf') @@ -451,7 +451,7 @@ def mrf_overview_external(): return 'success' -def mrf_lerc_nodata(): +def test_mrf_lerc_nodata(): gdal.Translate('/vsimem/out.mrf', 'data/byte.tif', format='MRF', noData=107, creationOptions=['COMPRESS=LERC']) @@ -479,7 +479,7 @@ def mrf_lerc_nodata(): return 'success' -def mrf_lerc_with_huffman(): +def test_mrf_lerc_with_huffman(): gdal.Translate('/vsimem/out.mrf', 'data/small_world.tif', format='MRF', width=5000, height=5000, creationOptions=['COMPRESS=LERC']) @@ -502,7 +502,7 @@ def mrf_lerc_with_huffman(): return 'success' -def mrf_cached_source(): +def test_mrf_cached_source(): # Caching MRF gdal.Translate('/vsimem/out.mrf', 'data/byte.tif', format='MRF', @@ -645,7 +645,7 @@ def mrf_cached_source(): return 'success' -def mrf_versioned(): +def test_mrf_versioned(): gdal.Unlink('/vsimem/out.mrf') gdal.Unlink('/vsimem/out.mrf.aux.xml') @@ -715,7 +715,7 @@ def mrf_versioned(): return 'success' -def mrf_cleanup(): +def test_mrf_cleanup(): files = [ '12bit_rose_extract.jpg.*', @@ -748,22 +748,22 @@ def mrf_cleanup(): gdaltest_list = [ - mrf_overview_near_fact_2, - mrf_overview_near_with_nodata_fact_2, - mrf_overview_avg_fact_2, - mrf_overview_avg_with_nodata_fact_2, - mrf_overview_near_fact_3, - mrf_overview_avg_fact_3, - mrf_overview_avg_with_nodata_fact_3, - mrf_overview_partial_block, - mrf_overview_near_implicit_level, - mrf_overview_external, - mrf_lerc_nodata, - mrf_lerc_with_huffman, - mrf_cached_source, - mrf_versioned, - mrf_zen_test, - mrf_cleanup, + test_mrf_overview_near_fact_2, + test_mrf_overview_near_with_nodata_fact_2, + test_mrf_overview_avg_fact_2, + test_mrf_overview_avg_with_nodata_fact_2, + test_mrf_overview_near_fact_3, + test_mrf_overview_avg_fact_3, + test_mrf_overview_avg_with_nodata_fact_3, + test_mrf_overview_partial_block, + test_mrf_overview_near_implicit_level, + test_mrf_overview_external, + test_mrf_lerc_nodata, + test_mrf_lerc_with_huffman, + test_mrf_cached_source, + test_mrf_versioned, + test_mrf_zen_test, + test_mrf_cleanup, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/mrsid.py b/autotest/gdrivers/mrsid.py index 624b26a6ac60..2b4b8e9459eb 100755 --- a/autotest/gdrivers/mrsid.py +++ b/autotest/gdrivers/mrsid.py @@ -41,7 +41,7 @@ # Read a simple byte file, checking projections and geotransform. -def mrsid_1(): +def test_mrsid_1(): gdaltest.mrsid_drv = gdal.GetDriverByName('MrSID') if gdaltest.mrsid_drv is None: @@ -139,7 +139,7 @@ def mrsid_1(): # RasterIO implementation. -def mrsid_2(): +def test_mrsid_2(): if gdaltest.mrsid_drv is None: return 'skip' @@ -176,7 +176,7 @@ def mrsid_2(): # Test overview reading. -def mrsid_3(): +def test_mrsid_3(): if gdaltest.mrsid_drv is None: return 'skip' @@ -207,7 +207,7 @@ def mrsid_3(): # Check a new (V3) file which uses a different form for coordinate sys. -def mrsid_4(): +def test_mrsid_4(): if gdaltest.mrsid_drv is None: return 'skip' @@ -253,7 +253,7 @@ def mrsid_4(): # Test JP2MrSID driver -def mrsid_5(): +def test_mrsid_5(): gdaltest.jp2mrsid_drv = gdal.GetDriverByName('JP2MrSID') if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -266,7 +266,7 @@ def mrsid_5(): # Open byte.jp2 -def mrsid_6(): +def test_mrsid_6(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -299,7 +299,7 @@ def mrsid_6(): ############################################################################### # Open int16.jp2 -def mrsid_7(): +def test_mrsid_7(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -327,7 +327,7 @@ def mrsid_7(): # Test PAM override for nodata, coordsys, and geotransform. -def mrsid_8(): +def test_mrsid_8(): if gdaltest.mrsid_drv is None: return 'skip' @@ -373,7 +373,7 @@ def mrsid_8(): # Test VSI*L IO with .sid -def mrsid_9(): +def test_mrsid_9(): if gdaltest.mrsid_drv is None: return 'skip' @@ -398,7 +398,7 @@ def mrsid_9(): # Test VSI*L IO with .jp2 -def mrsid_10(): +def test_mrsid_10(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -423,7 +423,7 @@ def mrsid_10(): # Check that we can use .j2w world files (#4651) -def mrsid_11(): +def test_mrsid_11(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -448,7 +448,7 @@ def mrsid_11(): ############################################################################### -def mrsid_online_1(): +def test_mrsid_online_1(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -471,7 +471,7 @@ def mrsid_online_1(): ############################################################################### -def mrsid_online_2(): +def test_mrsid_online_2(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -504,7 +504,7 @@ def mrsid_online_2(): ############################################################################### -def mrsid_online_3(): +def test_mrsid_online_3(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -541,7 +541,7 @@ def mrsid_online_3(): ############################################################################### -def mrsid_online_4(): +def test_mrsid_online_4(): if gdaltest.jp2mrsid_drv is None: return 'skip' @@ -577,7 +577,7 @@ def mrsid_online_4(): # Cleanup. -def mrsid_cleanup(): +def test_mrsid_cleanup(): try: os.remove('data/mercator.sid.aux.xml') @@ -591,22 +591,22 @@ def mrsid_cleanup(): gdaltest_list = [ - mrsid_1, - mrsid_2, - mrsid_3, - mrsid_4, - mrsid_5, - mrsid_6, - mrsid_7, - mrsid_8, - mrsid_9, - mrsid_10, - mrsid_11, - mrsid_online_1, - mrsid_online_2, - mrsid_online_3, - mrsid_online_4, - mrsid_cleanup] + test_mrsid_1, + test_mrsid_2, + test_mrsid_3, + test_mrsid_4, + test_mrsid_5, + test_mrsid_6, + test_mrsid_7, + test_mrsid_8, + test_mrsid_9, + test_mrsid_10, + test_mrsid_11, + test_mrsid_online_1, + test_mrsid_online_2, + test_mrsid_online_3, + test_mrsid_online_4, + test_mrsid_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/ndf.py b/autotest/gdrivers/ndf.py index c27e6ba09198..cc513056e853 100755 --- a/autotest/gdrivers/ndf.py +++ b/autotest/gdrivers/ndf.py @@ -37,7 +37,7 @@ # Simple image test of an NLAPS/NDF2 dataset. -def ndf_1(): +def test_ndf_1(): tst = gdaltest.GDALTest('NDF', 'LE7134052000500350.H3', 1, 6510, xoff=0, yoff=0, xsize=15620, ysize=1) @@ -71,7 +71,7 @@ def ndf_1(): gdaltest_list = [ - ndf_1] + test_ndf_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index 42db3b34edac..fac78514b745 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -275,7 +275,7 @@ def netcdf_check_vars(ifile, vals_global=None, vals_band=None): ############################################################################### # Perform simple read test. -def netcdf_1(): +def test_netcdf_1(): # setup netcdf environment netcdf_setup() @@ -299,7 +299,7 @@ def netcdf_1(): # operation because the new file will only be accessible via subdatasets. -def netcdf_2(): +def test_netcdf_2(): if gdaltest.netcdf_drv is None: return 'skip' @@ -350,7 +350,7 @@ def netcdf_2(): ############################################################################### -def netcdf_3(): +def test_netcdf_3(): if gdaltest.netcdf_drv is None: return 'skip' @@ -372,7 +372,7 @@ def netcdf_3(): # In #2582 5dimensional files were causing problems. Verify use ok. -def netcdf_4(): +def test_netcdf_4(): if gdaltest.netcdf_drv is None: return 'skip' @@ -395,7 +395,7 @@ def netcdf_4(): # dimension - check handling now on band 7. -def netcdf_5(): +def test_netcdf_5(): if gdaltest.netcdf_drv is None: return 'skip' @@ -418,7 +418,7 @@ def netcdf_5(): # 1 standard parallel. -def netcdf_6(): +def test_netcdf_6(): if gdaltest.netcdf_drv is None: return 'skip' @@ -444,7 +444,7 @@ def netcdf_6(): # 2 standard parallels. -def netcdf_7(): +def test_netcdf_7(): if gdaltest.netcdf_drv is None: return 'skip' @@ -473,7 +473,7 @@ def netcdf_7(): # now just look for PROJECTION=Albers_Conic_Equal_Area and some parameters -def netcdf_8(): +def test_netcdf_8(): if gdaltest.netcdf_drv is None: return 'skip' @@ -506,7 +506,7 @@ def netcdf_8(): # check to see if projected systems default to wgs84 if no spheroid def -def netcdf_9(): +def test_netcdf_9(): if gdaltest.netcdf_drv is None: return 'skip' @@ -533,7 +533,7 @@ def netcdf_9(): # check if km pixel size makes it through to gt -def netcdf_10(): +def test_netcdf_10(): if gdaltest.netcdf_drv is None: return 'skip' @@ -567,7 +567,7 @@ def netcdf_10(): # check if ll gets caught in km pixel size check -def netcdf_11(): +def test_netcdf_11(): if gdaltest.netcdf_drv is None: return 'skip' @@ -589,7 +589,7 @@ def netcdf_11(): # check for scale/offset set/get. -def netcdf_12(): +def test_netcdf_12(): if gdaltest.netcdf_drv is None: return 'skip' @@ -611,7 +611,7 @@ def netcdf_12(): # check for scale/offset = None if no scale or offset is available -def netcdf_13(): +def test_netcdf_13(): if gdaltest.netcdf_drv is None: return 'skip' @@ -633,7 +633,7 @@ def netcdf_13(): # check for scale/offset for two variables -def netcdf_14(): +def test_netcdf_14(): if gdaltest.netcdf_drv is None: return 'skip' @@ -668,7 +668,7 @@ def netcdf_14(): # This test fails in 1.8.1, because the driver does not support NC2 (bug #3890) -def netcdf_15(): +def test_netcdf_15(): if gdaltest.netcdf_drv is None: return 'skip' @@ -688,7 +688,7 @@ def netcdf_15(): # check support for netcdf-4 -def netcdf_16(): +def test_netcdf_16(): if gdaltest.netcdf_drv is None: return 'skip' @@ -725,7 +725,7 @@ def netcdf_16(): # check support for netcdf-4 - make sure hdf5 is not read by netcdf driver -def netcdf_17(): +def test_netcdf_17(): if gdaltest.netcdf_drv is None: return 'skip' @@ -767,7 +767,7 @@ def netcdf_17(): # check support for netcdf-4 classic (NC4C) -def netcdf_18(): +def test_netcdf_18(): if gdaltest.netcdf_drv is None: return 'skip' @@ -801,7 +801,7 @@ def netcdf_18(): # check support for reading with DEFLATE compression, requires NC4 -def netcdf_19(): +def test_netcdf_19(): if gdaltest.netcdf_drv is None: return 'skip' @@ -820,7 +820,7 @@ def netcdf_19(): # check support for writing with DEFLATE compression, requires NC4 -def netcdf_20(): +def test_netcdf_20(): if gdaltest.netcdf_drv is None: return 'skip' @@ -835,7 +835,7 @@ def netcdf_20(): ############################################################################### # check support for writing large file with DEFLATE compression # if chunking is not defined properly within the netcdf driver, this test can take 1h -def netcdf_21(): +def test_netcdf_21(): if gdaltest.netcdf_drv is None: return 'skip' @@ -883,7 +883,7 @@ def netcdf_21(): ############################################################################### # check support for hdf4 -def netcdf_22(): +def test_netcdf_22(): if gdaltest.netcdf_drv is None: return 'skip' @@ -910,7 +910,7 @@ def netcdf_22(): # check support for hdf4 - make sure hdf4 file is not read by netcdf driver -def netcdf_23(): +def test_netcdf_23(): # don't skip if netcdf is not enabled in GDAL # if gdaltest.netcdf_drv is None: @@ -950,7 +950,7 @@ def netcdf_23(): # check support for reading attributes (single values and array values) -def netcdf_24(): +def test_netcdf_24(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1007,7 +1007,7 @@ def netcdf_24_nc4(): # check support for writing attributes (single values and array values) -def netcdf_25(): +def test_netcdf_25(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1074,7 +1074,7 @@ def netcdf_25_nc4(): # depending on y-axis order -def netcdf_26(): +def test_netcdf_26(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1104,7 +1104,7 @@ def netcdf_26(): # check support for GDAL_NETCDF_BOTTOMUP configuration option -def netcdf_27(): +def test_netcdf_27(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1193,7 +1193,7 @@ def netcdf_test_4dfile(ofile): # check support for writing multi-dimensional files using CreateCopy() -def netcdf_28(): +def test_netcdf_28(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1219,7 +1219,7 @@ def netcdf_28(): # metadata to netcdf file with SetMetadata() and SetMetadataItem()). -def netcdf_29(): +def test_netcdf_29(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1261,7 +1261,7 @@ def netcdf_29(): # check support for file with nan values (bug #4705) -def netcdf_30(): +def test_netcdf_30(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1281,7 +1281,7 @@ def netcdf_30(): # 1 pixel (in width or height) still unsupported because we can't get the pixel dimensions -def netcdf_31(): +def test_netcdf_31(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1306,7 +1306,7 @@ def netcdf_31(): # Test NC_UBYTE write/read - netcdf-4 (FORMAT=NC4) only (#5053) -def netcdf_32(): +def test_netcdf_32(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1333,7 +1333,7 @@ def netcdf_32(): # TEST NC_UBYTE metadata read - netcdf-4 (FORMAT=NC4) only (#5053) -def netcdf_33(): +def test_netcdf_33(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1352,7 +1352,7 @@ def netcdf_33(): # if chunking is not supported within the netcdf driver, this test can take very long -def netcdf_34(): +def test_netcdf_34(): filename = 'utm-big-chunks.nc' # this timeout is more than enough - on my system takes <1s with fix, about 25 seconds without @@ -1401,7 +1401,7 @@ def netcdf_34(): # test writing a long metadata > 8196 chars (bug #5113) -def netcdf_35(): +def test_netcdf_35(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1437,7 +1437,7 @@ def netcdf_35(): # test for correct geotransform (bug #5114) -def netcdf_36(): +def test_netcdf_36(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1465,7 +1465,7 @@ def netcdf_36(): # test for correct geotransform with longitude wrap -def netcdf_36_lonwrap(): +def test_netcdf_36_lonwrap(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1493,7 +1493,7 @@ def netcdf_36_lonwrap(): # test for reading gaussian grid (bugs #4513 and #5118) -def netcdf_37(): +def test_netcdf_37(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1532,7 +1532,7 @@ def netcdf_37(): # test for correct geotransform of projected data in km units (bug #5118) -def netcdf_38(): +def test_netcdf_38(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1561,7 +1561,7 @@ def netcdf_38(): # Test VRT and NETCDF: -def netcdf_39(): +def test_netcdf_39(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1638,7 +1638,7 @@ def netcdf_39(): # Check support of reading of chunked bottom-up files. -def netcdf_40(): +def test_netcdf_40(): if gdaltest.netcdf_drv is None or not gdaltest.netcdf_drv_has_nc4: return 'skip' @@ -1649,7 +1649,7 @@ def netcdf_40(): # Test support for georeferenced file without CF convention -def netcdf_41(): +def test_netcdf_41(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1671,7 +1671,7 @@ def netcdf_41(): # Test writing & reading GEOLOCATION array -def netcdf_42(): +def test_netcdf_42(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1726,7 +1726,7 @@ def netcdf_42(): # Test reading GEOLOCATION array from geotransform (non default) -def netcdf_43(): +def test_netcdf_43(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1755,7 +1755,7 @@ def netcdf_43(): # Test NC_USHORT/UINT read/write - netcdf-4 only (#6337) -def netcdf_44(): +def test_netcdf_44(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1774,7 +1774,7 @@ def netcdf_44(): # Test reading a vector NetCDF 3 file -def netcdf_45(): +def test_netcdf_45(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1830,7 +1830,7 @@ def netcdf_45(): # Test reading a vector NetCDF 3 file -def netcdf_46(): +def test_netcdf_46(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1850,7 +1850,7 @@ def netcdf_46(): # Test reading a vector NetCDF 4 file -def netcdf_47(): +def test_netcdf_47(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1904,7 +1904,7 @@ def netcdf_47(): # Test reading a vector NetCDF 3 file without any geometry -def netcdf_48(): +def test_netcdf_48(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1926,7 +1926,7 @@ def netcdf_48(): # Test reading a vector NetCDF 3 file with X,Y,Z vars as float -def netcdf_49(): +def test_netcdf_49(): if gdaltest.netcdf_drv is None: return 'skip' @@ -1957,7 +1957,7 @@ def netcdf_49(): # Test creating a vector NetCDF 3 file with WKT geometry field -def netcdf_50(): +def test_netcdf_50(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2006,7 +2006,7 @@ def netcdf_50(): # Test creating a vector NetCDF 3 file with X,Y,Z fields -def netcdf_51(): +def test_netcdf_51(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2090,7 +2090,7 @@ def netcdf_51(): # Test creating a vector NetCDF 3 file with X,Y,Z fields with WRITE_GDAL_TAGS=NO -def netcdf_51_no_gdal_tags(): +def test_netcdf_51_no_gdal_tags(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2141,7 +2141,7 @@ def netcdf_51_no_gdal_tags(): # Test creating a vector NetCDF 4 file with X,Y,Z fields -def netcdf_52(): +def test_netcdf_52(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2225,7 +2225,7 @@ def netcdf_52(): # Test creating a vector NetCDF 4 file with WKT geometry field -def netcdf_53(): +def test_netcdf_53(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2277,7 +2277,7 @@ def netcdf_53(): # Test appending to a vector NetCDF 4 file with unusual types (ubyte, ushort...) -def netcdf_54(): +def test_netcdf_54(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2324,7 +2324,7 @@ def netcdf_54(): # Test auto-grow of bidimensional char variables in a vector NetCDF 4 file -def netcdf_55(): +def test_netcdf_55(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2371,7 +2371,7 @@ def netcdf_55(): # Test truncation of bidimensional char variables and WKT in a vector NetCDF 3 file -def netcdf_56(): +def test_netcdf_56(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2407,7 +2407,7 @@ def netcdf_56(): # Test one layer per file creation -def netcdf_57(): +def test_netcdf_57(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2459,7 +2459,7 @@ def netcdf_57(): # Test one layer per group (NC4) -def netcdf_58(): +def test_netcdf_58(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2494,7 +2494,7 @@ def netcdf_58(): # check for UnitType set/get. -def netcdf_59(): +def test_netcdf_59(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2520,7 +2520,7 @@ def netcdf_59(): # http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#_indexed_ragged_array_representation_of_profiles -def netcdf_60(): +def test_netcdf_60(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2562,7 +2562,7 @@ def netcdf_60(): # Test appending to a "Indexed ragged array representation of profiles" v1.6.0 H3.5 -def netcdf_61(): +def test_netcdf_61(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2599,7 +2599,7 @@ def netcdf_61(): # Test creating a "Indexed ragged array representation of profiles" v1.6.0 H3.5 -def netcdf_62(): +def test_netcdf_62(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2628,7 +2628,7 @@ def netcdf_62(): return 'success' -def netcdf_62_ncdump_check(): +def test_netcdf_62_ncdump_check(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2656,7 +2656,7 @@ def netcdf_62_ncdump_check(): return 'success' -def netcdf_62_cf_check(): +def test_netcdf_62_cf_check(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2677,7 +2677,7 @@ def netcdf_62_cf_check(): # Test creating a NC4 "Indexed ragged array representation of profiles" v1.6.0 H3.5 -def netcdf_63(): +def test_netcdf_63(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2710,7 +2710,7 @@ def netcdf_63(): return 'success' -def netcdf_63_ncdump_check(): +def test_netcdf_63_ncdump_check(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2747,7 +2747,7 @@ def netcdf_63_ncdump_check(): # but without a profile field. -def netcdf_64(): +def test_netcdf_64(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2781,7 +2781,7 @@ def netcdf_64(): # (they must be filled as empty strings to avoid crashes in netcdf lib) -def netcdf_65(): +def test_netcdf_65(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2814,7 +2814,7 @@ def netcdf_65(): # from a config file -def netcdf_66(): +def test_netcdf_66(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2917,7 +2917,7 @@ def netcdf_66(): return 'success' -def netcdf_66_ncdump_check(): +def test_netcdf_66_ncdump_check(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2953,7 +2953,7 @@ def netcdf_66_ncdump_check(): # blocks in the x axischeck for partial block reading. -def netcdf_67(): +def test_netcdf_67(): if gdaltest.netcdf_drv is None: return 'skip' @@ -2988,7 +2988,7 @@ def netcdf_67(): ############################################################################### # Test reading SRS from srid attribute (#6613) -def netcdf_68(): +def test_netcdf_68(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3006,7 +3006,7 @@ def netcdf_68(): # Test opening a dataset with a 1D variable with 0 record (#6645) -def netcdf_69(): +def test_netcdf_69(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3021,7 +3021,7 @@ def netcdf_69(): # Test that we don't erroneously identify non-longitude axis as longitude (#6759) -def netcdf_70(): +def test_netcdf_70(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3040,7 +3040,7 @@ def netcdf_70(): # (https://github.com/OSGeo/gdal/pull/200) -def netcdf_71(): +def test_netcdf_71(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3058,7 +3058,7 @@ def netcdf_71(): # test int64 attributes / dim -def netcdf_72(): +def test_netcdf_72(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3078,7 +3078,7 @@ def netcdf_72(): # test geostationary with radian units (https://github.com/OSGeo/gdal/pull/220) -def netcdf_73(): +def test_netcdf_73(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3096,7 +3096,7 @@ def netcdf_73(): # test geostationary with microradian units (https://github.com/OSGeo/gdal/pull/220) -def netcdf_74(): +def test_netcdf_74(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3114,7 +3114,7 @@ def netcdf_74(): # test opening a ncdump file -def netcdf_75(): +def test_netcdf_75(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3150,7 +3150,7 @@ def netcdf_75(): # test opening a vector ncdump file -def netcdf_76(): +def test_netcdf_76(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3171,7 +3171,7 @@ def netcdf_76(): # test opening a raster file that used to be confused with a vector file (#6974) -def netcdf_77(): +def test_netcdf_77(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3195,7 +3195,7 @@ def netcdf_77(): # test we handle correctly valid_range={0,255} for a byte dataset with # negative nodata value -def netcdf_78(): +def test_netcdf_78(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3218,7 +3218,7 @@ def netcdf_78(): # negative nodata value -def netcdf_79(): +def test_netcdf_79(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3240,7 +3240,7 @@ def netcdf_79(): # Test creating and opening with accent -def netcdf_80(): +def test_netcdf_80(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3252,7 +3252,7 @@ def netcdf_80(): # netCDF file in rotated_pole projection -def netcdf_81(): +def test_netcdf_81(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3287,7 +3287,7 @@ def netcdf_81(): # 1D variable, several corresponding variables) -def netcdf_82(): +def test_netcdf_82(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3324,7 +3324,7 @@ def netcdf_82(): ############################################################################### -def netcdf_uffd(): +def test_netcdf_uffd(): if gdaltest.netcdf_drv is None: return 'skip' @@ -3354,95 +3354,95 @@ def netcdf_uffd(): gdaltest_list = [ - netcdf_1, - netcdf_2, - netcdf_3, - netcdf_4, - netcdf_5, - netcdf_6, - netcdf_7, - netcdf_8, - netcdf_9, - netcdf_10, - netcdf_11, - netcdf_12, - netcdf_13, - netcdf_14, - netcdf_15, - netcdf_16, - netcdf_17, - netcdf_18, - netcdf_19, - netcdf_20, - netcdf_21, - netcdf_22, - netcdf_23, - netcdf_24, - netcdf_25, - netcdf_26, - netcdf_27, - netcdf_28, - netcdf_29, - netcdf_30, - netcdf_31, - netcdf_32, - netcdf_33, - netcdf_34, - netcdf_35, - netcdf_36, - netcdf_36_lonwrap, - netcdf_37, - netcdf_38, - netcdf_39, - netcdf_40, - netcdf_41, - netcdf_42, - netcdf_43, - netcdf_44, - netcdf_45, - netcdf_46, - netcdf_47, - netcdf_48, - netcdf_49, - netcdf_50, - netcdf_51, - netcdf_51_no_gdal_tags, - netcdf_52, - netcdf_53, - netcdf_54, - netcdf_55, - netcdf_56, - netcdf_57, - netcdf_58, - netcdf_59, - netcdf_60, - netcdf_61, - netcdf_62, - netcdf_62_ncdump_check, - netcdf_62_cf_check, - netcdf_63, - netcdf_63_ncdump_check, - netcdf_64, - netcdf_65, - netcdf_66, - netcdf_66_ncdump_check, - netcdf_67, - netcdf_68, - netcdf_69, - netcdf_70, - netcdf_71, - netcdf_72, - netcdf_73, - netcdf_74, - netcdf_75, - netcdf_76, - netcdf_77, - netcdf_78, - netcdf_79, - netcdf_80, - netcdf_81, - netcdf_82, - netcdf_uffd, + test_netcdf_1, + test_netcdf_2, + test_netcdf_3, + test_netcdf_4, + test_netcdf_5, + test_netcdf_6, + test_netcdf_7, + test_netcdf_8, + test_netcdf_9, + test_netcdf_10, + test_netcdf_11, + test_netcdf_12, + test_netcdf_13, + test_netcdf_14, + test_netcdf_15, + test_netcdf_16, + test_netcdf_17, + test_netcdf_18, + test_netcdf_19, + test_netcdf_20, + test_netcdf_21, + test_netcdf_22, + test_netcdf_23, + test_netcdf_24, + test_netcdf_25, + test_netcdf_26, + test_netcdf_27, + test_netcdf_28, + test_netcdf_29, + test_netcdf_30, + test_netcdf_31, + test_netcdf_32, + test_netcdf_33, + test_netcdf_34, + test_netcdf_35, + test_netcdf_36, + test_netcdf_36_lonwrap, + test_netcdf_37, + test_netcdf_38, + test_netcdf_39, + test_netcdf_40, + test_netcdf_41, + test_netcdf_42, + test_netcdf_43, + test_netcdf_44, + test_netcdf_45, + test_netcdf_46, + test_netcdf_47, + test_netcdf_48, + test_netcdf_49, + test_netcdf_50, + test_netcdf_51, + test_netcdf_51_no_gdal_tags, + test_netcdf_52, + test_netcdf_53, + test_netcdf_54, + test_netcdf_55, + test_netcdf_56, + test_netcdf_57, + test_netcdf_58, + test_netcdf_59, + test_netcdf_60, + test_netcdf_61, + test_netcdf_62, + test_netcdf_62_ncdump_check, + test_netcdf_62_cf_check, + test_netcdf_63, + test_netcdf_63_ncdump_check, + test_netcdf_64, + test_netcdf_65, + test_netcdf_66, + test_netcdf_66_ncdump_check, + test_netcdf_67, + test_netcdf_68, + test_netcdf_69, + test_netcdf_70, + test_netcdf_71, + test_netcdf_72, + test_netcdf_73, + test_netcdf_74, + test_netcdf_75, + test_netcdf_76, + test_netcdf_77, + test_netcdf_78, + test_netcdf_79, + test_netcdf_80, + test_netcdf_81, + test_netcdf_82, + test_netcdf_uffd, ] ############################################################################### diff --git a/autotest/gdrivers/netcdf_cf.py b/autotest/gdrivers/netcdf_cf.py index ed271c43bc81..a1a3b26347d1 100755 --- a/autotest/gdrivers/netcdf_cf.py +++ b/autotest/gdrivers/netcdf_cf.py @@ -556,7 +556,7 @@ def netcdf_cfproj_test_cf(proj, projNc): ############################################################################### # test copy and CF compliance for lat/lon (no datum, no GEOGCS) file, tif->nc->tif -def netcdf_cf_1(): +def test_netcdf_cf_1(): # setup netcdf and netcdf_cf environment netcdf_setup() @@ -584,7 +584,7 @@ def netcdf_cf_1(): ############################################################################### # test copy and CF compliance for lat/lon (no datum, no GEOGCS) file, nc->nc -def netcdf_cf_2(): +def test_netcdf_cf_2(): if gdaltest.netcdf_drv is None: return 'skip' @@ -603,7 +603,7 @@ def netcdf_cf_2(): ############################################################################### # test copy and CF compliance for lat/lon (W*S84) file, tif->nc->tif # note: this test fails in trunk (before r23246) -def netcdf_cf_3(): +def test_netcdf_cf_3(): if gdaltest.netcdf_drv is None: return 'skip' @@ -630,7 +630,7 @@ def netcdf_cf_3(): # test support for various CF projections -def netcdf_cf_4(): +def test_netcdf_cf_4(): if gdaltest.netcdf_drv is None: return 'skip' @@ -647,7 +647,7 @@ def netcdf_cf_4(): # test support for PS variants (bug #2893) -def netcdf_cf_5(): +def test_netcdf_cf_5(): if gdaltest.netcdf_drv is None: return 'skip' @@ -671,11 +671,11 @@ def netcdf_cf_5(): gdaltest_list = [ - netcdf_cf_1, - netcdf_cf_2, - netcdf_cf_3, - netcdf_cf_4, - netcdf_cf_5, + test_netcdf_cf_1, + test_netcdf_cf_2, + test_netcdf_cf_3, + test_netcdf_cf_4, + test_netcdf_cf_5, None] if __name__ == '__main__': diff --git a/autotest/gdrivers/ngsgeoid.py b/autotest/gdrivers/ngsgeoid.py index ea6e2c6041c6..e7af8efaf01e 100755 --- a/autotest/gdrivers/ngsgeoid.py +++ b/autotest/gdrivers/ngsgeoid.py @@ -37,7 +37,7 @@ # Test opening a little endian file -def ngsgeoid_1(): +def test_ngsgeoid_1(): tst = gdaltest.GDALTest('NGSGEOID', 'g2009u01_le_truncated.bin', 1, 65534) return tst.testOpen(check_gt=(229.99166666666667, 0.016666666666670001, 0.0, 40.00833333333334, 0.0, -0.016666666666670001), check_prj='WGS84') @@ -46,15 +46,15 @@ def ngsgeoid_1(): # Test opening a big endian file -def ngsgeoid_2(): +def test_ngsgeoid_2(): tst = gdaltest.GDALTest('NGSGEOID', 'g2009u01_be_truncated.bin', 1, 65534) return tst.testOpen(check_gt=(229.99166666666667, 0.016666666666670001, 0.0, 40.00833333333334, 0.0, -0.016666666666670001), check_prj='WGS84') gdaltest_list = [ - ngsgeoid_1, - ngsgeoid_2 + test_ngsgeoid_1, + test_ngsgeoid_2 ] if __name__ == '__main__': diff --git a/autotest/gdrivers/nitf.py b/autotest/gdrivers/nitf.py index 08c292c7e9ae..7fe2659b61ab 100755 --- a/autotest/gdrivers/nitf.py +++ b/autotest/gdrivers/nitf.py @@ -46,7 +46,7 @@ # Write/Read test of simple byte reference data. -def nitf_1(): +def test_nitf_1(): tst = gdaltest.GDALTest('NITF', 'byte.tif', 1, 4672) return tst.testCreateCopy() @@ -55,7 +55,7 @@ def nitf_1(): # Write/Read test of simple 16bit reference data. -def nitf_2(): +def test_nitf_2(): tst = gdaltest.GDALTest('NITF', 'int16.tif', 1, 4672) return tst.testCreateCopy() @@ -64,7 +64,7 @@ def nitf_2(): # Write/Read RGB image with lat/long georeferencing, and verify. -def nitf_3(): +def test_nitf_3(): tst = gdaltest.GDALTest('NITF', 'rgbsmall.tif', 3, 21349) return tst.testCreateCopy() @@ -118,7 +118,7 @@ def nitf_create(creation_options, set_inverted_color_interp=True, createcopy=Fal # Test direction creation of an non-compressed NITF file. -def nitf_4(): +def test_nitf_4(): return nitf_create(['ICORDS=G']) @@ -182,7 +182,7 @@ def nitf_check_created_file(checksum1, checksum2, checksum3, set_inverted_color_ # Verify file created by nitf_4() -def nitf_5(): +def test_nitf_5(): return nitf_check_created_file(32498, 42602, 38982) @@ -190,7 +190,7 @@ def nitf_5(): # Read existing NITF file. Verifies the new adjusted IGEOLO interp. -def nitf_6(): +def test_nitf_6(): tst = gdaltest.GDALTest('NITF', 'rgb.ntf', 3, 21349) return tst.testOpen(check_prj='WGS84', @@ -201,7 +201,7 @@ def nitf_6(): # NITF in-memory. -def nitf_7(): +def test_nitf_7(): tst = gdaltest.GDALTest('NITF', 'rgbsmall.tif', 3, 21349) return tst.testCreateCopy(vsimem=1) @@ -210,7 +210,7 @@ def nitf_7(): # Verify we can open an NSIF file, and get metadata including BLOCKA. -def nitf_8(): +def test_nitf_8(): ds = gdal.Open('data/fake_nsif.ntf') @@ -245,7 +245,7 @@ def nitf_8(): # Create and read a JPEG encoded NITF file. -def nitf_9(): +def test_nitf_9(): src_ds = gdal.Open('data/rgbsmall.tif') ds = gdal.GetDriverByName('NITF').CreateCopy('tmp/nitf9.ntf', src_ds, @@ -275,7 +275,7 @@ def nitf_9(): # tricky. Verify this is working. -def nitf_10(): +def test_nitf_10(): src_ds = gdal.Open('tmp/nitf9.ntf') expected_cs = src_ds.GetRasterBand(2).Checksum() @@ -291,7 +291,7 @@ def nitf_10(): # Test 1bit file ... conveniently very small and easy to include! (#1854) -def nitf_11(): +def test_nitf_11(): # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/i_3034c.ntf tst = gdaltest.GDALTest('NITF', 'i_3034c.ntf', 1, 170) @@ -301,7 +301,7 @@ def nitf_11(): # Verify that TRE and CGM access via the metadata domain works. -def nitf_12(): +def test_nitf_12(): ds = gdal.Open('data/fake_nsif.ntf') @@ -345,7 +345,7 @@ def nitf_12(): ############################################################################### # Test creation of an NITF file in UTM Zone 11, Southern Hemisphere. -def nitf_13(): +def test_nitf_13(): drv = gdal.GetDriverByName('NITF') ds = drv.Create('tmp/test_13.ntf', 200, 100, 1, gdal.GDT_Byte, ['ICORDS=S']) @@ -368,7 +368,7 @@ def nitf_13(): # Verify previous file -def nitf_14(): +def test_nitf_14(): ds = gdal.Open('tmp/test_13.ntf') chksum = ds.GetRasterBand(1).Checksum() @@ -403,7 +403,7 @@ def nitf_14(): # Test creating an in memory copy. -def nitf_15(): +def test_nitf_15(): tst = gdaltest.GDALTest('NITF', 'byte.tif', 1, 4672) @@ -413,7 +413,7 @@ def nitf_15(): # Checks a 1-bit mono with mask table having (0x00) black as transparent with white arrow. -def nitf_16(): +def test_nitf_16(): # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/ns3034d.nsf tst = gdaltest.GDALTest('NITF', 'ns3034d.nsf', 1, 170) @@ -424,7 +424,7 @@ def nitf_16(): # Checks a 1-bit RGB/LUT (green arrow) with a mask table (pad pixels having value of 0x00) # and a transparent pixel value of 1 being mapped to green by the LUT -def nitf_17(): +def test_nitf_17(): # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/i_3034f.ntf tst = gdaltest.GDALTest('NITF', 'i_3034f.ntf', 1, 170) @@ -434,7 +434,7 @@ def nitf_17(): # Test NITF file without image segment -def nitf_18(): +def test_nitf_18(): # Shut up the warning about missing image segment gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -451,7 +451,7 @@ def nitf_18(): # Test BILEVEL (C1) decompression -def nitf_19(): +def test_nitf_19(): # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_0/U_1050A.NTF tst = gdaltest.GDALTest('NITF', 'U_1050A.NTF', 1, 65024) @@ -462,7 +462,7 @@ def nitf_19(): ############################################################################### # Test NITF file consisting only of an header -def nitf_20(): +def test_nitf_20(): # Shut up the warning about file either corrupt or empty gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -481,7 +481,7 @@ def nitf_20(): # # See also nitf_35 for writing TEXT segments. -def nitf_21(): +def test_nitf_21(): # Shut up the warning about missing image segment gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -511,7 +511,7 @@ def nitf_21(): ############################################################################### # Write/Read test of simple int32 reference data. -def nitf_22(): +def test_nitf_22(): tst = gdaltest.GDALTest('NITF', '../../gcore/data/int32.tif', 1, 4672) return tst.testCreateCopy() @@ -520,7 +520,7 @@ def nitf_22(): # Write/Read test of simple float32 reference data. -def nitf_23(): +def test_nitf_23(): tst = gdaltest.GDALTest('NITF', '../../gcore/data/float32.tif', 1, 4672) return tst.testCreateCopy() @@ -529,7 +529,7 @@ def nitf_23(): # Write/Read test of simple float64 reference data. -def nitf_24(): +def test_nitf_24(): tst = gdaltest.GDALTest('NITF', '../../gcore/data/float64.tif', 1, 4672) return tst.testCreateCopy() @@ -538,7 +538,7 @@ def nitf_24(): # Write/Read test of simple uint16 reference data. -def nitf_25(): +def test_nitf_25(): tst = gdaltest.GDALTest('NITF', '../../gcore/data/uint16.tif', 1, 4672) return tst.testCreateCopy() @@ -547,7 +547,7 @@ def nitf_25(): # Write/Read test of simple uint32 reference data. -def nitf_26(): +def test_nitf_26(): tst = gdaltest.GDALTest('NITF', '../../gcore/data/uint32.tif', 1, 4672) return tst.testCreateCopy() @@ -556,7 +556,7 @@ def nitf_26(): # Test Create() with IC=NC compression, and multi-blocks -def nitf_27(): +def test_nitf_27(): if nitf_create(['ICORDS=G', 'IC=NC', 'BLOCKXSIZE=10', 'BLOCKYSIZE=10']) != 'success': return 'fail' @@ -567,7 +567,7 @@ def nitf_27(): ############################################################################### # Test Create() with IC=C8 compression with the JP2ECW driver -def nitf_28_jp2ecw(): +def test_nitf_28_jp2ecw(): gdaltest.nitf_28_jp2ecw_is_ok = False if gdal.GetDriverByName('JP2ECW') is None: @@ -607,7 +607,7 @@ def nitf_28_jp2ecw(): # Test reading the previously create file with the JP2MrSID driver -def nitf_28_jp2mrsid(): +def test_nitf_28_jp2mrsid(): if not gdaltest.nitf_28_jp2ecw_is_ok: return 'skip' @@ -628,7 +628,7 @@ def nitf_28_jp2mrsid(): ############################################################################### # Test reading the previously create file with the JP2KAK driver -def nitf_28_jp2kak(): +def test_nitf_28_jp2kak(): if not gdaltest.nitf_28_jp2ecw_is_ok: return 'skip' @@ -649,7 +649,7 @@ def nitf_28_jp2kak(): # Test reading the previously create file with the JP2KAK driver -def nitf_28_jp2openjpeg(): +def test_nitf_28_jp2openjpeg(): if not gdaltest.nitf_28_jp2ecw_is_ok: return 'skip' @@ -670,7 +670,7 @@ def nitf_28_jp2openjpeg(): # Test Create() with IC=C8 compression with the JP2OpenJPEG driver -def nitf_28_jp2openjpeg_bis(): +def test_nitf_28_jp2openjpeg_bis(): drv = gdal.GetDriverByName('JP2OpenJPEG') if drv is None: return 'skip' @@ -703,7 +703,7 @@ def nitf_28_jp2openjpeg_bis(): # Test Create() with a LUT -def nitf_29(): +def test_nitf_29(): drv = gdal.GetDriverByName('NITF') @@ -754,7 +754,7 @@ def nitf_29(): # Verify we can write a file with BLOCKA TRE and read it back properly. -def nitf_30(): +def test_nitf_30(): src_ds = gdal.Open('data/fake_nsif.ntf') ds = gdal.GetDriverByName('NITF').CreateCopy('tmp/nitf30.ntf', src_ds) @@ -870,7 +870,7 @@ def nitf_30(): # Verify we can write a file with a custom TRE and read it back properly. -def nitf_31(): +def test_nitf_31(): if nitf_create(['TRE=CUSTOM= Test TRE1\\0MORE', 'TRE=TOTEST=SecondTRE', @@ -907,7 +907,7 @@ def nitf_31(): ############################################################################### # Test Create() with ICORDS=D -def nitf_32(): +def test_nitf_32(): if nitf_create(['ICORDS=D']) != 'success': return 'fail' @@ -918,7 +918,7 @@ def nitf_32(): ############################################################################### # Test Create() with ICORDS=D and a consistent BLOCKA -def nitf_33(): +def test_nitf_33(): if nitf_create(['ICORDS=D', 'BLOCKA_BLOCK_COUNT=01', @@ -936,7 +936,7 @@ def nitf_33(): ############################################################################### # Test CreateCopy() of a 16bit image with tiling -def nitf_34(): +def test_nitf_34(): tst = gdaltest.GDALTest('NITF', 'n43.dt0', 1, 49187, options=['BLOCKSIZE=64']) return tst.testCreateCopy() @@ -945,7 +945,7 @@ def nitf_34(): # Test CreateCopy() writing file with a text segment. -def nitf_35(): +def test_nitf_35(): src_ds = gdal.Open('data/text_md.vrt') ds = gdal.GetDriverByName('NITF').CreateCopy('tmp/nitf_35.ntf', src_ds) @@ -981,7 +981,7 @@ def nitf_35(): # Check that statistics are persisted (#3985) -def nitf_36(): +def test_nitf_36(): src_ds = gdal.Open('data/rgbsmall.tif') ds = gdal.GetDriverByName('NITF').CreateCopy('tmp/nitf36.ntf', src_ds, @@ -1036,7 +1036,7 @@ def nitf_36(): # Create and read a NITF file with 69999 bands -def nitf_37(): +def test_nitf_37(): try: if int(gdal.VersionInfo('VERSION_NUM')) < 1700: return 'skip' @@ -1058,7 +1058,7 @@ def nitf_37(): # Create and read a NITF file with 999 images -def nitf_38(): +def test_nitf_38(): ds = gdal.Open('data/byte.tif') nXSize = ds.RasterXSize @@ -1146,7 +1146,7 @@ def nitf_38(): # Create and read a JPEG encoded NITF file (M3) with several blocks -def nitf_39(): +def test_nitf_39(): src_ds = gdal.Open('data/rgbsmall.tif') ds = gdal.GetDriverByName('NITF').CreateCopy('tmp/nitf39.ntf', src_ds, @@ -1177,7 +1177,7 @@ def nitf_39(): # Create a 10 GB NITF file -def nitf_40(): +def test_nitf_40(): # Determine if the filesystem supports sparse files (we don't want to create a real 10 GB # file ! @@ -1234,7 +1234,7 @@ def nitf_40(): ############################################################################### # Check reading a 12-bit JPEG compressed NITF -def nitf_41(): +def test_nitf_41(): import jpeg jpeg.jpeg_1() @@ -1273,7 +1273,7 @@ def nitf_41(): # Check creating a 12-bit JPEG compressed NITF -def nitf_42(): +def test_nitf_42(): if gdaltest.jpeg_version == '9b': return 'skip' @@ -1340,25 +1340,25 @@ def nitf_43(driver_to_test, options): return ret -def nitf_43_jasper(): +def test_nitf_43_jasper(): return nitf_43('JPEG2000', ['IC=C8']) -def nitf_43_jp2ecw(): +def test_nitf_43_jp2ecw(): import ecw if not ecw.has_write_support(): return 'skip' return nitf_43('JP2ECW', ['IC=C8', 'TARGET=0']) -def nitf_43_jp2kak(): +def test_nitf_43_jp2kak(): return nitf_43('JP2KAK', ['IC=C8', 'QUALITY=100']) ############################################################################### # Check creating a monoblock 10000x1 image (ticket #3263) -def nitf_44(): +def test_nitf_44(): out_ds = gdal.GetDriverByName('NITF').Create('tmp/nitf44.ntf', 10000, 1) out_ds.GetRasterBand(1).Fill(255) @@ -1381,7 +1381,7 @@ def nitf_44(): # Check overviews on a JPEG compressed subdataset -def nitf_45(): +def test_nitf_45(): try: os.remove('tmp/nitf45.ntf.aux.xml') @@ -1468,7 +1468,7 @@ def nitf_46_jp2kak(): return nitf_46('JP2KAK') -def nitf_46_jasper(): +def test_nitf_46_jasper(): return nitf_46('JPEG2000') @@ -1479,7 +1479,7 @@ def nitf_46_openjpeg(): # Check reading of rsets. -def nitf_47(): +def test_nitf_47(): ds = gdal.Open('data/rset.ntf.r0') @@ -1502,7 +1502,7 @@ def nitf_47(): # Check building of standard overviews in place of rset overviews. -def nitf_48(): +def test_nitf_48(): try: os.remove('tmp/rset.ntf.r0') @@ -1547,7 +1547,7 @@ def nitf_48(): # Test TEXT and CGM creation options with CreateCopy() (#3376) -def nitf_49(): +def test_nitf_49(): options = ["TEXT=DATA_0=COUCOU", "TEXT=HEADER_0=ABC", # This content is invalid but who cares here @@ -1591,7 +1591,7 @@ def nitf_49(): # Test TEXT and CGM creation options with Create() (#3376) -def nitf_50(): +def test_nitf_50(): options = [ # "IC=C8", "TEXT=DATA_0=COUCOU", @@ -1647,7 +1647,7 @@ def nitf_50(): # Test reading very small images with NBPP < 8 or NBPP == 12 -def nitf_51(): +def test_nitf_51(): for xsize in range(1, 9): for nbpp in [1, 2, 3, 4, 5, 6, 7, 12]: ds = gdal.GetDriverByName('NITF').Create('tmp/nitf51.ntf', xsize, 1) @@ -1689,7 +1689,7 @@ def nitf_51(): # Test reading GeoSDE TREs -def nitf_52(): +def test_nitf_52(): # Create a fake NITF file with GeoSDE TREs (probably not conformant, but enough to test GDAL code) ds = gdal.GetDriverByName('NITF').Create('tmp/nitf52.ntf', 1, 1, options=['FILE_TRE=GEOPSB=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345EURM ', @@ -1718,7 +1718,7 @@ def nitf_52(): # Test reading UTM MGRS -def nitf_53(): +def test_nitf_53(): ds = gdal.GetDriverByName('NITF').Create('tmp/nitf53.ntf', 2, 2, options=['ICORDS=N']) ds = None @@ -1756,7 +1756,7 @@ def nitf_53(): # Test reading RPC00B -def nitf_54(): +def test_nitf_54(): # Create a fake NITF file with RPC00B TRE (probably not conformant, but enough to test GDAL code) RPC00B = '100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' @@ -1778,7 +1778,7 @@ def nitf_54(): # Test reading ICHIPB -def nitf_55(): +def test_nitf_55(): # Create a fake NITF file with ICHIPB TRE (probably not conformant, but enough to test GDAL code) ICHIPB = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' @@ -1800,7 +1800,7 @@ def nitf_55(): # Test reading USE00A -def nitf_56(): +def test_nitf_56(): # Create a fake NITF file with USE00A TRE (probably not conformant, but enough to test GDAL code) USE00A = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' @@ -1822,7 +1822,7 @@ def nitf_56(): # Test reading GEOLOB -def nitf_57(): +def test_nitf_57(): # Create a fake NITF file with GEOLOB TRE GEOLOB = '000000360000000360-180.000000000090.000000000000' @@ -1845,7 +1845,7 @@ def nitf_57(): # Test reading STDIDC -def nitf_58(): +def test_nitf_58(): # Create a fake NITF file with STDIDC TRE (probably not conformant, but enough to test GDAL code) STDIDC = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' @@ -1867,7 +1867,7 @@ def nitf_58(): # Test reading IMRFCA and IMASDA -def nitf_read_IMRFCA_IMASDA(): +def test_nitf_read_IMRFCA_IMASDA(): # Create a fake NITF file with fake IMRFCA and IMASDA TRE IMRFCA = '0' * 1760 @@ -1936,7 +1936,7 @@ def nitf_read_IMRFCA_IMASDA(): # Test georeferencing through .nfw and .hdr files -def nitf_59(): +def test_nitf_59(): shutil.copyfile('data/nitf59.nfw', 'tmp/nitf59.nfw') shutil.copyfile('data/nitf59.hdr', 'tmp/nitf59.hdr') @@ -1964,7 +1964,7 @@ def nitf_59(): # Test reading CADRG polar tile georeferencing (#2940) -def nitf_60(): +def test_nitf_60(): # Shut down errors because the file is truncated gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -1992,7 +1992,7 @@ def nitf_60(): # Test reading TRE from DE segment -def nitf_61(): +def test_nitf_61(): # Derived from http://www.gwg.nga.mil/ntb/baseline/software/testfile/rsm/SampleFiles/FrameSet1/NITF_Files/i_6130a.zip # but hand edited to have just 1x1 imagery @@ -2016,7 +2016,7 @@ def nitf_61(): # Test creating & reading image comments -def nitf_62(): +def test_nitf_62(): # 80+1 characters comments = '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678ZA' @@ -2040,7 +2040,7 @@ def nitf_62(): # Test NITFReadImageLine() and NITFWriteImageLine() when nCols < nBlockWidth (#3551) -def nitf_63(): +def test_nitf_63(): ds = gdal.GetDriverByName('NITF').Create('tmp/nitf63.ntf', 50, 25, 3, gdal.GDT_Int16, options=['BLOCKXSIZE=256']) ds = None @@ -2082,7 +2082,7 @@ def nitf_63(): # Test SDE_TRE creation option -def nitf_64(): +def test_nitf_64(): src_ds = gdal.GetDriverByName('GTiff').Create('/vsimem/nitf_64.tif', 256, 256, 1) src_ds.SetGeoTransform([2.123456789, 0.123456789, 0, 49.123456789, 0, -0.123456789]) @@ -2142,7 +2142,7 @@ def nitf_64(): # Test creating an image with block_width = image_width > 8192 (#3922) -def nitf_65(): +def test_nitf_65(): ds = gdal.GetDriverByName('NITF').Create('/vsimem/nitf_65.ntf', 10000, 100, options=['BLOCKXSIZE=10000']) ds = None @@ -2164,7 +2164,7 @@ def nitf_65(): # Test creating an image with block_height = image_height > 8192 (#3922) -def nitf_66(): +def test_nitf_66(): ds = gdal.GetDriverByName('NITF').Create('/vsimem/nitf_66.ntf', 100, 10000, options=['BLOCKYSIZE=10000', 'BLOCKXSIZE=50']) ds = None @@ -2186,7 +2186,7 @@ def nitf_66(): # Test that we don't use scanline access in illegal cases (#3926) -def nitf_67(): +def test_nitf_67(): src_ds = gdal.Open('data/byte.tif') gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -2212,7 +2212,7 @@ def nitf_67(): # Test reading NITF_METADATA domain -def nitf_68(): +def test_nitf_68(): ds = gdal.Open('data/rgb.ntf') if len(ds.GetMetadata('NITF_METADATA')) != 2: @@ -2232,7 +2232,7 @@ def nitf_68(): # Test SetGCPs() support -def nitf_69(): +def test_nitf_69(): vrt_txt = """ @@ -2311,7 +2311,7 @@ def nitf_69(): # Create and read a JPEG encoded NITF file with NITF dimensions != JPEG dimensions -def nitf_70(): +def test_nitf_70(): src_ds = gdal.Open('data/rgbsmall.tif') @@ -2347,7 +2347,7 @@ def nitf_70(): # Test reading ENGRDA TRE (#6285) -def nitf_71(): +def test_nitf_71(): ds = gdal.GetDriverByName('NITF').Create('/vsimem/nitf_71.ntf', 1, 1, options=['TRE=ENGRDA=0123456789012345678900210012345678901230123X01200000002XY01X01230123X01200000001X']) ds = None @@ -2424,7 +2424,7 @@ def compare_rpc(src_md, md): return 'success' -def nitf_72(): +def test_nitf_72(): src_ds = gdal.GetDriverByName('MEM').Create('', 1, 1) # Use full precision @@ -2740,7 +2740,7 @@ def nitf_72(): # Test case for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1525 -def nitf_73(): +def test_nitf_73(): with gdaltest.error_handler(): gdal.Open('data/oss_fuzz_1525.ntf') @@ -2752,7 +2752,7 @@ def nitf_73(): # - Simple case -def nitf_74(): +def test_nitf_74(): ds = gdal.GetDriverByName('NITF').Create('/vsimem/nitf_74.ntf', 1, 1, options=['FILE_TRE=CCINFA=0012AS 17ge:GENC:3:3-5:AUS00000']) ds = None @@ -2788,7 +2788,7 @@ def nitf_74(): # - TABLE AG.2 case -def nitf_75(): +def test_nitf_75(): listing_AG1 = """ @@ -643,7 +643,7 @@ def sentinel2_l1c_7(): # Test opening a L1C tile -def sentinel2_l1c_tile_1(): +def test_sentinel2_l1c_tile_1(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml' gdal.ErrorReset() @@ -732,7 +732,7 @@ def sentinel2_l1c_tile_1(): # Test opening a L1C tile without main MTD file -def sentinel2_l1c_tile_2(): +def test_sentinel2_l1c_tile_2(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml' gdal.ErrorReset() @@ -777,7 +777,7 @@ def sentinel2_l1c_tile_2(): # Test opening a L1C tile subdataset on the 10m bands -def sentinel2_l1c_tile_3(): +def test_sentinel2_l1c_tile_3(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml' gdal.ErrorReset() @@ -914,7 +914,7 @@ def sentinel2_l1c_tile_3(): # Test opening a L1C tile subdataset on the 10m bands without main MTD file -def sentinel2_l1c_tile_4(): +def test_sentinel2_l1c_tile_4(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml' gdal.ErrorReset() @@ -1012,7 +1012,7 @@ def sentinel2_l1c_tile_4(): # Test opening a L1C tile subdataset on the preview bands -def sentinel2_l1c_tile_5(): +def test_sentinel2_l1c_tile_5(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml' gdal.ErrorReset() @@ -1060,7 +1060,7 @@ def sentinel2_l1c_tile_5(): # Test opening invalid XML files -def sentinel2_l1c_tile_6(): +def test_sentinel2_l1c_tile_6(): # Invalid XML gdal.FileFromMemBuffer('/vsimem/test.xml', @@ -1122,7 +1122,7 @@ def sentinel2_l1c_tile_6(): # Test opening a L1B product -def sentinel2_l1b_1(): +def test_sentinel2_l1b_1(): filename_xml = 'data/fake_sentinel2_l1b/S2B_OPER_PRD_MSIL1B.SAFE/S2B_OPER_MTD_SAFL1B.xml' gdal.ErrorReset() @@ -1204,7 +1204,7 @@ def sentinel2_l1b_1(): # Test opening a L1B granule -def sentinel2_l1b_2(): +def test_sentinel2_l1b_2(): filename_xml = 'data/fake_sentinel2_l1b/S2B_OPER_PRD_MSIL1B.SAFE/GRANULE/S2B_OPER_MSI_L1B_N01.03/S2B_OPER_MTD_L1B.xml' gdal.ErrorReset() @@ -1290,7 +1290,7 @@ def sentinel2_l1b_2(): # Test opening a L1B subdataset -def sentinel2_l1b_3(): +def test_sentinel2_l1b_3(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L1B:data/fake_sentinel2_l1b/S2B_OPER_PRD_MSIL1B.SAFE/GRANULE/S2B_OPER_MSI_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m') @@ -1448,7 +1448,7 @@ def sentinel2_l1b_3(): # Test opening a L1B granule (with missing tile, without any ../../main_mtd.xml) -def sentinel2_l1b_4(): +def test_sentinel2_l1b_4(): gdal.FileFromMemBuffer('/vsimem/foo/S2B_PROD_MTD_foo.xml', """ @@ -1560,7 +1560,7 @@ def sentinel2_l1b_4(): # Test opening invalid XML files -def sentinel2_l1b_5(): +def test_sentinel2_l1b_5(): # Invalid XML gdal.FileFromMemBuffer('/vsimem/test.xml', @@ -1755,7 +1755,7 @@ def sentinel2_l1b_5(): # Test opening a L2A product -def sentinel2_l2a_1(): +def test_sentinel2_l2a_1(): filename_xml = 'data/fake_sentinel2_l2a/S2A_USER_PRD_MSIL2A.SAFE/S2A_USER_MTD_SAFL2A.xml' gdal.ErrorReset() @@ -1864,7 +1864,7 @@ def sentinel2_l2a_1(): # Test opening a L21 subdataset on the 60m bands -def sentinel2_l2a_2(): +def test_sentinel2_l2a_2(): filename_xml = 'data/fake_sentinel2_l2a/S2A_USER_PRD_MSIL2A.SAFE/S2A_USER_MTD_SAFL2A.xml' gdal.ErrorReset() @@ -2033,7 +2033,7 @@ def sentinel2_l2a_2(): # Test opening invalid XML files -def sentinel2_l2a_3(): +def test_sentinel2_l2a_3(): # Invalid XML gdal.FileFromMemBuffer('/vsimem/test.xml', @@ -2113,7 +2113,7 @@ def sentinel2_l2a_3(): # Test opening a L2A MSIL2A product -def sentinel2_l2a_4(): +def test_sentinel2_l2a_4(): filename_xml = 'data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml' gdal.ErrorReset() @@ -2235,7 +2235,7 @@ def sentinel2_l2a_4(): # Test opening a L2A MSIL2A subdataset on the 60m bands -def sentinel2_l2a_5(): +def test_sentinel2_l2a_5(): filename_xml = 'data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml' gdal.ErrorReset() @@ -2362,7 +2362,7 @@ def sentinel2_l2a_5(): # Test opening a L2A MSIL2Ap product -def sentinel2_l2a_6(): +def test_sentinel2_l2a_6(): filename_xml = 'data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml' gdal.ErrorReset() @@ -2489,7 +2489,7 @@ def sentinel2_l2a_6(): # Test opening a L2A MSIL2Ap subdataset on the 60m bands -def sentinel2_l2a_7(): +def test_sentinel2_l2a_7(): filename_xml = 'data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml' gdal.ErrorReset() @@ -2622,7 +2622,7 @@ def sentinel2_l2a_7(): # Test opening a L1C Safe Compact product -def sentinel2_l1c_safe_compact_1(): +def test_sentinel2_l1c_safe_compact_1(): filename_xml = 'data/fake_sentinel2_l1c_safecompact/S2A_MSIL1C_test.SAFE/MTD_MSIL1C.xml' gdal.ErrorReset() @@ -2723,7 +2723,7 @@ def sentinel2_l1c_safe_compact_1(): # Test opening a L1C Safe Compact subdataset on the 10m bands -def sentinel2_l1c_safe_compact_2(): +def test_sentinel2_l1c_safe_compact_2(): filename_xml = 'data/fake_sentinel2_l1c_safecompact/S2A_MSIL1C_test.SAFE/MTD_MSIL1C.xml' gdal.ErrorReset() @@ -2857,7 +2857,7 @@ def sentinel2_l1c_safe_compact_2(): # Test opening a L1C subdataset on the TCI bands -def sentinel2_l1c_safe_compact_3(): +def test_sentinel2_l1c_safe_compact_3(): filename_xml = 'data/fake_sentinel2_l1c_safecompact/S2A_MSIL1C_test.SAFE/MTD_MSIL1C.xml' ds = gdal.OpenEx('SENTINEL2_L1C:%s:TCI:EPSG_32632' % filename_xml) @@ -2890,34 +2890,34 @@ def sentinel2_l1c_safe_compact_3(): gdaltest_list = [ - sentinel2_l1c_1, - sentinel2_l1c_2, - sentinel2_l1c_3, - sentinel2_l1c_4, - sentinel2_l1c_5, - sentinel2_l1c_6, - sentinel2_l1c_7, - sentinel2_l1c_tile_1, - sentinel2_l1c_tile_2, - sentinel2_l1c_tile_3, - sentinel2_l1c_tile_4, - sentinel2_l1c_tile_5, - sentinel2_l1c_tile_6, - sentinel2_l1b_1, - sentinel2_l1b_2, - sentinel2_l1b_3, - sentinel2_l1b_4, - sentinel2_l1b_5, - sentinel2_l2a_1, - sentinel2_l2a_2, - sentinel2_l2a_3, - sentinel2_l2a_4, - sentinel2_l2a_5, - sentinel2_l2a_6, - sentinel2_l2a_7, - sentinel2_l1c_safe_compact_1, - sentinel2_l1c_safe_compact_2, - sentinel2_l1c_safe_compact_3 + test_sentinel2_l1c_1, + test_sentinel2_l1c_2, + test_sentinel2_l1c_3, + test_sentinel2_l1c_4, + test_sentinel2_l1c_5, + test_sentinel2_l1c_6, + test_sentinel2_l1c_7, + test_sentinel2_l1c_tile_1, + test_sentinel2_l1c_tile_2, + test_sentinel2_l1c_tile_3, + test_sentinel2_l1c_tile_4, + test_sentinel2_l1c_tile_5, + test_sentinel2_l1c_tile_6, + test_sentinel2_l1b_1, + test_sentinel2_l1b_2, + test_sentinel2_l1b_3, + test_sentinel2_l1b_4, + test_sentinel2_l1b_5, + test_sentinel2_l2a_1, + test_sentinel2_l2a_2, + test_sentinel2_l2a_3, + test_sentinel2_l2a_4, + test_sentinel2_l2a_5, + test_sentinel2_l2a_6, + test_sentinel2_l2a_7, + test_sentinel2_l1c_safe_compact_1, + test_sentinel2_l1c_safe_compact_2, + test_sentinel2_l1c_safe_compact_3 ] if __name__ == '__main__': diff --git a/autotest/gdrivers/sgi.py b/autotest/gdrivers/sgi.py index ccdb45fcf40b..fa58c02f93e7 100755 --- a/autotest/gdrivers/sgi.py +++ b/autotest/gdrivers/sgi.py @@ -37,7 +37,7 @@ # Read existing simple 1 band SGI file. -def sgi_1(): +def test_sgi_1(): tst = gdaltest.GDALTest('SGI', 'byte.sgi', 1, 4672) @@ -47,7 +47,7 @@ def sgi_1(): # Write Test grayscale -def sgi_2(): +def test_sgi_2(): tst = gdaltest.GDALTest('SGI', 'byte.tif', 1, 4672) @@ -57,7 +57,7 @@ def sgi_2(): # Write Test rgb -def sgi_3(): +def test_sgi_3(): tst = gdaltest.GDALTest('SGI', 'rgbsmall.tif', 2, 21053) @@ -65,9 +65,9 @@ def sgi_3(): gdaltest_list = [ - sgi_1, - sgi_2, - sgi_3, + test_sgi_1, + test_sgi_2, + test_sgi_3, ] diff --git a/autotest/gdrivers/sigdem.py b/autotest/gdrivers/sigdem.py index b3cac67a20d2..2f8ecc40bc7f 100755 --- a/autotest/gdrivers/sigdem.py +++ b/autotest/gdrivers/sigdem.py @@ -38,7 +38,7 @@ # Create simple copy and check. -def sigdem_copy_check_prj(): +def test_sigdem_copy_check_prj(): tst = gdaltest.GDALTest('SIGDEM', 'byte.tif', 1, 4672) @@ -49,7 +49,7 @@ def sigdem_copy_check_prj(): ############################################################################### # Verify writing files with non-square pixels. -def sigdem_non_square(): +def test_sigdem_non_square(): tst = gdaltest.GDALTest('SIGDEM', 'nonsquare_nad27_utm11.vrt', 1, 12481) @@ -60,7 +60,7 @@ def sigdem_non_square(): ############################################################################### # Test creating an in memory copy. -def sigdem_in_memory(): +def test_sigdem_in_memory(): tst = gdaltest.GDALTest('SIGDEM', 'byte.tif', 1, 4672) @@ -71,9 +71,9 @@ def sigdem_in_memory(): gdaltest_list = [ - sigdem_copy_check_prj, - sigdem_non_square, - sigdem_in_memory + test_sigdem_copy_check_prj, + test_sigdem_non_square, + test_sigdem_in_memory ] if __name__ == '__main__': diff --git a/autotest/gdrivers/snodas.py b/autotest/gdrivers/snodas.py index 2a0d3b68c753..f86916f5450f 100755 --- a/autotest/gdrivers/snodas.py +++ b/autotest/gdrivers/snodas.py @@ -38,7 +38,7 @@ # Test a fake SNODAS dataset -def snodas_1(): +def test_snodas_1(): tst = gdaltest.GDALTest('SNODAS', 'fake_snodas.hdr', 1, 0) expected_gt = [-124.733749999995, 0.0083333333333330643, 0.0, 52.874583333331302, 0.0, -0.0083333333333330054] @@ -72,7 +72,7 @@ def snodas_1(): gdaltest_list = [ - snodas_1] + test_snodas_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/srp.py b/autotest/gdrivers/srp.py index dabb996f103d..e0b94cb2297a 100755 --- a/autotest/gdrivers/srp.py +++ b/autotest/gdrivers/srp.py @@ -41,7 +41,7 @@ # Read USRP dataset with PCB=0 -def srp_1(filename='USRP_PCB0/FKUSRP01.IMG'): +def test_srp_1(filename='USRP_PCB0/FKUSRP01.IMG'): srs = osr.SpatialReference() srs.ImportFromEPSG(32600 + 17) @@ -94,21 +94,21 @@ def srp_1(filename='USRP_PCB0/FKUSRP01.IMG'): # Read USRP dataset with PCB=4 -def srp_2(): - return srp_1('USRP_PCB4/FKUSRP01.IMG') +def test_srp_2(): + return test_srp_1('USRP_PCB4/FKUSRP01.IMG') ############################################################################### # Read USRP dataset with PCB=8 -def srp_3(): - return srp_1('USRP_PCB8/FKUSRP01.IMG') +def test_srp_3(): + return test_srp_1('USRP_PCB8/FKUSRP01.IMG') ############################################################################### # Read from TRANSH01.THF file. -def srp_4(): +def test_srp_4(): tst = gdaltest.GDALTest('SRP', 'USRP_PCB0/TRANSH01.THF', 1, 24576) ret = tst.testOpen() @@ -118,7 +118,7 @@ def srp_4(): # Read from TRANSH01.THF file (without "optimization" for single GEN in THF) -def srp_5(): +def test_srp_5(): gdal.SetConfigOption('SRP_SINGLE_GEN_IN_THF_AS_DATASET', 'FALSE') ds = gdal.Open('data/USRP_PCB0/TRANSH01.THF') @@ -154,7 +154,7 @@ def srp_5(): # Read with subdataset syntax -def srp_6(): +def test_srp_6(): tst = gdaltest.GDALTest('SRP', 'SRP:data/USRP_PCB4/FKUSRP01.GEN,data/USRP_PCB4/FKUSRP01.IMG', 1, 24576, filename_absolute=1) return tst.testOpen() @@ -163,7 +163,7 @@ def srp_6(): ############################################################################### # Cleanup -def srp_cleanup(): +def test_srp_cleanup(): # FIXME ? os.unlink('data/USRP_PCB0/TRANSH01.THF.aux.xml') @@ -173,13 +173,13 @@ def srp_cleanup(): gdaltest_list = [ - srp_1, - srp_2, - srp_3, - srp_4, - srp_5, - srp_6, - srp_cleanup + test_srp_1, + test_srp_2, + test_srp_3, + test_srp_4, + test_srp_5, + test_srp_6, + test_srp_cleanup ] if __name__ == '__main__': diff --git a/autotest/gdrivers/srtmhgt.py b/autotest/gdrivers/srtmhgt.py index f858358c298b..1042ff145e8d 100755 --- a/autotest/gdrivers/srtmhgt.py +++ b/autotest/gdrivers/srtmhgt.py @@ -40,7 +40,7 @@ ############################################################################### # Test a SRTMHGT Level 1 (made from a DTED Level 0) -def srtmhgt_1(): +def test_srtmhgt_1(): ds = gdal.Open('data/n43.dt0') @@ -79,7 +79,7 @@ def srtmhgt_1(): ############################################################################### # Test creating an in memory copy. -def srtmhgt_2(): +def test_srtmhgt_2(): ds = gdal.Open('tmp/n43w080.hgt') driver = gdal.GetDriverByName("SRTMHGT") @@ -110,7 +110,7 @@ def srtmhgt_2(): # Test reading from a .hgt.zip file -def srtmhgt_3(): +def test_srtmhgt_3(): ds = gdal.Open('tmp/n43w080.hgt') driver = gdal.GetDriverByName("SRTMHGT") @@ -131,7 +131,7 @@ def srtmhgt_3(): # Test reading from a .SRTMSWBD.raw.zip file (GRASS #3246) -def srtmhgt_4(): +def test_srtmhgt_4(): f = gdal.VSIFOpenL('/vsizip//vsimem/N43W080.SRTMSWBD.raw.zip/N43W080.raw', 'wb') if f is None: @@ -157,7 +157,7 @@ def srtmhgt_4(): # Cleanup. -def srtmhgt_cleanup(): +def test_srtmhgt_cleanup(): try: gdal.GetDriverByName("SRTMHGT").Delete('tmp/n43w080.hgt') gdal.GetDriverByName("SRTMHGT").Delete('/vsimem/n43w080.hgt') @@ -169,11 +169,11 @@ def srtmhgt_cleanup(): gdaltest_list = [ - srtmhgt_1, - srtmhgt_2, - srtmhgt_3, - srtmhgt_4, - srtmhgt_cleanup + test_srtmhgt_1, + test_srtmhgt_2, + test_srtmhgt_3, + test_srtmhgt_4, + test_srtmhgt_cleanup ] diff --git a/autotest/gdrivers/terragen.py b/autotest/gdrivers/terragen.py index 5133f5126335..d2c737735730 100755 --- a/autotest/gdrivers/terragen.py +++ b/autotest/gdrivers/terragen.py @@ -36,7 +36,7 @@ ############################################################################### -def terragen_1(): +def test_terragen_1(): tst = gdaltest.GDALTest('terragen', 'float32.ter', 1, 1128) @@ -46,7 +46,7 @@ def terragen_1(): # Write -def terragen_2(): +def test_terragen_2(): gdal.Translate('/vsimem/out.ter', 'data/float32.tif', options='-of TERRAGEN -co MINUSERPIXELVALUE=74 -co MAXUSERPIXELVALUE=255') gdal.Translate('/vsimem/out.tif', '/vsimem/out.ter', options='-unscale') @@ -60,8 +60,8 @@ def terragen_2(): gdaltest_list = [ - terragen_1, - terragen_2 + test_terragen_1, + test_terragen_2 ] diff --git a/autotest/gdrivers/tiff_profile.py b/autotest/gdrivers/tiff_profile.py index 8279108ce530..983aed76ffcd 100755 --- a/autotest/gdrivers/tiff_profile.py +++ b/autotest/gdrivers/tiff_profile.py @@ -42,7 +42,7 @@ ############################################################################### # Test writing and reading of ICC profile in Create() options -def tiff_write_icc(): +def test_tiff_write_icc(): f = open('data/sRGB.icc', 'rb') data = f.read() @@ -110,7 +110,7 @@ def tiff_write_icc(): # Test writing and reading of ICC profile in CreateCopy() -def tiff_copy_icc(): +def test_tiff_copy_icc(): f = open('data/sRGB.icc', 'rb') data = f.read() @@ -152,7 +152,7 @@ def tiff_copy_icc(): # Test writing and reading of ICC profile in CreateCopy() options -def tiff_copy_options_icc(): +def test_tiff_copy_options_icc(): f = open('data/sRGB.icc', 'rb') data = f.read() @@ -198,7 +198,7 @@ def cvtTuple2String(t): # Test writing and reading of ICC colorimetric data from options -def tiff_copy_options_colorimetric_data(): +def test_tiff_copy_options_colorimetric_data(): # sRGB values source_primaries = [(0.64, 0.33, 1.0), (0.3, 0.6, 1.0), (0.15, 0.06, 1.0)] source_whitepoint = (0.31271, 0.32902, 1.0) @@ -290,7 +290,7 @@ def tiff_copy_options_colorimetric_data(): # Test writing and reading of ICC colorimetric data in the file -def tiff_copy_colorimetric_data(): +def test_tiff_copy_colorimetric_data(): # sRGB values source_primaries = [(0.64, 0.33, 1.0), (0.3, 0.6, 1.0), (0.15, 0.06, 1.0)] source_whitepoint = (0.31271, 0.32902, 1.0) @@ -385,7 +385,7 @@ def tiff_copy_colorimetric_data(): # Test updating ICC profile -def tiff_update_icc(): +def test_tiff_update_icc(): f = open('data/sRGB.icc', 'rb') data = f.read() @@ -426,7 +426,7 @@ def tiff_update_icc(): # Test updating colorimetric options -def tiff_update_colorimetric(): +def test_tiff_update_colorimetric(): source_primaries = [(0.234, 0.555, 1.0), (0.2, 0, 1), (2, 3.5, 1)] source_whitepoint = (0.31271, 0.32902, 1.0) tifftag_transferfunction = (list(range(1, 256 * 4, 4)), list(range(2, 256 * 4 + 1, 4)), list(range(3, 256 * 4 + 2, 4))) @@ -515,13 +515,13 @@ def tiff_update_colorimetric(): gdaltest_list = [ - tiff_write_icc, - tiff_copy_icc, - tiff_copy_options_icc, - tiff_copy_options_colorimetric_data, - tiff_copy_colorimetric_data, - tiff_update_icc, - tiff_update_colorimetric, + test_tiff_write_icc, + test_tiff_copy_icc, + test_tiff_copy_options_icc, + test_tiff_copy_options_colorimetric_data, + test_tiff_copy_colorimetric_data, + test_tiff_update_icc, + test_tiff_update_colorimetric, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/til.py b/autotest/gdrivers/til.py index 9c0be4774454..549863473f71 100755 --- a/autotest/gdrivers/til.py +++ b/autotest/gdrivers/til.py @@ -39,7 +39,7 @@ # Test a fake TIL dataset -def til_1(): +def test_til_1(): tst = gdaltest.GDALTest('TIL', 'testtil.til', 1, 4672) return tst.testOpen() @@ -48,7 +48,7 @@ def til_1(): # Check GetFileList() result (#4018) & IMD -def til_2(): +def test_til_2(): try: os.remove('data/testtil.til.aux.xml') @@ -88,7 +88,7 @@ def til_2(): # Check GetFileList() & XML -def til_3(): +def test_til_3(): try: os.remove('data/testtil.til.aux.xml') @@ -126,9 +126,9 @@ def til_3(): gdaltest_list = [ - til_1, - til_2, - til_3] + test_til_1, + test_til_2, + test_til_3] if __name__ == '__main__': diff --git a/autotest/gdrivers/usgsdem.py b/autotest/gdrivers/usgsdem.py index 988fb715b0ca..b95cf3317e71 100755 --- a/autotest/gdrivers/usgsdem.py +++ b/autotest/gdrivers/usgsdem.py @@ -40,7 +40,7 @@ # Test truncated version of http://download.osgeo.org/gdal/data/usgsdem/022gdeme -def usgsdem_1(): +def test_usgsdem_1(): tst = gdaltest.GDALTest('USGSDEM', '022gdeme_truncated', 1, 1583) srs = osr.SpatialReference() @@ -52,7 +52,7 @@ def usgsdem_1(): # Test truncated version of http://download.osgeo.org/gdal/data/usgsdem/114p01_0100_deme.dem -def usgsdem_2(): +def test_usgsdem_2(): tst = gdaltest.GDALTest('USGSDEM', '114p01_0100_deme_truncated.dem', 1, 53864) srs = osr.SpatialReference() @@ -64,7 +64,7 @@ def usgsdem_2(): # Test truncated version of file that triggered bug #2348 -def usgsdem_3(): +def test_usgsdem_3(): tst = gdaltest.GDALTest('USGSDEM', '39079G6_truncated.dem', 1, 61424) srs = osr.SpatialReference() @@ -77,7 +77,7 @@ def usgsdem_3(): # Test CreateCopy() -def usgsdem_4(): +def test_usgsdem_4(): tst = gdaltest.GDALTest('USGSDEM', '39079G6_truncated.dem', 1, 61424, options=['RESAMPLE=Nearest']) @@ -87,7 +87,7 @@ def usgsdem_4(): ############################################################################### # Test CreateCopy() without any creation options -def usgsdem_5(): +def test_usgsdem_5(): ds = gdal.Open('data/n43.dt0') ds2 = gdal.GetDriverByName('USGSDEM').CreateCopy('tmp/n43.dem', ds, @@ -126,7 +126,7 @@ def usgsdem_5(): # creation option and check that both files are binary identical. -def usgsdem_6(): +def test_usgsdem_6(): ds = gdal.Open('data/n43.dt0') ds2 = gdal.GetDriverByName('USGSDEM').CreateCopy('tmp/file_1.dem', ds, @@ -161,7 +161,7 @@ def usgsdem_6(): # Test CreateCopy() with CDED50K profile -def usgsdem_7(): +def test_usgsdem_7(): ds = gdal.Open('data/n43.dt0') @@ -202,7 +202,7 @@ def usgsdem_7(): # Undocumented format -def usgsdem_8(): +def test_usgsdem_8(): tst = gdaltest.GDALTest('USGSDEM', '39109h1_truncated.dem', 1, 39443) srs = osr.SpatialReference() @@ -216,7 +216,7 @@ def usgsdem_8(): # Old format -def usgsdem_9(): +def test_usgsdem_9(): tst = gdaltest.GDALTest('USGSDEM', '4619old_truncated.dem', 1, 10659) srs = osr.SpatialReference() @@ -228,7 +228,7 @@ def usgsdem_9(): # https://github.com/OSGeo/gdal/issues/583 -def usgsdem_with_extra_values_at_end_of_profile(): +def test_usgsdem_with_extra_values_at_end_of_profile(): tst = gdaltest.GDALTest('USGSDEM', 'usgsdem_with_extra_values_at_end_of_profile.dem', 1, 56679) return tst.testOpen() @@ -237,7 +237,7 @@ def usgsdem_with_extra_values_at_end_of_profile(): # Like Novato.dem of https://trac.osgeo.org/gdal/ticket/4901 -def usgsdem_with_spaces_after_byte_864(): +def test_usgsdem_with_spaces_after_byte_864(): tst = gdaltest.GDALTest('USGSDEM', 'usgsdem_with_spaces_after_byte_864.dem', 1, 61078) return tst.testOpen() @@ -246,7 +246,7 @@ def usgsdem_with_spaces_after_byte_864(): # Cleanup -def usgsdem_cleanup(): +def test_usgsdem_cleanup(): try: os.remove('tmp/n43.dem') @@ -266,18 +266,18 @@ def usgsdem_cleanup(): gdaltest_list = [ - usgsdem_1, - usgsdem_2, - usgsdem_3, - usgsdem_4, - usgsdem_5, - usgsdem_6, - usgsdem_7, - usgsdem_8, - usgsdem_9, - usgsdem_with_extra_values_at_end_of_profile, - usgsdem_with_spaces_after_byte_864, - usgsdem_cleanup] + test_usgsdem_1, + test_usgsdem_2, + test_usgsdem_3, + test_usgsdem_4, + test_usgsdem_5, + test_usgsdem_6, + test_usgsdem_7, + test_usgsdem_8, + test_usgsdem_9, + test_usgsdem_with_extra_values_at_end_of_profile, + test_usgsdem_with_spaces_after_byte_864, + test_usgsdem_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/vicar.py b/autotest/gdrivers/vicar.py index 103134941074..cc7fc73027c2 100755 --- a/autotest/gdrivers/vicar.py +++ b/autotest/gdrivers/vicar.py @@ -39,7 +39,7 @@ # Read truncated VICAR file -def vicar_1(): +def test_vicar_1(): tst = gdaltest.GDALTest('VICAR', 'test_vicar_truncated.bin', 1, 0) expected_prj = """PROJCS["SINUSOIDAL MARS", @@ -97,7 +97,7 @@ def vicar_1(): gdaltest_list = [ - vicar_1] + test_vicar_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtderived.py b/autotest/gdrivers/vrtderived.py index 37228a4b5a12..c0918c6e8636 100755 --- a/autotest/gdrivers/vrtderived.py +++ b/autotest/gdrivers/vrtderived.py @@ -48,7 +48,7 @@ def _xmlsearch(root, nodetype, name): # Verify raster band subClass -def vrtderived_1(): +def test_vrtderived_1(): filename = 'tmp/derived.vrt' vrt_ds = gdal.GetDriverByName('VRT').Create(filename, 50, 50, 0) @@ -98,7 +98,7 @@ def vrtderived_1(): # Verify derived raster band pixel function type -def vrtderived_2(): +def test_vrtderived_2(): filename = 'tmp/derived.vrt' vrt_ds = gdal.GetDriverByName('VRT').Create(filename, 50, 50, 0) @@ -152,7 +152,7 @@ def vrtderived_2(): # Verify derived raster band transfer type -def vrtderived_3(): +def test_vrtderived_3(): filename = 'tmp/derived.vrt' vrt_ds = gdal.GetDriverByName('VRT').Create(filename, 50, 50, 0) @@ -191,7 +191,7 @@ def vrtderived_3(): # Check handling of invalid derived raster band transfer type -def vrtderived_4(): +def test_vrtderived_4(): filename = 'tmp/derived.vrt' vrt_ds = gdal.GetDriverByName('VRT').Create(filename, 50, 50, 0) @@ -213,7 +213,7 @@ def vrtderived_4(): # Check Python derived function with BufferRadius=1 -def vrtderived_5(): +def test_vrtderived_5(): try: import numpy @@ -236,7 +236,7 @@ def vrtderived_5(): # Check Python derived function with BufferRadius=0 and no source -def vrtderived_6(): +def test_vrtderived_6(): try: import numpy @@ -259,7 +259,7 @@ def vrtderived_6(): # Check Python derived function with no started Python interpreter -def vrtderived_7(): +def test_vrtderived_7(): import test_cli_utilities if test_cli_utilities.get_gdalinfo_path() is None: @@ -329,7 +329,7 @@ def vrtderived_7(): # Check that GDAL_VRT_ENABLE_PYTHON=NO or undefined is honored -def vrtderived_8(): +def test_vrtderived_8(): try: import numpy @@ -361,7 +361,7 @@ def vrtderived_8(): # Check various failure modes with Python functions -def vrtderived_9(): +def test_vrtderived_9(): try: import numpy @@ -681,7 +681,7 @@ def one_pix_func(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_y out_ar.fill(1) -def vrtderived_10(): +def test_vrtderived_10(): try: import numpy @@ -757,7 +757,7 @@ def vrtderived_10(): # Test serializing with python code -def vrtderived_11(): +def test_vrtderived_11(): try: import numpy @@ -790,7 +790,7 @@ def vrtderived_11(): # Test all data types with python code -def vrtderived_12(): +def test_vrtderived_12(): try: import numpy @@ -853,7 +853,7 @@ def vrtderived_12(): # Test translating a Python derived VRT -def vrtderived_13(): +def test_vrtderived_13(): try: import numpy @@ -880,7 +880,7 @@ def vrtderived_13(): # Test statistics functions -def vrtderived_14(): +def test_vrtderived_14(): try: import numpy @@ -938,7 +938,7 @@ def vrtderived_15_worker(args_dict): ds.FlushCache() -def vrtderived_15(): +def test_vrtderived_15(): try: import numpy @@ -971,7 +971,7 @@ def vrtderived_15(): ############################################################################### # Cleanup. -def vrtderived_cleanup(): +def test_vrtderived_cleanup(): try: os.remove('tmp/derived.vrt') except OSError: @@ -980,22 +980,22 @@ def vrtderived_cleanup(): gdaltest_list = [ - vrtderived_1, - vrtderived_2, - vrtderived_3, - vrtderived_4, - vrtderived_5, - vrtderived_6, - vrtderived_7, - vrtderived_8, - vrtderived_9, - vrtderived_10, - vrtderived_11, - vrtderived_12, - vrtderived_13, - vrtderived_14, - vrtderived_15, - vrtderived_cleanup, + test_vrtderived_1, + test_vrtderived_2, + test_vrtderived_3, + test_vrtderived_4, + test_vrtderived_5, + test_vrtderived_6, + test_vrtderived_7, + test_vrtderived_8, + test_vrtderived_9, + test_vrtderived_10, + test_vrtderived_11, + test_vrtderived_12, + test_vrtderived_13, + test_vrtderived_14, + test_vrtderived_15, + test_vrtderived_cleanup, ] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtfilt.py b/autotest/gdrivers/vrtfilt.py index bfe86d07f35c..5231015bd481 100755 --- a/autotest/gdrivers/vrtfilt.py +++ b/autotest/gdrivers/vrtfilt.py @@ -39,7 +39,7 @@ # Verify simple 3x3 averaging filter. -def vrtfilt_1(): +def test_vrtfilt_1(): tst = gdaltest.GDALTest('VRT', 'avfilt.vrt', 1, 21890) return tst.testOpen() @@ -48,7 +48,7 @@ def vrtfilt_1(): # Verify simple 3x3 averaging filter (normalized) on a dataset with nodata -def vrtfilt_2(): +def test_vrtfilt_2(): ds = gdal.Open('data/test_vrt_filter_nodata.tif') checksum = ds.GetRasterBand(1).Checksum() @@ -64,7 +64,7 @@ def vrtfilt_2(): # Same result expected as for vrtfilt_1 -def vrtfilt_3(): +def test_vrtfilt_3(): ds = gdal.OpenShared('data/rgbsmall.tif') vrt_ds = gdal.GetDriverByName('VRT').CreateCopy('', ds) @@ -96,7 +96,7 @@ def vrtfilt_3(): # Variant for SetMetadataItem('source_0', xml, 'vrt_sources') -def vrtfilt_4(): +def test_vrtfilt_4(): vrt_ds = gdal.GetDriverByName('VRT').Create('', 50, 50, 1) @@ -126,7 +126,7 @@ def vrtfilt_4(): # Variant for SetMetadata(md, 'vrt_sources') -def vrtfilt_5(): +def test_vrtfilt_5(): vrt_ds = gdal.GetDriverByName('VRT').Create('', 50, 50, 1) @@ -154,7 +154,7 @@ def vrtfilt_5(): # Verify separable Gaussian blur filter. -def vrtfilt_6(): +def test_vrtfilt_6(): tst = gdaltest.GDALTest('VRT', 'avfilt_1d.vrt', 1, 22377) return tst.testOpen() @@ -163,18 +163,18 @@ def vrtfilt_6(): # Cleanup. -def vrtfilt_cleanup(): +def test_vrtfilt_cleanup(): return 'success' gdaltest_list = [ - vrtfilt_1, - vrtfilt_2, - vrtfilt_3, - vrtfilt_4, - vrtfilt_5, - vrtfilt_6, - vrtfilt_cleanup] + test_vrtfilt_1, + test_vrtfilt_2, + test_vrtfilt_3, + test_vrtfilt_4, + test_vrtfilt_5, + test_vrtfilt_6, + test_vrtfilt_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtlut.py b/autotest/gdrivers/vrtlut.py index b135a89de082..269505fa6524 100755 --- a/autotest/gdrivers/vrtlut.py +++ b/autotest/gdrivers/vrtlut.py @@ -37,7 +37,7 @@ # Simple test -def vrtlut_1(): +def test_vrtlut_1(): tst = gdaltest.GDALTest('VRT', 'byte_lut.vrt', 1, 4655) return tst.testOpen() @@ -46,13 +46,13 @@ def vrtlut_1(): ############################################################################### # Cleanup. -def vrtlut_cleanup(): +def test_vrtlut_cleanup(): return 'success' gdaltest_list = [ - vrtlut_1, - vrtlut_cleanup] + test_vrtlut_1, + test_vrtlut_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtmask.py b/autotest/gdrivers/vrtmask.py index b1134a131584..3187043fd0ac 100755 --- a/autotest/gdrivers/vrtmask.py +++ b/autotest/gdrivers/vrtmask.py @@ -40,7 +40,7 @@ # Test with a global dataset mask band -def vrtmask_1(): +def test_vrtmask_1(): vrt_string = """ @@ -86,7 +86,7 @@ def vrtmask_1(): ############################################################################### # Test with a per band mask band -def vrtmask_2(): +def test_vrtmask_2(): vrt_string = """ @@ -132,7 +132,7 @@ def vrtmask_2(): # Translate a RGB dataset with a mask into a VRT -def vrtmask_3(): +def test_vrtmask_3(): gtiff_drv = gdal.GetDriverByName('GTiff') md = gtiff_drv.GetMetadata() @@ -167,7 +167,7 @@ def vrtmask_3(): # Same with gdalbuildvrt -def vrtmask_4(): +def test_vrtmask_4(): import test_cli_utilities if test_cli_utilities.get_gdalbuildvrt_path() is None: return 'skip' @@ -201,7 +201,7 @@ def vrtmask_4(): # Same with gdal_translate -def vrtmask_5(): +def test_vrtmask_5(): gtiff_drv = gdal.GetDriverByName('GTiff') md = gtiff_drv.GetMetadata() @@ -232,7 +232,7 @@ def vrtmask_5(): # Same with gdal_translate with explicit -b and -mask arguments -def vrtmask_6(): +def test_vrtmask_6(): gtiff_drv = gdal.GetDriverByName('GTiff') md = gtiff_drv.GetMetadata() @@ -264,7 +264,7 @@ def vrtmask_6(): # gdal_translate with RGBmask -> RGBA and then RGBA->RGBmask -def vrtmask_7(): +def test_vrtmask_7(): gtiff_drv = gdal.GetDriverByName('GTiff') md = gtiff_drv.GetMetadata() @@ -321,7 +321,7 @@ def vrtmask_7(): # gdal_translate with RGBmask -> RGB -def vrtmask_8(): +def test_vrtmask_8(): gtiff_drv = gdal.GetDriverByName('GTiff') md = gtiff_drv.GetMetadata() @@ -347,7 +347,7 @@ def vrtmask_8(): # gdal_translate with RGBA -> RGB -def vrtmask_9(): +def test_vrtmask_9(): import test_cli_utilities if test_cli_utilities.get_gdal_translate_path() is None: return 'skip' @@ -378,7 +378,7 @@ def vrtmask_9(): # Test fix for #5120 (VRTSourcedRasterBand::AddMaskBandSource() ignores specified window) -def vrtmask_10(): +def test_vrtmask_10(): gdal.Translate('tmp/vrtmask_10_ref.tif', '../gcore/data/stefan_full_rgba.tif', options='-srcwin 40 40 100 100') gdal.Translate('tmp/vrtmask_10.vrt', '../gcore/data/stefan_full_rgba.tif', options='-of VRT -b 1 -b 2 -b 3 -mask 4 -srcwin 30 30 120 120') @@ -405,7 +405,7 @@ def vrtmask_10(): ############################################################################### -def vrtmask_11(): +def test_vrtmask_11(): # Cannot create mask band at raster band level when a dataset mask band already exists ds = gdal.Translate('', 'data/byte.tif', format='VRT') @@ -446,23 +446,23 @@ def vrtmask_11(): # Cleanup. -def vrtmask_cleanup(): +def test_vrtmask_cleanup(): return 'success' gdaltest_list = [ - vrtmask_1, - vrtmask_2, - vrtmask_3, - vrtmask_4, - vrtmask_5, - vrtmask_6, - vrtmask_7, - vrtmask_8, - vrtmask_9, - vrtmask_10, - vrtmask_11, - vrtmask_cleanup] + test_vrtmask_1, + test_vrtmask_2, + test_vrtmask_3, + test_vrtmask_4, + test_vrtmask_5, + test_vrtmask_6, + test_vrtmask_7, + test_vrtmask_8, + test_vrtmask_9, + test_vrtmask_10, + test_vrtmask_11, + test_vrtmask_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtovr.py b/autotest/gdrivers/vrtovr.py index c753ac4f4730..37fbb96e2fd6 100755 --- a/autotest/gdrivers/vrtovr.py +++ b/autotest/gdrivers/vrtovr.py @@ -38,7 +38,7 @@ # Simple test -def vrtovr_1(): +def test_vrtovr_1(): vrt_string = """ @@ -83,7 +83,7 @@ def vrtovr_1(): # Test serialization -def vrtovr_2(): +def test_vrtovr_2(): vrt_string = """ @@ -132,7 +132,7 @@ def vrtovr_2(): # -def vrtovr_none(): +def test_vrtovr_none(): vrt_string = """ @@ -163,7 +163,7 @@ def vrtovr_none(): # -def vrtovr_errors(): +def test_vrtovr_errors(): vrt_string = """ @@ -207,16 +207,16 @@ def vrtovr_errors(): ############################################################################### # Cleanup. -def vrtovr_cleanup(): +def test_vrtovr_cleanup(): return 'success' gdaltest_list = [ - vrtovr_1, - vrtovr_2, - vrtovr_none, - vrtovr_errors, - vrtovr_cleanup] + test_vrtovr_1, + test_vrtovr_2, + test_vrtovr_none, + test_vrtovr_errors, + test_vrtovr_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtpansharpen.py b/autotest/gdrivers/vrtpansharpen.py index 20398b25be5a..31ceb3738140 100755 --- a/autotest/gdrivers/vrtpansharpen.py +++ b/autotest/gdrivers/vrtpansharpen.py @@ -39,7 +39,7 @@ # Error cases -def vrtpansharpen_1(): +def test_vrtpansharpen_1(): src_ds = gdal.Open('data/small_world.tif') src_data = src_ds.GetRasterBand(1).ReadRaster() @@ -879,7 +879,7 @@ def vrtpansharpen_1(): # Nominal cases -def vrtpansharpen_2(): +def test_vrtpansharpen_2(): shutil.copy('data/small_world.tif', 'tmp/small_world.tif') @@ -1111,7 +1111,7 @@ def vrtpansharpen_2(): # Test with overviews -def vrtpansharpen_3(): +def test_vrtpansharpen_3(): ds = gdal.Open('tmp/small_world_pan.tif') ds.BuildOverviews('CUBIC', [2]) @@ -1199,7 +1199,7 @@ def vrtpansharpen_3(): # Test RasterIO() with various buffer datatypes -def vrtpansharpen_4(): +def test_vrtpansharpen_4(): xml = """ @@ -1244,7 +1244,7 @@ def vrtpansharpen_4(): # Test RasterIO() with various band datatypes -def vrtpansharpen_5(): +def test_vrtpansharpen_5(): for dt in [gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, gdal.GDT_UInt32, gdal.GDT_Float32, gdal.GDT_Float64, gdal.GDT_CFloat64]: @@ -1328,7 +1328,7 @@ def vrtpansharpen_5(): # Test BitDepth limitations -def vrtpansharpen_6(): +def test_vrtpansharpen_6(): try: from osgeo import gdalnumeric @@ -1417,7 +1417,7 @@ def vrtpansharpen_6(): # Test bands with different extents -def vrtpansharpen_7(): +def test_vrtpansharpen_7(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/vrtpansharpen_7_pan.tif', 20, 40) ds.SetGeoTransform([120, 1, 0, 80, 0, -1]) @@ -1595,7 +1595,7 @@ def vrtpansharpen_7(): # Test SerializeToXML() -def vrtpansharpen_8(): +def test_vrtpansharpen_8(): xml = """ @@ -1652,7 +1652,7 @@ def vrtpansharpen_8(): # Test NoData support -def vrtpansharpen_9(): +def test_vrtpansharpen_9(): # Explicit nodata vrt_ds = gdal.Open(""" @@ -1736,7 +1736,7 @@ def vrtpansharpen_9(): # Test UInt16 optimizations -def vrtpansharpen_10(): +def test_vrtpansharpen_10(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/pan.tif', 1023, 1023, 1, gdal.GDT_UInt16) ds.GetRasterBand(1).Fill(1000) @@ -1877,7 +1877,7 @@ def vrtpansharpen_10(): # Test gdal.CreatePansharpenedVRT() -def vrtpansharpen_11(): +def test_vrtpansharpen_11(): pan_ds = gdal.Open('tmp/small_world_pan.tif') ms_ds = gdal.Open('data/small_world.tif') @@ -1999,7 +1999,7 @@ def vrtpansharpen_11(): # Cleanup -def vrtpansharpen_cleanup(): +def test_vrtpansharpen_cleanup(): gdal.GetDriverByName('GTiff').Delete('tmp/small_world_pan.tif') gdal.GetDriverByName('GTiff').Delete('tmp/small_world.tif') @@ -2010,18 +2010,18 @@ def vrtpansharpen_cleanup(): gdaltest_list = [ - vrtpansharpen_1, - vrtpansharpen_2, - vrtpansharpen_3, - vrtpansharpen_4, - vrtpansharpen_5, - vrtpansharpen_6, - vrtpansharpen_7, - vrtpansharpen_8, - vrtpansharpen_9, - vrtpansharpen_10, - vrtpansharpen_11, - vrtpansharpen_cleanup, + test_vrtpansharpen_1, + test_vrtpansharpen_2, + test_vrtpansharpen_3, + test_vrtpansharpen_4, + test_vrtpansharpen_5, + test_vrtpansharpen_6, + test_vrtpansharpen_7, + test_vrtpansharpen_8, + test_vrtpansharpen_9, + test_vrtpansharpen_10, + test_vrtpansharpen_11, + test_vrtpansharpen_cleanup, ] # gdaltest_list= [ vrtpansharpen_1, vrtpansharpen_8 ] diff --git a/autotest/gdrivers/vrtrawlink.py b/autotest/gdrivers/vrtrawlink.py index e9ed17ea8d9f..fffeb6810081 100755 --- a/autotest/gdrivers/vrtrawlink.py +++ b/autotest/gdrivers/vrtrawlink.py @@ -47,7 +47,7 @@ def _xmlsearch(root, nodetype, name): # Verify reading from simple existing raw definition. -def vrtrawlink_1(): +def test_vrtrawlink_1(): tst = gdaltest.GDALTest('VRT', 'small.vrt', 2, 12816) return tst.testOpen() @@ -56,7 +56,7 @@ def vrtrawlink_1(): # Create a new VRT raw link via the AddBand() method. -def vrtrawlink_2(): +def test_vrtrawlink_2(): driver = gdal.GetDriverByName("VRT") ds = driver.Create('tmp/rawlink.vrt', 31, 35, 0) @@ -87,7 +87,7 @@ def vrtrawlink_2(): # Confirm that the newly written file is was saved properly -def vrtrawlink_3(): +def test_vrtrawlink_3(): gdaltest.rawlink_ds = gdal.Open('tmp/rawlink.vrt', gdal.GA_Update) filelist = gdaltest.rawlink_ds.GetFileList() @@ -109,7 +109,7 @@ def vrtrawlink_3(): # Add a new band, and we will test if we can write to it. -def vrtrawlink_4(): +def test_vrtrawlink_4(): # force creation of the file. open('tmp/rawlink.dat', 'w').write(chr(0)) @@ -172,7 +172,7 @@ def vrtrawlink_4(): # Add a new band, and check the relativeToVRT property. -def vrtrawlink_5(): +def test_vrtrawlink_5(): driver = gdal.GetDriverByName("VRT") ds = driver.Create('tmp/rawlink.vrt', 31, 35, 0) @@ -221,7 +221,7 @@ def vrtrawlink_5(): # Add a new band with relativeToVRT=1, and re-open the dataset. -def vrtrawlink_6(): +def test_vrtrawlink_6(): driver = gdal.GetDriverByName("VRT") ds = driver.Create('tmp/rawlink.vrt', 31, 35, 0) @@ -268,7 +268,7 @@ def vrtrawlink_6(): # Add a new band with relativeToVRT=1, change directory and re-open the dataset. -def vrtrawlink_7(): +def test_vrtrawlink_7(): driver = gdal.GetDriverByName("VRT") ds = driver.Create('tmp/rawlink.vrt', 31, 35, 0) @@ -314,7 +314,7 @@ def vrtrawlink_7(): # Test error case (too much memory allocation) -def vrtrawlink_8(): +def test_vrtrawlink_8(): for _ in range(2): with gdaltest.error_handler(): @@ -337,7 +337,7 @@ def vrtrawlink_8(): # Test error case (inexisting file) -def vrtrawlink_9(): +def test_vrtrawlink_9(): with gdaltest.error_handler(): ds = gdal.Open(""" @@ -355,7 +355,7 @@ def vrtrawlink_9(): # Test error case (invalid byte order) -def vrtrawlink_10(): +def test_vrtrawlink_10(): with gdaltest.error_handler(): ds = gdal.Open(""" @@ -374,7 +374,7 @@ def vrtrawlink_10(): # Cleanup. -def vrtrawlink_cleanup(): +def test_vrtrawlink_cleanup(): gdaltest.rawlink_ds = None try: @@ -389,17 +389,17 @@ def vrtrawlink_cleanup(): gdaltest_list = [ - vrtrawlink_1, - vrtrawlink_2, - vrtrawlink_3, - vrtrawlink_4, - vrtrawlink_5, - vrtrawlink_6, - vrtrawlink_7, - vrtrawlink_8, - vrtrawlink_9, - vrtrawlink_10, - vrtrawlink_cleanup] + test_vrtrawlink_1, + test_vrtrawlink_2, + test_vrtrawlink_3, + test_vrtrawlink_4, + test_vrtrawlink_5, + test_vrtrawlink_6, + test_vrtrawlink_7, + test_vrtrawlink_8, + test_vrtrawlink_9, + test_vrtrawlink_10, + test_vrtrawlink_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/vrtwarp.py b/autotest/gdrivers/vrtwarp.py index ef1c7f07ac97..00133cd951af 100755 --- a/autotest/gdrivers/vrtwarp.py +++ b/autotest/gdrivers/vrtwarp.py @@ -40,7 +40,7 @@ # Verify reading from simple existing warp definition. -def vrtwarp_1(): +def test_vrtwarp_1(): tst = gdaltest.GDALTest('VRT', 'rgb_warp.vrt', 2, 21504) return tst.testOpen(check_filelist=False) @@ -49,7 +49,7 @@ def vrtwarp_1(): # Create a new VRT warp in the temp directory. -def vrtwarp_2(): +def test_vrtwarp_2(): try: os.remove('tmp/warp.vrt') @@ -76,7 +76,7 @@ def vrtwarp_2(): # verify checksum. -def vrtwarp_3(): +def test_vrtwarp_3(): gdaltest.vrtwarp_ds.SetDescription('tmp/warp.vrt') gdaltest.vrtwarp_ds = None @@ -100,7 +100,7 @@ def vrtwarp_3(): # Test implicit overviews with default source overview level strategy (AUTO) -def vrtwarp_4(): +def test_vrtwarp_4(): src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_4.tif', src_ds) @@ -176,7 +176,7 @@ def vrtwarp_4(): # Test implicit overviews with selection of the upper source overview level -def vrtwarp_5(): +def test_vrtwarp_5(): src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_5.tif', src_ds) @@ -223,7 +223,7 @@ def vrtwarp_5(): # Test implicit overviews with GCP -def vrtwarp_6(): +def test_vrtwarp_6(): src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_6.tif', src_ds) @@ -279,7 +279,7 @@ def vrtwarp_6(): # Test implicit overviews with GCP (TPS) -def vrtwarp_7(): +def test_vrtwarp_7(): src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_7.tif', src_ds) @@ -331,7 +331,7 @@ def vrtwarp_7(): # Test implicit overviews with RPC -def vrtwarp_8(): +def test_vrtwarp_8(): shutil.copy('../gcore/data/byte.tif', 'tmp/vrtwarp_8.tif') shutil.copy('../gcore/data/test_rpc.txt', 'tmp/vrtwarp_8_rpc.txt') @@ -368,7 +368,7 @@ def vrtwarp_8(): # Test implicit overviews with GEOLOCATION -def vrtwarp_9(): +def test_vrtwarp_9(): shutil.copy('../gcore/data/sstgeo.tif', 'tmp/sstgeo.tif') @@ -432,7 +432,7 @@ def vrtwarp_9(): # Test implicit overviews with selection of the full resolution level -def vrtwarp_10(): +def test_vrtwarp_10(): src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_10.tif', src_ds) @@ -478,7 +478,7 @@ def vrtwarp_10(): # Test implicit overviews with dest alpha band (#6081) -def vrtwarp_11(): +def test_vrtwarp_11(): ds = gdal.Open('data/bug6581.vrt') cs1 = ds.GetRasterBand(1).Checksum() @@ -499,7 +499,7 @@ def vrtwarp_11(): # Test reading a regular VRT whose source is a warped VRT inlined -def vrtwarp_read_vrt_of_warped_vrt(): +def test_vrtwarp_read_vrt_of_warped_vrt(): ds = gdal.Open('data/vrt_of_warped_vrt.vrt') cs = ds.GetRasterBand(1).Checksum() @@ -514,18 +514,18 @@ def vrtwarp_read_vrt_of_warped_vrt(): gdaltest_list = [ - vrtwarp_1, - vrtwarp_2, - vrtwarp_3, - vrtwarp_4, - vrtwarp_5, - vrtwarp_6, - vrtwarp_7, - vrtwarp_8, - vrtwarp_9, - vrtwarp_10, - vrtwarp_11, - vrtwarp_read_vrt_of_warped_vrt + test_vrtwarp_1, + test_vrtwarp_2, + test_vrtwarp_3, + test_vrtwarp_4, + test_vrtwarp_5, + test_vrtwarp_6, + test_vrtwarp_7, + test_vrtwarp_8, + test_vrtwarp_9, + test_vrtwarp_10, + test_vrtwarp_11, + test_vrtwarp_read_vrt_of_warped_vrt ] diff --git a/autotest/gdrivers/wcs.py b/autotest/gdrivers/wcs.py index 6e9baba60df4..293ba6da31d3 100755 --- a/autotest/gdrivers/wcs.py +++ b/autotest/gdrivers/wcs.py @@ -51,7 +51,7 @@ # Verify we have the driver. -def wcs_1(): +def test_wcs_1(): # Disable wcs tests till we have a more reliable test server. gdaltest.wcs_drv = gdal.GetDriverByName('WCS') @@ -92,7 +92,7 @@ def wcs_2(): # Check various things about the configuration. -def wcs_3(): +def test_wcs_3(): if gdaltest.wcs_drv is None or gdaltest.wcs_ds is None: return 'skip' @@ -133,7 +133,7 @@ def wcs_3(): # Check checksum -def wcs_4(): +def test_wcs_4(): if gdaltest.wcs_drv is None or gdaltest.wcs_ds is None: return 'skip' @@ -478,7 +478,7 @@ def setupFct(): ############################################################################### -def wcs_6(): +def test_wcs_6(): driver = gdal.GetDriverByName('WCS') if driver is None: return 'skip' @@ -577,7 +577,7 @@ def wcs_6(): ############################################################################### -def wcs_cleanup(): +def test_wcs_cleanup(): gdaltest.wcs_drv = None gdaltest.wcs_ds = None @@ -596,13 +596,13 @@ def wcs_cleanup(): gdaltest_list = [ - wcs_1, + test_wcs_1, # wcs_2, #FIXME: re-enable after adapting test - wcs_3, - wcs_4, + test_wcs_3, + test_wcs_4, # wcs_5, #FIXME: re-enable after adapting test - wcs_6, - wcs_cleanup] + test_wcs_6, + test_wcs_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/webp.py b/autotest/gdrivers/webp.py index 70d887369332..3e2e0f8b9682 100755 --- a/autotest/gdrivers/webp.py +++ b/autotest/gdrivers/webp.py @@ -39,7 +39,7 @@ # Test if WEBP driver is present -def webp_1(): +def test_webp_1(): gdaltest.webp_drv = gdal.GetDriverByName('WEBP') if gdaltest.webp_drv is None: @@ -51,7 +51,7 @@ def webp_1(): # Open() test -def webp_2(): +def test_webp_2(): if gdaltest.webp_drv is None: return 'skip' @@ -69,7 +69,7 @@ def webp_2(): # CreateCopy() test -def webp_3(): +def test_webp_3(): if gdaltest.webp_drv is None: return 'skip' @@ -94,7 +94,7 @@ def webp_3(): # CreateCopy() on RGBA -def webp_4(): +def test_webp_4(): if gdaltest.webp_drv is None: return 'skip' @@ -128,7 +128,7 @@ def webp_4(): # CreateCopy() on RGBA with lossless compression -def webp_5(): +def test_webp_5(): if gdaltest.webp_drv is None: return 'skip' @@ -159,11 +159,11 @@ def webp_5(): gdaltest_list = [ - webp_1, - webp_2, - webp_3, - webp_4, - webp_5] + test_webp_1, + test_webp_2, + test_webp_3, + test_webp_4, + test_webp_5] if __name__ == '__main__': diff --git a/autotest/gdrivers/wms.py b/autotest/gdrivers/wms.py index 7d513ed083cb..a01219d304b2 100755 --- a/autotest/gdrivers/wms.py +++ b/autotest/gdrivers/wms.py @@ -44,7 +44,7 @@ # Verify we have the driver. -def wms_1(): +def test_wms_1(): gdaltest.wms_drv = gdal.GetDriverByName('WMS') if gdaltest.wms_drv is None: @@ -158,7 +158,7 @@ def wms_4(): # Open the WMS service using XML as filename. -def wms_5(): +def test_wms_5(): if gdaltest.wms_drv is None: return 'skip' @@ -188,7 +188,7 @@ def wms_5(): # Test TileService -def wms_6(): +def test_wms_6(): if gdaltest.wms_drv is None: return 'skip' @@ -218,7 +218,7 @@ def wms_6(): # Test TMS -def wms_7(): +def test_wms_7(): if gdaltest.wms_drv is None: return 'skip' @@ -280,7 +280,7 @@ def wms_7(): ############################################################################### # Test TMS with cache -def wms_8(): +def test_wms_8(): if gdaltest.wms_drv is None: return 'skip' @@ -582,7 +582,7 @@ def wms_10(): # Test getting subdatasets from GetTileService -def wms_11(): +def test_wms_11(): if gdaltest.wms_drv is None: return 'skip' @@ -622,7 +622,7 @@ def wms_11(): # Test getting subdatasets from a TMS server -def wms_12(): +def test_wms_12(): if gdaltest.wms_drv is None: return 'skip' @@ -664,7 +664,7 @@ def wms_12(): # Test reading WMS through VRT (test effect of r21866) -def wms_13(): +def test_wms_13(): if gdaltest.wms_drv is None: return 'skip' @@ -683,7 +683,7 @@ def wms_13(): ############################################################################### # Test reading Virtual Earth layer -def wms_14(): +def test_wms_14(): if gdaltest.wms_drv is None: return 'skip' @@ -734,7 +734,7 @@ def wms_14(): # Test reading ArcGIS MapServer JSon definition and CreateCopy() -def wms_15(): +def test_wms_15(): if gdaltest.wms_drv is None: return 'skip' @@ -792,7 +792,7 @@ def wms_15(): # Test getting subdatasets from WMS-C Capabilities -def wms_16(): +def test_wms_16(): if gdaltest.wms_drv is None: return 'skip' @@ -916,7 +916,7 @@ def wms_17(): # Test a ArcGIS Server -def wms_18(): +def test_wms_18(): if gdaltest.wms_drv is None: return 'skip' @@ -959,7 +959,7 @@ def wms_18(): # Test a IIP server -def wms_19(): +def test_wms_19(): if gdaltest.wms_drv is None: return 'skip' @@ -991,7 +991,7 @@ def wms_19(): ############################################################################### -def wms_cleanup(): +def test_wms_cleanup(): gdaltest.wms_ds = None gdaltest.clean_tmp() @@ -1005,26 +1005,26 @@ def wms_cleanup(): gdaltest_list = [ - wms_1, + test_wms_1, # wms_2, # wms_3, # wms_4, - wms_5, - wms_6, - wms_7, - wms_8, + test_wms_5, + test_wms_6, + test_wms_7, + test_wms_8, # wms_9, # wms_10, - wms_11, - wms_12, - wms_13, - wms_14, - wms_15, - wms_16, + test_wms_11, + test_wms_12, + test_wms_13, + test_wms_14, + test_wms_15, + test_wms_16, # wms_17, - wms_18, - wms_19, - wms_cleanup] + test_wms_18, + test_wms_19, + test_wms_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/wmts.py b/autotest/gdrivers/wmts.py index 21e60c9ab981..24a1d0200302 100755 --- a/autotest/gdrivers/wmts.py +++ b/autotest/gdrivers/wmts.py @@ -41,7 +41,7 @@ # Find WMTS driver -def wmts_1(): +def test_wmts_1(): gdaltest.wmts_drv = gdal.GetDriverByName('WMTS') @@ -61,7 +61,7 @@ def wmts_1(): # Error: no URL and invalid GDAL_WMTS service file documents -def wmts_2(): +def test_wmts_2(): if gdaltest.wmts_drv is None: return 'skip' @@ -100,7 +100,7 @@ def wmts_2(): # Error: invalid URL -def wmts_3(): +def test_wmts_3(): if gdaltest.wmts_drv is None: return 'skip' @@ -118,7 +118,7 @@ def wmts_3(): # Error: invalid URL -def wmts_4(): +def test_wmts_4(): if gdaltest.wmts_drv is None: return 'skip' @@ -136,7 +136,7 @@ def wmts_4(): # Error: invalid XML in GetCapabilities response -def wmts_5(): +def test_wmts_5(): if gdaltest.wmts_drv is None: return 'skip' @@ -156,7 +156,7 @@ def wmts_5(): # Error: invalid content in GetCapabilities response -def wmts_6(): +def test_wmts_6(): if gdaltest.wmts_drv is None: return 'skip' @@ -176,7 +176,7 @@ def wmts_6(): # Error: no layers -def wmts_7(): +def test_wmts_7(): if gdaltest.wmts_drv is None: return 'skip' @@ -196,7 +196,7 @@ def wmts_7(): # Error: missing TileMatrixSetLink and Style -def wmts_8(): +def test_wmts_8(): if gdaltest.wmts_drv is None: return 'skip' @@ -222,7 +222,7 @@ def wmts_8(): # Error: missing TileMatrixSet -def wmts_9(): +def test_wmts_9(): if gdaltest.wmts_drv is None: return 'skip' @@ -255,7 +255,7 @@ def wmts_9(): # Error: Missing SupportedCRS -def wmts_10(): +def test_wmts_10(): if gdaltest.wmts_drv is None: return 'skip' @@ -291,7 +291,7 @@ def wmts_10(): # Error: Cannot find TileMatrix in TileMatrixSet -def wmts_11(): +def test_wmts_11(): if gdaltest.wmts_drv is None: return 'skip' @@ -328,7 +328,7 @@ def wmts_11(): # Error: Missing required element in TileMatrix element -def wmts_12(): +def test_wmts_12(): if gdaltest.wmts_drv is None: return 'skip' @@ -366,7 +366,7 @@ def wmts_12(): # Error: Missing ResourceURL -def wmts_12bis(): +def test_wmts_12bis(): if gdaltest.wmts_drv is None: return 'skip' @@ -411,7 +411,7 @@ def wmts_12bis(): # Minimal -def wmts_13(): +def test_wmts_13(): if gdaltest.wmts_drv is None: return 'skip' @@ -553,7 +553,7 @@ def wmts_13(): # Nominal RESTful -def wmts_14(): +def test_wmts_14(): if gdaltest.wmts_drv is None: return 'skip' @@ -850,7 +850,7 @@ def wmts_14(): # Nominal KVP -def wmts_15(): +def test_wmts_15(): if gdaltest.wmts_drv is None: return 'skip' @@ -1012,7 +1012,7 @@ def wmts_15(): # AOI from layer WGS84BoundingBox -def wmts_16(): +def test_wmts_16(): if gdaltest.wmts_drv is None: return 'skip' @@ -1102,7 +1102,7 @@ def wmts_16(): # AOI from layer BoundingBox -def wmts_17(): +def test_wmts_17(): if gdaltest.wmts_drv is None: return 'skip' @@ -1192,7 +1192,7 @@ def wmts_17(): # AOI from TileMatrixSet BoundingBox -def wmts_18(): +def test_wmts_18(): if gdaltest.wmts_drv is None: return 'skip' @@ -1282,7 +1282,7 @@ def wmts_18(): # AOI from TileMatrixSetLimits -def wmts_19(): +def test_wmts_19(): if gdaltest.wmts_drv is None: return 'skip' @@ -1377,7 +1377,7 @@ def wmts_19(): # AOI from layer BoundingBox but restricted with TileMatrixSetLimits -def wmts_20(): +def test_wmts_20(): if gdaltest.wmts_drv is None: return 'skip' @@ -1476,7 +1476,7 @@ def wmts_20(): # Test ExtendBeyondDateLine -def wmts_21(): +def test_wmts_21(): if gdaltest.wmts_drv is None: return 'skip' @@ -1589,7 +1589,7 @@ def wmts_21(): # Test when WGS84BoundingBox is a densified reprojection of the tile matrix bbox -def wmts_22(): +def test_wmts_22(): if gdaltest.wmts_drv is None: return 'skip' @@ -1729,27 +1729,27 @@ def wmts_23(imagetype, expected_cs): return 'success' -def wmts_23_gray(): +def test_wmts_23_gray(): return wmts_23('gray', [60137, 60137, 60137, 4428]) -def wmts_23_grayalpha(): +def test_wmts_23_grayalpha(): return wmts_23('gray+alpha', [39910, 39910, 39910, 63180]) -def wmts_23_pal(): +def test_wmts_23_pal(): return wmts_23('pal', [62950, 59100, 63864, 453]) -def wmts_23_rgb(): +def test_wmts_23_rgb(): return wmts_23('rgb', [1020, 3665, 6180, 4428]) -def wmts_23_rgba(): +def test_wmts_23_rgba(): return wmts_23('rgba', [65530, 51449, 1361, 59291]) -def wmts_invalid_global_to_tm_reprojection(): +def test_wmts_invalid_global_to_tm_reprojection(): if gdaltest.wmts_drv is None: return 'skip' @@ -1810,7 +1810,7 @@ def wmts_invalid_global_to_tm_reprojection(): # -def wmts_check_no_overflow_zoom_level(): +def test_wmts_check_no_overflow_zoom_level(): if gdaltest.wmts_drv is None: return 'skip' @@ -2100,7 +2100,7 @@ def wmts_CleanCache(): # -def wmts_cleanup(): +def test_wmts_cleanup(): if gdaltest.wmts_drv is None: return 'skip' @@ -2124,37 +2124,37 @@ def wmts_cleanup(): gdaltest_list = [ - wmts_1, - wmts_2, - wmts_3, - wmts_4, - wmts_5, - wmts_6, - wmts_7, - wmts_8, - wmts_9, - wmts_10, - wmts_11, - wmts_12, - wmts_12bis, - wmts_13, - wmts_14, - wmts_15, - wmts_16, - wmts_17, - wmts_18, - wmts_19, - wmts_20, - wmts_21, - wmts_22, - wmts_23_gray, - wmts_23_grayalpha, - wmts_23_pal, - wmts_23_rgb, - wmts_23_rgba, - wmts_invalid_global_to_tm_reprojection, - wmts_check_no_overflow_zoom_level, - wmts_cleanup] + test_wmts_1, + test_wmts_2, + test_wmts_3, + test_wmts_4, + test_wmts_5, + test_wmts_6, + test_wmts_7, + test_wmts_8, + test_wmts_9, + test_wmts_10, + test_wmts_11, + test_wmts_12, + test_wmts_12bis, + test_wmts_13, + test_wmts_14, + test_wmts_15, + test_wmts_16, + test_wmts_17, + test_wmts_18, + test_wmts_19, + test_wmts_20, + test_wmts_21, + test_wmts_22, + test_wmts_23_gray, + test_wmts_23_grayalpha, + test_wmts_23_pal, + test_wmts_23_rgb, + test_wmts_23_rgba, + test_wmts_invalid_global_to_tm_reprojection, + test_wmts_check_no_overflow_zoom_level, + test_wmts_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/xpm.py b/autotest/gdrivers/xpm.py index 05b288be4cfc..deca08c9570c 100755 --- a/autotest/gdrivers/xpm.py +++ b/autotest/gdrivers/xpm.py @@ -54,12 +54,12 @@ def test_xpm(downloadURL, fileName, checksum, download_size): assert ds.GetRasterBand(1).Checksum() == checksum, 'Bad checksum. Expected %d, got %d' % (checksum, ds.GetRasterBand(1).Checksum()) -def xpm_1(): +def test_xpm_1(): tst = gdaltest.GDALTest('XPM', 'byte.tif', 1, 4583) return tst.testCreateCopy(vsimem=1, check_minmax=False) -gdaltest_list = [xpm_1] +gdaltest_list = [test_xpm_1] if __name__ == '__main__': diff --git a/autotest/gdrivers/xyz.py b/autotest/gdrivers/xyz.py index bce66004cb07..c9cb545bac3c 100755 --- a/autotest/gdrivers/xyz.py +++ b/autotest/gdrivers/xyz.py @@ -40,7 +40,7 @@ # Test CreateCopy() of byte.tif -def xyz_1(): +def test_xyz_1(): tst = gdaltest.GDALTest('XYZ', 'byte.tif', 1, 4672) return tst.testCreateCopy(vsimem=1, check_gt=(-67.00041667, 0.00083333, 0.0, 50.000416667, 0.0, -0.00083333)) @@ -49,7 +49,7 @@ def xyz_1(): # Test CreateCopy() of float.img -def xyz_2(): +def test_xyz_2(): src_ds = gdal.Open('data/float.img') ds = gdal.GetDriverByName('XYZ').CreateCopy('tmp/float.xyz', src_ds, options=['COLUMN_SEPARATOR=,', 'ADD_HEADER_LINE=YES']) @@ -66,7 +66,7 @@ def xyz_2(): # Test random access to lines of imagery -def xyz_3(): +def test_xyz_3(): content = """Y X Z 0 0 65 @@ -114,7 +114,7 @@ def xyz_4_checkline(ds, i, expected_bytes): return struct.unpack('B' * ds.RasterXSize, buf) == expected_bytes -def xyz_4(): +def test_xyz_4(): content = """ 440750.001 3751290 1 @@ -160,7 +160,7 @@ def xyz_4(): ############################################################################### # Test XYZ with only integral values and comma field separator -def xyz_5(): +def test_xyz_5(): content = """0,1,100 0.5,1,100 @@ -193,7 +193,7 @@ def xyz_5(): ############################################################################### # Test XYZ with comma decimal separator and semi-colon field separator -def xyz_6(): +def test_xyz_6(): content = """0;1;100 0,5;1;100 @@ -226,7 +226,7 @@ def xyz_6(): ############################################################################### # Test XYZ with not completely equal stepX and stepY -def xyz_7(): +def test_xyz_7(): content = """y x z 51.500000 354.483333 54.721 @@ -275,7 +275,7 @@ def xyz_7(): # Test particular case of XYZ file with missed samples (#6934) -def xyz_8(): +def test_xyz_8(): content = """0 500 50 750 500 100 @@ -304,21 +304,21 @@ def xyz_8(): ############################################################################### # Cleanup -def xyz_cleanup(): +def test_xyz_cleanup(): return 'success' gdaltest_list = [ - xyz_1, - xyz_2, - xyz_3, - xyz_4, - xyz_5, - xyz_6, - xyz_7, - xyz_8, - xyz_cleanup] + test_xyz_1, + test_xyz_2, + test_xyz_3, + test_xyz_4, + test_xyz_5, + test_xyz_6, + test_xyz_7, + test_xyz_8, + test_xyz_cleanup] if __name__ == '__main__': diff --git a/autotest/gdrivers/zmap.py b/autotest/gdrivers/zmap.py index 41dec9a52f31..aceb5bb4dd68 100755 --- a/autotest/gdrivers/zmap.py +++ b/autotest/gdrivers/zmap.py @@ -37,14 +37,14 @@ # Test CreateCopy() of byte.tif -def zmap_1(): +def test_zmap_1(): tst = gdaltest.GDALTest('ZMap', 'byte.tif', 1, 4672) return tst.testCreateCopy(vsimem=1, check_gt=(-67.00041667, 0.00083333, 0.0, 50.000416667, 0.0, -0.00083333)) gdaltest_list = [ - zmap_1 + test_zmap_1 ] if __name__ == '__main__': diff --git a/autotest/gnm/gnm_test.py b/autotest/gnm/gnm_test.py index 50b41b220371..5e01cfac4791 100755 --- a/autotest/gnm/gnm_test.py +++ b/autotest/gnm/gnm_test.py @@ -45,7 +45,7 @@ # Create file base network -def gnm_filenetwork_create(): +def test_gnm_filenetwork_create(): try: shutil.rmtree('tmp/test_gnm') @@ -84,7 +84,7 @@ def gnm_filenetwork_create(): # Open file base network -def gnm_filenetwork_open(): +def test_gnm_filenetwork_open(): if not ogrtest.have_gnm: return 'skip' @@ -112,7 +112,7 @@ def gnm_filenetwork_open(): # Import layers into file base network -def gnm_import(): +def test_gnm_import(): if not ogrtest.have_gnm: return 'skip' @@ -150,7 +150,7 @@ def gnm_import(): # autoconnect -def gnm_autoconnect(): +def test_gnm_autoconnect(): if not ogrtest.have_gnm: return 'skip' @@ -173,7 +173,7 @@ def gnm_autoconnect(): # Dijkstra shortest path -def gnm_graph_dijkstra(): +def test_gnm_graph_dijkstra(): if not ogrtest.have_gnm: return 'skip' @@ -204,7 +204,7 @@ def gnm_graph_dijkstra(): # KShortest Paths -def gnm_graph_kshortest(): +def test_gnm_graph_kshortest(): if not ogrtest.have_gnm: return 'skip' @@ -233,7 +233,7 @@ def gnm_graph_kshortest(): # ConnectedComponents -def gnm_graph_connectedcomponents(): +def test_gnm_graph_connectedcomponents(): if not ogrtest.have_gnm: return 'skip' @@ -262,7 +262,7 @@ def gnm_graph_connectedcomponents(): # Network deleting -def gnm_delete(): +def test_gnm_delete(): if not ogrtest.have_gnm: return 'skip' @@ -280,14 +280,14 @@ def gnm_delete(): gdaltest_list = [ - gnm_filenetwork_create, - gnm_filenetwork_open, - gnm_import, - gnm_autoconnect, - gnm_graph_dijkstra, - gnm_graph_kshortest, - gnm_graph_connectedcomponents, - gnm_delete + test_gnm_filenetwork_create, + test_gnm_filenetwork_open, + test_gnm_import, + test_gnm_autoconnect, + test_gnm_graph_dijkstra, + test_gnm_graph_kshortest, + test_gnm_graph_connectedcomponents, + test_gnm_delete ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_arcgen.py b/autotest/ogr/ogr_arcgen.py index 2388b94446e1..95183d8b90d0 100755 --- a/autotest/ogr/ogr_arcgen.py +++ b/autotest/ogr/ogr_arcgen.py @@ -39,7 +39,7 @@ # Read points -def ogr_arcgen_points(): +def test_ogr_arcgen_points(): ds = ogr.Open('data/points.gen') if ds is None: @@ -76,7 +76,7 @@ def ogr_arcgen_points(): # Read points25d -def ogr_arcgen_points25d(): +def test_ogr_arcgen_points25d(): ds = ogr.Open('data/points25d.gen') if ds is None: @@ -113,7 +113,7 @@ def ogr_arcgen_points25d(): # Read lines -def ogr_arcgen_lines(): +def test_ogr_arcgen_lines(): ds = ogr.Open('data/lines.gen') if ds is None: @@ -146,7 +146,7 @@ def ogr_arcgen_lines(): # Read lines25d -def ogr_arcgen_lines25d(): +def test_ogr_arcgen_lines25d(): ds = ogr.Open('data/lines25d.gen') if ds is None: @@ -179,7 +179,7 @@ def ogr_arcgen_lines25d(): # Read polygons -def ogr_arcgen_polygons(): +def test_ogr_arcgen_polygons(): ds = ogr.Open('data/polygons.gen') if ds is None: @@ -212,7 +212,7 @@ def ogr_arcgen_polygons(): # Read polygons25d -def ogr_arcgen_polygons25d(): +def test_ogr_arcgen_polygons25d(): ds = ogr.Open('data/polygons25d.gen') if ds is None: @@ -243,12 +243,12 @@ def ogr_arcgen_polygons25d(): gdaltest_list = [ - ogr_arcgen_points, - ogr_arcgen_points25d, - ogr_arcgen_lines, - ogr_arcgen_lines25d, - ogr_arcgen_polygons, - ogr_arcgen_polygons25d] + test_ogr_arcgen_points, + test_ogr_arcgen_points25d, + test_ogr_arcgen_lines, + test_ogr_arcgen_lines25d, + test_ogr_arcgen_polygons, + test_ogr_arcgen_polygons25d] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_avc.py b/autotest/ogr/ogr_avc.py index a49ece921d34..4d445a2ef260 100755 --- a/autotest/ogr/ogr_avc.py +++ b/autotest/ogr/ogr_avc.py @@ -62,7 +62,7 @@ def check_content(ds): # Open AVCE00 datasource. -def ogr_avc_1(): +def test_ogr_avc_1(): # Example given at Annex A of http://avce00.maptools.org/docs/v7_e00_cover.html avc_ds = ogr.Open('data/test.e00') @@ -78,7 +78,7 @@ def ogr_avc_1(): # Open AVCBin datasource. -def ogr_avc_2(): +def test_ogr_avc_2(): avc_ds = ogr.Open('data/testavc/testavc') if avc_ds.GetLayer(0).GetSpatialRef() is None: @@ -93,7 +93,7 @@ def ogr_avc_2(): # Try opening a compressed E00 (which is not supported) -def ogr_avc_3(): +def test_ogr_avc_3(): gdal.PushErrorHandler('CPLQuietErrorHandler') avc_ds = ogr.Open('data/compressed.e00') @@ -114,7 +114,7 @@ def ogr_avc_3(): # Open larger AVCBin datasource. -def ogr_avc_4(): +def test_ogr_avc_4(): for filename in ['data/testpointavc/testpointavc', 'data/testpoint.e00']: avc_ds = ogr.Open(filename) @@ -156,7 +156,7 @@ def ogr_avc_4(): # Open AVCBin datasource with polygon -def ogr_avc_5(): +def test_ogr_avc_5(): for filename in ['data/testpolyavc/testpolyavc', 'data/testpoly.e00']: avc_ds = ogr.Open(filename) @@ -202,11 +202,11 @@ def ogr_avc_5(): gdaltest_list = [ - ogr_avc_1, - ogr_avc_2, - ogr_avc_3, - ogr_avc_4, - ogr_avc_5 + test_ogr_avc_1, + test_ogr_avc_2, + test_ogr_avc_3, + test_ogr_avc_4, + test_ogr_avc_5 ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_basic_test.py b/autotest/ogr/ogr_basic_test.py index 32697f36f2ea..b4f149415462 100755 --- a/autotest/ogr/ogr_basic_test.py +++ b/autotest/ogr/ogr_basic_test.py @@ -39,7 +39,7 @@ ############################################################################### -def ogr_basic_1(): +def test_ogr_basic_1(): gdaltest.ds = ogr.Open('data/poly.shp') @@ -53,7 +53,7 @@ def ogr_basic_1(): # Test Feature counting. -def ogr_basic_2(): +def test_ogr_basic_2(): gdaltest.lyr = gdaltest.ds.GetLayerByName('poly') @@ -91,7 +91,7 @@ def ogr_basic_2(): # Test Spatial Query. -def ogr_basic_3(): +def test_ogr_basic_3(): minx = 479405 miny = 4762826 @@ -139,7 +139,7 @@ def ogr_basic_3(): # Test GetDriver(). -def ogr_basic_4(): +def test_ogr_basic_4(): driver = gdaltest.ds.GetDriver() if driver is None: gdaltest.post_reason('GetDriver() returns None') @@ -155,7 +155,7 @@ def ogr_basic_4(): # Test attribute query on special field fid - per bug 1468. -def ogr_basic_5(): +def test_ogr_basic_5(): gdaltest.lyr.SetAttributeFilter('FID = 3') gdaltest.lyr.ResetReading() @@ -178,7 +178,7 @@ def ogr_basic_5(): ############################################################################### # Test opening a dataset with an empty string and a non existing dataset -def ogr_basic_6(): +def test_ogr_basic_6(): # Put inside try/except for OG python bindings if ogr.Open('') is not None: @@ -193,7 +193,7 @@ def ogr_basic_6(): # Test ogr.Feature.Equal() -def ogr_basic_7(): +def test_ogr_basic_7(): feat_defn = ogr.FeatureDefn() feat = ogr.Feature(feat_defn) @@ -386,7 +386,7 @@ def ogr_basic_7(): # Issue several RegisterAll() to check that OGR drivers are good citizens -def ogr_basic_8(): +def test_ogr_basic_8(): ogr.RegisterAll() ogr.RegisterAll() @@ -398,7 +398,7 @@ def ogr_basic_8(): # Test ogr.GeometryTypeToName (#4871) -def ogr_basic_9(): +def test_ogr_basic_9(): geom_type_tuples = [[ogr.wkbUnknown, "Unknown (any)"], [ogr.wkbPoint, "Point"], @@ -432,7 +432,7 @@ def ogr_basic_9(): # Run test_ogrsf -all_drivers -def ogr_basic_10(): +def test_ogr_basic_10(): import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is None: @@ -450,7 +450,7 @@ def ogr_basic_10(): # Test double call to UseExceptions() (#5704) -def ogr_basic_11(): +def test_ogr_basic_11(): if not ogrtest.have_geos(): return 'skip' @@ -470,7 +470,7 @@ def ogr_basic_11(): # Test OFSTBoolean, OFSTInt16 and OFSTFloat32 -def ogr_basic_12(): +def test_ogr_basic_12(): # boolean integer feat_def = ogr.FeatureDefn() @@ -643,7 +643,7 @@ def ogr_basic_12(): # Test OGRParseDate (#6452) -def ogr_basic_13(): +def test_ogr_basic_13(): feat_defn = ogr.FeatureDefn('test') field_defn = ogr.FieldDefn('date', ogr.OFTDateTime) feat_defn.AddFieldDefn(field_defn) @@ -686,7 +686,7 @@ def ogr_basic_13(): # Test ogr.Open(.) in an empty directory -def ogr_basic_14(): +def test_ogr_basic_14(): os.mkdir('tmp/ogr_basic_14') os.chdir('tmp/ogr_basic_14') @@ -704,7 +704,7 @@ def ogr_basic_14(): # Test exceptions with OGRErr return code -def ogr_basic_15(): +def test_ogr_basic_15(): ds = ogr.Open('data/poly.shp') lyr = ds.GetLayer(0) @@ -742,7 +742,7 @@ def ogr_basic_16_gen_list(N): yield i -def ogr_basic_16(): +def test_ogr_basic_16(): if list(ogr_basic_16_gen_list(2)) != [0, 1]: return 'fail' @@ -750,7 +750,7 @@ def ogr_basic_16(): return 'success' -def ogr_basic_invalid_unicode(): +def test_ogr_basic_invalid_unicode(): if sys.version_info >= (3, 0, 0): val = '\udcfc' @@ -774,7 +774,7 @@ def ogr_basic_invalid_unicode(): return 'success' -def ogr_basic_dataset_slice(): +def test_ogr_basic_dataset_slice(): ds = ogr.GetDriverByName('Memory').CreateDataSource('') ds.CreateLayer('lyr1') @@ -806,7 +806,7 @@ def ogr_basic_dataset_slice(): # cleanup -def ogr_basic_cleanup(): +def test_ogr_basic_cleanup(): gdaltest.lyr = None gdaltest.ds = None @@ -814,25 +814,25 @@ def ogr_basic_cleanup(): gdaltest_list = [ - ogr_basic_1, - ogr_basic_2, - ogr_basic_3, - ogr_basic_4, - ogr_basic_5, - ogr_basic_6, - ogr_basic_7, - ogr_basic_8, - ogr_basic_9, - ogr_basic_10, - ogr_basic_11, - ogr_basic_12, - ogr_basic_13, - ogr_basic_14, - ogr_basic_15, - ogr_basic_16, - ogr_basic_invalid_unicode, - ogr_basic_dataset_slice, - ogr_basic_cleanup] + test_ogr_basic_1, + test_ogr_basic_2, + test_ogr_basic_3, + test_ogr_basic_4, + test_ogr_basic_5, + test_ogr_basic_6, + test_ogr_basic_7, + test_ogr_basic_8, + test_ogr_basic_9, + test_ogr_basic_10, + test_ogr_basic_11, + test_ogr_basic_12, + test_ogr_basic_13, + test_ogr_basic_14, + test_ogr_basic_15, + test_ogr_basic_16, + test_ogr_basic_invalid_unicode, + test_ogr_basic_dataset_slice, + test_ogr_basic_cleanup] # gdaltest_list = [ ogr_basic_13 ] diff --git a/autotest/ogr/ogr_bna.py b/autotest/ogr/ogr_bna.py index 9b07d9adf74c..f13372efbd25 100755 --- a/autotest/ogr/ogr_bna.py +++ b/autotest/ogr/ogr_bna.py @@ -41,7 +41,7 @@ # Test points bna layer. -def ogr_bna_1(): +def test_ogr_bna_1(): gdaltest.bna_ds = ogr.Open('data/test.bna') @@ -70,7 +70,7 @@ def ogr_bna_1(): # Test lines bna layer. -def ogr_bna_2(): +def test_ogr_bna_2(): gdaltest.bna_ds = ogr.Open('data/test.bna') @@ -93,7 +93,7 @@ def ogr_bna_2(): # Test polygons bna layer. -def ogr_bna_3(): +def test_ogr_bna_3(): gdaltest.bna_ds = ogr.Open('data/test.bna') @@ -129,7 +129,7 @@ def ogr_bna_3(): # Test ellipses bna layer. -def ogr_bna_4(): +def test_ogr_bna_4(): gdaltest.bna_ds = ogr.Open('data/test.bna') @@ -211,12 +211,12 @@ def ogr_bna_write(creation_options): return 'success' -def ogr_bna_5(): +def test_ogr_bna_5(): return ogr_bna_write(['ELLIPSES_AS_ELLIPSES=YES']) -def ogr_bna_6(): +def test_ogr_bna_6(): try: os.remove('tmp/out.bna') @@ -249,7 +249,7 @@ def ogr_bna_6(): # -def ogr_bna_cleanup(): +def test_ogr_bna_cleanup(): gdaltest.bna_ds = None @@ -262,13 +262,13 @@ def ogr_bna_cleanup(): gdaltest_list = [ - ogr_bna_1, - ogr_bna_2, - ogr_bna_3, - ogr_bna_4, - ogr_bna_5, - ogr_bna_6, - ogr_bna_cleanup] + test_ogr_bna_1, + test_ogr_bna_2, + test_ogr_bna_3, + test_ogr_bna_4, + test_ogr_bna_5, + test_ogr_bna_6, + test_ogr_bna_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_cad.py b/autotest/ogr/ogr_cad.py index 0cc3dfb83a7a..7503507541a4 100755 --- a/autotest/ogr/ogr_cad.py +++ b/autotest/ogr/ogr_cad.py @@ -42,7 +42,7 @@ # Check driver existence. -def ogr_cad_1(): +def test_ogr_cad_1(): gdaltest.cad_ds = None gdaltest.cad_dr = None @@ -57,7 +57,7 @@ def ogr_cad_1(): # Check driver properly opens simple file, reads correct feature (ellipse). -def ogr_cad_2(): +def test_ogr_cad_2(): if gdaltest.cad_dr is None: return 'skip' @@ -135,7 +135,7 @@ def ogr_cad_2(): # Check proper read of 3 layers (one circle on each) with different parameters. -def ogr_cad_3(): +def test_ogr_cad_3(): if gdaltest.cad_dr is None: return 'skip' @@ -296,7 +296,7 @@ def ogr_cad_3(): # Check reading of a single point. -def ogr_cad_4(): +def test_ogr_cad_4(): if gdaltest.cad_dr is None: return 'skip' @@ -325,7 +325,7 @@ def ogr_cad_4(): # Check reading of a simple line. -def ogr_cad_5(): +def test_ogr_cad_5(): if gdaltest.cad_dr is None: return 'skip' @@ -355,7 +355,7 @@ def ogr_cad_5(): # OGR feature style string to LABEL. -def ogr_cad_6(): +def test_ogr_cad_6(): if gdaltest.cad_dr is None: return 'skip' @@ -389,7 +389,7 @@ def ogr_cad_6(): # Check MTEXT as TEXT geometry. -def ogr_cad_7(): +def test_ogr_cad_7(): if gdaltest.cad_dr is None: return 'skip' @@ -410,7 +410,7 @@ def ogr_cad_7(): # Check ATTDEF as TEXT geometry. -def ogr_cad_8(): +def test_ogr_cad_8(): if gdaltest.cad_dr is None: return 'skip' @@ -431,7 +431,7 @@ def ogr_cad_8(): # Open a not handled DWG version -def ogr_cad_9(): +def test_ogr_cad_9(): if gdaltest.cad_dr is None: return 'skip' @@ -451,7 +451,7 @@ def ogr_cad_9(): # Cleanup -def ogr_cad_cleanup(): +def test_ogr_cad_cleanup(): gdaltest.cad_layer = None gdaltest.cad_ds = None @@ -459,16 +459,16 @@ def ogr_cad_cleanup(): gdaltest_list = [ - ogr_cad_1, - ogr_cad_2, - ogr_cad_3, - ogr_cad_4, - ogr_cad_5, - ogr_cad_6, - ogr_cad_7, - ogr_cad_8, - ogr_cad_9, - ogr_cad_cleanup] + test_ogr_cad_1, + test_ogr_cad_2, + test_ogr_cad_3, + test_ogr_cad_4, + test_ogr_cad_5, + test_ogr_cad_6, + test_ogr_cad_7, + test_ogr_cad_8, + test_ogr_cad_9, + test_ogr_cad_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_carto.py b/autotest/ogr/ogr_carto.py index 67e41a8f80c3..b7f974fed208 100755 --- a/autotest/ogr/ogr_carto.py +++ b/autotest/ogr/ogr_carto.py @@ -43,7 +43,7 @@ # Test if driver is available -def ogr_carto_init(): +def test_ogr_carto_init(): ogrtest.carto_drv = None @@ -57,7 +57,7 @@ def ogr_carto_init(): ############################################################################### # -def ogr_carto_vsimem(): +def test_ogr_carto_vsimem(): if ogrtest.carto_drv is None: return 'skip' @@ -1046,7 +1046,7 @@ def ogr_carto_vsimem(): # -def ogr_carto_vsimem_cleanup(): +def test_ogr_carto_vsimem_cleanup(): if ogrtest.carto_drv is None: return 'skip' @@ -1065,7 +1065,7 @@ def ogr_carto_vsimem_cleanup(): # Run test_ogrsf -def ogr_carto_test_ogrsf(): +def test_ogr_carto_test_ogrsf(): if ogrtest.carto_drv is None or gdal.GetConfigOption('SKIP_SLOW') is not None: return 'skip' @@ -1299,10 +1299,10 @@ def ogr_carto_rw_1(): gdaltest_list = [ - ogr_carto_init, - ogr_carto_vsimem, - ogr_carto_vsimem_cleanup, - ogr_carto_test_ogrsf + test_ogr_carto_init, + test_ogr_carto_vsimem, + test_ogr_carto_vsimem_cleanup, + test_ogr_carto_test_ogrsf ] diff --git a/autotest/ogr/ogr_cloudant.py b/autotest/ogr/ogr_cloudant.py index 6b8eb8dced25..249dcfc899dc 100755 --- a/autotest/ogr/ogr_cloudant.py +++ b/autotest/ogr/ogr_cloudant.py @@ -42,7 +42,7 @@ # Test if driver is available -def ogr_cloudant_init(): +def test_ogr_cloudant_init(): ogrtest.cloudant_drv = None @@ -74,7 +74,7 @@ def ogr_cloudant_init(): # Test GetFeatureCount() -def ogr_cloudant_GetFeatureCount(): +def test_ogr_cloudant_GetFeatureCount(): if ogrtest.cloudant_drv is None: return 'skip' @@ -98,7 +98,7 @@ def ogr_cloudant_GetFeatureCount(): # Test GetNextFeature() -def ogr_cloudant_GetNextFeature(): +def test_ogr_cloudant_GetNextFeature(): if ogrtest.cloudant_drv is None: return 'skip' @@ -125,7 +125,7 @@ def ogr_cloudant_GetNextFeature(): # Test GetSpatialRef() -def ogr_cloudant_GetSpatialRef(): +def test_ogr_cloudant_GetSpatialRef(): if ogrtest.cloudant_drv is None: return 'skip' @@ -148,7 +148,7 @@ def ogr_cloudant_GetSpatialRef(): # Test GetExtent() -def ogr_cloudant_GetExtent(): +def test_ogr_cloudant_GetExtent(): if ogrtest.cloudant_drv is None: return 'skip' @@ -176,7 +176,7 @@ def ogr_cloudant_GetExtent(): # Test SetSpatialFilter() -def ogr_cloudant_SetSpatialFilter(): +def test_ogr_cloudant_SetSpatialFilter(): if ogrtest.cloudant_drv is None: return 'skip' @@ -206,12 +206,12 @@ def ogr_cloudant_SetSpatialFilter(): gdaltest_list = [ - ogr_cloudant_init, - ogr_cloudant_GetFeatureCount, - ogr_cloudant_GetNextFeature, - ogr_cloudant_GetSpatialRef, - ogr_cloudant_GetExtent, - ogr_cloudant_SetSpatialFilter + test_ogr_cloudant_init, + test_ogr_cloudant_GetFeatureCount, + test_ogr_cloudant_GetNextFeature, + test_ogr_cloudant_GetSpatialRef, + test_ogr_cloudant_GetExtent, + test_ogr_cloudant_SetSpatialFilter ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_couchdb.py b/autotest/ogr/ogr_couchdb.py index 990df5f0a182..83e00280e880 100755 --- a/autotest/ogr/ogr_couchdb.py +++ b/autotest/ogr/ogr_couchdb.py @@ -43,7 +43,7 @@ # Test if driver is available -def ogr_couchdb_init(): +def test_ogr_couchdb_init(): ogrtest.couchdb_drv = None @@ -68,7 +68,7 @@ def ogr_couchdb_init(): # Basic test -def ogr_couchdb_1(): +def test_ogr_couchdb_1(): if ogrtest.couchdb_drv is None: return 'skip' @@ -93,7 +93,7 @@ def ogr_couchdb_1(): # Test null / unset -def ogr_couchdb_2(): +def test_ogr_couchdb_2(): if ogrtest.couchdb_drv is None: return 'skip' @@ -138,7 +138,7 @@ def ogr_couchdb_2(): ############################################################################### # Cleanup -def ogr_couchdb_cleanup(): +def test_ogr_couchdb_cleanup(): if ogrtest.couchdb_drv is None: return 'skip' @@ -151,10 +151,10 @@ def ogr_couchdb_cleanup(): gdaltest_list = [ - ogr_couchdb_init, - ogr_couchdb_1, - ogr_couchdb_2, - ogr_couchdb_cleanup + test_ogr_couchdb_init, + test_ogr_couchdb_1, + test_ogr_couchdb_2, + test_ogr_couchdb_cleanup ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_csv.py b/autotest/ogr/ogr_csv.py index b69fb6bbaabf..43aed35ae336 100755 --- a/autotest/ogr/ogr_csv.py +++ b/autotest/ogr/ogr_csv.py @@ -41,7 +41,7 @@ # Open CSV datasource. -def ogr_csv_1(): +def test_ogr_csv_1(): gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/prime_meridian.csv') @@ -84,7 +84,7 @@ def ogr_csv_check_layer(lyr, expect_code_as_numeric): # -def ogr_csv_2(): +def test_ogr_csv_2(): if gdaltest.csv_ds is None: return 'skip' @@ -151,7 +151,7 @@ def ogr_csv_copy_layer(layer_name, options): # Copy prime_meridian.csv to a new subtree under the tmp directory. -def ogr_csv_3(): +def test_ogr_csv_3(): if gdaltest.csv_ds is None: return 'skip' @@ -196,7 +196,7 @@ def ogr_csv_3(): # NOTE: one weird thing is that in this pass the prime_meridian_code field # is typed as integer instead of string since it is created literally. -def ogr_csv_4(): +def test_ogr_csv_4(): if gdaltest.csv_ds is None: return 'skip' @@ -206,7 +206,7 @@ def ogr_csv_4(): # Copy prime_meridian.csv again, in CRLF mode. -def ogr_csv_5(): +def test_ogr_csv_5(): if gdaltest.csv_ds is None: return 'skip' @@ -221,7 +221,7 @@ def ogr_csv_5(): # -def ogr_csv_6(): +def test_ogr_csv_6(): if gdaltest.csv_ds is None: return 'skip' @@ -232,7 +232,7 @@ def ogr_csv_6(): # -def ogr_csv_7(): +def test_ogr_csv_7(): if gdaltest.csv_ds is None: return 'skip' @@ -270,7 +270,7 @@ def ogr_csv_7(): # -def ogr_csv_8(): +def test_ogr_csv_8(): if gdaltest.csv_ds is None: return 'skip' @@ -294,7 +294,7 @@ def ogr_csv_8(): # -def ogr_csv_9(): +def test_ogr_csv_9(): if gdaltest.csv_ds is None: return 'skip' @@ -328,7 +328,7 @@ def ogr_csv_9(): # -def ogr_csv_10(): +def test_ogr_csv_10(): if gdaltest.csv_ds is None: return 'skip' @@ -479,7 +479,7 @@ def ogr_csv_check_testcsvt(lyr): # Verify handling of csvt with width and precision specified # Test NULL handling of non string columns too (#2756) -def ogr_csv_11(): +def test_ogr_csv_11(): if gdaltest.csv_ds is None: return 'skip' @@ -498,7 +498,7 @@ def ogr_csv_11(): # Verify CREATE_CSVT=YES option -def ogr_csv_12(): +def test_ogr_csv_12(): if gdaltest.csv_ds is None: return 'skip' @@ -559,7 +559,7 @@ def ogr_csv_12(): # Verify GEOMETRY=AS_WKT,AS_XY,AS_XYZ,AS_YX options -def ogr_csv_13(): +def test_ogr_csv_13(): if gdaltest.csv_ds is None: return 'skip' @@ -729,7 +729,7 @@ def ogr_csv_13(): # Copy prime_meridian.csv again, with SEMICOLON as separator -def ogr_csv_14(): +def test_ogr_csv_14(): if gdaltest.csv_ds is None: return 'skip' @@ -748,7 +748,7 @@ def ogr_csv_14(): # -def ogr_csv_15(): +def test_ogr_csv_15(): if gdaltest.csv_ds is None: return 'skip' @@ -759,7 +759,7 @@ def ogr_csv_15(): # -def ogr_csv_16(): +def test_ogr_csv_16(): if gdaltest.csv_ds is None: return 'skip' @@ -774,7 +774,7 @@ def ogr_csv_16(): # -def ogr_csv_17(): +def test_ogr_csv_17(): if gdaltest.csv_ds is None: return 'skip' @@ -805,7 +805,7 @@ def ogr_csv_17(): ############################################################################### # Write to /vsistdout/ -def ogr_csv_18(): +def test_ogr_csv_18(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsistdout/') lyr = ds.CreateLayer('foo', options=['GEOMETRY=AS_WKT']) @@ -824,7 +824,7 @@ def ogr_csv_18(): # Verify handling of non-numeric values in numeric columns -def ogr_csv_19(): +def test_ogr_csv_19(): if gdaltest.csv_ds is None: return 'skip' @@ -860,7 +860,7 @@ def ogr_csv_19(): ############################################################################### # Verify handling of column names with numbers -def ogr_csv_20(): +def test_ogr_csv_20(): if gdaltest.csv_ds is None: return 'skip' @@ -913,7 +913,7 @@ def ogr_csv_20(): # Verify handling of numeric column names with quotes (bug #4361) -def ogr_csv_21(): +def test_ogr_csv_21(): if gdaltest.csv_ds is None: return 'skip' @@ -960,7 +960,7 @@ def ogr_csv_21(): ############################################################################### # Test handling of UTF8 BOM (bug #4623) -def ogr_csv_22(): +def test_ogr_csv_22(): ds = ogr.Open('data/csv_with_utf8_bom.csv') lyr = ds.GetLayer(0) @@ -974,7 +974,7 @@ def ogr_csv_22(): return 'success' -def ogr_csv_23(): +def test_ogr_csv_23(): # create a CSV file with UTF8 BOM ds = ogr.Open('tmp/csvwrk', update=1) lyr = ds.CreateLayer('utf8', options=['WRITE_BOM=YES', 'GEOMETRY=AS_WKT']) @@ -1028,7 +1028,7 @@ def ogr_csv_23(): # Test single column CSV files -def ogr_csv_24(): +def test_ogr_csv_24(): # Create an invalid CSV file f = gdal.VSIFOpenL('/vsimem/invalid.csv', 'wb') @@ -1071,7 +1071,7 @@ def ogr_csv_24(): ############################################################################### # Test newline handling (#4452) -def ogr_csv_25(): +def test_ogr_csv_25(): ds = ogr.Open('tmp/csvwrk', update=1) lyr = ds.CreateLayer('newlines', options=['LINEFORMAT=LF']) # just in case tests are run on windows... lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) @@ -1096,7 +1096,7 @@ def ogr_csv_25(): ############################################################################### # Test number padding behaviour (#4469) -def ogr_csv_26(): +def test_ogr_csv_26(): ds = ogr.Open('tmp/csvwrk', update=1) lyr = ds.CreateLayer('num_padding', options=['LINEFORMAT=LF']) # just in case tests are run on windows... @@ -1129,7 +1129,7 @@ def ogr_csv_26(): # Test Eurostat .TSV files -def ogr_csv_27(): +def test_ogr_csv_27(): ds = ogr.Open('data/test_eurostat.tsv') lyr = ds.GetLayer(0) @@ -1180,7 +1180,7 @@ def ogr_csv_27(): # Check that we don't rewrite erroneously a file that has no header (#5161). -def ogr_csv_28(): +def test_ogr_csv_28(): f = open('tmp/ogr_csv_28.csv', 'wb') f.write('1,2\n'.encode('ascii')) @@ -1206,7 +1206,7 @@ def ogr_csv_28(): # Check multi geometry field support -def ogr_csv_29(): +def test_ogr_csv_29(): ds = ogr.GetDriverByName('CSV').CreateDataSource('tmp/ogr_csv_29', options=['GEOMETRY=AS_WKT']) if ds.TestCapability(ogr.ODsCCurveGeometries) != 1: @@ -1265,7 +1265,7 @@ def ogr_csv_29(): # Run test_ogrsf -def ogr_csv_30(): +def test_ogr_csv_30(): import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is None: @@ -1283,7 +1283,7 @@ def ogr_csv_30(): # Read geonames.org allCountries.txt -def ogr_csv_31(): +def test_ogr_csv_31(): ds = ogr.Open('data/allCountries.txt') lyr = ds.GetLayer(0) @@ -1312,7 +1312,7 @@ def ogr_csv_31(): # Test AUTODETECT_TYPE=YES -def ogr_csv_32(): +def test_ogr_csv_32(): # Without limit, everything will be detected as string ds = gdal.OpenEx('data/testtypeautodetect.csv', gdal.OF_VECTOR, @@ -1525,7 +1525,7 @@ def ogr_csv_32(): # Test Boolean, Int16 and Float32 support -def ogr_csv_33(): +def test_ogr_csv_33(): ds = gdal.OpenEx('data/testtypeautodetectboolean.csv', gdal.OF_VECTOR, open_options=['AUTODETECT_TYPE=YES']) @@ -1595,7 +1595,7 @@ def ogr_csv_33(): # Test Integer64 support -def ogr_csv_34(): +def test_ogr_csv_34(): ds = gdal.OpenEx('data/testtypeautodetectinteger64.csv', gdal.OF_VECTOR, open_options=['AUTODETECT_TYPE=YES']) @@ -1646,7 +1646,7 @@ def ogr_csv_34(): # Test comma separator -def ogr_csv_35(): +def test_ogr_csv_35(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_35.csv', """FIELD_1 "FIELD 2" FIELD_3 @@ -1692,7 +1692,7 @@ def ogr_csv_35(): # Test GEOM_POSSIBLE_NAMES open option -def ogr_csv_36(): +def test_ogr_csv_36(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_36.csv', """id,mygeometry,format @@ -1797,7 +1797,7 @@ def ogr_csv_36(): # Test X_POSSIBLE_NAMES, Y_POSSIBLE_NAMES and Z_POSSIBLE_NAMES open options -def ogr_csv_37(): +def test_ogr_csv_37(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_37.csv', """id,y,other,x,z @@ -1869,7 +1869,7 @@ def ogr_csv_37(): # Test GeoCSV WKT type -def ogr_csv_38(): +def test_ogr_csv_38(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_38.csv') srs = osr.SpatialReference() @@ -1907,7 +1907,7 @@ def ogr_csv_38(): # Test GeoCSV CoordX and CoordY types -def ogr_csv_39(): +def test_ogr_csv_39(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_39.csv') lyr = ds.CreateLayer('ogr_csv_38', options=['GEOMETRY=AS_XY', 'CREATE_CSVT=YES']) @@ -1936,7 +1936,7 @@ def ogr_csv_39(): # Test X_POSSIBLE_NAMES, Y_POSSIBLE_NAMES, GEOM_POSSIBLE_NAMES and KEEP_GEOM_COLUMNS=NO together (#6137) -def ogr_csv_40(): +def test_ogr_csv_40(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_40.csv', """latitude,longitude,the_geom,id @@ -1980,7 +1980,7 @@ def ogr_csv_40(): # Test GEOM_POSSIBLE_NAMES and KEEP_GEOM_COLUMNS=NO together with empty content in geom column (#6152) -def ogr_csv_41(): +def test_ogr_csv_41(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_41.csv', """id,the_geom,foo @@ -2005,7 +2005,7 @@ def ogr_csv_41(): # Test writing field with empty content -def ogr_csv_42(): +def test_ogr_csv_42(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_42.csv') lyr = ds.CreateLayer('ogr_csv_42') @@ -2025,7 +2025,7 @@ def ogr_csv_42(): # Test editing capabilities -def ogr_csv_43(): +def test_ogr_csv_43(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_43.csv') lyr = ds.CreateLayer('ogr_csv_43', options=['GEOMETRY=AS_WKT', 'CREATE_CSVT=YES']) @@ -2324,7 +2324,7 @@ def ogr_csv_43(): # Test seeking back while creating -def ogr_csv_44(): +def test_ogr_csv_44(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_44.csv') lyr = ds.CreateLayer('ogr_csv_44', options=['GEOMETRY=AS_WKT']) @@ -2361,7 +2361,7 @@ def ogr_csv_44(): # CreateField() on the main dataset and assuming that file is already serialized. -def ogr_csv_45(): +def test_ogr_csv_45(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_45.csv') lyr = ds.CreateLayer('ogr_csv_45', options=['GEOMETRY=AS_WKT']) @@ -2387,7 +2387,7 @@ def ogr_csv_45(): # Test edition of CSV files with X_POSSIBLE_NAMES, Y_POSSIBLE_NAMES open options -def ogr_csv_46(): +def test_ogr_csv_46(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_46.csv') lyr = ds.CreateLayer('ogr_csv_46') @@ -2472,7 +2472,7 @@ def ogr_csv_46(): # Test writing XYZM -def ogr_csv_47(): +def test_ogr_csv_47(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_47.csv') if ds.TestCapability(ogr.ODsCMeasuredGeometries) != 1: @@ -2507,7 +2507,7 @@ def ogr_csv_47(): # Test reading/writing StringList, etc.. -def ogr_csv_48(): +def test_ogr_csv_48(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_48.csvt', 'JsonStringList,JsonIntegerList,JsonInteger64List,JsonRealList\n') gdal.FileFromMemBuffer('/vsimem/ogr_csv_48.csv', @@ -2546,7 +2546,7 @@ def ogr_csv_48(): # Test EMPTY_STRING_AS_NULL=ES -def ogr_csv_49(): +def test_ogr_csv_49(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_49.csv', """id,str 1, @@ -2568,7 +2568,7 @@ def ogr_csv_49(): ############################################################################### -def ogr_csv_more_than_100_geom_fields(): +def test_ogr_csv_more_than_100_geom_fields(): with gdaltest.error_handler(): ds = ogr.Open('data/more_than_100_geom_fields.csv') @@ -2580,7 +2580,7 @@ def ogr_csv_more_than_100_geom_fields(): ############################################################################### -def ogr_csv_string_quoting_always(): +def test_ogr_csv_string_quoting_always(): gdal.VectorTranslate('/vsimem/ogr_csv_string_quoting_always.csv', 'data/poly.shp', format='CSV', @@ -2620,7 +2620,7 @@ def ogr_csv_string_quoting_always(): ############################################################################### -def ogr_csv_string_quoting_if_ambiguous(): +def test_ogr_csv_string_quoting_if_ambiguous(): src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0, gdal.GDT_Unknown) lyr = src_ds.CreateLayer('layer') @@ -2652,7 +2652,7 @@ def ogr_csv_string_quoting_if_ambiguous(): ############################################################################### -def ogr_csv_string_quoting_if_needed(): +def test_ogr_csv_string_quoting_if_needed(): src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0, gdal.GDT_Unknown) lyr = src_ds.CreateLayer('layer') @@ -2685,7 +2685,7 @@ def ogr_csv_string_quoting_if_needed(): ############################################################################### -def ogr_csv_iter_and_set_feature(): +def test_ogr_csv_iter_and_set_feature(): gdal.FileFromMemBuffer('/vsimem/ogr_csv_iter_and_set_feature.csv', """id,str 1, @@ -2713,7 +2713,7 @@ def ogr_csv_iter_and_set_feature(): # -def ogr_csv_cleanup(): +def test_ogr_csv_cleanup(): if gdaltest.csv_ds is None: return 'skip' @@ -2742,62 +2742,62 @@ def ogr_csv_cleanup(): gdaltest_list = [ - ogr_csv_1, - ogr_csv_2, - ogr_csv_3, - ogr_csv_4, - ogr_csv_5, - ogr_csv_6, - ogr_csv_6, - ogr_csv_7, - ogr_csv_8, - ogr_csv_9, - ogr_csv_10, - ogr_csv_11, - ogr_csv_12, - ogr_csv_13, - ogr_csv_14, - ogr_csv_15, - ogr_csv_16, - ogr_csv_17, - ogr_csv_18, - ogr_csv_19, - ogr_csv_20, - ogr_csv_21, - ogr_csv_22, - ogr_csv_23, - ogr_csv_24, - ogr_csv_25, - ogr_csv_26, - ogr_csv_27, - ogr_csv_28, - ogr_csv_29, - ogr_csv_30, - ogr_csv_31, - ogr_csv_32, - ogr_csv_33, - ogr_csv_34, - ogr_csv_35, - ogr_csv_36, - ogr_csv_37, - ogr_csv_38, - ogr_csv_39, - ogr_csv_40, - ogr_csv_41, - ogr_csv_42, - ogr_csv_43, - ogr_csv_44, - ogr_csv_45, - ogr_csv_46, - ogr_csv_47, - ogr_csv_48, - ogr_csv_49, - ogr_csv_more_than_100_geom_fields, - ogr_csv_string_quoting_always, - ogr_csv_string_quoting_if_ambiguous, - ogr_csv_string_quoting_if_needed, - ogr_csv_iter_and_set_feature, - ogr_csv_cleanup] + test_ogr_csv_1, + test_ogr_csv_2, + test_ogr_csv_3, + test_ogr_csv_4, + test_ogr_csv_5, + test_ogr_csv_6, + test_ogr_csv_6, + test_ogr_csv_7, + test_ogr_csv_8, + test_ogr_csv_9, + test_ogr_csv_10, + test_ogr_csv_11, + test_ogr_csv_12, + test_ogr_csv_13, + test_ogr_csv_14, + test_ogr_csv_15, + test_ogr_csv_16, + test_ogr_csv_17, + test_ogr_csv_18, + test_ogr_csv_19, + test_ogr_csv_20, + test_ogr_csv_21, + test_ogr_csv_22, + test_ogr_csv_23, + test_ogr_csv_24, + test_ogr_csv_25, + test_ogr_csv_26, + test_ogr_csv_27, + test_ogr_csv_28, + test_ogr_csv_29, + test_ogr_csv_30, + test_ogr_csv_31, + test_ogr_csv_32, + test_ogr_csv_33, + test_ogr_csv_34, + test_ogr_csv_35, + test_ogr_csv_36, + test_ogr_csv_37, + test_ogr_csv_38, + test_ogr_csv_39, + test_ogr_csv_40, + test_ogr_csv_41, + test_ogr_csv_42, + test_ogr_csv_43, + test_ogr_csv_44, + test_ogr_csv_45, + test_ogr_csv_46, + test_ogr_csv_47, + test_ogr_csv_48, + test_ogr_csv_49, + test_ogr_csv_more_than_100_geom_fields, + test_ogr_csv_string_quoting_always, + test_ogr_csv_string_quoting_if_ambiguous, + test_ogr_csv_string_quoting_if_needed, + test_ogr_csv_iter_and_set_feature, + test_ogr_csv_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_csw.py b/autotest/ogr/ogr_csw.py index 4a1ff2cc8417..7b8178072cb7 100755 --- a/autotest/ogr/ogr_csw.py +++ b/autotest/ogr/ogr_csw.py @@ -82,7 +82,7 @@ def test_ogr_csw_pycsw(): ############################################################################### -def ogr_csw_vsimem_fail_because_not_enabled(): +def test_ogr_csw_vsimem_fail_because_not_enabled(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() @@ -93,7 +93,7 @@ def ogr_csw_vsimem_fail_because_not_enabled(): ############################################################################### -def ogr_csw_vsimem_fail_because_no_get_capabilities(): +def test_ogr_csw_vsimem_fail_because_no_get_capabilities(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.PushErrorHandler() @@ -107,7 +107,7 @@ def ogr_csw_vsimem_fail_because_no_get_capabilities(): ############################################################################### -def ogr_csw_vsimem_fail_because_empty_response(): +def test_ogr_csw_vsimem_fail_because_empty_response(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -128,7 +128,7 @@ def ogr_csw_vsimem_fail_because_empty_response(): ############################################################################### -def ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): +def test_ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -149,7 +149,7 @@ def ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): ############################################################################### -def ogr_csw_vsimem_fail_because_exception(): +def test_ogr_csw_vsimem_fail_because_exception(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -170,7 +170,7 @@ def ogr_csw_vsimem_fail_because_exception(): ############################################################################### -def ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): +def test_ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -191,7 +191,7 @@ def ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): ############################################################################### -def ogr_csw_vsimem_fail_because_missing_version(): +def test_ogr_csw_vsimem_fail_because_missing_version(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') gdal.FileFromMemBuffer('/vsimem/csw_endpoint?SERVICE=CSW&REQUEST=GetCapabilities', @@ -214,7 +214,7 @@ def ogr_csw_vsimem_fail_because_missing_version(): ############################################################################### -def ogr_csw_vsimem_csw_minimal_instance(): +def test_ogr_csw_vsimem_csw_minimal_instance(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', 'YES') # Invalid response, but enough for use @@ -533,7 +533,7 @@ def ogr_csw_vsimem_csw_minimal_instance(): ############################################################################### -def ogr_csw_vsimem_csw_output_schema_csw(): +def test_ogr_csw_vsimem_csw_output_schema_csw(): ds = gdal.OpenEx('CSW:/vsimem/csw_endpoint', open_options=['OUTPUT_SCHEMA=CSW']) lyr = ds.GetLayer(0) @@ -594,7 +594,7 @@ def ogr_csw_vsimem_csw_output_schema_csw(): ############################################################################### -def ogr_csw_vsimem_csw_output_schema_gmd(): +def test_ogr_csw_vsimem_csw_output_schema_gmd(): ds = gdal.OpenEx('CSW:/vsimem/csw_endpoint', open_options=['OUTPUT_SCHEMA=GMD']) lyr = ds.GetLayer(0) @@ -636,7 +636,7 @@ def ogr_csw_vsimem_csw_output_schema_gmd(): ############################################################################### -def ogr_csw_vsimem_csw_output_schema_fgdc(): +def test_ogr_csw_vsimem_csw_output_schema_fgdc(): ds = gdal.OpenEx('CSW:/vsimem/csw_endpoint', open_options=['OUTPUT_SCHEMA=http://www.opengis.net/cat/csw/csdgm']) lyr = ds.GetLayer(0) @@ -680,7 +680,7 @@ def ogr_csw_vsimem_csw_output_schema_fgdc(): ############################################################################### -def ogr_csw_vsimem_cleanup(): +def test_ogr_csw_vsimem_cleanup(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', None) for f in gdal.ReadDir('/vsimem/'): @@ -690,18 +690,18 @@ def ogr_csw_vsimem_cleanup(): gdaltest_list = [ - ogr_csw_vsimem_fail_because_not_enabled, - ogr_csw_vsimem_fail_because_no_get_capabilities, - ogr_csw_vsimem_fail_because_empty_response, - ogr_csw_vsimem_fail_because_no_CSW_Capabilities, - ogr_csw_vsimem_fail_because_exception, - ogr_csw_vsimem_fail_because_invalid_xml_capabilities, - ogr_csw_vsimem_fail_because_missing_version, - ogr_csw_vsimem_csw_minimal_instance, - ogr_csw_vsimem_csw_output_schema_csw, - ogr_csw_vsimem_csw_output_schema_gmd, - ogr_csw_vsimem_csw_output_schema_fgdc, - ogr_csw_vsimem_cleanup, + test_ogr_csw_vsimem_fail_because_not_enabled, + test_ogr_csw_vsimem_fail_because_no_get_capabilities, + test_ogr_csw_vsimem_fail_because_empty_response, + test_ogr_csw_vsimem_fail_because_no_CSW_Capabilities, + test_ogr_csw_vsimem_fail_because_exception, + test_ogr_csw_vsimem_fail_because_invalid_xml_capabilities, + test_ogr_csw_vsimem_fail_because_missing_version, + test_ogr_csw_vsimem_csw_minimal_instance, + test_ogr_csw_vsimem_csw_output_schema_csw, + test_ogr_csw_vsimem_csw_output_schema_gmd, + test_ogr_csw_vsimem_csw_output_schema_fgdc, + test_ogr_csw_vsimem_cleanup, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_db2.py b/autotest/ogr/ogr_db2.py index 89aeda7206a0..e20cd2d56002 100755 --- a/autotest/ogr/ogr_db2.py +++ b/autotest/ogr/ogr_db2.py @@ -50,7 +50,7 @@ # Test if driver is available -def ogr_db2_check_driver(): +def test_ogr_db2_check_driver(): ogrtest.db2_drv = None @@ -65,7 +65,7 @@ def ogr_db2_check_driver(): # Test if environment variable for DB2 connection is set and we can connect -def ogr_db2_init(): +def test_ogr_db2_init(): if ogrtest.db2_drv is None: return 'skip' @@ -82,7 +82,7 @@ def ogr_db2_init(): # Test GetFeatureCount() -def ogr_db2_GetFeatureCount(): +def test_ogr_db2_GetFeatureCount(): if ogrtest.db2_drv is None: return 'skip' @@ -108,7 +108,7 @@ def ogr_db2_GetFeatureCount(): # Test GetSpatialRef() -def ogr_db2_GetSpatialRef(): +def test_ogr_db2_GetSpatialRef(): if ogrtest.db2_drv is None: return 'skip' @@ -141,7 +141,7 @@ def ogr_db2_GetSpatialRef(): ############################################################################### # Test GetExtent() -def ogr_db2_GetExtent(): +def test_ogr_db2_GetExtent(): if ogrtest.db2_drv is None: return 'skip' @@ -172,7 +172,7 @@ def ogr_db2_GetExtent(): # Test GetFeature() -def ogr_db2_GetFeature(): +def test_ogr_db2_GetFeature(): if ogrtest.db2_drv is None: return 'skip' @@ -203,7 +203,7 @@ def ogr_db2_GetFeature(): # Test SetSpatialFilter() -def ogr_db2_SetSpatialFilter(): +def test_ogr_db2_SetSpatialFilter(): if ogrtest.db2_drv is None: return 'skip' @@ -268,7 +268,7 @@ def ogr_db2_SetSpatialFilter(): # -def ogr_db2_capabilities(): +def test_ogr_db2_capabilities(): if ogrtest.db2_drv is None: return 'skip' @@ -323,15 +323,15 @@ def ogr_db2_listdrivers(): gdaltest_list = [ - ogr_db2_check_driver, - ogr_db2_init, + test_ogr_db2_check_driver, + test_ogr_db2_init, # ogr_db2_listdrivers, - ogr_db2_GetSpatialRef, - ogr_db2_GetExtent, - ogr_db2_GetFeature, - ogr_db2_SetSpatialFilter, - ogr_db2_capabilities, - ogr_db2_GetFeatureCount + test_ogr_db2_GetSpatialRef, + test_ogr_db2_GetExtent, + test_ogr_db2_GetFeature, + test_ogr_db2_SetSpatialFilter, + test_ogr_db2_capabilities, + test_ogr_db2_GetFeatureCount ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_db2_hack.py b/autotest/ogr/ogr_db2_hack.py index d8c8582d6779..c7e9ea7cffe7 100755 --- a/autotest/ogr/ogr_db2_hack.py +++ b/autotest/ogr/ogr_db2_hack.py @@ -37,7 +37,7 @@ # Create a point in DB2 format, and verify the byte order flag. -def ogr_db2_hack_1(): +def test_ogr_db2_hack_1(): if ogr.SetGenerate_DB2_V72_BYTE_ORDER(1) != 0: return 'skip' @@ -66,7 +66,7 @@ def ogr_db2_hack_1(): # Verify that we can turn DB2 V7.2 mode back off! -def ogr_db2_hack_2(): +def test_ogr_db2_hack_2(): if ogr.SetGenerate_DB2_V72_BYTE_ORDER(0) != 0: gdaltest.post_reason('SetGenerate to turn off hack failed!') @@ -96,7 +96,7 @@ def ogr_db2_hack_2(): ############################################################################### # Try a more complex geometry, and verify we can read it back. -def ogr_db2_hack_3(): +def test_ogr_db2_hack_3(): if ogr.SetGenerate_DB2_V72_BYTE_ORDER(1) != 0: return 'skip' @@ -131,9 +131,9 @@ def ogr_db2_hack_3(): gdaltest_list = [ - ogr_db2_hack_1, - ogr_db2_hack_2, - ogr_db2_hack_3 + test_ogr_db2_hack_1, + test_ogr_db2_hack_2, + test_ogr_db2_hack_3 ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_dgn.py b/autotest/ogr/ogr_dgn.py index 8f15a639ec11..e8c71e280254 100755 --- a/autotest/ogr/ogr_dgn.py +++ b/autotest/ogr/ogr_dgn.py @@ -36,7 +36,7 @@ # Verify we can open the test file. -def ogr_dgn_1(): +def test_ogr_dgn_1(): gdaltest.dgn_ds = ogr.Open('data/smalltest.dgn') if gdaltest.dgn_ds is None: @@ -51,7 +51,7 @@ def ogr_dgn_1(): # Check first feature, a text element. -def ogr_dgn_2(): +def test_ogr_dgn_2(): if gdaltest.dgn_ds is None: return 'skip' @@ -77,7 +77,7 @@ def ogr_dgn_2(): # Check second feature, a circle. -def ogr_dgn_3(): +def test_ogr_dgn_3(): if gdaltest.dgn_ds is None: return 'skip' @@ -113,7 +113,7 @@ def ogr_dgn_3(): # Check third feature, a polygon with fill styling. -def ogr_dgn_4(): +def test_ogr_dgn_4(): if gdaltest.dgn_ds is None: return 'skip' @@ -140,7 +140,7 @@ def ogr_dgn_4(): # Use attribute query to pick just the type 15 level 2 object. -def ogr_dgn_5(): +def test_ogr_dgn_5(): if gdaltest.dgn_ds is None: return 'skip' @@ -155,7 +155,7 @@ def ogr_dgn_5(): # Use spatial filter to just pick the big circle. -def ogr_dgn_6(): +def test_ogr_dgn_6(): if gdaltest.dgn_ds is None: return 'skip' @@ -173,7 +173,7 @@ def ogr_dgn_6(): # Copy our small dgn file to a new dgn file. -def ogr_dgn_7(): +def test_ogr_dgn_7(): if gdaltest.dgn_ds is None: return 'skip' @@ -212,7 +212,7 @@ def ogr_dgn_7(): # -def ogr_dgn_8(): +def test_ogr_dgn_8(): if gdaltest.dgn_ds is None: return 'skip' @@ -289,7 +289,7 @@ def ogr_dgn_8(): # Test delta encoding (#6806) -def ogr_dgn_online_1(): +def test_ogr_dgn_online_1(): if not gdaltest.download_file('http://download.osgeo.org/gdal/data/dgn/DGNSample_v7.dgn', 'DGNSample_v7.dgn'): return 'skip' @@ -310,7 +310,7 @@ def ogr_dgn_online_1(): # Cleanup -def ogr_dgn_cleanup(): +def test_ogr_dgn_cleanup(): if gdaltest.dgn_ds is not None: gdaltest.dgn_lyr = None @@ -321,16 +321,16 @@ def ogr_dgn_cleanup(): gdaltest_list = [ - ogr_dgn_1, - ogr_dgn_2, - ogr_dgn_3, - ogr_dgn_4, - ogr_dgn_5, - ogr_dgn_6, - ogr_dgn_7, - ogr_dgn_8, - ogr_dgn_online_1, - ogr_dgn_cleanup] + test_ogr_dgn_1, + test_ogr_dgn_2, + test_ogr_dgn_3, + test_ogr_dgn_4, + test_ogr_dgn_5, + test_ogr_dgn_6, + test_ogr_dgn_7, + test_ogr_dgn_8, + test_ogr_dgn_online_1, + test_ogr_dgn_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_dgnv8.py b/autotest/ogr/ogr_dgnv8.py index 7d47fa8c5c93..9db0b393b787 100755 --- a/autotest/ogr/ogr_dgnv8.py +++ b/autotest/ogr/ogr_dgnv8.py @@ -41,7 +41,7 @@ # Verify we can open the test file. -def ogr_dgnv8_1(): +def test_ogr_dgnv8_1(): gdaltest.dgnv8_drv = ogr.GetDriverByName('DGNv8') if gdaltest.dgnv8_drv is None: @@ -58,7 +58,7 @@ def ogr_dgnv8_1(): # Compare with a reference CSV dump -def ogr_dgnv8_2(): +def test_ogr_dgnv8_2(): if gdaltest.dgnv8_drv is None: return 'skip' @@ -80,7 +80,7 @@ def ogr_dgnv8_2(): # Run test_ogrsf -def ogr_dgnv8_3(): +def test_ogr_dgnv8_3(): if gdaltest.dgnv8_drv is None: return 'skip' @@ -111,7 +111,7 @@ def ogr_dgnv8_3(): # Test creation code -def ogr_dgnv8_4(): +def test_ogr_dgnv8_4(): if gdaltest.dgnv8_drv is None: return 'skip' @@ -138,7 +138,7 @@ def ogr_dgnv8_4(): # Test creation options -def ogr_dgnv8_5(): +def test_ogr_dgnv8_5(): if gdaltest.dgnv8_drv is None: return 'skip' @@ -220,18 +220,18 @@ def ogr_dgnv8_5(): ############################################################################### # Cleanup -def ogr_dgnv8_cleanup(): +def test_ogr_dgnv8_cleanup(): return 'success' gdaltest_list = [ - ogr_dgnv8_1, - ogr_dgnv8_2, - ogr_dgnv8_3, - ogr_dgnv8_4, - ogr_dgnv8_5, - ogr_dgnv8_cleanup] + test_ogr_dgnv8_1, + test_ogr_dgnv8_2, + test_ogr_dgnv8_3, + test_ogr_dgnv8_4, + test_ogr_dgnv8_5, + test_ogr_dgnv8_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_dxf.py b/autotest/ogr/ogr_dxf.py index c415d7aa9e22..d77abfd56af2 100644 --- a/autotest/ogr/ogr_dxf.py +++ b/autotest/ogr/ogr_dxf.py @@ -44,7 +44,7 @@ # Check some general things to see if they meet expectations. -def ogr_dxf_1(): +def test_ogr_dxf_1(): gdaltest.dxf_ds = ogr.Open('data/assorted.dxf') @@ -91,7 +91,7 @@ def ogr_dxf_1(): # Read the first feature, an ellipse and see if it generally meets expectations. -def ogr_dxf_2(): +def test_ogr_dxf_2(): gdaltest.dxf_layer.ResetReading() @@ -150,7 +150,7 @@ def ogr_dxf_2(): # Second feature should be a partial ellipse. -def ogr_dxf_3(): +def test_ogr_dxf_3(): feat = gdaltest.dxf_layer.GetNextFeature() @@ -175,7 +175,7 @@ def ogr_dxf_3(): # Third feature: point. -def ogr_dxf_4(): +def test_ogr_dxf_4(): feat = gdaltest.dxf_layer.GetNextFeature() @@ -188,7 +188,7 @@ def ogr_dxf_4(): # Fourth feature: LINE -def ogr_dxf_5(): +def test_ogr_dxf_5(): feat = gdaltest.dxf_layer.GetNextFeature() @@ -205,7 +205,7 @@ def ogr_dxf_5(): # Fourth feature: MTEXT -def ogr_dxf_6(): +def test_ogr_dxf_6(): feat = gdaltest.dxf_layer.GetNextFeature() @@ -227,7 +227,7 @@ def ogr_dxf_6(): # Partial CIRCLE -def ogr_dxf_7(): +def test_ogr_dxf_7(): feat = gdaltest.dxf_layer.GetNextFeature() @@ -253,7 +253,7 @@ def ogr_dxf_7(): # PaperSpace and dimension -def ogr_dxf_8(): +def test_ogr_dxf_8(): # Check that this line is in PaperSpace feat = gdaltest.dxf_layer.GetNextFeature() @@ -312,7 +312,7 @@ def ogr_dxf_8(): # BLOCK (inlined) -def ogr_dxf_9(): +def test_ogr_dxf_9(): # Skip two dimensions each with a line, two arrowheads and text. for _ in range(8): @@ -362,7 +362,7 @@ def ogr_dxf_9(): # LWPOLYLINE in an Object Coordinate System. -def ogr_dxf_10(): +def test_ogr_dxf_10(): ocs_ds = ogr.Open('data/LWPOLYLINE-OCS.dxf') ocs_lyr = ocs_ds.GetLayer(0) @@ -398,7 +398,7 @@ def ogr_dxf_10(): # Test reading from an entities-only dxf file (#3412) -def ogr_dxf_11(): +def test_ogr_dxf_11(): eo_ds = ogr.Open('data/entities_only.dxf') eo_lyr = eo_ds.GetLayer(0) @@ -426,7 +426,7 @@ def ogr_dxf_11(): # Write a simple file with a polygon and a line, and read back. -def ogr_dxf_12(): +def test_ogr_dxf_12(): ds = ogr.GetDriverByName('DXF').CreateDataSource('tmp/dxf_11.dxf') @@ -517,7 +517,7 @@ def ogr_dxf_12(): ############################################################################### # Check smoothed polyline. -def ogr_dxf_13(): +def test_ogr_dxf_13(): ds = ogr.Open('data/polyline_smooth.dxf') @@ -577,7 +577,7 @@ def ogr_dxf_13(): ############################################################################### # Check smooth LWPOLYLINE entity. -def ogr_dxf_14(): +def test_ogr_dxf_14(): # This test is identical to the previous one except the # newer lwpolyline entity is used. See the comments in the @@ -626,7 +626,7 @@ def ogr_dxf_14(): # layer '0'. -def ogr_dxf_15(): +def test_ogr_dxf_15(): ds = ogr.GetDriverByName('DXF').CreateDataSource('tmp/dxf_14.dxf', ['FIRST_ENTITY=80']) @@ -720,7 +720,7 @@ def ogr_dxf_15(): ############################################################################### # Test reading without DXF blocks inlined. -def ogr_dxf_16(): +def test_ogr_dxf_16(): gdal.SetConfigOption('DXF_INLINE_BLOCKS', 'FALSE') @@ -820,7 +820,7 @@ def ogr_dxf_16(): # Write a file with blocks defined from a source blocks layer. -def ogr_dxf_17(): +def test_ogr_dxf_17(): ds = ogr.GetDriverByName('DXF').CreateDataSource('tmp/dxf_17.dxf', ['HEADER=data/header_extended.dxf']) @@ -966,7 +966,7 @@ def ogr_dxf_17(): # created. -def ogr_dxf_18(): +def test_ogr_dxf_18(): ds = ogr.GetDriverByName('DXF').CreateDataSource('tmp/dxf_18.dxf', ['HEADER=data/header_extended.dxf']) @@ -1092,7 +1092,7 @@ def ogr_dxf_18(): # template - no blocks layer transferred. -def ogr_dxf_19(): +def test_ogr_dxf_19(): ds = ogr.GetDriverByName('DXF').CreateDataSource('tmp/dxf_19.dxf', ['HEADER=data/header_extended.dxf']) @@ -1136,7 +1136,7 @@ def ogr_dxf_19(): # SPLINE -def ogr_dxf_20(): +def test_ogr_dxf_20(): ds = ogr.Open('data/spline_qcad.dxf') lyr = ds.GetLayer(0) @@ -1153,7 +1153,7 @@ def ogr_dxf_20(): # CIRCLE -def ogr_dxf_21(): +def test_ogr_dxf_21(): ds = ogr.Open('data/circle.dxf') lyr = ds.GetLayer(0) @@ -1170,7 +1170,7 @@ def ogr_dxf_21(): ############################################################################### # TEXT -def ogr_dxf_22(): +def test_ogr_dxf_22(): # Read MTEXT feature ds = ogr.Open('data/text.dxf') @@ -1255,7 +1255,7 @@ def ogr_dxf_22(): ############################################################################### # POLYGON with hole -def ogr_dxf_23(): +def test_ogr_dxf_23(): # Write polygon out_ds = ogr.GetDriverByName('DXF').CreateDataSource('/vsimem/ogr_dxf_23.dxf') @@ -1295,7 +1295,7 @@ def ogr_dxf_23(): # HATCH -def ogr_dxf_24(): +def test_ogr_dxf_24(): ds = ogr.Open('data/hatch.dxf') lyr = ds.GetLayer(0) @@ -1323,7 +1323,7 @@ def ogr_dxf_24(): # 3DFACE -def ogr_dxf_25(): +def test_ogr_dxf_25(): ds = ogr.Open('data/3dface.dxf') lyr = ds.GetLayer(0) @@ -1346,7 +1346,7 @@ def ogr_dxf_25(): # SOLID (#5380) -def ogr_dxf_26(): +def test_ogr_dxf_26(): ds = ogr.Open('data/solid.dxf') lyr = ds.GetLayer(0) @@ -1364,7 +1364,7 @@ def ogr_dxf_26(): # Test reading a DXF file without .dxf extensions (#5994) -def ogr_dxf_27(): +def test_ogr_dxf_27(): gdal.FileFromMemBuffer('/vsimem/a_dxf_without_extension', open('data/solid.dxf').read()) @@ -1380,7 +1380,7 @@ def ogr_dxf_27(): # Test reading a ELLIPSE with Z extrusion axis value of -1.0 (#5075) -def ogr_dxf_28(): +def test_ogr_dxf_28(): ds = ogr.Open('data/ellipse_z_extrusion_minus_1.dxf') lyr = ds.GetLayer(0) @@ -1403,7 +1403,7 @@ def ogr_dxf_28(): # SPLINE with weights -def ogr_dxf_29(): +def test_ogr_dxf_29(): ds = ogr.Open('data/spline_weight.dxf') lyr = ds.GetLayer(0) @@ -1434,7 +1434,7 @@ def ogr_dxf_29(): # SPLINE closed -def ogr_dxf_30(): +def test_ogr_dxf_30(): ds = ogr.Open('data/spline_closed.dxf') lyr = ds.GetLayer(0) @@ -1459,7 +1459,7 @@ def ogr_dxf_30(): # OCS2WCS transformations 1 -def ogr_dxf_31(): +def test_ogr_dxf_31(): ds = ogr.Open('data/ocs2wcs1.dxf') lyr = ds.GetLayer(0) @@ -1899,7 +1899,7 @@ def ogr_dxf_31(): # OCS2WCS transformations 2. Also test RawCodeValues -def ogr_dxf_32(): +def test_ogr_dxf_32(): gdal.SetConfigOption('DXF_INCLUDE_RAW_CODE_VALUES', 'TRUE') ds = ogr.Open('data/ocs2wcs2.dxf') @@ -2472,7 +2472,7 @@ def ogr_dxf_32(): # Test 3D entities (polyface mesh, cylinder, 3D solid) -def ogr_dxf_33(): +def test_ogr_dxf_33(): gdal.SetConfigOption('DXF_3D_EXTENSIBLE_MODE', 'TRUE') ds = ogr.Open('data/3d.dxf') @@ -2567,7 +2567,7 @@ def ogr_dxf_33(): # Writing Triangle geometry and checking if it is written properly -def ogr_dxf_34(): +def test_ogr_dxf_34(): ds = ogr.GetDriverByName('DXF').CreateDataSource('tmp/triangle_test.dxf') lyr = ds.CreateLayer('entities') dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn()) @@ -2602,7 +2602,7 @@ def ogr_dxf_34(): # Test reading hatch with elliptical harts -def ogr_dxf_35(): +def test_ogr_dxf_35(): ds = ogr.Open('data/elliptical-arc-hatch-min.dxf') lyr = ds.GetLayer(0) @@ -2710,7 +2710,7 @@ def ogr_dxf_35(): # Test reading files with only INSERT content (#7006) -def ogr_dxf_36(): +def test_ogr_dxf_36(): gdal.SetConfigOption('DXF_MERGE_BLOCK_GEOMETRIES', 'FALSE') ds = ogr.Open('data/insert_only.dxf') @@ -2725,7 +2725,7 @@ def ogr_dxf_36(): # Create a blocks layer only -def ogr_dxf_37(): +def test_ogr_dxf_37(): ds = ogr.GetDriverByName('DXF').CreateDataSource('/vsimem/ogr_dxf_37.dxf') @@ -2759,7 +2759,7 @@ def ogr_dxf_37(): # Test degenerated cases of SOLID (#7038) -def ogr_dxf_38(): +def test_ogr_dxf_38(): ds = ogr.Open('data/solid-less-than-4-vertices.dxf') lyr = ds.GetLayer(0) @@ -2783,7 +2783,7 @@ def ogr_dxf_38(): # Test correct reordering of vertices in SOLID (#7038, #7089) -def ogr_dxf_39(): +def test_ogr_dxf_39(): ds = ogr.Open('data/solid-vertex-ordering.dxf') lyr = ds.GetLayer(0) @@ -2806,7 +2806,7 @@ def ogr_dxf_39(): # Test handing of OCS vs WCS for MTEXT (#7049) -def ogr_dxf_40(): +def test_ogr_dxf_40(): ds = ogr.Open('data/mtext-ocs-reduced.dxf') lyr = ds.GetLayer(0) @@ -2822,7 +2822,7 @@ def ogr_dxf_40(): # Test handing of OCS vs WCS for SOLID, HATCH and INSERT (#7077, #7098) -def ogr_dxf_41(): +def test_ogr_dxf_41(): ds = ogr.Open('data/ocs2wcs3.dxf') lyr = ds.GetLayer(0) @@ -2923,7 +2923,7 @@ def ogr_dxf_41(): # Test insertion of blocks within blocks (#7106) -def ogr_dxf_42(): +def test_ogr_dxf_42(): # Inlining, merging ds = ogr.Open('data/block-insert-order.dxf') @@ -3006,7 +3006,7 @@ def ogr_dxf_42(): # Ensure recursively-included blocks don't fail badly -def ogr_dxf_43(): +def test_ogr_dxf_43(): ds = ogr.Open('data/insert-recursive-pair.dxf') lyr = ds.GetLayer(0) @@ -3019,7 +3019,7 @@ def ogr_dxf_43(): # General tests of LEADER and MULTILEADER entities (#7111) -def ogr_dxf_44(): +def test_ogr_dxf_44(): with gdaltest.config_option('DXF_MAX_BSPLINE_CONTROL_POINTS', '1'): ds = ogr.Open('data/leader-mleader.dxf') @@ -3274,7 +3274,7 @@ def ogr_dxf_44(): # Test linetype scaling (#7129) and parsing of complex linetypes (#7134) -def ogr_dxf_45(): +def test_ogr_dxf_45(): ds = ogr.Open('data/linetypes.dxf') lyr = ds.GetLayer(0) @@ -3325,7 +3325,7 @@ def ogr_dxf_45(): # Test handling of DIMENSION anonymous block insertion (#7120) -def ogr_dxf_46(): +def test_ogr_dxf_46(): ds = ogr.Open('data/dimension.dxf') lyr = ds.GetLayer(0) @@ -3383,7 +3383,7 @@ def ogr_dxf_46(): # Test handling of DIMENSION fallback when there is no anonymous block (#7120) -def ogr_dxf_47(): +def test_ogr_dxf_47(): ds = ogr.Open('data/dimension-entities-only.dxf') lyr = ds.GetLayer(0) @@ -3490,7 +3490,7 @@ def ogr_dxf_47(): # Test ByLayer and ByBlock color values (#7130) -def ogr_dxf_48(): +def test_ogr_dxf_48(): gdal.SetConfigOption('DXF_MERGE_BLOCK_GEOMETRIES', 'FALSE') ds = ogr.Open('data/byblock-bylayer.dxf') @@ -3593,7 +3593,7 @@ def ogr_dxf_48(): # Test block attributes (ATTRIB entities) (#7139) -def ogr_dxf_49(): +def test_ogr_dxf_49(): # Inline blocks mode ds = ogr.Open('data/attrib.dxf') @@ -3663,7 +3663,7 @@ def ogr_dxf_49(): # Test extended text styling (#7151) and additional ByBlock/ByLayer tests (#7130) -def ogr_dxf_50(): +def test_ogr_dxf_50(): gdal.SetConfigOption('DXF_MERGE_BLOCK_GEOMETRIES', 'FALSE') ds = ogr.Open('data/text-fancy.dxf') @@ -3722,7 +3722,7 @@ def ogr_dxf_50(): # Test transformation of text inside blocks (ACAdjustText function) -def ogr_dxf_51(): +def test_ogr_dxf_51(): ds = ogr.Open('data/text-block-transform.dxf') @@ -3750,7 +3750,7 @@ def ogr_dxf_51(): # Test HELIX, TRACE, HATCH with spline boundary, MLINE, and INSERT with rows/columns -def ogr_dxf_52(): +def test_ogr_dxf_52(): ds = ogr.Open('data/additional-entities.dxf') lyr = ds.GetLayer(0) @@ -3868,7 +3868,7 @@ def ogr_dxf_52(): # Test block base points -def ogr_dxf_53(): +def test_ogr_dxf_53(): ds = ogr.Open('data/block-basepoint.dxf') lyr = ds.GetLayer(0) @@ -3883,7 +3883,7 @@ def ogr_dxf_53(): ############################################################################### -def ogr_dxf_insert_too_many_errors(): +def test_ogr_dxf_insert_too_many_errors(): with gdaltest.error_handler(): ogr.Open('data/insert-too-many-errors.dxf') @@ -3894,7 +3894,7 @@ def ogr_dxf_insert_too_many_errors(): ############################################################################### -def ogr_dxf_write_geometry_collection_of_unsupported_type(): +def test_ogr_dxf_write_geometry_collection_of_unsupported_type(): tmpfile = '/vsimem/ogr_dxf_write_geometry_collection_of_unsupported_type.dxf' @@ -3915,7 +3915,7 @@ def ogr_dxf_write_geometry_collection_of_unsupported_type(): # cleanup -def ogr_dxf_cleanup(): +def test_ogr_dxf_cleanup(): gdaltest.dxf_layer = None gdaltest.dxf_ds = None @@ -3926,62 +3926,62 @@ def ogr_dxf_cleanup(): gdaltest_list = [ - ogr_dxf_1, - ogr_dxf_2, - ogr_dxf_3, - ogr_dxf_4, - ogr_dxf_5, - ogr_dxf_6, - ogr_dxf_7, - ogr_dxf_8, - ogr_dxf_9, - ogr_dxf_10, - ogr_dxf_11, - ogr_dxf_12, - ogr_dxf_13, - ogr_dxf_14, - ogr_dxf_15, - ogr_dxf_16, - ogr_dxf_17, - ogr_dxf_18, - ogr_dxf_19, - ogr_dxf_20, - ogr_dxf_21, - ogr_dxf_22, - ogr_dxf_23, - ogr_dxf_24, - ogr_dxf_25, - ogr_dxf_26, - ogr_dxf_27, - ogr_dxf_28, - ogr_dxf_29, - ogr_dxf_30, - ogr_dxf_31, - ogr_dxf_32, - ogr_dxf_33, - ogr_dxf_34, - ogr_dxf_35, - ogr_dxf_36, - ogr_dxf_37, - ogr_dxf_38, - ogr_dxf_39, - ogr_dxf_40, - ogr_dxf_41, - ogr_dxf_42, - ogr_dxf_43, - ogr_dxf_44, - ogr_dxf_45, - ogr_dxf_46, - ogr_dxf_47, - ogr_dxf_48, - ogr_dxf_49, - ogr_dxf_50, - ogr_dxf_51, - ogr_dxf_52, - ogr_dxf_53, - ogr_dxf_insert_too_many_errors, - ogr_dxf_write_geometry_collection_of_unsupported_type, - ogr_dxf_cleanup] + test_ogr_dxf_1, + test_ogr_dxf_2, + test_ogr_dxf_3, + test_ogr_dxf_4, + test_ogr_dxf_5, + test_ogr_dxf_6, + test_ogr_dxf_7, + test_ogr_dxf_8, + test_ogr_dxf_9, + test_ogr_dxf_10, + test_ogr_dxf_11, + test_ogr_dxf_12, + test_ogr_dxf_13, + test_ogr_dxf_14, + test_ogr_dxf_15, + test_ogr_dxf_16, + test_ogr_dxf_17, + test_ogr_dxf_18, + test_ogr_dxf_19, + test_ogr_dxf_20, + test_ogr_dxf_21, + test_ogr_dxf_22, + test_ogr_dxf_23, + test_ogr_dxf_24, + test_ogr_dxf_25, + test_ogr_dxf_26, + test_ogr_dxf_27, + test_ogr_dxf_28, + test_ogr_dxf_29, + test_ogr_dxf_30, + test_ogr_dxf_31, + test_ogr_dxf_32, + test_ogr_dxf_33, + test_ogr_dxf_34, + test_ogr_dxf_35, + test_ogr_dxf_36, + test_ogr_dxf_37, + test_ogr_dxf_38, + test_ogr_dxf_39, + test_ogr_dxf_40, + test_ogr_dxf_41, + test_ogr_dxf_42, + test_ogr_dxf_43, + test_ogr_dxf_44, + test_ogr_dxf_45, + test_ogr_dxf_46, + test_ogr_dxf_47, + test_ogr_dxf_48, + test_ogr_dxf_49, + test_ogr_dxf_50, + test_ogr_dxf_51, + test_ogr_dxf_52, + test_ogr_dxf_53, + test_ogr_dxf_insert_too_many_errors, + test_ogr_dxf_write_geometry_collection_of_unsupported_type, + test_ogr_dxf_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_edigeo.py b/autotest/ogr/ogr_edigeo.py index 9b35ef78d5f6..5718f73f1df5 100755 --- a/autotest/ogr/ogr_edigeo.py +++ b/autotest/ogr/ogr_edigeo.py @@ -40,7 +40,7 @@ ############################################################################### -def ogr_edigeo_1(): +def test_ogr_edigeo_1(): filelist = ['E000AB01.THF', 'EDAB01S1.VEC', @@ -125,7 +125,7 @@ def ogr_edigeo_1(): gdaltest_list = [ - ogr_edigeo_1] + test_ogr_edigeo_1] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_eeda.py b/autotest/ogr/ogr_eeda.py index 52b10cf5245f..32b9ab125a62 100644 --- a/autotest/ogr/ogr_eeda.py +++ b/autotest/ogr/ogr_eeda.py @@ -42,7 +42,7 @@ # Find EEDA driver -def eeda_1(): +def test_eeda_1(): ogrtest.eeda_drv = ogr.GetDriverByName('EEDA') @@ -57,7 +57,7 @@ def eeda_1(): # Nominal case -def eeda_2(): +def test_eeda_2(): if ogrtest.eeda_drv is None: return 'skip' @@ -335,7 +335,7 @@ def eeda_2(): # Nominal case where collection is in eedaconf.json -def eeda_3(): +def test_eeda_3(): if ogrtest.eeda_drv is None: return 'skip' @@ -361,7 +361,7 @@ def eeda_3(): # Test that name and id variants are handled correctly. -def eeda_4(): +def test_eeda_4(): if ogrtest.eeda_drv is None: return 'skip' @@ -456,7 +456,7 @@ def eeda_4(): # -def eeda_cleanup(): +def test_eeda_cleanup(): if ogrtest.eeda_drv is None: return 'skip' @@ -478,11 +478,11 @@ def eeda_cleanup(): gdaltest_list = [ - eeda_1, - eeda_2, - eeda_3, - eeda_4, - eeda_cleanup] + test_eeda_1, + test_eeda_2, + test_eeda_3, + test_eeda_4, + test_eeda_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_elasticsearch.py b/autotest/ogr/ogr_elasticsearch.py index 6ffe25900d31..e1eaaae5b696 100755 --- a/autotest/ogr/ogr_elasticsearch.py +++ b/autotest/ogr/ogr_elasticsearch.py @@ -42,7 +42,7 @@ # -def ogr_elasticsearch_init(): +def test_ogr_elasticsearch_init(): ogrtest.elasticsearch_drv = None ogrtest.srs_wgs84 = osr.SpatialReference() @@ -60,7 +60,7 @@ def ogr_elasticsearch_init(): # Test writing into an nonexistent ElasticSearch datastore. -def ogr_elasticsearch_nonexistent_server(): +def test_ogr_elasticsearch_nonexistent_server(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -122,7 +122,7 @@ def ogr_elasticsearch_nonexistent_server(): # Simple test -def ogr_elasticsearch_1(): +def test_ogr_elasticsearch_1(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -432,7 +432,7 @@ def ogr_elasticsearch_1(): # Geo_shape geometries -def ogr_elasticsearch_2(): +def test_ogr_elasticsearch_2(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -483,7 +483,7 @@ def ogr_elasticsearch_2(): # Test bulk insert and layer name laundering -def ogr_elasticsearch_3(): +def test_ogr_elasticsearch_3(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -537,7 +537,7 @@ def ogr_elasticsearch_3(): # Test basic read functionality -def ogr_elasticsearch_4(): +def test_ogr_elasticsearch_4(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -1158,7 +1158,7 @@ def ogr_elasticsearch_4(): # Write documents with non geojson structure -def ogr_elasticsearch_5(): +def test_ogr_elasticsearch_5(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -1411,7 +1411,7 @@ def ogr_elasticsearch_5(): # Test reading circle and envelope geometries -def ogr_elasticsearch_6(): +def test_ogr_elasticsearch_6(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -1512,7 +1512,7 @@ def ogr_elasticsearch_6(): # Test WRITE_MAPPING option -def ogr_elasticsearch_7(): +def test_ogr_elasticsearch_7(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -1550,7 +1550,7 @@ def ogr_elasticsearch_7(): # Test SRS support -def ogr_elasticsearch_8(): +def test_ogr_elasticsearch_8(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -1614,7 +1614,7 @@ def ogr_elasticsearch_8(): # Test ElasticSearch 5.X -def ogr_elasticsearch_9(): +def test_ogr_elasticsearch_9(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -1726,7 +1726,7 @@ def ogr_elasticsearch_9(): # Test SQL -def ogr_elasticsearch_10(): +def test_ogr_elasticsearch_10(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -2371,7 +2371,7 @@ def ogr_elasticsearch_10(): # Test isnull and unset -def ogr_elasticsearch_11(): +def test_ogr_elasticsearch_11(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -2511,7 +2511,7 @@ def ogr_elasticsearch_11(): # Test authentication -def ogr_elasticsearch_authentication(): +def test_ogr_elasticsearch_authentication(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -2583,7 +2583,7 @@ def ogr_elasticsearch_delete_files(): gdal.Unlink('/vsimem/fakeelasticsearch&USERPWD=user:pwd') -def ogr_elasticsearch_cleanup(): +def test_ogr_elasticsearch_cleanup(): if ogrtest.elasticsearch_drv is None: return 'skip' @@ -2595,21 +2595,21 @@ def ogr_elasticsearch_cleanup(): gdaltest_list = [ - ogr_elasticsearch_init, - ogr_elasticsearch_nonexistent_server, - ogr_elasticsearch_1, - ogr_elasticsearch_2, - ogr_elasticsearch_3, - ogr_elasticsearch_4, - ogr_elasticsearch_5, - ogr_elasticsearch_6, - ogr_elasticsearch_7, - ogr_elasticsearch_8, - ogr_elasticsearch_9, - ogr_elasticsearch_10, - ogr_elasticsearch_11, - ogr_elasticsearch_authentication, - ogr_elasticsearch_cleanup, + test_ogr_elasticsearch_init, + test_ogr_elasticsearch_nonexistent_server, + test_ogr_elasticsearch_1, + test_ogr_elasticsearch_2, + test_ogr_elasticsearch_3, + test_ogr_elasticsearch_4, + test_ogr_elasticsearch_5, + test_ogr_elasticsearch_6, + test_ogr_elasticsearch_7, + test_ogr_elasticsearch_8, + test_ogr_elasticsearch_9, + test_ogr_elasticsearch_10, + test_ogr_elasticsearch_11, + test_ogr_elasticsearch_authentication, + test_ogr_elasticsearch_cleanup, ] # gdaltest_list = [ ogr_elasticsearch_init, ogr_elasticsearch_10 ] diff --git a/autotest/ogr/ogr_factory.py b/autotest/ogr/ogr_factory.py index a9b36965fccd..0f23543f8c10 100755 --- a/autotest/ogr/ogr_factory.py +++ b/autotest/ogr/ogr_factory.py @@ -47,7 +47,7 @@ def save_as_csv(geom, filename): # 30 degree rotated ellipse, just one quarter. -def ogr_factory_1(): +def test_ogr_factory_1(): geom = ogr.ApproximateArcAngles(20, 30, 40, 7, 3.5, 30.0, 270.0, 360.0, 6.0) @@ -61,7 +61,7 @@ def ogr_factory_1(): # Test forceToPolygon() -def ogr_factory_2(): +def test_ogr_factory_2(): src_wkt = 'MULTIPOLYGON (((0 0,100 0,100 100,0 0)))' exp_wkt = 'POLYGON((0 0,100 0,100 100,0 0))' @@ -109,7 +109,7 @@ def ogr_factory_2(): # Test forceToMultiPolygon() -def ogr_factory_3(): +def test_ogr_factory_3(): src_wkt = 'POLYGON((0 0,100 0,100 100,0 0))' exp_wkt = 'MULTIPOLYGON (((0 0,100 0,100 100,0 0)))' @@ -157,7 +157,7 @@ def ogr_factory_3(): # Test forceToMultiPoint() -def ogr_factory_4(): +def test_ogr_factory_4(): src_wkt = 'POINT(2 5 3)' exp_wkt = 'MULTIPOINT(2 5 3)' @@ -185,7 +185,7 @@ def ogr_factory_4(): # Test forceToMultiLineString() -def ogr_factory_5(): +def test_ogr_factory_5(): src_wkt = 'LINESTRING(2 5,10 20)' exp_wkt = 'MULTILINESTRING((2 5,10 20))' @@ -232,7 +232,7 @@ def ogr_factory_5(): ############################################################################### # Test robustness of forceToXXX() primitives with various inputs (#3504) -def ogr_factory_6(): +def test_ogr_factory_6(): src_wkt_list = [None, 'POINT EMPTY', @@ -299,7 +299,7 @@ def ogr_factory_6(): # Test forceToLineString() -def ogr_factory_7(): +def test_ogr_factory_7(): src_wkt = 'LINESTRING(2 5,10 20)' exp_wkt = 'LINESTRING(2 5,10 20)' @@ -427,7 +427,7 @@ def ogr_factory_7(): # Test forceTo() -def ogr_factory_8(): +def test_ogr_factory_8(): tests = [('POINT(2 5)', 'MULTIPOINT (2 5)', ogr.wkbMultiPoint), @@ -601,14 +601,14 @@ def ogr_factory_8(): gdaltest_list = [ - ogr_factory_1, - ogr_factory_2, - ogr_factory_3, - ogr_factory_4, - ogr_factory_5, - ogr_factory_6, - ogr_factory_7, - ogr_factory_8, + test_ogr_factory_1, + test_ogr_factory_2, + test_ogr_factory_3, + test_ogr_factory_4, + test_ogr_factory_5, + test_ogr_factory_6, + test_ogr_factory_7, + test_ogr_factory_8, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_feature.py b/autotest/ogr/ogr_feature.py index 05dae6d07ba4..4af512d72cbd 100755 --- a/autotest/ogr/ogr_feature.py +++ b/autotest/ogr/ogr_feature.py @@ -138,7 +138,7 @@ def check(feat, fieldname, value): # Copy to Integer -def ogr_feature_cp_integer(): +def test_ogr_feature_cp_integer(): src_feature = mk_src_feature() src_feature.field_integerlist = [15] src_feature.field_reallist = [17.5] @@ -199,7 +199,7 @@ def ogr_feature_cp_integer(): # Copy to Integer64 -def ogr_feature_cp_integer64(): +def test_ogr_feature_cp_integer64(): src_feature = mk_src_feature() src_feature.field_integerlist = [15] src_feature.field_reallist = [17.5] @@ -256,7 +256,7 @@ def ogr_feature_cp_integer64(): # Copy to Real -def ogr_feature_cp_real(): +def test_ogr_feature_cp_real(): src_feature = mk_src_feature() src_feature.field_integerlist = [15] src_feature.field_reallist = [17.5] @@ -301,7 +301,7 @@ def ogr_feature_cp_real(): # Copy to String -def ogr_feature_cp_string(): +def test_ogr_feature_cp_string(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTString) @@ -349,7 +349,7 @@ def ogr_feature_cp_string(): # Copy to Binary -def ogr_feature_cp_binary(): +def test_ogr_feature_cp_binary(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTBinary) @@ -405,7 +405,7 @@ def ogr_feature_cp_binary(): # Copy to date -def ogr_feature_cp_date(): +def test_ogr_feature_cp_date(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTDate) @@ -453,7 +453,7 @@ def ogr_feature_cp_date(): # Copy to time -def ogr_feature_cp_time(): +def test_ogr_feature_cp_time(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTTime) @@ -501,7 +501,7 @@ def ogr_feature_cp_time(): # Copy to datetime -def ogr_feature_cp_datetime(): +def test_ogr_feature_cp_datetime(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTDateTime) @@ -549,7 +549,7 @@ def ogr_feature_cp_datetime(): # Copy to integerlist -def ogr_feature_cp_integerlist(): +def test_ogr_feature_cp_integerlist(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTIntegerList) @@ -599,7 +599,7 @@ def ogr_feature_cp_integerlist(): # Copy to integer64list -def ogr_feature_cp_integer64list(): +def test_ogr_feature_cp_integer64list(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTInteger64List) @@ -647,7 +647,7 @@ def ogr_feature_cp_integer64list(): # Copy to reallist -def ogr_feature_cp_reallist(): +def test_ogr_feature_cp_reallist(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTRealList) @@ -695,7 +695,7 @@ def ogr_feature_cp_reallist(): # Copy to stringlist -def ogr_feature_cp_stringlist(): +def test_ogr_feature_cp_stringlist(): src_feature = mk_src_feature() dst_feature = mk_dst_feature(src_feature, ogr.OFTStringList) @@ -743,7 +743,7 @@ def ogr_feature_cp_stringlist(): ############################################################################### # Test SetField() / GetField() with unicode string -def ogr_feature_unicode(): +def test_ogr_feature_unicode(): if sys.version_info >= (3, 0, 0): return 'skip' @@ -778,7 +778,7 @@ def ogr_feature_unicode(): # Test 64bit FID -def ogr_feature_64bit_fid(): +def test_ogr_feature_64bit_fid(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) @@ -791,7 +791,7 @@ def ogr_feature_64bit_fid(): # Test 64bit integer -def ogr_feature_overflow_64bit_integer(): +def test_ogr_feature_overflow_64bit_integer(): feat_def = ogr.FeatureDefn('test') feat_def.AddFieldDefn(ogr.FieldDefn('test', ogr.OFTInteger64)) @@ -816,7 +816,7 @@ def ogr_feature_overflow_64bit_integer(): # Test SetNullable(), IsNullable() and Validate() -def ogr_feature_nullable_validate(): +def test_ogr_feature_nullable_validate(): # No fields feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) @@ -947,7 +947,7 @@ def ogr_feature_nullable_validate(): # Test SetDefault(), GetDefault(), IsDefaultDriverSpecific() and FillUnsetWithDefault() -def ogr_feature_default(): +def test_ogr_feature_default(): feat_def = ogr.FeatureDefn('test') field_def = ogr.FieldDefn('field_string', ogr.OFTString) @@ -1035,7 +1035,7 @@ def ogr_feature_default(): # Test GetNativeData(), SetNativeData(), GetNativeMediaType(), SetNativeMediaType(): -def ogr_feature_native_data(): +def test_ogr_feature_native_data(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) @@ -1127,7 +1127,7 @@ def ogr_feature_native_data(): # Test assigning our geometry to ourselves -def ogr_feature_set_geometry_self(): +def test_ogr_feature_set_geometry_self(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) @@ -1146,7 +1146,7 @@ def ogr_feature_set_geometry_self(): # Test SetFieldNull(), IsFieldNull() -def ogr_feature_null_field(): +def test_ogr_feature_null_field(): feat_def = ogr.FeatureDefn('test') field_def = ogr.FieldDefn('field_string', ogr.OFTString) @@ -1242,7 +1242,7 @@ def ogr_feature_null_field(): return 'success' -def ogr_feature_cleanup(): +def test_ogr_feature_cleanup(): gdaltest.src_feature = None @@ -1250,27 +1250,27 @@ def ogr_feature_cleanup(): gdaltest_list = [ - ogr_feature_cp_integer, - ogr_feature_cp_integer64, - ogr_feature_cp_real, - ogr_feature_cp_string, - ogr_feature_cp_binary, - ogr_feature_cp_date, - ogr_feature_cp_time, - ogr_feature_cp_datetime, - ogr_feature_cp_integerlist, - ogr_feature_cp_integer64list, - ogr_feature_cp_reallist, - ogr_feature_cp_stringlist, - ogr_feature_unicode, - ogr_feature_64bit_fid, - ogr_feature_overflow_64bit_integer, - ogr_feature_nullable_validate, - ogr_feature_default, - ogr_feature_native_data, - ogr_feature_set_geometry_self, - ogr_feature_null_field, - ogr_feature_cleanup] + test_ogr_feature_cp_integer, + test_ogr_feature_cp_integer64, + test_ogr_feature_cp_real, + test_ogr_feature_cp_string, + test_ogr_feature_cp_binary, + test_ogr_feature_cp_date, + test_ogr_feature_cp_time, + test_ogr_feature_cp_datetime, + test_ogr_feature_cp_integerlist, + test_ogr_feature_cp_integer64list, + test_ogr_feature_cp_reallist, + test_ogr_feature_cp_stringlist, + test_ogr_feature_unicode, + test_ogr_feature_64bit_fid, + test_ogr_feature_overflow_64bit_integer, + test_ogr_feature_nullable_validate, + test_ogr_feature_default, + test_ogr_feature_native_data, + test_ogr_feature_set_geometry_self, + test_ogr_feature_null_field, + test_ogr_feature_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_fgdb.py b/autotest/ogr/ogr_fgdb.py index 3da90cb55f4a..c40a8cd9cb5b 100755 --- a/autotest/ogr/ogr_fgdb.py +++ b/autotest/ogr/ogr_fgdb.py @@ -44,7 +44,7 @@ # Test if driver is available -def ogr_fgdb_init(): +def test_ogr_fgdb_init(): ogrtest.fgdb_drv = None @@ -96,7 +96,7 @@ def ogr_fgdb_is_sdk_1_4_or_later(): ############################################################################### # Write and read back various geometry types -def ogr_fgdb_1(): +def test_ogr_fgdb_1(): if ogrtest.fgdb_drv is None: return 'skip' @@ -255,7 +255,7 @@ def ogr_fgdb_1(): # Test DeleteField() -def ogr_fgdb_DeleteField(): +def test_ogr_fgdb_DeleteField(): if ogrtest.fgdb_drv is None: return 'skip' @@ -331,7 +331,7 @@ def ogr_fgdb_DeleteField(): # Run test_ogrsf -def ogr_fgdb_2(): +def test_ogr_fgdb_2(): if ogrtest.fgdb_drv is None: return 'skip' @@ -351,7 +351,7 @@ def ogr_fgdb_2(): # Run ogr2ogr -def ogr_fgdb_3(): +def test_ogr_fgdb_3(): if ogrtest.fgdb_drv is None: return 'skip' @@ -388,7 +388,7 @@ def ogr_fgdb_3(): # Test SQL support -def ogr_fgdb_sql(): +def test_ogr_fgdb_sql(): if ogrtest.fgdb_drv is None: return 'skip' @@ -417,7 +417,7 @@ def ogr_fgdb_sql(): # Test delete layer -def ogr_fgdb_4(): +def test_ogr_fgdb_4(): if ogrtest.fgdb_drv is None: return 'skip' @@ -459,7 +459,7 @@ def ogr_fgdb_4(): # Test DeleteDataSource() -def ogr_fgdb_5(): +def test_ogr_fgdb_5(): if ogrtest.fgdb_drv is None: return 'skip' @@ -480,7 +480,7 @@ def ogr_fgdb_5(): # Test adding a layer to an existing feature dataset -def ogr_fgdb_6(): +def test_ogr_fgdb_6(): if ogrtest.fgdb_drv is None: return 'skip' @@ -503,7 +503,7 @@ def ogr_fgdb_6(): # Test bulk loading (#4420) -def ogr_fgdb_7(): +def test_ogr_fgdb_7(): if ogrtest.fgdb_drv is None: return 'skip' @@ -541,7 +541,7 @@ def ogr_fgdb_7(): # Test field name laundering (#4458) -def ogr_fgdb_8(): +def test_ogr_fgdb_8(): if ogrtest.fgdb_drv is None: return 'skip' @@ -580,7 +580,7 @@ def ogr_fgdb_8(): # Test layer name laundering (#4466) -def ogr_fgdb_9(): +def test_ogr_fgdb_9(): if ogrtest.fgdb_drv is None: return 'skip' @@ -628,7 +628,7 @@ def ogr_fgdb_9(): # Test SRS support -def ogr_fgdb_10(): +def test_ogr_fgdb_10(): if ogrtest.fgdb_drv is None: return 'skip' @@ -731,7 +731,7 @@ def ogr_fgdb_10(): # Test all data types -def ogr_fgdb_11(): +def test_ogr_fgdb_11(): if ogrtest.fgdb_drv is None: return 'skip' @@ -804,7 +804,7 @@ def ogr_fgdb_11(): # Test failed Open() -def ogr_fgdb_12(): +def test_ogr_fgdb_12(): if ogrtest.fgdb_drv is None: return 'skip' @@ -846,7 +846,7 @@ def ogr_fgdb_12(): # Test failed CreateDataSource() and DeleteDataSource() -def ogr_fgdb_13(): +def test_ogr_fgdb_13(): if ogrtest.fgdb_drv is None: return 'skip' @@ -896,7 +896,7 @@ def ogr_fgdb_13(): # Test interleaved opening and closing of databases (#4270) -def ogr_fgdb_14(): +def test_ogr_fgdb_14(): if ogrtest.fgdb_drv is None: return 'skip' @@ -918,7 +918,7 @@ def ogr_fgdb_14(): # Test opening a FGDB with both SRID and LatestSRID set (#5638) -def ogr_fgdb_15(): +def test_ogr_fgdb_15(): if ogrtest.fgdb_drv is None: return 'skip' @@ -946,7 +946,7 @@ def ogr_fgdb_15(): # Test fix for #5674 -def ogr_fgdb_16(): +def test_ogr_fgdb_16(): if ogrtest.fgdb_drv is None or ogrtest.openfilegdb_drv is None: return 'skip' @@ -982,7 +982,7 @@ def ogr_fgdb_16(): # Test not nullable fields -def ogr_fgdb_17(): +def test_ogr_fgdb_17(): if ogrtest.fgdb_drv is None: return 'skip' @@ -1058,7 +1058,7 @@ def ogr_fgdb_17(): # Test default values -def ogr_fgdb_18(): +def test_ogr_fgdb_18(): if ogrtest.fgdb_drv is None: return 'skip' @@ -1173,7 +1173,7 @@ def ogr_fgdb_19_open_update(filename): return (bPerLayerCopyingForTransaction, ds) -def ogr_fgdb_19(): +def test_ogr_fgdb_19(): if ogrtest.fgdb_drv is None: return 'skip' @@ -1846,7 +1846,7 @@ def ogr_fgdb_19(): # this was what was tested in previous step) -def ogr_fgdb_19bis(): +def test_ogr_fgdb_19bis(): if ogrtest.fgdb_drv is None: return 'skip' @@ -1860,7 +1860,7 @@ def ogr_fgdb_19bis(): return 'skip' gdal.SetConfigOption('FGDB_PER_LAYER_COPYING_TRANSACTION', 'FALSE') - ret = ogr_fgdb_19() + ret = test_ogr_fgdb_19() gdal.SetConfigOption('FGDB_PER_LAYER_COPYING_TRANSACTION', None) return ret @@ -1868,7 +1868,7 @@ def ogr_fgdb_19bis(): # Test CreateFeature() with user defined FID -def ogr_fgdb_20(): +def test_ogr_fgdb_20(): if ogrtest.fgdb_drv is None: return 'skip' @@ -2384,7 +2384,7 @@ def ogr_fgdb_20(): # Test M support -def ogr_fgdb_21(): +def test_ogr_fgdb_21(): if ogrtest.fgdb_drv is None: return 'skip' @@ -2473,7 +2473,7 @@ def ogr_fgdb_21(): # Read curves -def ogr_fgdb_22(): +def test_ogr_fgdb_22(): if ogrtest.fgdb_drv is None: return 'skip' @@ -2519,7 +2519,7 @@ def ogr_fgdb_22(): # Test opening '.' -def ogr_fgdb_23(): +def test_ogr_fgdb_23(): if ogrtest.fgdb_drv is None: return 'skip' @@ -2537,7 +2537,7 @@ def ogr_fgdb_23(): # one of the starting point (#7017) -def ogr_fgdb_24(): +def test_ogr_fgdb_24(): ds = ogr.Open('data/filegdb_polygonzm_m_not_closing_with_curves.gdb') lyr = ds.GetLayer(0) @@ -2569,7 +2569,7 @@ def ogr_fgdb_24(): # Test selecting FID column with OGRSQL -def ogr_fgdb_25(): +def test_ogr_fgdb_25(): ds = ogr.Open('data/curves.gdb') sql_lyr = ds.ExecuteSQL('SELECT OBJECTID FROM polygon WHERE OBJECTID = 2') @@ -2601,7 +2601,7 @@ def ogr_fgdb_25(): # Cleanup -def ogr_fgdb_cleanup(): +def test_ogr_fgdb_cleanup(): if ogrtest.fgdb_drv is None: return 'skip' @@ -2633,42 +2633,42 @@ def ogr_fgdb_cleanup(): gdaltest_list = [ - ogr_fgdb_init, - ogr_fgdb_1, - ogr_fgdb_DeleteField, - ogr_fgdb_2, - ogr_fgdb_3, - ogr_fgdb_sql, - ogr_fgdb_4, - ogr_fgdb_5, - ogr_fgdb_6, - ogr_fgdb_7, - ogr_fgdb_8, - ogr_fgdb_9, - ogr_fgdb_10, - ogr_fgdb_11, - ogr_fgdb_12, - ogr_fgdb_13, - ogr_fgdb_14, - ogr_fgdb_15, - ogr_fgdb_16, - ogr_fgdb_17, - ogr_fgdb_18, - ogr_fgdb_19, - ogr_fgdb_19bis, - ogr_fgdb_20, - ogr_fgdb_21, - ogr_fgdb_22, - ogr_fgdb_23, - ogr_fgdb_24, - ogr_fgdb_25, - ogr_fgdb_cleanup, + test_ogr_fgdb_init, + test_ogr_fgdb_1, + test_ogr_fgdb_DeleteField, + test_ogr_fgdb_2, + test_ogr_fgdb_3, + test_ogr_fgdb_sql, + test_ogr_fgdb_4, + test_ogr_fgdb_5, + test_ogr_fgdb_6, + test_ogr_fgdb_7, + test_ogr_fgdb_8, + test_ogr_fgdb_9, + test_ogr_fgdb_10, + test_ogr_fgdb_11, + test_ogr_fgdb_12, + test_ogr_fgdb_13, + test_ogr_fgdb_14, + test_ogr_fgdb_15, + test_ogr_fgdb_16, + test_ogr_fgdb_17, + test_ogr_fgdb_18, + test_ogr_fgdb_19, + test_ogr_fgdb_19bis, + test_ogr_fgdb_20, + test_ogr_fgdb_21, + test_ogr_fgdb_22, + test_ogr_fgdb_23, + test_ogr_fgdb_24, + test_ogr_fgdb_25, + test_ogr_fgdb_cleanup, ] disabled_gdaltest_list = [ - ogr_fgdb_init, - ogr_fgdb_20, - ogr_fgdb_cleanup + test_ogr_fgdb_init, + test_ogr_fgdb_20, + test_ogr_fgdb_cleanup ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_geoconcept.py b/autotest/ogr/ogr_geoconcept.py index 020752a2b22e..c1602c7bb7a4 100755 --- a/autotest/ogr/ogr_geoconcept.py +++ b/autotest/ogr/ogr_geoconcept.py @@ -42,7 +42,7 @@ # Simple read test of known file. -def ogr_gxt_1(): +def test_ogr_gxt_1(): gdaltest.gxt_ds = ogr.Open('data/expected_000_GRD.gxt') @@ -99,7 +99,7 @@ def ogr_gxt_1(): # Similar test than previous one with TAB separator. -def ogr_gxt_2(): +def test_ogr_gxt_2(): gdaltest.gxt_ds = ogr.Open('data/expected_000_GRD_TAB.txt') @@ -144,7 +144,7 @@ def ogr_gxt_2(): # Read a GXT file containing 2 points, duplicate it, and check the newly written file -def ogr_gxt_3(): +def test_ogr_gxt_3(): gdaltest.gxt_ds = None @@ -234,7 +234,7 @@ def ogr_gxt_3(): # -def ogr_gxt_multipolygon_singlepart_nohole(): +def test_ogr_gxt_multipolygon_singlepart_nohole(): ds = ogr.Open('data/geoconcept_multipolygon_singlepart_nohole.txt') lyr = ds.GetLayer(0) @@ -251,7 +251,7 @@ def ogr_gxt_multipolygon_singlepart_nohole(): # -def ogr_gxt_multipolygon_singlepart_hole(): +def test_ogr_gxt_multipolygon_singlepart_hole(): if not ogrtest.have_geos(): return 'skip' @@ -271,7 +271,7 @@ def ogr_gxt_multipolygon_singlepart_hole(): # -def ogr_gxt_multipolygon_twoparts_second_with_hole(): +def test_ogr_gxt_multipolygon_twoparts_second_with_hole(): if not ogrtest.have_geos(): return 'skip' @@ -291,7 +291,7 @@ def ogr_gxt_multipolygon_twoparts_second_with_hole(): # -def ogr_gxt_line(): +def test_ogr_gxt_line(): if not ogrtest.have_geos(): return 'skip' @@ -311,7 +311,7 @@ def ogr_gxt_line(): # -def ogr_gxt_cleanup(): +def test_ogr_gxt_cleanup(): gdaltest.gxt_ds = None try: @@ -322,14 +322,14 @@ def ogr_gxt_cleanup(): gdaltest_list = [ - ogr_gxt_1, - ogr_gxt_2, - ogr_gxt_3, - ogr_gxt_multipolygon_singlepart_nohole, - ogr_gxt_multipolygon_singlepart_hole, - ogr_gxt_multipolygon_twoparts_second_with_hole, - ogr_gxt_line, - ogr_gxt_cleanup, + test_ogr_gxt_1, + test_ogr_gxt_2, + test_ogr_gxt_3, + test_ogr_gxt_multipolygon_singlepart_nohole, + test_ogr_gxt_multipolygon_singlepart_hole, + test_ogr_gxt_multipolygon_twoparts_second_with_hole, + test_ogr_gxt_line, + test_ogr_gxt_cleanup, None] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index a702b95eb684..52520a8c2c24 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -203,7 +203,7 @@ def copy_shape_to_geojson(gjname, compress=None): # Find GeoJSON driver -def ogr_geojson_1(): +def test_ogr_geojson_1(): gdaltest.geojson_drv = ogr.GetDriverByName('GeoJSON') @@ -215,7 +215,7 @@ def ogr_geojson_1(): # Test file-based DS with standalone "Point" feature object. -def ogr_geojson_2(): +def test_ogr_geojson_2(): if gdaltest.geojson_drv is None: return 'skip' @@ -248,7 +248,7 @@ def ogr_geojson_2(): # Test file-based DS with standalone "LineString" feature object. -def ogr_geojson_3(): +def test_ogr_geojson_3(): if gdaltest.geojson_drv is None: return 'skip' @@ -281,7 +281,7 @@ def ogr_geojson_3(): # Test file-based DS with standalone "Polygon" feature object. -def ogr_geojson_4(): +def test_ogr_geojson_4(): if gdaltest.geojson_drv is None: return 'skip' @@ -314,7 +314,7 @@ def ogr_geojson_4(): # Test file-based DS with standalone "GeometryCollection" feature object. -def ogr_geojson_5(): +def test_ogr_geojson_5(): if gdaltest.geojson_drv is None: return 'skip' @@ -347,7 +347,7 @@ def ogr_geojson_5(): # Test file-based DS with standalone "MultiPoint" feature object. -def ogr_geojson_6(): +def test_ogr_geojson_6(): if gdaltest.geojson_drv is None: return 'skip' @@ -380,7 +380,7 @@ def ogr_geojson_6(): # Test file-based DS with standalone "MultiLineString" feature object. -def ogr_geojson_7(): +def test_ogr_geojson_7(): if gdaltest.geojson_drv is None: return 'skip' @@ -413,7 +413,7 @@ def ogr_geojson_7(): # Test file-based DS with standalone "MultiPolygon" feature object. -def ogr_geojson_8(): +def test_ogr_geojson_8(): if gdaltest.geojson_drv is None: return 'skip' @@ -446,7 +446,7 @@ def ogr_geojson_8(): # Test translation of data/gjpoint.shp to GeoJSON file -def ogr_geojson_9(): +def test_ogr_geojson_9(): if gdaltest.geojson_drv is None: return 'skip' @@ -479,7 +479,7 @@ def ogr_geojson_9(): # Test translation of data/gjpoint.shp to GZip compressed GeoJSON file -def ogr_geojson_10(): +def test_ogr_geojson_10(): if gdaltest.geojson_drv is None: return 'skip' @@ -511,7 +511,7 @@ def ogr_geojson_10(): ############################################################################### -def ogr_geojson_11(): +def test_ogr_geojson_11(): if gdaltest.geojson_drv is None: return 'skip' @@ -559,7 +559,7 @@ def ogr_geojson_11(): # Test DS passed as name with standalone "Point" feature object (#3377) -def ogr_geojson_12(): +def test_ogr_geojson_12(): if gdaltest.geojson_drv is None: return 'skip' @@ -583,7 +583,7 @@ def ogr_geojson_12(): ############################################################################### # Test writing to stdout (#3381) -def ogr_geojson_13(): +def test_ogr_geojson_13(): if gdaltest.geojson_drv is None: return 'skip' @@ -601,7 +601,7 @@ def ogr_geojson_13(): # Test reading & writing various degenerated geometries -def ogr_geojson_14(): +def test_ogr_geojson_14(): if gdaltest.geojson_drv is None: return 'skip' @@ -633,7 +633,7 @@ def ogr_geojson_14(): # Test Feature.ExportToJson (#3870) -def ogr_geojson_15(): +def test_ogr_geojson_15(): feature_defn = ogr.FeatureDefn() feature_defn.AddFieldDefn(ogr.FieldDefn("foo")) @@ -678,7 +678,7 @@ def ogr_geojson_15(): # Test reading ESRI point file -def ogr_geojson_16(): +def test_ogr_geojson_16(): if gdaltest.geojson_drv is None: return 'skip' @@ -741,7 +741,7 @@ def ogr_geojson_16(): # Test reading ESRI linestring file -def ogr_geojson_17(): +def test_ogr_geojson_17(): if gdaltest.geojson_drv is None: return 'skip' @@ -800,7 +800,7 @@ def ogr_geojson_17(): # Test reading ESRI polygon file -def ogr_geojson_18(): +def test_ogr_geojson_18(): if gdaltest.geojson_drv is None: return 'skip' @@ -850,7 +850,7 @@ def ogr_geojson_18(): # Test reading ESRI multipoint file -def ogr_geojson_19(): +def test_ogr_geojson_19(): if gdaltest.geojson_drv is None: return 'skip' @@ -887,7 +887,7 @@ def ogr_geojson_19(): # Test reading files with no extension (#4314) -def ogr_geojson_20(): +def test_ogr_geojson_20(): if gdaltest.geojson_drv is None: return 'skip' @@ -923,7 +923,7 @@ def ogr_geojson_20(): # Test reading output of geocouch spatiallist -def ogr_geojson_21(): +def test_ogr_geojson_21(): if gdaltest.geojson_drv is None: return 'skip' @@ -957,7 +957,7 @@ def ogr_geojson_21(): # Same as ogr_geojson_21 with several features -def ogr_geojson_22(): +def test_ogr_geojson_22(): if gdaltest.geojson_drv is None: return 'skip' @@ -1005,7 +1005,7 @@ def ogr_geojson_22(): # Write GeoJSON with bbox and test SRS writing&reading back -def ogr_geojson_23(): +def test_ogr_geojson_23(): if gdaltest.geojson_drv is None: return 'skip' @@ -1055,7 +1055,7 @@ def ogr_geojson_23(): # Test alternate form of geojson -def ogr_geojson_24(): +def test_ogr_geojson_24(): if gdaltest.geojson_drv is None: return 'skip' @@ -1119,7 +1119,7 @@ def ogr_geojson_24(): # Test TopoJSON -def ogr_geojson_25(): +def test_ogr_geojson_25(): if gdaltest.geojson_drv is None: return 'skip' @@ -1233,7 +1233,7 @@ def ogr_geojson_25(): # Test 64bit support -def ogr_geojson_26(): +def test_ogr_geojson_26(): if gdaltest.geojson_drv is None: return 'skip' @@ -1315,7 +1315,7 @@ def ogr_geojson_26(): # Test workaround for 64bit values (returned as strings) -def ogr_geojson_27(): +def test_ogr_geojson_27(): if gdaltest.geojson_drv is None: return 'skip' @@ -1357,7 +1357,7 @@ def ogr_geojson_27(): # Test reading ESRI point file with z value -def ogr_geojson_28(): +def test_ogr_geojson_28(): if gdaltest.geojson_drv is None: return 'skip' @@ -1418,7 +1418,7 @@ def ogr_geojson_28(): # Test reading ESRI linestring file with z -def ogr_geojson_29(): +def test_ogr_geojson_29(): if gdaltest.geojson_drv is None: return 'skip' @@ -1456,7 +1456,7 @@ def ogr_geojson_29(): # Test reading ESRI multipoint file with z -def ogr_geojson_30(): +def test_ogr_geojson_30(): if gdaltest.geojson_drv is None: return 'skip' @@ -1494,7 +1494,7 @@ def ogr_geojson_30(): # Test reading ESRI polygon file with z -def ogr_geojson_31(): +def test_ogr_geojson_31(): if gdaltest.geojson_drv is None: return 'skip' @@ -1532,7 +1532,7 @@ def ogr_geojson_31(): # Test reading ESRI multipoint file with m, but no z (hasM=true, hasZ omitted) -def ogr_geojson_32(): +def test_ogr_geojson_32(): if gdaltest.geojson_drv is None: return 'skip' @@ -1569,7 +1569,7 @@ def ogr_geojson_32(): # Test reading ESRI multipoint file with hasZ=true, but only 2 components. -def ogr_geojson_33(): +def test_ogr_geojson_33(): if gdaltest.geojson_drv is None: return 'skip' @@ -1606,7 +1606,7 @@ def ogr_geojson_33(): # Test reading ESRI multipoint file with z and m -def ogr_geojson_34(): +def test_ogr_geojson_34(): if gdaltest.geojson_drv is None: return 'skip' @@ -1643,7 +1643,7 @@ def ogr_geojson_34(): # Test handling of huge coordinates (#5377) -def ogr_geojson_35(): +def test_ogr_geojson_35(): if gdaltest.geojson_drv is None: return 'skip' @@ -1747,7 +1747,7 @@ def ogr_geojson_35(): # Test reading file with UTF-8 BOM (which is supposed to be illegal in JSON...) (#5630) -def ogr_geojson_36(): +def test_ogr_geojson_36(): if gdaltest.geojson_drv is None: return 'skip' @@ -1764,7 +1764,7 @@ def ogr_geojson_36(): # Test boolean type support -def ogr_geojson_37(): +def test_ogr_geojson_37(): if gdaltest.geojson_drv is None: return 'skip' @@ -1822,7 +1822,7 @@ def ogr_geojson_37(): # Test datetime/date/time type support -def ogr_geojson_38(): +def test_ogr_geojson_38(): if gdaltest.geojson_drv is None: return 'skip' @@ -1871,7 +1871,7 @@ def ogr_geojson_38(): # Test id top-object level -def ogr_geojson_39(): +def test_ogr_geojson_39(): if gdaltest.geojson_drv is None: return 'skip' @@ -2066,7 +2066,7 @@ def ogr_geojson_39(): # Test nested attributes -def ogr_geojson_40(): +def test_ogr_geojson_40(): if gdaltest.geojson_drv is None: return 'skip' @@ -2120,7 +2120,7 @@ def ogr_geojson_40(): # Test ogr.CreateGeometryFromJson() -def ogr_geojson_41(): +def test_ogr_geojson_41(): if gdaltest.geojson_drv is None: return 'skip' @@ -2157,7 +2157,7 @@ def ogr_geojson_41(): # Test ESRI FeatureService scrolling -def ogr_geojson_42(): +def test_ogr_geojson_42(): if gdaltest.geojson_drv is None: return 'skip' @@ -2373,7 +2373,7 @@ def ogr_geojson_42(): # Test Feature without geometry -def ogr_geojson_43(): +def test_ogr_geojson_43(): if gdaltest.geojson_drv is None: return 'skip' @@ -2399,7 +2399,7 @@ def ogr_geojson_43(): # Test null Feature (#6166) -def ogr_geojson_44(): +def test_ogr_geojson_44(): if gdaltest.geojson_drv is None: return 'skip' @@ -2412,7 +2412,7 @@ def ogr_geojson_44(): # Test native data support -def ogr_geojson_45(): +def test_ogr_geojson_45(): if gdaltest.geojson_drv is None: return 'skip' @@ -2558,7 +2558,7 @@ def ogr_geojson_45(): # Test that writing JSon content as value of a string field is serialized as it -def ogr_geojson_46(): +def test_ogr_geojson_46(): if gdaltest.geojson_drv is None: return 'skip' @@ -2587,7 +2587,7 @@ def ogr_geojson_46(): # Test update support -def ogr_geojson_47(): +def test_ogr_geojson_47(): if gdaltest.geojson_drv is None: return 'skip' @@ -2769,7 +2769,7 @@ def ogr_geojson_47(): # Test update support with file that has a single feature not in a FeatureCollection -def ogr_geojson_48(): +def test_ogr_geojson_48(): if gdaltest.geojson_drv is None: return 'skip' @@ -2810,7 +2810,7 @@ def ogr_geojson_48(): # Test ARRAY_AS_STRING -def ogr_geojson_49(): +def test_ogr_geojson_49(): if gdaltest.geojson_drv is None: return 'skip' @@ -2838,7 +2838,7 @@ def ogr_geojson_49(): # Test that we serialize floating point values with enough significant figures -def ogr_geojson_50(): +def test_ogr_geojson_50(): if gdaltest.geojson_drv is None: return 'skip' @@ -2917,7 +2917,7 @@ def ogr_geojson_50(): # Test writing empty geometries -def ogr_geojson_51(): +def test_ogr_geojson_51(): if gdaltest.geojson_drv is None: return 'skip' @@ -3002,7 +3002,7 @@ def ogr_geojson_51(): # Test NULL type detection -def ogr_geojson_52(): +def test_ogr_geojson_52(): if gdaltest.geojson_drv is None: return 'skip' @@ -3042,7 +3042,7 @@ def ogr_geojson_52(): # Test that M is ignored (this is a test of OGRLayer::CreateFeature() actually) -def ogr_geojson_53(): +def test_ogr_geojson_53(): if gdaltest.geojson_drv is None: return 'skip' @@ -3070,7 +3070,7 @@ def ogr_geojson_53(): # Test NULL type detection when first value is null -def ogr_geojson_54(): +def test_ogr_geojson_54(): if gdaltest.geojson_drv is None: return 'skip' @@ -3130,7 +3130,7 @@ def read_file(filename): return content -def ogr_geojson_55(): +def test_ogr_geojson_55(): if gdaltest.geojson_drv is None: return 'skip' @@ -3243,7 +3243,7 @@ def ogr_geojson_55(): # Test RFC 7946 (that require geos) -def ogr_geojson_56(): +def test_ogr_geojson_56(): if gdaltest.geojson_drv is None: return 'skip' if not ogrtest.have_geos(): @@ -3319,7 +3319,7 @@ def ogr_geojson_56(): # Test RFC 7946 and reprojection -def ogr_geojson_57(): +def test_ogr_geojson_57(): if gdaltest.geojson_drv is None: return 'skip' if not ogrtest.have_geos(): @@ -3564,7 +3564,7 @@ def ogr_geojson_57(): # Test using the name member of FeatureCollection -def ogr_geojson_58(): +def test_ogr_geojson_58(): if gdaltest.geojson_drv is None: return 'skip' @@ -3595,7 +3595,7 @@ def ogr_geojson_58(): # Test using the description member of FeatureCollection -def ogr_geojson_59(): +def test_ogr_geojson_59(): if gdaltest.geojson_drv is None: return 'skip' @@ -3627,7 +3627,7 @@ def ogr_geojson_59(): # Test null vs unset field -def ogr_geojson_60(): +def test_ogr_geojson_60(): if gdaltest.geojson_drv is None: return 'skip' @@ -3673,7 +3673,7 @@ def ogr_geojson_60(): ############################################################################### # Test corner cases -def ogr_geojson_61(): +def test_ogr_geojson_61(): # Invalid JSon gdal.FileFromMemBuffer('/vsimem/ogr_geojson_61.json', @@ -3710,7 +3710,7 @@ def ogr_geojson_61(): # Test crs object -def ogr_geojson_62(): +def test_ogr_geojson_62(): # crs type=name tests gdal.OpenEx("""{ "type": "FeatureCollection", "crs": { "type":"name" }, "features":[] }""") @@ -3797,7 +3797,7 @@ def ogr_geojson_62(): # Extensive test of field tye promotion -def ogr_geojson_63(): +def test_ogr_geojson_63(): ds_ref = ogr.Open('data/test_type_promotion_ref.json') lyr_ref = ds_ref.GetLayer(0) @@ -3809,7 +3809,7 @@ def ogr_geojson_63(): # Test exporting XYM / XYZM (#6935) -def ogr_geojson_64(): +def test_ogr_geojson_64(): g = ogr.CreateGeometryFromWkt('POINT ZM(1 2 3 4)') if ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), @@ -3838,7 +3838,7 @@ def ogr_geojson_64(): # See https://github.com/r-spatial/sf/issues/449#issuecomment-319369945 -def ogr_geojson_65(): +def test_ogr_geojson_65(): ds = ogr.Open("""{ "type": "FeatureCollection", @@ -3864,7 +3864,7 @@ def ogr_geojson_65(): # Test features with properties not being a dictionary -def ogr_geojson_66(): +def test_ogr_geojson_66(): ds = ogr.Open("""{ "type": "FeatureCollection", @@ -3890,7 +3890,7 @@ def ogr_geojson_66(): ############################################################################### # Test reading GeoJSON files starting with {"features":[{"geometry":.... (#7198) -def ogr_geojson_67(): +def test_ogr_geojson_67(): ds = ogr.Open('data/grenada.geojson') if ds is None: @@ -3909,7 +3909,7 @@ def ogr_geojson_67(): ############################################################################### # Test reading ESRIJSON files starting with {"features":[{"geometry":.... (#7198) -def ogr_geojson_68(): +def test_ogr_geojson_68(): ds = ogr.Open('data/esrijsonstartingwithfeaturesgeometry.json') if ds is None: @@ -3927,7 +3927,7 @@ def ogr_geojson_68(): ############################################################################### -def ogr_geojson_id_field_and_id_type(): +def test_ogr_geojson_id_field_and_id_type(): gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', options='-f GeoJSON -lco ID_TYPE=String -preserve_fid -limit 1 -fid 2') got = read_file('/vsimem/out.json') @@ -4042,7 +4042,7 @@ def ogr_geojson_id_field_and_id_type(): ############################################################################### -def ogr_geojson_geom_export_failure(): +def test_ogr_geojson_geom_export_failure(): g = ogr.CreateGeometryFromWkt('POINT EMPTY') geojson = g.ExportToJson() @@ -4092,7 +4092,7 @@ def ogr_geojson_geom_export_failure(): ############################################################################### -def ogr_geojson_starting_with_crs(): +def test_ogr_geojson_starting_with_crs(): ds = ogr.Open("""{ "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32631" } }, @@ -4113,7 +4113,7 @@ def ogr_geojson_starting_with_crs(): # Test we properly flush the file in SyncToDisk() in append situations -def ogr_geojson_append_flush(): +def test_ogr_geojson_append_flush(): tmpfilename = 'tmp/ogr_geojson_append_flush.json' f = gdal.VSIFOpenL(tmpfilename, 'wb') @@ -4148,7 +4148,7 @@ def ogr_geojson_append_flush(): ############################################################################### -def ogr_geojson_empty_geometrycollection(): +def test_ogr_geojson_empty_geometrycollection(): g = ogr.CreateGeometryFromJson('{"type": "GeometryCollection", "geometries": []}') if g.ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': @@ -4160,7 +4160,7 @@ def ogr_geojson_empty_geometrycollection(): ############################################################################### -def ogr_esrijson_without_geometryType(): +def test_ogr_esrijson_without_geometryType(): ds = ogr.Open("""{ "spatialReference" : { @@ -4191,7 +4191,7 @@ def ogr_esrijson_without_geometryType(): ############################################################################### -def ogr_geojson_read_fields_with_different_case(): +def test_ogr_geojson_read_fields_with_different_case(): ds = ogr.Open("""{ "type": "FeatureCollection", @@ -4212,7 +4212,7 @@ def ogr_geojson_read_fields_with_different_case(): # Test bugfix for https://github.com/OSGeo/gdal/issues/1068 -def ogr_geojson_clip_geometries_rfc7946(): +def test_ogr_geojson_clip_geometries_rfc7946(): if not ogrtest.have_geos(): return 'skip' @@ -4256,7 +4256,7 @@ def ogr_geojson_clip_geometries_rfc7946(): # Test bugfix for https://github.com/OSGeo/gdal/issues/1109 -def ogr_geojson_non_finite(): +def test_ogr_geojson_non_finite(): json_content = """{ "type": "FeatureCollection", @@ -4331,7 +4331,7 @@ def ogr_geojson_non_finite(): ############################################################################### -def ogr_geojson_cleanup(): +def test_ogr_geojson_cleanup(): gdal.SetConfigOption('CPL_CURL_ENABLE_VSIMEM', None) @@ -4367,84 +4367,84 @@ def ogr_geojson_cleanup(): gdaltest_list = [ - ogr_geojson_1, - ogr_geojson_2, - ogr_geojson_3, - ogr_geojson_4, - ogr_geojson_5, - ogr_geojson_6, - ogr_geojson_7, - ogr_geojson_8, - ogr_geojson_9, - ogr_geojson_10, - ogr_geojson_11, - ogr_geojson_12, - ogr_geojson_13, - ogr_geojson_14, - ogr_geojson_15, - ogr_geojson_16, - ogr_geojson_17, - ogr_geojson_18, - ogr_geojson_19, - ogr_geojson_20, - ogr_geojson_21, - ogr_geojson_22, - ogr_geojson_23, - ogr_geojson_24, - ogr_geojson_25, - ogr_geojson_26, - ogr_geojson_27, - ogr_geojson_28, - ogr_geojson_29, - ogr_geojson_30, - ogr_geojson_31, - ogr_geojson_32, - ogr_geojson_33, - ogr_geojson_34, - ogr_geojson_35, - ogr_geojson_36, - ogr_geojson_37, - ogr_geojson_38, - ogr_geojson_39, - ogr_geojson_40, - ogr_geojson_41, - ogr_geojson_42, - ogr_geojson_43, - ogr_geojson_44, - ogr_geojson_45, - ogr_geojson_46, - ogr_geojson_47, - ogr_geojson_48, - ogr_geojson_49, - ogr_geojson_50, - ogr_geojson_51, - ogr_geojson_52, - ogr_geojson_53, - ogr_geojson_54, - ogr_geojson_55, - ogr_geojson_56, - ogr_geojson_57, - ogr_geojson_58, - ogr_geojson_59, - ogr_geojson_60, - ogr_geojson_61, - ogr_geojson_62, - ogr_geojson_63, - ogr_geojson_64, - ogr_geojson_65, - ogr_geojson_66, - ogr_geojson_67, - ogr_geojson_68, - ogr_geojson_id_field_and_id_type, - ogr_geojson_geom_export_failure, - ogr_geojson_starting_with_crs, - ogr_geojson_append_flush, - ogr_geojson_empty_geometrycollection, - ogr_esrijson_without_geometryType, - ogr_geojson_read_fields_with_different_case, - ogr_geojson_clip_geometries_rfc7946, - ogr_geojson_non_finite, - ogr_geojson_cleanup] + test_ogr_geojson_1, + test_ogr_geojson_2, + test_ogr_geojson_3, + test_ogr_geojson_4, + test_ogr_geojson_5, + test_ogr_geojson_6, + test_ogr_geojson_7, + test_ogr_geojson_8, + test_ogr_geojson_9, + test_ogr_geojson_10, + test_ogr_geojson_11, + test_ogr_geojson_12, + test_ogr_geojson_13, + test_ogr_geojson_14, + test_ogr_geojson_15, + test_ogr_geojson_16, + test_ogr_geojson_17, + test_ogr_geojson_18, + test_ogr_geojson_19, + test_ogr_geojson_20, + test_ogr_geojson_21, + test_ogr_geojson_22, + test_ogr_geojson_23, + test_ogr_geojson_24, + test_ogr_geojson_25, + test_ogr_geojson_26, + test_ogr_geojson_27, + test_ogr_geojson_28, + test_ogr_geojson_29, + test_ogr_geojson_30, + test_ogr_geojson_31, + test_ogr_geojson_32, + test_ogr_geojson_33, + test_ogr_geojson_34, + test_ogr_geojson_35, + test_ogr_geojson_36, + test_ogr_geojson_37, + test_ogr_geojson_38, + test_ogr_geojson_39, + test_ogr_geojson_40, + test_ogr_geojson_41, + test_ogr_geojson_42, + test_ogr_geojson_43, + test_ogr_geojson_44, + test_ogr_geojson_45, + test_ogr_geojson_46, + test_ogr_geojson_47, + test_ogr_geojson_48, + test_ogr_geojson_49, + test_ogr_geojson_50, + test_ogr_geojson_51, + test_ogr_geojson_52, + test_ogr_geojson_53, + test_ogr_geojson_54, + test_ogr_geojson_55, + test_ogr_geojson_56, + test_ogr_geojson_57, + test_ogr_geojson_58, + test_ogr_geojson_59, + test_ogr_geojson_60, + test_ogr_geojson_61, + test_ogr_geojson_62, + test_ogr_geojson_63, + test_ogr_geojson_64, + test_ogr_geojson_65, + test_ogr_geojson_66, + test_ogr_geojson_67, + test_ogr_geojson_68, + test_ogr_geojson_id_field_and_id_type, + test_ogr_geojson_geom_export_failure, + test_ogr_geojson_starting_with_crs, + test_ogr_geojson_append_flush, + test_ogr_geojson_empty_geometrycollection, + test_ogr_esrijson_without_geometryType, + test_ogr_geojson_read_fields_with_different_case, + test_ogr_geojson_clip_geometries_rfc7946, + test_ogr_geojson_non_finite, + test_ogr_geojson_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_geojsonseq.py b/autotest/ogr/ogr_geojsonseq.py index 6107c96ae2df..6b391aadfa27 100755 --- a/autotest/ogr/ogr_geojsonseq.py +++ b/autotest/ogr/ogr_geojsonseq.py @@ -102,19 +102,19 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): return 'success' -def ogr_geojsonseq_lf(): +def test_ogr_geojsonseq_lf(): return _ogr_geojsonseq_create('/vsimem/test', [], False) -def ogr_geojsonseq_rs(): +def test_ogr_geojsonseq_rs(): return _ogr_geojsonseq_create('/vsimem/test', ['RS=YES'], True) -def ogr_geojsonseq_rs_auto(): +def test_ogr_geojsonseq_rs_auto(): return _ogr_geojsonseq_create('/vsimem/test.geojsons', [], True) -def ogr_geojsonseq_inline(): +def test_ogr_geojsonseq_inline(): ds = ogr.Open("""{"type":"Feature","properties":{},"geometry":null} {"type":"Feature","properties":{},"geometry":null}""") @@ -125,7 +125,7 @@ def ogr_geojsonseq_inline(): return 'success' -def ogr_geojsonseq_prefix(): +def test_ogr_geojsonseq_prefix(): ds = ogr.Open("""GeoJSONSeq:data/test.geojsonl""") lyr = ds.GetLayer(0) @@ -135,7 +135,7 @@ def ogr_geojsonseq_prefix(): return 'success' -def ogr_geojsonseq_seq_geometries(): +def test_ogr_geojsonseq_seq_geometries(): with gdaltest.config_option('OGR_GEOJSONSEQ_CHUNK_SIZE', '10'): ds = ogr.Open("""{"type":"Point","coordinates":[2,49]} @@ -153,7 +153,7 @@ def ogr_geojsonseq_seq_geometries(): return 'success' -def ogr_geojsonseq_reprojection(): +def test_ogr_geojsonseq_reprojection(): filename = '/vsimem/ogr_geojsonseq_reprojection.geojsonl' ds = ogr.GetDriverByName('GeoJSONSeq').CreateDataSource(filename) @@ -181,7 +181,7 @@ def ogr_geojsonseq_reprojection(): return 'success' -def ogr_geojsonseq_read_rs_json_pretty(): +def test_ogr_geojsonseq_read_rs_json_pretty(): ds = ogr.Open('data/test.geojsons') lyr = ds.GetLayer(0) @@ -202,7 +202,7 @@ def ogr_geojsonseq_read_rs_json_pretty(): return 'success' -def ogr_geojsonseq_test_ogrsf(): +def test_ogr_geojsonseq_test_ogrsf(): import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is None: @@ -219,15 +219,15 @@ def ogr_geojsonseq_test_ogrsf(): gdaltest_list = [ - ogr_geojsonseq_lf, - ogr_geojsonseq_rs, - ogr_geojsonseq_rs_auto, - ogr_geojsonseq_inline, - ogr_geojsonseq_prefix, - ogr_geojsonseq_seq_geometries, - ogr_geojsonseq_reprojection, - ogr_geojsonseq_read_rs_json_pretty, - ogr_geojsonseq_test_ogrsf, + test_ogr_geojsonseq_lf, + test_ogr_geojsonseq_rs, + test_ogr_geojsonseq_rs_auto, + test_ogr_geojsonseq_inline, + test_ogr_geojsonseq_prefix, + test_ogr_geojsonseq_seq_geometries, + test_ogr_geojsonseq_reprojection, + test_ogr_geojsonseq_read_rs_json_pretty, + test_ogr_geojsonseq_test_ogrsf, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_geom.py b/autotest/ogr/ogr_geom.py index 2e11a421f336..3fd3664f48ab 100755 --- a/autotest/ogr/ogr_geom.py +++ b/autotest/ogr/ogr_geom.py @@ -44,7 +44,7 @@ # get_Area() methods as well). -def ogr_geom_area(): +def test_ogr_geom_area(): geom_wkt = 'MULTIPOLYGON( ((0 0,1 1,1 0,0 0)),((0 0,10 0, 10 10, 0 10),(1 1,1 2,2 2,2 1)) )' geom = ogr.CreateGeometryFromWkt(geom_wkt) @@ -67,7 +67,7 @@ def ogr_geom_area(): # getGeometryType value). -def ogr_geom_area_linearring(): +def test_ogr_geom_area_linearring(): geom = ogr.Geometry(type=ogr.wkbLinearRing) geom.AddPoint_2D(0, 0) @@ -87,7 +87,7 @@ def ogr_geom_area_linearring(): # Test Area calculation for a GeometryCollection -def ogr_geom_area_geometrycollection(): +def test_ogr_geom_area_geometrycollection(): # OGR >= 1.8.0 geom_wkt = 'GEOMETRYCOLLECTION( POLYGON((0 0,1 1,1 0,0 0)), MULTIPOLYGON(((0 0,1 1,1 0,0 0))), LINESTRING(0 0,1 1), POINT(0 0), GEOMETRYCOLLECTION EMPTY )' @@ -105,7 +105,7 @@ def ogr_geom_area_geometrycollection(): # huge value With algorithm prior to #3556, this would return 0. -def ogr_geom_area_linearring_big_offset(): +def test_ogr_geom_area_linearring_big_offset(): geom = ogr.Geometry(type=ogr.wkbLinearRing) BIGOFFSET = 1.0e11 @@ -126,7 +126,7 @@ def ogr_geom_area_linearring_big_offset(): # Test Area calculation for a Triangle -def ogr_geom_area_triangle(): +def test_ogr_geom_area_triangle(): geom_wkt = 'TRIANGLE((0 0,100 0,0 100,0 0))' geom = ogr.CreateGeometryFromWkt(geom_wkt) @@ -145,7 +145,7 @@ def ogr_geom_area_triangle(): return 'success' -def ogr_geom_is_empty(): +def test_ogr_geom_is_empty(): geom_wkt = 'LINESTRING EMPTY' geom = ogr.CreateGeometryFromWkt(geom_wkt) @@ -169,7 +169,7 @@ def ogr_geom_is_empty(): # Test if a Triangle is Empty -def ogr_geom_is_empty_triangle(): +def test_ogr_geom_is_empty_triangle(): geom_wkt = 'TRIANGLE EMPTY' geom = ogr.CreateGeometryFromWkt(geom_wkt) @@ -197,7 +197,7 @@ def ogr_geom_is_empty_triangle(): return 'success' -def ogr_geom_pickle(): +def test_ogr_geom_pickle(): geom_wkt = 'MULTIPOLYGON( ((0 0,1 1,1 0,0 0)),((0 0,10 0, 10 10, 0 10),(1 1,1 2,2 2,2 1)) )' geom = ogr.CreateGeometryFromWkt(geom_wkt) p = pickle.dumps(geom) @@ -214,7 +214,7 @@ def ogr_geom_pickle(): # Test suite for PolyhedralSurface -def ogr_geom_polyhedral_surface(): +def test_ogr_geom_polyhedral_surface(): wkt_original = 'POLYHEDRALSURFACE Z (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),\ ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),\ @@ -325,7 +325,7 @@ def ogr_geom_polyhedral_surface(): # Test suite for TIN -def ogr_geom_tin(): +def test_ogr_geom_tin(): poly1 = ogr.CreateGeometryFromWkt("TRIANGLE ((0 0 0,0 0 1,0 1 0,0 0 0))") poly2 = ogr.CreateGeometryFromWkt("TRIANGLE ((0 0 0,0 1 0,1 1 0,0 0 0))") tin = ogr.Geometry(ogr.wkbTIN) @@ -458,7 +458,7 @@ def ogr_geom_tin(): # Test OGRGeometry::getBoundary() result for point. -def ogr_geom_boundary_point(): +def test_ogr_geom_boundary_point(): if not ogrtest.have_geos(): return 'skip' @@ -482,7 +482,7 @@ def ogr_geom_boundary_point(): # Test OGRGeometry::getBoundary() result for multipoint. -def ogr_geom_boundary_multipoint(): +def test_ogr_geom_boundary_multipoint(): if not ogrtest.have_geos(): return 'skip' @@ -501,7 +501,7 @@ def ogr_geom_boundary_multipoint(): # Test OGRGeometry::getBoundary() result for linestring. -def ogr_geom_boundary_linestring(): +def test_ogr_geom_boundary_linestring(): if not ogrtest.have_geos(): return 'skip' @@ -537,7 +537,7 @@ def ogr_geom_boundary_linestring(): # Test OGRGeometry::getBoundary() result for polygon. -def ogr_geom_boundary_polygon(): +def test_ogr_geom_boundary_polygon(): if not ogrtest.have_geos(): return 'skip' @@ -557,7 +557,7 @@ def ogr_geom_boundary_polygon(): # Test OGRBuildPolygonFromEdges() on a geometry collection of line strings -def ogr_geom_build_from_edges_1(): +def test_ogr_geom_build_from_edges_1(): if not ogrtest.have_geos(): return 'skip' @@ -590,7 +590,7 @@ def ogr_geom_build_from_edges_1(): # Test OGRBuildPolygonFromEdges() on a multilinestring -def ogr_geom_build_from_edges_2(): +def test_ogr_geom_build_from_edges_2(): if not ogrtest.have_geos(): return 'skip' @@ -622,7 +622,7 @@ def ogr_geom_build_from_edges_2(): # Test OGRBuildPolygonFromEdges() on invalid geometries -def ogr_geom_build_from_edges_3(): +def test_ogr_geom_build_from_edges_3(): if not ogrtest.have_geos(): return 'skip' @@ -653,7 +653,7 @@ def ogr_geom_build_from_edges_3(): # Test OGRBuildPolygonFromEdges() and identify exterior ring (#3610) -def ogr_geom_build_from_edges_4(): +def test_ogr_geom_build_from_edges_4(): if int(gdal.VersionInfo('VERSION_NUM')) < 1900: gdaltest.post_reason('would crash') @@ -699,7 +699,7 @@ def ogr_geom_build_from_edges_4(): # Test GetArea() on empty linear ring (#2792) -def ogr_geom_area_empty_linearring(): +def test_ogr_geom_area_empty_linearring(): geom = ogr.Geometry(type=ogr.wkbLinearRing) @@ -713,7 +713,7 @@ def ogr_geom_area_empty_linearring(): # Test TransformTo() -def ogr_geom_transform_to(): +def test_ogr_geom_transform_to(): # Somewhere in Paris suburbs... geom = ogr.CreateGeometryFromWkt('POINT(2 49)') @@ -748,7 +748,7 @@ def ogr_geom_transform_to(): # Test Transform() -def ogr_geom_transform(): +def test_ogr_geom_transform(): # Somewhere in Paris suburbs... geom = ogr.CreateGeometryFromWkt('POINT(2 49)') @@ -775,7 +775,7 @@ def ogr_geom_transform(): # Test CloseRings() -def ogr_geom_closerings(): +def test_ogr_geom_closerings(): geom = ogr.CreateGeometryFromWkt('POLYGON((0 0,0 1,1 1,1 0))') geom.CloseRings() @@ -795,7 +795,7 @@ def ogr_geom_closerings(): # Test Segmentize() -def ogr_geom_segmentize(): +def test_ogr_geom_segmentize(): geom = ogr.CreateGeometryFromWkt('LINESTRING(0 0,0 10)') geom.Segmentize(1.00001) @@ -834,7 +834,7 @@ def ogr_geom_segmentize(): # Test Value() -def ogr_geom_value(): +def test_ogr_geom_value(): geom = ogr.CreateGeometryFromWkt('LINESTRING(2 3,5 3,5 0)') @@ -879,7 +879,7 @@ def ogr_geom_value(): # Test FlattenTo2D(), GetDimension() and GetCoordinateDimension() -def ogr_geom_flattenTo2D(): +def test_ogr_geom_flattenTo2D(): geom = ogr.CreateGeometryFromWkt('POINT (1 2 3)') @@ -911,7 +911,7 @@ def ogr_geom_flattenTo2D(): # Test FlattenTo2D(), GetDimension() and GetCoordinateDimension() for Triangle -def ogr_geom_flattenTo2D_triangle(): +def test_ogr_geom_flattenTo2D_triangle(): geom = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0 0,100 0 100,0 100 100,0 0 0))') @@ -942,7 +942,7 @@ def ogr_geom_flattenTo2D_triangle(): ############################################################################### -def ogr_geom_linestring_limits(): +def test_ogr_geom_linestring_limits(): geom = ogr.CreateGeometryFromWkt('LINESTRING EMPTY') if geom.Length() != 0: @@ -1017,7 +1017,7 @@ def ogr_geom_linestring_limits(): ############################################################################### -def ogr_geom_coord_round(): +def test_ogr_geom_coord_round(): geom = ogr.CreateGeometryFromWkt('POINT(370441.860 5591000.590)') wkt = geom.ExportToWkt() @@ -1031,7 +1031,7 @@ def ogr_geom_coord_round(): ############################################################################### -def ogr_geom_coord_round_2(): +def test_ogr_geom_coord_round_2(): geom = ogr.CreateGeometryFromWkt('POINT(1.0 169.600374)') wkt = geom.ExportToWkt() @@ -1046,7 +1046,7 @@ def ogr_geom_coord_round_2(): # Test Area calculation for a Point -def ogr_geom_area_point(): +def test_ogr_geom_area_point(): geom_wkt = 'POINT(0 0)' geom = ogr.CreateGeometryFromWkt(geom_wkt) @@ -1063,7 +1063,7 @@ def ogr_geom_area_point(): # Test Length calculation for a Point -def ogr_geom_length_point(): +def test_ogr_geom_length_point(): # OGR >= 1.8.0 geom_wkt = 'POINT(0 0)' @@ -1081,7 +1081,7 @@ def ogr_geom_length_point(): # Test Length calculation for a MultiLineString -def ogr_geom_length_multilinestring(): +def test_ogr_geom_length_multilinestring(): # OGR >= 1.8.0 geom_wkt = 'MULTILINESTRING((0 0,0 1),(0 0,0 1))' @@ -1098,7 +1098,7 @@ def ogr_geom_length_multilinestring(): # Test Length calculation for a GeometryCollection -def ogr_geom_length_geometrycollection(): +def test_ogr_geom_length_geometrycollection(): # OGR >= 1.8.0 geom_wkt = 'GEOMETRYCOLLECTION( POLYGON((0 0,0 1,1 1,1 0,0 0)), MULTILINESTRING((0 0,0 1),(0 0,0 1)), LINESTRING(0 0,0 1), LINESTRING(0 0,0 1), POINT(0 0), GEOMETRYCOLLECTION EMPTY )' @@ -1115,7 +1115,7 @@ def ogr_geom_length_geometrycollection(): # Test Geometry.GetPoints() (#4016) -def ogr_geom_getpoints(): +def test_ogr_geom_getpoints(): geom = ogr.CreateGeometryFromWkt('LINESTRING(0 1,2 3)') points = geom.GetPoints() @@ -1171,7 +1171,7 @@ def ogr_geom_getpoints(): # Test OGRGeometry::empty() -def ogr_geom_empty(): +def test_ogr_geom_empty(): g1 = ogr.CreateGeometryFromWkt('POLYGON((0 0,1 1,1 2,1 1,0 0))') g1.Empty() @@ -1186,7 +1186,7 @@ def ogr_geom_empty(): # Test OGRGeometry::empty() for Triangle -def ogr_geom_empty_triangle(): +def test_ogr_geom_empty_triangle(): g1 = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,100 0,0 100,0 0))') g1.Empty() @@ -1201,7 +1201,7 @@ def ogr_geom_empty_triangle(): # Test parsing WKT made of 2D and 3D parts -def ogr_geom_mixed_coordinate_dimension(): +def test_ogr_geom_mixed_coordinate_dimension(): # first part is 3D, second part is 2D of same length wkt = 'MULTIPOLYGON (((1 2 -4,1 3 -3,2 3 -3,2 2 -3,1 2 -6)),((-1 -2,-1 -3,-2 -3,-2 -2,-1 -2,50 60)))' @@ -1227,7 +1227,7 @@ def ogr_geom_mixed_coordinate_dimension(): # Test GetEnvelope3D() -def ogr_geom_getenvelope3d(): +def test_ogr_geom_getenvelope3d(): g = ogr.CreateGeometryFromWkt('POINT EMPTY') envelope = g.GetEnvelope3D() @@ -1307,7 +1307,7 @@ def ogr_geom_getenvelope3d(): # Test importing/exporting XXX Z EMPTY -def ogr_geom_z_empty(): +def test_ogr_geom_z_empty(): for geom in ['POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION', 'CIRCULARSTRING', 'COMPOUNDCURVE', @@ -1333,7 +1333,7 @@ def ogr_geom_z_empty(): # Test HasCurveGeometry and GetLinearGeometry -def ogr_geom_getlineargeometry(): +def test_ogr_geom_getlineargeometry(): for geom in ['POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION', @@ -1381,7 +1381,7 @@ def ogr_geom_getlineargeometry(): # Test GetDimension() -def ogr_geom_getdimension(): +def test_ogr_geom_getdimension(): for (geom, dim) in [('POINT EMPTY', 0), ('LINESTRING EMPTY', 1), ('POLYGON EMPTY', 2), @@ -1420,7 +1420,7 @@ def ogr_geom_getdimension(): # Test triangle -def ogr_geom_triangle(): +def test_ogr_geom_triangle(): wkt_original = 'TRIANGLE ((0 0,0 1,1 1,0 0))' geom = ogr.CreateGeometryFromWkt(wkt_original) @@ -1455,7 +1455,7 @@ def ogr_geom_triangle(): # Test importing invalid triangle WKT -def ogr_geom_triangle_invalid_wkt(): +def test_ogr_geom_triangle_invalid_wkt(): geom_wkt = 'TRIANGLE (0 0)' with gdaltest.error_handler(): @@ -1502,7 +1502,7 @@ def ogr_geom_triangle_invalid_wkt(): # Test OGRTriangle. Tests if the GEOS/SFCGAL methods are working -def ogr_geom_triangle_sfcgal(): +def test_ogr_geom_triangle_sfcgal(): if not ogrtest.have_sfcgal(): return 'skip' @@ -1527,7 +1527,7 @@ def ogr_geom_triangle_sfcgal(): # Test OGRCircularString -def ogr_geom_circularstring(): +def test_ogr_geom_circularstring(): in_wkt = 'CIRCULARSTRING (0 0,1 1,1 -1)' @@ -2064,7 +2064,7 @@ def ogr_geom_circularstring(): # Test OGRCompoundCurve -def ogr_geom_compoundcurve(): +def test_ogr_geom_compoundcurve(): in_wkt = 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))' g1 = ogr.CreateGeometryFromWkt(in_wkt) @@ -2472,7 +2472,7 @@ def ogr_geom_compoundcurve(): # Test OGRCurvePolygon -def ogr_geom_curvepolygon(): +def test_ogr_geom_curvepolygon(): in_wkt = 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) @@ -2861,7 +2861,7 @@ def ogr_geom_curvepolygon(): # Test OGRMultiCurve -def ogr_geom_multicurve(): +def test_ogr_geom_multicurve(): # Simple test in_wkt = 'MULTICURVE (CIRCULARSTRING (0 0,1 0,0 0))' @@ -2985,7 +2985,7 @@ def ogr_geom_multicurve(): # Test OGRMultiSurface -def ogr_geom_multisurface(): +def test_ogr_geom_multisurface(): # Simple test in_wkt = 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0)))' @@ -3125,7 +3125,7 @@ def ogr_geom_multisurface(): # Test GetCurveGeometry -def ogr_geom_getcurvegeometry(): +def test_ogr_geom_getcurvegeometry(): for geom in ['POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION', @@ -3586,7 +3586,7 @@ def ogr_geom_getcurvegeometry(): # Test OGR_GT_ functions -def ogr_geom_gt_functions(): +def test_ogr_geom_gt_functions(): # GT_HasZ tuples = [(ogr.wkbPoint, 0), @@ -3844,7 +3844,7 @@ def ogr_geom_gt_functions(): # Limit cases -def ogr_geom_api_limit_tests(): +def test_ogr_geom_api_limit_tests(): p = ogr.Geometry(ogr.wkbPoint) lyr = ogr.Geometry(ogr.wkbLineString) @@ -3893,7 +3893,7 @@ def ogr_geom_api_limit_tests(): # Test Equals -def ogr_geom_equals(): +def test_ogr_geom_equals(): p_empty = ogr.Geometry(ogr.wkbPoint) p_0 = ogr.CreateGeometryFromWkt('POINT (0 0)') @@ -3964,7 +3964,7 @@ def ogr_geom_equals(): # Test FlattenTo2D(), SetCoordinateDimension(2) and SetCoordinateDimension(3) with Measured geometries -def ogr_geom_measured_geometries_to_2D_or_3D(): +def test_ogr_geom_measured_geometries_to_2D_or_3D(): list_wkt = [['POINT M (1 2 3)', 'POINT (1 2)', 'POINT Z (1 2 0)'], ['POINT ZM (1 2 3 4)', 'POINT (1 2)', 'POINT Z (1 2 3)'], @@ -4071,7 +4071,7 @@ def ogr_geom_measured_geometries_to_2D_or_3D(): # Test PostGIS EWKT with XYM -def ogr_geom_postgis_ewkt_xym(): +def test_ogr_geom_postgis_ewkt_xym(): list_wkt = [['POINTM(1 2 3)', 'POINT M (1 2 3)'], ['GEOMETRYCOLLECTIONM(POINTM(1 2 3))', 'GEOMETRYCOLLECTION M (POINT M (1 2 3))'], @@ -4091,7 +4091,7 @@ def ogr_geom_postgis_ewkt_xym(): # Test ogr.wkbCurve / ogr.wkbSurface -def ogr_geom_curve_surface(): +def test_ogr_geom_curve_surface(): tests = [[ogr.wkbCurve, "Curve"], [ogr.wkbCurveZ, "3D Curve"], @@ -4116,7 +4116,7 @@ def ogr_geom_curve_surface(): # Test importing corrupted WKB -def ogr_geom_import_corrupted_wkb(): +def test_ogr_geom_import_corrupted_wkb(): list_wkt = ['POINT ZM (1 2 3 4)' 'LINESTRING ZM (1 2 3 4)' @@ -4181,7 +4181,7 @@ def ogr_geom_import_corrupted_wkb(): # Test conversions from/into triangle, TIN, PS -def ogr_geom_triangle_ps_tin_conversion(): +def test_ogr_geom_triangle_ps_tin_conversion(): wkts = ["TRIANGLE ((0 0,0 1,1 1,0 0))", "POLYGON ((0 0,0 1,1 1,0 0))", @@ -4261,7 +4261,7 @@ def ogr_geom_triangle_ps_tin_conversion(): ############################################################################### -def ogr_geom_multipoint_envelope_bug(): +def test_ogr_geom_multipoint_envelope_bug(): g = ogr.CreateGeometryFromWkt('MULTIPOINT(0 0,1 1)') minx, maxx, miny, maxy = g.GetEnvelope() @@ -4282,7 +4282,7 @@ def ogr_geom_multipoint_envelope_bug(): ############################################################################### -def ogr_geom_polygon_empty_ring(): +def test_ogr_geom_polygon_empty_ring(): g = ogr.Geometry(ogr.wkbPolygon) g2 = ogr.Geometry(ogr.wkbLinearRing) @@ -4295,7 +4295,7 @@ def ogr_geom_polygon_empty_ring(): ############################################################################### -def ogr_geom_polygon_intersects_point(): +def test_ogr_geom_polygon_intersects_point(): if not ogrtest.have_geos(): return 'skip' @@ -4316,7 +4316,7 @@ def ogr_geom_polygon_intersects_point(): # Test fix for #7128 -def ogr_geom_geometrycollection(): +def test_ogr_geom_geometrycollection(): wkt_list = ['GEOMETRYCOLLECTION (POINT EMPTY)', 'GEOMETRYCOLLECTION (LINESTRING EMPTY)', @@ -4345,7 +4345,7 @@ def ogr_geom_geometrycollection(): # Test fix for #7126 -def ogr_geom_assignspatialref(): +def test_ogr_geom_assignspatialref(): g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POLYGON((0 0,0 1,1 1,0 0)),COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,2 0)),POLYHEDRALSURFACE(((0 0,0 1,1 1,0 0))))') sr = osr.SpatialReference() @@ -4369,7 +4369,7 @@ def ogr_geom_assignspatialref(): ############################################################################### -def ogr_geom_swapxy(): +def test_ogr_geom_swapxy(): g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(1 2,2 3),POLYGON((0 0,0 1,1 1,0 0)),COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,2 0)),POLYHEDRALSURFACE(((0 0,0 1,1 1,0 0))))') g.SwapXY() @@ -4382,7 +4382,7 @@ def ogr_geom_swapxy(): ############################################################################### -def ogr_geom_remove_geometry(): +def test_ogr_geom_remove_geometry(): # With GEOMETRYCOLLECTION g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 2),LINESTRING (1 2,2 3),POINT (3 4))') @@ -4496,7 +4496,7 @@ def ogr_geom_remove_geometry(): ############################################################################### -def ogr_geom_sfcgal(): +def test_ogr_geom_sfcgal(): if not ogrtest.have_sfcgal(): return 'skip' @@ -4518,7 +4518,7 @@ def ogr_geom_sfcgal(): ############################################################################### -def ogr_geom_cannot_add_triangle_to_multisurface(): +def test_ogr_geom_cannot_add_triangle_to_multisurface(): g = ogr.Geometry(ogr.wkbMultiSurface) if g.AddGeometry(ogr.Geometry(ogr.wkbTriangle)) == 0: @@ -4528,7 +4528,7 @@ def ogr_geom_cannot_add_triangle_to_multisurface(): ############################################################################### -def ogr_geom_force_polygonzm_to_linestring(): +def test_ogr_geom_force_polygonzm_to_linestring(): g = ogr.CreateGeometryFromWkt('POLYGON ZM ((0 0 10 20,0 1 30 40,1 1 50 60,0 0 10 70))') wkt = ogr.ForceToLineString(g).ExportToIsoWkt() if wkt != 'LINESTRING ZM (0 0 10 20,0 1 30 40,1 1 50 60,0 0 10 70)': @@ -4540,80 +4540,80 @@ def ogr_geom_force_polygonzm_to_linestring(): # cleanup -def ogr_geom_cleanup(): +def test_ogr_geom_cleanup(): return 'success' gdaltest_list = [ - ogr_geom_area, - ogr_geom_polyhedral_surface, - ogr_geom_tin, - ogr_geom_area_triangle, - ogr_geom_area_linearring, - ogr_geom_area_linearring_big_offset, - ogr_geom_area_geometrycollection, - ogr_geom_is_empty, - ogr_geom_is_empty_triangle, - ogr_geom_pickle, - ogr_geom_boundary_point, - ogr_geom_boundary_multipoint, - ogr_geom_boundary_linestring, - ogr_geom_boundary_polygon, - ogr_geom_build_from_edges_1, - ogr_geom_build_from_edges_2, - ogr_geom_build_from_edges_3, - ogr_geom_build_from_edges_4, - ogr_geom_area_empty_linearring, - ogr_geom_transform_to, - ogr_geom_transform, - ogr_geom_closerings, - ogr_geom_segmentize, - ogr_geom_value, - ogr_geom_flattenTo2D, - ogr_geom_flattenTo2D_triangle, - ogr_geom_linestring_limits, - ogr_geom_coord_round, - ogr_geom_coord_round_2, - ogr_geom_area_point, - ogr_geom_length_point, - ogr_geom_length_multilinestring, - ogr_geom_length_geometrycollection, - ogr_geom_empty_triangle, - ogr_geom_triangle, - ogr_geom_triangle_invalid_wkt, - ogr_geom_triangle_sfcgal, - ogr_geom_empty, - ogr_geom_getpoints, - ogr_geom_mixed_coordinate_dimension, - ogr_geom_getenvelope3d, - ogr_geom_z_empty, - ogr_geom_getlineargeometry, - ogr_geom_getdimension, - ogr_geom_circularstring, - ogr_geom_compoundcurve, - ogr_geom_curvepolygon, - ogr_geom_multicurve, - ogr_geom_multisurface, - ogr_geom_getcurvegeometry, - ogr_geom_gt_functions, - ogr_geom_api_limit_tests, - ogr_geom_equals, - ogr_geom_measured_geometries_to_2D_or_3D, - ogr_geom_postgis_ewkt_xym, - ogr_geom_curve_surface, - ogr_geom_import_corrupted_wkb, - ogr_geom_triangle_ps_tin_conversion, - ogr_geom_multipoint_envelope_bug, - ogr_geom_polygon_empty_ring, - ogr_geom_polygon_intersects_point, - ogr_geom_geometrycollection, - ogr_geom_assignspatialref, - ogr_geom_swapxy, - ogr_geom_remove_geometry, - ogr_geom_sfcgal, - ogr_geom_cannot_add_triangle_to_multisurface, - ogr_geom_force_polygonzm_to_linestring, - ogr_geom_cleanup] + test_ogr_geom_area, + test_ogr_geom_polyhedral_surface, + test_ogr_geom_tin, + test_ogr_geom_area_triangle, + test_ogr_geom_area_linearring, + test_ogr_geom_area_linearring_big_offset, + test_ogr_geom_area_geometrycollection, + test_ogr_geom_is_empty, + test_ogr_geom_is_empty_triangle, + test_ogr_geom_pickle, + test_ogr_geom_boundary_point, + test_ogr_geom_boundary_multipoint, + test_ogr_geom_boundary_linestring, + test_ogr_geom_boundary_polygon, + test_ogr_geom_build_from_edges_1, + test_ogr_geom_build_from_edges_2, + test_ogr_geom_build_from_edges_3, + test_ogr_geom_build_from_edges_4, + test_ogr_geom_area_empty_linearring, + test_ogr_geom_transform_to, + test_ogr_geom_transform, + test_ogr_geom_closerings, + test_ogr_geom_segmentize, + test_ogr_geom_value, + test_ogr_geom_flattenTo2D, + test_ogr_geom_flattenTo2D_triangle, + test_ogr_geom_linestring_limits, + test_ogr_geom_coord_round, + test_ogr_geom_coord_round_2, + test_ogr_geom_area_point, + test_ogr_geom_length_point, + test_ogr_geom_length_multilinestring, + test_ogr_geom_length_geometrycollection, + test_ogr_geom_empty_triangle, + test_ogr_geom_triangle, + test_ogr_geom_triangle_invalid_wkt, + test_ogr_geom_triangle_sfcgal, + test_ogr_geom_empty, + test_ogr_geom_getpoints, + test_ogr_geom_mixed_coordinate_dimension, + test_ogr_geom_getenvelope3d, + test_ogr_geom_z_empty, + test_ogr_geom_getlineargeometry, + test_ogr_geom_getdimension, + test_ogr_geom_circularstring, + test_ogr_geom_compoundcurve, + test_ogr_geom_curvepolygon, + test_ogr_geom_multicurve, + test_ogr_geom_multisurface, + test_ogr_geom_getcurvegeometry, + test_ogr_geom_gt_functions, + test_ogr_geom_api_limit_tests, + test_ogr_geom_equals, + test_ogr_geom_measured_geometries_to_2D_or_3D, + test_ogr_geom_postgis_ewkt_xym, + test_ogr_geom_curve_surface, + test_ogr_geom_import_corrupted_wkb, + test_ogr_geom_triangle_ps_tin_conversion, + test_ogr_geom_multipoint_envelope_bug, + test_ogr_geom_polygon_empty_ring, + test_ogr_geom_polygon_intersects_point, + test_ogr_geom_geometrycollection, + test_ogr_geom_assignspatialref, + test_ogr_geom_swapxy, + test_ogr_geom_remove_geometry, + test_ogr_geom_sfcgal, + test_ogr_geom_cannot_add_triangle_to_multisurface, + test_ogr_geom_force_polygonzm_to_linestring, + test_ogr_geom_cleanup] # gdaltest_list = [ ogr_geom_triangle_ps_tin_conversion ] diff --git a/autotest/ogr/ogr_georss.py b/autotest/ogr/ogr_georss.py index e81739b8da59..08f6d4982b70 100755 --- a/autotest/ogr/ogr_georss.py +++ b/autotest/ogr/ogr_georss.py @@ -39,7 +39,7 @@ from osgeo import gdal -def ogr_georss_init(): +def test_ogr_georss_init(): ds = ogr.Open('data/atom_rfc_sample.xml') if ds is None: @@ -112,7 +112,7 @@ def ogr_georss_test_atom(filename): # Test reading an ATOM document without any geometry -def ogr_georss_1(): +def test_ogr_georss_1(): return ogr_georss_test_atom('data/atom_rfc_sample.xml') @@ -120,7 +120,7 @@ def ogr_georss_1(): # Test reading an ATOM document with atom: prefiw -def ogr_georss_1_atom_ns(): +def test_ogr_georss_1_atom_ns(): return ogr_georss_test_atom('data/atom_rfc_sample_atom_ns.xml') @@ -128,7 +128,7 @@ def ogr_georss_1_atom_ns(): # Test writing a Atom 1.0 document (doesn't need read support) -def ogr_georss_1bis(): +def test_ogr_georss_1bis(): try: os.remove('tmp/test_atom.xml') @@ -159,7 +159,7 @@ def ogr_georss_1bis(): ############################################################################### # Test reading document created at previous step -def ogr_georss_1ter(): +def test_ogr_georss_1ter(): return ogr_georss_test_atom('tmp/test_atom.xml') @@ -242,7 +242,7 @@ def ogr_georss_test_rss(filename, only_first_feature): # Test reading a RSS 2.0 document with GeoRSS simple geometries -def ogr_georss_2(): +def test_ogr_georss_2(): return ogr_georss_test_rss('data/test_georss_simple.xml', False) @@ -250,7 +250,7 @@ def ogr_georss_2(): # Test reading a RSS 2.0 document with GeoRSS GML geometries -def ogr_georss_3(): +def test_ogr_georss_3(): if not gdaltest.have_gml_reader: return 'skip' @@ -336,7 +336,7 @@ def ogr_georss_create(filename, options): # Test writing a RSS 2.0 document in Simple dialect (doesn't need read support) -def ogr_georss_4(): +def test_ogr_georss_4(): if ogr_georss_create('tmp/test_rss2.xml', []) != 'success': return 'fail' @@ -352,7 +352,7 @@ def ogr_georss_4(): # Test reading document created at previous step -def ogr_georss_5(): +def test_ogr_georss_5(): return ogr_georss_test_rss('tmp/test_rss2.xml', False) @@ -360,7 +360,7 @@ def ogr_georss_5(): # Test writing a RSS 2.0 document in GML dialect (doesn't need read support) -def ogr_georss_6(): +def test_ogr_georss_6(): if ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=GML']) != 'success': return 'fail' @@ -376,7 +376,7 @@ def ogr_georss_6(): # Test reading document created at previous step -def ogr_georss_7(): +def test_ogr_georss_7(): if not gdaltest.have_gml_reader: return 'skip' @@ -386,7 +386,7 @@ def ogr_georss_7(): # Test writing a RSS 2.0 document in W3C Geo dialect (doesn't need read support) -def ogr_georss_8(): +def test_ogr_georss_8(): if ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=W3C_GEO']) != 'success': return 'fail' @@ -402,7 +402,7 @@ def ogr_georss_8(): # Test reading document created at previous step -def ogr_georss_9(): +def test_ogr_georss_9(): return ogr_georss_test_rss('tmp/test_rss2.xml', True) @@ -410,7 +410,7 @@ def ogr_georss_9(): # Test writing a RSS 2.0 document in GML dialect with EPSG:32631 -def ogr_georss_10(): +def test_ogr_georss_10(): try: os.remove('tmp/test32631.rss') except OSError: @@ -460,7 +460,7 @@ def ogr_georss_10(): # Test reading document created at previous step -def ogr_georss_11(): +def test_ogr_georss_11(): if not gdaltest.georss_read_support: return 'skip' @@ -494,7 +494,7 @@ def ogr_georss_11(): # Test various broken documents -def ogr_georss_12(): +def test_ogr_georss_12(): if not gdaltest.georss_read_support: return 'skip' @@ -528,7 +528,7 @@ def ogr_georss_12(): # Test writing non standard fields -def ogr_georss_13(): +def test_ogr_georss_13(): try: os.remove('tmp/nonstandard.rss') except OSError: @@ -568,7 +568,7 @@ def ogr_georss_13(): # Test reading document created at previous step -def ogr_georss_14(): +def test_ogr_georss_14(): if not gdaltest.georss_read_support: return 'skip' @@ -594,7 +594,7 @@ def ogr_georss_14(): # Test reading an in memory file (#2931) -def ogr_georss_15(): +def test_ogr_georss_15(): if not gdaltest.georss_read_support: return 'skip' @@ -639,7 +639,7 @@ def ogr_georss_15(): # -def ogr_georss_cleanup(): +def test_ogr_georss_cleanup(): list_files = ['tmp/test_rss2.xml', 'tmp/test_atom.xml', 'tmp/test32631.rss', 'tmp/broken.rss', 'tmp/nonstandard.rss'] for filename in list_files: @@ -657,26 +657,26 @@ def ogr_georss_cleanup(): gdaltest_list = [ - ogr_georss_init, - ogr_georss_1, - ogr_georss_1_atom_ns, - ogr_georss_1bis, - ogr_georss_1ter, - ogr_georss_2, - ogr_georss_3, - ogr_georss_4, - ogr_georss_5, - ogr_georss_6, - ogr_georss_7, - ogr_georss_8, - ogr_georss_9, - ogr_georss_10, - ogr_georss_11, - ogr_georss_12, - ogr_georss_13, - ogr_georss_14, - ogr_georss_15, - ogr_georss_cleanup] + test_ogr_georss_init, + test_ogr_georss_1, + test_ogr_georss_1_atom_ns, + test_ogr_georss_1bis, + test_ogr_georss_1ter, + test_ogr_georss_2, + test_ogr_georss_3, + test_ogr_georss_4, + test_ogr_georss_5, + test_ogr_georss_6, + test_ogr_georss_7, + test_ogr_georss_8, + test_ogr_georss_9, + test_ogr_georss_10, + test_ogr_georss_11, + test_ogr_georss_12, + test_ogr_georss_13, + test_ogr_georss_14, + test_ogr_georss_15, + test_ogr_georss_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_geos.py b/autotest/ogr/ogr_geos.py index 870dcc05b301..eba53c158d18 100755 --- a/autotest/ogr/ogr_geos.py +++ b/autotest/ogr/ogr_geos.py @@ -39,7 +39,7 @@ # Establish whether we have GEOS support integrated, testing simple Union. -def ogr_geos_union(): +def test_ogr_geos_union(): if not ogrtest.have_geos(): return 'skip' @@ -58,7 +58,7 @@ def ogr_geos_union(): # Test polygon intersection. -def ogr_geos_intersection(): +def test_ogr_geos_intersection(): if not ogrtest.have_geos(): return 'skip' @@ -78,7 +78,7 @@ def ogr_geos_intersection(): # Test polygon difference. -def ogr_geos_difference(): +def test_ogr_geos_difference(): if not ogrtest.have_geos(): return 'skip' @@ -99,7 +99,7 @@ def ogr_geos_difference(): # Test polygon symmetric difference. -def ogr_geos_symmetric_difference(): +def test_ogr_geos_symmetric_difference(): if not ogrtest.have_geos(): return 'skip' @@ -120,7 +120,7 @@ def ogr_geos_symmetric_difference(): # Test polygon symmetric difference. -def ogr_geos_sym_difference(): +def test_ogr_geos_sym_difference(): if not ogrtest.have_geos(): return 'skip' @@ -141,7 +141,7 @@ def ogr_geos_sym_difference(): # Test Intersect(). -def ogr_geos_intersect(): +def test_ogr_geos_intersect(): if not ogrtest.have_geos(): return 'skip' @@ -170,7 +170,7 @@ def ogr_geos_intersect(): # Test disjoint(). -def ogr_geos_disjoint(): +def test_ogr_geos_disjoint(): if not ogrtest.have_geos(): return 'skip' @@ -199,7 +199,7 @@ def ogr_geos_disjoint(): # Test touches. -def ogr_geos_touches(): +def test_ogr_geos_touches(): if not ogrtest.have_geos(): return 'skip' @@ -228,7 +228,7 @@ def ogr_geos_touches(): # Test crosses. -def ogr_geos_crosses(): +def test_ogr_geos_crosses(): if not ogrtest.have_geos(): return 'skip' @@ -256,7 +256,7 @@ def ogr_geos_crosses(): ############################################################################### -def ogr_geos_within(): +def test_ogr_geos_within(): if not ogrtest.have_geos(): return 'skip' @@ -281,7 +281,7 @@ def ogr_geos_within(): ############################################################################### -def ogr_geos_contains(): +def test_ogr_geos_contains(): if not ogrtest.have_geos(): return 'skip' @@ -306,7 +306,7 @@ def ogr_geos_contains(): ############################################################################### -def ogr_geos_overlaps(): +def test_ogr_geos_overlaps(): if not ogrtest.have_geos(): return 'skip' @@ -335,7 +335,7 @@ def ogr_geos_overlaps(): ############################################################################### -def ogr_geos_buffer(): +def test_ogr_geos_buffer(): if not ogrtest.have_geos(): return 'skip' @@ -354,7 +354,7 @@ def ogr_geos_buffer(): ############################################################################### -def ogr_geos_centroid(): +def test_ogr_geos_centroid(): if not ogrtest.have_geos(): return 'skip' @@ -382,7 +382,7 @@ def ogr_geos_centroid(): ############################################################################### -def ogr_geos_centroid_multipolygon(): +def test_ogr_geos_centroid_multipolygon(): if not ogrtest.have_geos(): return 'skip' @@ -401,7 +401,7 @@ def ogr_geos_centroid_multipolygon(): ############################################################################### -def ogr_geos_centroid_point_empty(): +def test_ogr_geos_centroid_point_empty(): if not ogrtest.have_geos(): return 'skip' @@ -419,7 +419,7 @@ def ogr_geos_centroid_point_empty(): ############################################################################### -def ogr_geos_simplify_linestring(): +def test_ogr_geos_simplify_linestring(): if not ogrtest.have_geos(): return 'skip' @@ -438,7 +438,7 @@ def ogr_geos_simplify_linestring(): ############################################################################### -def ogr_geos_simplifypreservetopology_linestring(): +def test_ogr_geos_simplifypreservetopology_linestring(): if not ogrtest.have_geos(): return 'skip' @@ -457,7 +457,7 @@ def ogr_geos_simplifypreservetopology_linestring(): ############################################################################### -def ogr_geos_unioncascaded(): +def test_ogr_geos_unioncascaded(): if not ogrtest.have_geos(): return 'skip' @@ -476,7 +476,7 @@ def ogr_geos_unioncascaded(): ############################################################################### -def ogr_geos_convexhull(): +def test_ogr_geos_convexhull(): if not ogrtest.have_geos(): return 'skip' @@ -494,7 +494,7 @@ def ogr_geos_convexhull(): ############################################################################### -def ogr_geos_distance(): +def test_ogr_geos_distance(): if not ogrtest.have_geos(): return 'skip' @@ -513,7 +513,7 @@ def ogr_geos_distance(): ############################################################################### -def ogr_geos_isring(): +def test_ogr_geos_isring(): if not ogrtest.have_geos(): return 'skip' @@ -530,7 +530,7 @@ def ogr_geos_isring(): ############################################################################### -def ogr_geos_issimple_true(): +def test_ogr_geos_issimple_true(): if not ogrtest.have_geos(): return 'skip' @@ -547,7 +547,7 @@ def ogr_geos_issimple_true(): ############################################################################### -def ogr_geos_issimple_false(): +def test_ogr_geos_issimple_false(): if not ogrtest.have_geos(): return 'skip' @@ -564,7 +564,7 @@ def ogr_geos_issimple_false(): ############################################################################### -def ogr_geos_isvalid_true(): +def test_ogr_geos_isvalid_true(): if not ogrtest.have_geos(): return 'skip' @@ -581,7 +581,7 @@ def ogr_geos_isvalid_true(): ############################################################################### -def ogr_geos_isvalid_true_linestringM(): +def test_ogr_geos_isvalid_true_linestringM(): if not ogrtest.have_geos(): return 'skip' @@ -598,7 +598,7 @@ def ogr_geos_isvalid_true_linestringM(): ############################################################################### -def ogr_geos_isvalid_true_circularStringM(): +def test_ogr_geos_isvalid_true_circularStringM(): if not ogrtest.have_geos(): return 'skip' @@ -615,7 +615,7 @@ def ogr_geos_isvalid_true_circularStringM(): ############################################################################### -def ogr_geos_isvalid_true_triangle(): +def test_ogr_geos_isvalid_true_triangle(): if not ogrtest.have_geos(): return 'skip' @@ -632,7 +632,7 @@ def ogr_geos_isvalid_true_triangle(): ############################################################################### -def ogr_geos_isvalid_false(): +def test_ogr_geos_isvalid_false(): if not ogrtest.have_geos(): return 'skip' @@ -650,7 +650,7 @@ def ogr_geos_isvalid_false(): ############################################################################### -def ogr_geos_pointonsurface(): +def test_ogr_geos_pointonsurface(): if not ogrtest.have_geos(): return 'skip' @@ -667,7 +667,7 @@ def ogr_geos_pointonsurface(): ############################################################################### -def ogr_geos_DelaunayTriangulation(): +def test_ogr_geos_DelaunayTriangulation(): if not ogrtest.have_geos(): return 'skip' @@ -690,7 +690,7 @@ def ogr_geos_DelaunayTriangulation(): ############################################################################### -def ogr_geos_polygonize(): +def test_ogr_geos_polygonize(): if not ogrtest.have_geos(): return 'skip' @@ -717,38 +717,38 @@ def ogr_geos_polygonize(): gdaltest_list = [ - ogr_geos_union, - ogr_geos_intersection, - ogr_geos_difference, - ogr_geos_symmetric_difference, - ogr_geos_sym_difference, - ogr_geos_intersect, - ogr_geos_disjoint, - ogr_geos_touches, - ogr_geos_crosses, - ogr_geos_within, - ogr_geos_contains, - ogr_geos_overlaps, - ogr_geos_buffer, - ogr_geos_centroid, - ogr_geos_centroid_multipolygon, - ogr_geos_centroid_point_empty, - ogr_geos_simplify_linestring, - ogr_geos_simplifypreservetopology_linestring, - ogr_geos_unioncascaded, - ogr_geos_convexhull, - ogr_geos_distance, - ogr_geos_isring, - ogr_geos_issimple_true, - ogr_geos_issimple_false, - ogr_geos_isvalid_true, - ogr_geos_isvalid_true_linestringM, - ogr_geos_isvalid_true_circularStringM, - ogr_geos_isvalid_true_triangle, - ogr_geos_isvalid_false, - ogr_geos_pointonsurface, - ogr_geos_DelaunayTriangulation, - ogr_geos_polygonize, + test_ogr_geos_union, + test_ogr_geos_intersection, + test_ogr_geos_difference, + test_ogr_geos_symmetric_difference, + test_ogr_geos_sym_difference, + test_ogr_geos_intersect, + test_ogr_geos_disjoint, + test_ogr_geos_touches, + test_ogr_geos_crosses, + test_ogr_geos_within, + test_ogr_geos_contains, + test_ogr_geos_overlaps, + test_ogr_geos_buffer, + test_ogr_geos_centroid, + test_ogr_geos_centroid_multipolygon, + test_ogr_geos_centroid_point_empty, + test_ogr_geos_simplify_linestring, + test_ogr_geos_simplifypreservetopology_linestring, + test_ogr_geos_unioncascaded, + test_ogr_geos_convexhull, + test_ogr_geos_distance, + test_ogr_geos_isring, + test_ogr_geos_issimple_true, + test_ogr_geos_issimple_false, + test_ogr_geos_isvalid_true, + test_ogr_geos_isvalid_true_linestringM, + test_ogr_geos_isvalid_true_circularStringM, + test_ogr_geos_isvalid_true_triangle, + test_ogr_geos_isvalid_false, + test_ogr_geos_pointonsurface, + test_ogr_geos_DelaunayTriangulation, + test_ogr_geos_polygonize, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_gft.py b/autotest/ogr/ogr_gft.py index 00890531e686..f998a4580f4d 100755 --- a/autotest/ogr/ogr_gft.py +++ b/autotest/ogr/ogr_gft.py @@ -42,7 +42,7 @@ # Test if driver is available -def ogr_gft_init(): +def test_ogr_gft_init(): ogrtest.gft_drv = None @@ -64,7 +64,7 @@ def ogr_gft_init(): # Read test on Wikileaks Afgan War Diary 2004-2010 table. -def ogr_gft_read(): +def test_ogr_gft_read(): if ogrtest.gft_drv is None: return 'skip' @@ -116,7 +116,7 @@ def ogr_gft_read(): # Write test -def ogr_gft_write(): +def test_ogr_gft_write(): if ogrtest.gft_drv is None: return 'skip' @@ -191,7 +191,7 @@ def ogr_gft_write(): # ogr2ogr test to create a non-spatial GFT table -def ogr_gft_ogr2ogr_non_spatial(): +def test_ogr_gft_ogr2ogr_non_spatial(): if ogrtest.gft_drv is None: return 'skip' @@ -241,7 +241,7 @@ def ogr_gft_ogr2ogr_non_spatial(): # ogr2ogr test to create a spatial GFT table -def ogr_gft_ogr2ogr_spatial(): +def test_ogr_gft_ogr2ogr_spatial(): if ogrtest.gft_drv is None: return 'skip' @@ -325,11 +325,11 @@ def ogr_gft_ogr2ogr_spatial(): gdaltest_list = [ - ogr_gft_init, - ogr_gft_read, - ogr_gft_write, - ogr_gft_ogr2ogr_non_spatial, - ogr_gft_ogr2ogr_spatial, + test_ogr_gft_init, + test_ogr_gft_read, + test_ogr_gft_write, + test_ogr_gft_ogr2ogr_non_spatial, + test_ogr_gft_ogr2ogr_spatial, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_gml_fgd_read.py b/autotest/ogr/ogr_gml_fgd_read.py index 6c02156b73f8..b1f0b1b6992a 100755 --- a/autotest/ogr/ogr_gml_fgd_read.py +++ b/autotest/ogr/ogr_gml_fgd_read.py @@ -49,7 +49,7 @@ ############################################################################### # Test reading Japanese FGD GML (v4) ElevPt file -def ogr_gml_fgd_1(): +def test_ogr_gml_fgd_1(): gdaltest.have_gml_fgd_reader = 0 @@ -95,7 +95,7 @@ def ogr_gml_fgd_1(): ############################################################################### # Test reading Japanese FGD GML (v4) BldA file -def ogr_gml_fgd_2(): +def test_ogr_gml_fgd_2(): if not gdaltest.have_gml_fgd_reader: return 'skip' @@ -135,8 +135,8 @@ def ogr_gml_fgd_2(): gdaltest_list = [ - ogr_gml_fgd_1, - ogr_gml_fgd_2 + test_ogr_gml_fgd_1, + test_ogr_gml_fgd_2 ] diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index 43b68000ae6a..ef7e15d48914 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -80,7 +80,7 @@ def test_gml_geom(unit): # by ESRI WFS software. -def gml_space_test(): +def test_gml_space_test(): gml = '189999.99995605,624999.99998375 200000.00005735,624999.99998375 200000.00005735,612499.99997125 195791.3593843,612499.99997125 193327.3749823,612499.99997125 189999.99995605,612499.99997125 189999.99995605,619462.31247125 189999.99995605,624999.99998375 \n' geom = ogr.CreateGeometryFromGML(gml) if geom is None or geom.GetGeometryType() is not ogr.wkbLineString \ @@ -94,7 +94,7 @@ def gml_space_test(): # Test GML 3.x "pos" element for a point. -def gml_pos_point(): +def test_gml_pos_point(): gml = '31 29 16' @@ -110,7 +110,7 @@ def gml_pos_point(): # Test GML 3.1.1 "pos" element for a polygon. (ticket #3244) -def gml_pos_polygon(): +def test_gml_pos_polygon(): gml = ''' @@ -145,7 +145,7 @@ def gml_pos_polygon(): # Test GML 3.x "posList" element for a linestring. -def gml_posList_line(): +def test_gml_posList_line(): gml = '31 42 53 64 55 76' @@ -161,7 +161,7 @@ def gml_posList_line(): ############################################################################### # Test GML 3.x "posList" element for a 3D linestring. -def gml_posList_line3d(): +def test_gml_posList_line3d(): gml = '31 42 1 53 64 2 55 76 3' @@ -178,7 +178,7 @@ def gml_posList_line3d(): # set on LineString, not posList -def gml_posList_line3d_2(): +def test_gml_posList_line3d_2(): gml = '31 42 1 53 64 2 55 76 3' @@ -194,7 +194,7 @@ def gml_posList_line3d_2(): # Test GML 3.x "polygon" element for a point. -def gml_polygon(): +def test_gml_polygon(): gml = '0 0 4 0 4 4 0 4 0 01 1 2 1 2 2 1 2 1 1' geom = ogr.CreateGeometryFromGML(gml) @@ -233,7 +233,7 @@ def _CreateGMLWithSRSFromWkt(wkt, epsg): # Test of Point geometry with SRS assigned -def gml_out_point_srs(): +def test_gml_out_point_srs(): wkt = 'POINT(21.675 53.763)' @@ -253,7 +253,7 @@ def gml_out_point_srs(): # Test of Point 3D geometry with SRS assigned -def gml_out_point3d_srs(): +def test_gml_out_point3d_srs(): wkt = 'POINT(21.675 53.763 100)' @@ -273,7 +273,7 @@ def gml_out_point3d_srs(): # Test of LineString geometry with SRS assigned -def gml_out_linestring_srs(): +def test_gml_out_linestring_srs(): wkt = open('data/wkb_wkt/5.wkt').read() @@ -293,7 +293,7 @@ def gml_out_linestring_srs(): # Test of Polygon geometry with SRS assigned -def gml_out_polygon_srs(): +def test_gml_out_polygon_srs(): wkt = open('data/wkb_wkt/6.wkt').read() @@ -313,7 +313,7 @@ def gml_out_polygon_srs(): # Test of MultiPoint geometry with SRS assigned -def gml_out_multipoint_srs(): +def test_gml_out_multipoint_srs(): wkt = open('data/wkb_wkt/11.wkt').read() @@ -333,7 +333,7 @@ def gml_out_multipoint_srs(): # Test of MultiLineString geometry with SRS assigned -def gml_out_multilinestring_srs(): +def test_gml_out_multilinestring_srs(): wkt = open('data/wkb_wkt/2.wkt').read() @@ -353,7 +353,7 @@ def gml_out_multilinestring_srs(): # Test of MultiPolygon geometry with SRS assigned -def gml_out_multipolygon_srs(): +def test_gml_out_multipolygon_srs(): wkt = open('data/wkb_wkt/4.wkt').read() @@ -380,7 +380,7 @@ def gml_out_multipolygon_srs(): # Test of GeometryCollection with SRS assigned -def gml_out_geometrycollection_srs(): +def test_gml_out_geometrycollection_srs(): wkt = open('data/wkb_wkt/3.wkt').read() @@ -401,7 +401,7 @@ def gml_out_geometrycollection_srs(): # Test GML Box -def gml_Box(): +def test_gml_Box(): gml = """ @@ -427,7 +427,7 @@ def gml_Box(): # Test GML Envelope -def gml_Envelope(): +def test_gml_Envelope(): gml = """ 1 2 @@ -447,7 +447,7 @@ def gml_Envelope(): # Test GML Curve -def gml_Curve(): +def test_gml_Curve(): gml = """ @@ -470,7 +470,7 @@ def gml_Curve(): # Test GML Curve with pointProperty elements -def gml_Curve_with_pointProperty(): +def test_gml_Curve_with_pointProperty(): gml = """ @@ -498,7 +498,7 @@ def gml_Curve_with_pointProperty(): # Test GML MultiCurve -def gml_MultiCurve(): +def test_gml_MultiCurve(): gml = """ @@ -526,7 +526,7 @@ def gml_MultiCurve(): # Test GML MultiSurface with PolygonPatch -def gml_MultiSurface(): +def test_gml_MultiSurface(): gml = """ @@ -609,7 +609,7 @@ def gml_MultiSurface(): ############################################################################### # Test GML MultiSurface with surfaceMembers -def gml_MultiSurface_surfaceMembers(): +def test_gml_MultiSurface_surfaceMembers(): gml = """ @@ -663,7 +663,7 @@ def gml_MultiSurface_surfaceMembers(): ############################################################################### # Test GML MultiCurve with curveMembers -def gml_MultiCurve_curveMembers(): +def test_gml_MultiCurve_curveMembers(): gml = """ @@ -685,7 +685,7 @@ def gml_MultiCurve_curveMembers(): ############################################################################### # Test GML MultiGeometry with geometryMembers -def gml_MultiGeometry_geometryMembers(): +def test_gml_MultiGeometry_geometryMembers(): gml = """ @@ -708,7 +708,7 @@ def gml_MultiGeometry_geometryMembers(): # Test GML CompositeCurve with curveMembers -def gml_CompositeCurve_curveMembers(): +def test_gml_CompositeCurve_curveMembers(): gml = """ @@ -734,7 +734,7 @@ def gml_CompositeCurve_curveMembers(): # Test GML MultiPoint with pointMembers -def gml_MultiCurve_pointMembers(): +def test_gml_MultiCurve_pointMembers(): gml = """ @@ -759,7 +759,7 @@ def gml_MultiCurve_pointMembers(): # Test GML Solid -def gml_Solid(): +def test_gml_Solid(): gml = """ @@ -790,7 +790,7 @@ def gml_Solid(): # Test GML OrientableSurface -def gml_OrientableSurface(): +def test_gml_OrientableSurface(): gml = """ @@ -819,7 +819,7 @@ def gml_OrientableSurface(): # Test GML Triangle -def gml_Triangle(): +def test_gml_Triangle(): gml = """ @@ -853,7 +853,7 @@ def gml_Triangle(): # Test GML Rectangle -def gml_Rectangle(): +def test_gml_Rectangle(): gml = """ @@ -876,7 +876,7 @@ def gml_Rectangle(): # Test GML PolyhedralSurface -def gml_PolyhedralSurface(): +def test_gml_PolyhedralSurface(): # Conversion from GML -> OGR @@ -1060,7 +1060,7 @@ def gml_PolyhedralSurface(): ############################################################################### # Test GML Tin -def gml_Tin(): +def test_gml_Tin(): gml = """ @@ -1155,7 +1155,7 @@ def gml_Tin(): # Test concatenated sections (#4451) -def gml_ConcatenatedDeduplication(): +def test_gml_ConcatenatedDeduplication(): gml = """ @@ -1223,7 +1223,7 @@ def gml_out_precision(): # Test various error cases of gml2ogrgeometry.cpp -def gml_invalid_geoms(): +def test_gml_invalid_geoms(): gml_expected_wkt_list = [ ('', None), @@ -1400,7 +1400,7 @@ def gml_invalid_geoms(): # Test write support for GML3 -def gml_write_gml3_geometries(): +def test_gml_write_gml3_geometries(): gml_list = ['2 3', '2 3 4', @@ -1432,7 +1432,7 @@ def gml_write_gml3_geometries(): # Test write support for GML3 SRS -def gml_write_gml3_srs(): +def test_gml_write_gml3_srs(): sr32631 = osr.SpatialReference() sr32631.SetFromUserInput("EPSG:32631") @@ -1511,7 +1511,7 @@ def gml_write_gml3_srs(): # Test that importing too nested GML doesn't cause stack overflows -def gml_nested(): +def test_gml_nested(): gml = '' * 31 gml += '' @@ -1539,7 +1539,7 @@ def gml_nested(): # Test GML 3.3 SimplePolygon -def gml_SimplePolygon(): +def test_gml_SimplePolygon(): gml = """0 0 1 0 1 1 0 1""" @@ -1556,7 +1556,7 @@ def gml_SimplePolygon(): # Test GML 3.3 SimpleRectangle -def gml_SimpleRectangle(): +def test_gml_SimpleRectangle(): gml = """0 0 1 0 1 1 0 1""" @@ -1573,7 +1573,7 @@ def gml_SimpleRectangle(): # Test GML 3.3 SimpleTriangle -def gml_SimpleTriangle(): +def test_gml_SimpleTriangle(): gml = """0 0 1 0 1 1""" @@ -1590,7 +1590,7 @@ def gml_SimpleTriangle(): # Test GML 3.3 SimpleMultiPoint -def gml_SimpleMultiPoint(): +def test_gml_SimpleMultiPoint(): gml = """0 1 2 3""" @@ -1607,7 +1607,7 @@ def gml_SimpleMultiPoint(): # Test gml:CompositeCurve> in -def gml_CompositeCurveInRing(): +def test_gml_CompositeCurveInRing(): gml = """ @@ -1666,7 +1666,7 @@ def gml_CompositeCurveInRing(): # Test in (#5369) -def gml_CompositeSurface_in_surfaceMembers(): +def test_gml_CompositeSurface_in_surfaceMembers(): gml = """ @@ -1705,7 +1705,7 @@ def gml_CompositeSurface_in_surfaceMembers(): # Test with only Interior ring (#5421) -def gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing(): +def test_gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing(): gml = """ @@ -1761,7 +1761,7 @@ def gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing(): # Test ts, cs and decimal attributes of gml:coordinates -def gml_Coordinates_ts_cs_decimal(): +def test_gml_Coordinates_ts_cs_decimal(): gml_expected_wkt_list = [ ('1,2', 'POINT (1 2)'), # default values @@ -1797,7 +1797,7 @@ def gml_Coordinates_ts_cs_decimal(): # Test gml with XML header and comments -def gml_with_xml_header_and_comments(): +def test_gml_with_xml_header_and_comments(): gml_expected_wkt_list = [ (' 1,2', 'POINT (1 2)'), @@ -1841,7 +1841,7 @@ def gml_with_xml_header_and_comments(): # Test srsDimension attribute on top-level geometry and not on posList (#5606) -def gml_srsDimension_topgeometry(): +def test_gml_srsDimension_topgeometry(): gml = """ @@ -1870,7 +1870,7 @@ def gml_srsDimension_topgeometry(): # Test GML Arc -def gml_Arc(): +def test_gml_Arc(): gml = "1 0 0 1 -1 0" geom = ogr.CreateGeometryFromGML(gml) @@ -1899,7 +1899,7 @@ def gml_Arc(): # Test GML ArcByBulge -def gml_ArcByBulge(): +def test_gml_ArcByBulge(): gml = "2 0 -2 02-1" geom = ogr.CreateGeometryFromGML(gml) @@ -1915,7 +1915,7 @@ def gml_ArcByBulge(): # Test GML ArcByCenterPoint -def gml_ArcByCenterPoint(): +def test_gml_ArcByCenterPoint(): gml = "1 2290270" geom = ogr.CreateGeometryFromGML(gml) @@ -1932,7 +1932,7 @@ def gml_ArcByCenterPoint(): # Test compound curve of ArcByCenterPoint whose ends don't exactly match # with ends of neighbouring curves, as found in some AIXM files -def gml_CompoundCurve_of_ArcByCenterPoint(): +def test_gml_CompoundCurve_of_ArcByCenterPoint(): gml = """ @@ -1994,7 +1994,7 @@ def gml_CompoundCurve_of_ArcByCenterPoint(): # Test GML CircleByCenterPoint -def gml_CircleByCenterPoint(): +def test_gml_CircleByCenterPoint(): gml = "1 22" geom = ogr.CreateGeometryFromGML(gml) @@ -2010,7 +2010,7 @@ def gml_CircleByCenterPoint(): # Test GML Circle -def gml_Circle(): +def test_gml_Circle(): gml = """ -1 0 0 1 -0.707106781186547 -0.707106781186548 @@ -2074,7 +2074,7 @@ def gml_Circle(): # Test ArcString -def gml_ArcString(): +def test_gml_ArcString(): gml = """-2 0 -1 -1 0 0""" geom = ogr.CreateGeometryFromGML(gml) @@ -2107,7 +2107,7 @@ def gml_ArcString(): # Test OGRCompoundCurve -def gml_OGRCompoundCurve(): +def test_gml_OGRCompoundCurve(): wkt = 'COMPOUNDCURVE ((0 0,1 1,2 0))' geom = ogr.CreateGeometryFromWkt(wkt) @@ -2193,7 +2193,7 @@ def gml_OGRCompoundCurve(): # Test OGRCurvePolygon -def gml_OGRCurvePolygon(): +def test_gml_OGRCurvePolygon(): # Test one CircularString gml = """0 0 1 0 0 0""" @@ -2244,7 +2244,7 @@ def gml_OGRCurvePolygon(): # Test OGRMultiSurface -def gml_OGRMultiSurface(): +def test_gml_OGRMultiSurface(): # MultiSurface of CurvePolygon gml = """ @@ -2329,7 +2329,7 @@ def gml_OGRMultiSurface(): # Test OGRMultiCurve -def gml_OGRMultiCurve(): +def test_gml_OGRMultiCurve(): # MultiCurve of Arc gml = """0 0 1 1 1 -1""" @@ -2410,7 +2410,7 @@ def gml_OGRMultiCurve(): # Test write support for GML namespace declaration -def gml_write_gml_ns(): +def test_gml_write_gml_ns(): geom = ogr.CreateGeometryFromWkt('POINT(500000 4500000)') gml = geom.ExportToGML(options=['NAMESPACE_DECL=YES']) @@ -2443,66 +2443,66 @@ def gml_write_gml_ns(): gdaltest_list = [ - gml_space_test, - gml_pos_point, - gml_pos_polygon, - gml_posList_line, - gml_posList_line3d, - gml_posList_line3d_2, - gml_polygon, - gml_out_point_srs, - gml_out_point3d_srs, - gml_out_linestring_srs, - gml_out_polygon_srs, - gml_out_multipoint_srs, - gml_out_multilinestring_srs, - gml_out_multipolygon_srs, - gml_out_geometrycollection_srs, - gml_Box, - gml_Envelope, - gml_Curve, - gml_Curve_with_pointProperty, - gml_MultiCurve, - gml_MultiSurface, - gml_MultiSurface_surfaceMembers, - gml_MultiCurve_curveMembers, - gml_MultiGeometry_geometryMembers, - gml_CompositeCurve_curveMembers, - gml_MultiCurve_pointMembers, - gml_Solid, - gml_OrientableSurface, - gml_Triangle, - gml_Rectangle, - gml_Tin, - gml_PolyhedralSurface, - gml_ConcatenatedDeduplication, + test_gml_space_test, + test_gml_pos_point, + test_gml_pos_polygon, + test_gml_posList_line, + test_gml_posList_line3d, + test_gml_posList_line3d_2, + test_gml_polygon, + test_gml_out_point_srs, + test_gml_out_point3d_srs, + test_gml_out_linestring_srs, + test_gml_out_polygon_srs, + test_gml_out_multipoint_srs, + test_gml_out_multilinestring_srs, + test_gml_out_multipolygon_srs, + test_gml_out_geometrycollection_srs, + test_gml_Box, + test_gml_Envelope, + test_gml_Curve, + test_gml_Curve_with_pointProperty, + test_gml_MultiCurve, + test_gml_MultiSurface, + test_gml_MultiSurface_surfaceMembers, + test_gml_MultiCurve_curveMembers, + test_gml_MultiGeometry_geometryMembers, + test_gml_CompositeCurve_curveMembers, + test_gml_MultiCurve_pointMembers, + test_gml_Solid, + test_gml_OrientableSurface, + test_gml_Triangle, + test_gml_Rectangle, + test_gml_Tin, + test_gml_PolyhedralSurface, + test_gml_ConcatenatedDeduplication, # gml_out_precision, - gml_invalid_geoms, - gml_write_gml3_geometries, - gml_write_gml3_srs, - gml_nested, - gml_SimplePolygon, - gml_SimpleRectangle, - gml_SimpleTriangle, - gml_SimpleMultiPoint, - gml_CompositeCurveInRing, - gml_CompositeSurface_in_surfaceMembers, - gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing, - gml_Coordinates_ts_cs_decimal, - gml_with_xml_header_and_comments, - gml_srsDimension_topgeometry, - gml_Arc, - gml_ArcByBulge, - gml_ArcByCenterPoint, - gml_CompoundCurve_of_ArcByCenterPoint, - gml_CircleByCenterPoint, - gml_Circle, - gml_ArcString, - gml_OGRCompoundCurve, - gml_OGRCurvePolygon, - gml_OGRMultiSurface, - gml_OGRMultiCurve, - gml_write_gml_ns, + test_gml_invalid_geoms, + test_gml_write_gml3_geometries, + test_gml_write_gml3_srs, + test_gml_nested, + test_gml_SimplePolygon, + test_gml_SimpleRectangle, + test_gml_SimpleTriangle, + test_gml_SimpleMultiPoint, + test_gml_CompositeCurveInRing, + test_gml_CompositeSurface_in_surfaceMembers, + test_gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing, + test_gml_Coordinates_ts_cs_decimal, + test_gml_with_xml_header_and_comments, + test_gml_srsDimension_topgeometry, + test_gml_Arc, + test_gml_ArcByBulge, + test_gml_ArcByCenterPoint, + test_gml_CompoundCurve_of_ArcByCenterPoint, + test_gml_CircleByCenterPoint, + test_gml_Circle, + test_gml_ArcString, + test_gml_OGRCompoundCurve, + test_gml_OGRCurvePolygon, + test_gml_OGRMultiSurface, + test_gml_OGRMultiCurve, + test_gml_write_gml_ns, ] diff --git a/autotest/ogr/ogr_gml_read.py b/autotest/ogr/ogr_gml_read.py index 7c21d54d450c..36acd7cf8a26 100755 --- a/autotest/ogr/ogr_gml_read.py +++ b/autotest/ogr/ogr_gml_read.py @@ -46,7 +46,7 @@ # -def ogr_gml_1(): +def test_ogr_gml_1(): gdaltest.have_gml_reader = 0 @@ -86,7 +86,7 @@ def ogr_gml_1(): # Do the same test somewhere without a .gfs file. -def ogr_gml_2(): +def test_ogr_gml_2(): if not gdaltest.have_gml_reader: return 'skip' @@ -122,7 +122,7 @@ def ogr_gml_2(): # Similar test for RNF style line data. -def ogr_gml_3(): +def test_ogr_gml_3(): if not gdaltest.have_gml_reader: return 'skip' @@ -160,7 +160,7 @@ def ogr_gml_3(): # Test also support for nested GML elements (#3680) -def ogr_gml_4(): +def test_ogr_gml_4(): if not gdaltest.have_gml_reader: return 'skip' @@ -210,7 +210,7 @@ def ogr_gml_4(): ############################################################################### # Test of read GML file that triggeered bug #2349 -def ogr_gml_5(): +def test_ogr_gml_5(): if not gdaltest.have_gml_reader: return 'skip' @@ -229,7 +229,7 @@ def ogr_gml_5(): # Test of various FIDs (various prefixes and lengths) (Ticket#1017) -def ogr_gml_6(): +def test_ogr_gml_6(): if not gdaltest.have_gml_reader: return 'skip' @@ -259,7 +259,7 @@ def ogr_gml_6(): # Test of colon terminated prefixes for attribute values (Ticket#2493) -def ogr_gml_7(): +def test_ogr_gml_7(): if not gdaltest.have_gml_reader: return 'skip' @@ -296,7 +296,7 @@ def ogr_gml_7(): # Test a GML file with some non-ASCII UTF-8 content that triggered a bug (Ticket#2948) -def ogr_gml_8(): +def test_ogr_gml_8(): if not gdaltest.have_gml_reader: return 'skip' @@ -319,7 +319,7 @@ def ogr_gml_8(): # Test writing invalid UTF-8 content in a GML file (ticket #2971) -def ogr_gml_9(): +def test_ogr_gml_9(): if not gdaltest.have_gml_reader: return 'skip' @@ -362,7 +362,7 @@ def ogr_gml_9(): # TODO: Add test for other data types as they are added to the driver. -def ogr_gml_10(): +def test_ogr_gml_10(): if not gdaltest.have_gml_reader: return 'skip' @@ -457,7 +457,7 @@ def ogr_gml_10(): # Test reading a geometry element specified with -def ogr_gml_11(): +def test_ogr_gml_11(): if not gdaltest.have_gml_reader: return 'skip' @@ -501,7 +501,7 @@ def ogr_gml_11(): # Test reading a virtual GML file -def ogr_gml_12(): +def test_ogr_gml_12(): if not gdaltest.have_gml_reader: return 'skip' @@ -530,7 +530,7 @@ def ogr_gml_12(): # Test reading GML with StringList, IntegerList and RealList fields -def ogr_gml_13(): +def test_ogr_gml_13(): if not gdaltest.have_gml_reader: return 'skip' @@ -560,7 +560,7 @@ def ogr_gml_13(): # Test xlink resolution -def ogr_gml_14(): +def test_ogr_gml_14(): if not gdaltest.have_gml_reader: return 'skip' @@ -628,7 +628,7 @@ def ogr_gml_14(): # Run test_ogrsf -def ogr_gml_15(): +def test_ogr_gml_15(): if not gdaltest.have_gml_reader: return 'skip' @@ -649,7 +649,7 @@ def ogr_gml_15(): # Read CityGML generic attributes -def ogr_gml_16(): +def test_ogr_gml_16(): if not gdaltest.have_gml_reader: return 'skip' @@ -671,7 +671,7 @@ def ogr_gml_16(): # Read layer SRS for WFS 1.0.0 return -def ogr_gml_17(): +def test_ogr_gml_17(): if not gdaltest.have_gml_reader: return 'skip' @@ -699,7 +699,7 @@ def ogr_gml_17(): # Read layer SRS for WFS 1.1.0 return -def ogr_gml_18(): +def test_ogr_gml_18(): if not gdaltest.have_gml_reader: return 'skip' @@ -728,7 +728,7 @@ def ogr_gml_18(): # (long, lat) order. So we should get EPSGA:4326 and (lat, long) order -def ogr_gml_19(): +def test_ogr_gml_19(): if not gdaltest.have_gml_reader: return 'skip' @@ -765,7 +765,7 @@ def ogr_gml_19(): # Test parsing a .xsd where the type definition is before its reference -def ogr_gml_20(): +def test_ogr_gml_20(): if not gdaltest.have_gml_reader: return 'skip' @@ -821,7 +821,7 @@ def ogr_gml_20(): # Test writing GML3 -def ogr_gml_21(frmt='GML3'): +def test_ogr_gml_21(frmt='GML3'): if not gdaltest.have_gml_reader: return 'skip' @@ -906,18 +906,18 @@ def ogr_gml_21(frmt='GML3'): return 'success' -def ogr_gml_21_deegree3(): - return ogr_gml_21('GML3Deegree') +def test_ogr_gml_21_deegree3(): + return test_ogr_gml_21('GML3Deegree') -def ogr_gml_21_gml32(): - return ogr_gml_21('GML3.2') +def test_ogr_gml_21_gml32(): + return test_ogr_gml_21('GML3.2') ############################################################################### # Read a OpenLS DetermineRouteResponse document -def ogr_gml_22(): +def test_ogr_gml_22(): if not gdaltest.have_gml_reader: return 'skip' @@ -945,7 +945,7 @@ def ogr_gml_22(): # feature geometry -def ogr_gml_23(): +def test_ogr_gml_23(): if not gdaltest.have_gml_reader: return 'skip' @@ -990,7 +990,7 @@ def ogr_gml_23(): # feature geometry -def ogr_gml_24(): +def test_ogr_gml_24(): if not gdaltest.have_gml_reader: return 'skip' @@ -1035,7 +1035,7 @@ def ogr_gml_24(): # Test fixes for #3934 and #3935 -def ogr_gml_25(): +def test_ogr_gml_25(): if not gdaltest.have_gml_reader: return 'skip' @@ -1069,7 +1069,7 @@ def ogr_gml_25(): # Test writing and reading 3D geoms (GML2) -def ogr_gml_26(): +def test_ogr_gml_26(): if not gdaltest.have_gml_reader: return 'skip' @@ -1101,7 +1101,7 @@ def ogr_gml_26(): # Test writing and reading 3D geoms (GML3) -def ogr_gml_27(): +def test_ogr_gml_27(): if not gdaltest.have_gml_reader: return 'skip' @@ -1135,7 +1135,7 @@ def ogr_gml_27(): # Test writing and reading layers of type wkbNone (#4154) -def ogr_gml_28(): +def test_ogr_gml_28(): if not gdaltest.have_gml_reader: return 'skip' @@ -1177,7 +1177,7 @@ def ogr_gml_28(): # Test reading FME GMLs -def ogr_gml_29(): +def test_ogr_gml_29(): if not gdaltest.have_gml_reader: return 'skip' @@ -1211,7 +1211,7 @@ def ogr_gml_29(): # Test reading a big field and a big geometry -def ogr_gml_30(): +def test_ogr_gml_30(): if not gdaltest.have_gml_reader: return 'skip' @@ -1263,13 +1263,13 @@ def ogr_gml_30(): # Test SEQUENTIAL_LAYERS -def ogr_gml_31(): +def test_ogr_gml_31(): if not gdaltest.have_gml_reader: return 'skip' gdal.SetConfigOption('GML_READ_MODE', 'SEQUENTIAL_LAYERS') - ret = ogr_gml_29() + ret = test_ogr_gml_29() gdal.SetConfigOption('GML_READ_MODE', None) if ret != 'success': @@ -1300,7 +1300,7 @@ def ogr_gml_31(): # Test SEQUENTIAL_LAYERS without a .gfs -def ogr_gml_32(): +def test_ogr_gml_32(): if not gdaltest.have_gml_reader: return 'skip' @@ -1344,7 +1344,7 @@ def ogr_gml_32(): # Test INTERLEAVED_LAYERS -def ogr_gml_33(): +def test_ogr_gml_33(): if not gdaltest.have_gml_reader: return 'skip' @@ -1386,7 +1386,7 @@ def ogr_gml_33(): # Test writing non-ASCII UTF-8 content (#4117, #4299) -def ogr_gml_34(): +def test_ogr_gml_34(): if not gdaltest.have_gml_reader: return 'skip' @@ -1418,7 +1418,7 @@ def ogr_gml_34(): # Test GML_SKIP_RESOLVE_ELEMS=HUGE (#4380) -def ogr_gml_35(): +def test_ogr_gml_35(): if not gdaltest.have_gml_reader: return 'skip' @@ -1487,7 +1487,7 @@ def ogr_gml_35(): # Test GML_SKIP_RESOLVE_ELEMS=NONE (and new GMLTopoSurface interpretation) -def ogr_gml_36(GML_FACE_HOLE_NEGATIVE='NO'): +def test_ogr_gml_36(GML_FACE_HOLE_NEGATIVE='NO'): if not gdaltest.have_gml_reader: return 'skip' @@ -1545,14 +1545,14 @@ def ogr_gml_36(GML_FACE_HOLE_NEGATIVE='NO'): # Test GML_SKIP_RESOLVE_ELEMS=NONE with old GMLTopoSurface interpretation -def ogr_gml_37(): - return ogr_gml_36('YES') +def test_ogr_gml_37(): + return test_ogr_gml_36('YES') ############################################################################### # Test new GMLTopoSurface interpretation (#3934) with HUGE xlink resolver -def ogr_gml_38(resolver='HUGE'): +def test_ogr_gml_38(resolver='HUGE'): if not gdaltest.have_gml_reader: return 'skip' @@ -1611,14 +1611,14 @@ def ogr_gml_38(resolver='HUGE'): # Test new GMLTopoSurface interpretation (#3934) with standard xlink resolver -def ogr_gml_39(): - return ogr_gml_38('NONE') +def test_ogr_gml_39(): + return test_ogr_gml_38('NONE') ############################################################################### # Test parsing XSD where simpleTypes not inlined, but defined elsewhere in the .xsd (#4328) -def ogr_gml_40(): +def test_ogr_gml_40(): if not gdaltest.have_gml_reader: return 'skip' @@ -1635,7 +1635,7 @@ def ogr_gml_40(): # Test validating against .xsd -def ogr_gml_41(): +def test_ogr_gml_41(): gdaltest.have_gml_validation = False @@ -1670,7 +1670,7 @@ def ogr_gml_41(): # Test validating against .xsd -def ogr_gml_42(): +def test_ogr_gml_42(): if not gdaltest.have_gml_validation: return 'skip' @@ -1706,7 +1706,7 @@ def ogr_gml_42(): # Test automated downloading of WFS schema -def ogr_gml_43(): +def test_ogr_gml_43(): # The service times out return 'skip' @@ -1742,7 +1742,7 @@ def ogr_gml_43(): # Test providing a custom XSD filename -def ogr_gml_44(): +def test_ogr_gml_44(): if not gdaltest.have_gml_reader: return 'skip' @@ -1797,7 +1797,7 @@ def ogr_gml_44(): # Test PREFIX and TARGET_NAMESPACE creation options -def ogr_gml_45(): +def test_ogr_gml_45(): if not gdaltest.have_gml_reader: return 'skip' @@ -1851,7 +1851,7 @@ def ogr_gml_45(): ############################################################################### # Validate different kinds of GML files -def ogr_gml_46(): +def test_ogr_gml_46(): if not gdaltest.have_gml_validation: return 'skip' @@ -1965,7 +1965,7 @@ def ogr_gml_46(): # Test validation of WFS GML documents -def ogr_gml_47(): +def test_ogr_gml_47(): if not gdaltest.have_gml_validation: return 'skip' @@ -2007,7 +2007,7 @@ def ogr_gml_47(): # -def ogr_gml_48(): +def test_ogr_gml_48(): if not gdaltest.have_gml_reader: return 'skip' @@ -2033,7 +2033,7 @@ def ogr_gml_48(): # Test a pseudo Inspire GML file -def ogr_gml_49(): +def test_ogr_gml_49(): if not gdaltest.have_gml_reader: return 'skip' @@ -2076,7 +2076,7 @@ def ogr_gml_49(): # Test support for StringList, IntegerList, RealList -def ogr_gml_50(): +def test_ogr_gml_50(): if not gdaltest.have_gml_reader: return 'skip' @@ -2123,7 +2123,7 @@ def ogr_gml_50(): # Test -dsco WRITE_FEATURE_BOUNDED_BY=no -dsco STRIP_PREFIX=YES -def ogr_gml_51(): +def test_ogr_gml_51(): if not gdaltest.have_gml_reader: return 'skip' @@ -2175,7 +2175,7 @@ def ogr_gml_51(): # Test reading MTKGML files -def ogr_gml_52(): +def test_ogr_gml_52(): if not gdaltest.have_gml_reader: return 'skip' @@ -2248,7 +2248,7 @@ def ogr_gml_52(): # Test that we don't recognize .xsd files themselves -def ogr_gml_53(): +def test_ogr_gml_53(): if not gdaltest.have_gml_reader: return 'skip' @@ -2265,7 +2265,7 @@ def ogr_gml_53(): # Test that we can open an empty GML datasource (#249, #5205) -def ogr_gml_54(): +def test_ogr_gml_54(): if not gdaltest.have_gml_reader: return 'skip' @@ -2294,7 +2294,7 @@ def ogr_gml_54(): # Necessary for Finnish NLS data -def ogr_gml_55(): +def test_ogr_gml_55(): if not gdaltest.have_gml_reader: return 'skip' @@ -2318,7 +2318,7 @@ def ogr_gml_55(): # Necessary for Finnish NLS data -def ogr_gml_56(): +def test_ogr_gml_56(): if not gdaltest.have_gml_reader: return 'skip' @@ -2388,7 +2388,7 @@ def ogr_gml_56(): # Test write support for multiple geometry field -def ogr_gml_57(): +def test_ogr_gml_57(): if not gdaltest.have_gml_reader: return 'skip' @@ -2462,7 +2462,7 @@ def ogr_gml_57(): # Test support for Inspire Cadastral schemas -def ogr_gml_58(): +def test_ogr_gml_58(): if not gdaltest.have_gml_reader: return 'skip' @@ -2759,7 +2759,7 @@ def ogr_gml_58(): # Test GFS conditions -def ogr_gml_59(): +def test_ogr_gml_59(): if not gdaltest.have_gml_reader: return 'skip' @@ -2804,7 +2804,7 @@ def ogr_gml_59(): # as a wfs:member of the top wfs:FeatureCollection -def ogr_gml_60(): +def test_ogr_gml_60(): if not gdaltest.have_gml_reader: return 'skip' @@ -2840,7 +2840,7 @@ def ogr_gml_60(): # Test reading a element specified with a full path in -def ogr_gml_61(): +def test_ogr_gml_61(): if not gdaltest.have_gml_reader: return 'skip' @@ -2895,7 +2895,7 @@ def ogr_gml_61(): # Test GML_ATTRIBUTES_TO_OGR_FIELDS option -def ogr_gml_62(): +def test_ogr_gml_62(): if not gdaltest.have_gml_reader: return 'skip' @@ -2963,7 +2963,7 @@ def ogr_gml_62(): # Test reading RUIAN VFR files -def ogr_gml_63(): +def test_ogr_gml_63(): if not gdaltest.have_gml_reader: return 'skip' @@ -3009,7 +3009,7 @@ def ogr_gml_63(): # Test multiple instances of parsers (#5571) -def ogr_gml_64(): +def test_ogr_gml_64(): if not gdaltest.have_gml_reader: return 'skip' @@ -3031,7 +3031,7 @@ def ogr_gml_64(): # Test SRSDIMENSION_LOC=GEOMETRY option (#5606) -def ogr_gml_65(): +def test_ogr_gml_65(): if not gdaltest.have_gml_reader: return 'skip' @@ -3076,7 +3076,7 @@ def ogr_gml_65(): # Test curve geometries -def ogr_gml_66(): +def test_ogr_gml_66(): if not gdaltest.have_gml_reader: return 'skip' @@ -3423,7 +3423,7 @@ def ogr_gml_66(): # Test boolean, int16, integer64 type -def ogr_gml_67(): +def test_ogr_gml_67(): if not gdaltest.have_gml_reader: return 'skip' @@ -3529,7 +3529,7 @@ def ogr_gml_67(): # Test reading GML with xsd with a choice of geometry properites -def ogr_gml_68(): +def test_ogr_gml_68(): if not gdaltest.have_gml_reader: return 'skip' @@ -3560,7 +3560,7 @@ def ogr_gml_68(): # Test not nullable fields -def ogr_gml_69(): +def test_ogr_gml_69(): if not gdaltest.have_gml_reader: return 'skip' @@ -3633,7 +3633,7 @@ def ogr_gml_69(): # support not nullable fields) -def ogr_gml_70(): +def test_ogr_gml_70(): if not gdaltest.have_gml_reader: return 'skip' @@ -3744,7 +3744,7 @@ def ogr_gml_71_helper(ds): return 'success' -def ogr_gml_71(): +def test_ogr_gml_71(): if not gdaltest.have_gml_reader: return 'skip' @@ -3805,7 +3805,7 @@ def ogr_gml_71(): # Test name and description -def ogr_gml_72(): +def test_ogr_gml_72(): if not gdaltest.have_gml_reader: return 'skip' @@ -3846,7 +3846,7 @@ def ogr_gml_72(): # Read a CSW GetRecordsResponse document -def ogr_gml_73(): +def test_ogr_gml_73(): if not gdaltest.have_gml_reader: return 'skip' @@ -3887,7 +3887,7 @@ def ogr_gml_73(): # Test FORCE_SRS_DETECTION open option -def ogr_gml_74(): +def test_ogr_gml_74(): if not gdaltest.have_gml_reader: return 'skip' @@ -3939,7 +3939,7 @@ def ogr_gml_74(): # Test we don't open a WMTS Capabilities doc -def ogr_gml_75(): +def test_ogr_gml_75(): if not gdaltest.have_gml_reader: return 'skip' @@ -3983,7 +3983,7 @@ def ogr_gml_75(): # Test we are robust to content of XML elements bigger than 2 GB -def ogr_gml_76(): +def test_ogr_gml_76(): if not gdaltest.have_gml_reader: return 'skip' @@ -4008,7 +4008,7 @@ def ogr_gml_76(): # Test interpretation of http://www.opengis.net/def/crs/EPSG/0/ URLs (#6678) -def ogr_gml_77(): +def test_ogr_gml_77(): if not gdaltest.have_gml_reader: return 'skip' @@ -4064,7 +4064,7 @@ def ogr_gml_77(): # Test effect of SWAP_COORDINATES (#6678) -def ogr_gml_78(): +def test_ogr_gml_78(): if not gdaltest.have_gml_reader: return 'skip' @@ -4120,7 +4120,7 @@ def ogr_gml_78(): # Test SRSNAME_FORMAT -def ogr_gml_79(): +def test_ogr_gml_79(): sr = osr.SpatialReference() sr.ImportFromEPSG(4326) @@ -4160,7 +4160,7 @@ def ogr_gml_79(): # Test null / unset -def ogr_gml_80(): +def test_ogr_gml_80(): if not gdaltest.have_gml_reader: return 'skip' @@ -4213,7 +4213,7 @@ def ogr_gml_80(): ############################################################################### # Test building a .gfs with a field with xsi:nil="true" (#7027) -def ogr_gml_81(): +def test_ogr_gml_81(): if not gdaltest.have_gml_reader: return 'skip' @@ -4235,7 +4235,7 @@ def ogr_gml_81(): # Test GML_FEATURE_COLLECTION=YES -def ogr_gml_82(): +def test_ogr_gml_82(): if not gdaltest.have_gml_reader: return 'skip' @@ -4282,7 +4282,7 @@ def ogr_gml_82(): ############################################################################### -def ogr_gml_gml2_write_geometry_error(): +def test_ogr_gml_gml2_write_geometry_error(): ds = ogr.GetDriverByName('GML').CreateDataSource('/vsimem/ogr_gml_83.gml') lyr = ds.CreateLayer('test') @@ -4301,7 +4301,7 @@ def ogr_gml_gml2_write_geometry_error(): # Cleanup -def ogr_gml_cleanup(): +def test_ogr_gml_cleanup(): if not gdaltest.have_gml_reader: return 'skip' @@ -4314,10 +4314,10 @@ def ogr_gml_cleanup(): if fl is not None: print(fl) - return ogr_gml_clean_files() + return test_ogr_gml_clean_files() -def ogr_gml_clean_files(): +def test_ogr_gml_clean_files(): try: os.remove('data/bom.gfs') except OSError: @@ -4433,99 +4433,99 @@ def ogr_gml_clean_files(): gdaltest_list = [ - ogr_gml_clean_files, - ogr_gml_1, - ogr_gml_2, - ogr_gml_3, - ogr_gml_4, - ogr_gml_5, - ogr_gml_6, - ogr_gml_7, - ogr_gml_8, - ogr_gml_9, - ogr_gml_10, - ogr_gml_11, - ogr_gml_12, - ogr_gml_13, - ogr_gml_14, - ogr_gml_15, - ogr_gml_16, - ogr_gml_17, - ogr_gml_18, - ogr_gml_19, - ogr_gml_20, - ogr_gml_21, - ogr_gml_21_deegree3, - ogr_gml_21_gml32, - ogr_gml_22, - ogr_gml_23, - ogr_gml_24, - ogr_gml_25, - ogr_gml_26, - ogr_gml_27, - ogr_gml_28, - ogr_gml_29, - ogr_gml_30, - ogr_gml_31, - ogr_gml_32, - ogr_gml_33, - ogr_gml_34, - ogr_gml_35, - ogr_gml_36, - ogr_gml_37, - ogr_gml_38, - ogr_gml_39, - ogr_gml_40, - ogr_gml_41, - ogr_gml_42, - ogr_gml_43, - ogr_gml_44, - ogr_gml_45, - ogr_gml_46, - ogr_gml_47, - ogr_gml_48, - ogr_gml_49, - ogr_gml_50, - ogr_gml_51, - ogr_gml_52, - ogr_gml_53, - ogr_gml_54, - ogr_gml_55, - ogr_gml_56, - ogr_gml_57, - ogr_gml_58, - ogr_gml_59, - ogr_gml_60, - ogr_gml_61, - ogr_gml_62, - ogr_gml_63, - ogr_gml_64, - ogr_gml_65, - ogr_gml_66, - ogr_gml_67, - ogr_gml_68, - ogr_gml_69, - ogr_gml_70, - ogr_gml_71, - ogr_gml_72, - ogr_gml_73, - ogr_gml_74, - ogr_gml_75, - ogr_gml_76, - ogr_gml_77, - ogr_gml_78, - ogr_gml_79, - ogr_gml_80, - ogr_gml_81, - ogr_gml_82, - ogr_gml_gml2_write_geometry_error, - ogr_gml_cleanup] + test_ogr_gml_clean_files, + test_ogr_gml_1, + test_ogr_gml_2, + test_ogr_gml_3, + test_ogr_gml_4, + test_ogr_gml_5, + test_ogr_gml_6, + test_ogr_gml_7, + test_ogr_gml_8, + test_ogr_gml_9, + test_ogr_gml_10, + test_ogr_gml_11, + test_ogr_gml_12, + test_ogr_gml_13, + test_ogr_gml_14, + test_ogr_gml_15, + test_ogr_gml_16, + test_ogr_gml_17, + test_ogr_gml_18, + test_ogr_gml_19, + test_ogr_gml_20, + test_ogr_gml_21, + test_ogr_gml_21_deegree3, + test_ogr_gml_21_gml32, + test_ogr_gml_22, + test_ogr_gml_23, + test_ogr_gml_24, + test_ogr_gml_25, + test_ogr_gml_26, + test_ogr_gml_27, + test_ogr_gml_28, + test_ogr_gml_29, + test_ogr_gml_30, + test_ogr_gml_31, + test_ogr_gml_32, + test_ogr_gml_33, + test_ogr_gml_34, + test_ogr_gml_35, + test_ogr_gml_36, + test_ogr_gml_37, + test_ogr_gml_38, + test_ogr_gml_39, + test_ogr_gml_40, + test_ogr_gml_41, + test_ogr_gml_42, + test_ogr_gml_43, + test_ogr_gml_44, + test_ogr_gml_45, + test_ogr_gml_46, + test_ogr_gml_47, + test_ogr_gml_48, + test_ogr_gml_49, + test_ogr_gml_50, + test_ogr_gml_51, + test_ogr_gml_52, + test_ogr_gml_53, + test_ogr_gml_54, + test_ogr_gml_55, + test_ogr_gml_56, + test_ogr_gml_57, + test_ogr_gml_58, + test_ogr_gml_59, + test_ogr_gml_60, + test_ogr_gml_61, + test_ogr_gml_62, + test_ogr_gml_63, + test_ogr_gml_64, + test_ogr_gml_65, + test_ogr_gml_66, + test_ogr_gml_67, + test_ogr_gml_68, + test_ogr_gml_69, + test_ogr_gml_70, + test_ogr_gml_71, + test_ogr_gml_72, + test_ogr_gml_73, + test_ogr_gml_74, + test_ogr_gml_75, + test_ogr_gml_76, + test_ogr_gml_77, + test_ogr_gml_78, + test_ogr_gml_79, + test_ogr_gml_80, + test_ogr_gml_81, + test_ogr_gml_82, + test_ogr_gml_gml2_write_geometry_error, + test_ogr_gml_cleanup] disabled_gdaltest_list = [ - ogr_gml_clean_files, - ogr_gml_1, - ogr_gml_82, - ogr_gml_cleanup] + test_ogr_gml_clean_files, + test_ogr_gml_1, + test_ogr_gml_82, + test_ogr_gml_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_gmlas.py b/autotest/ogr/ogr_gmlas.py index 830825a320af..10a9b8affdae 100755 --- a/autotest/ogr/ogr_gmlas.py +++ b/autotest/ogr/ogr_gmlas.py @@ -86,7 +86,7 @@ def compare_ogrinfo_output(gmlfile, reffile, options=''): # Basic test -def ogr_gmlas_basic(): +def test_ogr_gmlas_basic(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -116,7 +116,7 @@ def ogr_gmlas_basic(): # Run test_ogrsf -def ogr_gmlas_test_ogrsf(): +def test_ogr_gmlas_test_ogrsf(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -143,7 +143,7 @@ def ogr_gmlas_test_ogrsf(): # Test virtual file support -def ogr_gmlas_virtual_file(): +def test_ogr_gmlas_virtual_file(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -175,7 +175,7 @@ def ogr_gmlas_virtual_file(): # Test opening with XSD option -def ogr_gmlas_datafile_with_xsd_option(): +def test_ogr_gmlas_datafile_with_xsd_option(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -191,7 +191,7 @@ def ogr_gmlas_datafile_with_xsd_option(): # Test opening with just XSD option -def ogr_gmlas_no_datafile_with_xsd_option(): +def test_ogr_gmlas_no_datafile_with_xsd_option(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -207,7 +207,7 @@ def ogr_gmlas_no_datafile_with_xsd_option(): # Test opening with just XSD option but pointing to a non-xsd filename -def ogr_gmlas_no_datafile_xsd_which_is_not_xsd(): +def test_ogr_gmlas_no_datafile_xsd_which_is_not_xsd(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -228,7 +228,7 @@ def ogr_gmlas_no_datafile_xsd_which_is_not_xsd(): # Test opening with nothing -def ogr_gmlas_no_datafile_no_xsd(): +def test_ogr_gmlas_no_datafile_no_xsd(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -249,7 +249,7 @@ def ogr_gmlas_no_datafile_no_xsd(): # Test opening an inexisting GML file -def ogr_gmlas_non_existing_gml(): +def test_ogr_gmlas_non_existing_gml(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -270,7 +270,7 @@ def ogr_gmlas_non_existing_gml(): # Test opening with just XSD option but pointing to a non existing file -def ogr_gmlas_non_existing_xsd(): +def test_ogr_gmlas_non_existing_xsd(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -291,7 +291,7 @@ def ogr_gmlas_non_existing_xsd(): # Test opening a GML file without schemaLocation -def ogr_gmlas_gml_without_schema_location(): +def test_ogr_gmlas_gml_without_schema_location(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -317,7 +317,7 @@ def ogr_gmlas_gml_without_schema_location(): # Test invalid schema -def ogr_gmlas_invalid_schema(): +def test_ogr_gmlas_invalid_schema(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -338,7 +338,7 @@ def ogr_gmlas_invalid_schema(): # Test invalid XML -def ogr_gmlas_invalid_xml(): +def test_ogr_gmlas_invalid_xml(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -361,7 +361,7 @@ def ogr_gmlas_invalid_xml(): # Test links with gml:ReferenceType -def ogr_gmlas_gml_Reference(): +def test_ogr_gmlas_gml_Reference(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -392,7 +392,7 @@ def ogr_gmlas_gml_Reference(): # Test that we fix ambiguities in class names -def ogr_gmlas_same_element_in_different_ns(): +def test_ogr_gmlas_same_element_in_different_ns(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -433,7 +433,7 @@ def ogr_gmlas_same_element_in_different_ns(): # Test a corner case of relative path resolution -def ogr_gmlas_corner_case_relative_path(): +def test_ogr_gmlas_corner_case_relative_path(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -449,7 +449,7 @@ def ogr_gmlas_corner_case_relative_path(): # Test unexpected repeated element -def ogr_gmlas_unexpected_repeated_element(): +def test_ogr_gmlas_unexpected_repeated_element(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -478,7 +478,7 @@ def ogr_gmlas_unexpected_repeated_element(): # Test unexpected repeated element -def ogr_gmlas_unexpected_repeated_element_variant(): +def test_ogr_gmlas_unexpected_repeated_element_variant(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -507,7 +507,7 @@ def ogr_gmlas_unexpected_repeated_element_variant(): # Test reading geometries embedded in a geometry property element -def ogr_gmlas_geometryproperty(): +def test_ogr_gmlas_geometryproperty(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -668,7 +668,7 @@ def ogr_gmlas_geometryproperty(): # Test reading geometries referenced by a AbstractGeometry element -def ogr_gmlas_abstractgeometry(): +def test_ogr_gmlas_abstractgeometry(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -718,7 +718,7 @@ def error_handler(self, err_type, err_no, err_msg): self.error_list.append((err_type, err_no, err_msg)) -def ogr_gmlas_validate(): +def test_ogr_gmlas_validate(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -835,7 +835,7 @@ def ogr_gmlas_validate(): # Test correct namespace prefix handling -def ogr_gmlas_test_ns_prefix(): +def test_ogr_gmlas_test_ns_prefix(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -856,7 +856,7 @@ def ogr_gmlas_test_ns_prefix(): # Test parsing documents without namespace -def ogr_gmlas_no_namespace(): +def test_ogr_gmlas_no_namespace(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -875,7 +875,7 @@ def ogr_gmlas_no_namespace(): # Test CONFIG_FILE -def ogr_gmlas_conf(): +def test_ogr_gmlas_conf(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -983,7 +983,7 @@ def ogr_gmlas_conf(): # Test IgnoredXPaths aspect of config file -def ogr_gmlas_conf_ignored_xpath(): +def test_ogr_gmlas_conf_ignored_xpath(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1170,7 +1170,7 @@ def do_GET(self): # Test schema caching -def ogr_gmlas_cache(): +def test_ogr_gmlas_cache(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1323,7 +1323,7 @@ def ogr_gmlas_cache(): ############################################################################### # Test good working of linking to a child through its id attribute -def ogr_gmlas_link_nested_independant_child(): +def test_ogr_gmlas_link_nested_independant_child(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1342,7 +1342,7 @@ def ogr_gmlas_link_nested_independant_child(): # Test some pattern found in geosciml schemas -def ogr_gmlas_composition_compositionPart(): +def test_ogr_gmlas_composition_compositionPart(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1380,7 +1380,7 @@ def ogr_gmlas_composition_compositionPart(): # from _Feature/AbstractFeature -def ogr_gmlas_instantiate_only_gml_feature(): +def test_ogr_gmlas_instantiate_only_gml_feature(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1398,7 +1398,7 @@ def ogr_gmlas_instantiate_only_gml_feature(): # Test that WFS style timeStamp are ignored for hash generation -def ogr_gmlas_timestamp_ignored_for_hash(): +def test_ogr_gmlas_timestamp_ignored_for_hash(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1423,7 +1423,7 @@ def ogr_gmlas_timestamp_ignored_for_hash(): # Test dataset GetNextFeature() -def ogr_gmlas_dataset_getnextfeature(): +def test_ogr_gmlas_dataset_getnextfeature(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1591,7 +1591,7 @@ def ogr_gmlas_dataset_getnextfeature(): # will inline it. -def ogr_gmlas_inline_identifier(): +def test_ogr_gmlas_inline_identifier(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1614,7 +1614,7 @@ def ogr_gmlas_inline_identifier(): # Test that we can handle things like gml:name and au:name -def ogr_gmlas_avoid_same_name_inlined_classes(): +def test_ogr_gmlas_avoid_same_name_inlined_classes(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1639,7 +1639,7 @@ def ogr_gmlas_avoid_same_name_inlined_classes(): ############################################################################### # Test validation with an optional fixed attribute that is ignored -def ogr_gmlas_validate_ignored_fixed_attribute(): +def test_ogr_gmlas_validate_ignored_fixed_attribute(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1661,7 +1661,7 @@ def ogr_gmlas_validate_ignored_fixed_attribute(): ############################################################################### # Test REMOVE_UNUSED_LAYERS and REMOVE_UNUSED_FIELDS options -def ogr_gmlas_remove_unused_layers_and_fields(): +def test_ogr_gmlas_remove_unused_layers_and_fields(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -1710,7 +1710,7 @@ def ogr_gmlas_remove_unused_layers_and_fields(): # Test xlink resolution -def ogr_gmlas_xlink_resolver(): +def test_ogr_gmlas_xlink_resolver(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2190,7 +2190,7 @@ def ogr_gmlas_xlink_resolver(): # Test UTF-8 support -def ogr_gmlas_recoding(): +def test_ogr_gmlas_recoding(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2215,7 +2215,7 @@ def ogr_gmlas_recoding(): # Test schema without namespace prefix -def ogr_gmlas_schema_without_namespace_prefix(): +def test_ogr_gmlas_schema_without_namespace_prefix(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2259,7 +2259,7 @@ def ogr_gmlas_schema_without_namespace_prefix(): # Test parsing truncated XML -def ogr_gmlas_truncated_xml(): +def test_ogr_gmlas_truncated_xml(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2279,7 +2279,7 @@ def ogr_gmlas_truncated_xml(): # Test identifier truncation -def ogr_gmlas_identifier_truncation(): +def test_ogr_gmlas_identifier_truncation(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2350,7 +2350,7 @@ def ogr_gmlas_identifier_truncation(): # Test behaviour when identifiers have same case -def ogr_gmlas_identifier_case_ambiguity(): +def test_ogr_gmlas_identifier_case_ambiguity(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2386,7 +2386,7 @@ def ogr_gmlas_identifier_case_ambiguity(): # Test writing support -def ogr_gmlas_writer(): +def test_ogr_gmlas_writer(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2413,7 +2413,7 @@ def ogr_gmlas_writer(): # Check the generated .xml and .xsd -def ogr_gmlas_writer_check_xml_xsd(): +def test_ogr_gmlas_writer_check_xml_xsd(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2478,7 +2478,7 @@ def ogr_gmlas_writer_check_xml_xsd(): # as the original one. -def ogr_gmlas_writer_check_xml_read_back(): +def test_ogr_gmlas_writer_check_xml_read_back(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2547,7 +2547,7 @@ def ogr_gmlas_writer_check_xml_read_back(): # Test writing support with geometries -def ogr_gmlas_writer_gml(): +def test_ogr_gmlas_writer_gml(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2609,7 +2609,7 @@ def ogr_gmlas_writer_gml(): # Test writing support with geometries and -a_srs -def ogr_gmlas_writer_gml_assign_srs(): +def test_ogr_gmlas_writer_gml_assign_srs(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2679,7 +2679,7 @@ def ogr_gmlas_writer_gml_assign_srs(): # Test writing support with geometries with original XML content preserved -def ogr_gmlas_writer_gml_original_xml(): +def test_ogr_gmlas_writer_gml_original_xml(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2735,7 +2735,7 @@ def ogr_gmlas_writer_gml_original_xml(): # Test writing support with XSD, INDENT_SIZE, COMMENT, OUTPUT_XSD_FILENAME, TIMESTAMP options -def ogr_gmlas_writer_options(): +def test_ogr_gmlas_writer_options(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -2891,7 +2891,7 @@ def ogr_gmlas_writer_options(): # Test writing support error handle -def ogr_gmlas_writer_errors(): +def test_ogr_gmlas_writer_errors(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3031,7 +3031,7 @@ def ogr_gmlas_writer_errors(): # crashes -def ogr_gmlas_read_fake_gmljp2(): +def test_ogr_gmlas_read_fake_gmljp2(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3059,7 +3059,7 @@ def ogr_gmlas_read_fake_gmljp2(): # Test TypingConstraints -def ogr_gmlas_typing_constraints(): +def test_ogr_gmlas_typing_constraints(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3166,7 +3166,7 @@ def ogr_gmlas_typing_constraints(): # Test swe:DataArray -def ogr_gmlas_swe_dataarray(): +def test_ogr_gmlas_swe_dataarray(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3248,7 +3248,7 @@ def ogr_gmlas_swe_dataarray(): ############################################################################### # Test swe:DataRecord -def ogr_gmlas_swe_datarecord(): +def test_ogr_gmlas_swe_datarecord(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3286,7 +3286,7 @@ def ogr_gmlas_swe_datarecord(): # Test a xs:any field at end of a type declaration -def ogr_gmlas_any_field_at_end_of_declaration(): +def test_ogr_gmlas_any_field_at_end_of_declaration(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3318,7 +3318,7 @@ def ogr_gmlas_any_field_at_end_of_declaration(): # Test auxiliary schema without namespace prefix -def ogr_gmlas_aux_schema_without_namespace_prefix(): +def test_ogr_gmlas_aux_schema_without_namespace_prefix(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3337,7 +3337,7 @@ def ogr_gmlas_aux_schema_without_namespace_prefix(): # of another one (#6990) -def ogr_gmlas_geometry_as_substitutiongroup(): +def test_ogr_gmlas_geometry_as_substitutiongroup(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3381,7 +3381,7 @@ def ogr_gmlas_extra_eureg(): # Test a schema that has nothing interesting in it but imports another # schema -def ogr_gmlas_no_element_in_first_choice_schema(): +def test_ogr_gmlas_no_element_in_first_choice_schema(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3400,7 +3400,7 @@ def ogr_gmlas_no_element_in_first_choice_schema(): ############################################################################### # Test cross-layer links with xlink:href="#my_id" -def ogr_gmlas_internal_xlink_href(): +def test_ogr_gmlas_internal_xlink_href(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3554,7 +3554,7 @@ def ogr_gmlas_internal_xlink_href(): # Cleanup -def ogr_gmlas_cleanup(): +def test_ogr_gmlas_cleanup(): if ogr.GetDriverByName('GMLAS') is None: return 'skip' @@ -3570,64 +3570,64 @@ def ogr_gmlas_cleanup(): gdaltest_list = [ - ogr_gmlas_basic, - ogr_gmlas_test_ogrsf, - ogr_gmlas_virtual_file, - ogr_gmlas_datafile_with_xsd_option, - ogr_gmlas_no_datafile_with_xsd_option, - ogr_gmlas_no_datafile_xsd_which_is_not_xsd, - ogr_gmlas_no_datafile_no_xsd, - ogr_gmlas_non_existing_gml, - ogr_gmlas_non_existing_xsd, - ogr_gmlas_gml_without_schema_location, - ogr_gmlas_invalid_schema, - ogr_gmlas_invalid_xml, - ogr_gmlas_gml_Reference, - ogr_gmlas_same_element_in_different_ns, - ogr_gmlas_corner_case_relative_path, - ogr_gmlas_unexpected_repeated_element, - ogr_gmlas_unexpected_repeated_element_variant, - ogr_gmlas_geometryproperty, - ogr_gmlas_abstractgeometry, - ogr_gmlas_validate, - ogr_gmlas_test_ns_prefix, - ogr_gmlas_no_namespace, - ogr_gmlas_conf, - ogr_gmlas_conf_ignored_xpath, - ogr_gmlas_cache, - ogr_gmlas_link_nested_independant_child, - ogr_gmlas_composition_compositionPart, - ogr_gmlas_instantiate_only_gml_feature, - ogr_gmlas_timestamp_ignored_for_hash, - ogr_gmlas_dataset_getnextfeature, - ogr_gmlas_inline_identifier, - ogr_gmlas_avoid_same_name_inlined_classes, - ogr_gmlas_validate_ignored_fixed_attribute, - ogr_gmlas_remove_unused_layers_and_fields, - ogr_gmlas_xlink_resolver, - ogr_gmlas_recoding, - ogr_gmlas_schema_without_namespace_prefix, - ogr_gmlas_truncated_xml, - ogr_gmlas_identifier_truncation, - ogr_gmlas_identifier_case_ambiguity, - ogr_gmlas_writer, - ogr_gmlas_writer_check_xml_xsd, - ogr_gmlas_writer_check_xml_read_back, - ogr_gmlas_writer_gml, - ogr_gmlas_writer_gml_assign_srs, - ogr_gmlas_writer_gml_original_xml, - ogr_gmlas_writer_options, - ogr_gmlas_writer_errors, - ogr_gmlas_read_fake_gmljp2, - ogr_gmlas_typing_constraints, - ogr_gmlas_swe_dataarray, - ogr_gmlas_swe_datarecord, - ogr_gmlas_any_field_at_end_of_declaration, - ogr_gmlas_aux_schema_without_namespace_prefix, - ogr_gmlas_geometry_as_substitutiongroup, - ogr_gmlas_no_element_in_first_choice_schema, - ogr_gmlas_internal_xlink_href, - ogr_gmlas_cleanup] + test_ogr_gmlas_basic, + test_ogr_gmlas_test_ogrsf, + test_ogr_gmlas_virtual_file, + test_ogr_gmlas_datafile_with_xsd_option, + test_ogr_gmlas_no_datafile_with_xsd_option, + test_ogr_gmlas_no_datafile_xsd_which_is_not_xsd, + test_ogr_gmlas_no_datafile_no_xsd, + test_ogr_gmlas_non_existing_gml, + test_ogr_gmlas_non_existing_xsd, + test_ogr_gmlas_gml_without_schema_location, + test_ogr_gmlas_invalid_schema, + test_ogr_gmlas_invalid_xml, + test_ogr_gmlas_gml_Reference, + test_ogr_gmlas_same_element_in_different_ns, + test_ogr_gmlas_corner_case_relative_path, + test_ogr_gmlas_unexpected_repeated_element, + test_ogr_gmlas_unexpected_repeated_element_variant, + test_ogr_gmlas_geometryproperty, + test_ogr_gmlas_abstractgeometry, + test_ogr_gmlas_validate, + test_ogr_gmlas_test_ns_prefix, + test_ogr_gmlas_no_namespace, + test_ogr_gmlas_conf, + test_ogr_gmlas_conf_ignored_xpath, + test_ogr_gmlas_cache, + test_ogr_gmlas_link_nested_independant_child, + test_ogr_gmlas_composition_compositionPart, + test_ogr_gmlas_instantiate_only_gml_feature, + test_ogr_gmlas_timestamp_ignored_for_hash, + test_ogr_gmlas_dataset_getnextfeature, + test_ogr_gmlas_inline_identifier, + test_ogr_gmlas_avoid_same_name_inlined_classes, + test_ogr_gmlas_validate_ignored_fixed_attribute, + test_ogr_gmlas_remove_unused_layers_and_fields, + test_ogr_gmlas_xlink_resolver, + test_ogr_gmlas_recoding, + test_ogr_gmlas_schema_without_namespace_prefix, + test_ogr_gmlas_truncated_xml, + test_ogr_gmlas_identifier_truncation, + test_ogr_gmlas_identifier_case_ambiguity, + test_ogr_gmlas_writer, + test_ogr_gmlas_writer_check_xml_xsd, + test_ogr_gmlas_writer_check_xml_read_back, + test_ogr_gmlas_writer_gml, + test_ogr_gmlas_writer_gml_assign_srs, + test_ogr_gmlas_writer_gml_original_xml, + test_ogr_gmlas_writer_options, + test_ogr_gmlas_writer_errors, + test_ogr_gmlas_read_fake_gmljp2, + test_ogr_gmlas_typing_constraints, + test_ogr_gmlas_swe_dataarray, + test_ogr_gmlas_swe_datarecord, + test_ogr_gmlas_any_field_at_end_of_declaration, + test_ogr_gmlas_aux_schema_without_namespace_prefix, + test_ogr_gmlas_geometry_as_substitutiongroup, + test_ogr_gmlas_no_element_in_first_choice_schema, + test_ogr_gmlas_internal_xlink_href, + test_ogr_gmlas_cleanup] # gdaltest_list = [ ogr_gmlas_basic, ogr_gmlas_aux_schema_without_namespace_prefix, ogr_gmlas_cleanup ] diff --git a/autotest/ogr/ogr_gmt.py b/autotest/ogr/ogr_gmt.py index 18447411cbef..e996a58398ff 100755 --- a/autotest/ogr/ogr_gmt.py +++ b/autotest/ogr/ogr_gmt.py @@ -40,7 +40,7 @@ # Open Memory datasource. -def ogr_gmt_1(): +def test_ogr_gmt_1(): gmt_drv = ogr.GetDriverByName('GMT') gdaltest.gmt_ds = gmt_drv.CreateDataSource('tmp/tpoly.gmt') @@ -54,7 +54,7 @@ def ogr_gmt_1(): # Create table from data/poly.shp -def ogr_gmt_2(): +def test_ogr_gmt_2(): ####################################################### # Create gmtory Layer @@ -97,7 +97,7 @@ def ogr_gmt_2(): # Verify that stuff we just wrote is still OK. -def ogr_gmt_3(): +def test_ogr_gmt_3(): gdaltest.gmt_ds = ogr.Open('tmp/tpoly.gmt') gdaltest.gmt_lyr = gdaltest.gmt_ds.GetLayer(0) @@ -133,7 +133,7 @@ def ogr_gmt_3(): # Verify reading of multilinestring file. (#3802) -def ogr_gmt_4(): +def test_ogr_gmt_4(): ds = ogr.Open('data/test_multi.gmt') lyr = ds.GetLayer(0) @@ -172,7 +172,7 @@ def ogr_gmt_4(): # Write a multipolygon file and verify it. -def ogr_gmt_5(): +def test_ogr_gmt_5(): ####################################################### # Create gmtory Layer @@ -244,7 +244,7 @@ def ogr_gmt_5(): ############################################################################### # -def ogr_gmt_cleanup(): +def test_ogr_gmt_cleanup(): if gdaltest.gmt_ds is not None: gdaltest.gmt_lyr = None @@ -256,12 +256,12 @@ def ogr_gmt_cleanup(): gdaltest_list = [ - ogr_gmt_1, - ogr_gmt_2, - ogr_gmt_3, - ogr_gmt_4, - ogr_gmt_5, - ogr_gmt_cleanup] + test_ogr_gmt_1, + test_ogr_gmt_2, + test_ogr_gmt_3, + test_ogr_gmt_4, + test_ogr_gmt_5, + test_ogr_gmt_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_gpkg.py b/autotest/ogr/ogr_gpkg.py index 54fd44c791a5..86ebd1933cee 100755 --- a/autotest/ogr/ogr_gpkg.py +++ b/autotest/ogr/ogr_gpkg.py @@ -87,7 +87,7 @@ def validate(filename, quiet=False): # Create a fresh database. -def ogr_gpkg_1(): +def test_ogr_gpkg_1(): gdaltest.gpkg_ds = None gdaltest.gpkg_dr = None @@ -123,7 +123,7 @@ def ogr_gpkg_1(): # Re-open database to test validity -def ogr_gpkg_2(): +def test_ogr_gpkg_2(): if gdaltest.gpkg_dr is None: return 'skip' @@ -160,7 +160,7 @@ def ogr_gpkg_2(): ############################################################################### # Create a layer -def ogr_gpkg_3(): +def test_ogr_gpkg_3(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' @@ -189,7 +189,7 @@ def ogr_gpkg_3(): # Close and re-open to test the layer registration -def ogr_gpkg_4(): +def test_ogr_gpkg_4(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' @@ -260,7 +260,7 @@ def ogr_gpkg_4(): ############################################################################### # Delete a layer -def ogr_gpkg_5(): +def test_ogr_gpkg_5(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' @@ -299,7 +299,7 @@ def ogr_gpkg_5(): ############################################################################### # Add fields -def ogr_gpkg_6(): +def test_ogr_gpkg_6(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' @@ -352,7 +352,7 @@ def ogr_gpkg_6(): ############################################################################### # Add a feature / read a feature / delete a feature -def ogr_gpkg_7(): +def test_ogr_gpkg_7(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' @@ -446,7 +446,7 @@ def ogr_gpkg_7(): ############################################################################### # Test a variety of geometry feature types and attribute types -def ogr_gpkg_8(): +def test_ogr_gpkg_8(): # try: # os.remove( 'tmp/gpkg_test.gpkg' ) @@ -590,7 +590,7 @@ def ogr_gpkg_8(): # Test support for extents and counts -def ogr_gpkg_9(): +def test_ogr_gpkg_9(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' @@ -614,7 +614,7 @@ def ogr_gpkg_9(): # Test non-SELECT SQL commands -def ogr_gpkg_11(): +def test_ogr_gpkg_11(): if gdaltest.gpkg_dr is None: return 'skip' @@ -640,7 +640,7 @@ def ogr_gpkg_11(): # Test SELECT SQL commands -def ogr_gpkg_12(): +def test_ogr_gpkg_12(): if gdaltest.gpkg_dr is None: return 'skip' @@ -780,7 +780,7 @@ def ogr_gpkg_12(): # Test non-spatial tables -def ogr_gpkg_13(): +def test_ogr_gpkg_13(): if gdaltest.gpkg_dr is None: return 'skip' @@ -843,7 +843,7 @@ def ogr_gpkg_13(): # Add various geometries to test spatial filtering -def ogr_gpkg_14(): +def test_ogr_gpkg_14(): if gdaltest.gpkg_dr is None: return 'skip' @@ -943,7 +943,7 @@ def ogr_gpkg_14(): # Test SQL functions -def ogr_gpkg_15(): +def test_ogr_gpkg_15(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1350,7 +1350,7 @@ def ogr_gpkg_15(): # Test unknown extensions -def ogr_gpkg_16(): +def test_ogr_gpkg_16(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1475,7 +1475,7 @@ def ogr_gpkg_16(): # Run INDIRECT_SQLITE dialect -def ogr_gpkg_17(): +def test_ogr_gpkg_17(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1495,7 +1495,7 @@ def ogr_gpkg_17(): # Test geometry type extension -def ogr_gpkg_18(): +def test_ogr_gpkg_18(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1616,7 +1616,7 @@ def ogr_gpkg_18(): # Test metadata -def ogr_gpkg_19(): +def test_ogr_gpkg_19(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1747,7 +1747,7 @@ def ogr_gpkg_19(): # Test spatial reference system -def ogr_gpkg_20(): +def test_ogr_gpkg_20(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1859,7 +1859,7 @@ def ogr_gpkg_20(): # Test maximum width of text fields -def ogr_gpkg_21(): +def test_ogr_gpkg_21(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1954,7 +1954,7 @@ def ogr_gpkg_21(): # Test FID64 support -def ogr_gpkg_22(): +def test_ogr_gpkg_22(): if gdaltest.gpkg_dr is None: return 'skip' @@ -1990,7 +1990,7 @@ def ogr_gpkg_22(): # Test not nullable fields -def ogr_gpkg_23(): +def test_ogr_gpkg_23(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2184,7 +2184,7 @@ def ogr_gpkg_23(): # Test default values -def ogr_gpkg_24(): +def test_ogr_gpkg_24(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2317,7 +2317,7 @@ def ogr_gpkg_24(): # Test creating a field with the fid name -def ogr_gpkg_25(): +def test_ogr_gpkg_25(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2420,7 +2420,7 @@ def ogr_gpkg_25(): # Test dataset transactions -def ogr_gpkg_26(): +def test_ogr_gpkg_26(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2581,7 +2581,7 @@ def ogr_gpkg_26(): # Test interface with Spatialite -def ogr_gpkg_27(): +def test_ogr_gpkg_27(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2618,7 +2618,7 @@ def ogr_gpkg_27(): # but inc/dec its ref count, which can exhibit issues in GDALVectorTanslate()) -def ogr_gpkg_28(): +def test_ogr_gpkg_28(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2637,7 +2637,7 @@ def ogr_gpkg_28(): # Test XYM / XYZM support -def ogr_gpkg_29(): +def test_ogr_gpkg_29(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2725,7 +2725,7 @@ def ogr_gpkg_29(): # Test non standard file extension (#6396) -def ogr_gpkg_30(): +def test_ogr_gpkg_30(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2759,7 +2759,7 @@ def ogr_gpkg_30(): # Test CURVE and SURFACE types -def ogr_gpkg_31(): +def test_ogr_gpkg_31(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2805,7 +2805,7 @@ def ogr_gpkg_31(): # read it back -def ogr_gpkg_32(): +def test_ogr_gpkg_32(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2847,7 +2847,7 @@ def ogr_gpkg_32(): # Test OGR_CURRENT_DATE -def ogr_gpkg_33(): +def test_ogr_gpkg_33(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2874,7 +2874,7 @@ def ogr_gpkg_33(): # Run test_ogrsf -def ogr_gpkg_test_ogrsf(): +def test_ogr_gpkg_test_ogrsf(): if gdaltest.gpkg_dr is None: return 'skip' @@ -2913,7 +2913,7 @@ def ogr_gpkg_test_ogrsf(): ############################################################################### # Test rename and delete a layer registered in extensions, metadata, spatial index etc -def ogr_gpkg_34(): +def test_ogr_gpkg_34(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3047,7 +3047,7 @@ def ogr_gpkg_34(): # Test DeleteField() -def ogr_gpkg_35(): +def test_ogr_gpkg_35(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3166,7 +3166,7 @@ def ogr_gpkg_35(): # Test AlterFieldDefn() -def ogr_gpkg_36(): +def test_ogr_gpkg_36(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3320,7 +3320,7 @@ def ogr_gpkg_36(): # Test ReorderFields() -def ogr_gpkg_37(): +def test_ogr_gpkg_37(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3405,7 +3405,7 @@ def ogr_gpkg_37(): # Test GetExtent() and RECOMPUTE EXTENT ON -def ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): +def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): if gdaltest.gpkg_dr is None: return 'skip' @@ -3506,15 +3506,15 @@ def ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): return 'success' -def ogr_gpkg_38_nospi(): - return ogr_gpkg_38(options=['SPATIAL_INDEX=NO']) +def test_ogr_gpkg_38_nospi(): + return test_ogr_gpkg_38(options=['SPATIAL_INDEX=NO']) ############################################################################### # Test checking of IDENTIFIER unicity -def ogr_gpkg_39(): +def test_ogr_gpkg_39(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3564,7 +3564,7 @@ def ogr_gpkg_39(): # read it back -def ogr_gpkg_40(): +def test_ogr_gpkg_40(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3606,7 +3606,7 @@ def ogr_gpkg_40(): # Test tables without integer primary key (#6799), and unrecognized column type -def ogr_gpkg_41(): +def test_ogr_gpkg_41(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3664,7 +3664,7 @@ def get_feature_count_from_gpkg_contents(ds): return val -def ogr_gpkg_42(): +def test_ogr_gpkg_42(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3854,7 +3854,7 @@ def ogr_gpkg_42(): ############################################################################### # Test limitations on number of tables -def ogr_gpkg_43(): +def test_ogr_gpkg_43(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3898,7 +3898,7 @@ def ogr_gpkg_43(): ############################################################################### # Test GeoPackage without metadata table -def ogr_gpkg_44(): +def test_ogr_gpkg_44(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3952,7 +3952,7 @@ def ogr_gpkg_44(): ############################################################################### # Test non conformant GeoPackage: table with non INTEGER PRIMARY KEY -def ogr_gpkg_45(): +def test_ogr_gpkg_45(): if gdaltest.gpkg_dr is None: return 'skip' @@ -3979,7 +3979,7 @@ def ogr_gpkg_45(): # Test spatial view and spatial index -def ogr_gpkg_46(): +def test_ogr_gpkg_46(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4099,7 +4099,7 @@ def ogr_gpkg_46(): # Test corner case of Identify() -def ogr_gpkg_47(): +def test_ogr_gpkg_47(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4248,7 +4248,7 @@ def ogr_gpkg_47(): # Test insertion of features with unset fields -def ogr_gpkg_48(): +def test_ogr_gpkg_48(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4313,7 +4313,7 @@ def ogr_gpkg_48(): # Test CreateGeomField() on a attributes layer -def ogr_gpkg_49(): +def test_ogr_gpkg_49(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4341,7 +4341,7 @@ def ogr_gpkg_49(): # Test minimalistic support of definition_12_063 -def ogr_gpkg_50(): +def test_ogr_gpkg_50(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4393,7 +4393,7 @@ def ogr_gpkg_50(): # Test opening a .gpkg.sql file -def ogr_gpkg_51(): +def test_ogr_gpkg_51(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4413,7 +4413,7 @@ def ogr_gpkg_51(): # Test opening a .gpkg file -def ogr_gpkg_52(): +def test_ogr_gpkg_52(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4431,7 +4431,7 @@ def ogr_gpkg_52(): # Test opening a .gpkg file with inconsistency regarding table case (#6916) -def ogr_gpkg_53(): +def test_ogr_gpkg_53(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4463,7 +4463,7 @@ def ogr_gpkg_53(): # Test editing of a database with 2 layers (https://issues.qgis.org/issues/17034) -def ogr_gpkg_54(): +def test_ogr_gpkg_54(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4532,7 +4532,7 @@ def ogr_gpkg_54(): # Test inserting geometries incompatible with declared layer geometry type -def ogr_gpkg_55(): +def test_ogr_gpkg_55(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4567,7 +4567,7 @@ def ogr_gpkg_55(): # Test FID identification on SQL result layer -def ogr_gpkg_56(): +def test_ogr_gpkg_56(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4589,7 +4589,7 @@ def ogr_gpkg_56(): # Test opening a corrupted gpkg with duplicated layer names -def ogr_gpkg_57(): +def test_ogr_gpkg_57(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4628,7 +4628,7 @@ def ogr_gpkg_57(): # Test overwriting a layer -def ogr_gpkg_58(): +def test_ogr_gpkg_58(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4654,7 +4654,7 @@ def ogr_gpkg_58(): # Test CreateSpatialIndex() -def ogr_gpkg_59(): +def test_ogr_gpkg_59(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4679,7 +4679,7 @@ def ogr_gpkg_59(): # Test savepoints -def ogr_gpkg_savepoint(): +def test_ogr_gpkg_savepoint(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4720,7 +4720,7 @@ def ogr_gpkg_savepoint(): # Test that we don't open file handles behind the back of sqlite3 -def ogr_gpkg_wal(): +def test_ogr_gpkg_wal(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4764,7 +4764,7 @@ def ogr_gpkg_wal(): # Test JSon subtype support -def ogr_gpkg_json(): +def test_ogr_gpkg_json(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4855,7 +4855,7 @@ def ogr_gpkg_json(): # Remove the test db from the tmp directory -def ogr_gpkg_cleanup(): +def test_ogr_gpkg_cleanup(): if gdaltest.gpkg_dr is None: return 'skip' @@ -4878,70 +4878,70 @@ def ogr_gpkg_cleanup(): gdaltest_list = [ - ogr_gpkg_1, - ogr_gpkg_2, - ogr_gpkg_3, - ogr_gpkg_4, - ogr_gpkg_5, - ogr_gpkg_6, - ogr_gpkg_7, - ogr_gpkg_8, - ogr_gpkg_9, - ogr_gpkg_11, - ogr_gpkg_12, - ogr_gpkg_13, - ogr_gpkg_14, - ogr_gpkg_15, - ogr_gpkg_16, - ogr_gpkg_17, - ogr_gpkg_18, - ogr_gpkg_19, - ogr_gpkg_20, - ogr_gpkg_21, - ogr_gpkg_22, - ogr_gpkg_23, - ogr_gpkg_24, - ogr_gpkg_25, - ogr_gpkg_26, - ogr_gpkg_27, - ogr_gpkg_28, - ogr_gpkg_29, - ogr_gpkg_30, - ogr_gpkg_31, - ogr_gpkg_32, - ogr_gpkg_33, - ogr_gpkg_34, - ogr_gpkg_35, - ogr_gpkg_36, - ogr_gpkg_37, - ogr_gpkg_38, - ogr_gpkg_38_nospi, - ogr_gpkg_39, - ogr_gpkg_40, - ogr_gpkg_41, - ogr_gpkg_42, - ogr_gpkg_43, - ogr_gpkg_44, - ogr_gpkg_45, - ogr_gpkg_46, - ogr_gpkg_47, - ogr_gpkg_48, - ogr_gpkg_49, - ogr_gpkg_50, - ogr_gpkg_51, - ogr_gpkg_52, - ogr_gpkg_53, - ogr_gpkg_54, - ogr_gpkg_55, - ogr_gpkg_56, - ogr_gpkg_57, - ogr_gpkg_58, - ogr_gpkg_59, - ogr_gpkg_savepoint, - ogr_gpkg_wal, - ogr_gpkg_json, - ogr_gpkg_test_ogrsf, - ogr_gpkg_cleanup, + test_ogr_gpkg_1, + test_ogr_gpkg_2, + test_ogr_gpkg_3, + test_ogr_gpkg_4, + test_ogr_gpkg_5, + test_ogr_gpkg_6, + test_ogr_gpkg_7, + test_ogr_gpkg_8, + test_ogr_gpkg_9, + test_ogr_gpkg_11, + test_ogr_gpkg_12, + test_ogr_gpkg_13, + test_ogr_gpkg_14, + test_ogr_gpkg_15, + test_ogr_gpkg_16, + test_ogr_gpkg_17, + test_ogr_gpkg_18, + test_ogr_gpkg_19, + test_ogr_gpkg_20, + test_ogr_gpkg_21, + test_ogr_gpkg_22, + test_ogr_gpkg_23, + test_ogr_gpkg_24, + test_ogr_gpkg_25, + test_ogr_gpkg_26, + test_ogr_gpkg_27, + test_ogr_gpkg_28, + test_ogr_gpkg_29, + test_ogr_gpkg_30, + test_ogr_gpkg_31, + test_ogr_gpkg_32, + test_ogr_gpkg_33, + test_ogr_gpkg_34, + test_ogr_gpkg_35, + test_ogr_gpkg_36, + test_ogr_gpkg_37, + test_ogr_gpkg_38, + test_ogr_gpkg_38_nospi, + test_ogr_gpkg_39, + test_ogr_gpkg_40, + test_ogr_gpkg_41, + test_ogr_gpkg_42, + test_ogr_gpkg_43, + test_ogr_gpkg_44, + test_ogr_gpkg_45, + test_ogr_gpkg_46, + test_ogr_gpkg_47, + test_ogr_gpkg_48, + test_ogr_gpkg_49, + test_ogr_gpkg_50, + test_ogr_gpkg_51, + test_ogr_gpkg_52, + test_ogr_gpkg_53, + test_ogr_gpkg_54, + test_ogr_gpkg_55, + test_ogr_gpkg_56, + test_ogr_gpkg_57, + test_ogr_gpkg_58, + test_ogr_gpkg_59, + test_ogr_gpkg_savepoint, + test_ogr_gpkg_wal, + test_ogr_gpkg_json, + test_ogr_gpkg_test_ogrsf, + test_ogr_gpkg_cleanup, ] # gdaltest_list = [ ogr_gpkg_1, ogr_gpkg_47, ogr_gpkg_cleanup ] diff --git a/autotest/ogr/ogr_gpsbabel.py b/autotest/ogr/ogr_gpsbabel.py index 52134ddb788d..fcddac8a5763 100755 --- a/autotest/ogr/ogr_gpsbabel.py +++ b/autotest/ogr/ogr_gpsbabel.py @@ -40,7 +40,7 @@ # Check that dependencies are met -def ogr_gpsbabel_init(): +def test_ogr_gpsbabel_init(): # Test if the gpsbabel is accessible ogrtest.have_gpsbabel = False @@ -68,7 +68,7 @@ def ogr_gpsbabel_init(): # Test reading with explicit subdriver -def ogr_gpsbabel_1(): +def test_ogr_gpsbabel_1(): if not ogrtest.have_read_gpsbabel: return 'skip' @@ -86,7 +86,7 @@ def ogr_gpsbabel_1(): # Test reading with implicit subdriver -def ogr_gpsbabel_2(): +def test_ogr_gpsbabel_2(): if not ogrtest.have_read_gpsbabel: return 'skip' @@ -104,7 +104,7 @@ def ogr_gpsbabel_2(): # Test writing -def ogr_gpsbabel_3(): +def test_ogr_gpsbabel_3(): if not ogrtest.have_gpsbabel: return 'skip' @@ -148,10 +148,10 @@ def ogr_gpsbabel_3(): gdaltest_list = [ - ogr_gpsbabel_init, - ogr_gpsbabel_1, - ogr_gpsbabel_2, - ogr_gpsbabel_3] + test_ogr_gpsbabel_init, + test_ogr_gpsbabel_1, + test_ogr_gpsbabel_2, + test_ogr_gpsbabel_3] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_gpx.py b/autotest/ogr/ogr_gpx.py index 5431cdcfa934..8f872dfa5e4d 100755 --- a/autotest/ogr/ogr_gpx.py +++ b/autotest/ogr/ogr_gpx.py @@ -38,7 +38,7 @@ from osgeo import gdal -def ogr_gpx_init(): +def test_ogr_gpx_init(): gdaltest.gpx_ds = None gdaltest.gpx_ds = ogr.Open('data/test.gpx') @@ -60,7 +60,7 @@ def ogr_gpx_init(): # Test waypoints gpx layer. -def ogr_gpx_1(): +def test_ogr_gpx_1(): if not gdaltest.have_gpx: return 'skip' @@ -157,7 +157,7 @@ def ogr_gpx_1(): # Test routes gpx layer. -def ogr_gpx_2(): +def test_ogr_gpx_2(): if not gdaltest.have_gpx: return 'skip' @@ -181,7 +181,7 @@ def ogr_gpx_2(): ############################################################################### # Test route_points gpx layer. -def ogr_gpx_3(): +def test_ogr_gpx_3(): if not gdaltest.have_gpx: return 'skip' @@ -207,7 +207,7 @@ def ogr_gpx_3(): # Test tracks gpx layer. -def ogr_gpx_4(): +def test_ogr_gpx_4(): if not gdaltest.have_gpx: return 'skip' @@ -236,7 +236,7 @@ def ogr_gpx_4(): # Test route_points gpx layer. -def ogr_gpx_5(): +def test_ogr_gpx_5(): if not gdaltest.have_gpx: return 'skip' @@ -262,7 +262,7 @@ def ogr_gpx_5(): # Copy our small gpx file to a new gpx file. -def ogr_gpx_6(): +def test_ogr_gpx_6(): if not gdaltest.have_gpx: return 'skip' @@ -349,7 +349,7 @@ def ogr_gpx_6(): # Output extra fields as . -def ogr_gpx_7(): +def test_ogr_gpx_7(): if not gdaltest.have_gpx: return 'skip' @@ -423,7 +423,7 @@ def ogr_gpx_7(): # Output extra fields as . -def ogr_gpx_8(): +def test_ogr_gpx_8(): if not gdaltest.have_gpx: return 'skip' @@ -518,7 +518,7 @@ def ogr_gpx_8(): # Parse file with a ") @@ -1634,7 +1634,7 @@ def ogr_vrt_28(): # Test OGRVRTWarpedLayer -def ogr_vrt_29(): +def test_ogr_vrt_29(): gdal.Unlink('tmp/ogr_vrt_29.shp') gdal.Unlink('tmp/ogr_vrt_29.shx') @@ -2002,7 +2002,7 @@ def ogr_vrt_29(): ############################################################################### # Test OGRVRTUnionLayer -def ogr_vrt_30(): +def test_ogr_vrt_30(): for filename in ['tmp/ogr_vrt_30_1.shp', 'tmp/ogr_vrt_30_1.shx', @@ -2509,7 +2509,7 @@ def ogr_vrt_30(): # Test anti-recursion mechanism with union layer -def ogr_vrt_31(shared_ds_flag=''): +def test_ogr_vrt_31(shared_ds_flag=''): rec1 = """ @@ -2558,15 +2558,15 @@ def ogr_vrt_31(shared_ds_flag=''): # Test anti-recursion mechanism on shared DS -def ogr_vrt_32(): +def test_ogr_vrt_32(): - return ogr_vrt_31(' shared="1"') + return test_ogr_vrt_31(' shared="1"') ############################################################################### # Test multi-geometry support -def ogr_vrt_33(): +def test_ogr_vrt_33(): try: import shutil @@ -3324,7 +3324,7 @@ def ogr_vrt_33(): # Test SetIgnoredFields() with with PointFromColumns geometries -def ogr_vrt_34(): +def test_ogr_vrt_34(): if gdaltest.vrt_ds is None: return 'skip' @@ -3366,7 +3366,7 @@ def ogr_vrt_34(): # Test nullable fields -def ogr_vrt_35(): +def test_ogr_vrt_35(): if gdaltest.vrt_ds is None: return 'skip' @@ -3446,7 +3446,7 @@ def ogr_vrt_35(): # Test editing direct geometries -def ogr_vrt_36(): +def test_ogr_vrt_36(): if gdaltest.vrt_ds is None: return 'skip' @@ -3493,7 +3493,7 @@ def ogr_vrt_36(): # Test implict non-spatial layers (#6336) -def ogr_vrt_37(): +def test_ogr_vrt_37(): with gdaltest.error_handler(): ds = ogr.Open('data/vrt_test.vrt') @@ -3517,7 +3517,7 @@ def ogr_vrt_37(): # Test reading geometry type -def ogr_vrt_38(): +def test_ogr_vrt_38(): if gdaltest.vrt_ds is None: return 'skip' @@ -3572,7 +3572,7 @@ def ogr_vrt_38(): # Test that attribute filtering works with -def ogr_vrt_39(): +def test_ogr_vrt_39(): if gdaltest.vrt_ds is None: return 'skip' @@ -3616,7 +3616,7 @@ def ogr_vrt_39(): # Test PointZM support with encoding="PointFromColumns" -def ogr_vrt_40(): +def test_ogr_vrt_40(): if gdaltest.vrt_ds is None: return 'skip' @@ -3657,7 +3657,7 @@ def ogr_vrt_40(): # Test GetExtent() on erroneous definition -def ogr_vrt_41(): +def test_ogr_vrt_41(): ds = ogr.Open(""" @@ -3674,7 +3674,7 @@ def ogr_vrt_41(): # -def ogr_vrt_cleanup(): +def test_ogr_vrt_cleanup(): if gdaltest.vrt_ds is None: return 'skip' @@ -3699,49 +3699,49 @@ def ogr_vrt_cleanup(): gdaltest_list = [ - ogr_vrt_1, - ogr_vrt_2, - ogr_vrt_3, - ogr_vrt_4, - ogr_vrt_5, - ogr_vrt_6, - ogr_vrt_7, - ogr_vrt_8, - ogr_vrt_9, - ogr_vrt_10, - ogr_vrt_11, - ogr_vrt_12, - ogr_vrt_13, - ogr_vrt_14, - ogr_vrt_15, - ogr_vrt_16, - ogr_vrt_17, - ogr_vrt_18, - ogr_vrt_19_optimized, - ogr_vrt_19_nonoptimized, - ogr_vrt_20, - ogr_vrt_21, - ogr_vrt_22, - ogr_vrt_23, - ogr_vrt_24, - ogr_vrt_25, - ogr_vrt_26, - ogr_vrt_27, - ogr_vrt_28, - ogr_vrt_29, - ogr_vrt_30, - ogr_vrt_31, - ogr_vrt_32, - ogr_vrt_33, - ogr_vrt_34, - ogr_vrt_35, - ogr_vrt_36, - ogr_vrt_37, - ogr_vrt_38, - ogr_vrt_39, - ogr_vrt_40, - ogr_vrt_41, - ogr_vrt_cleanup] + test_ogr_vrt_1, + test_ogr_vrt_2, + test_ogr_vrt_3, + test_ogr_vrt_4, + test_ogr_vrt_5, + test_ogr_vrt_6, + test_ogr_vrt_7, + test_ogr_vrt_8, + test_ogr_vrt_9, + test_ogr_vrt_10, + test_ogr_vrt_11, + test_ogr_vrt_12, + test_ogr_vrt_13, + test_ogr_vrt_14, + test_ogr_vrt_15, + test_ogr_vrt_16, + test_ogr_vrt_17, + test_ogr_vrt_18, + test_ogr_vrt_19_optimized, + test_ogr_vrt_19_nonoptimized, + test_ogr_vrt_20, + test_ogr_vrt_21, + test_ogr_vrt_22, + test_ogr_vrt_23, + test_ogr_vrt_24, + test_ogr_vrt_25, + test_ogr_vrt_26, + test_ogr_vrt_27, + test_ogr_vrt_28, + test_ogr_vrt_29, + test_ogr_vrt_30, + test_ogr_vrt_31, + test_ogr_vrt_32, + test_ogr_vrt_33, + test_ogr_vrt_34, + test_ogr_vrt_35, + test_ogr_vrt_36, + test_ogr_vrt_37, + test_ogr_vrt_38, + test_ogr_vrt_39, + test_ogr_vrt_40, + test_ogr_vrt_41, + test_ogr_vrt_cleanup] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_wasp.py b/autotest/ogr/ogr_wasp.py index 22140cc7247d..df638b5fc87c 100755 --- a/autotest/ogr/ogr_wasp.py +++ b/autotest/ogr/ogr_wasp.py @@ -43,7 +43,7 @@ # Create wasp datasource -def ogr_wasp_create_ds(): +def test_ogr_wasp_create_ds(): wasp_drv = ogr.GetDriverByName('WAsP') wasp_drv.DeleteDataSource('tmp.map') @@ -58,9 +58,9 @@ def ogr_wasp_create_ds(): # Create elevation .map from linestrings z -def ogr_wasp_elevation_from_linestring_z(): +def test_ogr_wasp_elevation_from_linestring_z(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' ref = osr.SpatialReference() @@ -119,9 +119,9 @@ def ogr_wasp_elevation_from_linestring_z(): # Create elevation .map from linestrings z with simplification -def ogr_wasp_elevation_from_linestring_z_toler(): +def test_ogr_wasp_elevation_from_linestring_z_toler(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' ref = osr.SpatialReference() @@ -189,9 +189,9 @@ def ogr_wasp_elevation_from_linestring_z_toler(): ############################################################################### # Create elevation .map from linestrings field -def ogr_wasp_elevation_from_linestring_field(): +def test_ogr_wasp_elevation_from_linestring_field(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' layer = gdaltest.wasp_ds.CreateLayer('mylayer', @@ -244,9 +244,9 @@ def ogr_wasp_elevation_from_linestring_field(): # Create roughness .map from linestrings fields -def ogr_wasp_roughness_from_linestring_fields(): +def test_ogr_wasp_roughness_from_linestring_fields(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' layer = gdaltest.wasp_ds.CreateLayer('mylayer', @@ -307,9 +307,9 @@ def ogr_wasp_roughness_from_linestring_fields(): # Create .map from polygons z -def ogr_wasp_roughness_from_polygon_z(): +def test_ogr_wasp_roughness_from_polygon_z(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' if not ogrtest.have_geos(): @@ -377,9 +377,9 @@ def ogr_wasp_roughness_from_polygon_z(): # Create .map from polygons field -def ogr_wasp_roughness_from_polygon_field(): +def test_ogr_wasp_roughness_from_polygon_field(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' if not ogrtest.have_geos(): @@ -452,9 +452,9 @@ def ogr_wasp_roughness_from_polygon_field(): # a continuing line (pichart map) -def ogr_wasp_merge(): +def test_ogr_wasp_merge(): - if ogr_wasp_create_ds() != 'success': + if test_ogr_wasp_create_ds() != 'success': return 'skip' if not ogrtest.have_geos(): @@ -522,8 +522,8 @@ def ogr_wasp_merge(): # Read map file -def ogr_wasp_reading(): - if ogr_wasp_elevation_from_linestring_z() != 'success': +def test_ogr_wasp_reading(): + if test_ogr_wasp_elevation_from_linestring_z() != 'success': return 'skip' gdaltest.wasp_ds = None @@ -548,7 +548,7 @@ def ogr_wasp_reading(): # Cleanup -def ogr_wasp_cleanup(): +def test_ogr_wasp_cleanup(): wasp_drv = ogr.GetDriverByName('WAsP') wasp_drv.DeleteDataSource('tmp.map') @@ -556,16 +556,16 @@ def ogr_wasp_cleanup(): gdaltest_list = [ - ogr_wasp_create_ds, - ogr_wasp_elevation_from_linestring_z, - ogr_wasp_elevation_from_linestring_z_toler, - ogr_wasp_elevation_from_linestring_field, - ogr_wasp_roughness_from_linestring_fields, - ogr_wasp_roughness_from_polygon_z, - ogr_wasp_roughness_from_polygon_field, - ogr_wasp_merge, - ogr_wasp_reading, - ogr_wasp_cleanup + test_ogr_wasp_create_ds, + test_ogr_wasp_elevation_from_linestring_z, + test_ogr_wasp_elevation_from_linestring_z_toler, + test_ogr_wasp_elevation_from_linestring_field, + test_ogr_wasp_roughness_from_linestring_fields, + test_ogr_wasp_roughness_from_polygon_z, + test_ogr_wasp_roughness_from_polygon_field, + test_ogr_wasp_merge, + test_ogr_wasp_reading, + test_ogr_wasp_cleanup ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_wfs3.py b/autotest/ogr/ogr_wfs3.py index db39eb065b7a..e156ddc6167d 100755 --- a/autotest/ogr/ogr_wfs3.py +++ b/autotest/ogr/ogr_wfs3.py @@ -41,7 +41,7 @@ # -def ogr_wfs3_init(): +def test_ogr_wfs3_init(): gdaltest.wfs3_drv = ogr.GetDriverByName('WFS3') if gdaltest.wfs3_drv is None: @@ -57,7 +57,7 @@ def ogr_wfs3_init(): ############################################################################### -def ogr_wfs3_errors(): +def test_ogr_wfs3_errors(): if gdaltest.wfs3_drv is None: return 'skip' @@ -152,7 +152,7 @@ def ogr_wfs3_errors(): ############################################################################### -def ogr_wfs3_empty_layer(): +def test_ogr_wfs3_empty_layer(): if gdaltest.wfs3_drv is None: return 'skip' @@ -190,7 +190,7 @@ def ogr_wfs3_empty_layer(): ############################################################################### -def ogr_wfs3_fc_links_next_geojson(): +def test_ogr_wfs3_fc_links_next_geojson(): if gdaltest.wfs3_drv is None: return 'skip' @@ -266,7 +266,7 @@ def ogr_wfs3_fc_links_next_geojson(): ############################################################################### -def ogr_wfs3_fc_links_next_headers(): +def test_ogr_wfs3_fc_links_next_headers(): if gdaltest.wfs3_drv is None: return 'skip' @@ -341,7 +341,7 @@ def ogr_wfs3_fc_links_next_headers(): ############################################################################### -def ogr_wfs3_spatial_filter(): +def test_ogr_wfs3_spatial_filter(): if gdaltest.wfs3_drv is None: return 'skip' @@ -425,7 +425,7 @@ def ogr_wfs3_spatial_filter(): ############################################################################### -def ogr_wfs3_get_feature_count(): +def test_ogr_wfs3_get_feature_count(): if gdaltest.wfs3_drv is None: return 'skip' @@ -495,7 +495,7 @@ def ogr_wfs3_get_feature_count(): ############################################################################### -def ogr_wfs3_attribute_filter(): +def test_ogr_wfs3_attribute_filter(): if gdaltest.wfs3_drv is None: return 'skip' @@ -620,7 +620,7 @@ def ogr_wfs3_attribute_filter(): ############################################################################### -def ogr_wfs3_cleanup(): +def test_ogr_wfs3_cleanup(): if gdaltest.wfs3_drv is None: return 'skip' @@ -632,15 +632,15 @@ def ogr_wfs3_cleanup(): gdaltest_list = [ - ogr_wfs3_init, - ogr_wfs3_errors, - ogr_wfs3_empty_layer, - ogr_wfs3_fc_links_next_geojson, - ogr_wfs3_fc_links_next_headers, - ogr_wfs3_spatial_filter, - ogr_wfs3_get_feature_count, - ogr_wfs3_attribute_filter, - ogr_wfs3_cleanup, + test_ogr_wfs3_init, + test_ogr_wfs3_errors, + test_ogr_wfs3_empty_layer, + test_ogr_wfs3_fc_links_next_geojson, + test_ogr_wfs3_fc_links_next_headers, + test_ogr_wfs3_spatial_filter, + test_ogr_wfs3_get_feature_count, + test_ogr_wfs3_attribute_filter, + test_ogr_wfs3_cleanup, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_wkbwkt_geom.py b/autotest/ogr/ogr_wkbwkt_geom.py index 763a70d1ff87..67b737f3c5b3 100755 --- a/autotest/ogr/ogr_wkbwkt_geom.py +++ b/autotest/ogr/ogr_wkbwkt_geom.py @@ -124,7 +124,7 @@ def test_wkbwkt_geom(unit): # Test geometry with very large exponents of coordinate values. -def ogr_wkbwkt_geom_bigexponents(): +def test_ogr_wkbwkt_geom_bigexponents(): bigx = -1.79769313486e+308 bigy = -1.12345678901e+308 @@ -146,7 +146,7 @@ def ogr_wkbwkt_geom_bigexponents(): ############################################################################### # Test importing broken/unhandled WKT. -def ogr_wkbwkt_test_broken_geom(): +def test_ogr_wkbwkt_test_broken_geom(): list_broken = ['POINT', 'POINT UNKNOWN', @@ -387,7 +387,7 @@ def ogr_wkbwkt_test_broken_geom(): # Test importing WKT SF1.2 -def ogr_wkbwkt_test_import_wkt_sf12(): +def test_ogr_wkbwkt_test_import_wkt_sf12(): list_wkt_tuples = [('POINT EMPTY', 'POINT EMPTY'), ('POINT Z EMPTY', 'POINT EMPTY'), @@ -518,7 +518,7 @@ def ogr_wkbwkt_test_import_wkt_sf12(): # doesn't work -def ogr_wkbwkt_test_import_bad_multipoint_wkb(): +def test_ogr_wkbwkt_test_import_bad_multipoint_wkb(): import struct wkb = struct.pack('B' * 30, 0, 0, 0, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0) @@ -534,7 +534,7 @@ def ogr_wkbwkt_test_import_bad_multipoint_wkb(): # Test WKT -> WKB -> WKT roundtripping for GEOMETRYCOLLECTION -def ogr_wkbwkt_test_geometrycollection_wktwkb(): +def test_ogr_wkbwkt_test_geometrycollection_wktwkb(): wkt_list = ['GEOMETRYCOLLECTION (POINT (0 1))', 'GEOMETRYCOLLECTION (LINESTRING (0 1,2 3))', @@ -566,7 +566,7 @@ def ogr_wkbwkt_test_geometrycollection_wktwkb(): # Test that importing too nested WKT doesn't cause stack overflows -def ogr_wkbwkt_test_geometrycollection_wkt_recursion(): +def test_ogr_wkbwkt_test_geometrycollection_wkt_recursion(): wkt = 'GEOMETRYCOLLECTION (' * 31 + 'GEOMETRYCOLLECTION EMPTY' + ')' * 31 @@ -591,7 +591,7 @@ def ogr_wkbwkt_test_geometrycollection_wkt_recursion(): # Test that importing too nested WKB doesn't cause stack overflows -def ogr_wkbwkt_test_geometrycollection_wkb_recursion(): +def test_ogr_wkbwkt_test_geometrycollection_wkb_recursion(): import struct wkb_repeat = struct.pack('B' * 9, 0, 0, 0, 0, 7, 0, 0, 0, 1) @@ -619,7 +619,7 @@ def ogr_wkbwkt_test_geometrycollection_wkb_recursion(): # Test ISO WKT compliant export of MULTIPOINT -def ogr_wkbwkt_export_wkt_iso_multipoint(): +def test_ogr_wkbwkt_export_wkt_iso_multipoint(): wkt = 'MULTIPOINT ((0 0),(1 1))' g = ogr.CreateGeometryFromWkt(wkt) @@ -635,7 +635,7 @@ def ogr_wkbwkt_export_wkt_iso_multipoint(): # Test exporting WKT with non finite values (#6319) -def ogr_wkt_inf_nan(): +def test_ogr_wkt_inf_nan(): g = ogr.Geometry(ogr.wkbPoint) g.AddPoint(float('inf'), float('-inf'), float('nan')) @@ -651,7 +651,7 @@ def ogr_wkt_inf_nan(): # Test corrupted WKT -def ogr_wkt_multicurve_compoundcurve_corrupted(): +def test_ogr_wkt_multicurve_compoundcurve_corrupted(): with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt('MULTICURVE(COMPOUNDCURVE') @@ -664,7 +664,7 @@ def ogr_wkt_multicurve_compoundcurve_corrupted(): # Test corrupted WKT -def ogr_wkt_multipolygon_corrupted(): +def test_ogr_wkt_multipolygon_corrupted(): with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt('MULTIPOLYGON(POLYGON((N') @@ -681,17 +681,17 @@ def ogr_wkt_multipolygon_corrupted(): gdaltest_list = [ - ogr_wkbwkt_geom_bigexponents, - ogr_wkbwkt_test_broken_geom, - ogr_wkbwkt_test_import_wkt_sf12, - ogr_wkbwkt_test_import_bad_multipoint_wkb, - ogr_wkbwkt_test_geometrycollection_wktwkb, - ogr_wkbwkt_test_geometrycollection_wkt_recursion, - ogr_wkbwkt_test_geometrycollection_wkb_recursion, - ogr_wkbwkt_export_wkt_iso_multipoint, - ogr_wkt_inf_nan, - ogr_wkt_multicurve_compoundcurve_corrupted, - ogr_wkt_multipolygon_corrupted, + test_ogr_wkbwkt_geom_bigexponents, + test_ogr_wkbwkt_test_broken_geom, + test_ogr_wkbwkt_test_import_wkt_sf12, + test_ogr_wkbwkt_test_import_bad_multipoint_wkb, + test_ogr_wkbwkt_test_geometrycollection_wktwkb, + test_ogr_wkbwkt_test_geometrycollection_wkt_recursion, + test_ogr_wkbwkt_test_geometrycollection_wkb_recursion, + test_ogr_wkbwkt_export_wkt_iso_multipoint, + test_ogr_wkt_inf_nan, + test_ogr_wkt_multicurve_compoundcurve_corrupted, + test_ogr_wkt_multipolygon_corrupted, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_wktempty.py b/autotest/ogr/ogr_wktempty.py index 4c429cd28122..2313845f3edf 100755 --- a/autotest/ogr/ogr_wktempty.py +++ b/autotest/ogr/ogr_wktempty.py @@ -71,7 +71,7 @@ def test_empty_wkt(test_input, expected): geom.Destroy() -def ogr_wktempty_test_partial_empty_geoms(): +def test_ogr_wktempty_test_partial_empty_geoms(): # Multipoint with a valid point and an empty point wkt = 'MULTIPOINT (1 1)' @@ -150,7 +150,7 @@ def ogr_wktempty_test_partial_empty_geoms(): return 'success' -gdaltest_list = [ogr_wktempty_test_partial_empty_geoms] +gdaltest_list = [test_ogr_wktempty_test_partial_empty_geoms] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_xls.py b/autotest/ogr/ogr_xls.py index 35d33aa5e126..5d83b42f6682 100755 --- a/autotest/ogr/ogr_xls.py +++ b/autotest/ogr/ogr_xls.py @@ -40,7 +40,7 @@ # Basic tests -def ogr_xls_1(): +def test_ogr_xls_1(): drv = ogr.GetDriverByName('XLS') if drv is None: @@ -121,7 +121,7 @@ def ogr_xls_1(): # Test OGR_XLS_HEADERS = DISABLE -def ogr_xls_2(): +def test_ogr_xls_2(): drv = ogr.GetDriverByName('XLS') if drv is None: @@ -145,7 +145,7 @@ def ogr_xls_2(): # Test OGR_XLS_FIELD_TYPES = STRING -def ogr_xls_3(): +def test_ogr_xls_3(): drv = ogr.GetDriverByName('XLS') if drv is None: @@ -168,7 +168,7 @@ def ogr_xls_3(): # Run test_ogrsf -def ogr_xls_4(): +def test_ogr_xls_4(): drv = ogr.GetDriverByName('XLS') if drv is None: @@ -188,10 +188,10 @@ def ogr_xls_4(): gdaltest_list = [ - ogr_xls_1, - ogr_xls_2, - ogr_xls_3, - ogr_xls_4 + test_ogr_xls_1, + test_ogr_xls_2, + test_ogr_xls_3, + test_ogr_xls_4 ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_xlsx.py b/autotest/ogr/ogr_xlsx.py index f6bcc643aaa7..969522eda9cc 100755 --- a/autotest/ogr/ogr_xlsx.py +++ b/autotest/ogr/ogr_xlsx.py @@ -125,7 +125,7 @@ def ogr_xlsx_check(ds): # Basic tests -def ogr_xlsx_1(): +def test_ogr_xlsx_1(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -146,7 +146,7 @@ def ogr_xlsx_1(): # Test OGR_XLSX_HEADERS = DISABLE -def ogr_xlsx_2(): +def test_ogr_xlsx_2(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -170,7 +170,7 @@ def ogr_xlsx_2(): # Test OGR_XLSX_FIELD_TYPES = STRING -def ogr_xlsx_3(): +def test_ogr_xlsx_3(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -193,7 +193,7 @@ def ogr_xlsx_3(): # Run test_ogrsf -def ogr_xlsx_4(): +def test_ogr_xlsx_4(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -215,7 +215,7 @@ def ogr_xlsx_4(): # Test write support -def ogr_xlsx_5(): +def test_ogr_xlsx_5(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -239,7 +239,7 @@ def ogr_xlsx_5(): # Test reading a file using inlineStr representation. -def ogr_xlsx_6(): +def test_ogr_xlsx_6(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -274,7 +274,7 @@ def ogr_xlsx_6(): # Test update support -def ogr_xlsx_7(): +def test_ogr_xlsx_7(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -317,7 +317,7 @@ def ogr_xlsx_7(): # Test number of columns > 26 (#5774) -def ogr_xlsx_8(): +def test_ogr_xlsx_8(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -350,7 +350,7 @@ def ogr_xlsx_8(): # Test Integer64 -def ogr_xlsx_9(): +def test_ogr_xlsx_9(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -391,7 +391,7 @@ def ogr_xlsx_9(): # Test DateTime with milliseconds -def ogr_xlsx_10(): +def test_ogr_xlsx_10(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -439,7 +439,7 @@ def ogr_xlsx_10(): # Test reading sheet with more than 26 columns with holes (#6363)" -def ogr_xlsx_11(): +def test_ogr_xlsx_11(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -461,7 +461,7 @@ def ogr_xlsx_11(): # workbook.xml.rels (#6733) -def ogr_xlsx_12(): +def test_ogr_xlsx_12(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -480,7 +480,7 @@ def ogr_xlsx_12(): # Test that data types are correctly picked up even if first row is missing data -def ogr_xlsx_13(): +def test_ogr_xlsx_13(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -532,7 +532,7 @@ def ogr_xlsx_13(): # Test that field names are picked up even if last field has no data -def ogr_xlsx_14(): +def test_ogr_xlsx_14(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -584,7 +584,7 @@ def ogr_xlsx_14(): # Test appending a layer to an existing document -def ogr_xlsx_15(): +def test_ogr_xlsx_15(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -610,7 +610,7 @@ def ogr_xlsx_15(): # Test Boolean -def ogr_xlsx_boolean(): +def test_ogr_xlsx_boolean(): drv = ogr.GetDriverByName('XLSX') if drv is None: @@ -648,22 +648,22 @@ def ogr_xlsx_boolean(): gdaltest_list = [ - ogr_xlsx_1, - ogr_xlsx_2, - ogr_xlsx_3, - ogr_xlsx_4, - ogr_xlsx_5, - ogr_xlsx_6, - ogr_xlsx_7, - ogr_xlsx_8, - ogr_xlsx_9, - ogr_xlsx_10, - ogr_xlsx_11, - ogr_xlsx_12, - ogr_xlsx_13, - ogr_xlsx_14, - ogr_xlsx_15, - ogr_xlsx_boolean, + test_ogr_xlsx_1, + test_ogr_xlsx_2, + test_ogr_xlsx_3, + test_ogr_xlsx_4, + test_ogr_xlsx_5, + test_ogr_xlsx_6, + test_ogr_xlsx_7, + test_ogr_xlsx_8, + test_ogr_xlsx_9, + test_ogr_xlsx_10, + test_ogr_xlsx_11, + test_ogr_xlsx_12, + test_ogr_xlsx_13, + test_ogr_xlsx_14, + test_ogr_xlsx_15, + test_ogr_xlsx_boolean, ] if __name__ == '__main__': diff --git a/autotest/ogr/ogr_xplane.py b/autotest/ogr/ogr_xplane.py index 3ac8110cd552..d4973edb0d3d 100755 --- a/autotest/ogr/ogr_xplane.py +++ b/autotest/ogr/ogr_xplane.py @@ -38,7 +38,7 @@ # Test apt.dat reading -def ogr_xplane_apt_dat(): +def test_ogr_xplane_apt_dat(): xplane_apt_ds = ogr.Open('data/apt.dat') @@ -84,7 +84,7 @@ def ogr_xplane_apt_dat(): ############################################################################### # Test apt.dat v810 reading -def ogr_xplane_apt_v810_dat(): +def test_ogr_xplane_apt_v810_dat(): xplane_apt_ds = ogr.Open('data/apt810/apt.dat') @@ -130,7 +130,7 @@ def ogr_xplane_apt_v810_dat(): # Test nav.dat reading -def ogr_xplane_nav_dat(): +def test_ogr_xplane_nav_dat(): xplane_nav_ds = ogr.Open('data/nav.dat') @@ -167,7 +167,7 @@ def ogr_xplane_nav_dat(): ############################################################################### # Test awy.dat reading -def ogr_xplane_awy_dat(): +def test_ogr_xplane_awy_dat(): xplane_awy_ds = ogr.Open('data/awy.dat') @@ -197,7 +197,7 @@ def ogr_xplane_awy_dat(): # Test fix.dat reading -def ogr_xplane_fix_dat(): +def test_ogr_xplane_fix_dat(): xplane_fix_ds = ogr.Open('data/fix.dat') @@ -227,11 +227,11 @@ def ogr_xplane_fix_dat(): gdaltest_list = [ - ogr_xplane_apt_dat, - ogr_xplane_apt_v810_dat, - ogr_xplane_nav_dat, - ogr_xplane_awy_dat, - ogr_xplane_fix_dat] + test_ogr_xplane_apt_dat, + test_ogr_xplane_apt_v810_dat, + test_ogr_xplane_nav_dat, + test_ogr_xplane_awy_dat, + test_ogr_xplane_fix_dat] if __name__ == '__main__': diff --git a/autotest/ogr/ograpispy.py b/autotest/ogr/ograpispy.py index 38b440009f8c..d67ca18ca4e8 100755 --- a/autotest/ogr/ograpispy.py +++ b/autotest/ogr/ograpispy.py @@ -45,7 +45,7 @@ # Basic test without snapshoting -def ograpispy_1(): +def test_ograpispy_1(): gdal.SetConfigOption('OGR_API_SPY_FILE', 'tmp/ograpispy_1.py') test_py_scripts.run_py_script('data', 'testograpispy', '') @@ -76,7 +76,7 @@ def ograpispy_1(): # With snapshoting -def ograpispy_2(): +def test_ograpispy_2(): if not ogrtest.has_apispy: return 'skip' @@ -136,7 +136,7 @@ def ograpispy_2(): # -def ograpispy_cleanup(): +def test_ograpispy_cleanup(): gdal.Unlink('tmp/ograpispy_1.py') gdal.Unlink('tmp/ograpispy_2.py') gdal.Unlink('tmp/ograpispy_2.pyc') @@ -155,9 +155,9 @@ def ograpispy_cleanup(): gdaltest_list = [ - ograpispy_1, - ograpispy_2, - ograpispy_cleanup + test_ograpispy_1, + test_ograpispy_2, + test_ograpispy_cleanup ] if __name__ == '__main__': diff --git a/autotest/osr/osr_basic.py b/autotest/osr/osr_basic.py index 6ac462df2090..99108c5a8e46 100755 --- a/autotest/osr/osr_basic.py +++ b/autotest/osr/osr_basic.py @@ -41,7 +41,7 @@ ############################################################################### # Create a UTM WGS84 coordinate system and check various items. -def osr_basic_1(): +def test_osr_basic_1(): utm_srs = osr.SpatialReference() # Southern hemisphere @@ -93,7 +93,7 @@ def osr_basic_1(): # Simple default NAD83 State Plane zone. -def osr_basic_2(): +def test_osr_basic_2(): srs = osr.SpatialReference() srs.SetStatePlane(403, 1) # California III NAD83. @@ -138,7 +138,7 @@ def osr_basic_2(): # NAD83 State Plane zone, but overridden to be in Feet. -def osr_basic_3(): +def test_osr_basic_3(): srs = osr.SpatialReference() @@ -211,7 +211,7 @@ def osr_basic_3(): # Translate a coordinate system with nad shift into to PROJ.4 and back # and verify that the TOWGS84 parameters are preserved. -def osr_basic_4(): +def test_osr_basic_4(): srs = osr.SpatialReference() srs.SetGS(cm=-117.0, fe=100000.0, fn=100000) @@ -239,7 +239,7 @@ def osr_basic_4(): # Test URN support for OGC:CRS84. -def osr_basic_5(): +def test_osr_basic_5(): wkt_1 = osr.GetUserInputAsWKT('urn:ogc:def:crs:OGC:1.3:CRS84') wkt_2 = osr.GetUserInputAsWKT('WGS84') @@ -253,7 +253,7 @@ def osr_basic_5(): # Test URN support for EPSG -def osr_basic_6(): +def test_osr_basic_6(): # Without version wkt_1 = osr.GetUserInputAsWKT('urn:x-ogc:def:crs:EPSG::4326') @@ -286,7 +286,7 @@ def osr_basic_6(): # Test URN support for auto projection. -def osr_basic_7(): +def test_osr_basic_7(): wkt_1 = osr.GetUserInputAsWKT('urn:ogc:def:crs:OGC::AUTO42001:-117:33') wkt_2 = 'PROJCS["UTM Zone 11, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1,AUTHORITY["EPSG","9001"]]]' @@ -302,7 +302,7 @@ def osr_basic_7(): # Test the SetLinearUnitsAndUpdateParameters() method. -def osr_basic_8(): +def test_osr_basic_8(): srs = osr.SpatialReference() @@ -336,7 +336,7 @@ def osr_basic_8(): # Test the Validate() method. -def osr_basic_9(): +def test_osr_basic_9(): srs = osr.SpatialReference() srs.SetFromUserInput("PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6378137,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Mercator_2SP\"],PARAMETER[\"standard_parallel_1\",0],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",0],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs\"]]") @@ -349,7 +349,7 @@ def osr_basic_9(): ############################################################################### # Test the Validate() method on PROJCS with AXIS definition (#2739) -def osr_basic_10(): +def test_osr_basic_10(): srs = osr.SpatialReference() srs.SetFromUserInput("""PROJCS["NAD83(CSRS98) / UTM zone 20N (deprecated)", @@ -385,7 +385,7 @@ def osr_basic_10(): # Test the IsSame() method (and the IsSameGeogCS() method through that) -def osr_basic_11(): +def test_osr_basic_11(): srs1 = osr.SpatialReference() srs1.SetFromUserInput("""PROJCS["NAD83(CSRS98) / UTM zone 20N (deprecated)", @@ -441,7 +441,7 @@ def osr_basic_11(): # Test URN support for OGC:CRS84. -def osr_basic_12(): +def test_osr_basic_12(): wkt_1 = osr.GetUserInputAsWKT('CRS:84') wkt_2 = osr.GetUserInputAsWKT('WGS84') @@ -455,7 +455,7 @@ def osr_basic_12(): # Test GEOCCS lookup in supporting data files. -def osr_basic_13(): +def test_osr_basic_13(): srs = osr.SpatialReference() srs.ImportFromEPSG(4328) @@ -482,7 +482,7 @@ def osr_basic_13(): # Manually setup a simple geocentric/wgs84 srs. -def osr_basic_14(): +def test_osr_basic_14(): srs = osr.SpatialReference() srs.SetGeocCS('My Geocentric') @@ -511,7 +511,7 @@ def osr_basic_14(): # Test validation and fixup methods. -def osr_basic_15(): +def test_osr_basic_15(): wkt = """GEOCCS["WGS 84 (geocentric)", PRIMEM["Greenwich",0, @@ -544,7 +544,7 @@ def osr_basic_15(): # Test OSRSetGeocCS() -def osr_basic_16(): +def test_osr_basic_16(): # Nominal test : change citation of a GEOCCS srs = osr.SpatialReference() @@ -623,7 +623,7 @@ def osr_basic_16(): # Test OGC URL support -def osr_basic_17(): +def test_osr_basic_17(): wkt_1 = osr.GetUserInputAsWKT('urn:ogc:def:crs:EPSG::4326') wkt_2 = osr.GetUserInputAsWKT('http://www.opengis.net/def/crs/EPSG/0/4326') @@ -637,7 +637,7 @@ def osr_basic_17(): # Test OGC URL support for compound CRS -def osr_basic_18(): +def test_osr_basic_18(): # This is a dummy one, but who cares wkt = osr.GetUserInputAsWKT('http://www.opengis.net/def/crs-compound?1=http://www.opengis.net/def/crs/EPSG/0/4326&2=http://www.opengis.net/def/crs/EPSG/0/4326') @@ -652,7 +652,7 @@ def osr_basic_18(): # Test well known GCS names against their corresponding EPSG definitions (#6080) -def osr_basic_19(): +def test_osr_basic_19(): sr = osr.SpatialReference() sr.SetWellKnownGeogCS('WGS84') @@ -708,7 +708,7 @@ def osr_basic_19(): # Test GetAxisName() and GetAxisOrientation() and GetAngularUnitsName() -def osr_basic_20(): +def test_osr_basic_20(): sr = osr.SpatialReference() sr.ImportFromEPSGA(4326) @@ -744,7 +744,7 @@ def osr_basic_20(): # Test IsSame() with equivalent forms of Mercator_1SP and Mercator_2SP -def osr_basic_21(): +def test_osr_basic_21(): wkt1 = """PROJCS["unnamed", GEOGCS["Segara (Jakarta)", @@ -808,7 +808,7 @@ def osr_basic_21(): # Test LCC_2SP -> LCC_1SP -> LCC_2SP -def osr_basic_22(): +def test_osr_basic_22(): sr = osr.SpatialReference() sr.SetFromUserInput("""PROJCS["unnamed", @@ -1005,7 +1005,7 @@ def osr_basic_22(): # Test LCC_1SP -> LCC_2SP -> LCC_1SP -def osr_basic_23(): +def test_osr_basic_23(): sr = osr.SpatialReference() sr.SetFromUserInput("""PROJCS["unnamed", @@ -1073,7 +1073,7 @@ def osr_basic_23(): # Test Mercator_1SP -> Mercator_2SP -> Mercator_1SP -def osr_basic_24(): +def test_osr_basic_24(): sr = osr.SpatialReference() sr.SetFromUserInput("""PROJCS["unnamed", @@ -1131,7 +1131,7 @@ def osr_basic_24(): # Test corner cases of ConvertToOtherProjection() -def osr_basic_25(): +def test_osr_basic_25(): sr = osr.SpatialReference() sr.SetFromUserInput("""GEOGCS["WGS 84", @@ -1443,7 +1443,7 @@ def osr_basic_25(): # Test corner cases of osr.SetGeocCS() -def osr_basic_setgeogcs(): +def test_osr_basic_setgeogcs(): sr = osr.SpatialReference() sr.SetGeogCS(None, None, None, 0, 0, None, 0, None, 0) @@ -1481,32 +1481,32 @@ def osr_basic_setgeogcs(): gdaltest_list = [ - osr_basic_1, - osr_basic_2, - osr_basic_3, - osr_basic_4, - osr_basic_5, - osr_basic_6, - osr_basic_7, - osr_basic_8, - osr_basic_9, - osr_basic_10, - osr_basic_11, - osr_basic_12, - osr_basic_13, - osr_basic_14, - osr_basic_15, - osr_basic_16, - osr_basic_17, - osr_basic_18, - osr_basic_19, - osr_basic_20, - osr_basic_21, - osr_basic_22, - osr_basic_23, - osr_basic_24, - osr_basic_25, - osr_basic_setgeogcs, + test_osr_basic_1, + test_osr_basic_2, + test_osr_basic_3, + test_osr_basic_4, + test_osr_basic_5, + test_osr_basic_6, + test_osr_basic_7, + test_osr_basic_8, + test_osr_basic_9, + test_osr_basic_10, + test_osr_basic_11, + test_osr_basic_12, + test_osr_basic_13, + test_osr_basic_14, + test_osr_basic_15, + test_osr_basic_16, + test_osr_basic_17, + test_osr_basic_18, + test_osr_basic_19, + test_osr_basic_20, + test_osr_basic_21, + test_osr_basic_22, + test_osr_basic_23, + test_osr_basic_24, + test_osr_basic_25, + test_osr_basic_setgeogcs, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_compd.py b/autotest/osr/osr_compd.py index d2d00d82e099..cacdf0a6731c 100755 --- a/autotest/osr/osr_compd.py +++ b/autotest/osr/osr_compd.py @@ -43,7 +43,7 @@ # Test parsing and a few operations on a compound coordinate system. -def osr_compd_1(): +def test_osr_compd_1(): srs = osr.SpatialReference() srs.ImportFromWkt(example_compd_wkt) @@ -87,7 +87,7 @@ def osr_compd_1(): # Test SetFromUserInput() -def osr_compd_2(): +def test_osr_compd_2(): srs = osr.SpatialReference() srs.SetFromUserInput(example_compd_wkt) @@ -106,7 +106,7 @@ def osr_compd_2(): # Test expansion of compound coordinate systems from EPSG definition. -def osr_compd_3(): +def test_osr_compd_3(): srs = osr.SpatialReference() srs.ImportFromEPSG(7401) @@ -161,7 +161,7 @@ def osr_compd_3(): # Test expansion of GCS+VERTCS compound coordinate system. -def osr_compd_4(): +def test_osr_compd_4(): srs = osr.SpatialReference() srs.ImportFromEPSG(7400) @@ -206,7 +206,7 @@ def osr_compd_4(): # expanded properly and converted to PROJ.4 format with the grids. -def osr_compd_5(): +def test_osr_compd_5(): srs = osr.SpatialReference() srs.SetFromUserInput('EPSG:26911+5703') @@ -271,7 +271,7 @@ def osr_compd_5(): # Test conversion from PROJ.4 to WKT including vertical units. -def osr_compd_6(): +def test_osr_compd_6(): if not osr_proj4.have_proj480(): return 'skip' @@ -329,7 +329,7 @@ def osr_compd_6(): # Test SetCompound() -def osr_compd_7(): +def test_osr_compd_7(): srs_horiz = osr.SpatialReference() srs_horiz.ImportFromEPSG(4326) @@ -388,7 +388,7 @@ def osr_compd_7(): # Test ImportFromURN() -def osr_compd_8(): +def test_osr_compd_8(): srs = osr.SpatialReference() srs.SetFromUserInput('urn:ogc:def:crs,crs:EPSG::27700,crs:EPSG::5701') @@ -407,14 +407,14 @@ def osr_compd_8(): gdaltest_list = [ - osr_compd_1, - osr_compd_2, - osr_compd_3, - osr_compd_4, - osr_compd_5, - osr_compd_6, - osr_compd_7, - osr_compd_8, + test_osr_compd_1, + test_osr_compd_2, + test_osr_compd_3, + test_osr_compd_4, + test_osr_compd_5, + test_osr_compd_6, + test_osr_compd_7, + test_osr_compd_8, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_ct.py b/autotest/osr/osr_ct.py index 82b7874206fb..e3bacf72afb7 100755 --- a/autotest/osr/osr_ct.py +++ b/autotest/osr/osr_ct.py @@ -43,7 +43,7 @@ ############################################################################### # Verify that we have PROJ.4 available. -def osr_ct_1(): +def test_osr_ct_1(): gdaltest.have_proj4 = 0 @@ -81,7 +81,7 @@ def osr_ct_1(): # Actually perform a simple LL to UTM conversion. -def osr_ct_2(): +def test_osr_ct_2(): if gdaltest.have_proj4 == 0: return 'skip' @@ -109,7 +109,7 @@ def osr_ct_2(): # geometry which also uses it is deleted. -def osr_ct_3(): +def test_osr_ct_3(): if gdaltest.have_proj4 == 0: return 'skip' @@ -146,7 +146,7 @@ def osr_ct_3(): # Works for both OG and NG bindings -def osr_ct_4(): +def test_osr_ct_4(): if gdaltest.have_proj4 == 0: return 'skip' @@ -176,7 +176,7 @@ def osr_ct_4(): # New in NG bindings (#3020) -def osr_ct_5(): +def test_osr_ct_5(): if gdaltest.have_proj4 == 0: return 'skip' @@ -205,7 +205,7 @@ def osr_ct_5(): # Test osr.CreateCoordinateTransformation() method -def osr_ct_6(): +def test_osr_ct_6(): if gdaltest.have_proj4 == 0: return 'skip' @@ -240,7 +240,7 @@ def osr_ct_6(): # Actually perform a simple Pseudo Mercator to LL conversion. -def osr_ct_7(): +def test_osr_ct_7(): if gdaltest.have_proj4 == 0: return 'skip' @@ -284,7 +284,7 @@ def osr_ct_7(): # Test WebMercator -> WGS84 optimized transform -def osr_ct_8(): +def test_osr_ct_8(): if gdaltest.have_proj4 == 0: return 'skip' @@ -329,7 +329,7 @@ def osr_ct_8(): # Cleanup -def osr_ct_cleanup(): +def test_osr_ct_cleanup(): if gdaltest.have_proj4 == 0: return 'skip' @@ -340,15 +340,15 @@ def osr_ct_cleanup(): gdaltest_list = [ - osr_ct_1, - osr_ct_2, - osr_ct_3, - osr_ct_4, - osr_ct_5, - osr_ct_6, - osr_ct_7, - osr_ct_8, - osr_ct_cleanup, + test_osr_ct_1, + test_osr_ct_2, + test_osr_ct_3, + test_osr_ct_4, + test_osr_ct_5, + test_osr_ct_6, + test_osr_ct_7, + test_osr_ct_8, + test_osr_ct_cleanup, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_epsg.py b/autotest/osr/osr_epsg.py index 59aa99930bae..71948ca9d2c8 100755 --- a/autotest/osr/osr_epsg.py +++ b/autotest/osr/osr_epsg.py @@ -41,7 +41,7 @@ # file with the adjusted central_meridian. -def osr_epsg_1(): +def test_osr_epsg_1(): srs = osr.SpatialReference() srs.ImportFromEPSG(26591) @@ -58,7 +58,7 @@ def osr_epsg_1(): # from gcs.override.csv. -def osr_epsg_2(): +def test_osr_epsg_2(): srs = osr.SpatialReference() srs.ImportFromEPSG(4312) @@ -76,7 +76,7 @@ def osr_epsg_2(): # towgs84 values set properly (#3579) -def osr_epsg_3(): +def test_osr_epsg_3(): for epsg in [3120, 2172, 2173, 2174, 2175, 3333, 3334, 3335, 3329, 3330, 3331, 3332, 3328, 4179]: srs = osr.SpatialReference() @@ -97,7 +97,7 @@ def osr_epsg_3(): # Check that EPSG:4326 is *not* considered as lat/long (#3813) -def osr_epsg_4(): +def test_osr_epsg_4(): srs = osr.SpatialReference() srs.ImportFromEPSG(4326) @@ -116,7 +116,7 @@ def osr_epsg_4(): # Check that EPSGA:4326 is considered as lat/long -def osr_epsg_5(): +def test_osr_epsg_5(): srs = osr.SpatialReference() srs.ImportFromEPSGA(4326) @@ -135,7 +135,7 @@ def osr_epsg_5(): # Test datum shift for OSGB 36 -def osr_epsg_6(): +def test_osr_epsg_6(): srs = osr.SpatialReference() srs.ImportFromEPSG(4277) @@ -151,7 +151,7 @@ def osr_epsg_6(): # Check that EPSG:2193 is *not* considered as N/E -def osr_epsg_7(): +def test_osr_epsg_7(): srs = osr.SpatialReference() srs.ImportFromEPSG(2193) @@ -170,7 +170,7 @@ def osr_epsg_7(): # Check that EPSGA:2193 is considered as N/E -def osr_epsg_8(): +def test_osr_epsg_8(): srs = osr.SpatialReference() srs.ImportFromEPSGA(2193) @@ -189,7 +189,7 @@ def osr_epsg_8(): # Check EPSG:3857 -def osr_epsg_9(): +def test_osr_epsg_9(): srs = osr.SpatialReference() srs.ImportFromEPSG(3857) @@ -209,7 +209,7 @@ def osr_epsg_9(): # Test AutoIdentifyEPSG() on Polar Stereographic -def osr_epsg_10(): +def test_osr_epsg_10(): srs = osr.SpatialReference() srs.SetFromUserInput("""PROJCS["PS WGS84", @@ -285,7 +285,7 @@ def osr_epsg_10(): # Test datum shift for EPSG:2065 (PCS based override) -def osr_epsg_11(): +def test_osr_epsg_11(): srs = osr.SpatialReference() srs.ImportFromEPSG(2065) @@ -302,7 +302,7 @@ def osr_epsg_11(): # different EPSG codes) -def osr_epsg_12(): +def test_osr_epsg_12(): sr1 = osr.SpatialReference() sr1.ImportFromEPSG(3857) @@ -318,7 +318,7 @@ def osr_epsg_12(): # Test FindMatches() -def osr_epsg_13(): +def test_osr_epsg_13(): # One exact match (and test PROJCS) sr = osr.SpatialReference() @@ -442,7 +442,7 @@ def osr_epsg_13(): ############################################################################### -def osr_epsg_gcs_deprecated(): +def test_osr_epsg_gcs_deprecated(): sr = osr.SpatialReference() sr.ImportFromEPSG(4268) @@ -454,7 +454,7 @@ def osr_epsg_gcs_deprecated(): ############################################################################### -def osr_epsg_geoccs_deprecated(): +def test_osr_epsg_geoccs_deprecated(): sr = osr.SpatialReference() sr.ImportFromEPSG(4346) @@ -467,21 +467,21 @@ def osr_epsg_geoccs_deprecated(): gdaltest_list = [ - osr_epsg_1, - osr_epsg_2, - osr_epsg_3, - osr_epsg_4, - osr_epsg_5, - osr_epsg_6, - osr_epsg_7, - osr_epsg_8, - osr_epsg_9, - osr_epsg_10, - osr_epsg_11, - osr_epsg_12, - osr_epsg_13, - osr_epsg_gcs_deprecated, - osr_epsg_geoccs_deprecated, + test_osr_epsg_1, + test_osr_epsg_2, + test_osr_epsg_3, + test_osr_epsg_4, + test_osr_epsg_5, + test_osr_epsg_6, + test_osr_epsg_7, + test_osr_epsg_8, + test_osr_epsg_9, + test_osr_epsg_10, + test_osr_epsg_11, + test_osr_epsg_12, + test_osr_epsg_13, + test_osr_epsg_gcs_deprecated, + test_osr_epsg_geoccs_deprecated, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_erm.py b/autotest/osr/osr_erm.py index c51dfab5db7a..c508202fae93 100755 --- a/autotest/osr/osr_erm.py +++ b/autotest/osr/osr_erm.py @@ -37,7 +37,7 @@ # -def osr_erm_1(): +def test_osr_erm_1(): for sphere_datum in ['SPHERE', 'SPHERE2', 'USSPHERE']: srs = osr.SpatialReference() @@ -56,7 +56,7 @@ def osr_erm_1(): # -def osr_erm_2(): +def test_osr_erm_2(): srs = osr.SpatialReference() if srs.ImportFromERM('EPSG:3395', 'EPSG:3395', 'METRE') != 0 \ @@ -77,8 +77,8 @@ def osr_erm_2(): gdaltest_list = [ - osr_erm_1, - osr_erm_2, + test_osr_erm_1, + test_osr_erm_2, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_esri.py b/autotest/osr/osr_esri.py index f22a15d0f5e6..57da59ed20db 100755 --- a/autotest/osr/osr_esri.py +++ b/autotest/osr/osr_esri.py @@ -49,7 +49,7 @@ # gdal_datum.csv file. -def osr_esri_1(): +def test_osr_esri_1(): srs = osr.SpatialReference() srs.ImportFromEPSG(4202) @@ -80,7 +80,7 @@ def osr_esri_1(): # translating certain GEOGCSes to ESRI format. -def osr_esri_2(): +def test_osr_esri_2(): srs = osr.SpatialReference() srs.SetFromUserInput('+proj=utm +zone=11 +south +datum=WGS84') @@ -103,7 +103,7 @@ def osr_esri_2(): # Verify that Unnamed is changed to Unknown in morphToESRI(). -def osr_esri_3(): +def test_osr_esri_3(): srs = osr.SpatialReference() srs.SetFromUserInput('+proj=mill +datum=WGS84') @@ -121,7 +121,7 @@ def osr_esri_3(): # Verify Polar Stereographic translations work properly OGR to ESRI. -def osr_esri_4(): +def test_osr_esri_4(): srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["PS Test",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",-80.2333],PARAMETER["central_meridian",171],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1]]') @@ -144,7 +144,7 @@ def osr_esri_4(): # Verify Polar Stereographic translations work properly ESRI to OGR. -def osr_esri_5(): +def test_osr_esri_5(): srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["PS Test",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Stereographic_South_Pole"],PARAMETER["standard_parallel_1",-80.2333],PARAMETER["central_meridian",171],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]') @@ -168,7 +168,7 @@ def osr_esri_5(): # per bug 187. -def osr_esri_6(): +def test_osr_esri_6(): srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["Texas Centric Mapping System/Lambert Conformal",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1500000.0],PARAMETER["False_Northing",5000000.0],PARAMETER["Central_Meridian",-100.0],PARAMETER["Standard_Parallel_1",27.5],PARAMETER["Standard_Parallel_2",35.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",18.0],UNIT["Meter",1.0]]') @@ -187,7 +187,7 @@ def osr_esri_6(): # Verify that FEET is treated as US survey feet per bug #1533. -def osr_esri_7(): +def test_osr_esri_7(): prj = ['Projection STATEPLANE', 'Fipszone 903', @@ -238,7 +238,7 @@ def osr_esri_7(): # Verify that handling of numerically specified units (see bug #1533) -def osr_esri_8(): +def test_osr_esri_8(): prj = ['Projection STATEPLANE', 'Fipszone 903', @@ -287,7 +287,7 @@ def osr_esri_8(): # Verify Equidistant Conic handling. -def osr_esri_9(): +def test_osr_esri_9(): srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["edc",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Equidistant_Conic"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["Latitude_Of_Origin",37.5],UNIT["Meter",1.0]]') @@ -320,7 +320,7 @@ def osr_esri_9(): # Verify Plate_Carree handling. -def osr_esri_10(): +def test_osr_esri_10(): srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["Sphere_Plate_Carree",GEOGCS["GCS_Sphere",DATUM["D_Sphere",SPHEROID["Sphere",6371000.0,0.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Plate_Carree"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],UNIT["Meter",1.0]]') @@ -353,7 +353,7 @@ def osr_esri_10(): # Verify arc/info style TM handling. -def osr_esri_11(): +def test_osr_esri_11(): srs = osr.SpatialReference() srs.ImportFromESRI(['Projection TRANSVERSE', @@ -387,7 +387,7 @@ def osr_esri_11(): # Test automatic morphing of ESRI-style LCC WKT prefixed with 'ESRI::' -def osr_esri_12(): +def test_osr_esri_12(): srs = osr.SpatialReference() srs.SetFromUserInput('ESRI::PROJCS["Lambert Conformal Conic",GEOGCS["grs80",DATUM["D_North_American_1983",SPHEROID["Geodetic_Reference_System_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",34.33333333333334],PARAMETER["standard_parallel_2",36.16666666666666],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",609601.22],PARAMETER["false_northing",0],UNIT["Meter",1]]') @@ -420,7 +420,7 @@ def osr_esri_12(): # but read directly from file. -def osr_esri_13(): +def test_osr_esri_13(): srs = osr.SpatialReference() srs.SetFromUserInput('data/lcc_esri.prj') @@ -453,7 +453,7 @@ def osr_esri_13(): # Verify that state plane epsg authority values are not applied if the # linear units are changed for old style .prj files (bug #1697) -def osr_esri_14(): +def test_osr_esri_14(): srs = osr.SpatialReference() srs.ImportFromESRI(['PROJECTION STATEPLANE', @@ -484,7 +484,7 @@ def osr_esri_14(): # of the rectified_grid_angle parameter. -def osr_esri_15(): +def test_osr_esri_15(): srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["Bern_1898_Bern_LV03C",GEOGCS["GCS_Bern_1898_Bern",DATUM["D_Bern_1898",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Bern",7.439583333333333],UNIT["Degree",0.0174532925199433]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Azimuth",90.0],PARAMETER["Longitude_Of_Center",0.0],PARAMETER["Latitude_Of_Center",46.95240555555556],UNIT["Meter",1.0]]') @@ -519,7 +519,7 @@ def osr_esri_15(): # cleanup of parameters. -def osr_esri_16(): +def test_osr_esri_16(): srs = osr.SpatialReference() srs.SetFromUserInput('+proj=eqc +lat_0=0 +lat_ts=-10 +lon_0=2 +x=100000 +y_0=200000 +ellps=sphere') @@ -540,7 +540,7 @@ def osr_esri_16(): ############################################################################### # Test LAEA support (#3017) -def osr_esri_17(): +def test_osr_esri_17(): original = 'PROJCS["ETRS89 / ETRS-LAEA",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["degree",0.01745329251994328]],UNIT["metre",1],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",52],PARAMETER["longitude_of_center",10],PARAMETER["false_easting",4321000],PARAMETER["false_northing",3210000]]' srs = osr.SpatialReference() @@ -574,7 +574,7 @@ def osr_esri_17(): # Test EC morphing. -def osr_esri_18(): +def test_osr_esri_18(): original = """PROJCS["World_Equidistant_Cylindrical", GEOGCS["GCS_WGS_1984", @@ -621,7 +621,7 @@ def osr_esri_18(): # Test spheroid remapping (per #3904) -def osr_esri_19(): +def test_osr_esri_19(): original = """GEOGCS["GCS_South_American_1969",DATUM["D_South_American_1969",SPHEROID["GRS_1967_Truncated",6378160.0,298.25]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]""" @@ -737,7 +737,7 @@ def osr_esri_test(wkt_esri, wkt_ogc, proj4): # Orthographics (#4249) -def osr_esri_20(): +def test_osr_esri_20(): result = 'success' @@ -931,7 +931,7 @@ def osr_esri_test_esri_ogc_esri(ifile, ofile_base, fix_config='NO', check_epsg=F return result -def osr_esri_21(): +def test_osr_esri_21(): # FIXME ? if sys.version_info >= (3, 0, 0): @@ -1116,7 +1116,7 @@ def osr_esri_test_ogc_esri_ogc(ifile, ofile_base, fix_config='NO', check_epsg=Fa # Test EPSG->OGC->ESRI->OGC -def osr_esri_22(): +def test_osr_esri_22(): result = 'success' @@ -1137,7 +1137,7 @@ def osr_esri_22(): # set GDAL_FIX_ESRI_WKT=DATUM (bugs #4378 and #4345), don't expect to fail -def osr_esri_23(): +def test_osr_esri_23(): result = 'success' @@ -1160,7 +1160,7 @@ def osr_esri_23(): # -def osr_esri_24(): +def test_osr_esri_24(): srs = osr.SpatialReference() srs.ImportFromWkt('''PROJCS["Custom", @@ -1189,7 +1189,7 @@ def osr_esri_24(): # -def osr_esri_25(): +def test_osr_esri_25(): srs = osr.SpatialReference() srs.SetFromUserInput( 'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",' @@ -1235,7 +1235,7 @@ def osr_esri_25(): # -def osr_esri_26(): +def test_osr_esri_26(): srs = osr.SpatialReference() srs.SetFromUserInput("""PROJCS["NAD_1983_HARN_WISCRS_Washburn_County_Meters",GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",234086.8682],PARAMETER["False_Northing",188358.6058],PARAMETER["Central_Meridian",-91.78333333333333],PARAMETER["Standard_Parallel_1",45.96121983333334],PARAMETER["Scale_Factor",1.0000475376],PARAMETER["Latitude_Of_Origin",45.96121983333334],UNIT["Meter",1.0]]""") srs.MorphFromESRI() @@ -1250,7 +1250,7 @@ def osr_esri_26(): # Test Mercator_2SP (#4861) -def osr_esri_27(): +def test_osr_esri_27(): esri_wkt = """PROJCS["Batavia_NEIEZ", GEOGCS["GCS_Batavia", @@ -1310,7 +1310,7 @@ def osr_esri_27(): ############################################################################### # Test Mercator_1SP (#4861) -def osr_esri_28(): +def test_osr_esri_28(): ogc_wkt = """PROJCS["Segara (Jakarta) / NEIEZ (deprecated)", GEOGCS["Segara (Jakarta)", @@ -1381,7 +1381,7 @@ def osr_esri_28(): # Test Web Mercator -def osr_esri_29(): +def test_osr_esri_29(): srs = osr.SpatialReference() srs.ImportFromEPSG(3857) @@ -1469,7 +1469,7 @@ def osr_esri_29(): # Verify import of custom ellipsoid -def osr_esri_30(): +def test_osr_esri_30(): prj = ['Projection GEOGRAPHIC', 'Parameters 6370000.0 6370000.0', @@ -1497,7 +1497,7 @@ def osr_esri_30(): # Verify import of old-style Mercator -def osr_esri_31(): +def test_osr_esri_31(): prj = ['Projection MERCATOR', 'Datum WGS84', @@ -1548,7 +1548,7 @@ def osr_esri_31(): # Bad Equidistant Conic -def osr_esri_32(): +def test_osr_esri_32(): # Autofuzz POC from b/65416453 prj = [ 'PROJECTIONLOCA?L_CSw?( EQUIDISTANT_CONIC', @@ -1568,7 +1568,7 @@ def osr_esri_32(): # Test morphing invalid PROJCS WKT does not crash -def osr_esri_33(): +def test_osr_esri_33(): sr = osr.SpatialReference() sr.ImportFromWkt('PROJCS[]') @@ -1582,39 +1582,39 @@ def osr_esri_33(): gdaltest_list = [ - osr_esri_1, - osr_esri_2, - osr_esri_3, - osr_esri_4, - osr_esri_5, - osr_esri_6, - osr_esri_7, - osr_esri_8, - osr_esri_9, - osr_esri_10, - osr_esri_11, - osr_esri_12, - osr_esri_13, - osr_esri_14, - osr_esri_15, - osr_esri_16, - osr_esri_17, - osr_esri_18, - osr_esri_19, - osr_esri_20, - osr_esri_21, - osr_esri_22, - osr_esri_23, - osr_esri_24, - osr_esri_25, - osr_esri_26, - osr_esri_27, - osr_esri_28, - osr_esri_29, - osr_esri_30, - osr_esri_31, - osr_esri_32, - osr_esri_33, + test_osr_esri_1, + test_osr_esri_2, + test_osr_esri_3, + test_osr_esri_4, + test_osr_esri_5, + test_osr_esri_6, + test_osr_esri_7, + test_osr_esri_8, + test_osr_esri_9, + test_osr_esri_10, + test_osr_esri_11, + test_osr_esri_12, + test_osr_esri_13, + test_osr_esri_14, + test_osr_esri_15, + test_osr_esri_16, + test_osr_esri_17, + test_osr_esri_18, + test_osr_esri_19, + test_osr_esri_20, + test_osr_esri_21, + test_osr_esri_22, + test_osr_esri_23, + test_osr_esri_24, + test_osr_esri_25, + test_osr_esri_26, + test_osr_esri_27, + test_osr_esri_28, + test_osr_esri_29, + test_osr_esri_30, + test_osr_esri_31, + test_osr_esri_32, + test_osr_esri_33, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_getprojectionmethods.py b/autotest/osr/osr_getprojectionmethods.py index 52776e4d8a7e..3afe24e76ffe 100755 --- a/autotest/osr/osr_getprojectionmethods.py +++ b/autotest/osr/osr_getprojectionmethods.py @@ -38,7 +38,7 @@ ############################################################################### # Test osr.GetProjectionMethods() -def osr_getprojectionmethods_1(): +def test_osr_getprojectionmethods_1(): methods = osr.GetProjectionMethods() if methods[0][0] != 'Transverse_Mercator': @@ -48,7 +48,7 @@ def osr_getprojectionmethods_1(): gdaltest_list = [ - osr_getprojectionmethods_1, + test_osr_getprojectionmethods_1, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_micoordsys.py b/autotest/osr/osr_micoordsys.py index 507d18ea313a..2cdb84667e57 100755 --- a/autotest/osr/osr_micoordsys.py +++ b/autotest/osr/osr_micoordsys.py @@ -39,7 +39,7 @@ # -def osr_micoordsys_1(): +def test_osr_micoordsys_1(): srs = osr.SpatialReference() srs.ImportFromMICoordSys('Earth Projection 3, 62, "m", -117.474542888889, 33.7644620277778, 33.9036340277778, 33.6252900277778, 0, 0') @@ -61,7 +61,7 @@ def osr_micoordsys_1(): # -def osr_micoordsys_2(): +def test_osr_micoordsys_2(): srs = osr.SpatialReference() srs.ImportFromWkt("""PROJCS["unnamed",GEOGCS["NAD27",\ @@ -91,7 +91,7 @@ def osr_micoordsys_2(): # -def osr_micoordsys_3(): +def test_osr_micoordsys_3(): srs = osr.SpatialReference() srs.ImportFromEPSG(3857) @@ -123,9 +123,9 @@ def osr_micoordsys_3(): gdaltest_list = [ - osr_micoordsys_1, - osr_micoordsys_2, - osr_micoordsys_3] + test_osr_micoordsys_1, + test_osr_micoordsys_2, + test_osr_micoordsys_3] if __name__ == '__main__': diff --git a/autotest/osr/osr_ozi.py b/autotest/osr/osr_ozi.py index 39c48ba60520..3e532ed1ca72 100755 --- a/autotest/osr/osr_ozi.py +++ b/autotest/osr/osr_ozi.py @@ -38,7 +38,7 @@ # Test with WGS 84 datum -def osr_ozi_1(): +def test_osr_ozi_1(): srs = osr.SpatialReference() srs.ImportFromOzi(["OziExplorer Map Data File Version 2.2", @@ -60,7 +60,7 @@ def osr_ozi_1(): # Test with another datum known by OZI and whose EPSG code is known -def osr_ozi_2(): +def test_osr_ozi_2(): srs = osr.SpatialReference() srs.ImportFromOzi(["OziExplorer Map Data File Version 2.2", @@ -83,7 +83,7 @@ def osr_ozi_2(): # Test with another datum known by OZI and whose EPSG code is unknown -def osr_ozi_3(): +def test_osr_ozi_3(): srs = osr.SpatialReference() srs.ImportFromOzi(["OziExplorer Map Data File Version 2.2", @@ -103,9 +103,9 @@ def osr_ozi_3(): gdaltest_list = [ - osr_ozi_1, - osr_ozi_2, - osr_ozi_3, + test_osr_ozi_1, + test_osr_ozi_2, + test_osr_ozi_3, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_pci.py b/autotest/osr/osr_pci.py index 3c62a2b66260..f33d96c663a8 100755 --- a/autotest/osr/osr_pci.py +++ b/autotest/osr/osr_pci.py @@ -36,7 +36,7 @@ # -def osr_pci_1(): +def test_osr_pci_1(): prj_parms = (0.0, 0.0, 45.0, 54.5, 47.0, 62.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) srs = osr.SpatialReference() @@ -71,7 +71,7 @@ def osr_pci_1(): # -def osr_pci_2(): +def test_osr_pci_2(): srs = osr.SpatialReference() srs.ImportFromWkt("""PROJCS["unnamed",GEOGCS["NAD27",\ @@ -104,7 +104,7 @@ def osr_pci_2(): # -def osr_pci_3(): +def test_osr_pci_3(): srs = osr.SpatialReference() srs.ImportFromPCI( @@ -143,7 +143,7 @@ def osr_pci_3(): # -def osr_pci_4(): +def test_osr_pci_4(): prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) @@ -170,7 +170,7 @@ def osr_pci_4(): # -def osr_pci_5(): +def test_osr_pci_5(): prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) @@ -197,7 +197,7 @@ def osr_pci_5(): # -def osr_pci_6(): +def test_osr_pci_6(): prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) @@ -225,7 +225,7 @@ def osr_pci_6(): # -def osr_pci_7(): +def test_osr_pci_7(): srs = osr.SpatialReference() srs.SetFromUserInput('GEOGCS["My GCS",DATUM["My Datum",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[565.04,49.91,465.84,0.4094,-0.3597,1.8685,4.077200000063286]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]') @@ -244,13 +244,13 @@ def osr_pci_7(): gdaltest_list = [ - osr_pci_1, - osr_pci_2, - osr_pci_3, - osr_pci_4, - osr_pci_5, - osr_pci_6, - osr_pci_7, + test_osr_pci_1, + test_osr_pci_2, + test_osr_pci_3, + test_osr_pci_4, + test_osr_pci_5, + test_osr_pci_6, + test_osr_pci_7, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_pm.py b/autotest/osr/osr_pm.py index 90c6679dab25..be6eecfc1732 100755 --- a/autotest/osr/osr_pm.py +++ b/autotest/osr/osr_pm.py @@ -40,7 +40,7 @@ # and the central meridian. -def osr_pm_1(): +def test_osr_pm_1(): srs = osr.SpatialReference() srs.ImportFromEPSG(27572) @@ -60,7 +60,7 @@ def osr_pm_1(): # and the central meridian in the PROJ.4 string. -def osr_pm_2(): +def test_osr_pm_2(): srs = osr.SpatialReference() srs.ImportFromEPSG(27572) @@ -83,7 +83,7 @@ def osr_pm_2(): # are properly preserved. -def osr_pm_3(): +def test_osr_pm_3(): srs = osr.SpatialReference() srs.ImportFromProj4('+proj=utm +zone=30 +datum=WGS84 +pm=bogota') @@ -102,9 +102,9 @@ def osr_pm_3(): ############################################################################### gdaltest_list = [ - osr_pm_1, - osr_pm_2, - osr_pm_3, + test_osr_pm_1, + test_osr_pm_2, + test_osr_pm_3, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_proj4.py b/autotest/osr/osr_proj4.py index 6ccd98cd262f..085371d3271c 100755 --- a/autotest/osr/osr_proj4.py +++ b/autotest/osr/osr_proj4.py @@ -92,7 +92,7 @@ def have_proj480(): # -def osr_proj4_1(): +def test_osr_proj4_1(): srs = osr.SpatialReference() srs.ImportFromProj4('+proj=tmerc +lat_0=53.5000000000 +lon_0=-8.0000000000 +k_0=1.0000350000 +x_0=200000.0000000000 +y_0=250000.0000000000 +a=6377340.189000 +rf=299.324965 +towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15') @@ -109,7 +109,7 @@ def osr_proj4_1(): # -def osr_proj4_2(): +def test_osr_proj4_2(): srs = osr.SpatialReference() srs.ImportFromProj4("+proj=lcc +x_0=0.6096012192024384e+06 +y_0=0 +lon_0=90dw +lat_0=42dn +lat_1=44d4'n +lat_2=42d44'n +a=6378206.400000 +rf=294.978698 +nadgrids=conus,ntv1_can.dat +units=m") @@ -130,7 +130,7 @@ def osr_proj4_2(): # -def osr_proj4_3(): +def test_osr_proj4_3(): srs = osr.SpatialReference() @@ -154,7 +154,7 @@ def osr_proj4_3(): # -def osr_proj4_4(): +def test_osr_proj4_4(): srs = osr.SpatialReference() srs.SetFromUserInput('+proj=utm +zone=11 +datum=WGS84') @@ -179,7 +179,7 @@ def osr_proj4_4(): # -def osr_proj4_5(): +def test_osr_proj4_5(): srs = osr.SpatialReference() @@ -209,7 +209,7 @@ def osr_proj4_5(): # -def osr_proj4_6(): +def test_osr_proj4_6(): expect_proj4 = '+proj=merc +lon_0=0 +lat_ts=46.1333331 +x_0=1000 +y_0=2000 +datum=WGS84 +units=m +no_defs ' @@ -276,7 +276,7 @@ def osr_proj4_6(): # -def osr_proj4_7(): +def test_osr_proj4_7(): srs = osr.SpatialReference() srs.ImportFromEPSG(23700) @@ -321,7 +321,7 @@ def osr_proj4_7(): # Check EPSG:3857, confirm Google Mercator hackery. -def osr_proj4_8(): +def test_osr_proj4_8(): srs = osr.SpatialReference() srs.ImportFromEPSG(3857) @@ -349,7 +349,7 @@ def osr_proj4_8(): # -def osr_proj4_9(): +def test_osr_proj4_9(): srs = osr.SpatialReference() srs.ImportFromEPSG(4267) @@ -377,7 +377,7 @@ def osr_proj4_9(): # -def osr_proj4_10(): +def test_osr_proj4_10(): srs = osr.SpatialReference() srs.ImportFromProj4('+proj=geocent +ellps=WGS84 +towgs84=0,0,0 ') @@ -405,7 +405,7 @@ def osr_proj4_10(): # -def osr_proj4_11(): +def test_osr_proj4_11(): proj4strlist = ['+proj=bonne +lon_0=2 +lat_1=1 +x_0=3 +y_0=4', '+proj=cass +lat_0=1 +lon_0=2 +x_0=3 +y_0=4', @@ -504,7 +504,7 @@ def osr_proj4_11(): # -def osr_proj4_12(): +def test_osr_proj4_12(): expect_wkt = """GEOGCS["WGS 84", DATUM["WGS_1984", @@ -534,7 +534,7 @@ def osr_proj4_12(): # -def osr_proj4_13(): +def test_osr_proj4_13(): proj4strlist = ['', # None, @@ -562,7 +562,7 @@ def osr_proj4_13(): # -def osr_proj4_14(): +def test_osr_proj4_14(): proj4str = '+proj=etmerc +lat_0=0 +lon_0=9 +k=0.9996 +units=m +x_0=500000 +datum=WGS84 +nodefs' @@ -636,7 +636,7 @@ def osr_proj4_14(): # -def osr_proj4_15(): +def test_osr_proj4_15(): srs = osr.SpatialReference() if srs.ImportFromProj4("+init=IGNF:LAMB93") != 0: @@ -659,7 +659,7 @@ def osr_proj4_15(): # -def osr_proj4_16(): +def test_osr_proj4_16(): def almost(a, b): if abs(a - b) > 0.000000000001: @@ -702,7 +702,7 @@ def almost(a, b): # -def osr_proj4_17(): +def test_osr_proj4_17(): units = (('km', 'kilometre'), ('m', 'Meter'), @@ -741,7 +741,7 @@ def osr_proj4_17(): # -def osr_proj4_18(): +def test_osr_proj4_18(): for p in ['no_off', 'no_uoff']: srs = osr.SpatialReference() @@ -765,7 +765,7 @@ def osr_proj4_18(): # Test EXTENSION and AUTHORITY in DATUM -def osr_proj4_19(): +def test_osr_proj4_19(): srs = osr.SpatialReference() srs.ImportFromProj4("+proj=longlat +datum=WGS84 +nadgrids=@null") @@ -786,7 +786,7 @@ def osr_proj4_19(): # Test EXTENSION in GOGCS -def osr_proj4_20(): +def test_osr_proj4_20(): srs = osr.SpatialReference() srs.ImportFromProj4("+proj=longlat +foo=bar +wktext") @@ -808,7 +808,7 @@ def osr_proj4_20(): # Test importing datum other than WGS84, WGS72, NAD27 or NAD83 -def osr_proj4_21(): +def test_osr_proj4_21(): srs = osr.SpatialReference() srs.ImportFromProj4("+proj=longlat +datum=nzgd49") @@ -828,7 +828,7 @@ def osr_proj4_21(): # Test importing ellipsoid defined with +R -def osr_proj4_22(): +def test_osr_proj4_22(): srs = osr.SpatialReference() srs.ImportFromProj4("+proj=longlat +R=1") @@ -845,7 +845,7 @@ def osr_proj4_22(): # Test importing ellipsoid defined with +a and +f -def osr_proj4_23(): +def test_osr_proj4_23(): # +f=0 particular case srs = osr.SpatialReference() @@ -872,7 +872,7 @@ def osr_proj4_23(): # Test importing linear units defined with +to_meter -def osr_proj4_24(): +def test_osr_proj4_24(): srs = osr.SpatialReference() srs.ImportFromProj4("+proj=merc +to_meter=1.0") @@ -919,7 +919,7 @@ def osr_proj4_24(): # Test importing linear units defined with +vto_meter -def osr_proj4_25(): +def test_osr_proj4_25(): if not have_proj480(): return 'skip' @@ -969,7 +969,7 @@ def osr_proj4_25(): # Test importing linear units defined with +vunits -def osr_proj4_26(): +def test_osr_proj4_26(): if not have_proj480(): return 'skip' @@ -1009,7 +1009,7 @@ def osr_proj4_26(): # Test geostationary +sweep (#6030) -def osr_proj4_27(): +def test_osr_proj4_27(): if not have_proj480(): return 'skip' @@ -1029,7 +1029,7 @@ def osr_proj4_27(): # Test importing +init=epsg: with an override -def osr_proj4_28(): +def test_osr_proj4_28(): srs = osr.SpatialReference() srs.ImportFromProj4("+init=epsg:32631 +units=cm") @@ -1043,7 +1043,7 @@ def osr_proj4_28(): return 'success' -def osr_proj4_28_missing_proj_epsg_dict(): +def test_osr_proj4_28_missing_proj_epsg_dict(): python_exe = sys.executable if sys.platform == 'win32': @@ -1056,7 +1056,7 @@ def osr_proj4_28_missing_proj_epsg_dict(): return 'success' -def osr_proj4_error_cases_export_mercator(): +def test_osr_proj4_error_cases_export_mercator(): srs = osr.SpatialReference() @@ -1082,36 +1082,36 @@ def osr_proj4_error_cases_export_mercator(): gdaltest_list = [ - osr_proj4_1, - osr_proj4_2, - osr_proj4_3, - osr_proj4_4, - osr_proj4_5, - osr_proj4_6, - osr_proj4_7, - osr_proj4_8, - osr_proj4_9, - osr_proj4_10, - osr_proj4_11, - osr_proj4_12, - osr_proj4_13, - osr_proj4_14, - osr_proj4_15, - osr_proj4_16, - osr_proj4_17, - osr_proj4_18, - osr_proj4_19, - osr_proj4_20, - osr_proj4_21, - osr_proj4_22, - osr_proj4_23, - osr_proj4_24, - osr_proj4_25, - osr_proj4_26, - osr_proj4_27, - osr_proj4_28, - osr_proj4_28_missing_proj_epsg_dict, - osr_proj4_error_cases_export_mercator, + test_osr_proj4_1, + test_osr_proj4_2, + test_osr_proj4_3, + test_osr_proj4_4, + test_osr_proj4_5, + test_osr_proj4_6, + test_osr_proj4_7, + test_osr_proj4_8, + test_osr_proj4_9, + test_osr_proj4_10, + test_osr_proj4_11, + test_osr_proj4_12, + test_osr_proj4_13, + test_osr_proj4_14, + test_osr_proj4_15, + test_osr_proj4_16, + test_osr_proj4_17, + test_osr_proj4_18, + test_osr_proj4_19, + test_osr_proj4_20, + test_osr_proj4_21, + test_osr_proj4_22, + test_osr_proj4_23, + test_osr_proj4_24, + test_osr_proj4_25, + test_osr_proj4_26, + test_osr_proj4_27, + test_osr_proj4_28, + test_osr_proj4_28_missing_proj_epsg_dict, + test_osr_proj4_error_cases_export_mercator, ] @@ -1119,7 +1119,7 @@ def osr_proj4_error_cases_export_mercator(): if len(sys.argv) == 2 and sys.argv[1] == "osr_proj4_28": os.putenv('PROJ_LIB', '/i/dont_exist') - gdaltest.run_tests([osr_proj4_28]) + gdaltest.run_tests([test_osr_proj4_28]) sys.exit(0) gdaltest.setup_run('osr_proj4') diff --git a/autotest/osr/osr_url.py b/autotest/osr/osr_url.py index 486820ec9648..18650444ca10 100755 --- a/autotest/osr/osr_url.py +++ b/autotest/osr/osr_url.py @@ -73,17 +73,17 @@ def osr_url_test(url, expected_wkt): return 'success' -def osr_url_1(): +def test_osr_url_1(): return osr_url_test('http://spatialreference.org/ref/epsg/4326/', expected_wkt) -def osr_url_2(): +def test_osr_url_2(): return osr_url_test('http://spatialreference.org/ref/epsg/4326/ogcwkt/', expected_wkt) gdaltest_list = [ - osr_url_1, - osr_url_2, + test_osr_url_1, + test_osr_url_2, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_usgs.py b/autotest/osr/osr_usgs.py index d564d2e85fe2..945df77a75d0 100755 --- a/autotest/osr/osr_usgs.py +++ b/autotest/osr/osr_usgs.py @@ -40,7 +40,7 @@ # -def osr_usgs_1(): +def test_osr_usgs_1(): srs = osr.SpatialReference() srs.ImportFromUSGS( @@ -67,7 +67,7 @@ def osr_usgs_1(): # -def osr_usgs_2(): +def test_osr_usgs_2(): srs = osr.SpatialReference() srs.ImportFromWkt("""PROJCS["unnamed",GEOGCS["NAD27",\ @@ -97,8 +97,8 @@ def osr_usgs_2(): gdaltest_list = [ - osr_usgs_1, - osr_usgs_2, + test_osr_usgs_1, + test_osr_usgs_2, None] if __name__ == '__main__': diff --git a/autotest/osr/osr_validate.py b/autotest/osr/osr_validate.py index 2923b6a13061..8c70bed7bd9a 100755 --- a/autotest/osr/osr_validate.py +++ b/autotest/osr/osr_validate.py @@ -39,7 +39,7 @@ # No root pointer -def osr_validate_1(): +def test_osr_validate_1(): empty_srs = osr.SpatialReference() if empty_srs.Validate() == 0: @@ -51,7 +51,7 @@ def osr_validate_1(): # Unrecognized root node -def osr_validate_2(): +def test_osr_validate_2(): srs = osr.SpatialReference() srs.ImportFromWkt("FOO[]") @@ -64,7 +64,7 @@ def osr_validate_2(): # COMPD_CS errors -def osr_validate_3(): +def test_osr_validate_3(): # No DATUM child in GEOGCS srs = osr.SpatialReference() @@ -96,7 +96,7 @@ def osr_validate_3(): # VERT_CS errors -def osr_validate_4(): +def test_osr_validate_4(): # Invalid number of children : 1 srs = osr.SpatialReference() @@ -152,7 +152,7 @@ def osr_validate_4(): # GEOCCS errors -def osr_validate_5(): +def test_osr_validate_5(): # srs.ImportFromWkt('GEOCCS["My Geocentric",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["meter",1]]') @@ -216,7 +216,7 @@ def osr_validate_5(): # PROJCS errors -def osr_validate_6(): +def test_osr_validate_6(): # srs.ImportFromWkt('PROJCS["WGS 84 / UTM zone 31N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32631"]]') @@ -298,12 +298,12 @@ def osr_validate_6(): gdaltest_list = [ - osr_validate_1, - osr_validate_2, - osr_validate_3, - osr_validate_4, - osr_validate_5, - osr_validate_6] + test_osr_validate_1, + test_osr_validate_2, + test_osr_validate_3, + test_osr_validate_4, + test_osr_validate_5, + test_osr_validate_6] if __name__ == '__main__': diff --git a/autotest/osr/osr_xml.py b/autotest/osr/osr_xml.py index e3e353342f4e..d767f5ee20b0 100755 --- a/autotest/osr/osr_xml.py +++ b/autotest/osr/osr_xml.py @@ -41,7 +41,7 @@ # -def osr_xml_1(): +def test_osr_xml_1(): gdaltest.srs_xml = """ WGS 84 / UTM zone 31N @@ -191,7 +191,7 @@ def osr_xml_1(): # -def osr_xml_2(): +def test_osr_xml_2(): srs = osr.SpatialReference() srs.ImportFromWkt(gdaltest.srs_wkt) @@ -212,8 +212,8 @@ def osr_xml_2(): gdaltest_list = [ - osr_xml_1, - osr_xml_2] + test_osr_xml_1, + test_osr_xml_2] if __name__ == '__main__': From 1a5aa2785201653d7b53c914255b33c174c60a91 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Mon, 10 Dec 2018 09:21:37 +1300 Subject: [PATCH 136/488] Automated: Don't expect 'success' from test helpers Helpers are about to raise exceptions for skip/fail events, rather than returning a value. --- autotest/gcore/hdf4_read.py | 14 ---- autotest/gdrivers/aigrid.py | 2 - autotest/gdrivers/bag.py | 2 - autotest/gdrivers/ecw.py | 12 ++-- autotest/gdrivers/ers.py | 3 +- autotest/gdrivers/gif.py | 3 +- autotest/gdrivers/gpkg.py | 84 ++++++++---------------- autotest/gdrivers/ignfheightasciigrid.py | 3 +- autotest/gdrivers/ingr.py | 2 - autotest/gdrivers/isis.py | 22 ------- autotest/gdrivers/jp2lura.py | 15 ++--- autotest/gdrivers/jp2openjpeg.py | 15 ++--- autotest/gdrivers/jpeg2000.py | 15 ++--- autotest/gdrivers/kea.py | 4 -- autotest/gdrivers/mrsid.py | 15 ++--- autotest/gdrivers/netcdf.py | 28 -------- autotest/gdrivers/nitf.py | 18 ++--- autotest/gdrivers/pds.py | 12 +--- autotest/gdrivers/rmf.py | 20 ++---- autotest/gdrivers/rraster.py | 2 - autotest/gdrivers/saga.py | 4 -- autotest/gdrivers/sdts.py | 5 +- autotest/gdrivers/srp.py | 2 - autotest/gdrivers/vicar.py | 4 +- autotest/ogr/ogr_bna.py | 7 +- autotest/ogr/ogr_georss.py | 9 +-- autotest/ogr/ogr_gml_read.py | 19 ++---- autotest/ogr/ogr_index_test.py | 10 --- autotest/ogr/ogr_mitab.py | 9 +-- autotest/ogr/ogr_pg.py | 17 +---- autotest/ogr/ogr_rfc35_mem.py | 44 ------------- autotest/ogr/ogr_rfc35_mitab.py | 10 --- autotest/ogr/ogr_rfc35_shape.py | 58 ---------------- autotest/ogr/ogr_rfc35_sqlite.py | 64 ------------------ autotest/ogr/ogr_s57.py | 15 ++--- autotest/ogr/ogr_selafin.py | 3 +- autotest/ogr/ogr_shape.py | 26 -------- autotest/ogr/ogr_shape_sbn.py | 2 - autotest/ogr/ogr_sql_sqlite.py | 6 -- autotest/ogr/ogr_vrt.py | 2 - autotest/ogr/ogr_wasp.py | 24 +++---- autotest/osr/osr_metacrs.py | 2 - autotest/pyscripts/test_gdal_ls_py.py | 18 ----- 43 files changed, 97 insertions(+), 554 deletions(-) diff --git a/autotest/gcore/hdf4_read.py b/autotest/gcore/hdf4_read.py index cb52da4dc9b3..22ba75316ea7 100755 --- a/autotest/gcore/hdf4_read.py +++ b/autotest/gcore/hdf4_read.py @@ -97,8 +97,6 @@ def test_hdf4_read_online_2(): tst = gdaltest.GDALTest('HDF4Image', 'HDF4_SDS:UNKNOWN:"tmp/cache/A2006005182000.L2_LAC_SST.x.hdf":13', 1, 13209, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('HDF4_SDS:UNKNOWN:"tmp/cache/A2006005182000.L2_LAC_SST.x.hdf":13') md = ds.GetMetadata('GEOLOCATION') @@ -125,8 +123,6 @@ def test_hdf4_read_online_3(): tst = gdaltest.GDALTest('HDF4Image', 'tmp/cache/MO36MW14.chlor_MODIS.ADD2001089.004.2002186190207.hdf', 1, 34723, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('tmp/cache/MO36MW14.chlor_MODIS.ADD2001089.004.2002186190207.hdf') gt = ds.GetGeoTransform() @@ -161,8 +157,6 @@ def test_hdf4_read_online_4(): tst = gdaltest.GDALTest('HDF4Image', 'tmp/cache/S2002196124536.L1A_HDUN.BartonBendish.extract.hdf', 1, 33112, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('tmp/cache/S2002196124536.L1A_HDUN.BartonBendish.extract.hdf') if ds.RasterCount != 8: @@ -189,8 +183,6 @@ def test_hdf4_read_online_5(): tst = gdaltest.GDALTest('HDF4Image', 'tmp/cache/199101.s04m1pfv50-sst-16b.hdf', 1, 41173, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret return 'success' @@ -211,8 +203,6 @@ def test_hdf4_read_online_6(): tst = gdaltest.GDALTest('HDF4Image', 'HDF4_EOS:EOS_GRID:"tmp/cache/MOD09Q1G_EVI.A2006233.h07v03.005.2008338190308.hdf":"MODIS_NACP_EVI":"MODIS_EVI"', 1, 12197, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('HDF4_EOS:EOS_GRID:tmp/cache/MOD09Q1G_EVI.A2006233.h07v03.005.2008338190308.hdf:MODIS_NACP_EVI:MODIS_EVI') @@ -248,8 +238,6 @@ def test_hdf4_read_online_7(): tst = gdaltest.GDALTest('HDF4Image', 'HDF4_EOS:EOS_GRID:tmp/cache/MOD09A1.A2010041.h06v03.005.2010051001103.hdf:MOD_Grid_500m_Surface_Reflectance:sur_refl_b01', 1, 54894, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('HDF4_EOS:EOS_GRID:tmp/cache/MOD09A1.A2010041.h06v03.005.2010051001103.hdf:MOD_Grid_500m_Surface_Reflectance:sur_refl_b01') @@ -286,8 +274,6 @@ def test_hdf4_read_online_8(): tst = gdaltest.GDALTest('HDF4Image', 'HDF4_EOS:EOS_GRID:tmp/cache/MOD13Q1.A2006161.h21v13.005.2008234103220.hdf:MODIS_Grid_16DAY_250m_500m_VI:250m 16 days NDVI', 1, 53837, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('HDF4_EOS:EOS_GRID:tmp/cache/MOD13Q1.A2006161.h21v13.005.2008234103220.hdf:MODIS_Grid_16DAY_250m_500m_VI:250m 16 days NDVI') diff --git a/autotest/gdrivers/aigrid.py b/autotest/gdrivers/aigrid.py index 09ce6c564407..ba7bbbbe41fd 100755 --- a/autotest/gdrivers/aigrid.py +++ b/autotest/gdrivers/aigrid.py @@ -181,8 +181,6 @@ def test_aigrid_online_1(): tst = gdaltest.GDALTest('AIG', 'tmp/cache/nzdem/nzdem500/hdr.adf', 1, 45334, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('tmp/cache/nzdem/nzdem500/hdr.adf') diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index 982455194738..cbc4878692e4 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -843,8 +843,6 @@ def test_bag_write_two_bands(): ret = tst.testCreateCopy(quiet_error_handler=False, delete_copy=False, new_filename='/vsimem/out.bag') - if ret != 'success': - return ret ds = gdal.Open('/vsimem/out.bag') xml = ds.GetMetadata_List('xml:BAG')[0] diff --git a/autotest/gdrivers/ecw.py b/autotest/gdrivers/ecw.py index 8e7a8801456d..4f932e51536a 100755 --- a/autotest/gdrivers/ecw.py +++ b/autotest/gdrivers/ecw.py @@ -2173,8 +2173,7 @@ def test_ecw_online_1(): # checksum = 32316 on my PC tst = gdaltest.GDALTest('JP2ECW', 'tmp/cache/7sisters200.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/7sisters200.j2k') ds.GetRasterBand(1).Checksum() @@ -2195,8 +2194,7 @@ def test_ecw_online_2(): # checksum = 1292 on my PC tst = gdaltest.GDALTest('JP2ECW', 'tmp/cache/gcp.jp2', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/gcp.jp2') ds.GetRasterBand(1).Checksum() @@ -2231,8 +2229,7 @@ def ecw_online_3(): # checksum = 16481 on my PC tst = gdaltest.GDALTest('JP2ECW', 'tmp/cache/Bretagne1.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne1.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne1.bmp') @@ -2270,8 +2267,7 @@ def test_ecw_online_4(): # Checksum = 53054 on my PC tst = gdaltest.GDALTest('JP2ECW', 'tmp/cache/Bretagne2.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne2.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne2.bmp') diff --git a/autotest/gdrivers/ers.py b/autotest/gdrivers/ers.py index 799df323a44c..1b699b344be2 100755 --- a/autotest/gdrivers/ers.py +++ b/autotest/gdrivers/ers.py @@ -44,8 +44,7 @@ def test_ers_1(): tst = gdaltest.GDALTest('ERS', 'srtm.ers', 1, 64074) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('data/srtm.ers') md = ds.GetRasterBand(1).GetMetadata() expected_md = {'STATISTICS_MEAN': '-4020.25', 'STATISTICS_MINIMUM': '-4315', 'STATISTICS_MAXIMUM': '-3744', 'STATISTICS_MEDIAN': '-4000'} diff --git a/autotest/gdrivers/gif.py b/autotest/gdrivers/gif.py index 10c379ab38bc..f30b02d82a83 100755 --- a/autotest/gdrivers/gif.py +++ b/autotest/gdrivers/gif.py @@ -171,8 +171,7 @@ def test_gif_7(): tst = gdaltest.GDALTest('BIGGIF', 'bug407.gif', 1, 57921) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('data/bug407.gif') if ds is None: diff --git a/autotest/gdrivers/gpkg.py b/autotest/gdrivers/gpkg.py index 8ec3494198ed..c823855a5572 100755 --- a/autotest/gdrivers/gpkg.py +++ b/autotest/gdrivers/gpkg.py @@ -249,8 +249,7 @@ def test_gpkg_1(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'PNG', 2, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 2, False) # Check that there's no extensions out_ds = gdal.Open('/vsimem/tmp.gpkg') @@ -307,8 +306,7 @@ def test_gpkg_1(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, False) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -344,8 +342,7 @@ def test_gpkg_2(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'JPEG', 1, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'JPEG', 1, False) # Check that there's no extensions out_ds = gdal.Open('/vsimem/tmp.gpkg') @@ -380,8 +377,7 @@ def test_gpkg_2(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'JPEG', 1, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'JPEG', 1, False) # Try deregistering JPEG driver gdaltest.jpeg_dr.Deregister() @@ -463,8 +459,7 @@ def test_gpkg_3(): expected_band_count = 4 else: expected_band_count = 3 - if check_tile_format(out_ds, 'WEBP', expected_band_count, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'WEBP', expected_band_count, False) out_ds = None @@ -491,8 +486,7 @@ def test_gpkg_3(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'WEBP', 3, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'WEBP', 3, False) # Try deregistering WEBP driver gdaltest.webp_dr.Deregister() @@ -584,8 +578,7 @@ def test_gpkg_4(tile_drv_name='PNG'): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, tile_drv_name, working_bands, False) != 'success': - return 'fail' + check_tile_format(out_ds, tile_drv_name, working_bands, False) out_ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) @@ -611,8 +604,7 @@ def test_gpkg_4(tile_drv_name='PNG'): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, tile_drv_name, 3, False) != 'success': - return 'fail' + check_tile_format(out_ds, tile_drv_name, 3, False) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -689,8 +681,7 @@ def test_gpkg_7(tile_drv_name='PNG'): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, tile_drv_name, working_bands, False) != 'success': - return 'fail' + check_tile_format(out_ds, tile_drv_name, working_bands, False) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -710,8 +701,7 @@ def test_gpkg_7(tile_drv_name='PNG'): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, tile_drv_name, 3, False) != 'success': - return 'fail' + check_tile_format(out_ds, tile_drv_name, 3, False) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -731,8 +721,7 @@ def test_gpkg_7(tile_drv_name='PNG'): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, None, None, None) != 'success': - return 'fail' + check_tile_format(out_ds, None, None, None) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -801,8 +790,7 @@ def test_gpkg_10(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, True) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, True) got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: gdaltest.post_reason('fail') @@ -879,8 +867,7 @@ def test_gpkg_10(): gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' - if check_tile_format(out_ds, 'PNG', 4, False) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 4, False) got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: gdaltest.post_reason('fail') @@ -1677,8 +1664,7 @@ def test_gpkg_17(): gdaltest.post_reason('fail') print(got_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, False, zoom_level=0) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, False, zoom_level=0) if out_ds.GetRasterBand(1).GetOverview(0).GetColorTable() is not None: gdaltest.post_reason('fail') return 'fail' @@ -1701,8 +1687,7 @@ def test_gpkg_17(): gdaltest.post_reason('fail') print(got_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, False, zoom_level=0) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, False, zoom_level=0) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -1722,8 +1707,7 @@ def test_gpkg_17(): gdaltest.post_reason('fail') print(got_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 3, False, zoom_level=0) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 3, False, zoom_level=0) # Check that there's no extensions out_ds = gdal.Open('/vsimem/tmp.gpkg') @@ -1856,10 +1840,8 @@ def test_gpkg_18(): print(got_cs) print(expected_cs_ov1) return 'fail' - if check_tile_format(out_ds, 'PNG', 3, False, zoom_level=1) != 'success': - return 'fail' - if check_tile_format(out_ds, 'PNG', 4, False, zoom_level=0) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 3, False, zoom_level=1) + check_tile_format(out_ds, 'PNG', 4, False, zoom_level=0) out_ds = None # Test gpkg_zoom_other extension @@ -2013,10 +1995,8 @@ def test_gpkg_19(): print(got_cs) print(expected_cs_ov1) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, True, zoom_level=1) != 'success': - return 'fail' - if check_tile_format(out_ds, 'PNG', 4, False, zoom_level=0) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, True, zoom_level=1) + check_tile_format(out_ds, 'PNG', 4, False, zoom_level=0) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -2049,8 +2029,7 @@ def test_gpkg_20(): print(got_cs) print(expected_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, True) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, True) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -2068,8 +2047,7 @@ def test_gpkg_20(): print(got_cs) print(expected_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, True) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, True) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -2087,10 +2065,8 @@ def test_gpkg_20(): print(got_cs) print(expected_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, True) != 'success': - return 'fail' - if check_tile_format(out_ds, 'PNG', 4, False, row=0, col=2) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, True) + check_tile_format(out_ds, 'PNG', 4, False, row=0, col=2) out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -2113,8 +2089,7 @@ def test_gpkg_20(): print(got_cs) print(expected_cs) return 'fail' - if check_tile_format(out_ds, 'PNG', 1, True) != 'success': - return 'fail' + check_tile_format(out_ds, 'PNG', 1, True) out_ds = None out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_RASTER, open_options=['BAND_COUNT=1']) if out_ds.GetRasterBand(1).GetColorTable().GetCount() != 1: @@ -2801,8 +2776,7 @@ def test_gpkg_31(): gdal.SetConfigOption('GPKG_PNG_SUPPORTS_2BANDS', None) ds = gdal.Open('/vsimem/tmp.gpkg') - if check_tile_format(ds, 'PNG', 4, False) != 'success': - return 'fail' + check_tile_format(ds, 'PNG', 4, False) expected_cs = [4672, 4672, 4672, 4873] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: @@ -2832,8 +2806,7 @@ def test_gpkg_32(): gdal.SetConfigOption('GPKG_PNG_SUPPORTS_2BANDS', None) ds = gdal.Open('/vsimem/tmp.gpkg') - if check_tile_format(ds, 'PNG', 4, False) != 'success': - return 'fail' + check_tile_format(ds, 'PNG', 4, False) expected_cs = [1970, 1970, 1970, 10807] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != expected_cs: @@ -2873,8 +2846,7 @@ def test_gpkg_33(): gdal.Unlink(src_ds.GetDescription()) ds = gdal.Open('/vsimem/tmp.gpkg') - if check_tile_format(ds, 'PNG', 4, False) != 'success': - return 'fail' + check_tile_format(ds, 'PNG', 4, False) expected_cs = [10991, 57677, 34965, 10638] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: diff --git a/autotest/gdrivers/ignfheightasciigrid.py b/autotest/gdrivers/ignfheightasciigrid.py index afe0b67d31b8..386b38965d59 100755 --- a/autotest/gdrivers/ignfheightasciigrid.py +++ b/autotest/gdrivers/ignfheightasciigrid.py @@ -181,8 +181,7 @@ def test_ignfheightasciigrid_gra(): tst = gdaltest.GDALTest( 'IGNFHeightASCIIGrid', 'ignfheightasciigrid.gra', 1, 21) gt = (-152.125, 0.25, 0.0, -16.375, 0.0, -0.25) - if tst.testOpen(check_gt=gt, check_prj='WGS84') != 'success': - return 'fail' + tst.testOpen(check_gt=gt, check_prj='WGS84') ds = gdal.OpenEx('data/ignfheightasciigrid.gra', gdal.OF_RASTER) if ds.GetRasterBand(1).GetNoDataValue() != 9999: diff --git a/autotest/gdrivers/ingr.py b/autotest/gdrivers/ingr.py index 5407420332a0..d2ad420dfd66 100755 --- a/autotest/gdrivers/ingr.py +++ b/autotest/gdrivers/ingr.py @@ -63,8 +63,6 @@ def test_ingr_3(): tst = gdaltest.GDALTest('INGR', '8bit_pal.cot', 1, 4855) result = tst.testOpen() - if result != 'success': - return result ds = gdal.Open('data/8bit_pal.cot') ct = ds.GetRasterBand(1).GetRasterColorTable() diff --git a/autotest/gdrivers/isis.py b/autotest/gdrivers/isis.py index 5887ffdf8df2..f7308f9d1de0 100755 --- a/autotest/gdrivers/isis.py +++ b/autotest/gdrivers/isis.py @@ -118,8 +118,6 @@ def test_isis_4(): tst = gdaltest.GDALTest('ISIS3', 'isis3_detached.lbl', 1, 9978) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds.GetMetadataDomainList() != ['', 'json:ISIS3']: gdaltest.post_reason('fail') @@ -151,8 +149,6 @@ def test_isis_4(): options=['USE_SRC_MAPPING=YES']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('PositiveWest') < 0: @@ -174,8 +170,6 @@ def test_isis_4(): 'TARGET_NAME=my_label']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('PositiveEast') < 0: @@ -205,8 +199,6 @@ def test_isis_5(): 'WRITE_BOUNDING_DEGREES=NO']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret if gdal.VSIStatL('/vsimem/isis_tmp.cub') is not None: gdaltest.post_reason('fail') return 'fail' @@ -231,8 +223,6 @@ def test_isis_6(): 'COMMENT=my comment']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret if gdal.VSIStatL('/vsimem/isis_tmp.cub') is None: gdaltest.post_reason('fail') return 'fail' @@ -267,8 +257,6 @@ def test_isis_7(): 'USE_SRC_LABEL=NO']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret if gdal.VSIStatL('/vsimem/isis_tmp.tif') is None: gdaltest.post_reason('fail') return 'fail' @@ -288,8 +276,6 @@ def test_isis_7(): 'USE_SRC_LABEL=NO']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret if gdal.VSIStatL('/vsimem/isis_tmp.tif') is None: gdaltest.post_reason('fail') return 'fail' @@ -315,8 +301,6 @@ def test_isis_8(): 'GEOTIFF_OPTIONS=COMPRESS=LZW']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret if gdal.VSIStatL('/vsimem/isis_tmp.tif') is None: gdaltest.post_reason('fail') return 'fail' @@ -350,8 +334,6 @@ def test_isis_9(): 'EXTERNAL_FILENAME=/vsimem/foo.bin']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret if gdal.VSIStatL('/vsimem/foo.bin') is None: gdaltest.post_reason('fail') return 'fail' @@ -382,8 +364,6 @@ def test_isis_10(): 'EXTERNAL_FILENAME=/vsimem/foo.tif']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret ds = gdal.Open('/vsimem/foo.tif') if ds.GetRasterBand(1).GetBlockSize() != [16, 32]: gdaltest.post_reason('fail') @@ -408,8 +388,6 @@ def test_isis_11(): 'GEOTIFF_OPTIONS=COMPRESS=LZW']) ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) - if ret != 'success': - return ret ds = gdal.Open('/vsimem/isis_tmp.tif') if ds.GetRasterBand(1).GetBlockSize() != [256, 256]: gdaltest.post_reason('fail') diff --git a/autotest/gdrivers/jp2lura.py b/autotest/gdrivers/jp2lura.py index a584baf4295c..ecf612136efd 100755 --- a/autotest/gdrivers/jp2lura.py +++ b/autotest/gdrivers/jp2lura.py @@ -315,8 +315,7 @@ def test_jp2lura_6(): tst = gdaltest.GDALTest('JP2Lura', 'll.jp2', 1, None) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('data/ll.jp2') ds.GetRasterBand(1).Checksum() @@ -1935,8 +1934,7 @@ def test_jp2lura_online_1(): # Checksum = 32669 on my PC tst = gdaltest.GDALTest('JP2Lura', 'tmp/cache/7sisters200.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/7sisters200.j2k') ds.GetRasterBand(1).Checksum() @@ -1958,8 +1956,7 @@ def test_jp2lura_online_2(): # Checksum = 15621 on my PC tst = gdaltest.GDALTest('JP2Lura', 'tmp/cache/gcp.jp2', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/gcp.jp2') ds.GetRasterBand(1).Checksum() @@ -1991,8 +1988,7 @@ def test_jp2lura_online_3(): tst = gdaltest.GDALTest('JP2Lura', 'tmp/cache/Bretagne1.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne1.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne1.bmp') @@ -2025,8 +2021,7 @@ def test_jp2lura_online_4(): tst = gdaltest.GDALTest('JP2Lura', 'tmp/cache/Bretagne2.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'expected_fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne2.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne2.bmp') diff --git a/autotest/gdrivers/jp2openjpeg.py b/autotest/gdrivers/jp2openjpeg.py index b0e931fe03a9..29ace11c0e6e 100755 --- a/autotest/gdrivers/jp2openjpeg.py +++ b/autotest/gdrivers/jp2openjpeg.py @@ -219,8 +219,7 @@ def test_jp2openjpeg_6(): tst = gdaltest.GDALTest('JP2OpenJPEG', 'll.jp2', 1, None) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('data/ll.jp2') ds.GetRasterBand(1).Checksum() @@ -3365,8 +3364,7 @@ def test_jp2openjpeg_online_1(): # Checksum = 32669 on my PC tst = gdaltest.GDALTest('JP2OpenJPEG', 'tmp/cache/7sisters200.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/7sisters200.j2k') ds.GetRasterBand(1).Checksum() @@ -3388,8 +3386,7 @@ def test_jp2openjpeg_online_2(): # Checksum = 15621 on my PC tst = gdaltest.GDALTest('JP2OpenJPEG', 'tmp/cache/gcp.jp2', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/gcp.jp2') ds.GetRasterBand(1).Checksum() @@ -3421,8 +3418,7 @@ def test_jp2openjpeg_online_3(): tst = gdaltest.GDALTest('JP2OpenJPEG', 'tmp/cache/Bretagne1.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne1.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne1.bmp') @@ -3455,8 +3451,7 @@ def test_jp2openjpeg_online_4(): tst = gdaltest.GDALTest('JP2OpenJPEG', 'tmp/cache/Bretagne2.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'expected_fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne2.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne2.bmp') diff --git a/autotest/gdrivers/jpeg2000.py b/autotest/gdrivers/jpeg2000.py index f357668eba81..4f9554e30c3b 100755 --- a/autotest/gdrivers/jpeg2000.py +++ b/autotest/gdrivers/jpeg2000.py @@ -140,8 +140,7 @@ def test_jpeg2000_4(): return 'skip' tst = gdaltest.GDALTest('JPEG2000', 'byte.jp2', 1, 50054) - if tst.testCreateCopy() != 'success': - return 'fail' + tst.testCreateCopy() # This may fail for a good reason if tst.testCreateCopy(check_gt=1, check_srs=1) != 'success': @@ -173,8 +172,7 @@ def test_jpeg2000_6(): tst = gdaltest.GDALTest('JPEG2000', 'll.jp2', 1, None) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('data/ll.jp2') ds.GetRasterBand(1).Checksum() @@ -342,8 +340,7 @@ def test_jpeg2000_online_1(): # Checksum = 32669 on my PC tst = gdaltest.GDALTest('JPEG2000', 'tmp/cache/7sisters200.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/7sisters200.j2k') ds.GetRasterBand(1).Checksum() @@ -365,8 +362,7 @@ def test_jpeg2000_online_2(): # Checksum = 15621 on my PC tst = gdaltest.GDALTest('JPEG2000', 'tmp/cache/gcp.jp2', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/gcp.jp2') ds.GetRasterBand(1).Checksum() @@ -399,8 +395,7 @@ def test_jpeg2000_online_3(): # Checksum = 14443 on my PC tst = gdaltest.GDALTest('JPEG2000', 'tmp/cache/Bretagne1.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne1.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne1.bmp') diff --git a/autotest/gdrivers/kea.py b/autotest/gdrivers/kea.py index 25990fc5f6f8..c1dacc0e3fe7 100755 --- a/autotest/gdrivers/kea.py +++ b/autotest/gdrivers/kea.py @@ -73,8 +73,6 @@ def test_kea_2(): for src_file in src_files: tst = gdaltest.GDALTest('KEA', src_file, 1, 4672) ret = tst.testCreateCopy(check_minmax=1) - if ret != 'success': - return ret return 'success' @@ -97,8 +95,6 @@ def test_kea_3(): for src_file in src_files: tst = gdaltest.GDALTest('KEA', src_file, 1, 4672) ret = tst.testCreate(out_bands=1, check_minmax=1) - if ret != 'success': - return ret return 'success' diff --git a/autotest/gdrivers/mrsid.py b/autotest/gdrivers/mrsid.py index 2b4b8e9459eb..fa711eeff193 100755 --- a/autotest/gdrivers/mrsid.py +++ b/autotest/gdrivers/mrsid.py @@ -115,9 +115,6 @@ def test_mrsid_1(): check_stat=(0.0, 255.0, 103.319, 55.153), check_approx_stat=(2.0, 243.0, 103.131, 43.978)) - if ret != 'success': - return ret - ds = gdal.Open('data/mercator.sid') got_prj = ds.GetProjectionRef() ds = None @@ -459,8 +456,7 @@ def test_mrsid_online_1(): # Checksum = 29473 on my PC tst = gdaltest.GDALTest('JP2MrSID', 'tmp/cache/7sisters200.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/7sisters200.j2k') ds.GetRasterBand(1).Checksum() @@ -482,8 +478,7 @@ def test_mrsid_online_2(): # Checksum = 209 on my PC tst = gdaltest.GDALTest('JP2MrSID', 'tmp/cache/gcp.jp2', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() # The JP2MrSID driver doesn't handle GCPs ds = gdal.Open('tmp/cache/gcp.jp2') @@ -517,8 +512,7 @@ def test_mrsid_online_3(): # checksum = 14443 on my PC tst = gdaltest.GDALTest('JP2MrSID', 'tmp/cache/Bretagne1.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne1.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne1.bmp') @@ -554,8 +548,7 @@ def test_mrsid_online_4(): # Checksum = 53186 on my PC tst = gdaltest.GDALTest('JP2MrSID', 'tmp/cache/Bretagne2.j2k', 1, None, filename_absolute=1) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('tmp/cache/Bretagne2.j2k') ds_ref = gdal.Open('tmp/cache/Bretagne2.bmp') diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index fac78514b745..f15dcdeef784 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -333,9 +333,6 @@ def test_netcdf_2(): result = tst.testOpen(check_prj=wkt) - if result != 'success': - return result - # Test that in raster-only mode, update isn't supported (not sure what would be missing for that...) with gdaltest.error_handler(): ds = gdal.Open('tmp/netcdf2.nc', gdal.GA_Update) @@ -1013,8 +1010,6 @@ def test_netcdf_25(): return 'skip' result = netcdf_test_copy('data/nc_vars.nc', 1, None, 'tmp/netcdf_25.nc') - if result != 'success': - return result vals_global = {'NC_GLOBAL#test': 'testval', 'NC_GLOBAL#valid_range_i': '0,255', @@ -1042,8 +1037,6 @@ def netcdf_25_nc4(): return 'skip' result = netcdf_test_copy('data/nc4_vars.nc', 1, None, 'tmp/netcdf_25_nc4.nc', ['FORMAT=NC4']) - if result != 'success': - return result vals_global = {'NC_GLOBAL#test': 'testval', 'NC_GLOBAL#test_string': 'testval_string', @@ -1203,8 +1196,6 @@ def test_netcdf_28(): # copy file result = netcdf_test_copy(ifile, 0, None, ofile) - if result != 'success': - return 'fail' # test file return netcdf_test_4dfile(ofile) @@ -1247,8 +1238,6 @@ def test_netcdf_29(): # copy vrt to netcdf, with proper dimension rolling result = netcdf_test_copy(ofile1, 0, None, ofile) - if result != 'success': - return 'fail' # test file result = netcdf_test_4dfile(ofile) @@ -1321,11 +1310,7 @@ def test_netcdf_32(): # test basic read/write result = netcdf_test_copy(ifile, 1, 4672, ofile, ['FORMAT=NC4']) - if result != 'success': - return 'fail' result = netcdf_test_copy(ifile, 1, 4672, ofile, ['FORMAT=NC4C']) - if result != 'success': - return 'fail' return 'success' @@ -1342,8 +1327,6 @@ def test_netcdf_33(): ofile = 'tmp/netcdf_33.nc' result = netcdf_test_copy(ifile, 1, None, ofile, ['FORMAT=NC4']) - if result != 'success': - return result return netcdf_check_vars('tmp/netcdf_33.nc') @@ -1411,8 +1394,6 @@ def test_netcdf_35(): # copy file result = netcdf_test_copy(ifile, 0, None, ofile) - if result != 'success': - return 'fail' # test long metadata is copied correctly ds = gdal.Open(ofile) @@ -2073,9 +2054,6 @@ def test_netcdf_51(): if netcdf_cf.netcdf_cf_setup() == 'success' and \ gdaltest.netcdf_cf_method is not None: result_cf = netcdf_cf.netcdf_cf_check_file('tmp/netcdf_51.nc', 'auto', False) - if result_cf != 'success': - gdaltest.post_reason('failure') - return 'fail' gdal.Unlink('tmp/netcdf_51.nc') gdal.Unlink('tmp/netcdf_51.csv') @@ -2208,9 +2186,6 @@ def test_netcdf_52(): if netcdf_cf.netcdf_cf_setup() == 'success' and \ gdaltest.netcdf_cf_method is not None: result_cf = netcdf_cf.netcdf_cf_check_file('tmp/netcdf_52.nc', 'auto', False) - if result_cf != 'success': - gdaltest.post_reason('failure') - return 'fail' gdal.Unlink('tmp/netcdf_52.nc') gdal.Unlink('tmp/netcdf_52.csv') @@ -2665,9 +2640,6 @@ def test_netcdf_62_cf_check(): if netcdf_cf.netcdf_cf_setup() == 'success' and \ gdaltest.netcdf_cf_method is not None: result_cf = netcdf_cf.netcdf_cf_check_file('tmp/netcdf_62.nc', 'auto', False) - if result_cf != 'success': - gdaltest.post_reason('failure') - return 'fail' gdal.Unlink('/vsimem/netcdf_62.nc') diff --git a/autotest/gdrivers/nitf.py b/autotest/gdrivers/nitf.py index 7fe2659b61ab..ec573c9b8cf9 100755 --- a/autotest/gdrivers/nitf.py +++ b/autotest/gdrivers/nitf.py @@ -558,8 +558,7 @@ def test_nitf_26(): def test_nitf_27(): - if nitf_create(['ICORDS=G', 'IC=NC', 'BLOCKXSIZE=10', 'BLOCKYSIZE=10']) != 'success': - return 'fail' + nitf_create(['ICORDS=G', 'IC=NC', 'BLOCKXSIZE=10', 'BLOCKYSIZE=10']) return nitf_check_created_file(32498, 42602, 38982) @@ -872,10 +871,9 @@ def test_nitf_30(): def test_nitf_31(): - if nitf_create(['TRE=CUSTOM= Test TRE1\\0MORE', + nitf_create(['TRE=CUSTOM= Test TRE1\\0MORE', 'TRE=TOTEST=SecondTRE', - 'ICORDS=G']) != 'success': - return 'fail' + 'ICORDS=G']) ds = gdal.Open('tmp/test_create.ntf') @@ -909,8 +907,7 @@ def test_nitf_31(): def test_nitf_32(): - if nitf_create(['ICORDS=D']) != 'success': - return 'fail' + nitf_create(['ICORDS=D']) return nitf_check_created_file(32498, 42602, 38982) @@ -920,15 +917,14 @@ def test_nitf_32(): def test_nitf_33(): - if nitf_create(['ICORDS=D', + nitf_create(['ICORDS=D', 'BLOCKA_BLOCK_COUNT=01', 'BLOCKA_BLOCK_INSTANCE_01=01', 'BLOCKA_L_LINES_01=100', 'BLOCKA_FRLC_LOC_01=+29.950000+119.950000', 'BLOCKA_LRLC_LOC_01=+20.050000+119.950000', 'BLOCKA_LRFC_LOC_01=+20.050000+100.050000', - 'BLOCKA_FRFC_LOC_01=+29.950000+100.050000']) != 'success': - return 'fail' + 'BLOCKA_FRFC_LOC_01=+29.950000+100.050000']) return nitf_check_created_file(32498, 42602, 38982) @@ -3771,8 +3767,6 @@ def test_nitf_online_25(): tst = gdaltest.GDALTest('NITF', 'tmp/cache/Case1_HRE10G324642N1170747W_Uxx.hr5', 1, 7099, filename_absolute=1) ret = tst.testOpen() - if ret != 'success': - return ret ds = gdal.Open('tmp/cache/Case1_HRE10G324642N1170747W_Uxx.hr5') xml_tre = ds.GetMetadata('xml:TRE')[0] diff --git a/autotest/gdrivers/pds.py b/autotest/gdrivers/pds.py index 62637acf5b26..71356bcdbf06 100755 --- a/autotest/gdrivers/pds.py +++ b/autotest/gdrivers/pds.py @@ -77,8 +77,6 @@ def test_pds_2(): check_gt=expected_gt) gdal.SetConfigOption('PDS_SampleProjOffset_Shift', None) gdal.SetConfigOption('PDS_LineProjOffset_Shift', None) - if ret != 'success': - return 'fail' ds = gdal.Open('data/fl73n003_truncated.img') if ds.GetRasterBand(1).GetNoDataValue() != 7: @@ -108,8 +106,7 @@ def test_pds_3(): tst = gdaltest.GDALTest('PDS', 'EN0001426030M_truncated.IMG', 1, 1367) gt_expected = (0, 1, 0, 0, 0, 1) - if tst.testOpen(check_gt=gt_expected) != 'success': - return 'fail' + tst.testOpen(check_gt=gt_expected) ds = gdal.Open('data/EN0001426030M_truncated.IMG') if ds.GetRasterBand(1).GetNoDataValue() != 0: @@ -162,8 +159,6 @@ def test_pds_6(): ret = tst.testOpen(check_gt=gt_expected) gdal.SetConfigOption('PDS_SampleProjOffset_Shift', None) gdal.SetConfigOption('PDS_LineProjOffset_Shift', None) - if ret != 'success': - return 'fail' ds = gdal.Open('data/ESP_013951_1955_RED.LBL') @@ -210,8 +205,6 @@ def test_pds_7(): check_gt=gt_expected) gdal.SetConfigOption('PDS_SampleProjOffset_Shift', None) gdal.SetConfigOption('PDS_LineProjOffset_Shift', None) - if ret != 'success': - return 'fail' return 'success' @@ -252,8 +245,7 @@ def test_pds_9(): # Derived from http://pdsimage.wr.usgs.gov/data/co-v_e_j_s-radar-3-sbdr-v1.0/CORADR_0035/DATA/BIDR/BIEQI49N071_D035_T00AS01_V02.LBL tst = gdaltest.GDALTest('PDS', 'PDS_WITH_ZIP_IMG.LBL', 1, 0) - if tst.testOpen() != 'success': - return 'fail' + tst.testOpen() ds = gdal.Open('data/PDS_WITH_ZIP_IMG.LBL') got_nd = ds.GetRasterBand(1).GetNoDataValue() diff --git a/autotest/gdrivers/rmf.py b/autotest/gdrivers/rmf.py index 4922b2f26d25..2fbf4a16a540 100755 --- a/autotest/gdrivers/rmf.py +++ b/autotest/gdrivers/rmf.py @@ -65,14 +65,10 @@ def test_rmf_4(): tst = gdaltest.GDALTest('rmf', 'rgbsmall.rsw', 1, 21212) ret = tst.testOpen(check_gt=(-44.840320, 0.003432, 0, -22.932584, 0, -0.003432)) - if ret != 'success': - return 'fail' tst = gdaltest.GDALTest('rmf', 'rgbsmall.rsw', 2, 21053) ret = tst.testOpen(check_gt=(-44.840320, 0.003432, 0, -22.932584, 0, -0.003432)) - if ret != 'success': - return 'fail' tst = gdaltest.GDALTest('rmf', 'rgbsmall.rsw', 3, 21349) return tst.testOpen(check_gt=(-44.840320, 0.003432, 0, @@ -85,16 +81,12 @@ def test_rmf_5(): with gdaltest.error_handler(): ret = tst.testOpen() - if ret != 'success': - return 'fail' - + tst = gdaltest.GDALTest('rmf', 'rgbsmall-lzw.rsw', 2, 41429) with gdaltest.error_handler(): ret = tst.testOpen() - if ret != 'success': - return 'fail' - + tst = gdaltest.GDALTest('rmf', 'rgbsmall-lzw.rsw', 3, 40238) with gdaltest.error_handler(): return tst.testOpen() @@ -105,15 +97,11 @@ def test_rmf_6(): tst = gdaltest.GDALTest('rmf', 'big-endian.rsw', 1, 7782) with gdaltest.error_handler(): ret = tst.testOpen() - if ret != 'success': - return 'fail' - + tst = gdaltest.GDALTest('rmf', 'big-endian.rsw', 2, 8480) with gdaltest.error_handler(): ret = tst.testOpen() - if ret != 'success': - return 'fail' - + tst = gdaltest.GDALTest('rmf', 'big-endian.rsw', 3, 4195) with gdaltest.error_handler(): return tst.testOpen() diff --git a/autotest/gdrivers/rraster.py b/autotest/gdrivers/rraster.py index 01669dd662db..40ecec87f809 100755 --- a/autotest/gdrivers/rraster.py +++ b/autotest/gdrivers/rraster.py @@ -51,8 +51,6 @@ def test_rraster_1(filename='data/byte_rraster.grd', check_prj=None): check_gt=ref_ds.GetGeoTransform(), check_min=74, check_max=255) - if ret != 'success': - return ret ds = gdal.Open(filename) md = ds.GetMetadata() diff --git a/autotest/gdrivers/saga.py b/autotest/gdrivers/saga.py index 979c953b9885..0917b53a358e 100755 --- a/autotest/gdrivers/saga.py +++ b/autotest/gdrivers/saga.py @@ -96,8 +96,6 @@ def test_saga_4(): else: check_minmax = 1 ret = tst.testCreateCopy(new_filename='tmp/test4.sdat', check_minmax=check_minmax) - if ret != 'success': - return ret return 'success' @@ -122,8 +120,6 @@ def test_saga_5(): else: check_minmax = 1 ret = tst.testCreate(new_filename='tmp/test5.sdat', out_bands=1, check_minmax=check_minmax) - if ret != 'success': - return ret return 'success' diff --git a/autotest/gdrivers/sdts.py b/autotest/gdrivers/sdts.py index 0c11b17f6c18..f0ab691f0144 100755 --- a/autotest/gdrivers/sdts.py +++ b/autotest/gdrivers/sdts.py @@ -46,10 +46,9 @@ def test_sdts_1(): srs = osr.SpatialReference() srs.SetWellKnownGeogCS('NAD27') srs.SetUTM(16) - if tst.testOpen(check_prj=srs.ExportToWkt(), + tst.testOpen(check_prj=srs.ExportToWkt(), check_gt=(666015, 30, 0, 5040735, 0, -30), - check_filelist=False) != 'success': - return 'fail' + check_filelist=False) ds = gdal.Open('data/STDS_1107834_truncated/1107CATD.DDF') md = ds.GetMetadata() diff --git a/autotest/gdrivers/srp.py b/autotest/gdrivers/srp.py index e0b94cb2297a..d034266fe66a 100755 --- a/autotest/gdrivers/srp.py +++ b/autotest/gdrivers/srp.py @@ -48,8 +48,6 @@ def test_srp_1(filename='USRP_PCB0/FKUSRP01.IMG'): tst = gdaltest.GDALTest('SRP', filename, 1, 24576) ret = tst.testOpen(check_prj=srs.ExportToWkt(), check_gt=(500000.0, 5.0, 0.0, 5000000.0, 0.0, -5.0)) - if ret != 'success': - return ret ds = gdal.Open('data/' + filename) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_PaletteIndex: diff --git a/autotest/gdrivers/vicar.py b/autotest/gdrivers/vicar.py index cc7fc73027c2..4f34ac92d57d 100755 --- a/autotest/gdrivers/vicar.py +++ b/autotest/gdrivers/vicar.py @@ -52,9 +52,7 @@ def test_vicar_1(): PARAMETER["longitude_of_center",137], PARAMETER["false_easting",0], PARAMETER["false_northing",0]]""" - if tst.testOpen(check_prj=expected_prj, skip_checksum=True) != 'success': - gdaltest.post_reason('fail') - return 'fail' + tst.testOpen(check_prj=expected_prj, skip_checksum=True) ds = gdal.Open('data/test_vicar_truncated.bin') expected_gt = (-53985.0, 25.0, 0.0, -200805.0, 0.0, -25.0) diff --git a/autotest/ogr/ogr_bna.py b/autotest/ogr/ogr_bna.py index f13372efbd25..2fa0c6e4c552 100755 --- a/autotest/ogr/ogr_bna.py +++ b/autotest/ogr/ogr_bna.py @@ -205,8 +205,7 @@ def ogr_bna_write(creation_options): for layer_name in ['points', 'lines', 'polygons', 'ellipses']: src_lyr = gdaltest.bna_ds.GetLayerByName('test_' + layer_name) dst_lyr = output_ds.GetLayerByName('out_' + layer_name) - if ogr_bna_check_content(src_lyr, dst_lyr) != 'success': - return 'fail' + ogr_bna_check_content(src_lyr, dst_lyr) return 'success' @@ -224,8 +223,6 @@ def test_ogr_bna_6(): pass ret = ogr_bna_write(['LINEFORMAT=LF', 'MULTILINE=NO', 'COORDINATE_PRECISION=3']) - if ret != 'success': - return ret size = os.stat('tmp/out.bna').st_size if size != 1601: @@ -235,8 +232,6 @@ def test_ogr_bna_6(): os.remove('tmp/out.bna') ret = ogr_bna_write(['LINEFORMAT=CRLF', 'MULTILINE=NO', 'COORDINATE_PRECISION=3']) - if ret != 'success': - return ret size = os.stat('tmp/out.bna').st_size if size != 1611: diff --git a/autotest/ogr/ogr_georss.py b/autotest/ogr/ogr_georss.py index 08f6d4982b70..9d377624f90b 100755 --- a/autotest/ogr/ogr_georss.py +++ b/autotest/ogr/ogr_georss.py @@ -338,8 +338,7 @@ def ogr_georss_create(filename, options): def test_ogr_georss_4(): - if ogr_georss_create('tmp/test_rss2.xml', []) != 'success': - return 'fail' + ogr_georss_create('tmp/test_rss2.xml', []) content = open('tmp/test_rss2.xml').read() if content.find('49 2') == -1: @@ -362,8 +361,7 @@ def test_ogr_georss_5(): def test_ogr_georss_6(): - if ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=GML']) != 'success': - return 'fail' + ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=GML']) content = open('tmp/test_rss2.xml').read() if content.find('49 2') == -1: @@ -388,8 +386,7 @@ def test_ogr_georss_7(): def test_ogr_georss_8(): - if ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=W3C_GEO']) != 'success': - return 'fail' + ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=W3C_GEO']) content = open('tmp/test_rss2.xml').read() if content.find('49') == -1 or content.find('2') == -1: diff --git a/autotest/ogr/ogr_gml_read.py b/autotest/ogr/ogr_gml_read.py index 36acd7cf8a26..ebae82bd1e09 100755 --- a/autotest/ogr/ogr_gml_read.py +++ b/autotest/ogr/ogr_gml_read.py @@ -1272,9 +1272,6 @@ def test_ogr_gml_31(): ret = test_ogr_gml_29() gdal.SetConfigOption('GML_READ_MODE', None) - if ret != 'success': - return ret - # Test reading second layer and then first layer gdal.SetConfigOption('GML_READ_MODE', 'SEQUENTIAL_LAYERS') ds = ogr.Open('data/testfmegml.gml') @@ -3752,9 +3749,7 @@ def test_ogr_gml_71(): # With .xsd gdal.Unlink('data/wfsjointlayer.gfs') ds = ogr.Open('data/wfsjointlayer.gml') - if ogr_gml_71_helper(ds) != 'success': - gdaltest.post_reason('fail') - return 'fail' + ogr_gml_71_helper(ds) ds = None try: @@ -3766,9 +3761,7 @@ def test_ogr_gml_71(): # With .xsd but that is only partially understood ds = gdal.OpenEx('data/wfsjointlayer.gml', open_options=['XSD=data/wfsjointlayer_not_understood.xsd']) - if ogr_gml_71_helper(ds) != 'success': - gdaltest.post_reason('fail') - return 'fail' + ogr_gml_71_helper(ds) ds = None try: @@ -3781,9 +3774,7 @@ def test_ogr_gml_71(): shutil.copy('data/wfsjointlayer.gml', 'tmp/wfsjointlayer.gml') gdal.Unlink('tmp/wfsjointlayer.gfs') ds = ogr.Open('tmp/wfsjointlayer.gml') - if ogr_gml_71_helper(ds) != 'success': - gdaltest.post_reason('fail') - return 'fail' + ogr_gml_71_helper(ds) ds = None try: @@ -3794,9 +3785,7 @@ def test_ogr_gml_71(): # With .gfs ds = ogr.Open('tmp/wfsjointlayer.gml') - if ogr_gml_71_helper(ds) != 'success': - gdaltest.post_reason('fail') - return 'fail' + ogr_gml_71_helper(ds) ds = None return 'success' diff --git a/autotest/ogr/ogr_index_test.py b/autotest/ogr/ogr_index_test.py index f0559c54ec0e..72fab8dcc0e5 100755 --- a/autotest/ogr/ogr_index_test.py +++ b/autotest/ogr/ogr_index_test.py @@ -460,28 +460,18 @@ def test_ogr_index_11(): lyr.SetAttributeFilter("intfield = 1 OR strfield = 'bar'") ret = ogr_index_11_check(lyr, [0, 1, 3]) - if ret != 'success': - return ret lyr.SetAttributeFilter("intfield = 1 AND strfield = 'bar'") ret = ogr_index_11_check(lyr, [1]) - if ret != 'success': - return ret lyr.SetAttributeFilter("intfield = 1 AND strfield = 'foo'") ret = ogr_index_11_check(lyr, [0]) - if ret != 'success': - return ret lyr.SetAttributeFilter("intfield = 3 AND strfield = 'foo'") ret = ogr_index_11_check(lyr, []) - if ret != 'success': - return ret lyr.SetAttributeFilter("intfield IN (1, 2, 3)") ret = ogr_index_11_check(lyr, [0, 1, 2, 3, 4]) - if ret != 'success': - return ret ds = None diff --git a/autotest/ogr/ogr_mitab.py b/autotest/ogr/ogr_mitab.py index 4c31c4003434..553920282128 100755 --- a/autotest/ogr/ogr_mitab.py +++ b/autotest/ogr/ogr_mitab.py @@ -401,8 +401,7 @@ def test_ogr_mitab_13(): return 'skip' import ogr_gml_read - if ogr_gml_read.ogr_gml_1() != 'success': - return 'skip' + ogr_gml_read.ogr_gml_1() if test_cli_utilities.get_ogr2ogr_path() is None: return 'skip' @@ -452,8 +451,7 @@ def test_ogr_mitab_14(): return 'skip' import ogr_gml_read - if ogr_gml_read.ogr_gml_1() != 'success': - return 'skip' + ogr_gml_read.ogr_gml_1() if test_cli_utilities.get_ogr2ogr_path() is None: return 'skip' @@ -565,8 +563,7 @@ def test_ogr_mitab_17(): return 'skip' import ogr_gml_read - if ogr_gml_read.ogr_gml_1() != 'success': - return 'skip' + ogr_gml_read.ogr_gml_1() if test_cli_utilities.get_test_ogrsf_path() is None: return 'skip' diff --git a/autotest/ogr/ogr_pg.py b/autotest/ogr/ogr_pg.py index 1c46286f3ec9..35e8c97a58b8 100755 --- a/autotest/ogr/ogr_pg.py +++ b/autotest/ogr/ogr_pg.py @@ -1429,8 +1429,7 @@ def test_ogr_pg_24(with_and_without_postgis): lyr = ds.GetLayerByName('datatypetest') feat = lyr.GetNextFeature() - if check_value_23(lyr.GetLayerDefn(), feat) != 'success': - return 'fail' + check_value_23(lyr.GetLayerDefn(), feat) feat = None @@ -1454,8 +1453,7 @@ def test_ogr_pg_25(with_and_without_postgis): sql_lyr = ds.ExecuteSQL('select * from datatypetest') feat = sql_lyr.GetNextFeature() - if check_value_23(sql_lyr.GetLayerDefn(), feat) != 'success': - return 'fail' + check_value_23(sql_lyr.GetLayerDefn(), feat) ds.ReleaseResultSet(sql_lyr) @@ -1533,8 +1531,7 @@ def test_ogr_pg_29(with_and_without_postgis): # my_timestamp has now a time zone... feat = lyr.GetNextFeature() - if check_value_23(lyr.GetLayerDefn(), feat) != 'success': - return 'fail' + check_value_23(lyr.GetLayerDefn(), feat) geom = feat.GetGeometryRef() wkt = geom.ExportToWkt() @@ -4460,17 +4457,9 @@ def test_ogr_pg_76(with_and_without_postgis): return 'fail' ret = ogr_pg_76_scenario1(lyr1, lyr2) - if ret != 'success': - return ret ret = ogr_pg_76_scenario2(lyr1, lyr2) - if ret != 'success': - return ret ret = ogr_pg_76_scenario3(lyr1, lyr2) - if ret != 'success': - return ret ret = ogr_pg_76_scenario4(lyr1, lyr2) - if ret != 'success': - return ret return ret diff --git a/autotest/ogr/ogr_rfc35_mem.py b/autotest/ogr/ogr_rfc35_mem.py index 4b792b80688c..1fddc0348ff0 100755 --- a/autotest/ogr/ogr_rfc35_mem.py +++ b/autotest/ogr/ogr_rfc35_mem.py @@ -137,12 +137,8 @@ def CheckColumnOrder(lyr, expected_order): def Check(lyr, expected_order): ret = CheckColumnOrder(lyr, expected_order) - if ret != 'success': - return ret ret = CheckFeatures(lyr) - if ret != 'success': - return ret return 'success' @@ -165,43 +161,27 @@ def test_ogr_rfc35_mem_2(): if lyr.ReorderField(1, 3) != 0: return 'fail' ret = Check(lyr, ['foo5', 'baz15', 'baw20', 'bar10']) - if ret != 'success': - return ret lyr.ReorderField(3, 1) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(0, 2) ret = Check(lyr, ['bar10', 'baz15', 'foo5', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(2, 0) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(0, 1) ret = Check(lyr, ['bar10', 'foo5', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(1, 0) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderFields([3, 2, 1, 0]) ret = Check(lyr, ['baw20', 'baz15', 'bar10', 'foo5']) - if ret != 'success': - return ret lyr.ReorderFields([3, 2, 1, 0]) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret gdal.PushErrorHandler('CPLQuietErrorHandler') ret = lyr.ReorderFields([0, 0, 0, 0]) @@ -239,8 +219,6 @@ def test_ogr_rfc35_mem_3(): lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("baz15"), fd, ogr.ALTER_ALL_FLAG) ret = CheckFeatures(lyr, field3='baz25') - if ret != 'success': - return ret fd = ogr.FieldDefn("baz5", ogr.OFTString) fd.SetWidth(5) @@ -249,8 +227,6 @@ def test_ogr_rfc35_mem_3(): lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("baz25"), fd, ogr.ALTER_ALL_FLAG) ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret lyr_defn = lyr.GetLayerDefn() fld_defn = lyr_defn.GetFieldDefn(lyr_defn.GetFieldIndex('baz5')) @@ -258,8 +234,6 @@ def test_ogr_rfc35_mem_3(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret return 'success' @@ -296,8 +270,6 @@ def test_ogr_rfc35_mem_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret fd.SetWidth(5) lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("intfield"), fd, ogr.ALTER_ALL_FLAG) @@ -309,8 +281,6 @@ def test_ogr_rfc35_mem_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret fd.SetWidth(4) lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("intfield"), fd, ogr.ALTER_ALL_FLAG) @@ -323,8 +293,6 @@ def test_ogr_rfc35_mem_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret fd = ogr.FieldDefn("oldintfld", ogr.OFTString) fd.SetWidth(15) @@ -338,8 +306,6 @@ def test_ogr_rfc35_mem_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret lyr.DeleteField(lyr_defn.GetFieldIndex("oldintfld")) @@ -369,8 +335,6 @@ def test_ogr_rfc35_mem_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret return 'success' @@ -402,22 +366,16 @@ def test_ogr_rfc35_mem_5(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('baw20')) != 0: return 'fail' ret = CheckFeatures(lyr, field3='baz5', field4=None) - if ret != 'success': - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('baz5')) != 0: return 'fail' ret = CheckFeatures(lyr, field3=None, field4=None) - if ret != 'success': - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('foo5')) != 0: return 'fail' @@ -426,8 +384,6 @@ def test_ogr_rfc35_mem_5(): return 'fail' ret = CheckFeatures(lyr, field1=None, field2=None, field3=None, field4=None) - if ret != 'success': - return ret return 'success' diff --git a/autotest/ogr/ogr_rfc35_mitab.py b/autotest/ogr/ogr_rfc35_mitab.py index 05fa006309fb..2e2670deb640 100755 --- a/autotest/ogr/ogr_rfc35_mitab.py +++ b/autotest/ogr/ogr_rfc35_mitab.py @@ -156,23 +156,15 @@ def CheckColumnOrder(lyr, expected_order): def Check(lyr, expected_order): ret = CheckColumnOrder(lyr, expected_order) - if ret != 'success': - return ret ret = CheckFeatures(lyr) - if ret != 'success': - return ret ds = ogr.Open('/vsimem/rfc35_test.tab', update=1) lyr_reopen = ds.GetLayer(0) ret = CheckColumnOrder(lyr_reopen, expected_order) - if ret != 'success': - return ret ret = CheckFeatures(lyr_reopen) - if ret != 'success': - return ret return 'success' @@ -349,8 +341,6 @@ def test_ogr_rfc35_mitab_3(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret return 'success' diff --git a/autotest/ogr/ogr_rfc35_shape.py b/autotest/ogr/ogr_rfc35_shape.py index 40ae2975952f..a9540d481201 100755 --- a/autotest/ogr/ogr_rfc35_shape.py +++ b/autotest/ogr/ogr_rfc35_shape.py @@ -156,23 +156,15 @@ def CheckColumnOrder(lyr, expected_order): def Check(lyr, expected_order): ret = CheckColumnOrder(lyr, expected_order) - if ret != 'success': - return ret ret = CheckFeatures(lyr) - if ret != 'success': - return ret ds = ogr.Open('/vsimem/rfc35_test.dbf', update=1) lyr_reopen = ds.GetLayer(0) ret = CheckColumnOrder(lyr_reopen, expected_order) - if ret != 'success': - return ret ret = CheckFeatures(lyr_reopen) - if ret != 'success': - return ret return 'success' @@ -196,43 +188,27 @@ def test_ogr_rfc35_shape_2(): if lyr.ReorderField(1, 3) != 0: return 'fail' ret = Check(lyr, ['foo5', 'baz15', 'baw20', 'bar10']) - if ret != 'success': - return ret lyr.ReorderField(3, 1) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(0, 2) ret = Check(lyr, ['bar10', 'baz15', 'foo5', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(2, 0) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(0, 1) ret = Check(lyr, ['bar10', 'foo5', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderField(1, 0) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret lyr.ReorderFields([3, 2, 1, 0]) ret = Check(lyr, ['baw20', 'baz15', 'bar10', 'foo5']) - if ret != 'success': - return ret lyr.ReorderFields([3, 2, 1, 0]) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret gdal.PushErrorHandler('CPLQuietErrorHandler') ret = lyr.ReorderFields([0, 0, 0, 0]) @@ -246,12 +222,8 @@ def test_ogr_rfc35_shape_2(): lyr = ds.GetLayer(0) ret = CheckColumnOrder(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - return ret ret = CheckFeatures(lyr) - if ret != 'success': - return ret return 'success' @@ -284,8 +256,6 @@ def test_ogr_rfc35_shape_3(): lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("baz15"), fd, ogr.ALTER_ALL_FLAG) ret = CheckFeatures(lyr, field3='baz25') - if ret != 'success': - return ret fd = ogr.FieldDefn("baz5", ogr.OFTString) fd.SetWidth(5) @@ -294,8 +264,6 @@ def test_ogr_rfc35_shape_3(): lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("baz25"), fd, ogr.ALTER_ALL_FLAG) ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret ds = None @@ -307,8 +275,6 @@ def test_ogr_rfc35_shape_3(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret return 'success' @@ -346,8 +312,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret fd.SetWidth(5) lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("intfield"), fd, ogr.ALTER_ALL_FLAG) @@ -359,8 +323,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret ds = None @@ -378,8 +340,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret ds = None @@ -403,8 +363,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret ds = None @@ -419,8 +377,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret lyr.DeleteField(lyr_defn.GetFieldIndex("oldintfld")) @@ -450,8 +406,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret ds = None @@ -466,8 +420,6 @@ def test_ogr_rfc35_shape_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret return 'success' @@ -500,8 +452,6 @@ def test_ogr_rfc35_shape_5(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('baw20')) != 0: return 'fail' @@ -518,15 +468,11 @@ def test_ogr_rfc35_shape_5(): lyr_defn = lyr.GetLayerDefn() ret = CheckFeatures(lyr, field3='baz5', field4=None) - if ret != 'success': - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('baz5')) != 0: return 'fail' ret = CheckFeatures(lyr, field3=None, field4=None) - if ret != 'success': - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('foo5')) != 0: return 'fail' @@ -535,8 +481,6 @@ def test_ogr_rfc35_shape_5(): return 'fail' ret = CheckFeatures(lyr, field1=None, field2=None, field3=None, field4=None) - if ret != 'success': - return ret ds = None @@ -545,8 +489,6 @@ def test_ogr_rfc35_shape_5(): lyr_defn = lyr.GetLayerDefn() ret = CheckFeatures(lyr, field1=None, field2=None, field3=None, field4=None) - if ret != 'success': - return ret return 'success' diff --git a/autotest/ogr/ogr_rfc35_sqlite.py b/autotest/ogr/ogr_rfc35_sqlite.py index e3ae8a3ab83f..10a8392b3c7f 100755 --- a/autotest/ogr/ogr_rfc35_sqlite.py +++ b/autotest/ogr/ogr_rfc35_sqlite.py @@ -151,12 +151,8 @@ def CheckColumnOrder(lyr, expected_order): def Check(lyr, expected_order): ret = CheckColumnOrder(lyr, expected_order) - if ret != 'success': - return ret ret = CheckFeatures(lyr) - if ret != 'success': - return ret return 'success' @@ -185,51 +181,27 @@ def test_ogr_rfc35_sqlite_2(): return 'fail' ret = Check(lyr, ['foo5', 'baz15', 'baw20', 'bar10']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderField(3, 1) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderField(0, 2) ret = Check(lyr, ['bar10', 'baz15', 'foo5', 'baw20']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderField(2, 0) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderField(0, 1) ret = Check(lyr, ['bar10', 'foo5', 'baz15', 'baw20']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderField(1, 0) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderFields([3, 2, 1, 0]) ret = Check(lyr, ['baw20', 'baz15', 'bar10', 'foo5']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.ReorderFields([3, 2, 1, 0]) ret = Check(lyr, ['foo5', 'bar10', 'baz15', 'baw20']) - if ret != 'success': - gdaltest.post_reason('failed') - return ret gdal.PushErrorHandler('CPLQuietErrorHandler') ret = lyr.ReorderFields([0, 0, 0, 0]) @@ -273,9 +245,6 @@ def test_ogr_rfc35_sqlite_3(): lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("baz15"), fd, ogr.ALTER_ALL_FLAG) ret = CheckFeatures(lyr, field3='baz25') - if ret != 'success': - gdaltest.post_reason('failed') - return ret fd = ogr.FieldDefn("baz5", ogr.OFTString) fd.SetWidth(5) @@ -284,9 +253,6 @@ def test_ogr_rfc35_sqlite_3(): lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("baz25"), fd, ogr.ALTER_ALL_FLAG) ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr_defn = lyr.GetLayerDefn() fld_defn = lyr_defn.GetFieldDefn(lyr_defn.GetFieldIndex('baz5')) @@ -295,9 +261,6 @@ def test_ogr_rfc35_sqlite_3(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret return 'success' @@ -339,9 +302,6 @@ def test_ogr_rfc35_sqlite_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret fd.SetWidth(5) lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("intfield"), fd, ogr.ALTER_ALL_FLAG) @@ -354,9 +314,6 @@ def test_ogr_rfc35_sqlite_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret fd.SetWidth(4) lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("intfield"), fd, ogr.ALTER_ALL_FLAG) @@ -370,9 +327,6 @@ def test_ogr_rfc35_sqlite_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret fd = ogr.FieldDefn("oldintfld", ogr.OFTString) fd.SetWidth(15) @@ -387,9 +341,6 @@ def test_ogr_rfc35_sqlite_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret lyr.DeleteField(lyr_defn.GetFieldIndex("oldintfld")) @@ -423,9 +374,6 @@ def test_ogr_rfc35_sqlite_4(): feat = None ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret return 'success' @@ -464,27 +412,18 @@ def test_ogr_rfc35_sqlite_5(): return 'fail' ret = CheckFeatures(lyr, field3='baz5') - if ret != 'success': - gdaltest.post_reason('failed') - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('baw20')) != 0: gdaltest.post_reason('failed') return 'fail' ret = CheckFeatures(lyr, field3='baz5', field4=None) - if ret != 'success': - gdaltest.post_reason('failed') - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('baz5')) != 0: gdaltest.post_reason('failed') return 'fail' ret = CheckFeatures(lyr, field3=None, field4=None) - if ret != 'success': - gdaltest.post_reason('failed') - return ret if lyr.DeleteField(lyr_defn.GetFieldIndex('foo5')) != 0: gdaltest.post_reason('failed') @@ -495,9 +434,6 @@ def test_ogr_rfc35_sqlite_5(): return 'fail' ret = CheckFeatures(lyr, field1=None, field2=None, field3=None, field4=None) - if ret != 'success': - gdaltest.post_reason('failed') - return ret return 'success' diff --git a/autotest/ogr/ogr_s57.py b/autotest/ogr/ogr_s57.py index 14319197520a..efd38b5754b9 100755 --- a/autotest/ogr/ogr_s57.py +++ b/autotest/ogr/ogr_s57.py @@ -277,14 +277,10 @@ def test_ogr_s57_9(): return 'fail' gdaltest.s57_ds = ds - if test_ogr_s57_2() != 'success': - return 'fail' - if test_ogr_s57_3() != 'success': - return 'fail' - if test_ogr_s57_4() != 'success': - return 'fail' - if test_ogr_s57_5() != 'success': - return 'fail' + test_ogr_s57_2() + test_ogr_s57_3() + test_ogr_s57_4() + test_ogr_s57_5() gdaltest.s57_ds = None @@ -304,8 +300,7 @@ def test_ogr_s57_9(): return 'fail' gdaltest.s57_ds = ds - if test_ogr_s57_4() != 'success': - return 'fail' + test_ogr_s57_4() gdaltest.s57_ds = None diff --git a/autotest/ogr/ogr_selafin.py b/autotest/ogr/ogr_selafin.py index 858b295e3c54..aa3c5bffc9d1 100755 --- a/autotest/ogr/ogr_selafin.py +++ b/autotest/ogr/ogr_selafin.py @@ -63,8 +63,7 @@ def test_ogr_selafin_create_ds(): def test_ogr_selafin_create_nodes(): - if test_ogr_selafin_create_ds() != 'success': - return 'skip' + test_ogr_selafin_create_ds() ref = osr.SpatialReference() ref.ImportFromEPSG(4326) layer = gdaltest.selafin_ds.CreateLayer('name', ref, geom_type=ogr.wkbPoint) diff --git a/autotest/ogr/ogr_shape.py b/autotest/ogr/ogr_shape.py index b436c5db1d71..6fbb595021b4 100755 --- a/autotest/ogr/ogr_shape.py +++ b/autotest/ogr/ogr_shape.py @@ -2570,31 +2570,15 @@ def test_ogr_shape_54(): ds = ogr.Open(ds_name) for i in range(N): ret = ogr_shape_54_test_layer(ds, i) - if ret != 'success': - return ret # Now some 'random' access ret = ogr_shape_54_test_layer(ds, N - 1 - LRUListSize) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, N - LRUListSize / 2) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, N - LRUListSize / 4) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, 0) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, 0) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, 2) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, 1) - if ret != 'success': - return ret ds = None # Test adding a new layer @@ -2605,30 +2589,20 @@ def test_ogr_shape_54(): # Test accessing the new layer ds = ogr.Open(ds_name) ret = ogr_shape_54_test_layer(ds, N) - if ret != 'success': - return ret ds = None # Test deleting layers ds = ogr.Open(ds_name, update=1) for i in range(N): ret = ogr_shape_54_test_layer(ds, i) - if ret != 'success': - return ret for i in range(N - LRUListSize + 1, N): ds.ExecuteSQL('DROP TABLE layer%03d' % i) ret = ogr_shape_54_test_layer(ds, N - LRUListSize) - if ret != 'success': - return ret ogr_shape_54_create_layer(ds, N + 2) for i in range(0, N - LRUListSize + 1): ds.ExecuteSQL('DROP TABLE layer%03d' % i) ret = ogr_shape_54_test_layer(ds, N) - if ret != 'success': - return ret ret = ogr_shape_54_test_layer(ds, N + 2) - if ret != 'success': - return ret ds = None # Destroy and recreate datasource diff --git a/autotest/ogr/ogr_shape_sbn.py b/autotest/ogr/ogr_shape_sbn.py index 6ace12cd85da..02ffb2dd6e70 100755 --- a/autotest/ogr/ogr_shape_sbn.py +++ b/autotest/ogr/ogr_shape_sbn.py @@ -128,8 +128,6 @@ def test_ogr_shape_sbn_1(): for i in range(ds.GetLayerCount()): lyr = ds.GetLayer(i) ret = search_all_features(lyr) - if ret != 'success': - return ret return 'success' diff --git a/autotest/ogr/ogr_sql_sqlite.py b/autotest/ogr/ogr_sql_sqlite.py index 2e1faf4ea0d3..822ea2814767 100755 --- a/autotest/ogr/ogr_sql_sqlite.py +++ b/autotest/ogr/ogr_sql_sqlite.py @@ -534,16 +534,10 @@ def test_ogr_sql_sqlite_6(): gdal.SetConfigOption('OGR_SQLITE_DIALECT_USE_SPATIALITE', 'NO') ret = test_ogr_sql_sqlite_1() - if ret != 'success': - return ret ret = test_ogr_sql_sqlite_2() - if ret != 'success': - return ret ret = test_ogr_sql_sqlite_4() - if ret != 'success': - return ret gdal.SetConfigOption('OGR_SQLITE_DIALECT_USE_SPATIALITE', None) diff --git a/autotest/ogr/ogr_vrt.py b/autotest/ogr/ogr_vrt.py index 24c6db83e910..cd99dae7bcb5 100755 --- a/autotest/ogr/ogr_vrt.py +++ b/autotest/ogr/ogr_vrt.py @@ -1386,8 +1386,6 @@ def test_ogr_vrt_23(shared_ds_flag=''): def test_ogr_vrt_24(): ret = test_ogr_vrt_23(' shared="1"') - if ret != 'success': - return ret rec1 = """ diff --git a/autotest/ogr/ogr_wasp.py b/autotest/ogr/ogr_wasp.py index df638b5fc87c..70f3ff587a53 100755 --- a/autotest/ogr/ogr_wasp.py +++ b/autotest/ogr/ogr_wasp.py @@ -60,8 +60,7 @@ def test_ogr_wasp_create_ds(): def test_ogr_wasp_elevation_from_linestring_z(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() ref = osr.SpatialReference() ref.ImportFromProj4('+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356514.999978254 +pm=2.337229167 +units=m +no_defs') @@ -121,8 +120,7 @@ def test_ogr_wasp_elevation_from_linestring_z(): def test_ogr_wasp_elevation_from_linestring_z_toler(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() ref = osr.SpatialReference() ref.ImportFromProj4('+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356514.999978254 +pm=2.337229167 +units=m +no_defs') @@ -191,8 +189,7 @@ def test_ogr_wasp_elevation_from_linestring_z_toler(): def test_ogr_wasp_elevation_from_linestring_field(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() layer = gdaltest.wasp_ds.CreateLayer('mylayer', options=['WASP_FIELDS=elevation'], @@ -246,8 +243,7 @@ def test_ogr_wasp_elevation_from_linestring_field(): def test_ogr_wasp_roughness_from_linestring_fields(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() layer = gdaltest.wasp_ds.CreateLayer('mylayer', options=['WASP_FIELDS=z_left,z_right'], @@ -309,8 +305,7 @@ def test_ogr_wasp_roughness_from_linestring_fields(): def test_ogr_wasp_roughness_from_polygon_z(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() if not ogrtest.have_geos(): gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -379,8 +374,7 @@ def test_ogr_wasp_roughness_from_polygon_z(): def test_ogr_wasp_roughness_from_polygon_field(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() if not ogrtest.have_geos(): gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -454,8 +448,7 @@ def test_ogr_wasp_roughness_from_polygon_field(): def test_ogr_wasp_merge(): - if test_ogr_wasp_create_ds() != 'success': - return 'skip' + test_ogr_wasp_create_ds() if not ogrtest.have_geos(): gdal.PushErrorHandler('CPLQuietErrorHandler') @@ -523,8 +516,7 @@ def test_ogr_wasp_merge(): def test_ogr_wasp_reading(): - if test_ogr_wasp_elevation_from_linestring_z() != 'success': - return 'skip' + test_ogr_wasp_elevation_from_linestring_z() gdaltest.wasp_ds = None diff --git a/autotest/osr/osr_metacrs.py b/autotest/osr/osr_metacrs.py index 517cb4a32682..facb68035da2 100755 --- a/autotest/osr/osr_metacrs.py +++ b/autotest/osr/osr_metacrs.py @@ -59,8 +59,6 @@ def test_metacrs(self, test_line): self.dst_error = None result = self.parse_line() - if result != 'success': - return result try: gdal.PushErrorHandler('CPLQuietErrorHandler') diff --git a/autotest/pyscripts/test_gdal_ls_py.py b/autotest/pyscripts/test_gdal_ls_py.py index 8fb481cd8789..ab1c18b6f39d 100755 --- a/autotest/pyscripts/test_gdal_ls_py.py +++ b/autotest/pyscripts/test_gdal_ls_py.py @@ -79,9 +79,6 @@ def test_gdal_ls_py_1(): # TODO: Why the '' as the first element of the list here and below? ret, ret_str = run_gdal_ls(['', '-l', '../ogr/data/poly.shp']) - if ret != 'success': - return ret - if ret_str.find('poly.shp') == -1: print(ret_str) return 'fail' @@ -95,9 +92,6 @@ def test_gdal_ls_py_1(): def test_gdal_ls_py_2(): ret, ret_str = run_gdal_ls(['', '-l', '../ogr/data']) - if ret != 'success': - return ret - if ret_str.find('poly.shp') == -1: print(ret_str) return 'fail' @@ -111,9 +105,6 @@ def test_gdal_ls_py_2(): def test_gdal_ls_py_3(): ret, ret_str = run_gdal_ls(['', '-R', '../ogr/data']) - if ret != 'success': - return ret - if ret_str.find('PROJ_UNITS') == -1: print(ret_str) return 'fail' @@ -127,9 +118,6 @@ def test_gdal_ls_py_3(): def test_gdal_ls_py_4(): ret, ret_str = run_gdal_ls(['', '-l', '/vsizip/../ogr/data/poly.zip']) - if ret != 'success': - return ret - if ret_str.find('-r--r--r-- 1 unknown unknown 415 2008-02-11 21:35 /vsizip/../ogr/data/poly.zip/poly.PRJ') == -1: print(ret_str) if gdaltest.skip_on_travis(): @@ -194,9 +182,6 @@ def test_gdal_ls_py_6(): ret, ret_str = run_gdal_ls(['', '-l', '/vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip']) - if ret != 'success': - return ret - if ret_str.find('-r--r--r-- 1 unknown unknown 415 2008-02-11 21:35 /vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip/poly.PRJ') == -1: print(ret_str) if gdaltest.skip_on_travis(): @@ -272,9 +257,6 @@ def test_gdal_ls_py_8(): ret, ret_str = run_gdal_ls(['', '-l', '-R', '-Rzip', 'ftp://download.osgeo.org/gdal/data/aig']) - if ret != 'success': - return ret - if ret_str.find('-r--r--r-- 1 unknown unknown 24576 2007-03-29 00:00 /vsicurl/ftp://download.osgeo.org/gdal/data/aig/nzdem/info/arc0002r.001') == -1: print(ret_str) return 'fail' From 81a03cb9af98768c9f5b2a5c8a35fa23df42fddf Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Mon, 10 Dec 2018 09:22:41 +1300 Subject: [PATCH 137/488] Automated: Remove useless `post_reason() calls gdaltest.post_reason('fail') isn't a useful reason to keep. --- autotest/alg/applyverticalshiftgrid.py | 32 -- autotest/alg/contour.py | 1 - autotest/alg/reproject.py | 2 - autotest/alg/warp.py | 17 - autotest/gcore/basic_test.py | 70 ---- autotest/gcore/gdal_api_proxy.py | 90 ----- autotest/gcore/hfa_write.py | 6 - autotest/gcore/mask.py | 12 - autotest/gcore/misc.py | 3 - autotest/gcore/nodatamaskband.py | 5 - autotest/gcore/numpy_rw.py | 17 - autotest/gcore/overviewds.py | 27 -- autotest/gcore/pam.py | 7 - autotest/gcore/pixfun.py | 2 - autotest/gcore/rasterio.py | 73 ---- autotest/gcore/testnonboundtoswig.py | 6 - autotest/gcore/tiff_ovr.py | 17 - autotest/gcore/tiff_read.py | 109 ------ autotest/gcore/tiff_srs.py | 15 - autotest/gcore/tiff_write.py | 274 ------------- autotest/gcore/transformer.py | 13 - autotest/gcore/virtualmem.py | 12 - autotest/gcore/vrt_read.py | 49 --- autotest/gcore/vrtmisc.py | 30 -- autotest/gcore/vsiaz.py | 78 ---- autotest/gcore/vsicrypt.py | 39 -- autotest/gcore/vsicurl.py | 11 - autotest/gcore/vsicurl_streaming.py | 15 - autotest/gcore/vsifile.py | 101 ----- autotest/gcore/vsigs.py | 76 ---- autotest/gcore/vsioss.py | 110 ------ autotest/gcore/vsis3.py | 196 ---------- autotest/gcore/vsistdin.py | 2 - autotest/gcore/vsiswift.py | 58 --- autotest/gcore/vsiwebhdfs.py | 55 --- autotest/gcore/vsizip.py | 36 -- autotest/gdrivers/aaigrid.py | 6 - autotest/gdrivers/bag.py | 63 --- autotest/gdrivers/cals.py | 13 - autotest/gdrivers/db2.py | 6 - autotest/gdrivers/derived.py | 13 - autotest/gdrivers/ecrgtoc.py | 3 - autotest/gdrivers/ecw.py | 60 --- autotest/gdrivers/eedai.py | 21 - autotest/gdrivers/ehdr.py | 11 - autotest/gdrivers/ers.py | 1 - autotest/gdrivers/gdalhttp.py | 4 - autotest/gdrivers/gpkg.py | 300 -------------- autotest/gdrivers/grib.py | 17 - autotest/gdrivers/hdf5.py | 11 - autotest/gdrivers/ignfheightasciigrid.py | 5 - autotest/gdrivers/ingr.py | 3 - autotest/gdrivers/iris.py | 2 - autotest/gdrivers/isis.py | 125 ------ autotest/gdrivers/jp2kak.py | 9 - autotest/gdrivers/jp2lura.py | 121 ------ autotest/gdrivers/jp2openjpeg.py | 209 ---------- autotest/gdrivers/jpeg.py | 55 --- autotest/gdrivers/jpeg2000.py | 5 - autotest/gdrivers/jpeg_profile.py | 11 - autotest/gdrivers/kea.py | 97 ----- autotest/gdrivers/kmlsuperoverlay.py | 19 - autotest/gdrivers/l1b.py | 11 - autotest/gdrivers/mbtiles.py | 30 -- autotest/gdrivers/mem.py | 71 ---- autotest/gdrivers/mrf.py | 26 -- autotest/gdrivers/netcdf.py | 70 ---- autotest/gdrivers/nitf.py | 9 - autotest/gdrivers/ntv2.py | 4 - autotest/gdrivers/pcidsk.py | 15 - autotest/gdrivers/pdf.py | 36 -- autotest/gdrivers/pds.py | 4 - autotest/gdrivers/pds4.py | 57 --- autotest/gdrivers/plmosaic.py | 56 --- autotest/gdrivers/png.py | 10 - autotest/gdrivers/png_profile.py | 22 -- autotest/gdrivers/postgisraster.py | 10 - autotest/gdrivers/rda.py | 99 ----- autotest/gdrivers/rl2.py | 37 -- autotest/gdrivers/rraster.py | 14 - autotest/gdrivers/rs2.py | 1 - autotest/gdrivers/sentinel2.py | 206 ---------- autotest/gdrivers/srp.py | 6 - autotest/gdrivers/srtmhgt.py | 1 - autotest/gdrivers/tiff_profile.py | 29 -- autotest/gdrivers/vicar.py | 6 - autotest/gdrivers/vrtderived.py | 14 - autotest/gdrivers/vrtmask.py | 1 - autotest/gdrivers/vrtovr.py | 4 - autotest/gdrivers/vrtpansharpen.py | 81 ---- autotest/gdrivers/vrtrawlink.py | 1 - autotest/gdrivers/vrtwarp.py | 31 -- autotest/gdrivers/wmts.py | 109 ------ autotest/gdrivers/xyz.py | 14 - autotest/gnm/gnm_test.py | 2 - autotest/ogr/ogr_avc.py | 9 - autotest/ogr/ogr_basic_test.py | 32 -- autotest/ogr/ogr_cad.py | 2 - autotest/ogr/ogr_carto.py | 118 ------ autotest/ogr/ogr_couchdb.py | 4 - autotest/ogr/ogr_csv.py | 167 -------- autotest/ogr/ogr_csw.py | 40 -- autotest/ogr/ogr_dgnv8.py | 9 - autotest/ogr/ogr_dxf.py | 56 --- autotest/ogr/ogr_eeda.py | 20 - autotest/ogr/ogr_elasticsearch.py | 132 ------- autotest/ogr/ogr_factory.py | 2 - autotest/ogr/ogr_feature.py | 62 --- autotest/ogr/ogr_fgdb.py | 182 --------- autotest/ogr/ogr_fgdb_stress_test.py | 6 - autotest/ogr/ogr_geojson.py | 180 --------- autotest/ogr/ogr_geojsonseq.py | 12 - autotest/ogr/ogr_geom.py | 367 ------------------ autotest/ogr/ogr_gml_geom.py | 18 - autotest/ogr/ogr_gml_read.py | 179 --------- autotest/ogr/ogr_gmlas.py | 292 -------------- autotest/ogr/ogr_gpkg.py | 358 +---------------- autotest/ogr/ogr_idrisi.py | 40 -- autotest/ogr/ogr_index_test.py | 19 - autotest/ogr/ogr_jml.py | 28 -- autotest/ogr/ogr_join_test.py | 5 - autotest/ogr/ogr_kml.py | 16 - autotest/ogr/ogr_libkml.py | 65 ---- autotest/ogr/ogr_mem.py | 47 --- autotest/ogr/ogr_mitab.py | 115 ------ autotest/ogr/ogr_mongodb.py | 78 ---- autotest/ogr/ogr_mssqlspatial.py | 2 - autotest/ogr/ogr_mvt.py | 116 ------ autotest/ogr/ogr_mysql.py | 22 -- autotest/ogr/ogr_oci.py | 29 -- autotest/ogr/ogr_odbc.py | 10 - autotest/ogr/ogr_ods.py | 28 -- autotest/ogr/ogr_openfilegdb.py | 97 ----- autotest/ogr/ogr_osm.py | 73 ---- autotest/ogr/ogr_pcidsk.py | 23 -- autotest/ogr/ogr_pdf.py | 23 -- autotest/ogr/ogr_pg.py | 240 ------------ autotest/ogr/ogr_pgdump.py | 29 -- autotest/ogr/ogr_plscenes.py | 68 ---- autotest/ogr/ogr_rfc35_mitab.py | 26 -- autotest/ogr/ogr_rfc35_sqlite.py | 23 -- autotest/ogr/ogr_rfc41.py | 176 --------- autotest/ogr/ogr_s57.py | 2 - autotest/ogr/ogr_segy.py | 8 - autotest/ogr/ogr_shape.py | 157 -------- autotest/ogr/ogr_sql_rfc28.py | 85 ---- autotest/ogr/ogr_sql_sqlite.py | 70 ---- autotest/ogr/ogr_sql_test.py | 36 -- autotest/ogr/ogr_sqlite.py | 169 -------- autotest/ogr/ogr_style.py | 16 - autotest/ogr/ogr_tiger.py | 3 - autotest/ogr/ogr_vdv.py | 32 -- autotest/ogr/ogr_virtualogr.py | 20 - autotest/ogr/ogr_vrt.py | 156 -------- autotest/ogr/ogr_wfs.py | 229 ----------- autotest/ogr/ogr_wfs3.py | 29 -- autotest/ogr/ogr_wkbwkt_geom.py | 2 - autotest/ogr/ogr_xls.py | 10 - autotest/ogr/ogr_xlsx.py | 22 -- autotest/ogr/ograpispy.py | 3 - autotest/osr/osr_basic.py | 45 --- autotest/osr/osr_compd.py | 1 - autotest/osr/osr_epsg.py | 17 - autotest/osr/osr_esri.py | 10 - autotest/osr/osr_micoordsys.py | 3 - autotest/osr/osr_proj4.py | 23 -- autotest/pymod/ogrtest.py | 2 - autotest/pyscripts/test_gdal_calc.py | 2 - autotest/pyscripts/test_gdal_edit.py | 30 -- autotest/pyscripts/test_gdal_pansharpen.py | 2 - autotest/pyscripts/test_gdal_polygonize.py | 2 - autotest/pyscripts/test_gdal_retile.py | 4 - autotest/pyscripts/test_ogr2ogr_py.py | 6 - autotest/pyscripts/test_ogrmerge.py | 25 -- autotest/utilities/test_gdal_grid_lib.py | 2 - autotest/utilities/test_gdal_rasterize_lib.py | 6 - autotest/utilities/test_gdal_translate.py | 16 - autotest/utilities/test_gdal_translate_lib.py | 12 - autotest/utilities/test_gdaladdo.py | 3 - autotest/utilities/test_gdalbuildvrt.py | 4 - autotest/utilities/test_gdaldem.py | 3 - autotest/utilities/test_gdalinfo.py | 4 - autotest/utilities/test_gdalinfo_lib.py | 4 - autotest/utilities/test_gdalsrsinfo.py | 3 - autotest/utilities/test_gdaltindex.py | 5 - autotest/utilities/test_gdalwarp.py | 26 -- autotest/utilities/test_gdalwarp_lib.py | 30 -- autotest/utilities/test_gnmutils.py | 3 - autotest/utilities/test_nearblack_lib.py | 1 - autotest/utilities/test_ogr2ogr.py | 47 --- autotest/utilities/test_ogr2ogr_lib.py | 11 - autotest/utilities/test_ogrinfo.py | 10 - autotest/utilities/test_ogrtindex.py | 1 - 193 files changed, 1 insertion(+), 8999 deletions(-) diff --git a/autotest/alg/applyverticalshiftgrid.py b/autotest/alg/applyverticalshiftgrid.py index 82c459452881..4dc642755058 100755 --- a/autotest/alg/applyverticalshiftgrid.py +++ b/autotest/alg/applyverticalshiftgrid.py @@ -47,23 +47,18 @@ def test_applyverticalshiftgrid_1(): grid_ds = gdal.Translate('', src_ds, format='MEM') out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds.GetRasterBand(1).DataType != gdal.GDT_Byte: - gdaltest.post_reason('fail') print(out_ds.GetRasterBand(1).DataType) return 'fail' if out_ds.RasterXSize != src_ds.RasterXSize: - gdaltest.post_reason('fail') print(out_ds.RasterXSize) return 'fail' if out_ds.RasterYSize != src_ds.RasterYSize: - gdaltest.post_reason('fail') print(out_ds.RasterYSize) return 'fail' if out_ds.GetGeoTransform() != src_ds.GetGeoTransform(): - gdaltest.post_reason('fail') print(out_ds.GetGeoTransform()) return 'fail' if out_ds.GetProjectionRef() != src_ds.GetProjectionRef(): - gdaltest.post_reason('fail') print(out_ds.GetProjectionRef()) return 'fail' # Check that we can drop the reference to the sources @@ -72,7 +67,6 @@ def test_applyverticalshiftgrid_1(): cs = out_ds.GetRasterBand(1).Checksum() if cs != 10038: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -85,7 +79,6 @@ def test_applyverticalshiftgrid_1(): options=['BLOCKSIZE=15']) cs = out_ds.GetRasterBand(1).Checksum() if cs != 10038: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -93,12 +86,10 @@ def test_applyverticalshiftgrid_1(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, src_ds, True, options=['DATATYPE=Float32']) if out_ds.GetRasterBand(1).DataType != gdal.GDT_Float32: - gdaltest.post_reason('fail') print(out_ds.GetRasterBand(1).DataType) return 'fail' cs = out_ds.GetRasterBand(1).Checksum() if cs != 0: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -130,7 +121,6 @@ def test_applyverticalshiftgrid_2(): with gdaltest.error_handler(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds is not None: - gdaltest.post_reason('fail') print(i) return 'fail' @@ -144,7 +134,6 @@ def test_applyverticalshiftgrid_2(): with gdaltest.error_handler(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Non invertable grid geotransform @@ -157,7 +146,6 @@ def test_applyverticalshiftgrid_2(): with gdaltest.error_handler(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # No PROJ.4 translation for source SRS, coordinate transformation @@ -171,7 +159,6 @@ def test_applyverticalshiftgrid_2(): with gdaltest.error_handler(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Out of memory @@ -186,7 +173,6 @@ def test_applyverticalshiftgrid_2(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds, options=['BLOCKSIZE=2000000000']) if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Wrong DATATYPE @@ -200,7 +186,6 @@ def test_applyverticalshiftgrid_2(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds, options=['DATATYPE=x']) if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -217,24 +202,19 @@ def test_applyverticalshiftgrid_3(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds, options=['RESAMPLING=NEAREST']) if out_ds.RasterXSize != src_ds.RasterXSize: - gdaltest.post_reason('fail') print(out_ds.RasterXSize) return 'fail' if out_ds.RasterYSize != src_ds.RasterYSize: - gdaltest.post_reason('fail') print(out_ds.RasterYSize) return 'fail' if out_ds.GetGeoTransform() != src_ds.GetGeoTransform(): - gdaltest.post_reason('fail') print(out_ds.GetGeoTransform()) return 'fail' if out_ds.GetProjectionRef() != src_ds.GetProjectionRef(): - gdaltest.post_reason('fail') print(out_ds.GetProjectionRef()) return 'fail' cs = out_ds.GetRasterBand(1).Checksum() if cs != 5112: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -242,7 +222,6 @@ def test_applyverticalshiftgrid_3(): options=['RESAMPLING=BILINEAR']) cs = out_ds.GetRasterBand(1).Checksum() if cs != 4867 and cs != 4868: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -250,7 +229,6 @@ def test_applyverticalshiftgrid_3(): options=['RESAMPLING=CUBIC']) cs = out_ds.GetRasterBand(1).Checksum() if cs != 4841 and cs != 4854: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -277,12 +255,10 @@ def test_applyverticalshiftgrid_4(): grid_ds.GetRasterBand(1).Fill(30) out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds.GetRasterBand(1).GetNoDataValue() != 1: - gdaltest.post_reason('fail') print(out_ds.GetRasterBand(1).GetNoDataValue()) return 'fail' cs = out_ds.GetRasterBand(1).Checksum() if cs != 1: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -298,12 +274,10 @@ def test_applyverticalshiftgrid_4(): grid_ds.GetRasterBand(1).SetNoDataValue(30) out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) if out_ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') print(out_ds.GetRasterBand(1).GetNoDataValue()) return 'fail' cs = out_ds.GetRasterBand(1).Checksum() if cs != 1: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -320,7 +294,6 @@ def test_applyverticalshiftgrid_4(): with gdaltest.error_handler(): data = out_ds.GetRasterBand(1).ReadRaster() if data is not None: - gdaltest.post_reason('fail') return 'fail' # ERROR_ON_MISSING_VERT_SHIFT due to nodata in grid @@ -337,7 +310,6 @@ def test_applyverticalshiftgrid_4(): with gdaltest.error_handler(): data = out_ds.GetRasterBand(1).ReadRaster() if data is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -357,7 +329,6 @@ def test_applyverticalshiftgrid_5(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds, srcUnitToMeter=2) cs = out_ds.GetRasterBand(1).Checksum() if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -370,7 +341,6 @@ def test_applyverticalshiftgrid_5(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds, dstUnitToMeter=0.5) cs = out_ds.GetRasterBand(1).Checksum() if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -392,7 +362,6 @@ def test_applyverticalshiftgrid_6(): dstSRS='+proj=utm +zone=11 +datum=NAD27 +geoidgrids=/vsimem/applyverticalshiftgrid_6.gtx +vunits=m +no_defs') cs = ds.GetRasterBand(1).Checksum() if cs != 4783: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -416,7 +385,6 @@ def test_applyverticalshiftgrid_7(): dstSRS='+proj=utm +zone=11 +datum=NAD27 +geoidgrids=/vsimem/applyverticalshiftgrid_7.gtx +vunits=m +no_defs') cs = ds.GetRasterBand(1).Checksum() if cs != 4783: - gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/autotest/alg/contour.py b/autotest/alg/contour.py index fa8664e58298..2b749d083578 100755 --- a/autotest/alg/contour.py +++ b/autotest/alg/contour.py @@ -216,7 +216,6 @@ def test_contour_real_world_case(): ogr_lyr.SetAttributeFilter('elev = 330') if ogr_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' f = ogr_lyr.GetNextFeature() if ogrtest.check_feature_geometry(f, 'LINESTRING (4.50497512437811 11.5,4.5 11.501996007984,3.5 11.8333333333333,2.5 11.5049751243781,2.490099009901 11.5,2.0 10.5,2.5 10.1666666666667,3.0 9.5,3.5 9.21428571428571,4.49800399201597 8.5,4.5 8.49857346647646,5.5 8.16666666666667,6.5 8.0,7.5 8.0,8.0 7.5,8.5 7.0,9.490099009901 6.5,9.5 6.49667774086379,10.5 6.16666666666667,11.4950248756219 5.5,11.5 5.49833610648919,12.5 5.49667774086379,13.5 5.49800399201597,13.501996007984 5.5,13.5 5.50199600798403,12.501996007984 6.5,12.5 6.50142653352354,11.5 6.509900990099,10.509900990099 7.5,10.5 7.50142653352354,9.5 7.9,8.50332225913621 8.5,8.5 8.50249376558603,7.83333333333333 9.5,7.5 10.0,7.0 10.5,6.5 10.7857142857143,5.5 11.1666666666667,4.50497512437811 11.5)', 0.01) != 0: diff --git a/autotest/alg/reproject.py b/autotest/alg/reproject.py index c01495cf058a..045ddf8775df 100755 --- a/autotest/alg/reproject.py +++ b/autotest/alg/reproject.py @@ -119,7 +119,6 @@ def test_reproject_3(): got_data = dst_ds.GetRasterBand(1).ReadRaster(0, 0, 6, 3).decode('latin1') expected_data = '\x03\x7f\x7f\x7f\x03\x03\x03\x7f\x7f\x7f\x03\x03\x03\x7f\x7f\x7f\x03\x03' if got_data != expected_data: - gdaltest.post_reason('fail') import struct print(struct.unpack('B' * 18, got_data)) return 'fail' @@ -146,7 +145,6 @@ def test_reproject_4(): got_data = dst_ds.GetRasterBand(1).ReadRaster(0, 0, 6, 3).decode('latin1') expected_data = '\x03\x7f\x7f\x7f\x03\x03\x03\x7f\x7f\x7f\x03\x03\x03\x7f\x7f\x7f\x03\x03' if got_data != expected_data: - gdaltest.post_reason('fail') import struct print(struct.unpack('B' * 18, got_data)) return 'fail' diff --git a/autotest/alg/warp.py b/autotest/alg/warp.py index 8100815ff267..56c0a87ad32c 100755 --- a/autotest/alg/warp.py +++ b/autotest/alg/warp.py @@ -1110,7 +1110,6 @@ def test_warp_29(): gdal.SetConfigOption('WARP_THREAD_CHUNK_SIZE', None) if cs_monothread != cs_multithread: - gdaltest.post_reason('failed') return 'fail' old_val = gdal.GetConfigOption('GDAL_NUM_THREADS') @@ -1123,7 +1122,6 @@ def test_warp_29(): gdal.SetConfigOption('WARP_THREAD_CHUNK_SIZE', None) if cs_monothread != cs_multithread: - gdaltest.post_reason('failed') return 'fail' src_ds = gdal.Open('../gcore/data/byte.tif') @@ -1138,7 +1136,6 @@ def test_warp_29(): ds = None if got_cs != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('failed') return 'fail' ds = gdal.Open('data/byte_tps.vrt') @@ -1151,7 +1148,6 @@ def test_warp_29(): ds = None if got_cs != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('failed') return 'fail' src_ds = None @@ -1215,7 +1211,6 @@ def test_warp_30(): gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('failed') return 'fail' old_val = gdal.GetConfigOption('GDAL_NUM_THREADS') @@ -1234,7 +1229,6 @@ def test_warp_30(): gdal.SetConfigOption('GDAL_NUM_THREADS', old_val) if ret == 0: - gdaltest.post_reason('failed') return 'fail' gdal.Unlink('/vsimem/warp_30.tif') @@ -1386,7 +1380,6 @@ def test_warp_37(): gdal.PopErrorHandler() gdal.ErrorReset() if tmp_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Incompatible projection (UTM 40 is on the other side of the earth w.r.t UTM 11) @@ -1400,7 +1393,6 @@ def test_warp_37(): gdal.PopErrorHandler() gdal.ErrorReset() if tmp_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1520,16 +1512,13 @@ def test_warp_41(): vrt_ds = gdal.AutoCreateWarpedVRT(src_ds, None, None, gdal.GRA_NearestNeighbour, 0.3) if vrt_ds.RasterXSize != src_ds.RasterXSize: - gdaltest.post_reason('fail') return 'fail' if vrt_ds.RasterYSize != src_ds.RasterYSize: - gdaltest.post_reason('fail') return 'fail' src_gt = src_ds.GetGeoTransform() vrt_gt = vrt_ds.GetGeoTransform() for i in range(6): if abs(src_gt[i] - vrt_gt[i]) > 1e-5: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1792,7 +1781,6 @@ def test_warp_52(): cs = out_ds.GetRasterBand(4).Checksum() if cs != 3188: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1829,7 +1817,6 @@ def test_warp_53(): cs1 = dst_ds.GetRasterBand(1).Checksum() cs2 = dst_ds.GetRasterBand(2).Checksum() if cs1 not in expected_cs or cs2 not in [3903, 4138]: - gdaltest.post_reason('fail') print(typestr) print(option) print(alg_name) @@ -1853,7 +1840,6 @@ def test_warp_54(): expected_cs = src_ds.GetRasterBand(i + 1).Checksum() got_cs = dst_ds.GetRasterBand(i + 1).Checksum() if expected_cs != got_cs: - gdaltest.post_reason('fail') print(i) print(got_cs) print(expected_cs) @@ -1867,7 +1853,6 @@ def test_warp_54(): expected_cs = src_ds.GetRasterBand(i + 1).Checksum() got_cs = dst_ds.GetRasterBand(i + 1).Checksum() if expected_cs != got_cs: - gdaltest.post_reason('fail') print(i) print(got_cs) print(expected_cs) @@ -1883,7 +1868,6 @@ def test_warp_54(): expected_cs = src_ds.GetRasterBand(i + 1).Checksum() got_cs = dst_ds.GetRasterBand(i + 1).Checksum() if expected_cs != got_cs: - gdaltest.post_reason('fail') print(i) print(got_cs) print(expected_cs) @@ -1904,7 +1888,6 @@ def test_warp_55(): ds = gdal.Open('data/warpedvrt_with_ovr.vrt') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 25128: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None diff --git a/autotest/gcore/basic_test.py b/autotest/gcore/basic_test.py index 0756ac2fdea0..6974d8be255b 100755 --- a/autotest/gcore/basic_test.py +++ b/autotest/gcore/basic_test.py @@ -181,7 +181,6 @@ def test_basic_test_8(): ret = gdal.VersionInfo('RELEASE_DATE') if len(ret) != 8: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -191,7 +190,6 @@ def test_basic_test_8(): ret = gdaltest.runexternal(python_exe + ' basic_test.py LICENSE 0') if ret.find('GDAL/OGR is released under the MIT/X license') != 0 and ret.find('GDAL/OGR Licensing') < 0: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -201,7 +199,6 @@ def test_basic_test_8(): ret = gdaltest.runexternal(python_exe + ' basic_test.py LICENSE 1') os.unlink('tmp/LICENSE.TXT') if ret.find('fake_license') != 0 and ret.find('GDAL/OGR Licensing') < 0: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -227,15 +224,12 @@ def test_basic_test_9(): gdal.PopErrorHandler() if gdaltest.eErrClass != 1: - gdaltest.post_reason('fail') return 'fail' if gdaltest.err_no != 2: - gdaltest.post_reason('fail') return 'fail' if gdaltest.msg != 'test': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -269,15 +263,12 @@ def test_basic_test_10(): gdal.PopErrorHandler() if error_handler.eErrClass != 1: - gdaltest.post_reason('fail') return 'fail' if error_handler.err_no != 2: - gdaltest.post_reason('fail') return 'fail' if error_handler.msg != 'test': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -290,103 +281,83 @@ def test_basic_test_11(): ds = gdal.OpenEx('data/byte.tif') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', gdal.OF_RASTER) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', gdal.OF_VECTOR) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', gdal.OF_RASTER | gdal.OF_VECTOR) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', gdal.OF_ALL) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', gdal.OF_UPDATE) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', gdal.OF_RASTER | gdal.OF_VECTOR | gdal.OF_UPDATE | gdal.OF_VERBOSE_ERROR) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', allowed_drivers=[]) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', allowed_drivers=['GTiff']) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/byte.tif', allowed_drivers=['PNG']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.OpenEx('data/byte.tif', open_options=['FOO']) if ds is None: - gdaltest.post_reason('fail') return 'fail' ar_ds = [gdal.OpenEx('data/byte.tif', gdal.OF_SHARED) for _ in range(1024)] if ar_ds[1023] is None: - gdaltest.post_reason('fail') return 'fail' ar_ds = None ds = gdal.OpenEx('../ogr/data/poly.shp', gdal.OF_RASTER) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('../ogr/data/poly.shp', gdal.OF_VECTOR) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayer(0) is None: - gdaltest.post_reason('fail') return 'fail' ds.GetLayer(0).GetMetadata() ds = gdal.OpenEx('../ogr/data/poly.shp', allowed_drivers=['ESRI Shapefile']) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('../ogr/data/poly.shp', gdal.OF_RASTER | gdal.OF_VECTOR) if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('non existing') if ds is not None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ds = gdal.OpenEx('non existing', gdal.OF_VERBOSE_ERROR) gdal.PopErrorHandler() if ds is not None or gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' old_use_exceptions_status = gdal.GetUseExceptions() @@ -399,7 +370,6 @@ def test_basic_test_11(): if old_use_exceptions_status == 0: gdal.DontUseExceptions() if not got_exception: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -412,50 +382,38 @@ def test_basic_test_12(): ds = gdal.GetDriverByName('MEMORY').Create('bar', 0, 0, 0) if ds.GetDescription() != 'bar': - gdaltest.post_reason('failure') print(ds.GetDescription()) return 'fail' lyr = ds.CreateLayer("foo") if lyr is None: - gdaltest.post_reason('failure') return 'fail' if lyr.GetDescription() != 'foo': - gdaltest.post_reason('failure') print(lyr.GetDescription()) return 'fail' from osgeo import ogr if lyr.TestCapability(ogr.OLCCreateField) != 1: - gdaltest.post_reason('failure') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayerByName("foo") if lyr is None: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayerByIndex(0) if lyr is None: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayer(0) if lyr is None: - gdaltest.post_reason('failure') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT * FROM foo') if sql_lyr is None: - gdaltest.post_reason('failure') return 'fail' ds.ReleaseResultSet(sql_lyr) new_lyr = ds.CopyLayer(lyr, 'bar') if new_lyr is None: - gdaltest.post_reason('failure') return 'fail' if ds.DeleteLayer(0) != 0: - gdaltest.post_reason('failure') return 'fail' if ds.DeleteLayer('bar') != 0: - gdaltest.post_reason('failure') return 'fail' ds.SetStyleTable(ds.GetStyleTable()) ds = None @@ -484,19 +442,14 @@ def test_basic_test_13(): ds.SetMetadataItem("ScaleBounds.MaxScale", "2000000") if ds.GetMetadataItem('scalebounds') != 'True': - gdaltest.post_reason('failure') return 'fail' if ds.GetMetadataItem('ScaleBounds') != 'True': - gdaltest.post_reason('failure') return 'fail' if ds.GetMetadataItem('SCALEBOUNDS') != 'True': - gdaltest.post_reason('failure') return 'fail' if ds.GetMetadataItem('ScaleBounds.MinScale') != '0': - gdaltest.post_reason('failure') return 'fail' if ds.GetMetadataItem('ScaleBounds.MaxScale') != '2000000': - gdaltest.post_reason('failure') return 'fail' ds = None @@ -505,7 +458,6 @@ def test_basic_test_13(): ds.SetMetadataItem("FILENAME_%d" % i, "%d" % i) for i in range(200): if ds.GetMetadataItem("FILENAME_%d" % i) != '%d' % i: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -520,50 +472,42 @@ def test_basic_test_14(): ds.SetMetadata('foo') if ds.GetMetadata_List() != ['foo']: - gdaltest.post_reason('failure') return 'fail' try: ds.SetMetadata(5) - gdaltest.post_reason('failure') return 'fail' except: pass ds.SetMetadata(['foo=bar']) if ds.GetMetadata_List() != ['foo=bar']: - gdaltest.post_reason('failure') return 'fail' try: ds.SetMetadata([5]) - gdaltest.post_reason('failure') return 'fail' except: pass ds.SetMetadata({'foo': 'baz'}) if ds.GetMetadata_List() != ['foo=baz']: - gdaltest.post_reason('failure') return 'fail' try: ds.SetMetadata({'foo': 5}) - gdaltest.post_reason('failure') return 'fail' except: pass try: ds.SetMetadata({5: 'baz'}) - gdaltest.post_reason('failure') return 'fail' except: pass try: ds.SetMetadata({5: 6}) - gdaltest.post_reason('failure') return 'fail' except: pass @@ -575,24 +519,20 @@ def test_basic_test_14(): ds.SetMetadata({'bar': val}) if ds.GetMetadata()['bar'] != val: - gdaltest.post_reason('failure') return 'fail' ds.SetMetadata({val: 'baz'}) if ds.GetMetadata()[val] != 'baz': - gdaltest.post_reason('failure') return 'fail' try: ds.SetMetadata({val: 5}) - gdaltest.post_reason('failure') return 'fail' except: pass try: ds.SetMetadata({5: val}) - gdaltest.post_reason('failure') return 'fail' except: pass @@ -622,7 +562,6 @@ def test_basic_test_15(): try: with gdaltest.error_handler(): gdal.GetDriverByName('MEM').CreateCopy('', gdal.GetDriverByName('MEM').Create('', 1, 1), callback='foo') - gdaltest.post_reason('fail') return 'fail' except: pass @@ -630,19 +569,16 @@ def test_basic_test_15(): with gdaltest.error_handler(): ds = gdal.GetDriverByName('MEM').CreateCopy('', gdal.GetDriverByName('MEM').Create('', 1, 1), callback=basic_test_15_cbk_no_argument) if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.GetDriverByName('MEM').CreateCopy('', gdal.GetDriverByName('MEM').Create('', 1, 1), callback=basic_test_15_cbk_no_ret) if ds is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.GetDriverByName('MEM').CreateCopy('', gdal.GetDriverByName('MEM').Create('', 1, 1), callback=basic_test_15_cbk_bad_ret) if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -656,7 +592,6 @@ def test_basic_test_16(): gdal.ErrorReset() gdal.OpenEx('data/byte.tif', open_options=['@UNRECOGNIZED=FOO']) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -665,7 +600,6 @@ def test_basic_test_16(): gdal.OpenEx('/vsimem/temp.tif', gdal.OF_UPDATE, open_options=['@NUM_THREADS=INVALID']) gdal.Unlink('/vsimem/temp.tif') if gdal.GetLastErrorMsg() != 'Invalid value for NUM_THREADS: INVALID': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -689,10 +623,8 @@ def test_basic_test_17(): gdal.DontUseExceptions() ogr.DontUseExceptions() if gdal.GetUseExceptions(): - gdaltest.post_reason('fail') return 'fail' if ogr.GetUseExceptions(): - gdaltest.post_reason('fail') return 'fail' for _ in range(2): @@ -714,10 +646,8 @@ def test_basic_test_17(): gdaltest.post_reason('expected failure') return 'fail' if gdal.GetUseExceptions(): - gdaltest.post_reason('fail') return 'fail' if ogr.GetUseExceptions(): - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gcore/gdal_api_proxy.py b/autotest/gcore/gdal_api_proxy.py index 9b886389d6cb..9f3b49b72bd1 100755 --- a/autotest/gcore/gdal_api_proxy.py +++ b/autotest/gcore/gdal_api_proxy.py @@ -137,7 +137,6 @@ def test_gdal_api_proxy_sub(): drv = gdal.IdentifyDriver('data/byte.tif') if drv.GetDescription() != 'API_PROXY': - gdaltest.post_reason('fail') return 'fail' ds = gdal.GetDriverByName('GTiff').Create('tmp/byte.tif', 1, 1, 3) @@ -147,7 +146,6 @@ def test_gdal_api_proxy_sub(): ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/byte.tif', src_ds, options=['TILED=YES']) got_cs = ds.GetRasterBand(1).Checksum() if src_cs != got_cs: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -156,26 +154,21 @@ def test_gdal_api_proxy_sub(): ds.SetGeoTransform([1, 2, 3, 4, 5, 6]) got_gt = ds.GetGeoTransform() if src_gt == got_gt: - gdaltest.post_reason('fail') return 'fail' ds.SetGeoTransform(src_gt) got_gt = ds.GetGeoTransform() if src_gt != got_gt: - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPProjection() != '': print(ds.GetGCPProjection()) - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' gcps = [gdal.GCP(0, 1, 2, 3, 4)] @@ -183,37 +176,31 @@ def test_gdal_api_proxy_sub(): got_gcps = ds.GetGCPs() if len(got_gcps) != 1: - gdaltest.post_reason('fail') return 'fail' if got_gcps[0].GCPLine != gcps[0].GCPLine or \ got_gcps[0].GCPPixel != gcps[0].GCPPixel or \ got_gcps[0].GCPX != gcps[0].GCPX or \ got_gcps[0].GCPY != gcps[0].GCPY: - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPProjection() != 'foo': - gdaltest.post_reason('fail') print(ds.GetGCPProjection()) return 'fail' ds.SetGCPs([], "") if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' ds.SetProjection('') got_prj = ds.GetProjectionRef() if src_prj == got_prj: - gdaltest.post_reason('fail') return 'fail' ds.SetProjection(src_prj) got_prj = ds.GetProjectionRef() if src_prj != got_prj: - gdaltest.post_reason('fail') print(src_prj) print(got_prj) return 'fail' @@ -221,25 +208,21 @@ def test_gdal_api_proxy_sub(): ds.GetRasterBand(1).Fill(0) got_cs = ds.GetRasterBand(1).Checksum() if got_cs != 0: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).WriteRaster(0, 0, 20, 20, src_data) got_cs = ds.GetRasterBand(1).Checksum() if src_cs != got_cs: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).Fill(0) got_cs = ds.GetRasterBand(1).Checksum() if got_cs != 0: - gdaltest.post_reason('fail') return 'fail' ds.WriteRaster(0, 0, 20, 20, src_data) got_cs = ds.GetRasterBand(1).Checksum() if src_cs != got_cs: - gdaltest.post_reason('fail') return 'fail' # Not bound to SWIG @@ -247,41 +230,33 @@ def test_gdal_api_proxy_sub(): got_data = ds.ReadRaster(0, 0, 20, 20) if src_data != got_data: - gdaltest.post_reason('fail') return 'fail' got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 20, 20) if src_data != got_data: - gdaltest.post_reason('fail') return 'fail' got_data_weird_spacing = ds.ReadRaster(0, 0, 20, 20, buf_pixel_space=1, buf_line_space=32) if len(got_data_weird_spacing) != 32 * (20 - 1) + 20: - gdaltest.post_reason('fail') print(len(got_data_weird_spacing)) return 'fail' if got_data[20:20 + 20] != got_data_weird_spacing[32:32 + 20]: - gdaltest.post_reason('fail') return 'fail' got_data_weird_spacing = ds.GetRasterBand(1).ReadRaster(0, 0, 20, 20, buf_pixel_space=1, buf_line_space=32) if len(got_data_weird_spacing) != 32 * (20 - 1) + 20: - gdaltest.post_reason('fail') print(len(got_data_weird_spacing)) return 'fail' if got_data[20:20 + 20] != got_data_weird_spacing[32:32 + 20]: - gdaltest.post_reason('fail') return 'fail' got_block = ds.GetRasterBand(1).ReadBlock(0, 0) if len(got_block) != 256 * 256: - gdaltest.post_reason('fail') return 'fail' if got_data[20:20 + 20] != got_block[256:256 + 20]: - gdaltest.post_reason('fail') return 'fail' ds.FlushCache() @@ -289,304 +264,239 @@ def test_gdal_api_proxy_sub(): got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 20, 20) if src_data != got_data: - gdaltest.post_reason('fail') return 'fail' if len(ds.GetFileList()) != 1: - gdaltest.post_reason('fail') return 'fail' if ds.AddBand(gdal.GDT_Byte) == 0: - gdaltest.post_reason('fail') return 'fail' got_md = ds.GetMetadata() if src_md != got_md: - gdaltest.post_reason('fail') print(src_md) print(got_md) return 'fail' if ds.GetMetadataItem('AREA_OR_POINT') != 'Area': - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('foo') is not None: - gdaltest.post_reason('fail') return 'fail' ds.SetMetadataItem('foo', 'bar') if ds.GetMetadataItem('foo') != 'bar': - gdaltest.post_reason('fail') return 'fail' ds.SetMetadata({'foo': 'baz'}, 'OTHER') if ds.GetMetadataItem('foo', 'OTHER') != 'baz': - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetMetadata({'foo': 'baw'}, 'OTHER') if ds.GetRasterBand(1).GetMetadataItem('foo', 'OTHER') != 'baw': - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('INTERLEAVE', 'IMAGE_STRUCTURE') != 'BAND': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadata(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMetadata()) return 'fail' if ds.GetRasterBand(1).GetMetadataItem('foo') is not None: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetMetadataItem('foo', 'baz') if ds.GetRasterBand(1).GetMetadataItem('foo') != 'baz': - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetMetadata({'foo': 'baw'}) if ds.GetRasterBand(1).GetMetadataItem('foo') != 'baw': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_Undefined) ct = ds.GetRasterBand(1).GetColorTable() if ct is not None: - gdaltest.post_reason('fail') return 'fail' ct = gdal.ColorTable() ct.SetColorEntry(0, (1, 2, 3)) if ds.GetRasterBand(1).SetColorTable(ct) != 0: - gdaltest.post_reason('fail') return 'fail' ct = ds.GetRasterBand(1).GetColorTable() if ct is None: - gdaltest.post_reason('fail') return 'fail' if ct.GetColorEntry(0) != (1, 2, 3, 255): - gdaltest.post_reason('fail') return 'fail' ct = ds.GetRasterBand(1).GetColorTable() if ct is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetColorTable(None) != 0: - gdaltest.post_reason('fail') return 'fail' ct = ds.GetRasterBand(1).GetColorTable() if ct is not None: - gdaltest.post_reason('fail') return 'fail' rat = ds.GetRasterBand(1).GetDefaultRAT() if rat is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetDefaultRAT(None) != 0: - gdaltest.post_reason('fail') return 'fail' ref_rat = gdal.RasterAttributeTable() if ds.GetRasterBand(1).SetDefaultRAT(ref_rat) != 0: - gdaltest.post_reason('fail') return 'fail' rat = ds.GetRasterBand(1).GetDefaultRAT() if rat is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetDefaultRAT(None) != 0: - gdaltest.post_reason('fail') return 'fail' rat = ds.GetRasterBand(1).GetDefaultRAT() if rat is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMinimum() is not None: - gdaltest.post_reason('fail') return 'fail' got_stats = ds.GetRasterBand(1).GetStatistics(0, 0) if got_stats[3] >= 0.0: - gdaltest.post_reason('fail') return 'fail' got_stats = ds.GetRasterBand(1).GetStatistics(1, 1) if got_stats[0] != 74.0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMinimum() != 74.0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaximum() != 255.0: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetStatistics(1, 2, 3, 4) got_stats = ds.GetRasterBand(1).GetStatistics(1, 1) if got_stats != [1, 2, 3, 4]: print(got_stats) - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).ComputeStatistics(0) got_stats = ds.GetRasterBand(1).GetStatistics(1, 1) if got_stats[0] != 74.0: - gdaltest.post_reason('fail') return 'fail' minmax = ds.GetRasterBand(1).ComputeRasterMinMax() if minmax != (74.0, 255.0): - gdaltest.post_reason('fail') print(minmax) return 'fail' if ds.GetRasterBand(1).GetOffset() != 0.0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetScale() != 1.0: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetOffset(10.0) if ds.GetRasterBand(1).GetOffset() != 10.0: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetScale(2.0) if ds.GetRasterBand(1).GetScale() != 2.0: - gdaltest.post_reason('fail') return 'fail' ds.BuildOverviews('NEAR', [2]) if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' got_hist = ds.GetRasterBand(1).GetHistogram() if len(got_hist) != 256: - gdaltest.post_reason('fail') return 'fail' (minval, maxval, nitems, got_hist2) = ds.GetRasterBand(1).GetDefaultHistogram() if minval != -0.5: - gdaltest.post_reason('fail') return 'fail' if maxval != 255.5: - gdaltest.post_reason('fail') return 'fail' if nitems != 256: - gdaltest.post_reason('fail') return 'fail' if got_hist != got_hist2: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetDefaultHistogram(1, 2, [3]) (minval, maxval, nitems, got_hist3) = ds.GetRasterBand(1).GetDefaultHistogram() if minval != 1: - gdaltest.post_reason('fail') return 'fail' if maxval != 2: - gdaltest.post_reason('fail') return 'fail' if nitems != 1: - gdaltest.post_reason('fail') return 'fail' if got_hist3[0] != 3: - gdaltest.post_reason('fail') return 'fail' got_nodatavalue = ds.GetRasterBand(1).GetNoDataValue() if got_nodatavalue is not None: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetNoDataValue(123) got_nodatavalue = ds.GetRasterBand(1).GetNoDataValue() if got_nodatavalue != 123: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskFlags() != 8: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskBand() is None: - gdaltest.post_reason('fail') return 'fail' ret = ds.GetRasterBand(1).DeleteNoDataValue() if ret != 0: - gdaltest.post_reason('fail') return 'fail' got_nodatavalue = ds.GetRasterBand(1).GetNoDataValue() if got_nodatavalue is not None: - gdaltest.post_reason('fail') return 'fail' ds.CreateMaskBand(0) if ds.GetRasterBand(1).GetMaskFlags() != 2: print(ds.GetRasterBand(1).GetMaskFlags()) - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskBand() is None: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).CreateMaskBand(0) if ds.GetRasterBand(1).HasArbitraryOverviews() != 0: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetUnitType('foo') if ds.GetRasterBand(1).GetUnitType() != 'foo': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetCategoryNames() is not None: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetCategoryNames(['foo']) if ds.GetRasterBand(1).GetCategoryNames() != ['foo']: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetDescription('bar') diff --git a/autotest/gcore/hfa_write.py b/autotest/gcore/hfa_write.py index 5e7524c6057b..70bc71d763cf 100755 --- a/autotest/gcore/hfa_write.py +++ b/autotest/gcore/hfa_write.py @@ -289,11 +289,9 @@ def test_hfa_update_existing_aux_overviews(): new_cs_ovr0 = ds.GetRasterBand(1).GetOverview(0).Checksum() new_cs_ovr1 = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs_ovr0 != new_cs_ovr0: - gdaltest.post_reason('fail') gdal.SetConfigOption('USE_RRD', None) return 'fail' if cs_ovr1 != new_cs_ovr1: - gdaltest.post_reason('fail') gdal.SetConfigOption('USE_RRD', None) return 'fail' @@ -307,11 +305,9 @@ def test_hfa_update_existing_aux_overviews(): new_cs_ovr0 = ds.GetRasterBand(1).GetOverview(0).Checksum() new_cs_ovr1 = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs_ovr0 != new_cs_ovr0: - gdaltest.post_reason('fail') gdal.SetConfigOption('USE_RRD', None) return 'fail' if cs_ovr1 != new_cs_ovr1: - gdaltest.post_reason('fail') gdal.SetConfigOption('USE_RRD', None) return 'fail' @@ -324,11 +320,9 @@ def test_hfa_update_existing_aux_overviews(): new_cs_ovr0 = ds.GetRasterBand(1).GetOverview(0).Checksum() new_cs_ovr1 = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs_ovr0 != new_cs_ovr0: - gdaltest.post_reason('fail') gdal.SetConfigOption('USE_RRD', None) return 'fail' if cs_ovr1 != new_cs_ovr1: - gdaltest.post_reason('fail') gdal.SetConfigOption('USE_RRD', None) return 'fail' ds = None diff --git a/autotest/gcore/mask.py b/autotest/gcore/mask.py index 91ce1c0526c2..563ea4a3e506 100755 --- a/autotest/gcore/mask.py +++ b/autotest/gcore/mask.py @@ -676,7 +676,6 @@ def test_mask_14(): gdal.SetConfigOption('GDAL_TIFF_INTERNAL_MASK', None) gdal.SetCacheMax(old_val) if out_ds.GetRasterBand(1).Checksum() == 0: - gdaltest.post_reason('failure') return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 400: @@ -1035,14 +1034,12 @@ def test_mask_24(): # IRasterIO() optimized case import struct if struct.unpack('B', mask.ReadRaster(0, 0, 1, 1))[0] != 255: - gdaltest.post_reason('fail') print(struct.unpack('B', mask.ReadRaster(0, 0, 1, 1))[0]) return 'fail' # IReadBlock() code path (blockx, blocky) = mask.GetBlockSize() if struct.unpack('B' * blockx * blocky, mask.ReadBlock(0, 0))[0] != 255: - gdaltest.post_reason('fail') print(struct.unpack('B' * blockx * blocky, mask.ReadBlock(0, 0))[0]) return 'fail' mask.FlushCache() @@ -1050,7 +1047,6 @@ def test_mask_24(): # Test special case where dynamics is only 0-255 ds.GetRasterBand(4).Fill(255) if struct.unpack('B', mask.ReadRaster(0, 0, 1, 1))[0] != 1: - gdaltest.post_reason('fail') print(struct.unpack('B', mask.ReadRaster(0, 0, 1, 1))[0]) return 'fail' @@ -1068,7 +1064,6 @@ def test_mask_25(): ds = gdal.GetDriverByName('GTiff').Create('/vsimem/mask_25.tif', 1, 1) if ds.GetRasterBand(1).GetMaskFlags() != gdal.GMF_ALL_VALID: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1076,11 +1071,9 @@ def test_mask_25(): gdal.GetDriverByName('GTiff').Create('/vsimem/mask_25.tif.msk', 1, 1) ds = gdal.Open('/vsimem/mask_25.tif') if ds.GetRasterBand(1).GetMaskFlags() != gdal.GMF_ALL_VALID: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 3: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -1093,11 +1086,9 @@ def test_mask_25(): ds = None ds = gdal.Open('/vsimem/mask_25.tif') if ds.GetRasterBand(1).GetMaskFlags() != 0: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 0: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -1112,7 +1103,6 @@ def test_mask_25(): ds = gdal.Open('/vsimem/mask_25.tif') with gdaltest.error_handler(): if ds.GetRasterBand(2).GetMaskFlags() != gdal.GMF_ALL_VALID: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/mask_25.tif') @@ -1123,7 +1113,6 @@ def test_mask_25(): ds.GetRasterBand(1).CreateMaskBand(gdal.GMF_PER_DATASET) with gdaltest.error_handler(): if ds.GetRasterBand(2).CreateMaskBand(0) == 0: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/mask_25.tif') @@ -1155,7 +1144,6 @@ def test_mask_26(): # IRasterIO() optimized case import struct if struct.unpack('B', mask.ReadRaster(0, 0, 1, 1))[0] != 255: - gdaltest.post_reason('fail') print(struct.unpack('B', mask.ReadRaster(0, 0, 1, 1))[0]) return 'fail' diff --git a/autotest/gcore/misc.py b/autotest/gcore/misc.py index ec310958afb9..7350c83bf357 100755 --- a/autotest/gcore/misc.py +++ b/autotest/gcore/misc.py @@ -597,7 +597,6 @@ def test_misc_12(): ds = drv.CreateCopy('/nonexistingpath' + get_filename(drv, ''), src_ds) gdal.PopErrorHandler() if ds is None and gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('failure') print('CreateCopy() into non existing dir fails without error message for driver %s' % drv.ShortName) gdal.Unlink('/vsimem/misc_12_src.tif') return 'fail' @@ -637,7 +636,6 @@ def test_misc_13(): out_ds = gdal.GetDriverByName('ESRI Shapefile').CreateCopy('/vsimem/out.shp', ds) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Raster-only -> vector-only @@ -646,7 +644,6 @@ def test_misc_13(): out_ds = gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/out.tif', ds) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gcore/nodatamaskband.py b/autotest/gcore/nodatamaskband.py index 8f76f08033d1..553026a127e7 100755 --- a/autotest/gcore/nodatamaskband.py +++ b/autotest/gcore/nodatamaskband.py @@ -66,7 +66,6 @@ def test_nodatamaskband_1(): 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 255) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(dt) print(data_ar) return 'fail' @@ -75,7 +74,6 @@ def test_nodatamaskband_1(): data_ar = struct.unpack('B' * 6 * 1, data) expected_ar = (0, 255, 255, 0, 0, 255) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(dt) print(data_ar) return 'fail' @@ -84,7 +82,6 @@ def test_nodatamaskband_1(): data_ar = struct.unpack('B' * 6 * 1, data) expected_ar = (255, 0, 0, 255, 255, 255) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(dt) print(data_ar) return 'fail' @@ -95,7 +92,6 @@ def test_nodatamaskband_1(): expected_ar = (255, 0, 255, 0, 255, 255) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(dt) print(data_ar) return 'fail' @@ -106,7 +102,6 @@ def test_nodatamaskband_1(): expected_ar = (255, 0, 255, 0, 255, 255) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(dt) print(data_ar) return 'fail' diff --git a/autotest/gcore/numpy_rw.py b/autotest/gcore/numpy_rw.py index c03fe81983d2..388bed21264b 100755 --- a/autotest/gcore/numpy_rw.py +++ b/autotest/gcore/numpy_rw.py @@ -692,10 +692,8 @@ def test_numpy_rw_14(): callback=numpy_rw_14_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' if abs(tab[0] - 1.05) > 1e-5 or not tab[1]: - gdaltest.post_reason('failure') return 'fail' # Test interruption @@ -703,10 +701,8 @@ def test_numpy_rw_14(): data = ds.GetRasterBand(1).ReadAsArray(callback=numpy_rw_14_progress_interrupt_callback, callback_data=tab) if data is not None: - gdaltest.post_reason('failure') return 'fail' if tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' # Test Dataset.ReadAsArray @@ -715,10 +711,8 @@ def test_numpy_rw_14(): callback=numpy_rw_14_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' if abs(tab[0] - 1.05) > 1e-5 or not tab[1]: - gdaltest.post_reason('failure') return 'fail' # Same with interruption @@ -726,7 +720,6 @@ def test_numpy_rw_14(): data = ds.ReadAsArray(callback=numpy_rw_14_progress_interrupt_callback, callback_data=tab) if data is not None or tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' # Test Dataset.ReadAsArray on a multi band file @@ -736,7 +729,6 @@ def test_numpy_rw_14(): data = ds.ReadAsArray(callback=numpy_rw_14_progress_callback_2, callback_data=last_pct) if data is None or abs(last_pct[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' last_pct = [0] @@ -747,7 +739,6 @@ def test_numpy_rw_14(): callback=numpy_rw_14_progress_callback_2, callback_data=last_pct) if data is None or abs(last_pct[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -768,12 +759,10 @@ def test_numpy_rw_15(): ds = gdal_array.OpenArray(array) gt = ds.GetGeoTransform(can_return_null=True) if gt is not None: - gdaltest.post_reason('failure') return 'fail' ds.SetGeoTransform([1, 2, 3, 4, 5, -6]) gt = ds.GetGeoTransform() if gt != (1, 2, 3, 4, 5, -6): - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -795,7 +784,6 @@ def test_numpy_rw_16(): with gdaltest.error_handler(): ds = gdal_array.OpenArray(array) if ds is not None: - gdaltest.post_reason('failure') return 'fail' # 4D @@ -803,7 +791,6 @@ def test_numpy_rw_16(): with gdaltest.error_handler(): ds = gdal_array.OpenArray(array) if ds is not None: - gdaltest.post_reason('failure') return 'fail' # Unsupported data type @@ -811,7 +798,6 @@ def test_numpy_rw_16(): with gdaltest.error_handler(): ds = gdal_array.OpenArray(array) if ds is not None: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -833,21 +819,18 @@ def test_numpy_rw_17(): with gdaltest.error_handler(): ds = gdal.Open(gdal_array.GetArrayFilename(array)) if ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.SetConfigOption('GDAL_ARRAY_OPEN_BY_FILENAME', 'TRUE') ds = gdal.Open(gdal_array.GetArrayFilename(array)) gdal.SetConfigOption('GDAL_ARRAY_OPEN_BY_FILENAME', None) if ds is None: - gdaltest.post_reason('failure') return 'fail' # Invalid value with gdaltest.error_handler(): ds = gdal.Open('NUMPY:::invalid') if ds is not None: - gdaltest.post_reason('failure') return 'fail' return 'success' diff --git a/autotest/gcore/overviewds.py b/autotest/gcore/overviewds.py index a641a328f652..9ab4fdac9db4 100755 --- a/autotest/gcore/overviewds.py +++ b/autotest/gcore/overviewds.py @@ -64,7 +64,6 @@ def test_overviewds_2(): ds = gdal.OpenEx('tmp/byte.tif', open_options=['OVERVIEW_LEVEL=0only']) if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -73,54 +72,41 @@ def test_overviewds_2(): if ds is None: return 'fail' if ds.RasterXSize != 10 or ds.RasterYSize != 10 or ds.RasterCount != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef() != src_ds.GetProjectionRef(): - gdaltest.post_reason('fail') return 'fail' src_gt = src_ds.GetGeoTransform() expected_gt = (src_gt[0], src_gt[1] * 2, src_gt[2], src_gt[3], src_gt[4], src_gt[5] * 2) gt = ds.GetGeoTransform() for i in range(6): if abs(expected_gt[i] - gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(expected_gt) print(gt) return 'fail' if ds.GetGCPCount() != 0 or ds.GetGCPProjection() != src_ds.GetGCPProjection() or ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' expected_data = src_ds.ReadRaster(0, 0, 20, 20, 10, 10) got_data = ds.ReadRaster(0, 0, 10, 10) if expected_data != got_data: - gdaltest.post_reason('fail') return 'fail' got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 10, 10) if expected_data != got_data: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' expected_data = src_ds.ReadRaster(0, 0, 20, 20, 5, 5) got_data = ds.GetRasterBand(1).GetOverview(0).ReadRaster(0, 0, 5, 5) if expected_data != got_data: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadata() != src_ds.GetMetadata(): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('AREA_OR_POINT') != src_ds.GetMetadataItem('AREA_OR_POINT'): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadata('RPC'): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadata('GEOLOCATION'): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('RPC', 'FOO') is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -164,7 +150,6 @@ def test_overviewds_3(): for i in range(3): if gcps[i].GCPPixel != src_gcps[i].GCPPixel / 2 or gcps[i].GCPLine != src_gcps[i].GCPLine / 2 or \ gcps[i].GCPX != src_gcps[i].GCPX or gcps[i].GCPY != src_gcps[i].GCPY: - gdaltest.post_reason('fail') return 'fail' # Really check that the transformer works @@ -173,7 +158,6 @@ def test_overviewds_3(): for i in range(3): if abs(ref_pnt[i] - pnt[i]) > 1e-5: - gdaltest.post_reason('fail') print(ref_pnt) print(pnt) return 'fail' @@ -210,17 +194,14 @@ def test_overviewds_4(): for key in rpc_md: if ds.GetMetadataItem(key, 'RPC') != got_md[key]: - gdaltest.post_reason('fail') return 'fail' if key == 'LINE_SCALE' or key == 'SAMP_SCALE' or key == 'LINE_OFF' or key == 'SAMP_OFF': if float(got_md[key]) != myfloat(rpc_md[key]) / 2: - gdaltest.post_reason('fail') print(key) print(got_md[key]) print(rpc_md[key]) return 'fail' elif got_md[key] != rpc_md[key]: - gdaltest.post_reason('fail') print(key) print(got_md[key]) print(rpc_md[key]) @@ -232,7 +213,6 @@ def test_overviewds_4(): for i in range(3): if abs(ref_pnt[i] - pnt[i]) > 1e-5: - gdaltest.post_reason('fail') print(ref_pnt) print(pnt) return 'fail' @@ -269,24 +249,20 @@ def test_overviewds_5(): for key in geoloc_md: if ds.GetMetadataItem(key, 'GEOLOCATION') != got_md[key]: - gdaltest.post_reason('fail') return 'fail' if key == 'PIXEL_OFFSET' or key == 'LINE_OFFSET': if abs(float(got_md[key]) - myfloat(geoloc_md[key]) * 2) > 1e-1: - gdaltest.post_reason('fail') print(key) print(got_md[key]) print(geoloc_md[key]) return 'fail' elif key == 'PIXEL_STEP' or key == 'LINE_STEP': if abs(float(got_md[key]) - myfloat(geoloc_md[key]) / 2) > 1e-1: - gdaltest.post_reason('fail') print(key) print(got_md[key]) print(geoloc_md[key]) return 'fail' elif got_md[key] != geoloc_md[key]: - gdaltest.post_reason('fail') print(key) print(got_md[key]) print(geoloc_md[key]) @@ -299,7 +275,6 @@ def test_overviewds_5(): for i in range(3): if abs(pnt[i] - expected_xyz[i]) > 0.5: - gdaltest.post_reason('fail') print(pnt) print(expected_xyz) return 'fail' @@ -326,11 +301,9 @@ def test_overviewds_6(): ds = gdal.Open('tmp/byte.vrt') if ds.RasterXSize != 10 or ds.RasterYSize != 10 or ds.RasterCount != 1: - gdaltest.post_reason('fail') return 'fail' got_cs = ds.GetRasterBand(1).Checksum() if got_cs != expected_cs: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gcore/pam.py b/autotest/gcore/pam.py index 271ac4c22afa..b957686e77ac 100755 --- a/autotest/gcore/pam.py +++ b/autotest/gcore/pam.py @@ -142,7 +142,6 @@ def test_pam_3(): ds = None ds = gdal.Open('tmp/pam.pnm', gdal.GA_Update) if ds.GetRasterBand(1).DeleteNoDataValue() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -485,16 +484,13 @@ def test_pam_12(): gdal.Unlink('tmp/byte.tif.aux.xml') if hist1 != hist2: - gdaltest.post_reason('fail') print(hist1) print(hist2) return 'fail' if hist1[0] != 6000000000: - gdaltest.post_reason('fail') print(hist1) return 'fail' if aux_xml.find('6000000000|') < 0: - gdaltest.post_reason('fail') print(aux_xml) return 'fail' @@ -517,20 +513,17 @@ def test_pam_13(): ret = ds.GetRasterBand(1).SetNoDataValue(0) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = ds.GetRasterBand(1).DeleteNoDataValue() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None if gdal.VSIStatL('/vsimem/tmp.pnm.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/tmp.pnm') diff --git a/autotest/gcore/pixfun.py b/autotest/gcore/pixfun.py index f721d310e5ff..a21fd5fcc7e1 100755 --- a/autotest/gcore/pixfun.py +++ b/autotest/gcore/pixfun.py @@ -121,7 +121,6 @@ def test_pixfun_imag_c(): refdata = refds.GetRasterBand(1).ReadAsArray() if not numpy.alltrue(data == refdata.imag): - gdaltest.post_reason('fail') return 'fail' # Test bugfix of #6599 @@ -130,7 +129,6 @@ def test_pixfun_imag_c(): copied_ds = None if not numpy.alltrue(data == data_ds): - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gcore/rasterio.py b/autotest/gcore/rasterio.py index d720c1816fae..ee26bf673184 100755 --- a/autotest/gcore/rasterio.py +++ b/autotest/gcore/rasterio.py @@ -396,7 +396,6 @@ def test_rasterio_8(): gdaltest.post_reason('did not read expected band data via ReadRaster()') return 'fail' if abs(tab[0] - 1) > 1e-5 or not tab[1]: - gdaltest.post_reason('failure') return 'fail' # Test interruption @@ -405,10 +404,8 @@ def test_rasterio_8(): callback=rasterio_8_progress_interrupt_callback, callback_data=tab) if data is not None: - gdaltest.post_reason('failure') return 'fail' if tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster with type change @@ -420,7 +417,6 @@ def test_rasterio_8(): gdaltest.post_reason('did not read expected band data via ReadRaster()') return 'fail' if abs(tab[0] - 1) > 1e-5 or not tab[1]: - gdaltest.post_reason('failure') return 'fail' # Same with interruption @@ -429,7 +425,6 @@ def test_rasterio_8(): callback=rasterio_8_progress_interrupt_callback, callback_data=tab) if data is not None or tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster with resampling @@ -441,7 +436,6 @@ def test_rasterio_8(): gdaltest.post_reason('did not read expected band data via ReadRaster()') return 'fail' if abs(tab[0] - 1) > 1e-5 or not tab[1]: - gdaltest.post_reason('failure') return 'fail' # Same with interruption @@ -450,7 +444,6 @@ def test_rasterio_8(): callback=rasterio_8_progress_interrupt_callback, callback_data=tab) if data is not None or tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' # Test Dataset.ReadRaster @@ -462,7 +455,6 @@ def test_rasterio_8(): gdaltest.post_reason('did not read expected dataset data via ReadRaster()') return 'fail' if abs(tab[0] - 1) > 1e-5 or not tab[1]: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -474,7 +466,6 @@ def test_rasterio_8(): callback=rasterio_8_progress_callback_2, callback_data=last_pct) if data is None or abs(last_pct[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Same with interruption @@ -482,7 +473,6 @@ def test_rasterio_8(): data = ds.ReadRaster(callback=rasterio_8_progress_interrupt_callback, callback_data=tab) if data is not None or tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -494,7 +484,6 @@ def test_rasterio_8(): callback=rasterio_8_progress_callback_2, callback_data=last_pct) if data is None or abs(last_pct[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Same with interruption @@ -502,7 +491,6 @@ def test_rasterio_8(): data = ds.ReadRaster(callback=rasterio_8_progress_interrupt_callback, callback_data=tab) if data is not None or tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -541,17 +529,14 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' data_ar = struct.unpack('h' * 10 * 10, data) cs = rasterio_9_checksum(data, 10, 10, data_type=gdal.GDT_Int16) if cs != 1211: # checksum of gdal_translate data/byte.tif out.tif -outsize 10 10 -r BILINEAR - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Same but query with GDT_Float32. Check that we do not get floating-point @@ -563,7 +548,6 @@ def test_rasterio_9(): data_float32_ar = struct.unpack('f' * 10 * 10, data) if data_ar != data_float32_ar: - gdaltest.post_reason('failure') print(data_float32_ar) return 'fail' @@ -575,16 +559,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 10, 10) if cs != 1154: # checksum of gdal_translate data/byte.tif out.tif -outsize 10 10 -r LANCZOS - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster, with Bilinear and UInt16 data type @@ -597,16 +578,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 10, 10, data_type=gdal.GDT_UInt16) if cs != 1211: # checksum of gdal_translate data/byte.tif out.tif -outsize 10 10 -r BILINEAR - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster, with Bilinear on Complex, thus using warp API @@ -619,16 +597,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 10, 10, data_type=gdal.GDT_CInt16) if cs != 1211: # checksum of gdal_translate data/byte.tif out.tif -outsize 10 10 -r BILINEAR - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test interruption @@ -641,10 +616,8 @@ def test_rasterio_9(): callback_data=tab) gdal.PopErrorHandler() if data is not None: - gdaltest.post_reason('failure') return 'fail' if tab[0] < 0.50: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster, with Gauss, and downsampling @@ -655,16 +628,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 10, 10) if cs != 1089: # checksum of gdal_translate data/byte.tif out.tif -outsize 10 10 -r GAUSS - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster, with Cubic, and downsampling @@ -675,16 +645,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 10, 10) if cs != 1059: # checksum of gdal_translate data/byte.tif out.tif -outsize 10 10 -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test RasterBand.ReadRaster, with Cubic, and downsampling with >=8x8 source samples used for a dest sample @@ -692,11 +659,9 @@ def test_rasterio_9(): buf_ysize=5, resample_alg=gdal.GRIORA_Cubic) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 5, 5) if cs != 214: # checksum of gdal_translate data/byte.tif out.tif -outsize 5 5 -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -705,11 +670,9 @@ def test_rasterio_9(): buf_ysize=5, resample_alg=gdal.GRIORA_Cubic) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 5, 5, data_type=gdal.GDT_UInt16) if cs != 214: # checksum of gdal_translate data/byte.tif out.tif -outsize 5 5 -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -721,16 +684,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 40, 40) if cs != 19556: # checksum of gdal_translate data/byte.tif out.tif -outsize 40 40 -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test Dataset.ReadRaster, with Cubic and supersampling @@ -741,16 +701,13 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 40, 40) if cs != 19041: # checksum of gdal_translate data/byte.tif out.tif -outsize 40 40 -r CUBICSPLINE - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' # Test Dataset.ReadRaster on a multi band file, with INTERLEAVE=PIXEL @@ -762,21 +719,17 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data[0:25 * 25], 25, 25) if cs != 5975: # checksum of gdal_translate data/rgbsmall_cmyk.tif out.tif -outsize 25 25 -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' cs = rasterio_9_checksum(data[25 * 25:2 * 25 * 25], 25, 25) if cs != 6248: # checksum of gdal_translate data/rgbsmall_cmyk.tif out.tif -outsize 25 25 -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -789,15 +742,12 @@ def test_rasterio_9(): callback=rasterio_9_progress_callback, callback_data=tab) if data is None: - gdaltest.post_reason('failure') return 'fail' cs = rasterio_9_checksum(data, 162 * 16, 150 * 16) if cs != 30836: # checksum of gdal_translate data/stefan_full_rgba.png out.tif -outsize 1600% 1600% -r CUBIC - gdaltest.post_reason('failure') print(cs) return 'fail' if abs(tab[0] - 1.0) > 1e-5: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -813,7 +763,6 @@ def test_rasterio_10(): data = ds.GetRasterBand(1).ReadRaster() gdal.PopErrorHandler() if data is not None: - gdaltest.post_reason('failure') return 'fail' # Change buffer type @@ -821,7 +770,6 @@ def test_rasterio_10(): data = ds.GetRasterBand(1).ReadRaster(buf_type=gdal.GDT_Int16) gdal.PopErrorHandler() if data is not None: - gdaltest.post_reason('failure') return 'fail' # Resampling case @@ -830,7 +778,6 @@ def test_rasterio_10(): buf_ysize=10) gdal.PopErrorHandler() if data is not None: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -855,7 +802,6 @@ def test_rasterio_11(): mem_ds.GetRasterBand(1).SetMetadataItem('NBITS', '8', 'IMAGE_STRUCTURE') ar = mem_ds.GetRasterBand(1).ReadAsArray(0, 0, 4, 3, 8, 3, resample_alg=gdal.GRIORA_Cubic) if ar.max() != 129: - gdaltest.post_reason('failure') print(ar.max()) return 'fail' @@ -864,7 +810,6 @@ def test_rasterio_11(): ar = mem_ds.GetRasterBand(1).ReadAsArray(0, 0, 4, 3, 8, 3, resample_alg=gdal.GRIORA_Cubic) # Would overshoot to 129 if NBITS was ignored if ar.max() != 127: - gdaltest.post_reason('failure') print(ar.max()) return 'fail' @@ -903,13 +848,11 @@ def test_rasterio_12(): callback=rasterio_12_progress_callback, callback_data=tab) if tab[0] != 1.0: - gdaltest.post_reason('failure') print(tab) return 'fail' ar_ds2 = mem_ds.ReadAsArray(0, 0, 4, 3, buf_xsize=8, buf_ysize=3, resample_alg=gdal.GRIORA_Cubic) if not numpy.array_equal(ar_ds, ar_ds2): - gdaltest.post_reason('failure') print(ar_ds) print(ar_ds2) return 'fail' @@ -919,21 +862,18 @@ def test_rasterio_12(): # Results of band or dataset RasterIO should be the same for i in range(4): if not numpy.array_equal(ar_ds[i], ar_bands[i]): - gdaltest.post_reason('failure') print(ar_ds) print(ar_bands[i]) return 'fail' # First, second and third band should have identical content if not numpy.array_equal(ar_ds[0], ar_ds[1]): - gdaltest.post_reason('failure') print(ar_ds[0]) print(ar_ds[1]) return 'fail' # Alpha band should be different if numpy.array_equal(ar_ds[0], ar_ds[3]): - gdaltest.post_reason('failure') print(ar_ds[0]) print(ar_ds[3]) return 'fail' @@ -963,7 +903,6 @@ def test_rasterio_13(): expected_ar = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0], [0, 255, 255, 255, 255, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) if not numpy.array_equal(ar_ds, expected_ar): - gdaltest.post_reason('failure') print(dt) print(ar_ds) print(expected_ar) @@ -993,7 +932,6 @@ def test_rasterio_14(): ds = gdal.Translate('/vsimem/rasterio_14_out.asc', '/vsimem/rasterio_14.asc', options='-of AAIGRID -r average -outsize 50% 50%') cs = ds.GetRasterBand(1).Checksum() if cs != 110: - gdaltest.post_reason('fail') print(cs) print(ds.ReadAsArray()) return 'fail' @@ -1006,14 +944,12 @@ def test_rasterio_14(): data = ds.ReadRaster(buf_xsize=int(ds.RasterXSize / 2), buf_ysize=1, resample_alg=gdal.GRIORA_Average) data = struct.unpack('B' * int(ds.RasterXSize / 2), data) if data[-1:][0] != 50: - gdaltest.post_reason('fail') print(data[-1:][0]) return 'fail' data = ds.ReadRaster(ds.RasterXSize - 2, 0, 2, 1, buf_xsize=1, buf_ysize=1, resample_alg=gdal.GRIORA_Average) data = struct.unpack('B' * 1, data) if data[0] != 50: - gdaltest.post_reason('fail') print(data[0]) return 'fail' @@ -1022,14 +958,12 @@ def test_rasterio_14(): data = ds.ReadRaster(buf_xsize=1, buf_ysize=int(ds.RasterYSize / 2), resample_alg=gdal.GRIORA_Average) data = struct.unpack('B' * int(ds.RasterYSize / 2), data) if data[-1:][0] != 50: - gdaltest.post_reason('fail') print(data[-1:][0]) return 'fail' data = ds.ReadRaster(0, ds.RasterYSize - 2, 1, 2, buf_xsize=1, buf_ysize=1, resample_alg=gdal.GRIORA_Average) data = struct.unpack('B' * 1, data) if data[0] != 50: - gdaltest.post_reason('fail') print(data[0]) return 'fail' @@ -1057,7 +991,6 @@ def test_rasterio_15(): data = ds.GetRasterBand(1).ReadRaster() cs = ds.GetRasterBand(1).Checksum() if data != data_ref or cs != 134: - gdaltest.post_reason('fail') print(cs) print(ds.ReadAsArray()) return 'fail' @@ -1089,7 +1022,6 @@ def test_rasterio_16(): ds = gdal.Translate('/vsimem/rasterio_16_out.asc', '/vsimem/rasterio_16.asc', options='-of AAIGRID -r mode -outsize 50% 50%') cs = ds.GetRasterBand(1).Checksum() if cs != 15: - gdaltest.post_reason('fail') print(cs) print(ds.ReadAsArray()) return 'fail' @@ -1120,7 +1052,6 @@ def test_rasterio_lanczos_nodata(): 0, 0, 0, 22460, 22460, 22547, 22538, 22456, 22572, 0, 0, 0, 0, 22504, 22496, 22564, 22563, 22610) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(data_ar) return 'fail' @@ -1151,7 +1082,6 @@ def test_rasterio_resampled_value_is_nodata(): data_ar = struct.unpack('f' * 1, data) expected_ar = (1.1754943508222875e-38, ) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(data_ar) return 'fail' @@ -1161,7 +1091,6 @@ def test_rasterio_resampled_value_is_nodata(): data_ar = struct.unpack('f' * 1, data) expected_ar = (1.1754943508222875e-38, ) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(data_ar) return 'fail' @@ -1188,7 +1117,6 @@ def test_rasterio_resampled_value_is_nodata(): data_ar = struct.unpack('I' * 1, data) expected_ar = (1, ) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(data_ar) return 'fail' @@ -1198,7 +1126,6 @@ def test_rasterio_resampled_value_is_nodata(): data_ar = struct.unpack('I' * 1, data) expected_ar = (1, ) if data_ar != expected_ar: - gdaltest.post_reason('fail') print(data_ar) return 'fail' diff --git a/autotest/gcore/testnonboundtoswig.py b/autotest/gcore/testnonboundtoswig.py index c230852740a4..c459f6ea7601 100755 --- a/autotest/gcore/testnonboundtoswig.py +++ b/autotest/gcore/testnonboundtoswig.py @@ -204,7 +204,6 @@ def test_testnonboundtoswig_GDALSimpleImageWarp(): native_in_ds = gdal_handle_stdcall.GDALOpen(filename, gdal.GA_ReadOnly) if native_in_ds is None: - gdaltest.post_reason('fail') return 'fail' filename = '/vsimem/out.tif' @@ -213,17 +212,14 @@ def test_testnonboundtoswig_GDALSimpleImageWarp(): native_out_ds = gdal_handle_stdcall.GDALOpen(filename, gdal.GA_Update) if native_out_ds is None: - gdaltest.post_reason('fail') return 'fail' pTransformerArg = gdal_handle.GDALCreateGenImgProjTransformer2(native_in_ds, native_out_ds, None) if pTransformerArg is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal_handle_stdcall.GDALSimpleImageWarp(native_in_ds, native_out_ds, 0, None, gdal_handle_stdcall.GDALGenImgProjTransform, pTransformerArg, None, None, None) if ret != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -239,7 +235,6 @@ def test_testnonboundtoswig_GDALSimpleImageWarp(): gdal.Unlink('/vsimem/out.tif') if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -336,7 +331,6 @@ def test_testnonboundtoswig_VRTDerivedBands(): funcName = bytes(funcName, 'utf-8') ret = gdal_handle_stdcall.GDALAddDerivedBandPixelFunc(funcName, my_cDerivedPixelFunc) if ret != 0: - gdaltest.post_reason('fail') return 'fail' vrt_xml = """ diff --git a/autotest/gcore/tiff_ovr.py b/autotest/gcore/tiff_ovr.py index 9324d976606b..c27a9df86680 100755 --- a/autotest/gcore/tiff_ovr.py +++ b/autotest/gcore/tiff_ovr.py @@ -2025,7 +2025,6 @@ def test_tiff_ovr_49(both_endian): ds = None ds = gdal.Open('/vsimem/tiff_ovr_49.tif.ovr') if ds.GetRasterBand(1).Checksum() == 0: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('GTiff').Delete('/vsimem/tiff_ovr_49.tif') @@ -2099,12 +2098,10 @@ def test_tiff_ovr_52(): ds = gdal.Open('/vsimem/tiff_ovr_52.tif') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -2123,12 +2120,10 @@ def test_tiff_ovr_52(): ds = gdal.Open('/vsimem/tiff_ovr_52.tif') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -2160,12 +2155,10 @@ def test_tiff_ovr_53(): ds = gdal.Open('/vsimem/tiff_ovr_53.tif') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -2190,12 +2183,10 @@ def test_tiff_ovr_53(): ds = gdal.Open('/vsimem/tiff_ovr_53.tif') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -2239,7 +2230,6 @@ def test_tiff_ovr_54(): gdal.GetDriverByName('GTiff').Delete('/vsimem/tiff_ovr_54.tif') if cs0 == 0 or cs1 == 0: - gdaltest.post_reason('fail') print(cs0, cs1) return 'fail' @@ -2255,12 +2245,10 @@ def test_tiff_ovr_too_many_levels_contig(): ds = gdal.GetDriverByName('GTiff').CreateCopy(tmpfilename, src_ds) ds.BuildOverviews('AVERAGE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) if ds.GetRasterBand(1).GetOverviewCount() != 5: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' ds.BuildOverviews('AVERAGE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) if ds.GetRasterBand(1).GetOverviewCount() != 5: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('GTiff').Delete(tmpfilename) @@ -2277,11 +2265,9 @@ def test_tiff_ovr_too_many_levels_separate(): ds = gdal.GetDriverByName('GTiff').CreateCopy(tmpfilename, src_ds) ds.BuildOverviews('AVERAGE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) if ds.GetRasterBand(1).GetOverviewCount() != 6: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 6: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' ds = None @@ -2300,11 +2286,9 @@ def test_tiff_ovr_too_many_levels_external(): ds = gdal.Open(tmpfilename) ds.BuildOverviews('AVERAGE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) if ds.GetRasterBand(1).GetOverviewCount() != 5: - gdaltest.post_reason('fail') return 'fail' ds.BuildOverviews('AVERAGE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) if ds.GetRasterBand(1).GetOverviewCount() != 5: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('GTiff').Delete(tmpfilename) @@ -2333,7 +2317,6 @@ def test_tiff_ovr_average_multiband_vs_singleband(): gdal.GetDriverByName('GTiff').Delete('/vsimem/tiff_ovr_average_multiband_pixel.tif') if cs_band != cs_pixel: - gdaltest.post_reason('fail') print(cs_band, cs_pixel) return 'fail' diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index fc56fe63006b..8297577c4e37 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -88,19 +88,16 @@ def test_tiff_read_off(): # Test absolute/offset directory access. ds = gdal.Open('GTIFF_DIR:off:408:data/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' # Same with GTIFF_RAW: prefix ds = gdal.Open('GTIFF_RAW:GTIFF_DIR:off:408:data/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' # Test index directory access ds = gdal.Open('GTIFF_DIR:1:data/byte.tif') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' # Check that georeferencing is read properly when accessing @@ -115,32 +112,27 @@ def test_tiff_read_off(): with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:1') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:1:') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:1:/vsimem/i_dont_exist.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Requested directory not found with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:2:data/byte.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Opening a specific TIFF directory is not supported in update mode. @@ -148,7 +140,6 @@ def test_tiff_read_off(): with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:1:data/byte.tif', gdal.GA_Update) if ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -180,7 +171,6 @@ def test_tiff_check_alpha(): if gdaltest.supports_force_rgba: got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [1970, 1970, 1970, 10807]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -203,7 +193,6 @@ def test_tiff_check_alpha(): got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] # FIXME? Not the same as without GTIFF_FORCE_RGBA=YES if got_cs != [11547, 57792, 35643, 10807]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -225,7 +214,6 @@ def test_tiff_check_alpha(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [12603, 58561, 36064, 10807]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -1146,7 +1134,6 @@ def test_tiff_read_exif_and_gps(): ds = None if exif_md is None or not exif_md: - gdaltest.post_reason('failed') return 'fail' ds = gdal.Open('data/exif_and_gps.tif') @@ -1154,7 +1141,6 @@ def test_tiff_read_exif_and_gps(): ds = None if EXIF_GPSVersionID is None: - gdaltest.post_reason('failed') return 'fail' # We should not get any EXIF metadata with that file @@ -1163,7 +1149,6 @@ def test_tiff_read_exif_and_gps(): ds = None if not (exif_md is None or not exif_md): - gdaltest.post_reason('failed') return 'fail' return 'success' @@ -1180,18 +1165,15 @@ def test_tiff_jpeg_rgba_pixel_interleaved(): ds = gdal.Open('data/stefan_full_rgba_jpeg_contig.tif') md = ds.GetMetadata('IMAGE_STRUCTURE') if md['INTERLEAVE'] != 'PIXEL': - gdaltest.post_reason('failed') return 'fail' expected_cs = [16404, 62700, 37913, 14174] for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs[i]: - gdaltest.post_reason('failed') return 'fail' if ds.GetRasterBand(i + 1).GetRasterColorInterpretation() != gdal.GCI_RedBand + i: - gdaltest.post_reason('failed') return 'fail' ds = None @@ -1210,18 +1192,15 @@ def test_tiff_jpeg_rgba_band_interleaved(): ds = gdal.Open('data/stefan_full_rgba_jpeg_separate.tif') md = ds.GetMetadata('IMAGE_STRUCTURE') if md['INTERLEAVE'] != 'BAND': - gdaltest.post_reason('failed') return 'fail' expected_cs = [16404, 62700, 37913, 14174] for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs[i]: - gdaltest.post_reason('failed') return 'fail' if ds.GetRasterBand(i + 1).GetRasterColorInterpretation() != gdal.GCI_RedBand + i: - gdaltest.post_reason('failed') return 'fail' ds = None @@ -1358,33 +1337,24 @@ def test_tiff_read_tiff_metadata(): ds = gdal.Open('data/stefan_full_rgba_jpeg_contig.tif') if ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_0', 'TIFF') != '254': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_0_0', 'TIFF') != '770': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('JPEGTABLES', 'TIFF').find('FFD8') != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_100_0', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_100', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_100_0', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_0_100', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('data/stefan_full_rgba_jpeg_separate.tif') if ds.GetRasterBand(4).GetMetadataItem('BLOCK_OFFSET_0_2', 'TIFF') != '11071': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetMetadataItem('BLOCK_SIZE_0_2', 'TIFF') != '188': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1405,7 +1375,6 @@ def test_tiff_read_irregular_tile_size_jpeg_in_tiff(): ds.GetRasterBand(1).Checksum() gdal.PopErrorHandler() if gdal.GetLastErrorType() == 0: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -1413,7 +1382,6 @@ def test_tiff_read_irregular_tile_size_jpeg_in_tiff(): ds.GetRasterBand(1).GetOverview(0).Checksum() gdal.PopErrorHandler() if gdal.GetLastErrorType() == 0: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -1643,14 +1611,12 @@ def test_tiff_direct_and_virtual_mem_io(): gdal.Unlink(filename) if ref_data_native_type != got_data_native_type: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if truncated and not band_interleaved: if got_data_native_type_whole is not None: - gdaltest.post_reason('fail') print(truncated) print(band_interleaved) print(option) @@ -1658,19 +1624,16 @@ def test_tiff_direct_and_virtual_mem_io(): print(gdal.GetDataTypeName(dt)) return 'fail' elif ref_data_native_type_whole != got_data_native_type_whole: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if ref_data_native_type_downsampled != got_data_native_type_downsampled: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if not truncated and ref_data_native_type_downsampled_not_nearest != got_data_native_type_downsampled_not_nearest: - gdaltest.post_reason('fail') print(truncated) print(band_interleaved) print(option) @@ -1678,7 +1641,6 @@ def test_tiff_direct_and_virtual_mem_io(): return 'fail' if ref_data_native_type_upsampled != got_data_native_type_upsampled: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' @@ -1687,7 +1649,6 @@ def test_tiff_direct_and_virtual_mem_io(): for x in range(xsize): for k in range(dt_size): if ref_data_native_type_custom_spacings[(y * xsize + x) * nbands * dt_size + k] != got_data_native_type_custom_spacings[(y * xsize + x) * nbands * dt_size + k]: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) @@ -1695,7 +1656,6 @@ def test_tiff_direct_and_virtual_mem_io(): if not truncated: for band in range(nbands): if ref_nbands_data_native_type_custom_spacings[(y * xsize + x) * 2 * nbands * dt_size + band * dt_size + k] != got_nbands_data_native_type_custom_spacings[(y * xsize + x) * 2 * nbands * dt_size + band * dt_size + k]: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) @@ -1704,7 +1664,6 @@ def test_tiff_direct_and_virtual_mem_io(): if nbands == 3: for band in range(nbands): if ref_nbands_data_native_type_custom_spacings_2[(y * xsize + x) * 4 * dt_size + band * dt_size + k] != got_nbands_data_native_type_custom_spacings_2[(y * xsize + x) * 4 * dt_size + band * dt_size + k]: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) @@ -1712,14 +1671,12 @@ def test_tiff_direct_and_virtual_mem_io(): return 'fail' if ref_data_float32 != got_data_float32: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) return 'fail' if not truncated and ref_nbands_data_native_type != got_nbands_data_native_type: - gdaltest.post_reason('fail') print(truncated) print(band_interleaved) print(option) @@ -1728,13 +1685,11 @@ def test_tiff_direct_and_virtual_mem_io(): if truncated: if got_nbands_data_native_type_whole is not None: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) return 'fail' elif ref_nbands_data_native_type_whole != got_nbands_data_native_type_whole: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) @@ -1742,18 +1697,15 @@ def test_tiff_direct_and_virtual_mem_io(): if truncated: if got_nbands_data_native_type_pixel_interleaved_whole is not None: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' elif ref_nbands_data_native_type_pixel_interleaved_whole != got_nbands_data_native_type_pixel_interleaved_whole: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if truncated and got_nbands_data_native_type_bottom_right_downsampled is not None: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(option) print(i) @@ -1763,25 +1715,21 @@ def test_tiff_direct_and_virtual_mem_io(): continue if ref_nbands_data_native_type_downsampled != got_nbands_data_native_type_downsampled: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if ref_nbands_data_native_type_downsampled_interleaved != got_nbands_data_native_type_downsampled_interleaved: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if ref_nbands_data_native_type_downsampled_not_nearest != got_nbands_data_native_type_downsampled_not_nearest: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if ref_nbands_data_native_type_upsampled != got_nbands_data_native_type_upsampled: - gdaltest.post_reason('fail') print(option) print(i) # import struct @@ -1794,7 +1742,6 @@ def test_tiff_direct_and_virtual_mem_io(): return 'fail' if ref_nbands_data_native_type_downsampled_x_upsampled_y != got_nbands_data_native_type_downsampled_x_upsampled_y: - gdaltest.post_reason('fail') print(option) print(i) # import struct @@ -1807,13 +1754,11 @@ def test_tiff_direct_and_virtual_mem_io(): return 'fail' if ref_nbands_data_native_type_unordered_list != got_nbands_data_native_type_unordered_list: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if ref_nbands_data_native_type_pixel_interleaved != got_nbands_data_native_type_pixel_interleaved: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' @@ -1823,7 +1768,6 @@ def test_tiff_direct_and_virtual_mem_io(): for b in range(nbands - 1): for k in range(dt_size): if ref_nbands_m_1_data_native_type_pixel_interleaved_with_extra_space[((y * xsize + x) * nbands + b) * dt_size + k] != got_nbands_m_1_data_native_type_pixel_interleaved_with_extra_space[((y * xsize + x) * nbands + b) * dt_size + k]: - gdaltest.post_reason('fail') print(option) print(i) print(y) @@ -1832,13 +1776,11 @@ def test_tiff_direct_and_virtual_mem_io(): return 'fail' if ref_nbands_data_float32 != got_nbands_data_float32: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' if ref_nbands_data_float32_pixel_interleaved != got_nbands_data_float32_pixel_interleaved: - gdaltest.post_reason('fail') print(option) print(i) return 'fail' @@ -2475,7 +2417,6 @@ def test_tiff_read_empty_nodata_tag(): ds = gdal.Open('data/empty_nodata.tif') if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' @@ -2511,7 +2452,6 @@ def test_tiff_read_strace_check(): lines_with_dotdot_gcore += [line] if len(lines_with_dotdot_gcore) != 1: - gdaltest.post_reason('fail') print(lines_with_dotdot_gcore) return 'fail' @@ -2550,7 +2490,6 @@ def test_tiff_read_minisblack_as_rgba(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [4672, 4672, 4672, 4873]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2571,7 +2510,6 @@ def test_tiff_read_colortable_as_rgba(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [2433, 2433, 2433, 4873]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2593,7 +2531,6 @@ def test_tiff_read_logl_as_rgba(): got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] # I'm pretty sure this isn't the expected result... if got_cs != [0, 0, 0, 4873]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2618,7 +2555,6 @@ def test_tiff_read_strip_separate_as_rgba(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [21212, 21053, 21349, 30658]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2635,7 +2571,6 @@ def test_tiff_read_strip_separate_as_rgba(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [21212, 21212, 21212, 30658]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2662,7 +2597,6 @@ def test_tiff_read_tiled_separate_as_rgba(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [21212, 21053, 21349, 30658]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2678,7 +2612,6 @@ def test_tiff_read_tiled_separate_as_rgba(): gdal.SetConfigOption('GTIFF_FORCE_RGBA', None) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != [4672, 4672, 4672, 4873]: - gdaltest.post_reason('fail') print(got_cs) return 'fail' ds = None @@ -2710,11 +2643,9 @@ def test_tiff_read_wrong_number_extrasamples(): with gdaltest.error_handler(): ds = gdal.Open('data/6band_wrong_number_extrasamples.tif') if gdal.GetLastErrorMsg().find('Wrong number of ExtraSamples') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' if ds.GetRasterBand(6).GetRasterColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(6).GetRasterColorInterpretation()) return 'fail' @@ -2730,7 +2661,6 @@ def test_tiff_read_one_strip_no_bytecount(): ds = gdal.Open('data/one_strip_nobytecount.tif') gdal.PopErrorHandler() if ds.GetRasterBand(1).Checksum() != 1: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' @@ -2953,7 +2883,6 @@ def test_tiff_read_one_band_from_two_bands(): ds = gdal.Open('/vsimem/tiff_read_one_band_from_two_bands_dst.tif') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/tiff_read_one_band_from_two_bands.tif') @@ -2970,7 +2899,6 @@ def test_tiff_read_jpeg_cloud_optimized(): cs0 = ds.GetRasterBand(1).Checksum() cs1 = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs0 != 4743 or cs1 != 1133: - gdaltest.post_reason('failure') print(i) print(cs0) print(cs1) @@ -2990,7 +2918,6 @@ def test_tiff_read_corrupted_jpeg_cloud_optimized(): ds = gdal.Open('data/byte_ovr_jpeg_tablesmode_not_correctly_set_on_ovr.tif') cs0 = ds.GetRasterBand(1).Checksum() if cs0 != 4743: - gdaltest.post_reason('failure') print(cs0) return 'fail' @@ -2999,7 +2926,6 @@ def test_tiff_read_corrupted_jpeg_cloud_optimized(): if cs1 == 0: print('Expected error while writing overview with libjpeg-6b') elif cs1 != 1133: - gdaltest.post_reason('failure') print(cs1) return 'fail' @@ -3033,7 +2959,6 @@ def test_tiff_read_ycbcr_lzw(): if cs1 == 0: gdal.PopErrorHandler() if got_cs1 != cs1 or got_cs2 != cs2 or got_cs3 != cs3: - gdaltest.post_reason('failure') print(filename, got_cs1, got_cs2, got_cs3) return 'fail' @@ -3048,10 +2973,8 @@ def test_tiff_read_ycbcr_int12(): with gdaltest.error_handler(): ds = gdal.Open('data/int12_ycbcr_contig.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Cannot open TIFF file with') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -3072,7 +2995,6 @@ def test_tiff_read_unit_from_srs(): ds = gdal.Open('/vsimem/tiff_read_unit_from_srs.tif') unit = ds.GetRasterBand(1).GetUnitType() if unit != 'metre': - gdaltest.post_reason('fail') print(unit) return 'fail' ds = None @@ -3089,10 +3011,8 @@ def test_tiff_read_arcgis93_geodataxform_gcp(): ds = gdal.Open('data/arcgis93_geodataxform_gcp.tif') if ds.GetGCPProjection().find('26712') < 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPCount() != 16: - gdaltest.post_reason('fail') return 'fail' gcp = ds.GetGCPs()[0] if abs(gcp.GCPPixel - 565) > 1e-5 or \ @@ -3100,7 +3020,6 @@ def test_tiff_read_arcgis93_geodataxform_gcp(): abs(gcp.GCPX - 500000) > 1e-5 or \ abs(gcp.GCPY - 4705078.79016612) > 1e-5 or \ abs(gcp.GCPZ - 0) > 1e-5: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3113,7 +3032,6 @@ def test_tiff_read_block_width_above_32bit(): with gdaltest.error_handler(): ds = gdal.Open('data/block_width_above_32bit.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3126,7 +3044,6 @@ def test_tiff_read_image_width_above_32bit(): with gdaltest.error_handler(): ds = gdal.Open('data/image_width_above_32bit.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3139,13 +3056,11 @@ def test_tiff_read_second_image_width_above_32bit(): ds = gdal.Open('data/second_image_width_above_32bit.tif') with gdaltest.error_handler(): if ds.GetMetadata("SUBDATASETS") != {}: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('GTIFF_DIR:2:data/second_image_width_above_32bit.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3159,11 +3074,9 @@ def test_tiff_read_minimum_tiff_tags_no_warning(): gdal.ErrorReset() ds = gdal.Open('data/minimum_tiff_tags_no_warning.tif') if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).Checksum() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3178,12 +3091,10 @@ def test_tiff_read_minimum_tiff_tags_with_warning(): with gdaltest.error_handler(): ds = gdal.Open('data/minimum_tiff_tags_with_warning.tif') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() ds.GetRasterBand(1).Checksum() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3429,10 +3340,8 @@ def test_tiff_read_uint33(): with gdaltest.error_handler(): ds = gdal.Open('data/uint33.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Unsupported TIFF configuration') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -3477,7 +3386,6 @@ def test_tiff_read_toomanyblocks(): with gdaltest.error_handler(): ds = gdal.Open('data/toomanyblocks.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3491,7 +3399,6 @@ def test_tiff_read_toomanyblocks_separate(): with gdaltest.error_handler(): ds = gdal.Open('data/toomanyblocks_separate.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3506,22 +3413,17 @@ def test_tiff_read_size_of_stripbytecount_lower_than_stripcount(): ds = gdal.Open('data/size_of_stripbytecount_lower_than_stripcount.tif') # There are 3 strips but StripByteCounts has just two elements; if ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_1', 'TIFF') != '171': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_0_1', 'TIFF') != '1': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_2', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_0_2', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('data/size_of_stripbytecount_at_1_and_lower_than_stripcount.tif') # There are 3 strips but StripByteCounts has just one element; if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_0_0', 'TIFF') != '1': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3595,7 +3497,6 @@ def test_tiff_read_progressive_jpeg_denial_of_service(): with gdaltest.error_handler(): cs = ds.GetRasterBand(1).Checksum() if cs != 0 or gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' # Should error out with 'TIFFjpeg_progress_monitor:Scan number... @@ -3608,7 +3509,6 @@ def test_tiff_read_progressive_jpeg_denial_of_service(): del os.environ['LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC'] del os.environ['LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER'] if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3651,7 +3551,6 @@ def test_tiff_read_mmap_interface(): cs = ds.GetRasterBand(1).Checksum() gdal.SetConfigOption('GTIFF_USE_MMAP', None) if cs != 4672: - gdaltest.post_reason('fail') print(options, cs) return 'fail' @@ -3667,7 +3566,6 @@ def test_tiff_read_mmap_interface(): cs = ds.GetRasterBand(1).Checksum() gdal.SetConfigOption('GTIFF_USE_MMAP', None) if cs != 0: - gdaltest.post_reason('fail') print(options, cs) return 'fail' gdal.Unlink(tmpfile) @@ -3691,7 +3589,6 @@ def test_tiff_read_jpeg_too_big_last_stripe(): with gdaltest.error_handler(): cs = ds.GetRasterBand(1).Checksum() if cs != 4557: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -3699,7 +3596,6 @@ def test_tiff_read_jpeg_too_big_last_stripe(): with gdaltest.error_handler(): cs = ds.GetRasterBand(1).Checksum() if cs != 4557: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -3714,19 +3610,16 @@ def test_tiff_read_negative_scaley(): ds = gdal.Open('data/negative_scaley.tif') with gdaltest.error_handler(): if ds.GetGeoTransform()[5] != -60: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('data/negative_scaley.tif') with gdaltest.config_option('GTIFF_HONOUR_NEGATIVE_SCALEY', 'NO'): if ds.GetGeoTransform()[5] != -60: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('data/negative_scaley.tif') with gdaltest.config_option('GTIFF_HONOUR_NEGATIVE_SCALEY', 'YES'): if ds.GetGeoTransform()[5] != 60: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3850,11 +3743,9 @@ def test_tiff_read_overview_of_external_mask(): gdal.Unlink(filename + '.msk') if cs1 != cs2: - gdaltest.post_reason('fail') print(cs1, cs2) return 'fail' if flags1 != gdal.GMF_PER_DATASET: - gdaltest.post_reason('fail') print(flags1) return 'fail' diff --git a/autotest/gcore/tiff_srs.py b/autotest/gcore/tiff_srs.py index 03fed36f28d6..dd34fcbbe821 100755 --- a/autotest/gcore/tiff_srs.py +++ b/autotest/gcore/tiff_srs.py @@ -190,7 +190,6 @@ def test_tiff_srs_WGS_1984_Web_Mercator_Auxiliary_Sphere(): PARAMETER["Auxiliary_Sphere_Type",0.0], UNIT["Meter",1.0], EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"]]""": - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -213,7 +212,6 @@ def test_tiff_srs_angular_units(): wkt = ds.GetProjectionRef() if wkt.find('UNIT["arc-second",4.848136811095361e-06]') < 0 and \ wkt.find('UNIT["arc-second",4.848136811095361e-006]') < 0: # wine variant - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -228,7 +226,6 @@ def test_tiff_srs_angular_units(): ds = gdal.Open('/vsimem/tiff_srs_angular_units.tif') wkt = ds.GetProjectionRef() if wkt.find('UNIT["arc-minute",0.0002908882086657216]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -243,7 +240,6 @@ def test_tiff_srs_angular_units(): ds = gdal.Open('/vsimem/tiff_srs_angular_units.tif') wkt = ds.GetProjectionRef() if wkt.find('UNIT["grad",0.01570796326794897]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -258,7 +254,6 @@ def test_tiff_srs_angular_units(): ds = gdal.Open('/vsimem/tiff_srs_angular_units.tif') wkt = ds.GetProjectionRef() if wkt.find('UNIT["gon",0.01570796326794897]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -273,7 +268,6 @@ def test_tiff_srs_angular_units(): ds = gdal.Open('/vsimem/tiff_srs_angular_units.tif') wkt = ds.GetProjectionRef() if wkt.find('UNIT["radian",1]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -288,7 +282,6 @@ def test_tiff_srs_angular_units(): ds = gdal.Open('/vsimem/tiff_srs_angular_units.tif') wkt = ds.GetProjectionRef() if wkt.find('UNIT["custom",1.23]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -313,7 +306,6 @@ def test_tiff_custom_datum_known_ellipsoid(): ds = gdal.Open('/vsimem/tiff_custom_datum_known_ellipsoid.tif') wkt = ds.GetProjectionRef() if wkt != 'GEOGCS["WGS 84 based",DATUM["WGS_1984_based",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]': - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -335,7 +327,6 @@ def test_tiff_srs_epsg_2853_with_us_feet(): gdal.SetConfigOption('GTIFF_IMPORT_FROM_EPSG', old_val) wkt = ds.GetProjectionRef() if wkt.find('PARAMETER["false_easting",11482916.66') < 0 or wkt.find('UNIT["us_survey_feet",0.3048006') < 0 or wkt.find('2853') >= 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -344,7 +335,6 @@ def test_tiff_srs_epsg_2853_with_us_feet(): gdal.SetConfigOption('GTIFF_IMPORT_FROM_EPSG', old_val) wkt = ds.GetProjectionRef() if wkt.find('PARAMETER["false_easting",11482916.66') < 0 or wkt.find('UNIT["us_survey_feet",0.3048006') < 0 or wkt.find('2853') >= 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -375,7 +365,6 @@ def test_tiff_srs_PCSCitationGeoKey_LUnits(): ds = gdal.Open('/vsimem/tiff_srs_PCSCitationGeoKey_LUnits.tif') wkt = ds.GetProjectionRef() if wkt != 'PROJCS["UTM Zone 32, Northern Hemisphere",GEOGCS["GRS 1980(IUGG, 1980)",DATUM["unknown",SPHEROID["GRS80",6378137,298.257222101],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",50000000],PARAMETER["false_northing",0],UNIT["Centimeter",0.01]]': - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -395,7 +384,6 @@ def test_tiff_srs_projection_3856(): ds = None if wkt.find('EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -412,7 +400,6 @@ def test_tiff_srs_imagine_localcs_citation(): ds = None if wkt != 'LOCAL_CS["Projection Name = UTM Units = meters GeoTIFF Units = meters",UNIT["unknown",1]]': - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -430,7 +417,6 @@ def test_tiff_srs_towgs84_override(): ds = None if wkt.find('TOWGS84[584.8,67,400.3,0.105,0.013,-2.378,10.29]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -447,7 +433,6 @@ def test_tiff_srs_pcscitation(): ds = None if wkt.find('PROJCS["mycitation",') != 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' diff --git a/autotest/gcore/tiff_write.py b/autotest/gcore/tiff_write.py index 787725d740ff..0a16343bc207 100755 --- a/autotest/gcore/tiff_write.py +++ b/autotest/gcore/tiff_write.py @@ -1244,36 +1244,29 @@ def test_tiff_write_29(): # TIFFTAG_EXTRASAMPLES=EXTRASAMPLE_UNSPECIFIED ds = gdaltest.tiff_drv.Create('/vsimem/rgba.tif', 1, 1, 4, options=['PHOTOMETRIC=RGB']) if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '0': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' if ds.GetRasterBand(4).GetRasterColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' # Now turn on alpha ds.GetRasterBand(4).SetRasterColorInterpretation(gdal.GCI_AlphaBand) if ds.GetRasterBand(4).GetRasterColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' ds = None if gdal.VSIStatL('/vsimem/rgba.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/rgba.tif') if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' if ds.GetRasterBand(4).GetRasterColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' # Test cancelling alpha @@ -1281,16 +1274,13 @@ def test_tiff_write_29(): ds = None if gdal.VSIStatL('/vsimem/rgb_no_alpha.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/rgb_no_alpha.tif') if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '0': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' if ds.GetRasterBand(4).GetRasterColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' # Test re-adding alpha @@ -1298,16 +1288,13 @@ def test_tiff_write_29(): ds = None if gdal.VSIStatL('/vsimem/rgb_added_alpha.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/rgb_added_alpha.tif') if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' if ds.GetRasterBand(4).GetRasterColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2616,23 +2603,19 @@ def test_tiff_write_70(): ds = gdal.Open('tmp/tiff_write_70.tif', gdal.GA_Update) if ds.GetRasterBand(1).DeleteNoDataValue() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') return 'fail' ds = None try: os.stat('tmp/tiff_write_70.tif.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass ds = gdal.Open('tmp/tiff_write_70.tif') if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3655,7 +3638,6 @@ def test_tiff_write_87(): return 'fail' if ifd_main != 8 and not(ifd_main < ifd_ovr_0 and ifd_ovr_0 < ifd_ovr_1 and ifd_ovr_1 < data_ovr_1 and data_ovr_1 < data_ovr_0 and data_ovr_0 < data_main): - gdaltest.post_reason('failure') print(ifd_main, ifd_ovr_0, ifd_ovr_1, data_ovr_1, data_ovr_0, data_main) return 'fail' @@ -4653,7 +4635,6 @@ def test_tiff_write_115(): ds = gdal.Open(tmpfilename) md = ds.GetMetadata('IMAGE_STRUCTURE') if md['INTERLEAVE'] != 'PIXEL': - gdaltest.post_reason('failed') ds = None gdal.Unlink(tmpfilename) return 'fail' @@ -4662,13 +4643,11 @@ def test_tiff_write_115(): for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs[i]: - gdaltest.post_reason('failed') ds = None gdal.Unlink(tmpfilename) return 'fail' if ds.GetRasterBand(i + 1).GetRasterColorInterpretation() != gdal.GCI_RedBand + i: - gdaltest.post_reason('failed') ds = None gdal.Unlink(tmpfilename) return 'fail' @@ -4705,7 +4684,6 @@ def test_tiff_write_116(): ds = gdal.Open(tmpfilename) md = ds.GetMetadata('IMAGE_STRUCTURE') if md['INTERLEAVE'] != 'BAND': - gdaltest.post_reason('failed') ds = None gdal.Unlink(tmpfilename) return 'fail' @@ -4714,13 +4692,11 @@ def test_tiff_write_116(): for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs[i]: - gdaltest.post_reason('failed') ds = None gdal.Unlink(tmpfilename) return 'fail' if ds.GetRasterBand(i + 1).GetRasterColorInterpretation() != gdal.GCI_RedBand + i: - gdaltest.post_reason('failed') ds = None gdal.Unlink(tmpfilename) return 'fail' @@ -4876,7 +4852,6 @@ def test_tiff_write_121(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_121.tif', src_ds, options=['COPY_SRC_OVERVIEWS=YES']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' src_ds = None @@ -4903,7 +4878,6 @@ def test_tiff_write_121(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_121.tif', src_ds, options=['COPY_SRC_OVERVIEWS=YES']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' src_ds = None @@ -4934,7 +4908,6 @@ def test_tiff_write_121(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_121.tif', src_ds, options=['COPY_SRC_OVERVIEWS=YES']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' src_ds = None @@ -4994,20 +4967,15 @@ def test_tiff_write_123(): gdaltest.post_reason('did not expect a TIFFTAG_GDAL_METADATA tag') return 'fail' if src_ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(src_ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_')) return 'fail' if src_ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(5).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if src_ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '0,2': - gdaltest.post_reason('fail') print(src_ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' @@ -5022,16 +4990,12 @@ def test_tiff_write_123(): gdaltest.post_reason('did not expect a TIFFTAG_GDAL_METADATA tag') return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(5).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '0,2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' ds = None @@ -5042,16 +5006,13 @@ def test_tiff_write_123(): # From implicit RGB to BGR (with Photometric = MinIsBlack) ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_123_bgr.tif', 1, 1, 3, gdal.GDT_Byte) if ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_')) return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') is not None: - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_BlueBand) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_GreenBand) ds.GetRasterBand(3).SetColorInterpretation(gdal.GCI_RedBand) @@ -5063,24 +5024,19 @@ def test_tiff_write_123(): return 'fail' ds = gdal.Open('/vsimem/tiff_write_123_bgr.tif') if ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_') != '1': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_')) return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '0,0': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' if ds.GetMetadataItem('TIFFTAG_GDAL_METADATA', '_DEBUG_') is None: gdaltest.post_reason('expected a TIFFTAG_GDAL_METADATA tag') return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5095,13 +5051,10 @@ def test_tiff_write_123(): return 'fail' ds = gdal.Open('/vsimem/tiff_write_123_bgr.tif') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_123_bgr.tif') @@ -5123,13 +5076,10 @@ def test_tiff_write_123(): gdaltest.post_reason('did not expect a TIFFTAG_GDAL_METADATA tag') return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_123_bgr.tif') @@ -5137,30 +5087,23 @@ def test_tiff_write_123(): # From implicit RGBA to MINISBLACK ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_123_rgba.tif', 1, 1, 4, gdal.GDT_Byte) if ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_')) return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_Undefined) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_') != '1': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_')) return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') != '0,0,2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' ds = None @@ -5184,10 +5127,8 @@ def test_tiff_write_123(): gdaltest.post_reason('did not expect TIFFTAG_GDAL_METADATA tag') return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_123_guua.tif') @@ -5198,11 +5139,9 @@ def test_tiff_write_123(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_123_rgb.tif', src_ds) src_ds = None if ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_') != '2': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_PHOTOMETRIC', '_DEBUG_')) return 'fail' if ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_') is not None: - gdaltest.post_reason('fail') print(ds.GetMetadataItem('TIFFTAG_EXTRASAMPLES', '_DEBUG_')) return 'fail' ds = None @@ -5216,7 +5155,6 @@ def test_tiff_write_123(): options=['PHOTOMETRIC=RGB']) ds = gdal.Open('/vsimem/tiff_write_123_rgb.tif') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_123_rgb.tif') @@ -5227,13 +5165,10 @@ def test_tiff_write_123(): options=['PHOTOMETRIC=RGB']) ds = gdal.Open('/vsimem/tiff_write_123_rgbua.tif') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(5).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_123_rgbua.tif') @@ -5250,7 +5185,6 @@ def test_tiff_write_123(): return 'fail' ds = gdal.Open('/vsimem/tiff_write_123_rgba_to_undefined.tif') if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_123_rgba_to_undefined.tif') @@ -5369,46 +5303,38 @@ def test_tiff_write_126(): if ds.GetRasterBand(1).GetOverviewCount() != 0: print(options) print(ds.GetRasterBand(1).GetOverviewCount()) - gdaltest.post_reason('fail') return 'fail' # But they do exist... cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs not in cs1: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(2).GetOverview(0).Checksum() if cs not in cs2: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs not in cs3: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(2).Checksum() if cs not in cs4: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: print(options) - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(3) is not None: print(options) - gdaltest.post_reason('fail') return 'fail' ovr_1_data = ds.GetRasterBand(1).GetOverview(1).GetDataset().ReadRaster(0, 0, 400, 200) subsampled_data = ds.ReadRaster(0, 0, 1600, 800, 400, 200) if ovr_1_data != subsampled_data: print(options) - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5433,32 +5359,27 @@ def test_tiff_write_126(): if ds.GetRasterBand(1).GetOverviewCount() != 0: print(options) print(ds.GetRasterBand(1).GetOverviewCount()) - gdaltest.post_reason('fail') return 'fail' # But they do exist... cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs not in cs1: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs not in cs3: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(2).Checksum() if cs not in cs4: print(options) print(cs) - gdaltest.post_reason('fail') return 'fail' ovr_1_data = ds.GetRasterBand(1).GetOverview(1).GetDataset().ReadRaster(0, 0, 400, 200) subsampled_data = ds.ReadRaster(0, 0, 1600, 800, 400, 200) if ovr_1_data != subsampled_data: print(options) - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5475,13 +5396,11 @@ def test_tiff_write_126(): ds = gdal.Open('/vsimem/tiff_write_126.tif') if ds.GetRasterBand(1).GetBlockSize() != [8, 1]: print(ds.GetRasterBand(1).GetBlockSize()) - gdaltest.post_reason('fail') return 'fail' ovr_ds = ds.GetRasterBand(1).GetOverview(1).GetDataset() ovr_1_data = ovr_ds.ReadRaster(0, 0, ovr_ds.RasterXSize, ovr_ds.RasterYSize, 1, 1) subsampled_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 1, 1) if ovr_1_data != subsampled_data: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5498,16 +5417,12 @@ def test_tiff_write_126(): ds = gdal.Open('/vsimem/tiff_write_126.tif') if ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('JPEGTABLES', 'TIFF') is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_0', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('BLOCK_SIZE_0_0', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_126.tif') @@ -5522,7 +5437,6 @@ def test_tiff_write_126(): cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 0: print(cs) - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_126.tif') @@ -5549,7 +5463,6 @@ def test_tiff_write_127(): ds = gdal.Open('/vsimem/tiff_write_127.tif', gdal.GA_Update) obj = ds if i == 0 else ds.GetRasterBand(1) if obj.GetMetadataItem('key') != 'value': - gdaltest.post_reason('fail') print(i) print(obj.GetMetadata()) return 'fail' @@ -5560,7 +5473,6 @@ def test_tiff_write_127(): ds = gdal.Open('/vsimem/tiff_write_127.tif', gdal.GA_Update) obj = ds if i == 0 else ds.GetRasterBand(1) if obj.GetMetadata(): - gdaltest.post_reason('fail') print(i) return 'fail' obj.SetMetadataItem('key', 'value') @@ -5570,7 +5482,6 @@ def test_tiff_write_127(): ds = gdal.Open('/vsimem/tiff_write_127.tif', gdal.GA_Update) obj = ds if i == 0 else ds.GetRasterBand(1) if obj.GetMetadataItem('key') != 'value': - gdaltest.post_reason('fail') print(i) return 'fail' obj.SetMetadataItem('key', None) @@ -5580,7 +5491,6 @@ def test_tiff_write_127(): ds = gdal.Open('/vsimem/tiff_write_127.tif', gdal.GA_Update) obj = ds if i == 0 else ds.GetRasterBand(1) if obj.GetMetadata(): - gdaltest.post_reason('fail') print(i) return 'fail' obj = None @@ -5621,10 +5531,8 @@ def test_tiff_write_128(): ds = gdal.Open('GTIFF_RAW:/vsimem/tiff_write_128.tif') for i in range(4): if src_ds.GetRasterBand(i + 1).GetColorInterpretation() != ds.GetRasterBand(i + 1).GetColorInterpretation(): - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(i + 1).Checksum() != ds.GetRasterBand(i + 1).Checksum(): - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5641,10 +5549,8 @@ def test_tiff_write_128(): ds = gdal.Open('GTIFF_RAW:/vsimem/tiff_write_128.tif') for i in range(4): if src_ds.GetRasterBand(i + 1).GetColorInterpretation() != ds.GetRasterBand(i + 1).GetColorInterpretation(): - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(i + 1).Checksum() != ds.GetRasterBand(i + 1).Checksum(): - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5662,10 +5568,8 @@ def test_tiff_write_128(): for i in range(4): # The color interpretation will NOT be CMYK if src_ds.GetRasterBand(i + 1).GetColorInterpretation() == ds.GetRasterBand(i + 1).GetColorInterpretation(): - gdaltest.post_reason('fail') return 'fail' if src_ds.GetRasterBand(i + 1).Checksum() != ds.GetRasterBand(i + 1).Checksum(): - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5711,7 +5615,6 @@ def test_tiff_write_129(): if i == 0: cs_ref = cs elif cs != cs_ref: - gdaltest.post_reason('fail') print(jpegtablesmode) print(photometric) print(i) @@ -5734,7 +5637,6 @@ def test_tiff_write_130(): shutil.copyfile('data/byte_jpg_unusual_jpegtable.tif', 'tmp/byte_jpg_unusual_jpegtable.tif') ds = gdal.Open('tmp/byte_jpg_unusual_jpegtable.tif', gdal.GA_Update) if ds.GetRasterBand(1).Checksum() != 4771: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' src_ds = gdal.Open('data/byte.tif', gdal.GA_Update) @@ -5743,7 +5645,6 @@ def test_tiff_write_130(): ds = None ds = gdal.Open('tmp/byte_jpg_unusual_jpegtable.tif') if ds.GetRasterBand(1).Checksum() != 4743: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None @@ -5752,7 +5653,6 @@ def test_tiff_write_130(): shutil.copyfile('data/byte_jpg_tablesmodezero.tif', 'tmp/byte_jpg_tablesmodezero.tif') ds = gdal.Open('tmp/byte_jpg_tablesmodezero.tif', gdal.GA_Update) if ds.GetRasterBand(1).Checksum() != 4743: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' src_ds = gdal.Open('data/byte.tif', gdal.GA_Update) @@ -5761,7 +5661,6 @@ def test_tiff_write_130(): ds = None ds = gdal.Open('tmp/byte_jpg_tablesmodezero.tif') if ds.GetRasterBand(1).Checksum() != 4743: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None @@ -5784,7 +5683,6 @@ def test_tiff_write_131(level=1): ds = gdaltest.tiff_drv.CreateCopy(filename, src_ds, options=['COMPRESS=LZMA', 'LZMA_PRESET=' + str(level)]) if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5795,7 +5693,6 @@ def test_tiff_write_131(level=1): ds = gdal.Open(filename) if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5827,7 +5724,6 @@ def test_tiff_write_132(): # Check that PAM file exists if gdal.VSIStatL('/vsimem/tiff_write_132.tif.aux.xml') is None: - gdaltest.post_reason('fail') return 'fail' # Open in read-write @@ -5842,13 +5738,11 @@ def test_tiff_write_132(): # Check that PAM file no longer exists if gdal.VSIStatL('/vsimem/tiff_write_132.tif.aux.xml') is not None: - gdaltest.post_reason('fail') print(i) return 'fail' ds = gdal.Open('/vsimem/tiff_write_132.tif') if ds.GetMetadataItem('FOO') != 'BAZ' or ds.GetRasterBand(1).GetMetadataItem('FOO') != 'BAZ': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -5878,43 +5772,36 @@ def test_tiff_write_133(): ret = src_ds.SetProjection(srs.ExportToWkt()) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = src_ds.SetGeoTransform([1, 2, 0, 3, 0, -4]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = src_ds.SetMetadataItem('FOO', 'BAZ') gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = src_ds.SetMetadata({}) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = src_ds.GetRasterBand(1).SetMetadataItem('FOO', 'BAZ') gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = src_ds.GetRasterBand(1).SetMetadata({}) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = src_ds.GetRasterBand(1).SetNoDataValue(0) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Pixel interleaved @@ -5925,23 +5812,18 @@ def test_tiff_write_133(): ds = gdal.Open('/vsimem/tiff_write_133_dst.tif') gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds.GetProjectionRef().find('32601') < 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform() != (1.0, 2.0, 0.0, 3.0, 0.0, -2.0): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('FOO') != 'BAR': - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('UNORDERED_BLOCKS', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.SetCacheMax(0): for y in range(1000): got_data = ds.ReadRaster(0, y, 1024, 1) if got_data is None: - gdaltest.post_reason('fail') return 'fail' ds.FlushCache() @@ -5950,7 +5832,6 @@ def test_tiff_write_133(): got_data = ds.ReadRaster(0, y, 1024, 1) gdal.PopErrorHandler() if got_data is not None: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_133_dst.tif') @@ -5963,16 +5844,12 @@ def test_tiff_write_133(): ds = gdal.Open('/vsimem/tiff_write_133_dst.tif') gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds.GetProjectionRef().find('32601') < 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform() != (1.0, 2.0, 0.0, 3.0, 0.0, -2.0): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('FOO') != 'BAR': - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('UNORDERED_BLOCKS', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.SetCacheMax(0): @@ -5988,7 +5865,6 @@ def test_tiff_write_133(): xsize = ds.RasterXSize - x got_data = ds.ReadRaster(x, y, xsize, ysize) if got_data is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6002,7 +5878,6 @@ def test_tiff_write_133(): ds = gdal.Open('/vsimem/tiff_write_133_dst.tif') gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds.GetMetadataItem('UNORDERED_BLOCKS', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.SetCacheMax(0): @@ -6010,7 +5885,6 @@ def test_tiff_write_133(): for y in range(1000): got_data = ds.GetRasterBand(band + 1).ReadRaster(0, y, 1024, 1) if got_data is None: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_133_dst.tif') @@ -6025,14 +5899,12 @@ def test_tiff_write_133(): ds = gdal.Open('/vsimem/tiff_write_133_dst.tif') gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds.GetMetadataItem('UNORDERED_BLOCKS', 'TIFF') is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.SetCacheMax(0): for y in range(1000): got_data = ds.ReadRaster(0, y, 1024, 1) if got_data is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6043,20 +5915,17 @@ def test_tiff_write_133(): out_ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_133_dst.tif', src_ds, options=['STREAMABLE_OUTPUT=YES', 'COMPRESS=DEFLATE']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Test writing into a non authorized file ds = gdaltest.tiff_drv.Create('/foo/bar', 1024, 1000, 3, options=['STREAMABLE_OUTPUT=YES', 'BLOCKYSIZE=1']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() out_ds = gdaltest.tiff_drv.CreateCopy('/foo/bar', src_ds, options=['STREAMABLE_OUTPUT=YES']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' src_ds = None @@ -6068,7 +5937,6 @@ def test_tiff_write_133(): gdal.PopErrorHandler() gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # BigTIFF with IFD not at offset 16 @@ -6085,7 +5953,6 @@ def test_tiff_write_133(): gdal.PopErrorHandler() gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Test reading strips in not increasing order @@ -6101,14 +5968,12 @@ def test_tiff_write_133(): gdal.PopErrorHandler() gdal.SetConfigOption('TIFF_READ_STREAMING', None) if ds.GetMetadataItem('UNORDERED_BLOCKS', 'TIFF') != 'YES': - gdaltest.post_reason('fail') return 'fail' with gdaltest.SetCacheMax(0): for y in range(1000): got_data = ds.ReadRaster(0, 1000 - y - 1, 1024, 1) if got_data is None: - gdaltest.post_reason('fail') return 'fail' # Test writing strips in not increasing order in a streamable output @@ -6119,7 +5984,6 @@ def test_tiff_write_133(): ds.FlushCache() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6131,7 +5995,6 @@ def test_tiff_write_133(): ds.FlushCache() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6155,7 +6018,6 @@ def test_tiff_write_134(): cs2 = ds.GetRasterBand(2).Checksum() cs3 = ds.GetRasterBand(3).Checksum() if cs1 != 1 or cs2 != 0 or cs3 != 5: - gdaltest.post_reason('fail') print(cs1) print(cs2) print(cs3) @@ -6174,7 +6036,6 @@ def test_tiff_write_134(): cs2 = ds.GetRasterBand(2).Checksum() cs3 = ds.GetRasterBand(3).Checksum() if cs1 != 1 or cs2 != 0 or cs3 != 5: - gdaltest.post_reason('fail') print(cs1) print(cs2) print(cs3) @@ -6193,7 +6054,6 @@ def test_tiff_write_134(): cs2 = ds.GetRasterBand(2).Checksum() cs3 = ds.GetRasterBand(3).Checksum() if cs1 != 5 or cs2 != 5 or cs3 != 5: - gdaltest.post_reason('fail') print(cs1) print(cs2) print(cs3) @@ -6220,10 +6080,8 @@ def test_tiff_write_135(): ds = gdal.Open('/vsimem/tiff_write_135.tif') if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPProjection() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6239,10 +6097,8 @@ def test_tiff_write_135(): ds = gdal.Open('/vsimem/tiff_write_135.tif') if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPProjection() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6261,13 +6117,10 @@ def test_tiff_write_135(): ds = gdal.Open('/vsimem/tiff_write_135.tif') if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform() != (1, 2, 3, 4, 5, -6): - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef().find('32601') < 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6290,7 +6143,6 @@ def test_tiff_write_136(): ds = gdal.Open('/vsimem/tiff_write_136.tif') cs = ds.GetRasterBand(1).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -6321,7 +6173,6 @@ def test_tiff_write_137(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -6335,7 +6186,6 @@ def test_tiff_write_137(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -6351,7 +6201,6 @@ def test_tiff_write_137(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -6363,7 +6212,6 @@ def test_tiff_write_137(): ds.FlushCache() val = ds.ReadRaster(0, 0, 1, 1).decode('ascii') if val != 'A': - gdaltest.post_reason('fail') print(val) return 'fail' ds = None @@ -6381,7 +6229,6 @@ def test_tiff_write_137(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != 4672: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -6408,7 +6255,6 @@ def test_tiff_write_138(): ds = None size = gdal.VSIStatL('/vsimem/tiff_write_138.tif').size if size != 181: - gdaltest.post_reason('fail') print(size) return 'fail' @@ -6433,7 +6279,6 @@ def test_tiff_write_138(): ds = None size = gdal.VSIStatL('/vsimem/tiff_write_138.tif').size if size != 181: - gdaltest.post_reason('fail') print(size) return 'fail' @@ -6466,7 +6311,6 @@ def test_tiff_write_139(): for i in range(nbands): content = ds.GetRasterBand(i + 1).ReadRaster() if ref_content != content: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -6486,7 +6330,6 @@ def test_tiff_write_139(): ds = gdal.Open('/vsimem/tiff_write_139.tif') content = ds.GetRasterBand(1).ReadRaster() if ref_content != content: - gdaltest.post_reason('fail') print(endianness) print(struct.unpack('h' * 6, content)) return 'fail' @@ -6508,7 +6351,6 @@ def test_tiff_write_139(): ds = gdal.Open('/vsimem/tiff_write_139.tif') content = ds.GetRasterBand(1).ReadRaster() if ref_content != content: - gdaltest.post_reason('fail') print(endianness) print(struct.unpack('H' * 6, content)) return 'fail' @@ -6530,7 +6372,6 @@ def test_tiff_write_139(): ds = gdal.Open('/vsimem/tiff_write_139.tif') content = ds.GetRasterBand(1).ReadRaster() if ref_content != content: - gdaltest.post_reason('fail') print(endianness) print(struct.unpack('I' * 6, content)) return 'fail' @@ -6548,7 +6389,6 @@ def test_tiff_write_139(): ds = gdal.Open('/vsimem/tiff_write_139.tif') content = ds.GetRasterBand(1).ReadRaster() if ref_content != content: - gdaltest.post_reason('fail') print(struct.unpack('d' * 4, content)) return 'fail' ds = None @@ -6573,7 +6413,6 @@ def test_tiff_write_140(): return 'fail' ds = gdal.Open('/vsimem/tiff_write_140.tif') if ds.GetRasterBand(5).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(5).GetColorInterpretation()) return 'fail' ds = None @@ -6586,10 +6425,8 @@ def test_tiff_write_140(): with gdaltest.error_handler(): ret = ds.GetRasterBand(5).SetColorInterpretation(gdal.GCI_AlphaBand) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds = None statBuf = gdal.VSIStatL('/vsimem/tiff_write_140.tif.aux.xml', gdal.VSI_STAT_EXISTS_FLAG | gdal.VSI_STAT_NATURE_FLAG | gdal.VSI_STAT_SIZE_FLAG) @@ -6598,11 +6435,9 @@ def test_tiff_write_140(): return 'fail' ds = gdal.Open('/vsimem/tiff_write_140.tif') if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(5).GetColorInterpretation()) return 'fail' if ds.GetRasterBand(5).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(5).GetColorInterpretation()) return 'fail' ds = None @@ -6614,10 +6449,8 @@ def test_tiff_write_140(): with gdaltest.error_handler(): ret = ds.GetRasterBand(5).SetColorInterpretation(gdal.GCI_AlphaBand) if gdal.GetLastErrorMsg().find('ALPHA') < 0: - gdaltest.post_reason('fail') return 'fail' if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds = None statBuf = gdal.VSIStatL('/vsimem/tiff_write_140.tif.aux.xml', gdal.VSI_STAT_EXISTS_FLAG | gdal.VSI_STAT_NATURE_FLAG | gdal.VSI_STAT_SIZE_FLAG) @@ -6626,11 +6459,9 @@ def test_tiff_write_140(): return 'fail' ds = gdal.Open('/vsimem/tiff_write_140.tif') if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(5).GetColorInterpretation()) return 'fail' if ds.GetRasterBand(5).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(5).GetColorInterpretation()) return 'fail' ds = None @@ -6656,12 +6487,10 @@ def test_tiff_write_141(): ds = None if wkt.find('PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere"') != 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' if wkt.find('EXTENSION["PROJ4"') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -6713,7 +6542,6 @@ def test_tiff_write_143(): with gdaltest.error_handler(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_143.tif', 1000000000, 1000000000) if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -6755,7 +6583,6 @@ def test_tiff_write_144(): gdal.Unlink('tmp/tiff_write_144.tif') if got_cs != 4873 or got_cs_ovr != 1218: - gdaltest.post_reason('fail') print(got_cs) print(got_cs_ovr) return 'fail' @@ -6926,7 +6753,6 @@ def test_tiff_write_149(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != 1: - gdaltest.post_reason('fail') print(cs) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_149.tif') @@ -6941,7 +6767,6 @@ def test_tiff_write_149(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_149.tif') @@ -6955,7 +6780,6 @@ def test_tiff_write_149(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_149.tif') @@ -6969,7 +6793,6 @@ def test_tiff_write_149(): cs = ds.GetRasterBand(1).Checksum() ds = None if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_149.tif') @@ -6989,7 +6812,6 @@ def test_tiff_write_150(): with gdaltest.error_handler(): ds.FlushCache() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('tmp/tiled_bad_offset.tif') @@ -7014,13 +6836,10 @@ def test_tiff_write_151(): ds = None ds = gdal.Open('/vsimem/tiff_write_151.tif') if ds.GetRasterBand(1).Checksum() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).Checksum() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).Checksum() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_151.tif') @@ -7039,11 +6858,9 @@ def test_tiff_write_152(): ds = None ds = gdal.Open('/vsimem/tiff_write_152.tif') if ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' if ds.GetRasterBand(2).Checksum() != 1: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None @@ -7071,7 +6888,6 @@ def test_tiff_write_153(): gdaltest.tiff_drv.Delete(target_dir + '/tiff_write_153.tif') if ret == gdal.VSI_RANGE_STATUS_DATA: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -7091,13 +6907,11 @@ def test_tiff_write_154(): ds.FlushCache() # At that point empty blocks have not yet been flushed if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 162: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' ds = None # Now they are and that's done in a filesystem sparse way. TODO: check this if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 256162: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_154.tif') @@ -7106,12 +6920,10 @@ def test_tiff_write_154(): ds.FlushCache() # With compression, empty blocks are written right away if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 462: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 462: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_154.tif') @@ -7120,7 +6932,6 @@ def test_tiff_write_154(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_154.tif', src_ds, options=['SPARSE_OK=YES', 'BLOCKYSIZE=256']) ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 162: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' # SPARSE_OK in Open()/update: blocks are not written @@ -7128,7 +6939,6 @@ def test_tiff_write_154(): ds.GetRasterBand(1).Fill(0) ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 162: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' ds = None @@ -7137,7 +6947,6 @@ def test_tiff_write_154(): ds.GetRasterBand(1).Fill(0) ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 250162: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' ds = None @@ -7147,7 +6956,6 @@ def test_tiff_write_154(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_154.tif', src_ds, options=['SPARSE_OK=YES', 'BLOCKYSIZE=256', 'COMPRESS=DEFLATE']) ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 174: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_154.tif') @@ -7156,7 +6964,6 @@ def test_tiff_write_154(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_154.tif', src_ds, options=['SPARSE_OK=YES', 'TILED=YES']) ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 190: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' gdaltest.tiff_drv.Delete('/vsimem/tiff_write_154.tif') @@ -7174,7 +6981,6 @@ def test_tiff_write_154(): options = ['SPARSE_OK=YES', 'BLOCKYSIZE=256'] gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_154.tif', src_ds, options=options) if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 162: - gdaltest.post_reason('fail') print(dt) print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' @@ -7195,7 +7001,6 @@ def test_tiff_write_154(): ds = gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_154.tif', src_ds, options=options) ds = None if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 174: - gdaltest.post_reason('fail') print(dt) print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' @@ -7206,7 +7011,6 @@ def test_tiff_write_154(): src_ds.GetRasterBand(1).WriteRaster(99, 0, 1, 1, struct.pack('B' * 1, 1)) gdaltest.tiff_drv.CreateCopy('/vsimem/tiff_write_154.tif', src_ds, options=['SPARSE_OK=YES']) if gdal.VSIStatL('/vsimem/tiff_write_154.tif').size != 246: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/tiff_write_154.tif').size) return 'fail' @@ -7221,7 +7025,6 @@ def test_tiff_write_154(): ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_154.tif') if offset is None or int(offset) == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -7237,12 +7040,10 @@ def test_tiff_write_155(): ds = None if gdal.VSIStatL('/vsimem/tiff_write_155.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_155.tif') if ds.GetRasterBand(1).GetDescription() != 'foo': - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_155.tif') @@ -7252,12 +7053,10 @@ def test_tiff_write_155(): ds = None if gdal.VSIStatL('/vsimem/tiff_write_155.tif.aux.xml') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_155.tif') if ds.GetRasterBand(1).GetDescription() != 'foo': - gdaltest.post_reason('fail') return 'fail' ds = None gdaltest.tiff_drv.Delete('/vsimem/tiff_write_155.tif') @@ -7275,21 +7074,18 @@ def test_tiff_write_156(): (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(0, 0, 32, 32) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_DATA or pct != 100.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(32, 0, 32, 32) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_EMPTY or pct != 0.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(16, 16, 32, 32) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_DATA | gdal.GDAL_DATA_COVERAGE_STATUS_EMPTY or pct != 25.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' @@ -7304,7 +7100,6 @@ def test_tiff_write_156(): ds = gdal.Open('/vsimem/tiff_write_156.tif') flags, _ = ds.GetRasterBand(1).GetDataCoverageStatus(0, 100, 1, 1) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_DATA: - gdaltest.post_reason('failure') print(flags) return 'fail' ds = None @@ -7352,19 +7147,16 @@ def test_tiff_write_157(): # Check that we properly deserialize Float16 values ds = gdal.Open('/vsimem/tiff_write_157.tif') if ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '16': - gdaltest.post_reason('failure') return 'fail' got = struct.unpack('f' * 14, ds.ReadRaster()) expected = [0.0, -0.0, gdaltest.posinf(), -gdaltest.posinf(), gdaltest.NaN(), gdaltest.NaN(), 1.25, -1.25, 5.9604644775390625e-08, -5.9604644775390625e-08, 6.0975551605224609e-05, -6.0975551605224609e-05, 6.103515625e-05, -6.103515625e-05] for i in range(14): if i == 4 or i == 5: if got[i] == got[i]: - gdaltest.post_reason('failure') print(i) print(got[i]) return 'fail' elif abs(got[i] - expected[i]) > 1e-15: - gdaltest.post_reason('failure') print(i) print(got[i]) print(expected[i]) @@ -7384,7 +7176,6 @@ def test_tiff_write_157(): gdal.VSIFCloseL(f) if vals != vals_copied: - gdaltest.post_reason('failure') print(struct.unpack('H' * 14, vals)) print(struct.unpack('H' * 14, vals_copied)) return 'fail' @@ -7428,12 +7219,10 @@ def test_tiff_write_157(): for i in range(18): if i == 4 or i == 5: if got[i] == got[i]: - gdaltest.post_reason('failure') print(i) print(got[i]) return 'fail' elif abs(got[i] - expected[i]) > 1e-15: - gdaltest.post_reason('failure') print(i) print(got[i]) print(expected[i]) @@ -7446,12 +7235,10 @@ def test_tiff_write_157(): ds = gdal.Open('/vsimem/tiff_write_157.tif') cs = ds.GetRasterBand(1).Checksum() if cs != 30111: - gdaltest.post_reason('failure') print(cs) return 'fail' cs = ds.GetRasterBand(2).Checksum() if cs != 32302: - gdaltest.post_reason('failure') print(cs) return 'fail' ds = None @@ -7469,29 +7256,23 @@ def test_tiff_write_158(): ds = gdaltest.tiff_drv.Create('/vsimem/tiff_write_158.tif', 20, 40, 1, options=['TILED=YES', 'BLOCKXSIZE=16', 'BLOCKYSIZE=32']) (w, h) = ds.GetRasterBand(1).GetActualBlockSize(0, 0) if (w, h) != (16, 32): - gdaltest.post_reason('failure') print(w, h) return 'fail' (w, h) = ds.GetRasterBand(1).GetActualBlockSize(1, 1) if (w, h) != (4, 8): - gdaltest.post_reason('failure') print(w, h) return 'fail' res = ds.GetRasterBand(1).GetActualBlockSize(2, 0) if res is not None: - gdaltest.post_reason('failure') return 'fail' res = ds.GetRasterBand(1).GetActualBlockSize(0, 2) if res is not None: - gdaltest.post_reason('failure') return 'fail' res = ds.GetRasterBand(1).GetActualBlockSize(-1, 0) if res is not None: - gdaltest.post_reason('failure') return 'fail' res = ds.GetRasterBand(1).GetActualBlockSize(0, -1) if res is not None: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -7527,7 +7308,6 @@ def test_tiff_write_159(): cs1 = ds.GetRasterBand(1).GetOverview(0).Checksum() cs2 = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs0 == 0 or cs1 == 0 or cs2 == 0: - gdaltest.post_reason('failure') print(options) print(cs0) print(cs1) @@ -7540,7 +7320,6 @@ def test_tiff_write_159(): data_ovr_0 = int(ds.GetRasterBand(1).GetOverview(0).GetMetadataItem('BLOCK_OFFSET_0_0', 'TIFF')) data_main = int(ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_0', 'TIFF')) if not(ifd_main < ifd_ovr_0 and ifd_ovr_0 < ifd_ovr_1 and ifd_ovr_1 < data_ovr_1 and data_ovr_1 < data_ovr_0 and data_ovr_0 < data_main): - gdaltest.post_reason('failure') print(options) print(ifd_main, ifd_ovr_0, ifd_ovr_1, data_ovr_1, data_ovr_0, data_main) return 'fail' @@ -7548,12 +7327,10 @@ def test_tiff_write_159(): table_ovr_0 = ds.GetRasterBand(1).GetOverview(0).GetMetadataItem('JPEGTABLES', 'TIFF') table_ovr_1 = ds.GetRasterBand(1).GetOverview(1).GetMetadataItem('JPEGTABLES', 'TIFF') if table_main != table_ovr_0 or table_ovr_0 != table_ovr_1: - gdaltest.post_reason('failure') print(options) return 'fail' # Check that the JPEG tables are different in the 3 modes if table_main == prev_table: - gdaltest.post_reason('failure') print(options) return 'fail' prev_table = table_main @@ -7574,7 +7351,6 @@ def test_tiff_write_159(): cs0 = ds.GetRasterBand(1).Checksum() cs1 = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs0 != 4743 or cs1 != 1133: - gdaltest.post_reason('failure') print(value) print(cs0) print(cs1) @@ -7598,7 +7374,6 @@ def test_tiff_write_160(): ds = gdal.Open('/vsimem/tiff_write_160.tif') cs = ds.GetRasterBand(1).Checksum() if cs != 1218: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -7621,38 +7396,29 @@ def test_tiff_write_161(): src_ds = gdal.Open('data/gcps.vrt') with gdaltest.error_handler(): if ds.SetGCPs(src_ds.GetGCPs(), '') != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform(can_return_null=True) is not None: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('/vsimem/tiff_write_161.tif', gdal.GA_Update) if not ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform(can_return_null=True) is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if ds.SetGeoTransform([0, 1, 2, 3, 4, 5]) != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform() != (0.0, 1.0, 2.0, 3.0, 4.0, 5.0): - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('/vsimem/tiff_write_161.tif', gdal.GA_Update) if ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' if ds.GetGeoTransform() != (0.0, 1.0, 2.0, 3.0, 4.0, 5.0): - gdaltest.post_reason('fail') return 'fail' ds = None @@ -7696,13 +7462,11 @@ def test_tiff_write_163(): ds = gdal.Open('/vsimem/tiff_write_163.tif') cs = ds.GetRasterBand(1).Checksum() if cs != 47567: - gdaltest.post_reason('fail') print(cs) return 'fail' # Check that IsBlockAvailable() works properly in that mode offset_0_2 = ds.GetRasterBand(1).GetMetadataItem('BLOCK_OFFSET_0_2', 'TIFF') if offset_0_2 != str(146 + 2 * 8192): - gdaltest.post_reason('fail') print(offset_0_2) return 'fail' ds = None @@ -7726,7 +7490,6 @@ def test_tiff_write_164(): ds = None if gt != (0, 1, 0, 0, 0, 1): - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -7740,7 +7503,6 @@ def test_tiff_write_164(): ds = None if gt != (0, 1, 0, 0, 0, -1): - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -7757,7 +7519,6 @@ def test_tiff_write_165(): ds = gdaltest.tiff_drv.Create('/vsimem/test.tif', 1, 1, 3) ret = ds.GetRasterBand(1).SetNoDataValue(100) if ret != 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): @@ -7766,18 +7527,15 @@ def test_tiff_write_165(): gdaltest.post_reason('warning expected, but not emitted') return 'fail' if ret != 0: - gdaltest.post_reason('fail') return 'fail' nd = ds.GetRasterBand(1).GetNoDataValue() if nd != 100: - gdaltest.post_reason('fail') print(nd) return 'fail' nd = ds.GetRasterBand(2).GetNoDataValue() if nd != 200: - gdaltest.post_reason('fail') print(nd) return 'fail' @@ -7788,7 +7546,6 @@ def test_tiff_write_165(): ds = None if nd != 200: - gdaltest.post_reason('fail') print(nd) return 'fail' @@ -7804,12 +7561,10 @@ def test_tiff_write_166(): ds = gdal.Open('data/tiff_vertcs_scale_offset.tif') if ds.GetRasterBand(1).GetScale() != 2.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 10.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOffset()) return 'fail' @@ -7817,17 +7572,14 @@ def test_tiff_write_166(): gdal.Translate('/vsimem/tiff_write_166.tif', 'data/byte.tif', options='-a_srs EPSG:26711+5773 -a_scale 2.0 -a_offset 10 -co PROFILE=GEOTIFF') if gdal.VSIStatL('/vsimem/tiff_write_166.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_166.tif') if ds.GetRasterBand(1).GetScale() != 2.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 10.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOffset()) return 'fail' ds = None @@ -7837,17 +7589,14 @@ def test_tiff_write_166(): gdal.Translate('/vsimem/tiff_write_166.tif', 'data/byte.tif', options='-a_srs EPSG:26711+5773 -a_offset 10 -co PROFILE=GEOTIFF') if gdal.VSIStatL('/vsimem/tiff_write_166.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_166.tif') if ds.GetRasterBand(1).GetScale() != 1.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 10.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOffset()) return 'fail' ds = None @@ -7863,16 +7612,13 @@ def test_tiff_write_166(): ds.GetRasterBand(1).SetOffset(10) ds = None if gdal.VSIStatL('/vsimem/tiff_write_166.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_166.tif') if ds.GetRasterBand(1).GetScale() != 2.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 10.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOffset()) return 'fail' ds = None @@ -7887,16 +7633,13 @@ def test_tiff_write_166(): ds.GetRasterBand(1).SetScale(2) ds = None if gdal.VSIStatL('/vsimem/tiff_write_166.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_166.tif') if ds.GetRasterBand(1).GetScale() != 2.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 0.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOffset()) return 'fail' ds = None @@ -7911,16 +7654,13 @@ def test_tiff_write_166(): ds.GetRasterBand(1).SetOffset(10) ds = None if gdal.VSIStatL('/vsimem/tiff_write_166.tif.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tiff_write_166.tif') if ds.GetRasterBand(1).GetScale() != 1.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 10.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOffset()) return 'fail' ds = None @@ -7947,7 +7687,6 @@ def test_tiff_write_167_deflate_zlevel(): gdal.Unlink('/vsimem/out.tif') if size2 >= size1: - gdaltest.post_reason('fail') print(size1, size2) return 'fail' @@ -7963,7 +7702,6 @@ def test_tiff_write_167_deflate_zlevel(): gdal.Unlink('/vsimem/out.tif') if size2 != size2_create: - gdaltest.post_reason('fail') print(size2, size2_create) return 'fail' @@ -8068,7 +7806,6 @@ def test_tiff_write_tiled_webp(): ds = gdal.Open(filename) cs = [ds.GetRasterBand(i+1).Checksum() for i in range(3)] if cs != [21212, 21053, 21349]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -8127,11 +7864,9 @@ def test_tiff_write_172_geometadata_tiff_rsid(): ds = gdal.Open(tmpfilename, gdal.GA_Update) if ds.GetMetadataItem('GEO_METADATA') != 'foo': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetMetadataItem('TIFF_RSID') != 'bar': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds.SetMetadata({}) @@ -8139,11 +7874,9 @@ def test_tiff_write_172_geometadata_tiff_rsid(): ds = gdal.Open(tmpfilename) if ds.GetMetadataItem('GEO_METADATA') is not None: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetMetadataItem('TIFF_RSID') is not None: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -8253,7 +7986,6 @@ def test_tiff_write_177_lerc_several_bands_tiling(): ds = None gdal.Unlink(filename) if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -8277,7 +8009,6 @@ def test_tiff_write_178_lerc_with_alpha(): ds = None gdal.Unlink(filename) if cs != [12603, 58561, 36064, 10807]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -8301,7 +8032,6 @@ def test_tiff_write_178_lerc_with_alpha_0_and_255(): ds = None gdal.Unlink(filename) if cs != [13, 13, 13, 13]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -8327,7 +8057,6 @@ def test_tiff_write_179_lerc_data_types(): ds = None gdal.Unlink(filename) if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -8341,7 +8070,6 @@ def test_tiff_write_179_lerc_data_types(): ds = None gdal.Unlink(filename) if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -8349,7 +8077,6 @@ def test_tiff_write_179_lerc_data_types(): with gdaltest.error_handler(): gdal.Translate(filename, 'data/cfloat32.tif', creationOptions=['COMPRESS=LERC']) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(filename) @@ -8373,7 +8100,6 @@ def test_tiff_write_180_lerc_separate(): ds = None gdal.Unlink(filename) if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/autotest/gcore/transformer.py b/autotest/gcore/transformer.py index 32ec5d22bb1a..22a0dfcd868d 100755 --- a/autotest/gcore/transformer.py +++ b/autotest/gcore/transformer.py @@ -317,12 +317,10 @@ def test_transformer_5(): (success, pnt) = tr.TransformPoint(0, 40000, 0, 0) if success != 0: - gdaltest.post_reason('fail') return 'fail' (success, pnt) = tr.TransformPoint(1, 125, 40, 0) if success != 0: - gdaltest.post_reason('fail') return 'fail' tr = None @@ -466,19 +464,16 @@ def test_transformer_9(): points = [(125.64828521533849, 39.869345204440144)] * 10 (pnt, success) = tr.TransformPoints(1, points) if not success[0]: - gdaltest.post_reason('failure') print(method) return 'fail' pnt_optimized = pnt[0] (success, pnt) = tr.TransformPoint(1, 125.64828521533849, 39.869345204440144, 0) if not success: - gdaltest.post_reason('failure') print(method) return 'fail' if pnt != pnt_optimized: - gdaltest.post_reason('failure') print(method) print(pnt) print(pnt_optimized) @@ -641,7 +636,6 @@ def test_transformer_12(): tr = gdal.Transformer(ds, None, ['METHOD=GCP_TPS']) if tr is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(""" @@ -665,7 +659,6 @@ def test_transformer_12(): with gdaltest.error_handler(): tr = gdal.Transformer(ds, None, ['METHOD=GCP_TPS']) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(""" @@ -689,7 +682,6 @@ def test_transformer_12(): with gdaltest.error_handler(): tr = gdal.Transformer(ds, None, ['METHOD=GCP_TPS']) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -763,7 +755,6 @@ def test_transformer_14(): gdal.SetConfigOption('RPC_INVERSE_LOG', old_rpc_inverse_log) (success, pnt) = tr.TransformPoint(0, 0, 0) if not success or abs(pnt[0] - 1.9391846640653961e-05) > 1e-7 or abs(pnt[1] - -0.0038824752244123275) > 1e-7: - gdaltest.post_reason('fail') print(pnt) return 'fail' @@ -772,7 +763,6 @@ def test_transformer_14(): content = gdal.VSIFReadL(1, 1000, f).decode('ASCII') gdal.VSIFCloseL(f) if content.find('Integer,Real,Real,Real,String,Real,Real') != 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -782,7 +772,6 @@ def test_transformer_14(): gdal.VSIFCloseL(f) if content.find("""iter,long,lat,height,WKT,error_pixel_x,error_pixel_y 0,""") != 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -905,12 +894,10 @@ def test_transformer_16(): content.find('0.1') < 0 or \ content.find('0.0001') < 0 or \ content.find('6.1') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' ds = gdal.Translate('', '/vsimem/transformer_16.vrt', format='MEM') if ds.GetRasterBand(1).Checksum() != 4727: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None diff --git a/autotest/gcore/virtualmem.py b/autotest/gcore/virtualmem.py index b284d54aaa97..05279db291ff 100755 --- a/autotest/gcore/virtualmem.py +++ b/autotest/gcore/virtualmem.py @@ -90,26 +90,19 @@ def test_virtualmem_1(): for x in range(reqxsize): for band in range(3): if ar_tip[tiley][tilex][y][x][band] != ar[band][tiley * tileysize + y][tilex * tilexsize + x]: - gdaltest.post_reason('fail') return 'fail' if ar_tip[tiley][tilex][y][x][band] != ar_flat_bsq[band][tiley * tileysize + y][tilex * tilexsize + x]: - gdaltest.post_reason('fail') return 'fail' if ar_tip[tiley][tilex][y][x][band] != ar_flat_bip[tiley * tileysize + y][tilex * tilexsize + x][band]: - gdaltest.post_reason('fail') return 'fail' if ar_tip[tiley][tilex][y][x][band] != ar_bsq[band][tiley][tilex][y][x]: - gdaltest.post_reason('fail') return 'fail' if ar_tip[tiley][tilex][y][x][band] != ar_bit[tiley][tilex][band][y][x]: - gdaltest.post_reason('fail') return 'fail' if band == 0: if ar_flat_band1[tiley * tileysize + y][tilex * tilexsize + x] != ar_flat_bip[tiley * tileysize + y][tilex * tilexsize + x][0]: - gdaltest.post_reason('fail') return 'fail' if ar_tiled_band1[tiley][tilex][y][x] != ar_flat_bip[tiley * tileysize + y][tilex * tilexsize + x][0]: - gdaltest.post_reason('fail') return 'fail' # We need to destroy the array before dataset destruction @@ -192,10 +185,8 @@ def test_virtualmem_3(): ar_255.fill(255) for y in range(ds.RasterYSize): if not gdalnumeric.array_equal(ar1[y], ar_127): - gdaltest.post_reason('fail') return 'fail' if not gdalnumeric.array_equal(ar2[y], ar_255): - gdaltest.post_reason('fail') return 'fail' # We need to destroy the array before dataset destruction ar1 = None @@ -246,7 +237,6 @@ def test_virtualmem_4(): ar2 = None ds = None if val != 127: - gdaltest.post_reason('fail') print(val) return 'fail' @@ -259,13 +249,11 @@ def test_virtualmem_4(): ar_255.fill(255) for y in range(ds.RasterYSize): if not gdalnumeric.array_equal(ar1[y], ar_127): - gdaltest.post_reason('fail') ar1 = None ar2 = None ds = None return 'fail' if not gdalnumeric.array_equal(ar2[y], ar_255): - gdaltest.post_reason('fail') ar1 = None ar2 = None ds = None diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index dd03513e2b3b..0f24a437f04c 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -341,11 +341,9 @@ def test_vrt_read_7(): gdal.Unlink(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' if error_msg == '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -423,13 +421,11 @@ def test_vrt_read_10(): gdal.VSIFCloseL(f) if vrt_hist != mem_hist: - gdaltest.post_reason('fail') print(vrt_hist) print(mem_hist) return 'fail' if content.find('') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -456,7 +452,6 @@ def test_vrt_read_10(): gdal.VSIFCloseL(f) if content.find('') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -486,7 +481,6 @@ def test_vrt_read_10(): gdal.VSIFCloseL(f) if content.find('') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -611,7 +605,6 @@ def test_vrt_read_14(): if vrt_stats[0] != 115.0 or vrt_stats[1] != 173.0: print(vrt_stats) - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -807,7 +800,6 @@ def test_vrt_read_20(): """) ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -checksum tmp/byte2.vrt --config VRT_SHARED_SOURCE 0 --config GDAL_MAX_DATASET_POOL_SIZE 3') if ret.find('Checksum=4672') < 0: - gdaltest.post_reason('failure') print(ret) return 'fail' @@ -843,7 +835,6 @@ def test_vrt_read_21(): """) ds = gdal.Open('/vsimem/vrt_read_21.vrt') if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' data_ds_one_band = ds.ReadRaster(0, 0, 800, 800, 400, 400) @@ -872,22 +863,18 @@ def test_vrt_read_21(): """) ds = gdal.Open('/vsimem/vrt_read_21.vrt') if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' ds = gdal.Open('/vsimem/vrt_read_21.vrt') ovr_band = ds.GetRasterBand(1).GetOverview(-1) if ovr_band is not None: - gdaltest.post_reason('failure') return 'fail' ovr_band = ds.GetRasterBand(1).GetOverview(1) if ovr_band is not None: - gdaltest.post_reason('failure') return 'fail' ovr_band = ds.GetRasterBand(1).GetOverview(0) if ovr_band is None: - gdaltest.post_reason('failure') return 'fail' cs = ovr_band.Checksum() cs2 = ds.GetRasterBand(2).GetOverview(0).Checksum() @@ -895,7 +882,6 @@ def test_vrt_read_21(): data = ds.ReadRaster(0, 0, 800, 800, 400, 400) if data != data_ds_one_band + ds.GetRasterBand(2).ReadRaster(0, 0, 800, 800, 400, 400): - gdaltest.post_reason('failure') return 'fail' mem_ds = gdal.GetDriverByName('MEM').Create('', 400, 400, 2) @@ -904,12 +890,10 @@ def test_vrt_read_21(): ref_cs2 = mem_ds.GetRasterBand(2).Checksum() mem_ds = None if cs != ref_cs: - gdaltest.post_reason('failure') print(cs) print(ref_cs) return 'fail' if cs2 != ref_cs2: - gdaltest.post_reason('failure') print(cs2) print(ref_cs2) return 'fail' @@ -920,12 +904,10 @@ def test_vrt_read_21(): ds = None if cs != expected_cs: - gdaltest.post_reason('failure') print(cs) print(expected_cs) return 'fail' if cs2 != expected_cs2: - gdaltest.post_reason('failure') print(cs2) print(expected_cs2) return 'fail' @@ -962,26 +944,21 @@ def test_vrt_read_22(): """) if ds.GetRasterBand(1).GetMinimum() != 63: - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).GetMaximum() != 63: - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).ComputeRasterMinMax() != (63, 63): - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).ComputeStatistics(False) != [63.0, 63.0, 63.0, 0.0]: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).ComputeStatistics(False)) return 'fail' data = ds.ReadRaster() got = struct.unpack('B' * 20 * 20, data) if got[0] != 63: - gdaltest.post_reason('failure') return 'fail' ds = gdal.Open(""" @@ -996,19 +973,15 @@ def test_vrt_read_22(): """) if ds.GetRasterBand(1).GetMinimum() != 63: - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).GetMaximum() != 63: - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).ComputeRasterMinMax() != (63, 63): - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).ComputeStatistics(False) != [63.0, 63.0, 63.0, 0.0]: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).ComputeStatistics(False)) return 'fail' @@ -1025,20 +998,16 @@ def test_vrt_read_22(): """) if ds.GetRasterBand(1).GetMinimum() is not None: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).GetMinimum()) return 'fail' if ds.GetRasterBand(1).GetMaximum() is not None: - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).ComputeRasterMinMax() != (63, 63): - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).ComputeStatistics(False) != [63.0, 63.0, 63.0, 0.0]: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).ComputeStatistics(False)) return 'fail' @@ -1074,11 +1043,9 @@ def test_vrt_read_23(): """) got_ar = ds.GetRasterBand(1).ReadAsArray(0, 0, 2, 1, 4, 1, resample_alg=gdal.GRIORA_Bilinear) if list(got_ar[0]) != [0, 10, 10, 10]: - gdaltest.post_reason('failure') print(list(got_ar[0])) return 'fail' if ds.ReadRaster(0, 0, 2, 1, 4, 1, resample_alg=gdal.GRIORA_Bilinear) != ds.GetRasterBand(1).ReadRaster(0, 0, 2, 1, 4, 1, resample_alg=gdal.GRIORA_Bilinear): - gdaltest.post_reason('failure') return 'fail' ds = None @@ -1099,11 +1066,9 @@ def test_vrt_read_23(): """) got_ar = ds.GetRasterBand(1).ReadAsArray(0, 0, 2, 1, 4, 1, resample_alg=gdal.GRIORA_Bilinear) if list(got_ar[0]) != [0, 10, 10, 10]: - gdaltest.post_reason('failure') print(list(got_ar[0])) return 'fail' if ds.ReadRaster(0, 0, 2, 1, 4, 1, resample_alg=gdal.GRIORA_Bilinear) != ds.GetRasterBand(1).ReadRaster(0, 0, 2, 1, 4, 1, resample_alg=gdal.GRIORA_Bilinear): - gdaltest.post_reason('failure') return 'fail' ds = None @@ -1129,7 +1094,6 @@ def test_vrt_read_24(): # Please do not change the expected checksum without checking that # the result image has no vertical black line in the middle if cs != 46612: - gdaltest.post_reason('failure') print(cs) return 'fail' ds = None @@ -1171,28 +1135,24 @@ def test_vrt_read_25(): (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(0, 0, 20, 20) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_DATA or pct != 100.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(1005, 35, 10, 10) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_DATA or pct != 100.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(100, 100, 20, 20) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_EMPTY or pct != 0.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' (flags, pct) = ds.GetRasterBand(1).GetDataCoverageStatus(10, 10, 20, 20) if flags != gdal.GDAL_DATA_COVERAGE_STATUS_DATA | gdal.GDAL_DATA_COVERAGE_STATUS_EMPTY or pct != 25.0: - gdaltest.post_reason('failure') print(flags) print(pct) return 'fail' @@ -1225,7 +1185,6 @@ def test_vrt_read_26(): partial_data = struct.unpack('B' * 1 * 1, partial_data) if partial_data[0] != full_data[22 + 1]: - gdaltest.post_reason('fail') print(full_data) print(partial_data[0]) print(full_data[22 + 1]) @@ -1296,7 +1255,6 @@ def test_vrt_read_29(): # Just after opening, we shouldn't have read the source lst = gdaltest.get_opened_files() if lst.sort() != lst_before.sort(): - gdaltest.post_reason('fail') print(lst) print(lst_before) return 'fail' @@ -1305,14 +1263,12 @@ def test_vrt_read_29(): ds.GetRasterBand(1).Checksum() lst = gdaltest.get_opened_files() if len(lst) != len(lst_before) + 1: - gdaltest.post_reason('fail') print(lst) print(lst_before) return 'fail' ds.GetRasterBand(2).Checksum() lst = gdaltest.get_opened_files() if len(lst) != len(lst_before) + 1: - gdaltest.post_reason('fail') print(lst) print(lst_before) return 'fail' @@ -1324,7 +1280,6 @@ def test_vrt_read_29(): ds2.GetRasterBand(1).Checksum() lst = gdaltest.get_opened_files() if len(lst) != len(lst_before) + 2: - gdaltest.post_reason('fail') print(lst) print(lst_before) return 'fail' @@ -1379,14 +1334,12 @@ def test_vrt_read_31(): data = ds.GetRasterBand(1).ReadRaster(0, 0, 2, 2, buf_type=gdal.GDT_Float32) got = struct.unpack('f' * 2 * 2, data) if got != (0, 1, 254, 255): - gdaltest.post_reason('fail') print(got) return 'fail' data = ds.ReadRaster(0, 0, 2, 2, buf_type=gdal.GDT_Float32) got = struct.unpack('f' * 2 * 2, data) if got != (0, 1, 254, 255): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -1445,7 +1398,6 @@ def test_vrt_subpixel_offset(): ds = gdal.Open('data/vrt_subpixel_offset.vrt') cs = ds.GetRasterBand(1).Checksum() if cs != 4849: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1461,7 +1413,6 @@ def test_vrt_dstsize_larger_than_source(): ds = gdal.Open('data/dstsize_larger_than_source.vrt') cs = ds.GetRasterBand(1).Checksum() if cs != 33273: - gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/autotest/gcore/vrtmisc.py b/autotest/gcore/vrtmisc.py index 84d2482f816b..bfe5cf9b37c0 100755 --- a/autotest/gcore/vrtmisc.py +++ b/autotest/gcore/vrtmisc.py @@ -270,15 +270,12 @@ def test_vrtmisc_10(): ds = gdal.Open("/vsimem/vrtmisc_10.vrt", gdal.GA_Update) if ds.GetMetadata() != {'foo': 'bar'}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetMetadata('some_domain') != {'bar': 'baz'}: - gdaltest.post_reason('fail') print(ds.GetMetadata('some_domain')) return 'fail' if ds.GetMetadata_List('xml:a_xml_domain')[0] != '\n': - gdaltest.post_reason('fail') print(ds.GetMetadata_List('xml:a_xml_domain')) return 'fail' # Empty default domain @@ -287,15 +284,12 @@ def test_vrtmisc_10(): ds = gdal.Open("/vsimem/vrtmisc_10.vrt") if ds.GetMetadata() != {}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetMetadata('some_domain') != {'bar': 'baz'}: - gdaltest.post_reason('fail') print(ds.GetMetadata('some_domain')) return 'fail' if ds.GetMetadata_List('xml:a_xml_domain')[0] != '\n': - gdaltest.post_reason('fail') print(ds.GetMetadata_List('xml:a_xml_domain')) return 'fail' ds = None @@ -336,7 +330,6 @@ def test_vrtmisc_11(): gdal.Unlink("tmp/vrtmisc_11.vrt") if data.find('../data/byte.tif') < 0: - gdaltest.post_reason('fail') return 'fail' return "success" @@ -367,16 +360,13 @@ def test_vrtmisc_12(): ds = gdal.Open("/vsimem/vrtmisc_12.vrt", gdal.GA_Update) if ds.GetRasterBand(1).GetNoDataValue() != 123: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).DeleteNoDataValue() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open("/vsimem/vrtmisc_12.vrt") if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -393,7 +383,6 @@ def test_vrtmisc_13(): ds = gdal.Open('data/oddsize1bit.tif') out_ds = gdal.GetDriverByName('VRT').CreateCopy('', ds) if out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' return "success" @@ -416,7 +405,6 @@ def test_vrtmisc_14(): if content.find('data/byte.tif') < 0 and \ xml_vrt.find('data\\byte.tif') < 0: - gdaltest.post_reason('fail') print(xml_vrt) return 'fail' @@ -580,12 +558,10 @@ def test_vrtmisc_rat(): xml_vrt = vrt_ds.GetMetadata('xml:VRT')[0] if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' vrt_ds = None if xml_vrt.find('') < 0: - gdaltest.post_reason('fail') print(xml_vrt) return 'fail' @@ -593,12 +569,10 @@ def test_vrtmisc_rat(): xml_vrt = vrt_ds.GetMetadata('xml:VRT')[0] if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' vrt_ds = None if xml_vrt.find('') < 0: - gdaltest.post_reason('fail') print(xml_vrt) return 'fail' @@ -607,11 +581,9 @@ def test_vrtmisc_rat(): vrt_ds = gdal.Open('/vsimem/vrtmisc_rat.vrt', gdal.GA_Update) rat = vrt_ds.GetRasterBand(1).GetDefaultRAT() if rat is None or rat.GetColumnCount() != 1: - gdaltest.post_reason('fail') return 'fail' vrt_ds.GetRasterBand(1).SetDefaultRAT(None) if vrt_ds.GetRasterBand(1).GetDefaultRAT() is not None: - gdaltest.post_reason('fail') return 'fail' vrt_ds = None @@ -633,11 +605,9 @@ def test_vrtmisc_colortable(): ct.SetColorEntry(0, (255, 255, 255, 255)) ds.GetRasterBand(1).SetColorTable(ct) if ds.GetRasterBand(1).GetColorTable().GetCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetColorTable(None) if ds.GetRasterBand(1).GetColorTable() is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gcore/vsiaz.py b/autotest/gcore/vsiaz.py index 96a2cc3064ff..e95bcb7af677 100755 --- a/autotest/gcore/vsiaz.py +++ b/autotest/gcore/vsiaz.py @@ -56,7 +56,6 @@ def test_vsiaz_init(): gdal.SetConfigOption(var, "") if gdal.GetSignedURL('/vsiaz/foo/bar') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -75,7 +74,6 @@ def test_vsiaz_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('AZURE_STORAGE_ACCOUNT') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -83,7 +81,6 @@ def test_vsiaz_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiaz_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('AZURE_STORAGE_ACCOUNT') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -93,7 +90,6 @@ def test_vsiaz_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('AZURE_STORAGE_CONNECTION_STRING', '') @@ -104,7 +100,6 @@ def test_vsiaz_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('AZURE_STORAGE_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -118,7 +113,6 @@ def test_vsiaz_real_server_errors(): gdal.VSIFCloseL(f) if gdal.GetConfigOption('APPVEYOR') is not None: return 'success' - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -126,7 +120,6 @@ def test_vsiaz_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiaz_streaming/foo/bar.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -167,7 +160,6 @@ def test_vsiaz_fake_basic(): signed_url = gdal.GetSignedURL('/vsiaz/az_fake_bucket/resource', ['START_DATE=20180213T123456']) if signed_url not in ('http://127.0.0.1:8080/azure/blob/myaccount/az_fake_bucket/resource?se=2018-02-13T13%3A34%3A56Z&sig=9Jc4yBFlSRZSSxf059OohN6pYRrjuHWJWSEuryczN%2FM%3D&sp=r&sr=c&st=2018-02-13T12%3A34%3A56Z&sv=2012-02-12', 'http://127.0.0.1:8081/azure/blob/myaccount/az_fake_bucket/resource?se=2018-02-13T13%3A34%3A56Z&sig=9Jc4yBFlSRZSSxf059OohN6pYRrjuHWJWSEuryczN%2FM%3D&sp=r&sr=c&st=2018-02-13T12%3A34%3A56Z&sv=2012-02-12'): - gdaltest.post_reason('fail') print(signed_url) return 'fail' @@ -193,13 +185,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsiaz/az_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -226,13 +216,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsiaz_streaming/az_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -242,7 +230,6 @@ def method(request): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsiaz/az_fake_bucket/resource2.bin') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -255,7 +242,6 @@ def method(request): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsiaz_streaming/az_fake_bucket/resource2.bin') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -319,27 +305,22 @@ def test_vsiaz_fake_readdir(): print('Skipped on trusty branch, but should be investigated') return 'skip' - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) dir_contents = gdal.ReadDir('/vsiaz/az_fake_bucket2/a_dir') if dir_contents != ['resource3.bin', 'resource4.bin', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' if gdal.VSIStatL('/vsiaz/az_fake_bucket2/a_dir/resource3.bin').size != 123456: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsiaz/az_fake_bucket2/a_dir/resource3.bin').size) return 'fail' if gdal.VSIStatL('/vsiaz/az_fake_bucket2/a_dir/resource3.bin').mtime != 1: - gdaltest.post_reason('fail') return 'fail' # ReadDir on something known to be a file shouldn't cause network access dir_contents = gdal.ReadDir('/vsiaz/az_fake_bucket2/a_dir/resource3.bin') if dir_contents is not None: - gdaltest.post_reason('fail') return 'fail' # Test error on ReadDir() @@ -348,7 +329,6 @@ def test_vsiaz_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiaz/az_fake_bucket2/error_test/') if dir_contents is not None: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -363,7 +343,6 @@ def test_vsiaz_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiaz/') if dir_contents != ['.']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -395,7 +374,6 @@ def test_vsiaz_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiaz/') if dir_contents != ['mycontainer1', 'mycontainer2']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -415,7 +393,6 @@ def test_vsiaz_fake_write(): # Test creation of BlockBob f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -450,7 +427,6 @@ def method(request): ret = gdal.VSIFWriteL('x' * 35000, 1, 35000, f) ret += gdal.VSIFWriteL('x' * 5000, 1, 5000, f) if ret != 40000: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -459,12 +435,10 @@ def method(request): # Simulate illegal read f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFReadL(1, 1, f) if ret: - gdaltest.post_reason('fail') print(ret) return 'fail' gdal.VSIFCloseL(f) @@ -472,19 +446,16 @@ def method(request): # Simulate illegal seek f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFSeekL(f, 1, 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) # Simulate failure when putting BlockBob f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -498,33 +469,27 @@ def method(request): handler.add('PUT', '/azure/blob/myaccount/test_copy/file.bin', custom_method=method) if gdal.VSIFSeekL(f, 0, 0) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' gdal.VSIFWriteL('x' * 35000, 1, 35000, f) if gdal.VSIFTellL(f) != 35000: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' if gdal.VSIFSeekL(f, 35000, 0) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' if gdal.VSIFSeekL(f, 0, 1) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' if gdal.VSIFSeekL(f, 0, 2) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' if gdal.VSIFEofL(f) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' @@ -532,7 +497,6 @@ def method(request): with gdaltest.error_handler(): ret = gdal.VSIFCloseL(f) if ret == 0: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -540,7 +504,6 @@ def method(request): # Simulate creation of BlockBob over an existing blob of incompatible type f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -555,7 +518,6 @@ def method(request): f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') gdal.SetConfigOption('VSIAZ_CHUNK_SIZE_BYTES', None) if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -627,7 +589,6 @@ def method(request): with webserver.install_http_handler(handler): ret = gdal.VSIFWriteL('0123456789abcdef', 1, 16, f) if ret != 16: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -638,7 +599,6 @@ def method(request): f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') gdal.SetConfigOption('VSIAZ_CHUNK_SIZE_BYTES', None) if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -655,7 +615,6 @@ def method(request): with gdaltest.error_handler(): ret = gdal.VSIFWriteL('0123456789abcdef', 1, 16, f) if ret != 0: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -666,7 +625,6 @@ def method(request): f = gdal.VSIFOpenL('/vsiaz/test_copy/file.bin', 'wb') gdal.SetConfigOption('VSIAZ_CHUNK_SIZE_BYTES', None) if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -676,7 +634,6 @@ def method(request): with gdaltest.error_handler(): ret = gdal.VSIFWriteL('0123456789abcdef', 1, 16, f) if ret != 0: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -700,7 +657,6 @@ def test_vsiaz_fake_unlink(): with webserver.install_http_handler(handler): ret = gdal.Unlink('/vsiaz/az_bucket_test_unlink/myfile') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Failure @@ -711,7 +667,6 @@ def test_vsiaz_fake_unlink(): with gdaltest.error_handler(): ret = gdal.Unlink('/vsiaz/az_bucket_test_unlink/myfile') if ret != -1: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -728,7 +683,6 @@ def test_vsiaz_fake_mkdir_rmdir(): # Invalid name ret = gdal.Mkdir('/vsiaz', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -738,7 +692,6 @@ def test_vsiaz_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsiaz/az_bucket_test_mkdir/dir', 0) if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try creating already existing directory @@ -760,13 +713,11 @@ def test_vsiaz_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsiaz/az_bucket_test_mkdir/dir', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Invalid name ret = gdal.Rmdir('/vsiaz') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Not a directory @@ -783,7 +734,6 @@ def test_vsiaz_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiaz/az_bucket_test_mkdir/it_is_a_file') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Valid @@ -805,7 +755,6 @@ def test_vsiaz_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiaz/az_bucket_test_mkdir/dir') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting already deleted directory @@ -815,7 +764,6 @@ def test_vsiaz_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiaz/az_bucket_test_mkdir/dir') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting non-empty directory @@ -850,7 +798,6 @@ def test_vsiaz_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiaz/az_bucket_test_mkdir/dir_nonempty') if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -868,7 +815,6 @@ def test_vsiaz_fake_test_BlobEndpointInConnectionString(): signed_url = gdal.GetSignedURL('/vsiaz/az_fake_bucket/resource') if signed_url.find('http://127.0.0.1:%d/myaccount/az_fake_bucket/resource' % gdaltest.webserver_port) < 0: - gdaltest.post_reason('fail') print(signed_url) return 'fail' @@ -909,20 +855,17 @@ def vsiaz_extra_1(): path = '/vsiaz/' + az_resource statres = gdal.VSIStatL(path) if statres is None or not stat.S_ISDIR(statres.mode): - gdaltest.post_reason('fail') print('%s is not a valid bucket' % path) return 'fail' readdir = gdal.ReadDir(path) if readdir is None: - gdaltest.post_reason('fail') print('ReadDir() should not return empty list') return 'fail' for filename in readdir: if filename != '.': subpath = path + '/' + filename if gdal.VSIStatL(subpath) is None: - gdaltest.post_reason('fail') print('Stat(%s) should not return an error' % subpath) return 'fail' @@ -930,81 +873,68 @@ def vsiaz_extra_1(): subpath = path + '/' + unique_id ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id not in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret == 0: - gdaltest.post_reason('fail') print('Mkdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should not contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, f) gdal.VSIFCloseL(f) ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) on non empty directory should return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 5, f).decode('utf-8') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' gdal.VSIFCloseL(f) ret = gdal.Unlink(subpath + '/test.txt') if ret < 0: - gdaltest.post_reason('fail') print('Unlink(%s) should not return an error' % (subpath + '/test.txt')) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' @@ -1012,26 +942,22 @@ def vsiaz_extra_1(): f = open_for_read('/vsiaz/' + az_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' # Same with /vsiaz_streaming/ f = open_for_read('/vsiaz_streaming/' + az_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -1044,7 +970,6 @@ def vsiaz_extra_1(): gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -1052,7 +977,6 @@ def vsiaz_extra_1(): gdal.ErrorReset() f = open_for_read('/vsiaz_streaming/' + az_resource + '/invalid_resource.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -1060,13 +984,11 @@ def vsiaz_extra_1(): signed_url = gdal.GetSignedURL('/vsiaz/' + az_resource) f = open_for_read('/vsicurl_streaming/' + signed_url) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' diff --git a/autotest/gcore/vsicrypt.py b/autotest/gcore/vsicrypt.py index efe79b9e9c75..b48c63ef42e6 100755 --- a/autotest/gcore/vsicrypt.py +++ b/autotest/gcore/vsicrypt.py @@ -66,42 +66,36 @@ def test_vsicrypt_2(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt//vsimem/file.bin', 'wb+') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid file with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/not_existing/not_existing', 'wb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid file with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/not_existing/not_existing', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid file with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/not_existing/not_existing', 'ab') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid access with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/not_existing/not_existing', 'foo') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Key to short with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=a,file=/vsimem/file.bin', 'wb+') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid signature @@ -109,7 +103,6 @@ def test_vsicrypt_2(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/vsimem/file.bin', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Generate empty file @@ -118,7 +111,6 @@ def test_vsicrypt_2(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/vsimem/file.bin', 'rb') if fp is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(fp) @@ -127,7 +119,6 @@ def test_vsicrypt_2(): gdal.VSIFCloseL(fp) if len(header) != 46: - gdaltest.post_reason('fail') print(len(header)) return 'fail' @@ -140,7 +131,6 @@ def test_vsicrypt_2(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/vsimem/file.bin', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Test corrupting all bytes of header @@ -193,7 +183,6 @@ def test_vsicrypt_2(): fp = gdal.VSIFOpenL( '/vsicrypt/key=DONT_USE_IN_PROD,file=/vsimem/file.bin', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Inconsistent initial vector with key check. @@ -220,7 +209,6 @@ def test_vsicrypt_2(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,file=/vsimem/file.bin', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Test reading with wrong key @@ -233,13 +221,11 @@ def test_vsicrypt_2(): gdal.VSIFCloseL(fp) if content == 'hello': - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=short_key,file=/vsimem/file.bin', 'ab') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Test reading with wrong key with add_key_check @@ -250,19 +236,16 @@ def test_vsicrypt_2(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=dont_use_in_prod,file=/vsimem/file.bin', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=short_key,file=/vsimem/file.bin', 'ab') if fp is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=dont_use_in_prod,file=/vsimem/file.bin', 'ab') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Test creating with potentially not build-in alg: @@ -275,14 +258,12 @@ def test_vsicrypt_2(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,sector_size=1,file=/vsimem/file.bin', 'wb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Sector size (16) should be at least twice larger than the block size (16) in CBC_CTS with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PROD,sector_size=16,mode=CBC_CTS,file=/vsimem/file.bin', 'wb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/file.bin') @@ -311,7 +292,6 @@ def test_vsicrypt_3(): else: fp = gdal.VSIFOpenL('/vsicrypt/key=DONT_USE_IN_PRODDONT_USE_IN_PROD,%s,file=/vsimem/file.bin' % options, 'wb') if fp is None: - gdaltest.post_reason('fail') print(options) return 'fail' gdal.VSIFWriteL('hello', 1, 5, fp) @@ -322,7 +302,6 @@ def test_vsicrypt_3(): gdal.VSIFCloseL(fp) if content != 'hello': - gdaltest.post_reason('fail') print(options) return 'fail' @@ -342,7 +321,6 @@ def test_vsicrypt_3(): gdal.VSIFCloseL(fp) if content != 'hello': - gdaltest.post_reason('fail') print(options) return 'fail' @@ -356,7 +334,6 @@ def test_vsicrypt_3(): # Get the generated random key key_b64 = gdal.GetConfigOption('VSICRYPT_KEY_B64') if key_b64 is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, fp) @@ -367,7 +344,6 @@ def test_vsicrypt_3(): gdal.VSIFCloseL(fp) if content != 'hello': - gdaltest.post_reason('fail') print(options) return 'fail' @@ -378,31 +354,26 @@ def test_vsicrypt_3(): gdal.VSIFCloseL(fp) if content != 'hello': - gdaltest.post_reason('fail') print(options) return 'fail' with gdaltest.error_handler(): statRes = gdal.VSIStatL('/vsicrypt//vsimem/file.bin') if statRes is not None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.Rename('/vsicrypt//vsimem/file.bin', '/vsicrypt//vsimem/subdir_crypt/file.bin') if ret != 0: - gdaltest.post_reason('fail') print(ret) return 'fail' ret = gdal.Rename('/vsicrypt//vsimem/subdir_crypt/file.bin', '/vsimem/subdir_crypt/file2.bin') if ret != 0: - gdaltest.post_reason('fail') print(ret) return 'fail' dir_content = gdal.ReadDir('/vsicrypt//vsimem/subdir_crypt') if dir_content != ['file2.bin']: - gdaltest.post_reason('fail') print(dir_content) return 'fail' @@ -504,7 +475,6 @@ def test_vsicrypt_5(): content = struct.unpack('B' * len(content), content) gdal.VSIFCloseL(f) if content != (97, 98, 0, 100): - gdaltest.post_reason('fail') print(content) return 'fail' @@ -519,7 +489,6 @@ def test_vsicrypt_5(): content = struct.unpack('B' * len(content), content) gdal.VSIFCloseL(f) if content != (97, 98, 0, 100, 0, 102): - gdaltest.post_reason('fail') print(content) return 'fail' @@ -536,7 +505,6 @@ def test_vsicrypt_5(): content = struct.unpack('B' * len(content), content) gdal.VSIFCloseL(f) if content != (97, 98, 0, 100, 0, 102, 0, 104): - gdaltest.post_reason('fail') print(content) return 'fail' @@ -572,7 +540,6 @@ def test_vsicrypt_6(): fp = gdal.VSIFOpenL('/vsicrypt/add_key_check=yes,file=/vsimem/file.bin', 'wb+') if fp is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, fp) gdal.VSIFCloseL(fp) @@ -582,12 +549,10 @@ def test_vsicrypt_6(): gdal.VSIFCloseL(fp) if content != 'hello': - gdaltest.post_reason('fail') return 'fail' fp = gdal.VSIFOpenL('/vsicrypt//vsimem/file.bin', 'wb+') if fp is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, fp) gdal.VSIFCloseL(fp) @@ -597,7 +562,6 @@ def test_vsicrypt_6(): gdal.VSIFCloseL(fp) if content != 'hello': - gdaltest.post_reason('fail') return 'fail' # Set a too short key @@ -605,13 +569,11 @@ def test_vsicrypt_6(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt//vsimem/file.bin', 'rb') if fp is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt//vsimem/file.bin', 'wb+') if fp is not None: - gdaltest.post_reason('fail') return 'fail' # Erase key @@ -619,7 +581,6 @@ def test_vsicrypt_6(): with gdaltest.error_handler(): fp = gdal.VSIFOpenL('/vsicrypt//vsimem/file.bin', 'wb+') if fp is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/file.bin') diff --git a/autotest/gcore/vsicurl.py b/autotest/gcore/vsicurl.py index 65990dc262c2..0992cff4ba45 100755 --- a/autotest/gcore/vsicurl.py +++ b/autotest/gcore/vsicurl.py @@ -326,12 +326,10 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsicurl/http://localhost:%d/test_redirect/test.bin' % gdaltest.webserver_port, 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFSeekL(f, 0, 2) if gdal.VSIFTellL(f) != 1000000: - gdaltest.post_reason('fail') print(gdal.VSIFTellL(f)) gdal.VSIFCloseL(f) return 'fail' @@ -374,13 +372,11 @@ def method(request): with webserver.install_http_handler(handler): content = gdal.VSIFReadL(1, 16383, f).decode('ascii') if len(content) != 16383 or content[0] != 'x': - gdaltest.post_reason('fail') print(content) gdal.VSIFCloseL(f) return 'fail' content = gdal.VSIFReadL(1, 2, f).decode('ascii') if content != 'xy': - gdaltest.post_reason('fail') print(content) gdal.VSIFCloseL(f) return 'fail' @@ -419,7 +415,6 @@ def test_vsicurl_test_retry(): data_len = len(gdal.VSIFReadL(1, 1, f)) gdal.VSIFCloseL(f) if data_len != 0: - gdaltest.post_reason('fail') print(data_len) return 'fail' @@ -434,7 +429,6 @@ def test_vsicurl_test_retry(): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsicurl?max_retry=2&retry_delay=0.01&url=http://localhost:%d/test_retry/test.txt' % gdaltest.webserver_port, 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): @@ -442,11 +436,9 @@ def test_vsicurl_test_retry(): error_msg = gdal.GetLastErrorMsg() gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' if error_msg.find('429') < 0: - gdaltest.post_reason('fail') print(error_msg) return 'fail' @@ -500,19 +492,16 @@ def test_vsicurl_test_parse_html_filelist_apache(): with webserver.install_http_handler(handler): fl = gdal.ReadDir('/vsicurl/http://localhost:%d/mydir' % gdaltest.webserver_port) if fl != ['foo.tif', 'foo%20with%20space.tif']: - gdaltest.post_reason('fail') print(fl) return 'fail' if gdal.VSIStatL('/vsicurl/http://localhost:%d/mydir/foo%%20with%%20space.tif' % gdaltest.webserver_port, gdal.VSI_STAT_EXISTS_FLAG) is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('HEAD', '/mydir/i_dont_exist', 404, {}) with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsicurl/http://localhost:%d/mydir/i_dont_exist' % gdaltest.webserver_port, gdal.VSI_STAT_EXISTS_FLAG) is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gcore/vsicurl_streaming.py b/autotest/gcore/vsicurl_streaming.py index 29f543692cbb..178a8b9bb8a2 100755 --- a/autotest/gcore/vsicurl_streaming.py +++ b/autotest/gcore/vsicurl_streaming.py @@ -52,36 +52,29 @@ def test_vsicurl_streaming_1(): if gdaltest.gdalurlopen('http://download.osgeo.org/gdal/data/usgsdem/cded/114p01_0100_deme.dem', timeout=4) is None: print('cannot open URL') return 'skip' - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFTellL(fp) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' data = gdal.VSIFReadL(1, 50, fp) if data.decode('ascii') != ' 114p01DEMe Base Ma': - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' if gdal.VSIFTellL(fp) != 50: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' gdal.VSIFSeekL(fp, 0, 0) if gdal.VSIFTellL(fp) != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' data = gdal.VSIFReadL(1, 50, fp) if data.decode('ascii') != ' 114p01DEMe Base Ma': - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' if gdal.VSIFTellL(fp) != 50: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' @@ -90,35 +83,29 @@ def test_vsicurl_streaming_1(): data_2001 = gdal.VSIFReadL(1, 20, fp) if data_2001.decode('ascii') != '7-32767-32767-32767-': print(data_2001) - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' if gdal.VSIFTellL(fp) != 2001 + 20: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' gdal.VSIFSeekL(fp, 0, 2) if gdal.VSIFTellL(fp) != 9839616: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' nRet = len(gdal.VSIFReadL(1, 10, fp)) if nRet != 0: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' gdal.VSIFSeekL(fp, 2001, 0) data_2001_2 = gdal.VSIFReadL(1, 20, fp) if gdal.VSIFTellL(fp) != 2001 + 20: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' if data_2001 != data_2001_2: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' @@ -126,11 +113,9 @@ def test_vsicurl_streaming_1(): data = gdal.VSIFReadL(1, 20, fp) if data.decode('ascii') != '67-32767-32767-32767': print(data) - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' if gdal.VSIFTellL(fp) != 1024 * 1024 + 100 + 20: - gdaltest.post_reason('fail') gdal.VSIFCloseL(fp) return 'fail' diff --git a/autotest/gcore/vsifile.py b/autotest/gcore/vsifile.py index e5419a4b1871..ae31a5a0a71f 100755 --- a/autotest/gcore/vsifile.py +++ b/autotest/gcore/vsifile.py @@ -46,39 +46,30 @@ def vsifile_generic(filename): fp = gdal.VSIFOpenL(filename, 'wb+') if fp is None: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFWriteL('0123456789', 1, 10, fp) != 10: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFFlushL(fp) != 0: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFTruncateL(fp, 20) != 0: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFTellL(fp) != 10: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFTruncateL(fp, 5) != 0: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFTellL(fp) != 10: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFSeekL(fp, 0, 2) != 0: - gdaltest.post_reason('failure') return 'fail' if gdal.VSIFTellL(fp) != 5: - gdaltest.post_reason('failure') return 'fail' gdal.VSIFWriteL('XX', 1, 2, fp) @@ -86,26 +77,21 @@ def vsifile_generic(filename): statBuf = gdal.VSIStatL(filename, gdal.VSI_STAT_EXISTS_FLAG | gdal.VSI_STAT_NATURE_FLAG | gdal.VSI_STAT_SIZE_FLAG) if statBuf.size != 7: - gdaltest.post_reason('failure') print(statBuf.size) return 'fail' if abs(start_time - statBuf.mtime) > 2: - gdaltest.post_reason('failure') print(statBuf.mtime) return 'fail' fp = gdal.VSIFOpenL(filename, 'rb') buf = gdal.VSIFReadL(1, 7, fp) if gdal.VSIFWriteL('a', 1, 1, fp) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFTruncateL(fp, 0) == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(fp) if buf.decode('ascii') != '01234XX': - gdaltest.post_reason('failure') print(buf.decode('ascii')) return 'fail' @@ -116,17 +102,14 @@ def vsifile_generic(filename): statBuf = gdal.VSIStatL(filename, gdal.VSI_STAT_EXISTS_FLAG | gdal.VSI_STAT_NATURE_FLAG | gdal.VSI_STAT_SIZE_FLAG) if statBuf.size != 9: - gdaltest.post_reason('failure') print(statBuf.size) return 'fail' if gdal.Unlink(filename) != 0: - gdaltest.post_reason('failure') return 'fail' statBuf = gdal.VSIStatL(filename, gdal.VSI_STAT_EXISTS_FLAG) if statBuf is not None: - gdaltest.post_reason('failure') return 'fail' # Test append mode on non existing file @@ -136,12 +119,10 @@ def vsifile_generic(filename): statBuf = gdal.VSIStatL(filename, gdal.VSI_STAT_EXISTS_FLAG | gdal.VSI_STAT_NATURE_FLAG | gdal.VSI_STAT_SIZE_FLAG) if statBuf.size != 2: - gdaltest.post_reason('failure') print(statBuf.size) return 'fail' if gdal.Unlink(filename) != 0: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -183,7 +164,6 @@ def test_vsifile_3(): gdal.VSIFSeekL(fp, 0, 2) pos = gdal.VSIFTellL(fp) if pos != 10 * 1024 * 1024 * 1024: - gdaltest.post_reason('failure') gdal.VSIFCloseL(fp) gdal.Unlink(filename) print(pos) @@ -192,7 +172,6 @@ def test_vsifile_3(): gdal.VSIFSeekL(fp, pos, 0) pos = gdal.VSIFTellL(fp) if pos != 10 * 1024 * 1024 * 1024: - gdaltest.post_reason('failure') gdal.VSIFCloseL(fp) gdal.Unlink(filename) print(pos) @@ -204,7 +183,6 @@ def test_vsifile_3(): gdal.Unlink(filename) if statBuf.size != 10 * 1024 * 1024 * 1024: - gdaltest.post_reason('failure') print(statBuf.size) return 'fail' @@ -252,21 +230,18 @@ def test_vsifile_5(): gdal.VSIFSeekL(fp, 50000, 0) if gdal.VSIFTellL(fp) != 50000: - gdaltest.post_reason('fail') gdal.SetConfigOption('VSI_CACHE_SIZE', None) gdal.SetConfigOption('VSI_CACHE', None) return 'fail' gdal.VSIFSeekL(fp, 50000, 1) if gdal.VSIFTellL(fp) != 100000: - gdaltest.post_reason('fail') gdal.SetConfigOption('VSI_CACHE_SIZE', None) gdal.SetConfigOption('VSI_CACHE', None) return 'fail' gdal.VSIFSeekL(fp, 0, 2) if gdal.VSIFTellL(fp) != 5 * 32768 * 8: - gdaltest.post_reason('fail') gdal.SetConfigOption('VSI_CACHE_SIZE', None) gdal.SetConfigOption('VSI_CACHE', None) return 'fail' @@ -275,7 +250,6 @@ def test_vsifile_5(): gdal.VSIFSeekL(fp, 0, 0) data = gdal.VSIFReadL(1, 3 * 32768, fp) if data.decode('ascii') != ref_data[0:3 * 32768]: - gdaltest.post_reason('fail') gdal.SetConfigOption('VSI_CACHE_SIZE', None) gdal.SetConfigOption('VSI_CACHE', None) return 'fail' @@ -283,14 +257,12 @@ def test_vsifile_5(): gdal.VSIFSeekL(fp, 16384, 0) data = gdal.VSIFReadL(1, 5 * 32768, fp) if data.decode('ascii') != ref_data[16384:16384 + 5 * 32768]: - gdaltest.post_reason('fail') gdal.SetConfigOption('VSI_CACHE_SIZE', None) gdal.SetConfigOption('VSI_CACHE', None) return 'fail' data = gdal.VSIFReadL(1, 50 * 32768, fp) if data[0:1130496].decode('ascii') != ref_data[16384 + 5 * 32768:]: - gdaltest.post_reason('fail') gdal.SetConfigOption('VSI_CACHE_SIZE', None) gdal.SetConfigOption('VSI_CACHE', None) return 'fail' @@ -358,38 +330,29 @@ def test_vsifile_7(): # Test extending file beyond reasonable limits in write mode fp = gdal.VSIFOpenL('/vsimem/vsifile_7.bin', 'wb') if gdal.VSIFSeekL(fp, 0x7FFFFFFFFFFFFFFF, 0) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsimem/vsifile_7.bin').size != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = gdal.VSIFWriteL('a', 1, 1, fp) gdal.PopErrorHandler() if ret != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsimem/vsifile_7.bin').size != 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(fp) # Test seeking beyond file size in read-only mode fp = gdal.VSIFOpenL('/vsimem/vsifile_7.bin', 'rb') if gdal.VSIFSeekL(fp, 0x7FFFFFFFFFFFFFFF, 0) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFEofL(fp) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFTellL(fp) != 0x7FFFFFFFFFFFFFFF: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFReadL(1, 1, fp): - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFEofL(fp) != 1: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(fp) @@ -409,10 +372,8 @@ def test_vsifile_8(): gdal.VSIFCloseL(fp) gdal.Rename('/vsimem/mydir', '/vsimem/newdir'.encode('ascii').decode('ascii')) if gdal.VSIStatL('/vsimem/newdir') is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsimem/newdir/a') is None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/newdir/a') gdal.Rmdir('/vsimem/newdir') @@ -427,12 +388,10 @@ def test_vsifile_9(): lst = gdal.ReadDir('.') if len(lst) < 4: - gdaltest.post_reason('fail') return 'fail' # Test truncation lst_truncated = gdal.ReadDir('.', int(len(lst) / 2)) if len(lst_truncated) <= int(len(lst) / 2): - gdaltest.post_reason('fail') return 'fail' gdal.Mkdir('/vsimem/mydir', 438) @@ -442,12 +401,10 @@ def test_vsifile_9(): lst = gdal.ReadDir('/vsimem/mydir') if len(lst) < 4: - gdaltest.post_reason('fail') return 'fail' # Test truncation lst_truncated = gdal.ReadDir('/vsimem/mydir', int(len(lst) / 2)) if len(lst_truncated) <= int(len(lst) / 2): - gdaltest.post_reason('fail') return 'fail' for i in range(10): @@ -521,19 +478,15 @@ def test_vsifile_10(): gdal.Unlink('/vsimem/vsifile_10.tar') return 'skip' if contents != ['test.txt', 'huge.txt', 'small.txt']: - gdaltest.post_reason('fail') print(contents) return 'fail' if gdal.VSIStatL('/vsitar//vsimem/vsifile_10.tar/test.txt').size != 3: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsitar//vsimem/vsifile_10.tar/test.txt').size) return 'fail' if gdal.VSIStatL('/vsitar//vsimem/vsifile_10.tar/huge.txt').size != 3888: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsitar//vsimem/vsifile_10.tar/huge.txt').size) return 'fail' if gdal.VSIStatL('/vsitar//vsimem/vsifile_10.tar/small.txt').size != 1: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsitar//vsimem/vsifile_10.tar/small.txt').size) return 'fail' @@ -543,7 +496,6 @@ def test_vsifile_10(): abc""") contents = gdal.ReadDir('/vsitar//vsimem/vsifile_10.tar') if contents != ['x']: - gdaltest.post_reason('fail') print(contents) return 'fail' @@ -553,7 +505,6 @@ def test_vsifile_10(): abc***NEWFILE***:""") contents = gdal.ReadDir('/vsitar//vsimem/vsifile_10.tar') if contents != ['x']: - gdaltest.post_reason('fail') print(contents) return 'fail' @@ -572,13 +523,10 @@ def test_vsifile_11(): f = gdal.VSIFOpenL('/vsisubfile/0_,/vsimem/vsifile_11', 'wb') gdal.VSIFWriteL('0123456789', 1, 10, f) if gdal.VSIFTruncateL(f, 10 + 4096 + 2) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFTellL(f) != 10: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFTruncateL(f, 0) != -1: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -588,7 +536,6 @@ def test_vsifile_11(): import struct data = struct.unpack('B' * len(data), data) if data[0] != 48 or data[9] != 57 or data[10] != 0 or data[10 + 4096 + 2 - 1] != 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -612,7 +559,6 @@ def test_vsifile_12(): f = gdal.VSIFOpenL(target_dir + '/vsifile_12', 'wb') gdal.VSIFWriteL('a', 1, 1, f) if gdal.VSIFTruncateL(f, block_size * 2) != 0: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFGetRangeStatusL(f, 0, 1) # We could get unknown on nfs @@ -620,12 +566,10 @@ def test_vsifile_12(): print('Range status unknown') else: if ret != gdal.VSI_RANGE_STATUS_DATA: - gdaltest.post_reason('fail') print(ret) return 'fail' ret = gdal.VSIFGetRangeStatusL(f, block_size * 2 - 1, 1) if ret != gdal.VSI_RANGE_STATUS_HOLE: - gdaltest.post_reason('fail') print(ret) return 'fail' gdal.VSIFCloseL(f) @@ -695,27 +639,22 @@ def test_vsifile_15(): with gdaltest.error_handler(): file_len += len(gdal.VSIFReadL(1, 4, fp)) if file_len != 6469: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): file_len += len(gdal.VSIFReadL(1, 4, fp)) if file_len != 6469: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if gdal.VSIFSeekL(fp, 0, 2) == 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(fp, 0, 0) != 0: - gdaltest.post_reason('fail') return 'fail' len_read = len(gdal.VSIFReadL(1, file_len, fp)) if len_read != file_len: - gdaltest.post_reason('fail') print(len_read) return 'fail' @@ -747,11 +686,9 @@ def test_vsifile_16(): def test_vsifile_17(): if gdal.GetActualURL('foo') is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetSignedURL('foo') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -781,7 +718,6 @@ def test_vsifile_19(): if options is not None: ret = gdal.ParseXMLString(options) if ret is None: - gdaltest.post_reason('fail') print(prefix, options) return 'fail' @@ -904,8 +840,6 @@ def test_vsigzip_multi_thread(): gdal.Unlink('/vsimem/vsigzip_multi_thread.gz') if data != 'hello' * 100000: - gdaltest.post_reason('fail') - for i in range(10000): if data[i*5:i*5+5] != 'hello': print(i*5, data[i*5:i*5+5], data[i*5-5:i*5+5-5]) @@ -923,21 +857,17 @@ def test_vsisync(): with gdaltest.error_handler(): if gdal.Sync('/i_do/not/exist', '/vsimem/'): - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if gdal.Sync('vsifile.py', '/i_do/not/exist'): - gdaltest.post_reason('fail') return 'fail' # Test copying a file for i in range(2): if not gdal.Sync('vsifile.py', '/vsimem/'): - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsimem/vsifile.py').size != gdal.VSIStatL('vsifile.py').size: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/vsifile.py') @@ -950,23 +880,18 @@ def test_vsisync(): if sys.platform != 'win32': with gdaltest.error_handler(): if gdal.Sync('/vsimem/test_sync/', '/i_do_not/exist'): - gdaltest.post_reason('fail') return 'fail' if not gdal.Sync('/vsimem/test_sync/', '/vsimem/out'): - gdaltest.post_reason('fail') return 'fail' if gdal.ReadDir('/vsimem/out') != [ 'foo.txt', 'subdir' ]: - gdaltest.post_reason('fail') print(gdal.ReadDir('/vsimem/out')) return 'fail' if gdal.ReadDir('/vsimem/out/subdir') != [ 'bar.txt' ]: - gdaltest.post_reason('fail') print(gdal.ReadDir('/vsimem/out/subdir')) return 'fail' # Again if not gdal.Sync('/vsimem/test_sync/', '/vsimem/out'): - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/out') @@ -977,20 +902,16 @@ def my_progress(pct, message, user_data): pct_values.append(pct) if not gdal.Sync('/vsimem/test_sync', '/vsimem/out', callback = my_progress): - gdaltest.post_reason('fail') return 'fail' if pct_values != [0.5, 1.0]: - gdaltest.post_reason('fail') print(pct_values) return 'fail' if gdal.ReadDir('/vsimem/out') != [ 'test_sync' ]: - gdaltest.post_reason('fail') print(gdal.ReadDir('/vsimem/out')) return 'fail' if gdal.ReadDir('/vsimem/out/test_sync') != [ 'foo.txt', 'subdir' ]: - gdaltest.post_reason('fail') print(gdal.ReadDir('/vsimem/out/test_sync')) return 'fail' @@ -1007,7 +928,6 @@ def test_vsifile_opendir(): # Non existing dir d = gdal.OpenDir('/vsimem/i_dont_exist') if d: - gdaltest.post_reason('fail') return 'fail' gdal.Mkdir('/vsimem/vsifile_opendir', 0o755) @@ -1015,11 +935,9 @@ def test_vsifile_opendir(): # Empty dir d = gdal.OpenDir('/vsimem/vsifile_opendir') if not d: - gdaltest.post_reason('fail') return 'fail' entry = gdal.GetNextDirEntry(d) if entry: - gdaltest.post_reason('fail') return 'fail' gdal.CloseDir(d) @@ -1033,65 +951,50 @@ def test_vsifile_opendir(): entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 16384: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir/subdir2': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 16384: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir/subdir2/test2': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 32768: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'test': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 32768: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' if not entry.modeKnown: - gdaltest.post_reason('fail') return 'fail' if entry.size != 3: - gdaltest.post_reason('fail') return 'fail' if not entry.sizeKnown: - gdaltest.post_reason('fail') return 'fail' if entry.mtime == 0: - gdaltest.post_reason('fail') return 'fail' if not entry.mtimeKnown: - gdaltest.post_reason('fail') return 'fail' if entry.extra: - gdaltest.post_reason('fail') return 'fail' entry = gdal.GetNextDirEntry(d) if entry: - gdaltest.post_reason('fail') return 'fail' gdal.CloseDir(d) @@ -1099,24 +1002,20 @@ def test_vsifile_opendir(): d = gdal.OpenDir('/vsimem/vsifile_opendir', 0) entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir': - gdaltest.post_reason('fail') print(entry.name) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'test': - gdaltest.post_reason('fail') print(entry.name) return 'fail' entry = gdal.GetNextDirEntry(d) if entry: - gdaltest.post_reason('fail') return 'fail' gdal.CloseDir(d) # Depth 1 files = [l_entry.name for l_entry in gdal.listdir('/vsimem/vsifile_opendir', 1)] if files != ['subdir', 'subdir/subdir2', 'test']: - gdaltest.post_reason('fail') print(files) return 'fail' diff --git a/autotest/gcore/vsigs.py b/autotest/gcore/vsigs.py index 258e9acb08d3..e11e5cf62b63 100755 --- a/autotest/gcore/vsigs.py +++ b/autotest/gcore/vsigs.py @@ -68,7 +68,6 @@ def test_vsigs_init(): with gdaltest.config_option('CPL_GCE_SKIP', 'YES'): if gdal.GetSignedURL('/vsigs/foo/bar') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -89,12 +88,10 @@ def test_vsigs_1(): with gdaltest.error_handler(): f = open_for_read('/vsigs/foo/bar') if f is not None: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' last_err = gdal.GetLastErrorMsg() if last_err.find('Cannot read') < 0: - gdaltest.post_reason('fail') print(last_err) return 'fail' @@ -103,7 +100,6 @@ def test_vsigs_1(): with gdaltest.config_option('CPL_GCE_SKIP', 'YES'): f = open_for_read('/vsigs/foo/bar') if f is not None: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' @@ -113,7 +109,6 @@ def test_vsigs_1(): with gdaltest.error_handler(): f = open_for_read('/vsigs/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('GS_SECRET_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -122,7 +117,6 @@ def test_vsigs_1(): with gdaltest.error_handler(): f = open_for_read('/vsigs_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('GS_SECRET_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -133,7 +127,6 @@ def test_vsigs_1(): with gdaltest.error_handler(): f = open_for_read('/vsigs/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('GS_ACCESS_KEY_ID') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -148,7 +141,6 @@ def test_vsigs_1(): gdal.VSIFCloseL(f) if gdal.GetConfigOption('APPVEYOR') is not None: return 'success' - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -156,7 +148,6 @@ def test_vsigs_1(): with gdaltest.error_handler(): f = open_for_read('/vsigs_streaming/foo/bar.baz') if f is not None or gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -203,12 +194,10 @@ def test_vsigs_2(): with gdaltest.config_option('GDAL_HTTP_HEADER_FILE', '/vsimem/my_headers.txt'): f = open_for_read('/vsigs/gs_fake_bucket_http_header_file/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(data) != 1: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/my_headers.txt') @@ -220,7 +209,6 @@ def test_vsigs_2(): ['START_DATE=20180212T123456Z']) if signed_url not in ('http://127.0.0.1:8080/gs_fake_bucket/resource?Expires=1518442496&GoogleAccessId=GS_ACCESS_KEY_ID&Signature=xTphUyMqtKA6UmAX3PEr5VL3EOg%3D', 'http://127.0.0.1:8081/gs_fake_bucket/resource?Expires=1518442496&GoogleAccessId=GS_ACCESS_KEY_ID&Signature=xTphUyMqtKA6UmAX3PEr5VL3EOg%3D'): - gdaltest.post_reason('fail') print(signed_url) return 'fail' @@ -231,13 +219,11 @@ def test_vsigs_2(): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -248,13 +234,11 @@ def test_vsigs_2(): with webserver.install_http_handler(handler): f = open_for_read('/vsigs_streaming/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -264,7 +248,6 @@ def test_vsigs_2(): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsigs/gs_fake_bucket/resource2.bin') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -277,7 +260,6 @@ def test_vsigs_2(): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsigs_streaming/gs_fake_bucket/resource2.bin') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -333,26 +315,21 @@ def test_vsigs_readdir(): print('Skipped on trusty branch, but should be investigated') return 'skip' - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) dir_contents = gdal.ReadDir('/vsigs/gs_fake_bucket2/a_dir') if dir_contents != ['resource3.bin', 'resource4.bin', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' if gdal.VSIStatL('/vsigs/gs_fake_bucket2/a_dir/resource3.bin').size != 123456: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsigs/gs_fake_bucket2/a_dir/resource3.bin').mtime != 1: - gdaltest.post_reason('fail') return 'fail' # ReadDir on something known to be a file shouldn't cause network access dir_contents = gdal.ReadDir('/vsigs/gs_fake_bucket2/a_dir/resource3.bin') if dir_contents is not None: - gdaltest.post_reason('fail') return 'fail' # List buckets @@ -370,7 +347,6 @@ def test_vsigs_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsigs/') if dir_contents != ['mybucket']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -389,7 +365,6 @@ def test_vsigs_write(): f = gdal.VSIFOpenL('/vsigs/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -419,7 +394,6 @@ def method(request): ret = gdal.VSIFWriteL('x' * 35000, 1, 35000, f) ret += gdal.VSIFWriteL('x' * 5000, 1, 5000, f) if ret != 40000: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -428,7 +402,6 @@ def method(request): # Simulate failure while transmitting f = gdal.VSIFOpenL('/vsigs/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -444,7 +417,6 @@ def method(request): with gdaltest.error_handler(): ret = gdal.VSIFWriteL('x' * 35000, 1, 35000, f) if ret != 0: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -453,7 +425,6 @@ def method(request): # Simulate failure at end of transfer f = gdal.VSIFOpenL('/vsigs/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -476,14 +447,12 @@ def method(request): with webserver.install_http_handler(handler): ret = gdal.VSIFWriteL('x' * 35000, 1, 35000, f) if ret != 35000: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFCloseL(f) if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -507,7 +476,6 @@ def test_vsigs_read_credentials_refresh_token_default_gdal_app(): with gdaltest.error_handler(): if gdal.GetSignedURL('/vsigs/foo/bar') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -555,13 +523,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -634,13 +600,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -746,7 +710,6 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) @@ -761,7 +724,6 @@ def method(request): gdal.SetConfigOption('GS_OAUTH2_CLIENT_EMAIL', '') if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -840,7 +802,6 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') gdal.Unlink('/vsimem/service_account.json') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') @@ -850,7 +811,6 @@ def method(request): ['START_DATE=20180212T123456Z']) if signed_url not in ('http://127.0.0.1:8080/gs_fake_bucket/resource?Expires=1518442496&GoogleAccessId=CLIENT_EMAIL&Signature=b19I62KdqV51DpWGxhxGXLGJIA8MHvSJofwOygoeQuIxkM6PmmQFvJYTNWRt9zUVTUoVC0UHVB7ee5Z35NqDC8K4i0quu1hb8Js2B4h0W6OAupvyF3nSQ5D0OJmiSbomGMq0Ehyro5cqJ%2FU%2Fd8oAaKrGKVQScKfXoFrSJBbWkNs%3D', 'http://127.0.0.1:8081/gs_fake_bucket/resource?Expires=1518442496&GoogleAccessId=CLIENT_EMAIL&Signature=b19I62KdqV51DpWGxhxGXLGJIA8MHvSJofwOygoeQuIxkM6PmmQFvJYTNWRt9zUVTUoVC0UHVB7ee5Z35NqDC8K4i0quu1hb8Js2B4h0W6OAupvyF3nSQ5D0OJmiSbomGMq0Ehyro5cqJ%2FU%2Fd8oAaKrGKVQScKfXoFrSJBbWkNs%3D'): - gdaltest.post_reason('fail') print(signed_url) gdal.Unlink('/vsimem/service_account.json') return 'fail' @@ -866,7 +826,6 @@ def method(request): gdal.Unlink('/vsimem/service_account.json') if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -922,13 +881,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1006,13 +963,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1073,13 +1028,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1091,19 +1044,16 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'bar': - gdaltest.post_reason('fail') print(data) return 'fail' with gdaltest.error_handler(): if gdal.GetSignedURL('/vsigs/foo/bar') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('CPL_GCE_CREDENTIALS_URL', '') @@ -1171,13 +1121,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsigs/gs_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1227,20 +1175,17 @@ def vsigs_extra_1(): path = '/vsigs/' + gs_resource statres = gdal.VSIStatL(path) if statres is None or not stat.S_ISDIR(statres.mode): - gdaltest.post_reason('fail') print('%s is not a valid bucket' % path) return 'fail' readdir = gdal.ReadDir(path) if readdir is None: - gdaltest.post_reason('fail') print('ReadDir() should not return empty list') return 'fail' for filename in readdir: if filename != '.': subpath = path + '/' + filename if gdal.VSIStatL(subpath) is None: - gdaltest.post_reason('fail') print('Stat(%s) should not return an error' % subpath) return 'fail' @@ -1248,81 +1193,68 @@ def vsigs_extra_1(): subpath = path + '/' + unique_id ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id not in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret == 0: - gdaltest.post_reason('fail') print('Mkdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should not contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, f) gdal.VSIFCloseL(f) ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) on non empty directory should return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 5, f).decode('utf-8') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' gdal.VSIFCloseL(f) ret = gdal.Unlink(subpath + '/test.txt') if ret < 0: - gdaltest.post_reason('fail') print('Unlink(%s) should not return an error' % (subpath + '/test.txt')) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' @@ -1330,26 +1262,22 @@ def vsigs_extra_1(): f = open_for_read('/vsigs/' + gs_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' # Same with /vsigs_streaming/ f = open_for_read('/vsigs_streaming/' + gs_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -1362,7 +1290,6 @@ def vsigs_extra_1(): gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -1370,7 +1297,6 @@ def vsigs_extra_1(): gdal.ErrorReset() f = open_for_read('/vsigs_streaming/' + gs_resource + '/invalid_resource.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -1378,13 +1304,11 @@ def vsigs_extra_1(): signed_url = gdal.GetSignedURL('/vsigs/' + gs_resource) f = open_for_read('/vsicurl_streaming/' + signed_url) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' diff --git a/autotest/gcore/vsioss.py b/autotest/gcore/vsioss.py index a3311b4a7817..93901eed863a 100755 --- a/autotest/gcore/vsioss.py +++ b/autotest/gcore/vsioss.py @@ -55,7 +55,6 @@ def test_visoss_init(): gdal.SetConfigOption(var, "") if gdal.GetSignedURL('/vsioss/foo/bar') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -74,7 +73,6 @@ def test_visoss_1(): with gdaltest.error_handler(): f = open_for_read('/vsioss/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('OSS_SECRET_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -82,7 +80,6 @@ def test_visoss_1(): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('OSS_SECRET_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -93,7 +90,6 @@ def test_visoss_1(): with gdaltest.error_handler(): f = open_for_read('/vsioss/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('OSS_ACCESS_KEY_ID') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -119,7 +115,6 @@ def test_visoss_real_test(): gdal.VSIFCloseL(f) if gdal.GetConfigOption('APPVEYOR') is not None: return 'success' - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -127,7 +122,6 @@ def test_visoss_real_test(): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/foo/bar.baz') if f is not None or gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -193,7 +187,6 @@ def test_visoss_2(): ['START_DATE=20180212T123456Z']) if signed_url not in ('http://127.0.0.1:8080/oss_fake_bucket/resource?Expires=1518442496&OSSAccessKeyId=OSS_ACCESS_KEY_ID&Signature=bpFqur6tQMNN7Xe7UHVFFrugmgs%3D', 'http://127.0.0.1:8081/oss_fake_bucket/resource?Expires=1518442496&OSSAccessKeyId=OSS_ACCESS_KEY_ID&Signature=bpFqur6tQMNN7Xe7UHVFFrugmgs%3D'): - gdaltest.post_reason('fail') print(signed_url) return 'fail' @@ -203,13 +196,11 @@ def test_visoss_2(): with webserver.install_http_handler(handler): f = open_for_read('/vsioss/oss_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -218,13 +209,11 @@ def test_visoss_2(): with webserver.install_http_handler(handler): f = open_for_read('/vsioss_streaming/oss_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -269,7 +258,6 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsioss/oss_fake_bucket/redirect') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) @@ -280,7 +268,6 @@ def method(request): print('Skipped on trusty branch, but should be investigated') return 'skip' - gdaltest.post_reason('fail') print(data) return 'fail' @@ -289,13 +276,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsioss_streaming/oss_fake_bucket/redirect') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -324,7 +309,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/oss_fake_bucket/non_xml_error') if f is not None or gdal.VSIGetLastErrorMsg().find('bla') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -340,7 +324,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/oss_fake_bucket/invalid_xml_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -356,7 +339,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/oss_fake_bucket/no_code_in_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -372,7 +354,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/oss_fake_bucket/no_region_in_AuthorizationHeaderMalformed_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -388,7 +369,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/oss_fake_bucket/no_endpoint_in_PermanentRedirect_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -404,7 +384,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/oss_fake_bucket/no_message_in_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -473,27 +452,22 @@ def method(request): print('Skipped on trusty branch, but should be investigated') return 'skip' - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) with webserver.install_http_handler(webserver.SequentialHandler()): dir_contents = gdal.ReadDir('/vsioss/oss_fake_bucket2/a_dir') if dir_contents != ['resource3.bin', 'resource4.bin', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' if gdal.VSIStatL('/vsioss/oss_fake_bucket2/a_dir/resource3.bin').size != 123456: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsioss/oss_fake_bucket2/a_dir/resource3.bin').mtime != 1: - gdaltest.post_reason('fail') return 'fail' # ReadDir on something known to be a file shouldn't cause network access dir_contents = gdal.ReadDir('/vsioss/oss_fake_bucket2/a_dir/resource3.bin') if dir_contents is not None: - gdaltest.post_reason('fail') return 'fail' # Test CPL_VSIL_CURL_NON_CACHED @@ -510,13 +484,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsioss/oss_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -527,7 +499,6 @@ def method(request): with webserver.install_http_handler(handler): size = gdal.VSIStatL('/vsioss/oss_non_cached/test.txt').size if size != 4: - gdaltest.post_reason('fail') print(config_option_value) print(size) return 'fail' @@ -538,7 +509,6 @@ def method(request): with webserver.install_http_handler(handler): size = gdal.VSIStatL('/vsioss/oss_non_cached/test.txt').size if size != 3: - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -549,13 +519,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsioss/oss_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'bar2': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -588,13 +556,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsioss/oss_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -603,14 +569,12 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsioss/oss_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) # We should still get foo because of caching if data != 'foo': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -627,7 +591,6 @@ def method(request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsioss/') if dir_contents != ['.']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -648,7 +611,6 @@ def method(request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsioss/') if dir_contents != ['mybucket']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -667,14 +629,12 @@ def test_visoss_4(): with gdaltest.error_handler(): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket3', 'wb') if f is not None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/oss_fake_bucket3/empty_file.bin', 200, {'Connection': 'close'}, 'foo') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsioss/oss_fake_bucket3/empty_file.bin').size != 3: - gdaltest.post_reason('fail') return 'fail' # Empty file @@ -695,19 +655,16 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket3/empty_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/oss_fake_bucket3/empty_file.bin', 200, {'Connection': 'close'}, '') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsioss/oss_fake_bucket3/empty_file.bin').size != 0: - gdaltest.post_reason('fail') return 'fail' # Invalid seek @@ -715,12 +672,10 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket3/empty_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFSeekL(f, 1, 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -729,12 +684,10 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket3/empty_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFReadL(1, 1, f) if ret: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -744,38 +697,29 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket3/empty_file_error.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' # Nominal case with webserver.install_http_handler(webserver.SequentialHandler()): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket3/another_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, gdal.VSIFTellL(f), 0) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, 0, 1) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, 0, 2) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('foo', 1, 3, f) != 3: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, gdal.VSIFTellL(f), 0) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('bar', 1, 3, f) != 3: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -808,7 +752,6 @@ def method(request): with webserver.install_http_handler(handler): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -826,19 +769,16 @@ def test_visoss_5(): with gdaltest.error_handler(): ret = gdal.Unlink('/vsioss/foo') if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/oss_delete_bucket/delete_file', 200, {'Connection': 'close'}, 'foo') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsioss/oss_delete_bucket/delete_file').size != 3: - gdaltest.post_reason('fail') return 'fail' with webserver.install_http_handler(webserver.SequentialHandler()): if gdal.VSIStatL('/vsioss/oss_delete_bucket/delete_file').size != 3: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -846,7 +786,6 @@ def test_visoss_5(): with webserver.install_http_handler(handler): ret = gdal.Unlink('/vsioss/oss_delete_bucket/delete_file') if ret != 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -854,7 +793,6 @@ def test_visoss_5(): handler.add('GET', '/oss_delete_bucket/?delimiter=%2F&max-keys=100&prefix=delete_file%2F', 404, {'Connection': 'close'}, 'foo') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsioss/oss_delete_bucket/delete_file') is not None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -864,7 +802,6 @@ def test_visoss_5(): with gdaltest.error_handler(): ret = gdal.Unlink('/vsioss/oss_delete_bucket/delete_file_error') if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -882,7 +819,6 @@ def test_visoss_6(): with webserver.install_http_handler(webserver.SequentialHandler()): f = gdal.VSIFOpenL('/vsioss/oss_fake_bucket4/large_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' size = 1024 * 1024 + 1 big_buffer = 'a' * size @@ -917,7 +853,6 @@ def method(request): with webserver.install_http_handler(handler): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != size: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -966,7 +901,6 @@ def method(request): with webserver.install_http_handler(handler): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -982,18 +916,15 @@ def method(request): with gdaltest.config_option('VSIOSS_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != 0: - gdaltest.post_reason('fail') print(ret) return 'fail' gdal.ErrorReset() gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1013,20 +944,17 @@ def method(request): with gdaltest.config_option('VSIOSS_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') print(filename) return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != 0: - gdaltest.post_reason('fail') print(filename) print(ret) return 'fail' gdal.ErrorReset() gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(filename) return 'fail' @@ -1042,13 +970,11 @@ def method(request): with gdaltest.config_option('VSIOSS_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') print(filename) return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != 0: - gdaltest.post_reason('fail') print(filename) print(ret) return 'fail' @@ -1056,7 +982,6 @@ def method(request): with gdaltest.error_handler(): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(filename) return 'fail' @@ -1074,12 +999,10 @@ def method(request): with gdaltest.config_option('VSIOSS_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') print(filename) return 'fail' ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != size: - gdaltest.post_reason('fail') print(filename) print(ret) return 'fail' @@ -1087,7 +1010,6 @@ def method(request): with gdaltest.error_handler(): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(filename) return 'fail' @@ -1109,7 +1031,6 @@ def test_visoss_7(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsioss/oss_bucket_test_mkdir/dir', 0) if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try creating already existing directory @@ -1118,7 +1039,6 @@ def test_visoss_7(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsioss/oss_bucket_test_mkdir/dir', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1126,7 +1046,6 @@ def test_visoss_7(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsioss/oss_bucket_test_mkdir/dir') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting already deleted directory @@ -1136,7 +1055,6 @@ def test_visoss_7(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsioss/oss_bucket_test_mkdir/dir') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting non-empty directory @@ -1157,7 +1075,6 @@ def test_visoss_7(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsioss/oss_bucket_test_mkdir/dir_nonempty') if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1191,20 +1108,17 @@ def test_visoss_8(): with webserver.install_http_handler(handler): listdir = gdal.ReadDir('/vsioss/visoss_8', 0) if listdir != ['test', 'test/']: - gdaltest.post_reason('fail') print(listdir) return 'fail' handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if stat.S_ISDIR(gdal.VSIStatL('/vsioss/visoss_8/test').mode): - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if not stat.S_ISDIR(gdal.VSIStatL('/vsioss/visoss_8/test/').mode): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1251,20 +1165,17 @@ def visoss_extra_1(): path = '/vsioss/' + OSS_RESOURCE statres = gdal.VSIStatL(path) if statres is None or not stat.S_ISDIR(statres.mode): - gdaltest.post_reason('fail') print('%s is not a valid bucket' % path) return 'fail' readdir = gdal.ReadDir(path) if readdir is None: - gdaltest.post_reason('fail') print('ReadDir() should not return empty list') return 'fail' for filename in readdir: if filename != '.': subpath = path + '/' + filename if gdal.VSIStatL(subpath) is None: - gdaltest.post_reason('fail') print('Stat(%s) should not return an error' % subpath) return 'fail' @@ -1272,81 +1183,68 @@ def visoss_extra_1(): subpath = path + '/' + unique_id ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id not in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret == 0: - gdaltest.post_reason('fail') print('Mkdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should not contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, f) gdal.VSIFCloseL(f) ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) on non empty directory should return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 5, f).decode('utf-8') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' gdal.VSIFCloseL(f) ret = gdal.Unlink(subpath + '/test.txt') if ret < 0: - gdaltest.post_reason('fail') print('Unlink(%s) should not return an error' % (subpath + '/test.txt')) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' @@ -1354,27 +1252,23 @@ def visoss_extra_1(): f = open_for_read('/vsioss/' + OSS_RESOURCE) if f is None: - gdaltest.post_reason('fail') print('cannot open %s' % ('/vsioss/' + OSS_RESOURCE)) return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' # Same with /vsioss_streaming/ f = open_for_read('/vsioss_streaming/' + OSS_RESOURCE) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -1387,7 +1281,6 @@ def visoss_extra_1(): gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -1395,7 +1288,6 @@ def visoss_extra_1(): gdal.ErrorReset() f = open_for_read('/vsioss_streaming/' + OSS_RESOURCE + '/invalid_resource.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -1403,13 +1295,11 @@ def visoss_extra_1(): signed_url = gdal.GetSignedURL('/vsioss/' + OSS_RESOURCE) f = open_for_read('/vsicurl_streaming/' + signed_url) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' diff --git a/autotest/gcore/vsis3.py b/autotest/gcore/vsis3.py index 1dff8c9d98b2..01760b786f32 100755 --- a/autotest/gcore/vsis3.py +++ b/autotest/gcore/vsis3.py @@ -62,7 +62,6 @@ def test_vsis3_init(): gdal.SetConfigOption('CPL_AWS_EC2_CREDENTIALS_URL', '') if gdal.GetSignedURL('/vsis3/foo/bar') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -79,13 +78,11 @@ def test_vsis3_no_sign_request(): with gdaltest.config_option('AWS_NO_SIGN_REQUEST', 'YES'): actual_url = gdal.GetActualURL('/vsis3/landsat-pds/L8/001/002/LC80010022016230LGN00/LC80010022016230LGN00_B1.TIF') if actual_url != 'https://landsat-pds.s3.amazonaws.com/L8/001/002/LC80010022016230LGN00/LC80010022016230LGN00_B1.TIF': - gdaltest.post_reason('fail') print(actual_url) return 'fail' actual_url = gdal.GetActualURL('/vsis3_streaming/landsat-pds/L8/001/002/LC80010022016230LGN00/LC80010022016230LGN00_B1.TIF') if actual_url != 'https://landsat-pds.s3.amazonaws.com/L8/001/002/LC80010022016230LGN00/LC80010022016230LGN00_B1.TIF': - gdaltest.post_reason('fail') print(actual_url) return 'fail' @@ -113,7 +110,6 @@ def test_vsis3_1(): with gdaltest.error_handler(): f = open_for_read('/vsis3/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('AWS_SECRET_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -121,7 +117,6 @@ def test_vsis3_1(): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('AWS_SECRET_ACCESS_KEY') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -132,7 +127,6 @@ def test_vsis3_1(): with gdaltest.error_handler(): f = open_for_read('/vsis3/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('AWS_ACCESS_KEY_ID') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -147,7 +141,6 @@ def test_vsis3_1(): gdal.VSIFCloseL(f) if gdal.GetConfigOption('APPVEYOR') is not None: return 'success' - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -155,7 +148,6 @@ def test_vsis3_1(): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/foo/bar.baz') if f is not None or gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -220,7 +212,6 @@ def test_vsis3_2(): expected_url_8080 = 'http://127.0.0.1:8080/s3_fake_bucket/resource?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AWS_ACCESS_KEY_ID%2F20150101%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20150101T000000Z&X-Amz-Expires=3600&X-Amz-Signature=dca239dd95f72ff8c37c15c840afc54cd19bdb07f7aaee2223108b5b0ad35da8&X-Amz-SignedHeaders=host' expected_url_8081 = 'http://127.0.0.1:8081/s3_fake_bucket/resource?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AWS_ACCESS_KEY_ID%2F20150101%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20150101T000000Z&X-Amz-Expires=3600&X-Amz-Signature=ef5216bc5971863414c69f6ca095276c0d62c0da97fa4f6ab80c30bd7fc146ac&X-Amz-SignedHeaders=host' if signed_url not in (expected_url_8080, expected_url_8081): - gdaltest.post_reason('fail') print(signed_url) return 'fail' @@ -230,13 +221,11 @@ def test_vsis3_2(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -245,13 +234,11 @@ def test_vsis3_2(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3_streaming/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -284,7 +271,6 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket_with_session_token/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) @@ -321,7 +307,6 @@ def method(request): stat_res = gdal.VSIStatL('/vsis3/s3_fake_bucket/resource2.bin') # gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', old_val) if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -336,7 +321,6 @@ def method(request): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsis3_streaming/s3_fake_bucket/resource2.bin') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -398,7 +382,6 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/redirect') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) @@ -409,7 +392,6 @@ def method(request): print('Skipped on trusty branch, but should be investigated') return 'skip' - gdaltest.post_reason('fail') print(data) return 'fail' @@ -418,13 +400,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3_streaming/s3_fake_bucket/redirect') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -454,7 +434,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/s3_fake_bucket/non_xml_error') if f is not None or gdal.VSIGetLastErrorMsg().find('bla') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -470,7 +449,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/s3_fake_bucket/invalid_xml_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -486,7 +464,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/s3_fake_bucket/no_code_in_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -502,7 +479,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/s3_fake_bucket/no_region_in_AuthorizationHeaderMalformed_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -518,7 +494,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/s3_fake_bucket/no_endpoint_in_PermanentRedirect_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -534,7 +509,6 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3_streaming/s3_fake_bucket/no_message_in_error') if f is not None or gdal.VSIGetLastErrorMsg().find('') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -571,13 +545,11 @@ def method(request): with gdaltest.error_handler(): f = open_for_read('/vsis3/s3_fake_bucket_with_requester_pays/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') return 'fail' # Test temporary redirect @@ -626,13 +598,11 @@ def method_req_2(self, request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_test_temporary_redirect_read/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -646,13 +616,11 @@ def method_req_2(self, request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_test_temporary_redirect_read/resource2') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'bar': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -759,47 +727,39 @@ def method(request): print('Skipped on trusty branch, but should be investigated') return 'skip' - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) with webserver.install_http_handler(webserver.SequentialHandler()): dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir') if dir_contents != ['resource3.bin', 'resource4.bin', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' if gdal.VSIStatL('/vsis3/s3_fake_bucket2/a_dir/resource3.bin').size != 123456: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsis3/s3_fake_bucket2/a_dir/resource3.bin').mtime != 1: - gdaltest.post_reason('fail') return 'fail' # Same as above: cached dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir') if dir_contents != ['resource3.bin', 'resource4.bin', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' # ReadDir on something known to be a file shouldn't cause network access dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir/resource3.bin') if dir_contents is not None: - gdaltest.post_reason('fail') return 'fail' # Test unrelated partial clear of the cache gdal.VSICurlPartialClearCache('/vsis3/s3_fake_bucket_unrelated') if gdal.VSIStatL('/vsis3/s3_fake_bucket2/a_dir/resource3.bin').size != 123456: - gdaltest.post_reason('fail') return 'fail' dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir') if dir_contents != ['resource3.bin', 'resource4.bin', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -827,7 +787,6 @@ def method(request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir') if dir_contents != ['test.txt']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -857,7 +816,6 @@ def method(request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsis3/s3_fake_bucket2/a_dir') if dir_contents != ['resource4.bin', 'i_am_a_glacier_file', 'subdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -876,13 +834,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -893,7 +849,6 @@ def method(request): with webserver.install_http_handler(handler): size = gdal.VSIStatL('/vsis3/s3_non_cached/test.txt').size if size != 4: - gdaltest.post_reason('fail') print(config_option_value) print(size) return 'fail' @@ -904,7 +859,6 @@ def method(request): with webserver.install_http_handler(handler): size = gdal.VSIStatL('/vsis3/s3_non_cached/test.txt').size if size != 3: - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -915,13 +869,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'bar2': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -954,13 +906,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -969,14 +919,12 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_non_cached/test.txt') if f is None: - gdaltest.post_reason('fail') print(config_option_value) return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) # We should still get foo because of caching if data != 'foo': - gdaltest.post_reason('fail') print(config_option_value) print(data) return 'fail' @@ -993,7 +941,6 @@ def method(request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsis3/') if dir_contents != ['.']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -1014,7 +961,6 @@ def method(request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsis3/') if dir_contents != ['mybucket']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -1072,7 +1018,6 @@ def method_req_2(self, request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsis3/s3_test_temporary_redirect_read_dir') if dir_contents != ['test']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -1093,7 +1038,6 @@ def method_req_2(self, request): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsis3/s3_test_temporary_redirect_read_dir/test') if dir_contents != ['test2']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -1135,46 +1079,37 @@ def test_vsis3_opendir(): with webserver.install_http_handler(handler): d = gdal.OpenDir('/vsis3/vsis3_opendir') if d is None: - gdaltest.post_reason('fail') return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'test.txt': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.size != 40: - gdaltest.post_reason('fail') print(entry.size) return 'fail' if entry.mode != 32768: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' if entry.mtime != 1: - gdaltest.post_reason('fail') print(entry.mtime) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 16384: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir/test.txt': - gdaltest.post_reason('fail') print(entry.name) return 'fail' entry = gdal.GetNextDirEntry(d) if entry is not None: - gdaltest.post_reason('fail') return 'fail' gdal.CloseDir(d) @@ -1199,40 +1134,32 @@ def test_vsis3_opendir(): with webserver.install_http_handler(handler): d = gdal.OpenDir('/vsis3/vsis3_opendir', 0) if d is None: - gdaltest.post_reason('fail') return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'test.txt': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.size != 40: - gdaltest.post_reason('fail') print(entry.size) return 'fail' if entry.mode != 32768: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' if entry.mtime != 1: - gdaltest.post_reason('fail') print(entry.mtime) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 16384: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' entry = gdal.GetNextDirEntry(d) if entry is not None: - gdaltest.post_reason('fail') return 'fail' gdal.CloseDir(d) @@ -1257,34 +1184,27 @@ def test_vsis3_opendir(): with webserver.install_http_handler(handler): d = gdal.OpenDir('/vsis3/vsis3_opendir', 1) if d is None: - gdaltest.post_reason('fail') return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'test.txt': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.size != 40: - gdaltest.post_reason('fail') print(entry.size) return 'fail' if entry.mode != 32768: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' if entry.mtime != 1: - gdaltest.post_reason('fail') print(entry.mtime) return 'fail' entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir': - gdaltest.post_reason('fail') print(entry.name) return 'fail' if entry.mode != 16384: - gdaltest.post_reason('fail') print(entry.mode) return 'fail' @@ -1304,13 +1224,11 @@ def test_vsis3_opendir(): with webserver.install_http_handler(handler): entry = gdal.GetNextDirEntry(d) if entry.name != 'subdir/test.txt': - gdaltest.post_reason('fail') print(entry.name) return 'fail' entry = gdal.GetNextDirEntry(d) if entry is not None: - gdaltest.post_reason('fail') return 'fail' gdal.CloseDir(d) @@ -1332,14 +1250,12 @@ def test_vsis3_4(): with gdaltest.error_handler(): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3', 'wb') if f is not None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/s3_fake_bucket3/empty_file.bin', 200, {'Connection': 'close'}, 'foo') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsis3/s3_fake_bucket3/empty_file.bin').size != 3: - gdaltest.post_reason('fail') return 'fail' # Empty file @@ -1360,19 +1276,16 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3/empty_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/s3_fake_bucket3/empty_file.bin', 200, {'Connection': 'close'}, '') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsis3/s3_fake_bucket3/empty_file.bin').size != 0: - gdaltest.post_reason('fail') return 'fail' # Invalid seek @@ -1380,12 +1293,10 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3/empty_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFSeekL(f, 1, 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -1394,12 +1305,10 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3/empty_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFReadL(1, 1, f) if ret: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -1409,38 +1318,29 @@ def method(request): with webserver.install_http_handler(handler): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3/empty_file_error.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' # Nominal case with webserver.install_http_handler(webserver.SequentialHandler()): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3/another_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, gdal.VSIFTellL(f), 0) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, 0, 1) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, 0, 2) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('foo', 1, 3, f) != 3: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFSeekL(f, gdal.VSIFTellL(f), 0) != 0: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('bar', 1, 3, f) != 3: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1473,17 +1373,14 @@ def method(request): with webserver.install_http_handler(handler): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' # Redirect case with webserver.install_http_handler(webserver.SequentialHandler()): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket3/redirect', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('foobar', 1, 6, f) != 6: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1529,7 +1426,6 @@ def method(request): with webserver.install_http_handler(handler): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1547,20 +1443,17 @@ def test_vsis3_5(): with gdaltest.error_handler(): ret = gdal.Unlink('/vsis3/foo') if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/s3_delete_bucket/delete_file', 200, {'Connection': 'close'}, 'foo') with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsis3/s3_delete_bucket/delete_file').size != 3: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsis3/s3_delete_bucket/delete_file').size != 3: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1568,7 +1461,6 @@ def test_vsis3_5(): with webserver.install_http_handler(handler): ret = gdal.Unlink('/vsis3/s3_delete_bucket/delete_file') if ret != 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1576,7 +1468,6 @@ def test_vsis3_5(): handler.add('GET', '/s3_delete_bucket/?delimiter=%2F&max-keys=100&prefix=delete_file%2F', 404, {'Connection': 'close'}) with webserver.install_http_handler(handler): if gdal.VSIStatL('/vsis3/s3_delete_bucket/delete_file') is not None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1586,7 +1477,6 @@ def test_vsis3_5(): with gdaltest.error_handler(): ret = gdal.Unlink('/vsis3/s3_delete_bucket/delete_file_error') if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1619,7 +1509,6 @@ def method(request): with webserver.install_http_handler(handler): ret = gdal.Unlink('/vsis3/s3_delete_bucket/redirect') if ret != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1637,7 +1526,6 @@ def test_vsis3_6(): with webserver.install_http_handler(webserver.SequentialHandler()): f = gdal.VSIFOpenL('/vsis3/s3_fake_bucket4/large_file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' size = 1024 * 1024 + 1 big_buffer = 'a' * size @@ -1687,7 +1575,6 @@ def method(request): with webserver.install_http_handler(handler): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != size: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1736,7 +1623,6 @@ def method(request): with webserver.install_http_handler(handler): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1752,18 +1638,15 @@ def method(request): with gdaltest.config_option('VSIS3_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != 0: - gdaltest.post_reason('fail') print(ret) return 'fail' gdal.ErrorReset() gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1783,20 +1666,17 @@ def method(request): with gdaltest.config_option('VSIS3_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') print(filename) return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != 0: - gdaltest.post_reason('fail') print(filename) print(ret) return 'fail' gdal.ErrorReset() gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(filename) return 'fail' @@ -1812,13 +1692,11 @@ def method(request): with gdaltest.config_option('VSIS3_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') print(filename) return 'fail' with gdaltest.error_handler(): ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != 0: - gdaltest.post_reason('fail') print(filename) print(ret) return 'fail' @@ -1826,7 +1704,6 @@ def method(request): with gdaltest.error_handler(): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(filename) return 'fail' @@ -1844,12 +1721,10 @@ def method(request): with gdaltest.config_option('VSIS3_CHUNK_SIZE', '1'): # 1 MB f = gdal.VSIFOpenL(filename, 'wb') if f is None: - gdaltest.post_reason('fail') print(filename) return 'fail' ret = gdal.VSIFWriteL(big_buffer, 1, size, f) if ret != size: - gdaltest.post_reason('fail') print(filename) print(ret) return 'fail' @@ -1857,7 +1732,6 @@ def method(request): with gdaltest.error_handler(): gdal.VSIFCloseL(f) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(filename) return 'fail' @@ -1879,16 +1753,13 @@ def test_vsis3_7(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsis3/s3_bucket_test_mkdir/dir', 0) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if not stat.S_ISDIR(gdal.VSIStatL('/vsis3/s3_bucket_test_mkdir/dir').mode): - gdaltest.post_reason('fail') return 'fail' dir_content = gdal.ReadDir('/vsis3/s3_bucket_test_mkdir/dir') if dir_content != ['.']: - gdaltest.post_reason('fail') print(dir_content) return 'fail' @@ -1898,7 +1769,6 @@ def test_vsis3_7(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsis3/s3_bucket_test_mkdir/dir', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -1906,7 +1776,6 @@ def test_vsis3_7(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsis3/s3_bucket_test_mkdir/dir') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting already deleted directory @@ -1916,7 +1785,6 @@ def test_vsis3_7(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsis3/s3_bucket_test_mkdir/dir') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting non-empty directory @@ -1937,7 +1805,6 @@ def test_vsis3_7(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsis3/s3_bucket_test_mkdir/dir_nonempty') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Try stat'ing a directory not ending with slash @@ -1957,7 +1824,6 @@ def test_vsis3_7(): """) with webserver.install_http_handler(handler): if not stat.S_ISDIR(gdal.VSIStatL('/vsis3/s3_bucket_test_dir_stat/test_dir_stat').mode): - gdaltest.post_reason('fail') return 'fail' # Try ReadDi'ing a directory not ending with slash @@ -1976,7 +1842,6 @@ def test_vsis3_7(): """) with webserver.install_http_handler(handler): if gdal.ReadDir('/vsis3/s3_bucket_test_readdir/test_dirread') is None: - gdaltest.post_reason('fail') return 'fail' # Try stat'ing a directory ending with slash @@ -1996,7 +1861,6 @@ def test_vsis3_7(): """) with webserver.install_http_handler(handler): if not stat.S_ISDIR(gdal.VSIStatL('/vsis3/s3_bucket_test_dir_stat_2/test_dir_stat/').mode): - gdaltest.post_reason('fail') return 'fail' # Try ReadDi'ing a directory ending with slash @@ -2015,7 +1879,6 @@ def test_vsis3_7(): """) with webserver.install_http_handler(handler): if gdal.ReadDir('/vsis3/s3_bucket_test_readdir2/test_dirread') is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2049,20 +1912,17 @@ def test_vsis3_8(): with webserver.install_http_handler(handler): listdir = gdal.ReadDir('/vsis3/vsis3_8', 0) if listdir != ['test', 'test/']: - gdaltest.post_reason('fail') print(listdir) return 'fail' handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if stat.S_ISDIR(gdal.VSIStatL('/vsis3/vsis3_8/test').mode): - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if not stat.S_ISDIR(gdal.VSIStatL('/vsis3/vsis3_8/test/').mode): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2084,7 +1944,6 @@ def test_vsis3_sync_etag(): handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if gdal.Sync('/i_do/not/exist', '/vsis3/', options=options): - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): @@ -2094,7 +1953,6 @@ def test_vsis3_sync_etag(): handler.add('PUT', '/do_not/exist', 404) with webserver.install_http_handler(handler): if gdal.Sync('vsifile.py', '/vsis3/do_not/exist', options=options): - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -2130,14 +1988,12 @@ def method(request): gdal.FileFromMemBuffer('/vsimem/testsync.txt', 'foo') with webserver.install_http_handler(handler): if not gdal.Sync('/vsimem/testsync.txt', '/vsis3/out', options=options): - gdaltest.post_reason('fail') return 'fail' # Re-try with cached ETag. Should generate no network access handler = webserver.SequentialHandler() with webserver.install_http_handler(handler): if not gdal.Sync('/vsimem/testsync.txt', '/vsis3/out', options=options): - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -2150,13 +2006,11 @@ def method(request): 'ETag' : '"acbd18db4cc2f85cedef654fccc4a4d8"' }, "foo") with webserver.install_http_handler(handler): if not gdal.Sync( '/vsis3/out/testsync.txt', '/vsimem/', options=options): - gdaltest.post_reason('fail') return 'fail' # Shouldn't do any copy, but hard to verify with webserver.install_http_handler(webserver.SequentialHandler()): if not gdal.Sync( '/vsis3/out/testsync.txt', '/vsimem/', options=options): - gdaltest.post_reason('fail') return 'fail' # Modify target file, and redo synchronization @@ -2181,14 +2035,12 @@ def method(request): 'ETag' : '"acbd18db4cc2f85cedef654fccc4a4d8"' }, "foo") with webserver.install_http_handler(handler): if not gdal.Sync( '/vsis3/out/testsync.txt', '/vsimem/', options=options): - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsimem/testsync.txt', 'rb') data = gdal.VSIFReadL(1, 3, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') return 'fail' # /vsimem to S3, but after cleaning the cache @@ -2202,7 +2054,6 @@ def method(request): 'ETag' : '"acbd18db4cc2f85cedef654fccc4a4d8"' }, "foo") with webserver.install_http_handler(handler): if not gdal.Sync('/vsimem/testsync.txt', '/vsis3/out', options=options): - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/testsync.txt') @@ -2227,7 +2078,6 @@ def method(request): """) with webserver.install_http_handler(handler): if not gdal.Sync('/vsimem/subdir/', '/vsis3/out', options=options): - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/subdir') @@ -2261,7 +2111,6 @@ def test_vsis3_sync_timestamp(): with webserver.install_http_handler(handler): if not gdal.Sync( '/vsis3/out/testsync.txt', '/vsimem/', options=options): - gdaltest.post_reason('fail') return 'fail' # S3 to local: S3 file is newer -> do nothing @@ -2274,7 +2123,6 @@ def test_vsis3_sync_timestamp(): with webserver.install_http_handler(handler): if not gdal.Sync( '/vsis3/out/testsync.txt', '/vsimem/', options=options): - gdaltest.post_reason('fail') return 'fail' # Local to S3: S3 file is older -> upload @@ -2288,7 +2136,6 @@ def test_vsis3_sync_timestamp(): with webserver.install_http_handler(handler): if not gdal.Sync( '/vsimem/testsync.txt', '/vsis3/out/testsync.txt', options=options): - gdaltest.post_reason('fail') return 'fail' # Local to S3: S3 file is newer -> do nothgin @@ -2301,7 +2148,6 @@ def test_vsis3_sync_timestamp(): with webserver.install_http_handler(handler): if not gdal.Sync( '/vsimem/testsync.txt', '/vsis3/out/testsync.txt', options=options): - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/testsync.txt') @@ -2341,13 +2187,11 @@ def test_vsis3_read_credentials_file(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2390,13 +2234,11 @@ def test_vsis3_read_config_file(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2452,13 +2294,11 @@ def test_vsis3_read_credentials_config_file(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2516,13 +2356,11 @@ def test_vsis3_read_credentials_config_file_non_default(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2583,17 +2421,14 @@ def test_vsis3_read_credentials_config_file_inconsistent(): with gdaltest.error_handler(): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': # Expected 'aws_access_key_id defined in both /vsimem/aws_credentials and /vsimem/aws_config' - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2640,13 +2475,11 @@ def test_vsis3_read_credentials_ec2(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2658,13 +2491,11 @@ def test_vsis3_read_credentials_ec2(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'bar': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2710,13 +2541,11 @@ def test_vsis3_read_credentials_ec2_expiration(): with webserver.install_http_handler(handler): f = open_for_read('/vsis3/s3_fake_bucket/resource') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2726,7 +2555,6 @@ def test_vsis3_read_credentials_ec2_expiration(): with gdaltest.error_handler(): f = open_for_read('/vsis3/s3_fake_bucket/bar') if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('CPL_AWS_EC2_CREDENTIALS_URL', '') @@ -2780,20 +2608,17 @@ def vsis3_extra_1(): path = '/vsis3/' + s3_resource statres = gdal.VSIStatL(path) if statres is None or not stat.S_ISDIR(statres.mode): - gdaltest.post_reason('fail') print('%s is not a valid bucket' % path) return 'fail' readdir = gdal.ReadDir(path) if readdir is None: - gdaltest.post_reason('fail') print('ReadDir() should not return empty list') return 'fail' for filename in readdir: if filename != '.': subpath = path + '/' + filename if gdal.VSIStatL(subpath) is None: - gdaltest.post_reason('fail') print('Stat(%s) should not return an error' % subpath) return 'fail' @@ -2801,81 +2626,68 @@ def vsis3_extra_1(): subpath = path + '/' + unique_id ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id not in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret == 0: - gdaltest.post_reason('fail') print('Mkdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should not contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, f) gdal.VSIFCloseL(f) ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) on non empty directory should return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 5, f).decode('utf-8') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' gdal.VSIFCloseL(f) ret = gdal.Unlink(subpath + '/test.txt') if ret < 0: - gdaltest.post_reason('fail') print('Unlink(%s) should not return an error' % (subpath + '/test.txt')) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' @@ -2883,27 +2695,23 @@ def vsis3_extra_1(): f = open_for_read('/vsis3/' + s3_resource) if f is None: - gdaltest.post_reason('fail') print('cannot open %s' % ('/vsis3/' + s3_resource)) return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' # Same with /vsis3_streaming/ f = open_for_read('/vsis3_streaming/' + s3_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -2916,7 +2724,6 @@ def vsis3_extra_1(): gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if gdal.VSIGetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -2924,7 +2731,6 @@ def vsis3_extra_1(): gdal.ErrorReset() f = open_for_read('/vsis3_streaming/' + gdal.GetConfigOption('S3_RESOURCE') + '/invalid_resource.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -2932,13 +2738,11 @@ def vsis3_extra_1(): signed_url = gdal.GetSignedURL('/vsis3/' + s3_resource) f = open_for_read('/vsicurl_streaming/' + signed_url) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' diff --git a/autotest/gcore/vsistdin.py b/autotest/gcore/vsistdin.py index 6a9c0fe7ef59..be4e7d88f767 100755 --- a/autotest/gcore/vsistdin.py +++ b/autotest/gcore/vsistdin.py @@ -57,10 +57,8 @@ def test_vsistdin_1(): ds = gdal.Open("tmp/vsistdin_1_out.tif") if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != cs: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink("tmp/vsistdin_1_out.tif") diff --git a/autotest/gcore/vsiswift.py b/autotest/gcore/vsiswift.py index 6c0cb2370f99..31f7126d3705 100644 --- a/autotest/gcore/vsiswift.py +++ b/autotest/gcore/vsiswift.py @@ -71,7 +71,6 @@ def test_vsiswift_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_STORAGE_URL') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -79,7 +78,6 @@ def test_vsiswift_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiswift_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_STORAGE_URL') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -90,7 +88,6 @@ def test_vsiswift_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_AUTH_TOKEN') < 0: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -102,7 +99,6 @@ def test_vsiswift_real_server_errors(): if f is not None: if f is not None: gdal.VSIFCloseL(f) - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -110,7 +106,6 @@ def test_vsiswift_real_server_errors(): with gdaltest.error_handler(): f = open_for_read('/vsiswift_streaming/foo/bar.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' @@ -190,13 +185,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsiswift/foo/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -223,13 +216,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsiswift/foo/baz') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'bar': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -257,7 +248,6 @@ def test_vsiswift_fake_auth_storage_url_and_auth_token(): with webserver.install_http_handler(handler): f = open_for_read('/vsiswift/foo/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) @@ -286,13 +276,11 @@ def method(request): with webserver.install_http_handler(handler): f = open_for_read('/vsiswift/foo/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f).decode('ascii') gdal.VSIFCloseL(f) if data != 'foo': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -315,7 +303,6 @@ def test_vsiswift_stat(): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsiswift/foo/bar') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -327,7 +314,6 @@ def test_vsiswift_stat(): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsiswift_streaming/foo/bar') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -342,7 +328,6 @@ def test_vsiswift_stat(): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL('/vsiswift/foo') if stat_res is None or not stat.S_ISDIR(stat_res.mode): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -386,28 +371,23 @@ def test_vsiswift_fake_readdir(): with webserver.install_http_handler(handler): f = open_for_read('/vsiswift/foo/bar.baz') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) dir_contents = gdal.ReadDir('/vsiswift/foo') if dir_contents != ['bar.baz', 'mysubdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' stat_res = gdal.VSIStatL('/vsiswift/foo/bar.baz') if stat_res.size != 123456: - gdaltest.post_reason('fail') print(stat_res.size) return 'fail' if stat_res.mtime != 1: - gdaltest.post_reason('fail') return 'fail' # ReadDir on something known to be a file shouldn't cause network access dir_contents = gdal.ReadDir('/vsiswift/foo/bar.baz') if dir_contents is not None: - gdaltest.post_reason('fail') return 'fail' # Test error on ReadDir() @@ -416,7 +396,6 @@ def test_vsiswift_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiswift/foo/error_test/') if dir_contents is not None: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -428,7 +407,6 @@ def test_vsiswift_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiswift/') if dir_contents != ['.']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -443,7 +421,6 @@ def test_vsiswift_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiswift/') if dir_contents != ['mycontainer1', 'mycontainer2']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -461,7 +438,6 @@ def test_vsiswift_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiswift/') if dir_contents != ['foo', 'foo/']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -471,7 +447,6 @@ def test_vsiswift_fake_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir('/vsiswift/foo/') if dir_contents != ['.']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -491,7 +466,6 @@ def test_vsiswift_fake_write(): # Test creation of BlockBob f = gdal.VSIFOpenL('/vsiswift/test_copy/file.bin', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -529,7 +503,6 @@ def method(request): ret = gdal.VSIFWriteL('x' * 35000, 1, 35000, f) ret += gdal.VSIFWriteL('x' * 5000, 1, 5000, f) if ret != 40000: - gdaltest.post_reason('fail') print(ret) gdal.VSIFCloseL(f) return 'fail' @@ -556,7 +529,6 @@ def test_vsiswift_fake_unlink(): with webserver.install_http_handler(handler): ret = gdal.Unlink('/vsiswift/foo/bar') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Failure @@ -568,7 +540,6 @@ def test_vsiswift_fake_unlink(): with gdaltest.error_handler(): ret = gdal.Unlink('/vsiswift/foo/bar') if ret != -1: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -587,7 +558,6 @@ def test_vsiswift_fake_mkdir_rmdir(): # Invalid name ret = gdal.Mkdir('/vsiswift', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -597,7 +567,6 @@ def test_vsiswift_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsiswift/foo/dir', 0) if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try creating already existing directory @@ -610,13 +579,11 @@ def test_vsiswift_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Mkdir('/vsiswift/foo/dir', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Invalid name ret = gdal.Rmdir('/vsiswift') if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -631,7 +598,6 @@ def test_vsiswift_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiswift/foo/it_is_a_file') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Valid @@ -646,7 +612,6 @@ def test_vsiswift_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiswift/foo/dir') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Try deleting already deleted directory @@ -656,7 +621,6 @@ def test_vsiswift_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiswift/foo/dir') if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -675,7 +639,6 @@ def test_vsiswift_fake_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir('/vsiswift/foo/dir_nonempty') if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -714,20 +677,17 @@ def vsiswift_extra_1(): path = '/vsiswift/' + swift_resource statres = gdal.VSIStatL(path) if statres is None or not stat.S_ISDIR(statres.mode): - gdaltest.post_reason('fail') print('%s is not a valid bucket' % path) return 'fail' readdir = gdal.ReadDir(path) if readdir is None: - gdaltest.post_reason('fail') print('ReadDir() should not return empty list') return 'fail' for filename in readdir: if filename != '.': subpath = path + '/' + filename if gdal.VSIStatL(subpath) is None: - gdaltest.post_reason('fail') print('Stat(%s) should not return an error' % subpath) return 'fail' @@ -735,81 +695,68 @@ def vsiswift_extra_1(): subpath = path + '/' + unique_id ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id not in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret == 0: - gdaltest.post_reason('fail') print('Mkdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should not contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, f) gdal.VSIFCloseL(f) ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) on non empty directory should return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 5, f).decode('utf-8') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' gdal.VSIFCloseL(f) ret = gdal.Unlink(subpath + '/test.txt') if ret < 0: - gdaltest.post_reason('fail') print('Unlink(%s) should not return an error' % (subpath + '/test.txt')) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' @@ -817,26 +764,22 @@ def vsiswift_extra_1(): f = open_for_read('/vsiswift/' + swift_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' # Same with /vsiswift_streaming/ f = open_for_read('/vsiswift_streaming/' + swift_resource) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -844,7 +787,6 @@ def vsiswift_extra_1(): gdal.ErrorReset() f = open_for_read('/vsiswift_streaming/' + swift_resource + '/invalid_resource.baz') if f is not None: - gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' diff --git a/autotest/gcore/vsiwebhdfs.py b/autotest/gcore/vsiwebhdfs.py index ea79f7677366..bfa0fb4a3741 100644 --- a/autotest/gcore/vsiwebhdfs.py +++ b/autotest/gcore/vsiwebhdfs.py @@ -97,11 +97,9 @@ def test_vsiwebhdfs_open(): with webserver.install_http_handler(handler): f = open_for_read(gdaltest.webhdfs_base_connection + '/foo/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFSeekL(f, 9999990784 + 10, 0) if gdal.VSIFReadL(1, 4, f).decode('ascii') != 'data': - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -120,10 +118,8 @@ def test_vsiwebhdfs_open(): with webserver.install_http_handler(handler): f = open_for_read(gdaltest.webhdfs_base_connection + '/foo/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFReadL(1, 4, f).decode('ascii') != 'yeah': - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -133,19 +129,16 @@ def test_vsiwebhdfs_open(): f = open_for_read(gdaltest.webhdfs_base_connection + '/foo/bar') if f is None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() handler.add('GET', '/webhdfs/v1/foo/bar?op=OPEN&offset=0&length=16384', 404) with webserver.install_http_handler(handler): if len(gdal.VSIFReadL(1, 4, f)) != 0: - gdaltest.post_reason('fail') return 'fail' # Retry: shouldn't not cause network access if len(gdal.VSIFReadL(1, 4, f)) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) @@ -169,7 +162,6 @@ def test_vsiwebhdfs_stat(): with webserver.install_http_handler(handler): stat_res = gdal.VSIStatL(gdaltest.webhdfs_base_connection + '/foo/bar') if stat_res is None or stat_res.size != 1000000: - gdaltest.post_reason('fail') if stat_res is not None: print(stat_res.size) else: @@ -179,7 +171,6 @@ def test_vsiwebhdfs_stat(): # Test caching stat_res = gdal.VSIStatL(gdaltest.webhdfs_base_connection + '/foo/bar') if stat_res.size != 1000000: - gdaltest.post_reason('fail') return 'fail' # Test missing file @@ -190,7 +181,6 @@ def test_vsiwebhdfs_stat(): stat_res = gdal.VSIStatL( gdaltest.webhdfs_base_connection + '/unexisting') if stat_res is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -212,23 +202,19 @@ def test_vsiwebhdfs_readdir(): with webserver.install_http_handler(handler): dir_contents = gdal.ReadDir(gdaltest.webhdfs_base_connection + '/foo') if dir_contents != ['bar.baz', 'mysubdir']: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' stat_res = gdal.VSIStatL(gdaltest.webhdfs_base_connection + '/foo/bar.baz') if stat_res.size != 123456: - gdaltest.post_reason('fail') print(stat_res.size) return 'fail' if stat_res.mtime != 1: - gdaltest.post_reason('fail') return 'fail' # ReadDir on something known to be a file shouldn't cause network access dir_contents = gdal.ReadDir( gdaltest.webhdfs_base_connection + '/foo/bar.baz') if dir_contents is not None: - gdaltest.post_reason('fail') return 'fail' # Test error on ReadDir() @@ -238,7 +224,6 @@ def test_vsiwebhdfs_readdir(): dir_contents = gdal.ReadDir( gdaltest.webhdfs_base_connection + 'foo/error_test/') if dir_contents is not None: - gdaltest.post_reason('fail') print(dir_contents) return 'fail' @@ -263,7 +248,6 @@ def test_vsiwebhdfs_write(): f = gdal.VSIFOpenL( gdaltest.webhdfs_base_connection + '/foo/bar', 'wb') if f is not None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -277,10 +261,8 @@ def test_vsiwebhdfs_write(): f = gdal.VSIFOpenL( gdaltest.webhdfs_base_connection + '/foo/bar', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFCloseL(f) != 0: - gdaltest.post_reason('fail') return 'fail' # Non-empty file @@ -298,11 +280,9 @@ def test_vsiwebhdfs_write(): f = gdal.VSIFOpenL( gdaltest.webhdfs_base_connection + '/foo/bar', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('foobar', 1, 6, f) != 6: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -328,7 +308,6 @@ def method(request): with webserver.install_http_handler(handler): if gdal.VSIFCloseL(f) != 0: - gdaltest.post_reason('fail') return 'fail' # Errors during file creation @@ -344,7 +323,6 @@ def method(request): f = gdal.VSIFOpenL( gdaltest.webhdfs_base_connection + '/foo/bar', 'wb') if f is not None: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -356,7 +334,6 @@ def method(request): f = gdal.VSIFOpenL( gdaltest.webhdfs_base_connection + '/foo/bar', 'wb') if f is not None: - gdaltest.post_reason('fail') return 'fail' # Errors during POST @@ -374,11 +351,9 @@ def method(request): f = gdal.VSIFOpenL( gdaltest.webhdfs_base_connection + '/foo/bar', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIFWriteL('foobar', 1, 6, f) != 6: - gdaltest.post_reason('fail') return 'fail' handler = webserver.SequentialHandler() @@ -390,7 +365,6 @@ def method(request): with gdaltest.error_handler(): with webserver.install_http_handler(handler): if gdal.VSIFCloseL(f) == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -413,7 +387,6 @@ def test_vsiwebhdfs_unlink(): with webserver.install_http_handler(handler): ret = gdal.Unlink(gdaltest.webhdfs_base_connection + '/foo/bar') if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -431,7 +404,6 @@ def test_vsiwebhdfs_unlink(): with webserver.install_http_handler(handler): ret = gdal.Unlink(gdaltest.webhdfs_base_connection + '/foo/bar') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Failure @@ -442,7 +414,6 @@ def test_vsiwebhdfs_unlink(): with gdaltest.error_handler(): ret = gdal.Unlink(gdaltest.webhdfs_base_connection + '/foo/bar') if ret != -1: - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -455,7 +426,6 @@ def test_vsiwebhdfs_unlink(): with gdaltest.error_handler(): ret = gdal.Unlink(gdaltest.webhdfs_base_connection + '/foo/bar') if ret != -1: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -474,7 +444,6 @@ def test_vsiwebhdfs_mkdir_rmdir(): # Invalid name ret = gdal.Mkdir('/vsiwebhdfs', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Valid @@ -484,7 +453,6 @@ def test_vsiwebhdfs_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Mkdir(gdaltest.webhdfs_base_connection + '/foo/dir', 0) if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Valid with all options @@ -496,7 +464,6 @@ def test_vsiwebhdfs_mkdir_rmdir(): ret = gdal.Mkdir(gdaltest.webhdfs_base_connection + '/foo/dir/', 493) # 0755 if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Error @@ -506,19 +473,16 @@ def test_vsiwebhdfs_mkdir_rmdir(): ret = gdal.Mkdir(gdaltest.webhdfs_base_connection + '/foo/dir_error', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Root name is invalid ret = gdal.Mkdir(gdaltest.webhdfs_base_connection + '/', 0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Invalid name ret = gdal.Rmdir('/vsiwebhdfs') if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.VSICurlClearCache() @@ -530,7 +494,6 @@ def test_vsiwebhdfs_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir(gdaltest.webhdfs_base_connection + '/foo/dir') if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Error @@ -539,7 +502,6 @@ def test_vsiwebhdfs_mkdir_rmdir(): with webserver.install_http_handler(handler): ret = gdal.Rmdir(gdaltest.webhdfs_base_connection + '/foo/dir_error') if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -578,20 +540,17 @@ def vsiwebhdfs_extra_1(): path = '/vsiwebhdfs/' + webhdfs_url statres = gdal.VSIStatL(path) if statres is None or not stat.S_ISDIR(statres.mode): - gdaltest.post_reason('fail') print('%s is not a valid bucket' % path) return 'fail' readdir = gdal.ReadDir(path) if readdir is None: - gdaltest.post_reason('fail') print('ReadDir() should not return empty list') return 'fail' for filename in readdir: if filename != '.': subpath = path + '/' + filename if gdal.VSIStatL(subpath) is None: - gdaltest.post_reason('fail') print('Stat(%s) should not return an error' % subpath) return 'fail' @@ -599,13 +558,11 @@ def vsiwebhdfs_extra_1(): subpath = path + '/' + unique_id ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id not in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should contain %s' % (path, unique_id)) print(readdir) return 'fail' @@ -618,63 +575,53 @@ def vsiwebhdfs_extra_1(): ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' readdir = gdal.ReadDir(path) if unique_id in readdir: - gdaltest.post_reason('fail') print('ReadDir(%s) should not contain %s' % (path, unique_id)) print(readdir) return 'fail' ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) repeated should return an error' % subpath) return 'fail' ret = gdal.Mkdir(subpath, 0) if ret < 0: - gdaltest.post_reason('fail') print('Mkdir(%s) should not return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'wb') if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL('hello', 1, 5, f) gdal.VSIFCloseL(f) ret = gdal.Rmdir(subpath) if ret == 0: - gdaltest.post_reason('fail') print('Rmdir(%s) on non empty directory should return an error' % subpath) return 'fail' f = gdal.VSIFOpenL(subpath + '/test.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 5, f).decode('utf-8') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' gdal.VSIFCloseL(f) ret = gdal.Unlink(subpath + '/test.txt') if ret < 0: - gdaltest.post_reason('fail') print('Unlink(%s) should not return an error' % (subpath + '/test.txt')) return 'fail' ret = gdal.Rmdir(subpath) if ret < 0: - gdaltest.post_reason('fail') print('Rmdir(%s) should not return an error' % subpath) return 'fail' @@ -682,13 +629,11 @@ def vsiwebhdfs_extra_1(): f = open_for_read('/vsiwebhdfs/' + webhdfs_url) if f is None: - gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: - gdaltest.post_reason('fail') print(ret) return 'fail' diff --git a/autotest/gcore/vsizip.py b/autotest/gcore/vsizip.py index 81863b6cf737..7755e334ff57 100755 --- a/autotest/gcore/vsizip.py +++ b/autotest/gcore/vsizip.py @@ -123,7 +123,6 @@ def test_vsizip_1(): gdal.VSIFCloseL(f) if data.decode('ASCII') != 'abcd': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -131,51 +130,43 @@ def test_vsizip_1(): gdal.Rename("/vsimem/test.zip", "/vsimem/test.xxx") f = gdal.VSIFOpenL("/vsizip/{/vsimem/test.xxx}/subdir3/abcd", "rb") if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f) gdal.VSIFCloseL(f) if data.decode('ASCII') != 'abcd': - gdaltest.post_reason('fail') print(data) return 'fail' # With a trailing slash f = gdal.VSIFOpenL("/vsizip/{/vsimem/test.xxx}/subdir3/abcd/", "rb") if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(f) # Test ReadDir() if len(gdal.ReadDir("/vsizip/{/vsimem/test.xxx}")) != 3: - gdaltest.post_reason('fail') print(gdal.ReadDir("/vsizip/{/vsimem/test.xxx}")) return 'fail' # Unbalanced curls f = gdal.VSIFOpenL("/vsizip/{/vsimem/test.xxx", "rb") if f is not None: - gdaltest.post_reason('fail') return 'fail' # Non existing mainfile f = gdal.VSIFOpenL("/vsizip/{/vsimem/test.xxx}/bla", "rb") if f is not None: - gdaltest.post_reason('fail') return 'fail' # Non existing subfile f = gdal.VSIFOpenL("/vsizip/{/vsimem/test.zzz}/bla", "rb") if f is not None: - gdaltest.post_reason('fail') return 'fail' # Wrong syntax f = gdal.VSIFOpenL("/vsizip/{/vsimem/test.xxx}.aux.xml", "rb") if f is not None: - gdaltest.post_reason('fail') return 'fail' # Test nested { { } } @@ -193,13 +184,11 @@ def test_vsizip_1(): f = gdal.VSIFOpenL("/vsizip/{/vsizip/{/vsimem/zipinzip.yyy}/test.xxx}/subdir3/abcd/", "rb") if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 4, f) gdal.VSIFCloseL(f) if data.decode('ASCII') != 'abcd': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -208,12 +197,10 @@ def test_vsizip_1(): # Test VSIStatL on a non existing file if gdal.VSIStatL('/vsizip//vsimem/foo.zip') is not None: - gdaltest.post_reason('fail') return 'fail' # Test ReadDir on a non existing file if gdal.ReadDir('/vsizip//vsimem/foo.zip') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -355,13 +342,11 @@ def test_vsizip_5(): # make file in memory fmain = gdal.VSIFOpenL('/vsizip/vsimem/bigdepthzip.zip', 'wb') if fmain is None: - gdaltest.post_reason('fail') return 'fail' filename = "a" + "/a" * 1000 finside = gdal.VSIFOpenL('/vsizip/vsimem/bigdepthzip.zip/' + filename, 'wb') if finside is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFCloseL(finside) gdal.VSIFCloseL(fmain) @@ -392,7 +377,6 @@ def test_vsizip_6(): fmain = gdal.VSIFOpenL("/vsizip/vsimem/test6.zip", "wb") f = gdal.VSIFOpenL("/vsizip/vsimem/test6.zip/foo.bar", "wb") if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL("12345", 1, 5, f) gdal.VSIFCloseL(f) @@ -402,7 +386,6 @@ def test_vsizip_6(): f = gdal.VSIFOpenL("/vsizip/vsimem/test6.zip/foo.bar", "wb") gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' gdal.VSIFCloseL(fmain) @@ -413,7 +396,6 @@ def test_vsizip_6(): # Now close it each time f = gdal.VSIFOpenL("/vsizip/vsimem/test6.zip/foo.bar", "wb") if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.VSIFWriteL("12345", 1, 5, f) gdal.VSIFCloseL(f) @@ -423,7 +405,6 @@ def test_vsizip_6(): f = gdal.VSIFOpenL("/vsizip/vsimem/test6.zip/foo.bar", "wb") gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') gdal.VSIFCloseL(f) return 'fail' @@ -472,11 +453,9 @@ def test_vsizip_8(): def test_vsizip_9(): if gdal.VSIStatL('/vsizip//vsisparse/data/zero_stored.bin.xml.zip/zero.bin').size != 5000 * 1000 * 1000 + 1: - gdaltest.post_reason('fail') return 'fail' if gdal.VSIStatL('/vsizip//vsisparse/data/zero_stored.bin.xml.zip/hello.txt').size != 6: - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsizip//vsisparse/data/zero_stored.bin.xml.zip/zero.bin', 'rb') @@ -484,7 +463,6 @@ def test_vsizip_9(): data = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if data.decode('ascii') != '\x03': - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsizip//vsisparse/data/zero_stored.bin.xml.zip/hello.txt', 'rb') @@ -492,7 +470,6 @@ def test_vsizip_9(): gdal.VSIFCloseL(f) if data.decode('ascii') != 'HELLO\n': print(data) - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -595,7 +572,6 @@ def test_vsizip_12(): gdal.Unlink('/vsimem/vsizip_12.zip') if content != ['bar.baz']: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -615,12 +591,10 @@ def test_vsizip_13(): lst = gdal.ReadDir('/vsizip/vsimem/vsizip_13.zip') if len(lst) < 4: - gdaltest.post_reason('fail') return 'fail' # Test truncation lst_truncated = gdal.ReadDir('/vsizip/vsimem/vsizip_13.zip', int(len(lst) / 2)) if len(lst_truncated) <= int(len(lst) / 2): - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/vsizip_13.zip') @@ -684,8 +658,6 @@ def test_vsizip_multi_thread(): gdal.Unlink('/vsimem/vsizip_multi_thread.zip') if data != 'hello' * 100000: - gdaltest.post_reason('fail') - for i in range(10000): if data[i*5:i*5+5] != 'hello': print(i*5, data[i*5:i*5+5], data[i*5-5:i*5+5-5]) @@ -715,7 +687,6 @@ def test_vsizip_multi_thread_below_threshold(): gdal.Unlink('/vsimem/vsizip_multi_thread.zip') if data != 'hello': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -744,13 +715,11 @@ def test_vsizip_create_zip64(): size = gdal.VSIStatL(zip_name).size if size > 0xFFFFFFFF: - gdaltest.post_reason('fail') print(size) return 'fail' size = gdal.VSIStatL('/vsizip/' + zip_name + '/test').size if size != len(s) * niters: - gdaltest.post_reason('fail') print(size) return 'fail' @@ -758,7 +727,6 @@ def test_vsizip_create_zip64(): data = gdal.VSIFReadL(1, len(s), f).decode('ascii') gdal.VSIFCloseL(f) if data != s: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(zip_name) @@ -788,13 +756,11 @@ def test_vsizip_create_zip64_stream_larger_than_4G(): size = gdal.VSIStatL(zip_name).size if size <= 0xFFFFFFFF: - gdaltest.post_reason('fail') print(size) return 'fail' size = gdal.VSIStatL('/vsizip/' + zip_name + '/test2').size if size != len(s) * niters: - gdaltest.post_reason('fail') print(size) return 'fail' @@ -802,7 +768,6 @@ def test_vsizip_create_zip64_stream_larger_than_4G(): data = gdal.VSIFReadL(1, len(s), f).decode('ascii') gdal.VSIFCloseL(f) if data != s: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(zip_name) @@ -815,7 +780,6 @@ def test_vsizip_byte_zip64_local_header_zeroed(): size = gdal.VSIStatL('/vsizip/data/byte_zip64_local_header_zeroed.zip/byte.tif').size if size != 736: - gdaltest.post_reason('fail') print(size) return 'fail' diff --git a/autotest/gdrivers/aaigrid.py b/autotest/gdrivers/aaigrid.py index 89ee33e4c603..f3e23a10948c 100755 --- a/autotest/gdrivers/aaigrid.py +++ b/autotest/gdrivers/aaigrid.py @@ -328,11 +328,9 @@ def test_aaigrid_12(): aai.close() gdal.GetDriverByName('AAIGRID').Delete('tmp/aaigrid.tmp') if not ndv.startswith('nodata_value'): - gdaltest.post_reason('fail') print(ndv) return 'fail' if not ndv.endswith('-99999.000'): - gdaltest.post_reason('fail') print(ndv) return 'fail' return 'success' @@ -357,11 +355,9 @@ def test_aaigrid_13(): aai.close() gdal.GetDriverByName('AAIGRID').Delete('tmp/aaigrid.tmp') if not ndv.startswith('nodata_value'): - gdaltest.post_reason('fail') print(ndv) return 'fail' if not ndv.endswith('-1e+05') and not ndv.endswith('-1e+005'): - gdaltest.post_reason('fail') print(ndv) return 'fail' return 'success' @@ -385,7 +381,6 @@ def test_aaigrid_14(): gdal.GetDriverByName('AAIGRID').Delete('/vsimem/aaigrid_14.asc') if data.find('107.0 123') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -408,7 +403,6 @@ def test_aaigrid_15(): ds = gdal.Open('/vsimem/aaigrid_15.asc') if ds.GetRasterBand(1).DataType != gdal.GDT_Float64: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index cbc4878692e4..f2a190c6d4f1 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -206,7 +206,6 @@ def test_bag_vr_normal(): for key in expected_md: if key not in got_md or got_md[key] != expected_md[key]: - gdaltest.post_reason('fail') print(key) import pprint pp = pprint.PrettyPrinter() @@ -222,7 +221,6 @@ def test_bag_vr_normal(): got_md2 = gdal.Info(ds, computeChecksum=True, format='json') if got_md2 != got_md: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -238,17 +236,14 @@ def test_bag_vr_list_supergrids(): ds = gdal.OpenEx('data/test_vr.bag', open_options=['MODE=LIST_SUPERGRIDS']) if ds is None: - gdaltest.post_reason('fail') return 'fail' sub_ds = ds.GetSubDatasets() if len(sub_ds) != 24: - gdaltest.post_reason('fail') print(len(sub_ds)) print(sub_ds) return 'fail' if sub_ds[0][0] != 'BAG:"data/test_vr.bag":supergrid:0:0': - gdaltest.post_reason('fail') print(sub_ds) return 'fail' @@ -259,7 +254,6 @@ def test_bag_vr_list_supergrids(): open_options=['MODE=LIST_SUPERGRIDS', 'MINX=200']) sub_ds = ds.GetSubDatasets() if len(sub_ds) != 24: - gdaltest.post_reason('fail') print(len(sub_ds)) print(sub_ds) return 'fail' @@ -268,12 +262,10 @@ def test_bag_vr_list_supergrids(): 'MODE=LIST_SUPERGRIDS', 'MINX=100', 'MAXX=220', 'MINY=500000', 'MAXY=500100']) sub_ds = ds.GetSubDatasets() if len(sub_ds) != 6: - gdaltest.post_reason('fail') print(len(sub_ds)) print(sub_ds) return 'fail' if sub_ds[0][0] != 'BAG:"data/test_vr.bag":supergrid:1:1': - gdaltest.post_reason('fail') print(sub_ds) return 'fail' @@ -281,12 +273,10 @@ def test_bag_vr_list_supergrids(): 'MODE=LIST_SUPERGRIDS', 'RES_FILTER_MIN=5', 'RES_FILTER_MAX=10']) sub_ds = ds.GetSubDatasets() if len(sub_ds) != 12: - gdaltest.post_reason('fail') print(len(sub_ds)) print(sub_ds) return 'fail' if sub_ds[0][0] != 'BAG:"data/test_vr.bag":supergrid:0:3': - gdaltest.post_reason('fail') print(sub_ds) return 'fail' @@ -294,13 +284,11 @@ def test_bag_vr_list_supergrids(): 'SUPERGRIDS_INDICES=(2,1),(3,4)']) sub_ds = ds.GetSubDatasets() if len(sub_ds) != 2: - gdaltest.post_reason('fail') print(len(sub_ds)) print(sub_ds) return 'fail' if sub_ds[0][0] != 'BAG:"data/test_vr.bag":supergrid:2:1' or \ sub_ds[1][0] != 'BAG:"data/test_vr.bag":supergrid:3:4': - gdaltest.post_reason('fail') print(sub_ds) return 'fail' @@ -309,7 +297,6 @@ def test_bag_vr_list_supergrids(): 'SUPERGRIDS_INDICES=(2,1)']) ds2 = gdal.Open('BAG:"data/test_vr.bag":supergrid:2:1') if gdal.Info(ds) != gdal.Info(ds2): - gdaltest.post_reason('fail') print(sub_ds) return 'fail' @@ -320,7 +307,6 @@ def test_bag_vr_list_supergrids(): ds = gdal.OpenEx('data/test_vr.bag', open_options=[ 'SUPERGRIDS_INDICES=' + invalid_val]) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') print(invalid_val) return 'fail' @@ -337,7 +323,6 @@ def test_bag_vr_open_supergrids(): ds = gdal.Open('BAG:"data/test_vr.bag":supergrid:0:0') if ds is None: - gdaltest.post_reason('fail') return 'fail' got_md = gdal.Info(ds, computeChecksum=True, format='json') @@ -375,7 +360,6 @@ def test_bag_vr_open_supergrids(): for key in expected_md: if key not in got_md or got_md[key] != expected_md[key]: - gdaltest.post_reason('fail') print(key) import pprint pp = pprint.PrettyPrinter() @@ -385,19 +369,16 @@ def test_bag_vr_open_supergrids(): with gdaltest.error_handler(): ds = gdal.Open('BAG:"/vsimem/unexisting.bag":supergrid:0:0') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('BAG:"data/test_vr.bag":supergrid:4:0') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('BAG:"data/test_vr.bag":supergrid:0:6') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): @@ -420,7 +401,6 @@ def test_bag_vr_resampled(): ds = gdal.OpenEx('data/test_vr.bag', open_options=['MODE=RESAMPLED_GRID']) if ds is None: - gdaltest.post_reason('fail') return 'fail' got_md = gdal.Info(ds, computeChecksum=True, format='json') @@ -462,7 +442,6 @@ def test_bag_vr_resampled(): for key in expected_md: if key not in got_md or got_md[key] != expected_md[key]: - gdaltest.post_reason('fail') print(key) import pprint pp = pprint.PrettyPrinter() @@ -477,14 +456,12 @@ def test_bag_vr_resampled(): ds = gdal.OpenEx('data/test_vr.bag', open_options=['MODE=RESAMPLED_GRID']) if ds.GetRasterBand(1).GetBlockSize() != [block_size, block_size]: - gdaltest.post_reason('fail') print(block_size) print(ds.GetRasterBand(1).GetBlockSize()) return 'fail' data = ds.ReadRaster() if data != data_ref: - gdaltest.post_reason('fail') print(block_size) return 'fail' @@ -493,39 +470,32 @@ def test_bag_vr_resampled(): ds = gdal.OpenEx('data/test_vr.bag', open_options=['MODE=RESAMPLED_GRID']) if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(2) is not None: - gdaltest.post_reason('fail') return 'fail' ovr = ds.GetRasterBand(1).GetOverview(0) cs = ovr.Checksum() if cs != 681: - gdaltest.post_reason('fail') print(cs) return 'fail' ovr = ds.GetRasterBand(2).GetOverview(0) cs = ovr.Checksum() if cs != 1344: - gdaltest.post_reason('fail') print(cs) return 'fail' ds.GetRasterBand(1).GetOverview(0).FlushCache() ds.GetRasterBand(1).GetOverview(1).FlushCache() cs = ovr.Checksum() if cs != 1344: - gdaltest.post_reason('fail') print(cs) return 'fail' ovr = ds.GetRasterBand(1).GetOverview(0) cs = ovr.Checksum() if cs != 681: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -535,7 +505,6 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[0], gt[3], ds.RasterXSize) if got != (90.0, 500112.0, 6): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -545,7 +514,6 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[3] + gt[5] * ds.RasterYSize, ds.RasterYSize) if got != (500000.0, 21): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -555,7 +523,6 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (5.0, -6.0): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -565,7 +532,6 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (4.983333110809326, -5.316666603088379): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -575,7 +541,6 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (29.899999618530273, -31.899999618530273): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -585,7 +550,6 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (12.209166447321573, -13.025833209355673): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -596,12 +560,10 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (8.0, -8.0): - gdaltest.post_reason('fail') print(got) return 'fail' got = (ds.GetRasterBand(1).Checksum(), ds.GetRasterBand(2).Checksum()) if got != (2099, 2747): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -611,12 +573,10 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (8.0, -8.0): - gdaltest.post_reason('fail') print(got) return 'fail' got = (ds.GetRasterBand(1).Checksum(), ds.GetRasterBand(2).Checksum()) if got != (2099, 2747): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -627,12 +587,10 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (16.0, -16.0): - gdaltest.post_reason('fail') print(got) return 'fail' got = (ds.GetRasterBand(1).Checksum(), ds.GetRasterBand(2).Checksum()) if got != (796, 864): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -643,12 +601,10 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (32.0, -32.0): - gdaltest.post_reason('fail') print(got) return 'fail' got = (ds.GetRasterBand(1).Checksum(), ds.GetRasterBand(2).Checksum()) if got != (207, 207): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -658,12 +614,10 @@ def test_bag_vr_resampled(): gt = ds.GetGeoTransform() got = (gt[1], gt[5]) if got != (29.899999618530273, -31.899999618530273): - gdaltest.post_reason('fail') print(got) return 'fail' got = (ds.GetRasterBand(1).Checksum(), ds.GetRasterBand(2).Checksum()) if got != (165, 205): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -673,7 +627,6 @@ def test_bag_vr_resampled(): open_options=['MODE=RESAMPLED_GRID', 'RES_FILTER_MIN=32']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Too small RES_FILTER_MAX @@ -682,7 +635,6 @@ def test_bag_vr_resampled(): open_options=['MODE=RESAMPLED_GRID', 'RES_FILTER_MAX=4']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # RES_FILTER_MIN >= RES_FILTER_MAX @@ -692,7 +644,6 @@ def test_bag_vr_resampled(): 'RES_FILTER_MIN=4', 'RES_FILTER_MAX=4']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Test VALUE_POPULATION @@ -720,7 +671,6 @@ def test_bag_vr_resampled(): m2_min, M2_min, mean2_min, _ = ds.GetRasterBand(2).ComputeStatistics(False) if mean1_min >= mean1_mean or mean1_mean >= mean1_max: - gdaltest.post_reason('fail') print(m1_max, M1_max, mean1_max) print(m2_max, M2_max, mean2_max) print(m1_mean, M1_mean, mean1_mean) @@ -731,7 +681,6 @@ def test_bag_vr_resampled(): if m2_min >= m2_max or \ (m2_mean, M2_mean, mean2_mean) != (m2_max, M2_max, mean2_max): - gdaltest.post_reason('fail') print(m1_max, M1_max, mean1_max) print(m2_max, M2_max, mean2_max) print(m1_mean, M1_mean, mean1_mean) @@ -755,20 +704,15 @@ def test_bag_vr_resampled_mask(): open_options=['MODE=RESAMPLED_GRID', 'SUPERGRIDS_MASK=YES']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).DataType != gdal.GDT_Byte: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 4507: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -788,7 +732,6 @@ def test_bag_vr_resampled_interpolated(): 'INTERPOLATION=INVDIST']) cs = ds.GetRasterBand(1).Checksum() if cs != 2175: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -797,7 +740,6 @@ def test_bag_vr_resampled_interpolated(): ds = gdal.OpenEx('data/test_vr.bag', open_options=['MODE=RESAMPLED_GRID']) if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' @@ -808,7 +750,6 @@ def test_bag_vr_resampled_interpolated(): 'SUPERGRIDS_MASK=YES', 'INTERPOLATION=INVDIST']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -847,11 +788,9 @@ def test_bag_write_two_bands(): ds = gdal.Open('/vsimem/out.bag') xml = ds.GetMetadata_List('xml:BAG')[0] if xml.find('') < 0: - gdaltest.post_reason('fail') print(xml) return 'fail' if xml.find('Generated by GDAL ') < 0: - gdaltest.post_reason('fail') print(xml) return 'fail' @@ -879,13 +818,11 @@ def test_bag_write_south_up(): # Check that it is presented as north-up cs = ds.GetRasterBand(1).Checksum() if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' gt = ds.GetGeoTransform() if gt != (440720.0, 60.0, 0.0, 3751320.0, 0.0, -60.0): - gdaltest.post_reason('fail') print(gt) return 'fail' diff --git a/autotest/gdrivers/cals.py b/autotest/gdrivers/cals.py index 2c1790f30dbd..def873922394 100755 --- a/autotest/gdrivers/cals.py +++ b/autotest/gdrivers/cals.py @@ -67,19 +67,14 @@ def test_cals_3(): tmp_ds.SetMetadataItem('TIFFTAG_YRESOLUTION', '600') out_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_2.cal', tmp_ds) if gdal.VSIStatL('/vsimem/cals_2.cal.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(1).Checksum() != 3883: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('PIXEL_PATH') is not None: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('TIFFTAG_XRESOLUTION') != '600': - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_PaletteIndex: - gdaltest.post_reason('fail') return 'fail' tmp_ds = None out_ds = None @@ -101,7 +96,6 @@ def test_cals_4(): out_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_4.cal', src_ds) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # 2 bands @@ -110,7 +104,6 @@ def test_cals_4(): out_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_4.cal', src_ds, strict=True) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # 1 band but not 1-bit @@ -119,7 +112,6 @@ def test_cals_4(): out_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_4.cal', src_ds, strict=True) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Dimension > 999999 @@ -129,7 +121,6 @@ def test_cals_4(): out_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_4.cal', src_ds, strict=True) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid output filename @@ -139,7 +130,6 @@ def test_cals_4(): out_ds = gdal.GetDriverByName('CALS').CreateCopy('/not_existing_dir/cals_4.cal', src_ds) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -156,13 +146,10 @@ def test_cals_5(): src_ds.SetMetadataItem('LINE_PROGRESSION', '270') out_ds = gdal.GetDriverByName('CALS').CreateCopy('/vsimem/cals_5.cal', src_ds) if gdal.VSIStatL('/vsimem/cals_5.cal.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('PIXEL_PATH') != '90': - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('LINE_PROGRESSION') != '270': - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/cals_5.cal') diff --git a/autotest/gdrivers/db2.py b/autotest/gdrivers/db2.py index 7648a34d109a..e74fe8d5a1b2 100755 --- a/autotest/gdrivers/db2.py +++ b/autotest/gdrivers/db2.py @@ -152,15 +152,12 @@ def check_tile_format(out_ds, expected_format, expected_band_count, expected_ct, expected_mime_type = 'image/x-webp' if mime_type != expected_mime_type: - gdaltest.post_reason('fail') print(mime_type) return 'fail' if band_count != expected_band_count: - gdaltest.post_reason('fail') print(band_count) return 'fail' if expected_ct != has_ct: - gdaltest.post_reason('fail') print(has_ct) return 'fail' return 'success' @@ -200,7 +197,6 @@ def test_gpkg_1(): got_gt = out_ds.GetGeoTransform() for i in range(6): if abs(expected_gt[i] - got_gt[i]) > 1e-8: - gdaltest.post_reason('fail') return 'fail' got_wkt = out_ds.GetProjectionRef() print("\n** expected_wkt " + expected_wkt + " **\n") @@ -209,12 +205,10 @@ def test_gpkg_1(): # the WKT (similar but different) # just check if it contains '11N' for NAD27 UTM zone 11N if got_wkt.find('11N') == -1: - gdaltest.post_reason('fail') return 'fail' expected_cs = [expected_cs, expected_cs, expected_cs, 4873] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' diff --git a/autotest/gdrivers/derived.py b/autotest/gdrivers/derived.py index a98946daf964..7310e1611611 100755 --- a/autotest/gdrivers/derived.py +++ b/autotest/gdrivers/derived.py @@ -40,7 +40,6 @@ def test_derived_test1(): gdal.ErrorReset() ds = gdal.Open(filename) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' got_dsds = ds.GetMetadata('DERIVED_SUBDATASETS') expected_gt = ds.GetGeoTransform() @@ -61,7 +60,6 @@ def test_derived_test1(): 'DERIVED_SUBDATASET_7_DESC': 'log10 of amplitude of input bands from ../gcore/data/cfloat64.tif'} if got_dsds != expected_dsds: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_dsds) return 'fail' @@ -71,17 +69,14 @@ def test_derived_test1(): if key.endswith('_NAME'): ds = gdal.Open(val) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' gt = ds.GetGeoTransform() if gt != expected_gt: - gdaltest.post_reason('fail') import pprint pprint.pprint("Expected geotransform: " + str(expected_gt) + ", got " + str(gt)) return 'fail' prj = ds.GetProjection() if prj != expected_prj: - gdaltest.post_reason('fail') import pprint pprint.pprint("Expected projection: " + str(expected_prj) + ", got: " + str(gt)) return 'fail' @@ -93,7 +88,6 @@ def test_derived_test2(): gdal.ErrorReset() ds = gdal.Open(filename) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' got_dsds = ds.GetMetadata('DERIVED_SUBDATASETS') expected_dsds = {'DERIVED_SUBDATASET_1_NAME': 'DERIVED_SUBDATASET:AMPLITUDE:../gcore/data/cint_sar.tif', @@ -120,7 +114,6 @@ def test_derived_test2(): 'DERIVED_SUBDATASET_7_NAME': 55} if got_dsds != expected_dsds: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_dsds) return 'fail' @@ -130,11 +123,9 @@ def test_derived_test2(): if key.endswith('_NAME'): ds = gdal.Open(val) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() if expected_cs[key] != cs: - gdaltest.post_reason('fail') import pprint pprint.pprint("Expected checksum " + str(expected_cs[key]) + ", got " + str(cs)) return 'fail' @@ -150,26 +141,22 @@ def test_derived_test3(): # Missing filename ds = gdal.Open('DERIVED_SUBDATASET:LOGAMPLITUDE') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('DERIVED_SUBDATASET:invalid_alg:../gcore/data/byte.tif') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('DERIVED_SUBDATASET:LOGAMPLITUDE:dataset_does_not_exist') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): # Raster with zero band ds = gdal.Open('DERIVED_SUBDATASET:LOGAMPLITUDE:data/CSK_DGM.h5') if ds is not None: - gdaltest.post_reason('fail') return 'fail' for function in ['real', 'imag', 'complex', 'mod', 'phase', 'conj', diff --git a/autotest/gdrivers/ecrgtoc.py b/autotest/gdrivers/ecrgtoc.py index ebd2e3929484..ee1c3a60edf7 100755 --- a/autotest/gdrivers/ecrgtoc.py +++ b/autotest/gdrivers/ecrgtoc.py @@ -171,20 +171,17 @@ def test_ecrgtoc_3(): ds = gdal.Open(name) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' # Legacy syntax ds = gdal.Open('ECRG_TOC_ENTRY:ProductTitle:DiscId:/vsimem/TOC.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('ECRG_TOC_ENTRY:ProductTitle:DiscId:1_500_K:/vsimem/TOC.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/ecw.py b/autotest/gdrivers/ecw.py index 4f932e51536a..6450976b6dbb 100755 --- a/autotest/gdrivers/ecw.py +++ b/autotest/gdrivers/ecw.py @@ -835,7 +835,6 @@ def test_ecw_24(): try: os.stat('tmp/spif83.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -846,7 +845,6 @@ def test_ecw_24(): for i in range(6): if abs(gt[i] - got_gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -891,7 +889,6 @@ def test_ecw_25(): try: os.stat('tmp/spif83.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -904,20 +901,16 @@ def test_ecw_25(): ds = None if got_proj != proj: - gdaltest.post_reason('fail') print(got_proj) return 'fail' if got_datum != datum: - gdaltest.post_reason('fail') print(got_datum) return 'fail' if got_units != units: - gdaltest.post_reason('fail') print(got_units) return 'fail' if wkt != got_wkt: - gdaltest.post_reason('fail') print(got_wkt) return 'fail' @@ -961,7 +954,6 @@ def test_ecw_26(): try: os.stat('tmp/spif83.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -974,15 +966,12 @@ def test_ecw_26(): ds = None if got_proj != proj: - gdaltest.post_reason('fail') print(proj) return 'fail' if got_datum != datum: - gdaltest.post_reason('fail') print(datum) return 'fail' if got_units != units: - gdaltest.post_reason('fail') print(units) return 'fail' @@ -991,7 +980,6 @@ def test_ecw_26(): wkt = sr.ExportToWkt() if wkt != got_wkt: - gdaltest.post_reason('fail') print(got_wkt) return 'fail' @@ -1212,7 +1200,6 @@ def test_ecw_32(): data_123 = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, band_list=[1, 2, 3]) data_321 = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, band_list=[3, 2, 1]) if data_123 == data_321: - gdaltest.post_reason('failure') return 'fail' vrt_ds = gdal.Open(""" @@ -1238,7 +1225,6 @@ def test_ecw_32(): data_vrt = vrt_ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, band_list=[1, 2, 3]) if data_321 != data_vrt: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1285,7 +1271,6 @@ def test_ecw_33(): ds = None if data1_1 != data1_2 or data2_1 != data2_2 or data3_1 != data3_2: - gdaltest.post_reason('fail') return 'fail' # When heuristics is ON, returned values should be the same as @@ -1294,7 +1279,6 @@ def test_ecw_33(): tab1 = struct.unpack('B' * 3 * 50 * 50, multiband_data) tab2 = struct.unpack('B' * 3 * 50 * 50, data1_1 + data2_1 + data3_2) if tab1 != tab2: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1331,13 +1315,10 @@ def test_ecw_33_bis(): # SDK such as 5.0) for i in range(50 * 50): if data1[i * 4] != data_ref[i]: - gdaltest.post_reason('fail') return 'fail' if data2[i * 4] != data_ref[50 * 50 + i]: - gdaltest.post_reason('fail') return 'fail' if data3[i * 4] != data_ref[2 * 50 * 50 + i]: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1591,7 +1572,6 @@ def test_ecw_40(): return 'skip' gdaltest.post_reason('explicit error message expected') return 'fail' - gdaltest.post_reason('fail') return 'fail' expected_md = [ @@ -1616,7 +1596,6 @@ def test_ecw_40(): got_md = ds.GetMetadata() for (key, value) in expected_md: if key not in got_md or got_md[key] != value: - gdaltest.post_reason('fail') print(key) print(got_md[key]) return 'fail' @@ -1625,7 +1604,6 @@ def test_ecw_40(): for i in range(4): got_cs = ds.GetRasterBand(i + 1).Checksum() if got_cs != expected_cs_list[i]: - gdaltest.post_reason('fail') print(expected_cs_list[i]) print(got_cs) return 'fail' @@ -1651,16 +1629,12 @@ def test_ecw_41(): # Check that no statistics is already included in the file if ds.GetRasterBand(1).GetMinimum() is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaximum() is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetStatistics(1, 0) != [0.0, 0.0, 0.0, -1.0]: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetDefaultHistogram(force=0) is not None: - gdaltest.post_reason('fail') return 'fail' # Now compute the stats @@ -1668,7 +1642,6 @@ def test_ecw_41(): expected_stats = [0.0, 255.0, 21.662427983539093, 51.789457392268119] for i in range(4): if abs(stats[i] - expected_stats[i]) > 1: - gdaltest.post_reason('fail') print(stats) print(expected_stats) return 'fail' @@ -1678,25 +1651,21 @@ def test_ecw_41(): # Check that there's no .aux.xml file try: os.stat('tmp/stefan_full_rgba_ecwv3_meta.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass ds = gdal.Open('tmp/stefan_full_rgba_ecwv3_meta.ecw') if ds.GetRasterBand(1).GetMinimum() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMinimum()) return 'fail' if ds.GetRasterBand(1).GetMaximum() != 255: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMaximum()) return 'fail' stats = ds.GetRasterBand(1).GetStatistics(0, 0) expected_stats = [0.0, 255.0, 21.662427983539093, 51.789457392268119] for i in range(4): if abs(stats[i] - expected_stats[i]) > 1: - gdaltest.post_reason('fail') print(stats[i]) print(expected_stats[i]) return 'fail' @@ -1707,7 +1676,6 @@ def test_ecw_41(): got_hist = ds.GetRasterBand(1).GetDefaultHistogram() expected_hist = (-0.5, 255.5, 256, [1006, 16106, 548, 99, 13, 24, 62, 118, 58, 125, 162, 180, 133, 146, 70, 81, 84, 97, 90, 60, 79, 70, 85, 77, 73, 63, 60, 64, 56, 69, 63, 73, 70, 72, 61, 66, 40, 52, 65, 44, 62, 54, 56, 55, 63, 51, 47, 39, 58, 44, 36, 43, 47, 45, 54, 28, 40, 41, 37, 36, 33, 31, 28, 34, 19, 32, 19, 23, 23, 33, 16, 34, 32, 54, 29, 33, 40, 37, 27, 34, 24, 29, 26, 21, 22, 24, 25, 19, 29, 22, 24, 14, 20, 20, 29, 28, 13, 19, 21, 19, 19, 21, 13, 19, 13, 14, 22, 15, 13, 26, 10, 13, 13, 14, 10, 17, 15, 19, 11, 18, 11, 14, 8, 12, 20, 12, 17, 10, 15, 15, 16, 14, 11, 7, 7, 10, 8, 12, 7, 8, 14, 7, 9, 12, 4, 6, 12, 5, 5, 4, 11, 8, 4, 8, 7, 10, 11, 6, 7, 5, 6, 8, 10, 10, 7, 5, 3, 5, 5, 6, 4, 10, 7, 6, 8, 4, 6, 6, 4, 6, 6, 7, 10, 4, 5, 2, 5, 6, 1, 1, 2, 6, 2, 1, 7, 4, 1, 3, 3, 2, 6, 2, 3, 3, 3, 3, 5, 5, 4, 2, 3, 2, 1, 3, 5, 5, 4, 1, 1, 2, 5, 10, 5, 9, 3, 5, 3, 5, 4, 5, 4, 4, 6, 7, 9, 17, 13, 15, 14, 13, 20, 18, 16, 27, 35, 53, 60, 51, 46, 40, 38, 50, 66, 36, 45, 13]) if got_hist != expected_hist: - gdaltest.post_reason('fail') print(got_hist) print(expected_hist) return 'fail' @@ -1721,16 +1689,13 @@ def test_ecw_41(): ds = gdal.Open('tmp/stefan_full_rgba_ecwv3_meta.ecw') if ds.GetRasterBand(1).GetMinimum() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMinimum()) return 'fail' if ds.GetRasterBand(1).GetMaximum() != 255: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMaximum()) return 'fail' got_hist = ds.GetRasterBand(1).GetDefaultHistogram(force=0) if got_hist != expected_hist: - gdaltest.post_reason('fail') print(got_hist) print(expected_hist) return 'fail' @@ -1739,7 +1704,6 @@ def test_ecw_41(): # Check that there's no .aux.xml file try: os.stat('tmp/stefan_full_rgba_ecwv3_meta.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -1779,7 +1743,6 @@ def test_ecw_42(): # Check that there's no .aux.xml file try: os.stat('tmp/stefan_full_rgba_ecwv3_meta.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -1789,7 +1752,6 @@ def test_ecw_42(): got_md = ds.GetMetadata() for item in md: if got_md[item] != md[item]: - gdaltest.post_reason('fail') print(got_md[item]) print(md[item]) return 'fail' @@ -1814,7 +1776,6 @@ def test_ecw_42(): # Check that there's no .aux.xml file try: os.stat('tmp/stefan_full_rgba_ecwv3_meta.ecw.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -1824,7 +1785,6 @@ def test_ecw_42(): got_md = ds.GetMetadata() for item in md: if item in got_md and item != 'FILE_METADATA_ACQUISITION_DATE': - gdaltest.post_reason('fail') print(got_md[item]) print(md[item]) return 'fail' @@ -1848,7 +1808,6 @@ def test_ecw_43(): return 'fail' got_cs = fourth_band.Checksum() if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' jp2_bands_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -1864,22 +1823,18 @@ def test_ecw_43(): tmp_ds = None gdal.GetDriverByName('GTiff').Delete('/vsimem/ecw_43.tif') if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' if jp2_bands_data != gtiff_bands_data: - gdaltest.post_reason('fail') return 'fail' if jp2_fourth_band_data != gtiff_fourth_band_data: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/stefan_full_rgba_alpha_1bit.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1920,7 +1875,6 @@ def test_ecw_44(): got_md = ds.GetMetadata('JPEG2000') for (key, value) in expected_md: if key not in got_md or got_md[key] != value: - gdaltest.post_reason('fail') print(key) print(got_md) return 'fail' @@ -1950,12 +1904,10 @@ def test_ecw_45(): out_ds = gdaltest.jp2ecw_drv.CreateCopy('/vsimem/ecw_45.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/ecw_45.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/ecw_45.jp2') md = RemoveDriverMetadata(ds.GetMetadata()) if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' gdal.Unlink('/vsimem/ecw_45.jp2') @@ -1967,12 +1919,10 @@ def test_ecw_45(): out_ds = gdaltest.jp2ecw_drv.CreateCopy('/vsimem/ecw_45.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/ecw_45.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/ecw_45.jp2') md = RemoveDriverMetadata(ds.GetMetadata()) if md != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') print(md) return 'fail' gdal.Unlink('/vsimem/ecw_45.jp2') @@ -1983,12 +1933,10 @@ def test_ecw_45(): out_ds = gdaltest.jp2ecw_drv.CreateCopy('/vsimem/ecw_45.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/ecw_45.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/ecw_45.jp2') md = RemoveDriverMetadata(ds.GetMetadata('SOME_DOMAIN')) if md != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') print(md) return 'fail' gdal.Unlink('/vsimem/ecw_45.jp2') @@ -1999,11 +1947,9 @@ def test_ecw_45(): out_ds = gdaltest.jp2ecw_drv.CreateCopy('/vsimem/ecw_45.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/ecw_45.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/ecw_45.jp2') if ds.GetMetadata('xml:SOME_DOMAIN')[0] != '\n': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/ecw_45.jp2') @@ -2014,11 +1960,9 @@ def test_ecw_45(): out_ds = gdaltest.jp2ecw_drv.CreateCopy('/vsimem/ecw_45.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/ecw_45.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/ecw_45.jp2') if ds.GetMetadata('xml:BOX_0')[0] != '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/ecw_45.jp2') @@ -2029,11 +1973,9 @@ def test_ecw_45(): out_ds = gdaltest.jp2ecw_drv.CreateCopy('/vsimem/ecw_45.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/ecw_45.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/ecw_45.jp2') if ds.GetMetadata('xml:XMP')[0] != '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/ecw_45.jp2') @@ -2066,7 +2008,6 @@ def test_ecw_46(): mem_ds.GetRasterBand(1).WriteRaster(0, 0, 40, 40, upsampled_data) cs = mem_ds.GetRasterBand(1).Checksum() if cs != ref_cs: - gdaltest.post_reason('fail') print(cs) print(ref_cs) return 'fail' @@ -2090,7 +2031,6 @@ def test_ecw_47(): ds = gdal.Open('/vsimem/ecw_47.ecw') if ds is None: - gdaltest.post_reason('fail') return 'fail' mean_tolerance = 0.5 diff --git a/autotest/gdrivers/eedai.py b/autotest/gdrivers/eedai.py index d6fcf036cc96..9115326d92cb 100644 --- a/autotest/gdrivers/eedai.py +++ b/autotest/gdrivers/eedai.py @@ -285,7 +285,6 @@ def test_eedai_2(): info = gdal.Info(ds, format='json') for key in expected_info: if not (key in info and info[key] == expected_info[key]): - gdaltest.post_reason('fail') print('Got difference for key %s' % key) if key in info: print('Got: ' + str(info[key])) @@ -297,16 +296,13 @@ def test_eedai_2(): return 'fail' if ds.GetProjectionRef().find('32610') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(3) is not None: - gdaltest.post_reason('fail') return 'fail' npy_serialized = struct.pack( @@ -323,13 +319,11 @@ def test_eedai_2(): got_data = ds.GetRasterBand(1).ReadRaster(1800, 1810, 1, 1) got_data = struct.unpack('h', got_data)[0] if got_data != 12345: - gdaltest.post_reason('fail') print(got_data) return 'fail' got_data = ds.GetRasterBand(2).ReadRaster(1800, 1810, 1, 1) got_data = struct.unpack('h', got_data)[0] if got_data != 23456: - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -339,7 +333,6 @@ def test_eedai_2(): sub_ds = gdal.Open('EEDAI:image:B1,B9') gdal.SetConfigOption('EEDA_URL', None) if sub_ds.RasterCount != 2: - gdaltest.post_reason('fail') print(sub_ds.RasterCount) return 'fail' @@ -347,14 +340,12 @@ def test_eedai_2(): sub_ds = gdal.Open('EEDAI:image:B2') gdal.SetConfigOption('EEDA_URL', None) if sub_ds.RasterCount != 1: - gdaltest.post_reason('fail') print(sub_ds.RasterCount) return 'fail' got_md = sub_ds.GetRasterBand(1).GetMetadata() expected_md = {'prop': 'the_prop_B2'} if got_md != expected_md: - gdaltest.post_reason('fail') print(got_md) return 'fail' @@ -644,7 +635,6 @@ def test_eedai_4(): got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) got_data = struct.unpack('B', got_data)[0] if got_data != 127: - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -652,7 +642,6 @@ def test_eedai_4(): got_data = ds.ReadRaster(0, 0, 1, 1) got_data = struct.unpack('B' * 3, got_data) if got_data != (127, 128, 129): - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -661,7 +650,6 @@ def test_eedai_4(): got_data = ds.ReadRaster(0, 0, 1, 1) got_data = struct.unpack('B' * 3, got_data) if got_data != (127, 128, 129): - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -672,7 +660,6 @@ def test_eedai_4(): 0, 0, 2, 2, buf_xsize=1, buf_ysize=1) got_data = struct.unpack('B', got_data)[0] if got_data != 127: - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -681,7 +668,6 @@ def test_eedai_4(): got_data = ds.ReadRaster(0, 0, 2, 2, buf_xsize=1, buf_ysize=1) got_data = struct.unpack('B' * 3, got_data) if got_data != (127, 128, 129): - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -747,7 +733,6 @@ def test_eedai_geotiff(): got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) got_data = struct.unpack('H', got_data)[0] if got_data != 12345: - gdaltest.post_reason('fail') print(got_data) return 'fail' @@ -778,30 +763,24 @@ def test_eedai_real_service(): ds = gdal.Open('EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725') if ds is None: - gdaltest.post_reason('fail') return 'fail' res = gdal.Info(ds, format='json') expected = {'files': [], 'cornerCoordinates': {'upperRight': [415016.0, 4435536.0], 'lowerLeft': [408970.0, 4427936.0], 'lowerRight': [415016.0, 4427936.0], 'upperLeft': [408970.0, 4435536.0], 'center': [411993.0, 4431736.0]}, 'wgs84Extent': {'type': 'Polygon', 'coordinates': [[]]}, 'description': 'EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725', 'driverShortName': 'EEDAI', 'driverLongName': 'Earth Engine Data API Image', 'bands': [{'description': 'R', 'band': 1, 'colorInterpretation': 'Red', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'G', 'band': 2, 'colorInterpretation': 'Green', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'B', 'band': 3, 'colorInterpretation': 'Blue', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}], 'coordinateSystem': {'wkt': 'PROJCS["NAD83 / UTM zone 14N",\n GEOGCS["NAD83",\n DATUM["North_American_Datum_1983",\n SPHEROID["GRS 1980",6378137,298.257222101,\n AUTHORITY["EPSG","7019"]],\n TOWGS84[0,0,0,0,0,0,0],\n AUTHORITY["EPSG","6269"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4269"]],\n PROJECTION["Transverse_Mercator"],\n PARAMETER["latitude_of_origin",0],\n PARAMETER["central_meridian",-99],\n PARAMETER["scale_factor",0.9996],\n PARAMETER["false_easting",500000],\n PARAMETER["false_northing",0],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n AXIS["Easting",EAST],\n AXIS["Northing",NORTH],\n AUTHORITY["EPSG","26914"]]'}, 'geoTransform': [408970.0, 2.0, 0.0, 4435536.0, 0.0, -2.0], 'metadata': {'IMAGE_STRUCTURE': {'INTERLEAVE': 'PIXEL'}}, 'size': [3023, 3800]} if expected != res: - gdaltest.post_reason('fail') print(res) return 'fail' if ds.ReadRaster(0, 0, 1, 1) is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('EEDAI:MODIS/006/MYD09GA/2017_05_24') if ds is None: - gdaltest.post_reason('fail') return 'fail' res = gdal.Info(ds, format='json') expected = {'files': [], 'cornerCoordinates': {'upperRight': [20015109.354, 10007554.677], 'lowerLeft': [-20015109.354, -10007554.677], 'lowerRight': [20015109.354, -10007554.677], 'upperLeft': [-20015109.354, 10007554.677], 'center': [9.6e-06, 6e-06]}, 'wgs84Extent': {'type': 'Polygon', 'coordinates': [[]]}, 'description': 'EEDAI:MODIS/006/MYD09GA/2017_05_24', 'driverShortName': 'EEDAI', 'driverLongName': 'Earth Engine Data API Image', 'bands': [{'description': 'num_observations_1km', 'band': 1, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {'IMAGE_STRUCTURE': {'PIXELTYPE': 'SIGNEDBYTE'}}}, {'description': 'state_1km', 'band': 2, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'UInt16', 'block': [256, 256], 'metadata': {}}, {'description': 'SensorZenith', 'band': 3, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Int16', 'block': [256, 256], 'metadata': {}}, {'description': 'SensorAzimuth', 'band': 4, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Int16', 'block': [256, 256], 'metadata': {}}, {'description': 'Range', 'band': 5, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'UInt16', 'block': [256, 256], 'metadata': {}}, {'description': 'SolarZenith', 'band': 6, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Int16', 'block': [256, 256], 'metadata': {}}, {'description': 'SolarAzimuth', 'band': 7, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Int16', 'block': [256, 256], 'metadata': {}}, {'description': 'gflags', 'band': 8, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'orbit_pnt', 'band': 9, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {'IMAGE_STRUCTURE': {'PIXELTYPE': 'SIGNEDBYTE'}}}, {'description': 'granule_pnt', 'band': 10, 'colorInterpretation': 'Undefined', 'overviews': [{'size': [21600, 10800]}, {'size': [10800, 5400]}, {'size': [5400, 2700]}, {'size': [2700, 1350]}, {'size': [1350, 675]}, {'size': [675, 337]}, {'size': [337, 168]}, {'size': [168, 84]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}], 'coordinateSystem': {'wkt': 'PROJCS["MODIS Sinusoidal",\n GEOGCS["WGS 84",\n DATUM["WGS_1984",\n SPHEROID["WGS 84",6378137,298.257223563,\n AUTHORITY["EPSG","7030"]],\n AUTHORITY["EPSG","6326"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.01745329251994328,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4326"]],\n PROJECTION["Sinusoidal"],\n PARAMETER["false_easting",0.0],\n PARAMETER["false_northing",0.0],\n PARAMETER["central_meridian",0.0],\n PARAMETER["semi_major",6371007.181],\n PARAMETER["semi_minor",6371007.181],\n UNIT["m",1.0],\n AUTHORITY["SR-ORG","6974"]]'}, 'geoTransform': [-20015109.354, 926.625433056, 0.0, 10007554.677, 0.0, -926.625433055], 'metadata': {'IMAGE_STRUCTURE': {'INTERLEAVE': 'PIXEL'}, 'SUBDATASETS': {'SUBDATASET_2_NAME': 'EEDAI:MODIS/006/MYD09GA/2017_05_24:num_observations_500m,sur_refl_b01,sur_refl_b02,sur_refl_b03,sur_refl_b04,sur_refl_b05,sur_refl_b06,sur_refl_b07,QC_500m,obscov_500m,iobs_res,q_scan', 'SUBDATASET_2_DESC': 'Bands num_observations_500m,sur_refl_b01,sur_refl_b02,sur_refl_b03,sur_refl_b04,sur_refl_b05,sur_refl_b06,sur_refl_b07,QC_500m,obscov_500m,iobs_res,q_scan of MODIS/006/MYD09GA/2017_05_24', 'SUBDATASET_1_NAME': 'EEDAI:MODIS/006/MYD09GA/2017_05_24:num_observations_1km,state_1km,SensorZenith,SensorAzimuth,Range,SolarZenith,SolarAzimuth,gflags,orbit_pnt,granule_pnt', 'SUBDATASET_1_DESC': 'Bands num_observations_1km,state_1km,SensorZenith,SensorAzimuth,Range,SolarZenith,SolarAzimuth,gflags,orbit_pnt,granule_pnt of MODIS/006/MYD09GA/2017_05_24'}}, 'size': [43200, 21600]} if expected != res: - gdaltest.post_reason('fail') print(res) return 'fail' if ds.ReadRaster(0, 0, 1, 1) is None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/ehdr.py b/autotest/gdrivers/ehdr.py index 1b797eb3fc10..340ed312feab 100755 --- a/autotest/gdrivers/ehdr.py +++ b/autotest/gdrivers/ehdr.py @@ -331,12 +331,10 @@ def test_ehdr_14(): cs2 = out_ds.GetRasterBand(1).Checksum() if space == 1 and data != data2: - gdaltest.post_reason('fail') print(space) return 'fail' if (cs1 != 1087 and cs1 != 1192) or (cs2 != 1087 and cs2 != 1192): - gdaltest.post_reason('fail') print(space) print(cs1) print(cs2) @@ -350,7 +348,6 @@ def test_ehdr_14(): cs3 = out_ds.GetRasterBand(1).Checksum() if cs3 != 1087 and cs3 != 1192: - gdaltest.post_reason('fail') print(space) print(cs3) return 'fail' @@ -373,28 +370,22 @@ def test_ehdr_rat(): ds = gdal.Open(tmpfile) rat = ds.GetRasterBand(1).GetDefaultRAT() if rat is None: - gdaltest.post_reason('fail') return 'fail' if rat.GetColumnCount() != 4: - gdaltest.post_reason('fail') print(rat.GetColumnCount()) return 'fail' if rat.GetRowCount() != 25: - gdaltest.post_reason('fail') print(rat.GetRowCount()) return 'fail' for (idx, val) in [(0, -500), (1, 127), (2, 40), (3, 65)]: if rat.GetValueAsInt(0, idx) != val: - gdaltest.post_reason('fail') print(idx, rat.GetValueAsInt(0, idx)) return 'fail' for (idx, val) in [(0, 2000), (1, 145), (2, 97), (3, 47)]: if rat.GetValueAsInt(24, idx) != val: - gdaltest.post_reason('fail') print(idx, rat.GetValueAsInt(24, idx)) return 'fail' if ds.GetRasterBand(1).GetColorTable() is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -405,12 +396,10 @@ def test_ehdr_rat(): ds = gdal.Open(tmpfile, gdal.GA_Update) if ds.GetRasterBand(1).GetDefaultRAT() or ds.GetRasterBand(1).GetColorTable(): - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = ds.GetRasterBand(1).SetDefaultRAT(gdal.RasterAttributeTable()) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/ers.py b/autotest/gdrivers/ers.py index 1b699b344be2..20cef315f188 100755 --- a/autotest/gdrivers/ers.py +++ b/autotest/gdrivers/ers.py @@ -49,7 +49,6 @@ def test_ers_1(): md = ds.GetRasterBand(1).GetMetadata() expected_md = {'STATISTICS_MEAN': '-4020.25', 'STATISTICS_MINIMUM': '-4315', 'STATISTICS_MAXIMUM': '-3744', 'STATISTICS_MEDIAN': '-4000'} if md != expected_md: - gdaltest.post_reason('fail') print(md) return 'fail' return 'success' diff --git a/autotest/gdrivers/gdalhttp.py b/autotest/gdrivers/gdalhttp.py index ec1d5b216c7a..c92e65fa89c5 100755 --- a/autotest/gdrivers/gdalhttp.py +++ b/autotest/gdrivers/gdalhttp.py @@ -173,13 +173,11 @@ def test_http_4(): if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS', None) is not None: print("Fails on MacOSX Travis sometimes. Not sure why.") return 'skip' - gdaltest.post_reason('fail') return 'fail' filelist = ds.GetFileList() if '/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif' not in filelist: print(filelist) - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -206,7 +204,6 @@ def test_http_5(): print('cannot read') return 'skip' conn.close() - gdaltest.post_reason('fail') return 'fail' filename = ds.GetDescription() ds = None @@ -242,7 +239,6 @@ def test_http_6(): print('cannot read') return 'skip' conn.close() - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/gpkg.py b/autotest/gdrivers/gpkg.py index c823855a5572..f708e1f1e97b 100755 --- a/autotest/gdrivers/gpkg.py +++ b/autotest/gdrivers/gpkg.py @@ -184,15 +184,12 @@ def check_tile_format(out_ds, expected_format, expected_band_count, expected_ct, expected_mime_type = 'image/x-webp' if mime_type != expected_mime_type: - gdaltest.post_reason('fail') print(mime_type) return 'fail' if band_count != expected_band_count: - gdaltest.post_reason('fail') print(band_count) return 'fail' if expected_ct != has_ct: - gdaltest.post_reason('fail') print(has_ct) return 'fail' return 'success' @@ -230,23 +227,19 @@ def test_gpkg_1(): sql_lyr = out_ds.ExecuteSQL("SELECT COUNT(*) FROM sqlite_master WHERE name = 'ogr_empty_table'") f = sql_lyr.GetNextFeature() if f.GetField(0) != 0: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) got_gt = out_ds.GetGeoTransform() for i in range(6): if abs(expected_gt[i] - got_gt[i]) > 1e-8: - gdaltest.post_reason('fail') return 'fail' got_wkt = out_ds.GetProjectionRef() if expected_wkt != got_wkt: - gdaltest.post_reason('fail') return 'fail' expected_cs = [expected_cs, expected_cs, expected_cs, 4873] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'PNG', 2, False) @@ -255,7 +248,6 @@ def test_gpkg_1(): out_ds = gdal.Open('/vsimem/tmp.gpkg') sql_lyr = out_ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) @@ -265,19 +257,16 @@ def test_gpkg_1(): expected_cs = expected_cs[0:3] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(out_ds.RasterCount)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' out_ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) if ds.RasterXSize != 256 or ds.RasterYSize != 256: - gdaltest.post_reason('fail') return 'fail' expected_cs = [clamped_expected_cs, clamped_expected_cs, clamped_expected_cs, 4898] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -288,7 +277,6 @@ def test_gpkg_1(): ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_RASTER, open_options=['USE_TILE_EXTENT=YES']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/tmp.gpkg') @@ -303,7 +291,6 @@ def test_gpkg_1(): expected_cs = [expected_cs, expected_cs, expected_cs, 4873] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'PNG', 1, False) @@ -339,7 +326,6 @@ def test_gpkg_2(): expected_cs = [expected_cs, expected_cs, expected_cs, 4873] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'JPEG', 1, False) @@ -348,7 +334,6 @@ def test_gpkg_2(): out_ds = gdal.Open('/vsimem/tmp.gpkg') sql_lyr = out_ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) @@ -357,7 +342,6 @@ def test_gpkg_2(): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != clamped_expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(clamped_expected_cs))) return 'fail' ds = None @@ -374,7 +358,6 @@ def test_gpkg_2(): expected_cs = [expected_cs, expected_cs, expected_cs, 4873] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'JPEG', 1, False) @@ -389,7 +372,6 @@ def test_gpkg_2(): out_ds.GetRasterBand(1).Checksum() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -402,7 +384,6 @@ def test_gpkg_2(): out_ds.FlushCache() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -444,14 +425,12 @@ def test_gpkg_3(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs not in (expected_cs, [4736, 4734, 4736]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' # Check that extension is declared sql_lyr = out_ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'tmp' AND column_name = 'tile_data' AND extension_name = 'gpkg_webp'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) @@ -466,7 +445,6 @@ def test_gpkg_3(): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs not in (clamped_expected_cs, [6850, 6848, 6850, 4898]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(clamped_expected_cs))) return 'fail' ds = None @@ -483,7 +461,6 @@ def test_gpkg_3(): expected_cs.append(4873) got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'WEBP', 3, False) @@ -498,7 +475,6 @@ def test_gpkg_3(): gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': gdaltest.webp_dr.Register() - gdaltest.post_reason('fail') return 'fail' # And at pixel reading time as well @@ -508,7 +484,6 @@ def test_gpkg_3(): gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': gdaltest.webp_dr.Register() - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -525,7 +500,6 @@ def test_gpkg_3(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_RASTER | gdal.OF_UPDATE, open_options=['TILE_FORMAT=WEBP']) sql_lyr = out_ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'tmp' AND column_name = 'tile_data' AND extension_name = 'gpkg_webp'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) out_ds = None @@ -575,7 +549,6 @@ def test_gpkg_4(tile_drv_name='PNG'): expected_cs.append(30658) got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs not in (expected_cs, [22290, 21651, 21551, 30658]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, tile_drv_name, working_bands, False) @@ -584,7 +557,6 @@ def test_gpkg_4(tile_drv_name='PNG'): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs not in (clamped_expected_cs, [56886, 43228, 56508, 30638]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(clamped_expected_cs))) return 'fail' ds = None @@ -601,7 +573,6 @@ def test_gpkg_4(tile_drv_name='PNG'): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, tile_drv_name, 3, False) @@ -678,7 +649,6 @@ def test_gpkg_7(tile_drv_name='PNG'): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(working_bands)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, tile_drv_name, working_bands, False) @@ -698,7 +668,6 @@ def test_gpkg_7(tile_drv_name='PNG'): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, tile_drv_name, 3, False) @@ -718,7 +687,6 @@ def test_gpkg_7(tile_drv_name='PNG'): expected_cs = [0, 0, 0, 0] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, None, None, None) @@ -782,18 +750,15 @@ def test_gpkg_10(): out_ds = gdal.Open('/vsimem/tmp.gpkg') block_size = out_ds.GetRasterBand(1).GetBlockSize() if block_size != [out_ds.RasterXSize, out_ds.RasterYSize]: - gdaltest.post_reason('fail') print(block_size) return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'PNG', 1, True) got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: - gdaltest.post_reason('fail') return 'fail' # SetColorTable() on a non single-band dataset @@ -802,7 +767,6 @@ def test_gpkg_10(): out_ds.GetRasterBand(1).SetColorTable(None) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -811,12 +775,10 @@ def test_gpkg_10(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['BAND_COUNT=1']) got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(out_ds.RasterCount)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' got_ct = out_ds.GetRasterBand(1).GetColorTable() if expected_ct.GetCount() != got_ct.GetCount(): - gdaltest.post_reason('fail') return 'fail' # SetColorTable() on a re-opened dataset @@ -825,7 +787,6 @@ def test_gpkg_10(): out_ds.GetRasterBand(1).SetColorTable(None) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -841,7 +802,6 @@ def test_gpkg_10(): out_ds.GetRasterBand(1).SetColorTable(None) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() @@ -864,13 +824,11 @@ def test_gpkg_10(): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' check_tile_format(out_ds, 'PNG', 4, False) got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -922,7 +880,6 @@ def test_gpkg_11(tile_drv_name='JPEG'): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(working_bands)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' out_ds = None @@ -962,12 +919,10 @@ def test_gpkg_13(): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -975,12 +930,10 @@ def test_gpkg_13(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['BAND_COUNT=1']) got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(out_ds.RasterCount)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' got_ct = out_ds.GetRasterBand(1).GetColorTable() if expected_ct.GetCount() != got_ct.GetCount(): - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -996,12 +949,10 @@ def test_gpkg_13(): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) if ds.RasterXSize != 512 or ds.RasterYSize != 256: - gdaltest.post_reason('fail') return 'fail' expected_cs = [62358, 45823, 12238, 64301] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1030,7 +981,6 @@ def test_gpkg_14(): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['TABLE=non_existing']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/tmp.gpkg') @@ -1038,76 +988,59 @@ def test_gpkg_14(): feat_count = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if feat_count != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('IDENTIFIER') != 'bar': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetMetadataItem('DESCRIPTION') != 'baz': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetMetadataItem('ZOOM_LEVEL') != '1': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is not None: - gdaltest.post_reason('fail') return 'fail' ds = None # In update mode, we expose even empty overview levels ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if ds.GetMetadataItem('ZOOM_LEVEL') != '1': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0).Checksum() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['ZOOM_LEVEL=2']) if ds.RasterXSize != 400: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['ZOOM_LEVEL=1']) if ds.RasterXSize != 400: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None # In update mode, we expose even empty overview levels ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_UPDATE, open_options=['ZOOM_LEVEL=1']) if ds.RasterXSize != 400: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['ZOOM_LEVEL=0']) if ds.RasterXSize != 200: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1118,18 +1051,15 @@ def test_gpkg_14(): with gdaltest.error_handler(): ds = gdal.OpenEx('/vsimem/tmp2.gpkg', open_options=['ZOOM_LEVEL=-1']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/tmp2.gpkg') ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['USE_TILE_EXTENT=YES']) if ds.RasterXSize != 512 or ds.RasterYSize != 256: - gdaltest.post_reason('fail') return 'fail' expected_cs = [27644, 31968, 38564, 64301] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1137,12 +1067,10 @@ def test_gpkg_14(): # Open with exactly one tile shift ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_UPDATE, open_options=['TILE_FORMAT=PNG', 'MINX=-410.4', 'MAXY=320.4']) if ds.RasterXSize != 400 + 256 or ds.RasterYSize != 200 + 256: - gdaltest.post_reason('fail') return 'fail' expected_cs = [29070, 32796, 41086, 64288] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -1153,7 +1081,6 @@ def test_gpkg_14(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 0: - gdaltest.post_reason('fail') return 'fail' ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data) ds = None @@ -1163,12 +1090,10 @@ def test_gpkg_14(): if ds.RasterXSize != 600 or ds.RasterYSize != 400: print(ds.RasterXSize) print(ds.RasterYSize) - gdaltest.post_reason('fail') return 'fail' expected_cs = [28940, 32454, 40526, 64323] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -1182,7 +1107,6 @@ def test_gpkg_14(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 0: - gdaltest.post_reason('fail') return 'fail' ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data) ds = None @@ -1191,7 +1115,6 @@ def test_gpkg_14(): expected_cs = [28940, 32454, 40526, 64323] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' # Partial rewrite @@ -1203,7 +1126,6 @@ def test_gpkg_14(): expected_cs = [28940, 32454, 40526, 64323] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1211,12 +1133,10 @@ def test_gpkg_14(): # Partial tile shift (included in tiles) ds = gdal.OpenEx('GPKG:/vsimem/tmp.gpkg:foo', gdal.OF_UPDATE, open_options=['MINX=-90', 'MAXY=45', 'MINY=-45', 'MAXX=90']) if ds.RasterXSize != 200 or ds.RasterYSize != 100: - gdaltest.post_reason('fail') return 'fail' expected_cs = [9586, 9360, 26758, 48827] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -1227,12 +1147,10 @@ def test_gpkg_14(): ds = gdal.OpenEx('GPKG:/vsimem/tmp.gpkg:foo', open_options=['MINX=-90', 'MAXY=45', 'MINY=-45', 'MAXX=90']) if ds.RasterXSize != 200 or ds.RasterYSize != 100: - gdaltest.post_reason('fail') return 'fail' expected_cs = [9586, 9360, 26758, 48827] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1247,27 +1165,21 @@ def test_gpkg_14(): ds = gdal.Open('/vsimem/tmp.gpkg') md = ds.GetMetadata('SUBDATASETS') if md['SUBDATASET_1_NAME'] != 'GPKG:/vsimem/tmp.gpkg:foo': - gdaltest.post_reason('fail') print(md) return 'fail' if md['SUBDATASET_1_DESC'] != 'foo - bar': - gdaltest.post_reason('fail') print(md) return 'fail' if md['SUBDATASET_2_NAME'] != 'GPKG:/vsimem/tmp.gpkg:other': - gdaltest.post_reason('fail') print(md) return 'fail' if md['SUBDATASET_2_DESC'] != 'other - other': - gdaltest.post_reason('fail') print(md) return 'fail' if md['SUBDATASET_3_NAME'] != 'GPKG:/vsimem/tmp.gpkg:byte': - gdaltest.post_reason('fail') print(md) return 'fail' if md['SUBDATASET_3_DESC'] != 'byte - byte': - gdaltest.post_reason('fail') print(md) return 'fail' ds = None @@ -1275,22 +1187,18 @@ def test_gpkg_14(): ds = gdal.Open('GPKG:/vsimem/tmp.gpkg:other') block_size = ds.GetRasterBand(1).GetBlockSize() if block_size != [64, 64]: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['TABLE=other', 'MINX=-90', 'MAXY=45', 'MINY=-45', 'MAXX=90']) if ds.RasterXSize != 200 or ds.RasterYSize != 100: - gdaltest.post_reason('fail') return 'fail' block_size = ds.GetRasterBand(1).GetBlockSize() if block_size != [64, 64]: - gdaltest.post_reason('fail') return 'fail' expected_cs = [9586, 9360, 26758, 48827] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1310,7 +1218,6 @@ def test_gpkg_14(): expected_cs = [4934, 4934, 4934, 4934] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1331,7 +1238,6 @@ def test_gpkg_14(): expected_cs = [1223, 1223, 1223, 1223] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1352,7 +1258,6 @@ def test_gpkg_14(): expected_cs = [13365, 13365, 13365, 13365] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' ds = None @@ -1382,13 +1287,11 @@ def test_gpkg_14(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 0: - gdaltest.post_reason('fail') return 'fail' expected_cs = [0, 56451, 0, 0] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) ds.GetRasterBand(4).Fill(255) # sys.exit(0) @@ -1399,14 +1302,12 @@ def test_gpkg_14(): with gdaltest.error_handler(): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['MINX=-1e12', 'MAXX=-0.9999e12']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Overflow occurred in ComputeTileAndPixelShifts() with gdaltest.error_handler(): ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['MINY=-1e12', 'MAXY=-0.9999e12']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Overflow occurred in ComputeTileAndPixelShifts() @@ -1417,7 +1318,6 @@ def test_gpkg_14(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/tmp.gpkg') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/tmp.gpkg') @@ -1437,16 +1337,13 @@ def test_gpkg_15(): # SetGeoTransform() and SetProjection() on a non-raster GPKG out_ds = gdaltest.gpkg_dr.Create('/vsimem/tmp.gpkg', 0, 0, 0) if out_ds.GetGeoTransform(can_return_null=True) is not None: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' srs = osr.SpatialReference() @@ -1455,7 +1352,6 @@ def test_gpkg_15(): ret = out_ds.SetProjection(srs.ExportToWkt()) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1465,55 +1361,46 @@ def test_gpkg_15(): out_ds = gdaltest.gpkg_dr.Create('/vsimem/tmp.gpkg', 1, 1) ret = out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None # Repeated SetProjection() out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' srs = osr.SpatialReference() srs.ImportFromEPSG(4326) ret = out_ds.SetProjection(srs.ExportToWkt()) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' out_ds.SetProjection('') out_ds = None out_ds = gdal.Open('/vsimem/tmp.gpkg') if out_ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' # Test setting on read-only dataset gdal.PushErrorHandler() ret = out_ds.SetProjection('') gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1524,21 +1411,17 @@ def test_gpkg_15(): out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_Undefined) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_GrayIndex) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_PaletteIndex) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_RedBand) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1548,13 +1431,11 @@ def test_gpkg_15(): out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_RedBand) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_RedBand) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1564,23 +1445,19 @@ def test_gpkg_15(): out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_GrayIndex) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_RedBand) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ret = out_ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_AlphaBand) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = out_ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_RedBand) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1619,15 +1496,12 @@ def test_gpkg_16(): out_ds = None if abs(val1 - 255) > 1: - gdaltest.post_reason('fail') print(val1) return 'fail' if abs(val2 - 127) > 1: - gdaltest.post_reason('fail') print(val2) return 'fail' if abs(val3 - 0) > 1: - gdaltest.post_reason('fail') print(val3) return 'fail' gdal.Unlink('/vsimem/tmp.gpkg') @@ -1661,12 +1535,10 @@ def test_gpkg_17(): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = out_ds.GetRasterBand(1).GetOverview(0).Checksum() if got_cs != 1087: - gdaltest.post_reason('fail') print(got_cs) return 'fail' check_tile_format(out_ds, 'PNG', 1, False, zoom_level=0) if out_ds.GetRasterBand(1).GetOverview(0).GetColorTable() is not None: - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -1684,7 +1556,6 @@ def test_gpkg_17(): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = out_ds.GetRasterBand(1).GetOverview(0).Checksum() if got_cs != 1087: - gdaltest.post_reason('fail') print(got_cs) return 'fail' check_tile_format(out_ds, 'PNG', 1, False, zoom_level=0) @@ -1704,7 +1575,6 @@ def test_gpkg_17(): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = out_ds.GetRasterBand(1).GetOverview(0).Checksum() if got_cs != 1087: - gdaltest.post_reason('fail') print(got_cs) return 'fail' check_tile_format(out_ds, 'PNG', 3, False, zoom_level=0) @@ -1713,7 +1583,6 @@ def test_gpkg_17(): out_ds = gdal.Open('/vsimem/tmp.gpkg') sql_lyr = out_ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) @@ -1725,7 +1594,6 @@ def test_gpkg_17(): out_ds = None out_ds = gdal.Open('/vsimem/tmp.gpkg') if out_ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1735,7 +1603,6 @@ def test_gpkg_17(): ret = out_ds.GetRasterBand(1).GetOverview(0).GetDataset().BuildOverviews('NONE', []) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1745,7 +1612,6 @@ def test_gpkg_17(): ret = out_ds.BuildOverviews('NEAR', [1]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1757,7 +1623,6 @@ def test_gpkg_17(): gdal.SetConfigOption('ALLOW_GPKG_ZOOM_OTHER_EXTENSION', None) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1769,7 +1634,6 @@ def test_gpkg_17(): gdal.SetConfigOption('ALLOW_GPKG_ZOOM_OTHER_EXTENSION', None) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1780,7 +1644,6 @@ def test_gpkg_17(): ret = out_ds.BuildOverviews('NEAR', [3]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1790,7 +1653,6 @@ def test_gpkg_17(): ret = out_ds.BuildOverviews('NEAR', [2]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1830,13 +1692,11 @@ def test_gpkg_18(): out_ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(3)] if got_cs != expected_cs_ov0: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov0) return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(1).Checksum() for i in range(3)] if got_cs != expected_cs_ov1: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov1) return 'fail' @@ -1851,27 +1711,22 @@ def test_gpkg_18(): ret = out_ds.BuildOverviews('NEAR', [3]) gdal.PopErrorHandler() if ret != 0: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(1).GetOverviewCount() != 3: - gdaltest.post_reason('fail') return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(3)] if got_cs != expected_cs_ov0: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov0) return 'fail' expected_cs = [24807, 25544, 34002] got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(2).Checksum() for i in range(3)] if got_cs != expected_cs_ov1: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov1) return 'fail' @@ -1879,7 +1734,6 @@ def test_gpkg_18(): # Check that extension is declared sql_lyr = out_ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'tmp' AND extension_name = 'gpkg_zoom_other'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) @@ -1887,24 +1741,20 @@ def test_gpkg_18(): out_ds = gdal.Open('/vsimem/tmp.gpkg') if out_ds.GetRasterBand(1).GetOverviewCount() != 3: - gdaltest.post_reason('fail') return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(3)] if got_cs != expected_cs_ov0: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov0) return 'fail' expected_cs = [24807, 25544, 34002] got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(2).Checksum() for i in range(3)] if got_cs != expected_cs_ov1: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov1) return 'fail' @@ -1914,12 +1764,10 @@ def test_gpkg_18(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_RASTER | gdal.OF_UPDATE) ret = out_ds.BuildOverviews('NEAR', [8]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' expected_cs = [12725, 12539, 13553] got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(3).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' @@ -1934,7 +1782,6 @@ def test_gpkg_18(): # Should not result in gpkg_zoom_other ret = out_ds.BuildOverviews('NEAR', [8]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -1942,7 +1789,6 @@ def test_gpkg_18(): out_ds = gdal.Open('/vsimem/tmp.gpkg') sql_lyr = out_ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' out_ds.ReleaseResultSet(sql_lyr) out_ds = None @@ -1981,17 +1827,14 @@ def test_gpkg_19(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_RASTER, open_options=['BAND_COUNT=1']) if out_ds.GetRasterBand(1).GetOverview(0).GetColorTable() is None: - gdaltest.post_reason('fail') return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(1)] if got_cs != expected_cs_ov0: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov0) return 'fail' got_cs = [out_ds.GetRasterBand(i + 1).GetOverview(1).Checksum() for i in range(1)] if got_cs != expected_cs_ov1: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs_ov1) return 'fail' @@ -2025,7 +1868,6 @@ def test_gpkg_20(): got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [30875, 31451, 38110, 64269] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' @@ -2043,7 +1885,6 @@ def test_gpkg_20(): got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [27001, 30168, 34800, 64269] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' @@ -2061,7 +1902,6 @@ def test_gpkg_20(): got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [27718, 31528, 42062, 64269] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' @@ -2085,7 +1925,6 @@ def test_gpkg_20(): got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [2500, 5000, 7500, 30658] if got_cs != expected_cs: - gdaltest.post_reason('fail') print(got_cs) print(expected_cs) return 'fail' @@ -2093,7 +1932,6 @@ def test_gpkg_20(): out_ds = None out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', gdal.OF_RASTER, open_options=['BAND_COUNT=1']) if out_ds.GetRasterBand(1).GetColorTable().GetCount() != 1: - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/tmp.gpkg') @@ -2117,7 +1955,6 @@ def test_gpkg_21(): out_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) mddlist = out_ds.GetMetadataDomainList() if len(mddlist) != 3: - gdaltest.post_reason('fail') print(mddlist) return 'fail' out_ds = None @@ -2130,7 +1967,6 @@ def test_gpkg_21(): out_ds.ReleaseResultSet(sql_lyr) feat_is_none = feat is None if not feat_is_none: - gdaltest.post_reason('fail') return 'fail' # Set a metadata item now @@ -2143,17 +1979,14 @@ def test_gpkg_21(): out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadata('GEOPACKAGE'): - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('foo') != foo_value: - gdaltest.post_reason('fail') print(out_ds.GetMetadataItem('foo')) feat.DumpReadable() return 'fail' md = out_ds.GetMetadata() if len(md) != 3 or md['foo'] != foo_value or \ md['IDENTIFIER'] != 'tmp' or md['ZOOM_LEVEL'] != '0': - gdaltest.post_reason('fail') print(md) feat.DumpReadable() return 'fail' @@ -2169,7 +2002,6 @@ def test_gpkg_21(): """ % foo_value: - gdaltest.post_reason('fail') print(i) feat.DumpReadable() return 'fail' @@ -2184,7 +2016,6 @@ def test_gpkg_21(): not feat.IsFieldSet('timestamp') or \ feat.GetField('md_file_id') != 1 or \ not feat.IsFieldNull('md_parent_id'): - gdaltest.post_reason('fail') print(i) feat.DumpReadable() return 'fail' @@ -2208,7 +2039,6 @@ def test_gpkg_21(): sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2216,7 +2046,6 @@ def test_gpkg_21(): sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata_reference') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2229,15 +2058,12 @@ def test_gpkg_21(): # Still no metadata out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadataItem('IDENTIFIER') != 'my_identifier': - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('DESCRIPTION') != 'my_description': - gdaltest.post_reason('fail') return 'fail' sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2245,7 +2071,6 @@ def test_gpkg_21(): sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata_reference') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2259,7 +2084,6 @@ def test_gpkg_21(): out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadataItem('bar', 'GEOPACKAGE') != 'foo': - gdaltest.post_reason('fail') return 'fail' sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata') @@ -2273,7 +2097,6 @@ def test_gpkg_21(): """: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2288,7 +2111,6 @@ def test_gpkg_21(): not feat.IsFieldSet('timestamp') or \ feat.GetField('md_file_id') != 1 or \ not feat.IsFieldNull('md_parent_id'): - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2299,14 +2121,12 @@ def test_gpkg_21(): out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadataItem('bar', 'GEOPACKAGE') != 'baz': - gdaltest.post_reason('fail') return 'fail' out_ds.SetMetadata(None, 'GEOPACKAGE') out_ds = None out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadata('GEOPACKAGE'): - gdaltest.post_reason('fail') return 'fail' out_ds.SetMetadataItem('1', '2') @@ -2326,29 +2146,22 @@ def test_gpkg_21(): for i in range(2): out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadataItem('1') != '2': - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('GPKG_METADATA_ITEM_1') != 'my_metadata_local': - gdaltest.post_reason('fail') print(out_ds.GetMetadata()) return 'fail' if out_ds.GetMetadataItem('GPKG_METADATA_ITEM_2') != 'other_metadata_local': - gdaltest.post_reason('fail') print(out_ds.GetMetadata()) return 'fail' if out_ds.GetMetadataItem('GPKG_METADATA_ITEM_1', 'GEOPACKAGE') != 'my_metadata': - gdaltest.post_reason('fail') print(out_ds.GetMetadata('GEOPACKAGE')) return 'fail' if out_ds.GetMetadataItem('GPKG_METADATA_ITEM_2', 'GEOPACKAGE') != 'other_metadata': - gdaltest.post_reason('fail') print(out_ds.GetMetadata('GEOPACKAGE')) return 'fail' if out_ds.GetMetadataItem('3', 'CUSTOM_DOMAIN') != '4': - gdaltest.post_reason('fail') return 'fail' if out_ds.GetMetadataItem('6', 'GEOPACKAGE') != '7': - gdaltest.post_reason('fail') return 'fail' out_ds.SetMetadata(out_ds.GetMetadata()) out_ds.SetMetadata(out_ds.GetMetadata('GEOPACKAGE'), 'GEOPACKAGE') @@ -2362,13 +2175,11 @@ def test_gpkg_21(): out_ds = gdal.Open('/vsimem/tmp.gpkg', gdal.GA_Update) if out_ds.GetMetadataItem('GPKG_METADATA_ITEM_1', 'GEOPACKAGE') != 'my_metadata': - gdaltest.post_reason('fail') print(out_ds.GetMetadata()) return 'fail' sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata WHERE id < 10') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2376,7 +2187,6 @@ def test_gpkg_21(): sql_lyr = out_ds.ExecuteSQL('SELECT * FROM gpkg_metadata_reference WHERE md_file_id < 10') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') feat.DumpReadable() out_ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -2447,7 +2257,6 @@ def test_gpkg_22(tile_drv_name='PNG'): got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(2)] if got_cs != expected_cs: if tile_drv_name != 'WEBP' or got_cs not in ([4899, 10807], [6274, 10807], [17638, 10807]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' out_ds = None @@ -2457,7 +2266,6 @@ def test_gpkg_22(tile_drv_name='PNG'): expected_cs = [expected_cs[0], expected_cs[0], expected_cs[0], expected_cs[1]] if got_cs != expected_cs: if tile_drv_name != 'WEBP' or got_cs not in ([4899, 4899, 4899, 10807], [4899, 4984, 4899, 10807], [6274, 6274, 6274, 10807], [17638, 17631, 17638, 10807]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' out_ds = None @@ -2466,7 +2274,6 @@ def test_gpkg_22(tile_drv_name='PNG'): got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != clamped_expected_cs: if tile_drv_name != 'WEBP' or got_cs not in ([5266, 5266, 5266, 11580], [5266, 5310, 5266, 11580], [6436, 6436, 6436, 11580], [17007, 17000, 17007, 11580]): - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(clamped_expected_cs))) return 'fail' ds = None @@ -2531,13 +2338,11 @@ def test_gpkg_26(): ds = gdal.Open('/vsimem/tmp.gpkg') if ds.GetMetadataItem('AREA_OR_POINT') != 'Area': - gdaltest.post_reason('fail') return 'fail' got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] # VC12 returns [3561, 3561, 3561, 3691] for GoogleCRS84Quad # and For GoogleCRS84Quad RESAMPLING=CUBIC, got [3415, 3415, 3415, 3691] if max([abs(got_cs[i] - expected_cs[i]) for i in range(4)]) > 2: - gdaltest.post_reason('fail') print('For %s, got %s, expected %s' % (scheme, str(got_cs), str(expected_cs))) if gdal.GetConfigOption('APPVEYOR') is None: return 'fail' @@ -2560,7 +2365,6 @@ def test_gpkg_26(): ds = gdal.Open('/vsimem/tmp.gpkg') got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs not in expected_cs: - gdaltest.post_reason('fail') print('For %s, got %s, expected %s' % (scheme, str(got_cs), str(expected_cs))) if gdal.GetConfigOption('APPVEYOR') is None: return 'fail' @@ -2573,20 +2377,17 @@ def test_gpkg_26(): ds = gdaltest.gpkg_dr.Create('/vsimem/tmp.gpkg', 1, 1, 1, options=['TILING_SCHEME=GoogleCRS84Quad', 'BLOCKSIZE=128']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/tmp.gpkg') ds = gdaltest.gpkg_dr.Create('/vsimem/tmp.gpkg', 1, 1, 1, options=['TILING_SCHEME=GoogleCRS84Quad']) # Test that implicit SRS registration works. if ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = ds.SetGeoTransform([0, 10, 0, 0, 0, -10]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' srs = osr.SpatialReference() srs.ImportFromEPSG(32630) @@ -2594,7 +2395,6 @@ def test_gpkg_26(): ret = ds.SetProjection(srs.ExportToWkt()) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ds = None @@ -2608,7 +2408,6 @@ def test_gpkg_26(): ds = gdaltest.gpkg_dr.CreateCopy('/foo/tmp.gpkg', src_ds, options=['TILING_SCHEME=invalid']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid target filename @@ -2617,7 +2416,6 @@ def test_gpkg_26(): ds = gdaltest.gpkg_dr.CreateCopy('/foo/tmp.gpkg', src_ds, options=['TILING_SCHEME=GoogleCRS84Quad']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Source is not georeferenced @@ -2626,7 +2424,6 @@ def test_gpkg_26(): ds = gdaltest.gpkg_dr.CreateCopy('/vsimem/tmp.gpkg', src_ds, options=['TILING_SCHEME=GoogleCRS84Quad']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2653,7 +2450,6 @@ def test_gpkg_27(): expected_cs = [src_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2697,7 +2493,6 @@ def test_gpkg_28(): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['BAND_COUNT=3']) got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2742,7 +2537,6 @@ def test_gpkg_29(x=0): out_ds = gdal.OpenEx('/vsimem/tmp.gpkg', open_options=['BAND_COUNT=3']) got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2780,7 +2574,6 @@ def test_gpkg_31(): expected_cs = [4672, 4672, 4672, 4873] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2810,7 +2603,6 @@ def test_gpkg_32(): expected_cs = [1970, 1970, 1970, 10807] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2818,7 +2610,6 @@ def test_gpkg_32(): expected_cs = [1970, 10807] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2850,7 +2641,6 @@ def test_gpkg_33(): expected_cs = [10991, 57677, 34965, 10638] got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' @@ -2956,12 +2746,10 @@ def test_gpkg_36(): out_ds = gdal.Open('/vsimem/gpkg_36.gpkg') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(4)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -2986,7 +2774,6 @@ def test_gpkg_37(): ds = gdal.Open('/vsimem/gpkg_37.gpkg', gdal.GA_Update) ret = ds.BuildOverviews('NONE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) if ret != 0 or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3008,7 +2795,6 @@ def test_gpkg_38(): ds = gdal.Open('/vsimem/gpkg_38.gpkg') if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') return 'fail' ds = None filesize = gdal.VSIStatL('/vsimem/gpkg_38.gpkg').size @@ -3021,7 +2807,6 @@ def test_gpkg_38(): ds = None gdal.Unlink(filename) if not ds_is_none and gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' filename = '/vsimem/||maxlength=%d||gpkg_38.gpkg' % (filesize - 1) @@ -3031,7 +2816,6 @@ def test_gpkg_38(): ds = None gdal.Unlink(filename) if not ds_is_none and gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3058,27 +2842,21 @@ def test_gpkg_39(): sql_lyr = ds.ExecuteSQL("SELECT COUNT(*) FROM sqlite_master WHERE name = 'ogr_empty_table'") f = sql_lyr.GetNextFeature() if f.GetField(0) != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) if ds.GetRasterBand(1).DataType != gdal.GDT_Int16: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('AREA_OR_POINT') != 'Area': - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT scale, offset FROM gpkg_2d_gridded_tile_ancillary') f = sql_lyr.GetNextFeature() if f['scale'] != 1.0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f['offset'] != 0.0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3086,7 +2864,6 @@ def test_gpkg_39(): sql_lyr = ds.ExecuteSQL('SELECT grid_cell_encoding FROM gpkg_2d_gridded_coverage_ancillary') f = sql_lyr.GetNextFeature() if f['grid_cell_encoding'] != 'grid-value-is-area': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3097,20 +2874,17 @@ def test_gpkg_39(): ds.ReleaseResultSet(sql_lyr) feat_is_none = feat is None if not feat_is_none: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('PRAGMA application_id') f = sql_lyr.GetNextFeature() if f['application_id'] != 1196444487: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL('PRAGMA user_version') f = sql_lyr.GetNextFeature() if f['user_version'] != 10200: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3118,7 +2892,6 @@ def test_gpkg_39(): # Statistics not available on partial tile without nodata md = ds.GetRasterBand(1).GetMetadata() if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' ds = None @@ -3127,11 +2900,9 @@ def test_gpkg_39(): gdal.Translate('/vsimem/gpkg_39.gpkg', 'data/n43.dt0', format='GPKG') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetMetadataItem('AREA_OR_POINT') != 'Point': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetRasterBand(1).GetUnitType() != 'm': - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetUnitType()) return 'fail' ds = None @@ -3142,11 +2913,9 @@ def test_gpkg_39(): creationOptions=['GRID_CELL_ENCODING=grid-value-is-corner']) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetMetadataItem('AREA_OR_POINT') != 'Point': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetRasterBand(1).GetMetadataItem('GRID_CELL_ENCODING') != 'grid-value-is-corner': - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMetadataItem()) return 'fail' @@ -3156,7 +2925,6 @@ def test_gpkg_39(): ds.ReleaseResultSet(sql_lyr) feat_is_none = feat is None if not feat_is_none: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3167,7 +2935,6 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') md = ds.GetRasterBand(1).GetMetadata() if md != {'STATISTICS_MINIMUM': '74', 'STATISTICS_MAXIMUM': '255'}: - gdaltest.post_reason('fail') print(md) return 'fail' ds = None @@ -3175,7 +2942,6 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') mdi = ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') if mdi != '74': - gdaltest.post_reason('fail') print(mdi) return 'fail' ds = None @@ -3186,7 +2952,6 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') md = ds.GetRasterBand(1).GetMetadata() if md != {'STATISTICS_MINIMUM': '74', 'STATISTICS_MAXIMUM': '255'}: - gdaltest.post_reason('fail') print(md) return 'fail' ds = None @@ -3194,7 +2959,6 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') mdi = ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') if mdi != '74': - gdaltest.post_reason('fail') print(mdi) return 'fail' ds = None @@ -3202,10 +2966,8 @@ def test_gpkg_39(): gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG', noData=1) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != -32768.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' @@ -3213,11 +2975,9 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') cs = ds.GetRasterBand(1).Checksum() if cs != 4649: - gdaltest.post_reason('fail') print(cs) return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != -32768.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' @@ -3225,7 +2985,6 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') cs = ds.GetRasterBand(1).Checksum() if cs != 4118 and cs != 4077: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -3235,7 +2994,6 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') cs = ds.GetRasterBand(1).Checksum() if cs != 4118 and cs != 4077: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -3243,37 +3001,30 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg', gdal.GA_Update) ds.BuildOverviews('NEAR', [2, 4]) if ds.GetRasterBand(1).GetOverview(0).Checksum() != 37308: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverview(0).Checksum()) return 'fail' ds.BuildOverviews('NONE', []) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG', outputType=gdal.GDT_UInt16) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT scale, offset FROM gpkg_2d_gridded_tile_ancillary') f = sql_lyr.GetNextFeature() if f['scale'] != 1.0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG', outputType=gdal.GDT_UInt16, noData=1) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 1.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' @@ -3281,11 +3032,9 @@ def test_gpkg_39(): ds = gdal.Open('/vsimem/gpkg_39.gpkg') cs = ds.GetRasterBand(1).Checksum() if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 74.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' @@ -3293,56 +3042,45 @@ def test_gpkg_39(): gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_Float32: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT scale, offset FROM gpkg_2d_gridded_tile_ancillary') f = sql_lyr.GetNextFeature() if f.GetField('scale') != 1.0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG', noData=1) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 1: - gdaltest.post_reason('fail') return 'fail' gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG', creationOptions=['TILE_FORMAT=PNG']) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_Float32: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT scale, offset FROM gpkg_2d_gridded_tile_ancillary') f = sql_lyr.GetNextFeature() if f['scale'] == 1.0 or not f.IsFieldSetAndNotNull('scale'): - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) gdal.Translate('/vsimem/gpkg_39.gpkg', src_ds, format='GPKG', noData=74, creationOptions=['TILE_FORMAT=PNG']) ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_Float32: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 4680: - gdaltest.post_reason('fail') print(cs) return 'fail' sql_lyr = ds.ExecuteSQL('SELECT scale, offset FROM gpkg_2d_gridded_tile_ancillary') f = sql_lyr.GetNextFeature() if f['scale'] == 1.0 or not f.IsFieldSetAndNotNull('scale'): - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3359,14 +3097,11 @@ def test_gpkg_39(): src_ds = gdal.Open('/vsimem/gpkg_39.asc') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_Int16: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != -32768.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' ds = None @@ -3386,14 +3121,11 @@ def test_gpkg_39(): src_ds = gdal.Open('/vsimem/gpkg_39.asc') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 65535.0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' ds = None @@ -3413,14 +3145,11 @@ def test_gpkg_39(): src_ds = gdal.Open('/vsimem/gpkg_39.asc') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' ds = None @@ -3444,10 +3173,8 @@ def test_gpkg_39(): src_ds = gdal.Open('/vsimem/gpkg_39.asc') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_Float32: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' ds = None @@ -3466,10 +3193,8 @@ def test_gpkg_39(): src_ds = gdal.Open('/vsimem/gpkg_39.asc') ds = gdal.Open('/vsimem/gpkg_39.gpkg') if ds.GetRasterBand(1).DataType != gdal.GDT_Float32: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetNoDataValue()) return 'fail' ds = None @@ -3490,7 +3215,6 @@ def test_gpkg_39(): sql_lyr = ds.ExecuteSQL('SELECT scale, offset FROM gpkg_2d_gridded_tile_ancillary') f = sql_lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -3508,7 +3232,6 @@ def test_gpkg_39(): sql_lyr = ds.ExecuteSQL('SELECT * FROM gpkg_39') f = sql_lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -3527,7 +3250,6 @@ def test_gpkg_39(): sql_lyr = ds.ExecuteSQL('SELECT * FROM gpkg_39') f = sql_lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -3553,14 +3275,12 @@ def test_gpkg_40(): sql_lyr = ds.ExecuteSQL('PRAGMA application_id') f = sql_lyr.GetNextFeature() if f['application_id'] != 1196444487: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL('PRAGMA user_version') f = sql_lyr.GetNextFeature() if f['user_version'] != 10200: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3573,14 +3293,12 @@ def test_gpkg_40(): sql_lyr = ds.ExecuteSQL('PRAGMA application_id') f = sql_lyr.GetNextFeature() if f['application_id'] != 1196437808: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL('PRAGMA user_version') f = sql_lyr.GetNextFeature() if f['user_version'] != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3592,14 +3310,12 @@ def test_gpkg_40(): sql_lyr = ds.ExecuteSQL('PRAGMA application_id') f = sql_lyr.GetNextFeature() if f['application_id'] != 1196437809: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL('PRAGMA user_version') f = sql_lyr.GetNextFeature() if f['user_version'] != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3611,14 +3327,12 @@ def test_gpkg_40(): sql_lyr = ds.ExecuteSQL('PRAGMA application_id') f = sql_lyr.GetNextFeature() if f['application_id'] != 1196444487: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL('PRAGMA user_version') f = sql_lyr.GetNextFeature() if f['user_version'] != 10200: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3667,15 +3381,12 @@ def test_gpkg_42(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('test') if lyr is None: - gdaltest.post_reason('fail') return 'fail' ds.FlushCache() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3703,7 +3414,6 @@ def test_gpkg_43(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3711,10 +3421,8 @@ def test_gpkg_43(): format='GPKG', creationOptions=['APPEND_SUBDATASET=YES']) ds = gdal.OpenEx('/vsimem/gpkg_43.gpkg') if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3787,7 +3495,6 @@ def test_gpkg_46(): count += 1 if abs(f.GetField(1) - 40075016.6855785) > 1e-7 or \ abs(f.GetField(2) - 40075016.6855785) > 1e-7: - gdaltest.post_reason('fail') f.DumpReadable() ds.ReleaseResultSet(sql_lyr) gdal.Unlink('/vsimem/gpkg_46.gpkg') @@ -3798,7 +3505,6 @@ def test_gpkg_46(): gdal.Unlink('/vsimem/gpkg_46.gpkg') if count != 23: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3880,7 +3586,6 @@ def test_gpkg_delete_raster_layer(): ds = None if fc != 0: - gdaltest.post_reason('fail') print(fc) return 'fail' @@ -3890,7 +3595,6 @@ def test_gpkg_delete_raster_layer(): gdal.VSIFCloseL(f) if content.find('foo') >= 0: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(filename) @@ -3920,7 +3624,6 @@ def test_gpkg_delete_gridded_coverage_raster_layer(): gdal.VSIFCloseL(f) if content.find('foo') >= 0: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(filename) @@ -3937,11 +3640,9 @@ def test_gpkg_open_old_gpkg_elevation_tiles_extension(): gdal.ErrorReset() ds = gdal.Open('data/uint16-old-elevation-extension.gpkg') if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 4672: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3982,7 +3683,6 @@ def test_gpkg_match_overview_factor(): ds = gdal.Open('/vsimem/gpkg_match_overview_factor.gpkg', gdal.GA_Update) ret = ds.BuildOverviews('NONE', [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) if ret != 0 or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/grib.py b/autotest/gdrivers/grib.py index 3ae6b47dc364..1dd1e8f77998 100755 --- a/autotest/gdrivers/grib.py +++ b/autotest/gdrivers/grib.py @@ -138,12 +138,10 @@ def test_grib_read_units(): ds = gdal.Open('tmp/ds.mint.bin') md = ds.GetRasterBand(1).GetMetadata() if md['GRIB_UNIT'] != '[C]' or md['GRIB_COMMENT'] != 'Minimum temperature [C]': - gdaltest.post_reason('fail') print(md) return 'success' ds.GetRasterBand(1).ComputeStatistics(False) if abs(ds.GetRasterBand(1).GetMinimum() - 13) > 1: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMinimum()) return 'success' ds = None @@ -155,12 +153,10 @@ def test_grib_read_units(): gdal.SetConfigOption('GRIB_NORMALIZE_UNITS', None) md = ds.GetRasterBand(1).GetMetadata() if md['GRIB_UNIT'] != '[K]' or md['GRIB_COMMENT'] != 'Minimum temperature [K]': - gdaltest.post_reason('fail') print(md) return 'success' ds.GetRasterBand(1).ComputeStatistics(False) if abs(ds.GetRasterBand(1).GetMinimum() - 286) > 1: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMinimum()) return 'success' ds = None @@ -748,7 +744,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_NUMBERS=20 0 156 72 0 255 99 0 0 0 1 0 0 0 0 1 255 255 255 255 255 255 255 255 255 255 255 0extra" ]) if out_ds is None: - gdaltest.post_reason('failure') return 'fail' out_ds = None ds = gdal.Open(tmpfilename) @@ -770,7 +765,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_NUMBERS=20 0 156 72 0 255 99 0 0 0 1 0 0 0 0 1 255 255 255 255 255 255 255 255 255 255" ]) if out_ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink(tmpfilename) @@ -799,7 +793,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_ASSEMBLED_VALUES=20 0 40008 0 255 99 0 0 1 0 1 -127 -2147483647 255 -127 -2147483647 0extra" ]) if out_ds is None: - gdaltest.post_reason('failure') return 'fail' out_ds = None ds = gdal.Open(tmpfilename) @@ -821,7 +814,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_ASSEMBLED_VALUES=20 0 40008 0 255 99 0 0 1 0 1 -127 -2147483647 255 -127" ]) if out_ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink(tmpfilename) @@ -850,7 +842,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_ASSEMBLED_VALUES=5 7 2 0 0 0 0 1 0 2 31 285 17292 2 61145 31 285 17292 2" ]) if out_ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink(tmpfilename) @@ -897,7 +888,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_NUMBERS=1 2 3 4 5" ]) if out_ds is None: - gdaltest.post_reason('failure') return 'fail' out_ds = None with gdaltest.error_handler(): @@ -920,7 +910,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_ASSEMBLED_VALUES=1 2 3 4 5" ]) if out_ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink(tmpfilename) @@ -931,7 +920,6 @@ def test_grib_grib2_write_creation_options(): "PDS_PDTN=32" ]) if out_ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink(tmpfilename) @@ -943,7 +931,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_NUMBERS=-1 256 0 0 0 0" ]) if out_ds is None: - gdaltest.post_reason('failure') return 'fail' out_ds = None gdal.Unlink(tmpfilename) @@ -957,7 +944,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_ASSEMBLED_VALUES=-1 256 -1 1 128 4000000000 -1 -4 1 1 1 65536 1 1 32768 1 -129 -4 1 -1 -4" ]) if out_ds is None: - gdaltest.post_reason('failure') return 'fail' out_ds = None gdal.Unlink(tmpfilename) @@ -971,7 +957,6 @@ def test_grib_grib2_write_creation_options(): "PDS_TEMPLATE_ASSEMBLED_VALUES=20 0 40008 0 255 99 0 0 1 0 1 -127 -2147483647 255 -127 -2147483647" ]) if out_ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink(tmpfilename) @@ -1032,7 +1017,6 @@ def test_grib_grib2_write_projections(): out_ds = None gdal.Unlink(tmpfilename) if wkt.find('SPHEROID["GRS80",6378137,298.257222101]') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -1553,7 +1537,6 @@ def test_grib_grib2_write_nodata(): ds = gdal.Open(tmpfilename) if ds.GetRasterBand(1).GetNoDataValue() != 123: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink(tmpfilename) diff --git a/autotest/gdrivers/hdf5.py b/autotest/gdrivers/hdf5.py index 756ce5546898..2d40182dd629 100755 --- a/autotest/gdrivers/hdf5.py +++ b/autotest/gdrivers/hdf5.py @@ -324,7 +324,6 @@ def test_hdf5_10(): gdal.ErrorReset() ds = gdal.Open('HDF5:"data/CSK_DGM.h5"://S01/QLK') if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -332,17 +331,14 @@ def test_hdf5_10(): got_gcpprojection = ds.GetGCPProjection() if got_gcpprojection.find('GEOGCS["WGS 84",DATUM["WGS_1984"') != 0: print(got_gcpprojection) - gdaltest.post_reason('fail') return 'fail' got_gcps = ds.GetGCPs() if len(got_gcps) != 4: - gdaltest.post_reason('fail') return 'fail' if abs(got_gcps[0].GCPPixel - 0) > 1e-5 or abs(got_gcps[0].GCPLine - 0) > 1e-5 or \ abs(got_gcps[0].GCPX - 12.2395902509238) > 1e-5 or abs(got_gcps[0].GCPY - 44.7280047434954) > 1e-5: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -362,7 +358,6 @@ def test_hdf5_11(): gdal.ErrorReset() ds = gdal.Open('HDF5:"data/CSK_GEC.h5"://S01/QLK') if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -370,7 +365,6 @@ def test_hdf5_11(): got_projection = ds.GetProjection() if got_projection.find('PROJCS["Transverse_Mercator",GEOGCS["WGS 84",DATUM["WGS_1984"') != 0: print(got_projection) - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() @@ -378,7 +372,6 @@ def test_hdf5_11(): for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-5: print(got_gt) - gdaltest.post_reason('fail') return 'fail' ds = None @@ -402,7 +395,6 @@ def test_hdf5_12(): got_projection = ds.GetProjection() if got_projection.find('Azimuthal_Equidistant') < 0: print(got_projection) - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() @@ -413,7 +405,6 @@ def test_hdf5_12(): if max([abs(got_gt[i] - expected_gt[i]) for i in range(6)]) > 1e-5 and \ max([abs(got_gt[i] - expected_gt2[i]) for i in range(6)]) > 1e-5: print(got_gt) - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -431,12 +422,10 @@ def test_hdf5_13(): got_gcps = ds.GetGCPs() if len(got_gcps) != 3030: - gdaltest.post_reason('fail') return 'fail' if abs(got_gcps[0].GCPPixel - 0.5) > 1e-5 or abs(got_gcps[0].GCPLine - 0.5) > 1e-5 or \ abs(got_gcps[0].GCPX - 33.1655693) > 1e-5 or abs(got_gcps[0].GCPY - 39.3207207) > 1e-5: - gdaltest.post_reason('fail') print(got_gcps[0]) return 'fail' diff --git a/autotest/gdrivers/ignfheightasciigrid.py b/autotest/gdrivers/ignfheightasciigrid.py index 386b38965d59..938c9be2ef4d 100755 --- a/autotest/gdrivers/ignfheightasciigrid.py +++ b/autotest/gdrivers/ignfheightasciigrid.py @@ -112,10 +112,8 @@ def test_ignfheightasciigrid_invalid(): gdal.FileFromMemBuffer(filename, ok_content) ds = gdal.OpenEx(filename) if not ds: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetUnitType() != 'm': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(filename) @@ -151,7 +149,6 @@ def test_ignfheightasciigrid_invalid(): gdal.FileFromMemBuffer(filename, content) with gdaltest.error_handler(): if gdal.OpenEx(filename, gdal.OF_RASTER): - gdaltest.post_reason('fail') print(content) return 'fail' gdal.Unlink(filename) @@ -185,7 +182,6 @@ def test_ignfheightasciigrid_gra(): ds = gdal.OpenEx('data/ignfheightasciigrid.gra', gdal.OF_RASTER) if ds.GetRasterBand(1).GetNoDataValue() != 9999: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -203,7 +199,6 @@ def test_ignfheightasciigrid_gra_invalid(): gdal.FileFromMemBuffer(filename, content) with gdaltest.error_handler(): if gdal.OpenEx(filename, gdal.OF_RASTER): - gdaltest.post_reason('fail') print(content) return 'fail' gdal.Unlink(filename) diff --git a/autotest/gdrivers/ingr.py b/autotest/gdrivers/ingr.py index d2ad420dfd66..d081e02d5407 100755 --- a/autotest/gdrivers/ingr.py +++ b/autotest/gdrivers/ingr.py @@ -222,7 +222,6 @@ def test_ingr_17(): gdal.GetDriverByName('INGR').Delete('/vsimem/ingr_17.rle') if got_cs != ref_cs: - gdaltest.post_reason('fail') print(got_cs) print(ref_cs) return 'fail' @@ -247,7 +246,6 @@ def test_ingr_18(): got_data = ds.ReadRaster(0, ds.RasterYSize - 1, ds.RasterXSize, 1) if got_data != expected_data: - gdaltest.post_reason('fail') return 'fail' ds.FlushCache() @@ -255,7 +253,6 @@ def test_ingr_18(): got_data = ds.ReadRaster(0, ds.RasterYSize - 1, ds.RasterXSize, 1) if got_data != expected_data: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/iris.py b/autotest/gdrivers/iris.py index ffc6647202a5..80dfacc7544b 100755 --- a/autotest/gdrivers/iris.py +++ b/autotest/gdrivers/iris.py @@ -52,7 +52,6 @@ def test_iris_2(): ds = gdal.Open('data/iristest.dat') if ds.GetRasterBand(1).Checksum() != 52872: - gdaltest.post_reason('fail') return 'fail' ds.GetProjectionRef() @@ -75,7 +74,6 @@ def test_iris_2(): for i in range(6): if (expected_gt[i] == 0.0 and got_gt[i] != 0.0) or \ (expected_gt[i] != 0.0 and abs(got_gt[i] - expected_gt[i]) / abs(expected_gt[i]) > 1e-5): - gdaltest.post_reason('fail') print(got_gt) print(i) return 'fail' diff --git a/autotest/gdrivers/isis.py b/autotest/gdrivers/isis.py index f7308f9d1de0..6daaf0f71c3c 100755 --- a/autotest/gdrivers/isis.py +++ b/autotest/gdrivers/isis.py @@ -120,25 +120,20 @@ def test_isis_4(): delete_copy=0) ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds.GetMetadataDomainList() != ['', 'json:ISIS3']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' lbl = ds.GetMetadata_List('json:ISIS3')[0] # Couldn't be preserved, since points to dangling file if lbl.find('OriginalLabel') >= 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('PositiveWest') >= 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if ds.GetRasterBand(1).GetMaskFlags() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMaskFlags()) return 'fail' if ds.GetRasterBand(1).GetMaskBand().Checksum() != 12220: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMaskBand().Checksum()) return 'fail' ds = None @@ -152,11 +147,9 @@ def test_isis_4(): ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('PositiveWest') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('Planetographic') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -173,15 +166,12 @@ def test_isis_4(): ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('PositiveEast') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('Planetocentric') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('my_label') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -200,12 +190,10 @@ def test_isis_5(): ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) if gdal.VSIStatL('/vsimem/isis_tmp.cub') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('MinimumLongitude') >= 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -224,24 +212,20 @@ def test_isis_6(): ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) if gdal.VSIStatL('/vsimem/isis_tmp.cub') is None: - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsimem/isis_tmp.lbl', 'rb') content = gdal.VSIFReadL(1, 10000, f).decode('ASCII') gdal.VSIFCloseL(f) if content.find('#my comment') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if len(content) == 10000: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/isis_tmp.lbl', gdal.GA_Update) ds.GetRasterBand(1).Fill(0) ds = None ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -258,12 +242,10 @@ def test_isis_7(): ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) if gdal.VSIStatL('/vsimem/isis_tmp.tif') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"Format":"BandSequential"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -277,12 +259,10 @@ def test_isis_7(): ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) if gdal.VSIStatL('/vsimem/isis_tmp.tif') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"Format":"GeoTIFF"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -302,12 +282,10 @@ def test_isis_8(): ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) if gdal.VSIStatL('/vsimem/isis_tmp.tif') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"Format":"GeoTIFF"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -316,7 +294,6 @@ def test_isis_8(): ds = None ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -335,19 +312,16 @@ def test_isis_9(): ret = tst.testCreateCopy(new_filename='/vsimem/isis_tmp.lbl', delete_copy=0) if gdal.VSIStatL('/vsimem/foo.bin') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"Format":"Tile"') < 0 or lbl.find('"TileSamples":256') < 0 or \ lbl.find('"TileLines":256') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') if gdal.VSIStatL('/vsimem/foo.bin') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -366,13 +340,11 @@ def test_isis_10(): delete_copy=0) ds = gdal.Open('/vsimem/foo.tif') if ds.GetRasterBand(1).GetBlockSize() != [16, 32]: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetBlockSize()) return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') if gdal.VSIStatL('/vsimem/foo.tif') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -390,7 +362,6 @@ def test_isis_11(): delete_copy=0) ds = gdal.Open('/vsimem/isis_tmp.tif') if ds.GetRasterBand(1).GetBlockSize() != [256, 256]: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetBlockSize()) return 'fail' ds = None @@ -409,7 +380,6 @@ def test_isis_12(): cs = ds.GetRasterBand(i + 1).Checksum() expected_cs = src_ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(i + 1, cs, expected_cs) return 'fail' ds = None @@ -430,7 +400,6 @@ def test_isis_13(): cs = ds.GetRasterBand(i + 1).Checksum() expected_cs = src_ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(i + 1, cs, expected_cs) return 'fail' ds = None @@ -450,7 +419,6 @@ def test_isis_14(): cs = ds.GetRasterBand(i + 1).Checksum() expected_cs = src_ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(i + 1, cs, expected_cs) return 'fail' ds = None @@ -471,7 +439,6 @@ def test_isis_15(): cs = ds.GetRasterBand(i + 1).Checksum() expected_cs = src_ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(i + 1, cs, expected_cs) return 'fail' ds = None @@ -505,27 +472,21 @@ def test_isis_16(): ds = None ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds.GetRasterBand(1).Checksum() != cs: - gdaltest.post_reason('fail') print(dt, cs, nd, options, init_nd, ds.GetRasterBand(1).Checksum()) return 'fail' if ds.GetRasterBand(1).GetMaskFlags() != 0: - gdaltest.post_reason('fail') print(dt, cs, nd, options, init_nd, ds.GetRasterBand(1).GetMaskFlags()) return 'fail' if ds.GetRasterBand(1).GetMaskBand().Checksum() != 0: - gdaltest.post_reason('fail') print(dt, cs, nd, options, init_nd, ds.GetRasterBand(1).GetMaskBand().Checksum()) return 'fail' if ds.GetRasterBand(1).GetOffset() != 10: - gdaltest.post_reason('fail') print(dt, cs, nd, options, init_nd, ds.GetRasterBand(1).GetOffset()) return 'fail' if ds.GetRasterBand(1).GetScale() != 20: - gdaltest.post_reason('fail') print(dt, cs, nd, options, init_nd, ds.GetRasterBand(1).GetScale()) return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != nd: - gdaltest.post_reason('fail') print(dt, cs, nd, options, init_nd, ds.GetRasterBand(1).GetNoDataValue()) return 'fail' ds = None @@ -556,7 +517,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["Equirectangular DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME_localRadius",123455.2424988797,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Equirectangular"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",1],PARAMETER["standard_parallel_1",2],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -573,7 +533,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["Equirectangular DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME_localRadius",123455.2424988797,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Equirectangular"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",1],PARAMETER["standard_parallel_1",2],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -587,7 +546,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["Orthographic DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME",123456,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Orthographic"],PARAMETER["latitude_of_origin",1],PARAMETER["central_meridian",2],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -601,7 +559,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["Sinusoidal DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME",123456,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Sinusoidal"],PARAMETER["longitude_of_center",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -615,7 +572,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["Mercator DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME",123456,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["latitude_of_origin",1],PARAMETER["central_meridian",2],PARAMETER["scale_factor",0.9],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -629,7 +585,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["PolarStereographic DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME_polarRadius",122838.72,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",1],PARAMETER["central_meridian",2],PARAMETER["scale_factor",0.9],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -643,7 +598,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["TransverseMercator DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME",123456,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",1],PARAMETER["central_meridian",2],PARAMETER["scale_factor",0.9],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -657,7 +611,6 @@ def test_isis_18(): wkt = ds.GetProjectionRef() ds = None if not osr.SpatialReference(wkt).IsSame(osr.SpatialReference('PROJCS["LambertConformal DATUM_NAME",GEOGCS["GCS_DATUM_NAME",DATUM["D_DATUM_NAME",SPHEROID["DATUM_NAME",123456,0]],PRIMEM["Reference_Meridian",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",1],PARAMETER["standard_parallel_2",2],PARAMETER["latitude_of_origin",3],PARAMETER["central_meridian",4],PARAMETER["false_easting",0],PARAMETER["false_northing",0]]')): - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -674,27 +627,21 @@ def test_isis_18(): ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"TargetName":"my_target"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"LatitudeType":"Planetographic"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MinimumLatitude":2.5') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MinimumLongitude":1.5') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MaximumLatitude":4.5') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MaximumLongitude":3.5') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -709,27 +656,21 @@ def test_isis_18(): ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"LongitudeDirection":"PositiveWest"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"LongitudeDomain":180') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MinimumLatitude":-60') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MinimumLongitude":-110') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MaximumLatitude":40') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MaximumLongitude":-10') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -744,27 +685,21 @@ def test_isis_18(): ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('"MinimumLatitude":-60') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MinimumLongitude":90') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MaximumLatitude":40') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"MaximumLongitude":350') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"UpperLeftCornerX":-21547') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' if lbl.find('"UpperLeftCornerY":86188') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -781,14 +716,12 @@ def test_isis_19(): ds = gdal.Open('data/isis3_detached.lbl') res = gdal.Info(ds, format='json', extraMDDomains=['json:ISIS3']) if res['metadata']['json:ISIS3']['IsisCube']['_type'] != 'object': - gdaltest.post_reason('fail') print(res) return 'fail' ds = gdal.Open('data/isis3_detached.lbl') res = gdal.Info(ds, extraMDDomains=['json:ISIS3']) if res.find('IsisCube') < 0: - gdaltest.post_reason('fail') print(res) return 'fail' @@ -805,7 +738,6 @@ def test_isis_20(): ds = gdal.Open('/vsimem/isis_tmp.lbl') lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('AMadeUpValue') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -823,12 +755,10 @@ def test_isis_21(): format='ISIS3') ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds.GetRasterBand(1).Checksum() != 9978: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' lbl = ds.GetMetadata_List('json:ISIS3')[0] if lbl.find('AMadeUpValue') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -846,7 +776,6 @@ def test_isis_22(): js = """invalid""" with gdaltest.error_handler(): if ds.SetMetadata([js], 'json:ISIS3') == 0: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -857,13 +786,11 @@ def test_isis_22(): ds.SetMetadata([js], 'json:ISIS3') lbl = ds.GetMetadata_List('json:ISIS3') if lbl is None: - gdaltest.post_reason('fail') return 'fail' ds.SetMetadata([js], 'json:ISIS3') ds = None ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds is None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -874,7 +801,6 @@ def test_isis_22(): ds = None ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds is None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -886,7 +812,6 @@ def test_isis_22(): ds = None ds = gdal.Open('/vsimem/isis_tmp.lbl') if ds is None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -901,7 +826,6 @@ def test_isis_22(): f = gdal.VSIFOpenL('/vsimem/isis_tmp.lbl', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('ASCII') gdal.VSIFCloseL(f) @@ -915,7 +839,6 @@ def test_isis_22(): content.find('baz = 5 ') < 0 or \ content.find('baw = "with space"') < 0 or \ content.find('very_long = aveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -926,7 +849,6 @@ def test_isis_22(): lbl.find('"value":5') < 0 or lbl.find('"unit":"M"') < 0 or \ lbl.find('"baw":"with space"') < 0 or \ lbl.find('"very_long":"aveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylooooongtext"') < 0: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -948,7 +870,6 @@ def test_isis_23(): format='ISIS3') ds = gdal.Open('/vsimem/isis_tmp.lbl') if ref_data == ds.GetRasterBand(1).ReadRaster(): - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -957,7 +878,6 @@ def test_isis_23(): format='ISIS3', creationOptions=['DATA_LOCATION=GeoTIFF']) ds = gdal.Open('/vsimem/isis_tmp.lbl') if ref_data == ds.GetRasterBand(1).ReadRaster(): - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -966,7 +886,6 @@ def test_isis_23(): format='ISIS3', creationOptions=['TILED=YES']) ds = gdal.Open('/vsimem/isis_tmp.lbl') if ref_data == ds.GetRasterBand(1).ReadRaster(): - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -981,7 +900,6 @@ def test_isis_23(): format='ISIS3') ds = gdal.Open('/vsimem/isis_tmp.lbl') if ref_data == ds.GetRasterBand(1).ReadRaster(): - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/isis_tmp.lbl') @@ -1003,7 +921,6 @@ def test_isis_24(): ds = gdal.GetDriverByName('ISIS3').Create('/vsimem/error.txt', 1, 1, options=['DATA_LOCATION=EXTERNAL']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # cannot create external filename @@ -1012,7 +929,6 @@ def test_isis_24(): options=['DATA_LOCATION=EXTERNAL', 'EXTERNAL_FILENAME=/i_dont/exist/error.cub']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # no GTiff driver @@ -1032,7 +948,6 @@ def test_isis_24(): options=['DATA_LOCATION=GEOTIFF', 'EXTERNAL_FILENAME=/i_dont/exist/error.tif']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/error.lbl') @@ -1043,7 +958,6 @@ def test_isis_24(): src_ds, options=['DATA_LOCATION=GEOTIFF']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/out.tif') @@ -1057,12 +971,10 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl', gdal.GA_Update) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1078,7 +990,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1114,12 +1025,10 @@ def test_isis_24(): gdal.FileFromMemBuffer('/vsimem/out.lbl', 'IsisCube') if gdal.IdentifyDriver('/vsimem/out.lbl') is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1145,7 +1054,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1171,7 +1079,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1197,7 +1104,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1224,7 +1130,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1251,7 +1156,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1271,7 +1175,6 @@ def test_isis_24(): # missing Group = Pixels. This is actually valid. Assuming Real ds = gdal.Open('/vsimem/out.lbl') if ds is None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1284,25 +1187,21 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 2, 1) with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1, 2) with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1, 1, gdal.GDT_Int16) with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1316,42 +1215,36 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 2, 1) gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1, 2) gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1, 1, gdal.GDT_Int16) gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1, options=['COMPRESS=LZW']) gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1, options=['TILED=YES']) gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = gdal.GetDriverByName('GTiff').Create('/vsimem/out.tif', 1, 1) ds.GetRasterBand(1).SetNoDataValue(0) @@ -1361,7 +1254,6 @@ def test_isis_24(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.lbl') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): gdal.GetDriverByName('ISIS3').Delete('/vsimem/out.lbl') @@ -1373,7 +1265,6 @@ def test_isis_24(): mem_ds, callback=cancel_cbk) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Delete would fail since ds is None gdal.Unlink('/vsimem/out.lbl') @@ -1391,10 +1282,8 @@ def test_isis_25(): gdal.GetDriverByName('ISIS3').CreateCopy('/vsimem/out.lbl', mem_ds) ds = gdal.Open('/vsimem/out.lbl') if ds.GetRasterBand(1).GetScale() != 10: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOffset() != 20: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.GetDriverByName('ISIS3').Delete('/vsimem/out.lbl') @@ -1472,7 +1361,6 @@ def test_isis_26(): x = C End_Object """) < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -1508,7 +1396,6 @@ def test_isis_27(): if dst_location == 'EXTERNAL': history_filename = lbl['History']['^History'] if history_filename != 'out2.History.IsisCube': - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1521,7 +1408,6 @@ def test_isis_27(): gdal.VSIFCloseL(f) if offset != 0 or size != len(history): - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1529,7 +1415,6 @@ def test_isis_27(): return 'fail' else: if offset + size != len(content): - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1540,7 +1425,6 @@ def test_isis_27(): history.find('FROM = out.lbl') < 0 or \ history.find('TO = out2.lbl') < 0 or \ history.find('TO = out.lbl') < 0: - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1559,7 +1443,6 @@ def test_isis_27(): content = gdal.VSIFReadL(1, 10000, f).decode('ASCII') gdal.VSIFCloseL(f) if content.find('foo') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' gdal.GetDriverByName('ISIS3').Delete('/vsimem/out.lbl') @@ -1601,7 +1484,6 @@ def test_isis_28(): ds = gdal.Open('/vsimem/in.lbl') fl = ds.GetFileList() if fl != ['/vsimem/in.lbl', '/vsimem/in_table']: - gdaltest.post_reason('fail') print(fl) return 'success' ds = None @@ -1631,7 +1513,6 @@ def test_isis_28(): if dst_location == 'EXTERNAL': table_filename = lbl['Table_first_table']['^Table'] if table_filename != 'out.Table.first_table': - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1644,7 +1525,6 @@ def test_isis_28(): gdal.VSIFCloseL(f) if offset != 0 or size != 3 or size != len(table): - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1652,7 +1532,6 @@ def test_isis_28(): return 'fail' else: if offset + size != len(content): - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1660,7 +1539,6 @@ def test_isis_28(): table = content[offset:] if table != 'FOO': - gdaltest.post_reason('fail') print(src_location) print(dst_location) print(content) @@ -1688,7 +1566,6 @@ def test_isis_29(): lbl = ds.GetMetadata_List('json:ISIS3')[0] lbl = json.loads(lbl) if 'History' in lbl: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None @@ -1702,12 +1579,10 @@ def test_isis_29(): lbl = ds.GetMetadata_List('json:ISIS3')[0] lbl = json.loads(lbl) if 'History' in lbl: - gdaltest.post_reason('fail') print(lbl) return 'fail' ds = None if gdal.VSIStatL('/vsimem/out.History.IsisCube') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('ISIS3').Delete('/vsimem/out.lbl') diff --git a/autotest/gdrivers/jp2kak.py b/autotest/gdrivers/jp2kak.py index 2b8bb446708f..e0a8d481be81 100755 --- a/autotest/gdrivers/jp2kak.py +++ b/autotest/gdrivers/jp2kak.py @@ -176,7 +176,6 @@ def test_jp2kak_11(): ds = gdal.Open('data/gtsmall_11_int16.jp2') cs = ds.GetRasterBand(1).Checksum() if cs not in (63475, 63472, 63452, 63471): - gdaltest.post_reason('fail') print(cs) return 'fail' return 'success' @@ -194,7 +193,6 @@ def test_jp2kak_12(): ds = gdal.Open('data/gtsmall_10_uint16.jp2') cs = ds.GetRasterBand(1).Checksum() if cs != 63360 and cs != 63357 and cs != 63358: - gdaltest.post_reason('fail') print(cs) return 'fail' return 'success' @@ -414,7 +412,6 @@ def test_jp2kak_20(): return 'fail' got_cs = fourth_band.Checksum() if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' jp2_bands_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -436,12 +433,10 @@ def test_jp2kak_20(): tmp_ds = None tiff_drv.Delete('/vsimem/jp2kak_20.tif') if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' if jp2_bands_data != gtiff_bands_data: - gdaltest.post_reason('fail') return 'fail' # if jp2_fourth_band_data != gtiff_fourth_band_data: @@ -452,7 +447,6 @@ def test_jp2kak_20(): open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -488,7 +482,6 @@ def test_jp2kak_21(): mem_ds.GetRasterBand(1).WriteRaster(0, 0, 40, 40, upsampled_data) cs = mem_ds.GetRasterBand(1).Checksum() if cs != ref_cs: - gdaltest.post_reason('fail') print(cs) print(ref_cs) return 'fail' @@ -511,13 +504,11 @@ def test_jp2kak_22(): ref_cs = src_ds.GetRasterBand(1).Checksum() cs = ds.GetRasterBand(1).Checksum() if ref_cs != cs: - gdaltest.post_reason('fail') print(i) print(cs) print(ref_cs) return 'fail' if src_ds.GetRasterBand(1).GetColorInterpretation() != ds.GetRasterBand(1).GetColorInterpretation(): - gdaltest.post_reason('fail') print(i) return 'fail' ds = None diff --git a/autotest/gdrivers/jp2lura.py b/autotest/gdrivers/jp2lura.py index ecf612136efd..a9b112975212 100755 --- a/autotest/gdrivers/jp2lura.py +++ b/autotest/gdrivers/jp2lura.py @@ -206,7 +206,6 @@ def test_jp2lura_3(): ds = ogr.Open('data/int16.jp2') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -238,11 +237,9 @@ def test_jp2lura_4(out_filename='tmp/jp2lura_4.jp2'): gdal.Unlink('/vsimem/jp2lura_4.vrt') if gdal.VSIStatL(out_filename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if validate(out_filename, inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(out_filename) @@ -398,13 +395,10 @@ def DISABLED_jp2lura_10(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_10.jp2', src_ds, options=['YCBCR420=YES', 'RESOLUTIONS=3']) maxdiff = gdaltest.compare_ds(src_ds, out_ds) if out_ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' del out_ds src_ds = None @@ -429,11 +423,9 @@ def DISABLED_jp2lura_11(): ds = gdal.Open('data/stefan_full_rgba_alpha_1bit.jp2') fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') is not None: - gdaltest.post_reason('fail') return 'fail' got_cs = fourth_band.Checksum() if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' jp2_bands_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -449,22 +441,18 @@ def DISABLED_jp2lura_11(): tmp_ds = None gdal.GetDriverByName('GTiff').Delete('/vsimem/jp2lura_11.tif') if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' if jp2_bands_data != gtiff_bands_data: - gdaltest.post_reason('fail') return 'fail' if jp2_fourth_band_data != gtiff_fourth_band_data: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/stefan_full_rgba_alpha_1bit.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -494,7 +482,6 @@ def test_jp2lura_12(): gdaltest.jp2lura_drv.Delete('tmp/jp2lura_12.jp2') if wkt.find('32631') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -512,7 +499,6 @@ def test_jp2lura_12(): gdaltest.jp2lura_drv.Delete('tmp/jp2lura_12.jp2') if gt != (1000, 1, 0, 2000, 0, -1): - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -534,7 +520,6 @@ def test_jp2lura_13(): src_ds = None if gdal.VSIStatL('tmp/jp2lura_13.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('tmp/jp2lura_13.jp2') @@ -542,13 +527,10 @@ def test_jp2lura_13(): gcps = ds.GetGCPs() wkt = ds.GetGCPProjection() if count != 4: - gdaltest.post_reason('fail') return 'fail' if len(gcps) != 4: - gdaltest.post_reason('fail') return 'fail' if wkt.find('4326') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -570,13 +552,10 @@ def test_jp2lura_13(): gdaltest.jp2lura_drv.Delete('tmp/jp2lura_13.jp2') if count != 1: - gdaltest.post_reason('fail') return 'fail' if len(gcps) != 1: - gdaltest.post_reason('fail') return 'fail' if wkt.find('32631') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -593,7 +572,6 @@ def test_jp2lura_14(): ds = gdal.Open('data/byte_2gcps.jp2') if ds.GetGCPCount() != 2: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -653,7 +631,6 @@ def test_jp2lura_17(): src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_17.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_17.jp2') @@ -692,7 +669,6 @@ def test_jp2lura_18(): ds = gdal.Open('/vsimem/jp2lura_18.jp2') ds.GetRasterBand(1).Checksum() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -711,7 +687,6 @@ def test_jp2lura_19(): ds = gdal.Open('data/byte_gmljp2_with_nul_car.jp2') if ds.GetProjectionRef() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -805,25 +780,19 @@ def test_jp2lura_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None if validate('/vsimem/jp2lura_22.jp2', expected_gmljp2=False, inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_22.jp2') @@ -839,17 +808,14 @@ def test_jp2lura_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('/vsimem/jp2lura_22.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('/vsimem/jp2lura_22.jp2') if ds.GetRasterBand(4).Checksum() != 23120: - gdaltest.post_reason('fail') print(ds.GetRasterBand(4).Checksum()) return 'fail' ds = None @@ -861,23 +827,17 @@ def test_jp2lura_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 11457: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None @@ -891,7 +851,6 @@ def test_jp2lura_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_22.jp2') @@ -906,20 +865,15 @@ def test_jp2lura_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2lura_22.jp2') @@ -935,20 +889,15 @@ def test_jp2lura_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2lura_22.jp2') @@ -975,18 +924,15 @@ def DISABLED_jp2lura_23(): src_ds = None ds = gdal.Open('/vsimem/jp2lura_23.jp2') if ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '9': - gdaltest.post_reason('failure') return 'fail' out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_23_2.jp2', ds) if out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '9': - gdaltest.post_reason('failure') return 'fail' del out_ds ds = None if gdal.VSIStatL('/vsimem/jp2lura_23.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_23.jp2') gdal.Unlink('/vsimem/jp2lura_23_2.jp2') @@ -1013,19 +959,15 @@ def test_jp2lura_24(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_24.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_24.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None if validate('/vsimem/jp2lura_24.jp2', expected_gmljp2=False, inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_24.jp2') @@ -1041,26 +983,20 @@ def test_jp2lura_24(): src_ds = None if gdal.VSIStatL('/vsimem/jp2lura_24.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('/vsimem/jp2lura_24.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('/vsimem/jp2lura_24.jp2') if ds.GetRasterBand(2).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') is not None: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE')) return 'fail' if ds.GetRasterBand(2).Checksum() != 23120: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).Checksum()) return 'fail' ds = None @@ -1090,11 +1026,9 @@ def test_jp2lura_25(): src_ds = None ds = gdal.Open('/vsimem/jp2lura_25.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' ds = None if gdal.VSIStatL('/vsimem/jp2lura_25.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_25.jp2') @@ -1272,18 +1206,14 @@ def DISABLED_jp2lura_31(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_31.jp2', src_ds) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_31.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_31.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetColorInterpretation()) return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2lura_31.jp2') @@ -1297,21 +1227,16 @@ def DISABLED_jp2lura_31(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_31.jp2', src_ds) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_31.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_31.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetColorInterpretation()) return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2lura_31.jp2') @@ -1335,7 +1260,6 @@ def DISABLED_jp2lura_33(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_33.jp2', src_ds, options=['BLOCKXSIZE=100000', 'BLOCKYSIZE=100000']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/jp2lura_33.jp2') @@ -1355,7 +1279,6 @@ def test_jp2lura_34(): ds = gdal.Open('data/dimensions_above_31bit.jp2') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1373,7 +1296,6 @@ def test_jp2lura_35(): ds = gdal.Open('data/truncated.jp2') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1392,7 +1314,6 @@ def test_jp2lura_36(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_36.jp2', src_ds) gdal.PopErrorHandler() if out_ds is not None or gdal.VSIStatL('/vsimem/jp2lura_36.jp2') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1411,11 +1332,9 @@ def test_jp2lura_37(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_37.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_37.jp2') if ds.GetMetadata() != {}: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_37.jp2') @@ -1426,11 +1345,9 @@ def test_jp2lura_37(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_37.jp2') if ds.GetMetadata() != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1442,12 +1359,10 @@ def test_jp2lura_37(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_37.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_37.jp2') md = ds.GetMetadata('SOME_DOMAIN') if md != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') print(md) return 'fail' gdal.Unlink('/vsimem/jp2lura_37.jp2') @@ -1458,11 +1373,9 @@ def test_jp2lura_37(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_37.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_37.jp2') if ds.GetMetadata('xml:SOME_DOMAIN')[0] != '\n': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_37.jp2') @@ -1473,11 +1386,9 @@ def test_jp2lura_37(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_37.jp2') if ds.GetMetadata('xml:BOX_0')[0] != '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_37.jp2') @@ -1488,11 +1399,9 @@ def test_jp2lura_37(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_37.jp2') if ds.GetMetadata('xml:XMP')[0] != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1533,7 +1442,6 @@ def test_jp2lura_38(): src_ds.SetGeoTransform([0, 60, 0, 0, 0, -60]) out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_38.jp2', src_ds, options=['GeoJP2=NO']) if out_ds.GetProjectionRef() != wkt: - gdaltest.post_reason('fail') print(out_ds.GetProjectionRef()) return 'fail' crsdictionary = out_ds.GetMetadata_List("xml:CRSDictionary.gml")[0] @@ -1625,7 +1533,6 @@ def test_jp2lura_39(): del out_ds ds = gdal.Open('/vsimem/jp2lura_39.jp2') if ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' ds = None @@ -1702,14 +1609,12 @@ def test_jp2lura_40(): del out_ds ds = gdal.Open('/vsimem/jp2lura_40.jp2') if ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (2, 0.1, 0, 49, 0, -0.1) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(got_gt) return 'fail' ds = None @@ -1730,11 +1635,9 @@ def test_jp2lura_41(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_41.jp2', src_ds, options=['USE_SRC_CODESTREAM=YES', '@PROFILE=PROFILE_1', 'GEOJP2=NO', 'GMLJP2=NO']) if src_ds.GetRasterBand(1).Checksum() != out_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') return 'fail' del out_ds if gdal.VSIStatL('/vsimem/jp2lura_41.jp2').size != 9923: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_41.jp2') gdal.Unlink('/vsimem/jp2lura_41.jp2.aux.xml') @@ -1761,7 +1664,6 @@ def test_jp2lura_41(): gdal.PopErrorHandler() del out_ds if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2lura_41.jp2') @@ -1796,10 +1698,8 @@ def test_jp2lura_45(): src_ds = gdal.Open('data/byte.tif') out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_45.jp2', src_ds, options=['GMLJP2V2_DEF=YES']) if out_ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetLayer(0) is not None: - gdaltest.post_reason('fail') return 'fail' del out_ds @@ -1864,7 +1764,6 @@ def test_jp2lura_45(): """ if gmljp2 != minimal_instance: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' @@ -1885,12 +1784,10 @@ def test_jp2lura_47(): out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_47.jp2', src_ds) del out_ds if gdal.VSIStatL('/vsimem/jp2lura_47.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2lura_47.jp2') if ds.GetMetadata('RPC') is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1910,11 +1807,9 @@ def test_jp2lura_48(): ds = gdal.Open('data/byte_tile_2048.jp2') (blockxsize, blockysize) = ds.GetRasterBand(1).GetBlockSize() if (blockxsize, blockysize) != (20, 20): - gdaltest.post_reason('fail') print(blockxsize, blockysize) return 'fail' if ds.GetRasterBand(1).Checksum() != 4610: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2247,7 +2142,6 @@ def test_jp2lura_51(): with gdaltest.error_handler(): ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_51.jp2', src_ds) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_51.jp2', src_ds, @@ -2256,13 +2150,11 @@ def test_jp2lura_51(): ds = None if validate('/vsimem/jp2lura_51.jp2', inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdaltest.jp2lura_drv.Delete('/vsimem/jp2lura_51.jp2') if maxdiff > 0.01: - gdaltest.post_reason('fail') return 'fail' # QUALITY @@ -2273,12 +2165,10 @@ def test_jp2lura_51(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff > 124: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' if validate('/vsimem/jp2lura_51.jp2', inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' ds = None with gdaltest.error_handler(): @@ -2291,12 +2181,10 @@ def test_jp2lura_51(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff > 370: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' if validate('/vsimem/jp2lura_51.jp2', inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdaltest.jp2lura_drv.Delete('/vsimem/jp2lura_51.jp2') @@ -2307,7 +2195,6 @@ def test_jp2lura_51(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff != 0.0: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' @@ -2342,13 +2229,11 @@ def test_jp2lura_52(): options=['REVERSIBLE=YES']) got_min, got_max = ds.GetRasterBand(1).ComputeRasterMinMax() if val != got_min or val != got_max: - gdaltest.post_reason('fail') print(val, dt, fmt, got_min, got_max) return 'fail' ds = None if val >= 0 and validate('/vsimem/jp2lura_52.jp2', expected_gmljp2=False, inspire_tg=False) == 'fail': - gdaltest.post_reason('fail') print(val, dt, fmt) return 'fail' @@ -2372,7 +2257,6 @@ def test_jp2lura_53(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff > 8: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' @@ -2383,7 +2267,6 @@ def test_jp2lura_53(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff > 2: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' @@ -2395,7 +2278,6 @@ def test_jp2lura_53(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff > 8: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' @@ -2407,7 +2289,6 @@ def test_jp2lura_53(): maxdiff = gdaltest.compare_ds(ds, src_ds) ds = None if maxdiff > 0: - gdaltest.post_reason('fail') print(maxdiff) return 'fail' @@ -2434,7 +2315,6 @@ def test_jp2lura_54(): buf_type=gdal.GDT_Int16) data = struct.unpack('h' * 100 * 100, data) if min(data) != 100 or max(data) != 100: - gdaltest.post_reason('fail') print(min(data)) print(max(data)) return 'fail' @@ -2443,7 +2323,6 @@ def test_jp2lura_54(): data = ds.GetRasterBand(1).ReadRaster(0, 0, 100, 100, 30, 30) data = struct.unpack('B' * 30 * 30, data) if min(data) != 100 or max(data) != 100: - gdaltest.post_reason('fail') print(min(data)) print(max(data)) return 'fail' diff --git a/autotest/gdrivers/jp2openjpeg.py b/autotest/gdrivers/jp2openjpeg.py index 29ace11c0e6e..ef24418804fb 100755 --- a/autotest/gdrivers/jp2openjpeg.py +++ b/autotest/gdrivers/jp2openjpeg.py @@ -114,7 +114,6 @@ def test_jp2openjpeg_3(): ds = ogr.Open('data/int16.jp2') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -146,7 +145,6 @@ def test_jp2openjpeg_4(out_filename='tmp/jp2openjpeg_4.jp2'): gdal.Unlink('/vsimem/jp2openjpeg_4.vrt') if gdal.VSIStatL(out_filename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(out_filename) @@ -302,13 +300,10 @@ def test_jp2openjpeg_10(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_10.jp2', src_ds, options=['YCBCR420=YES', 'RESOLUTIONS=3']) maxdiff = gdaltest.compare_ds(src_ds, out_ds) if out_ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' del out_ds src_ds = None @@ -333,11 +328,9 @@ def test_jp2openjpeg_11(): ds = gdal.Open('data/stefan_full_rgba_alpha_1bit.jp2') fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') is not None: - gdaltest.post_reason('fail') return 'fail' got_cs = fourth_band.Checksum() if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' jp2_bands_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -353,22 +346,18 @@ def test_jp2openjpeg_11(): tmp_ds = None gdal.GetDriverByName('GTiff').Delete('/vsimem/jp2openjpeg_11.tif') if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' if jp2_bands_data != gtiff_bands_data: - gdaltest.post_reason('fail') return 'fail' if jp2_fourth_band_data != gtiff_fourth_band_data: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/stefan_full_rgba_alpha_1bit.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -398,7 +387,6 @@ def test_jp2openjpeg_12(): gdaltest.jp2openjpeg_drv.Delete('tmp/jp2openjpeg_12.jp2') if wkt.find('32631') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -416,7 +404,6 @@ def test_jp2openjpeg_12(): gdaltest.jp2openjpeg_drv.Delete('tmp/jp2openjpeg_12.jp2') if gt != (1000, 1, 0, 2000, 0, -1): - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -438,7 +425,6 @@ def test_jp2openjpeg_13(): src_ds = None if gdal.VSIStatL('tmp/jp2openjpeg_13.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('tmp/jp2openjpeg_13.jp2') @@ -446,13 +432,10 @@ def test_jp2openjpeg_13(): gcps = ds.GetGCPs() wkt = ds.GetGCPProjection() if count != 4: - gdaltest.post_reason('fail') return 'fail' if len(gcps) != 4: - gdaltest.post_reason('fail') return 'fail' if wkt.find('4326') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' ds = None @@ -474,13 +457,10 @@ def test_jp2openjpeg_13(): gdaltest.jp2openjpeg_drv.Delete('tmp/jp2openjpeg_13.jp2') if count != 1: - gdaltest.post_reason('fail') return 'fail' if len(gcps) != 1: - gdaltest.post_reason('fail') return 'fail' if wkt.find('32631') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -497,7 +477,6 @@ def test_jp2openjpeg_14(): ds = gdal.Open('data/byte_2gcps.jp2') if ds.GetGCPCount() != 2: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -579,7 +558,6 @@ def test_jp2openjpeg_17(): src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_17.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_17.jp2') @@ -618,7 +596,6 @@ def test_jp2openjpeg_18(): ds = gdal.Open('/vsimem/jp2openjpeg_18.jp2') ds.GetRasterBand(1).Checksum() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -637,7 +614,6 @@ def test_jp2openjpeg_19(): ds = gdal.Open('data/byte_gmljp2_with_nul_car.jp2') if ds.GetProjectionRef() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -754,20 +730,15 @@ def test_jp2openjpeg_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2openjpeg_22.jp2') @@ -782,17 +753,14 @@ def test_jp2openjpeg_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('/vsimem/jp2openjpeg_22.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('/vsimem/jp2openjpeg_22.jp2') if ds.GetRasterBand(4).Checksum() != 23120: - gdaltest.post_reason('fail') print(ds.GetRasterBand(4).Checksum()) return 'fail' ds = None @@ -804,23 +772,17 @@ def test_jp2openjpeg_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() not in [11457, 11450]: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None @@ -834,7 +796,6 @@ def test_jp2openjpeg_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_22.jp2') @@ -849,20 +810,15 @@ def test_jp2openjpeg_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2openjpeg_22.jp2') @@ -878,20 +834,15 @@ def test_jp2openjpeg_22(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_22.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_22.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2openjpeg_22.jp2') @@ -918,18 +869,15 @@ def test_jp2openjpeg_23(): src_ds = None ds = gdal.Open('/vsimem/jp2openjpeg_23.jp2') if ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '9': - gdaltest.post_reason('failure') return 'fail' out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_23_2.jp2', ds) if out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '9': - gdaltest.post_reason('failure') return 'fail' del out_ds ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_23.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_23.jp2') gdal.Unlink('/vsimem/jp2openjpeg_23_2.jp2') @@ -956,14 +904,11 @@ def test_jp2openjpeg_24(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_24.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_24.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2openjpeg_24.jp2') @@ -978,26 +923,20 @@ def test_jp2openjpeg_24(): del out_ds src_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_24.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('/vsimem/jp2openjpeg_24.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('/vsimem/jp2openjpeg_24.jp2') if ds.GetRasterBand(2).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') is not None: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE')) return 'fail' if ds.GetRasterBand(2).Checksum() != 23120: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).Checksum()) return 'fail' ds = None @@ -1027,11 +966,9 @@ def test_jp2openjpeg_25(): src_ds = None ds = gdal.Open('/vsimem/jp2openjpeg_25.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_25.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_25.jp2') @@ -1099,14 +1036,11 @@ def test_jp2openjpeg_26(): out_ds.GetRasterBand(1).GetOverview(overview_count - 1).YSize != 2 * 128: print(out_ds.GetRasterBand(1).GetOverview(overview_count - 1).XSize) print(out_ds.GetRasterBand(1).GetOverview(overview_count - 1).YSize) - gdaltest.post_reason('fail') return 'fail' out_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_26.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if validate('/vsimem/jp2openjpeg_26.jp2') == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1117,23 +1051,18 @@ def test_jp2openjpeg_26(): out_ds.GetRasterBand(1).GetOverview(overview_count - 1).YSize != 128: print(out_ds.GetRasterBand(1).GetOverview(overview_count - 1).XSize) print(out_ds.GetRasterBand(1).GetOverview(overview_count - 1).YSize) - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() out_ds.GetRasterBand(1).Checksum() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' out_ds.GetRasterBand(1).GetOverview(0).Checksum() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' out_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_26.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if validate('/vsimem/jp2openjpeg_26.jp2') == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1145,17 +1074,13 @@ def test_jp2openjpeg_26(): out_ds = None ds = gdal.OpenEx('/vsimem/jp2openjpeg_26.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_26.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if validate('/vsimem/jp2openjpeg_26.jp2') == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1165,15 +1090,12 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'JPX=NO']) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' out_ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_26.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' res = validate('/vsimem/jp2openjpeg_26.jp2', return_error_count=True) if res != 'skip' and res != (2, 0): - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1182,14 +1104,11 @@ def test_jp2openjpeg_26(): src_ds.GetRasterBand(1).SetMetadataItem('NBITS', '1', 'IMAGE_STRUCTURE') out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES']) if out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_26.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if validate('/vsimem/jp2openjpeg_26.jp2', expected_gmljp2=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1198,14 +1117,11 @@ def test_jp2openjpeg_26(): src_ds.GetRasterBand(1).SetMetadataItem('NBITS', '12', 'IMAGE_STRUCTURE') out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES']) if out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') is not None: - gdaltest.post_reason('fail') return 'fail' ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_26.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' if validate('/vsimem/jp2openjpeg_26.jp2', expected_gmljp2=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1216,7 +1132,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'BLOCKXSIZE=1536', 'BLOCKYSIZE=1536']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Error case: non square tile @@ -1224,7 +1139,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'BLOCKXSIZE=512', 'BLOCKYSIZE=128']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Error case: incompatible PROFILE @@ -1232,7 +1146,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'PROFILE=UNRESTRICTED']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Error case: valid, but too small number of resolutions regarding PROFILE_1 @@ -1240,7 +1153,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'RESOLUTIONS=1']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Too big resolution number. Will fallback to default one @@ -1248,7 +1160,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'RESOLUTIONS=100']) gdal.PopErrorHandler() if out_ds is None: - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/jp2openjpeg_26.jp2') @@ -1258,7 +1169,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'NBITS=2']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Error case: unsupported CODEC (J2K) @@ -1266,7 +1176,6 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.j2k', src_ds, options=['INSPIRE_TG=YES']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Error case: invalid CODEBLOCK_WIDTH/HEIGHT @@ -1274,13 +1183,11 @@ def test_jp2openjpeg_26(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'CODEBLOCK_WIDTH=128', 'CODEBLOCK_HEIGHT=32']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_26.jp2', src_ds, options=['INSPIRE_TG=YES', 'CODEBLOCK_WIDTH=32', 'CODEBLOCK_HEIGHT=128']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1491,7 +1398,6 @@ def test_jp2openjpeg_30(): del out_ds if validate('/vsimem/jp2openjpeg_30.jp2', expected_gmljp2=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_30.jp2') @@ -1545,7 +1451,6 @@ def test_jp2openjpeg_30(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_30.jp2', src_ds) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1566,18 +1471,14 @@ def test_jp2openjpeg_31(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_31.jp2', src_ds) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_31.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_31.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetColorInterpretation()) return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2openjpeg_31.jp2') @@ -1591,21 +1492,16 @@ def test_jp2openjpeg_31(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_31.jp2', src_ds) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_31.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_31.jp2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetColorInterpretation()) return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/jp2openjpeg_31.jp2') @@ -1626,7 +1522,6 @@ def test_jp2openjpeg_32(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_32.jp2', src_ds, options=['JP2C_XLBOX=YES']) gdal.PopErrorHandler() if out_ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/jp2openjpeg_32.jp2') @@ -1652,7 +1547,6 @@ def test_jp2openjpeg_33(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_33.jp2', src_ds, options=['BLOCKXSIZE=100000', 'BLOCKYSIZE=100000', 'RESOLUTIONS=5']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' out_ds = None gdal.Unlink('/vsimem/jp2openjpeg_33.jp2') @@ -1672,7 +1566,6 @@ def test_jp2openjpeg_34(): ds = gdal.Open('data/dimensions_above_31bit.jp2') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1690,7 +1583,6 @@ def test_jp2openjpeg_35(): ds = gdal.Open('data/truncated.jp2') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1709,7 +1601,6 @@ def test_jp2openjpeg_36(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_36.jp2', src_ds) gdal.PopErrorHandler() if out_ds is not None or gdal.VSIStatL('/vsimem/jp2openjpeg_36.jp2') is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1728,11 +1619,9 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') if ds.GetMetadata() != {}: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1743,16 +1632,13 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') if ds.GetMetadata() != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') return 'fail' ds = None if 'INSPIRE_TG=YES' in options and validate('/vsimem/jp2openjpeg_37.jp2', expected_gmljp2=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1763,12 +1649,10 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') md = ds.GetMetadata('SOME_DOMAIN') if md != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') print(md) return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1779,11 +1663,9 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=['WRITE_METADATA=YES']) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') if ds.GetMetadata('xml:SOME_DOMAIN')[0] != '\n': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1794,11 +1676,9 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') if ds.GetMetadata('xml:BOX_0')[0] != '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1809,16 +1689,13 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') if ds.GetMetadata('xml:XMP')[0] != '': - gdaltest.post_reason('fail') return 'fail' ds = None if 'INSPIRE_TG=YES' in options and validate('/vsimem/jp2openjpeg_37.jp2', expected_gmljp2=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1830,16 +1707,13 @@ def test_jp2openjpeg_37(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_37.jp2', src_ds, options=options) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_37.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_37.jp2') if ds.GetMetadata('xml:IPR')[0] != '': - gdaltest.post_reason('fail') return 'fail' ds = None if validate('/vsimem/jp2openjpeg_37.jp2', expected_gmljp2=False) == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_37.jp2') @@ -1861,7 +1735,6 @@ def test_jp2openjpeg_38(): src_ds.SetGeoTransform([0, 60, 0, 0, 0, -60]) out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_38.jp2', src_ds, options=['GeoJP2=NO']) if out_ds.GetProjectionRef() != wkt: - gdaltest.post_reason('fail') print(out_ds.GetProjectionRef()) return 'fail' crsdictionary = out_ds.GetMetadata_List("xml:CRSDictionary.gml")[0] @@ -1954,7 +1827,6 @@ def test_jp2openjpeg_39(): del out_ds ds = gdal.Open('/vsimem/jp2openjpeg_39.jp2') if ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' ds = None @@ -2031,14 +1903,12 @@ def test_jp2openjpeg_40(): del out_ds ds = gdal.Open('/vsimem/jp2openjpeg_40.jp2') if ds.GetProjectionRef().find('4326') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (2, 0.1, 0, 49, 0, -0.1) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(got_gt) return 'fail' ds = None @@ -2059,11 +1929,9 @@ def test_jp2openjpeg_41(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_41.jp2', src_ds, options=['USE_SRC_CODESTREAM=YES', 'PROFILE=PROFILE_1', 'GEOJP2=NO', 'GMLJP2=NO']) if src_ds.GetRasterBand(1).Checksum() != out_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') return 'fail' del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_41.jp2').size != 9923: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_41.jp2') gdal.Unlink('/vsimem/jp2openjpeg_41.jp2.aux.xml') @@ -2076,7 +1944,6 @@ def test_jp2openjpeg_41(): gdal.PopErrorHandler() del out_ds if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_41.jp2') gdal.Unlink('/vsimem/jp2openjpeg_41.jp2.aux.xml') @@ -2090,7 +1957,6 @@ def test_jp2openjpeg_41(): gdal.PopErrorHandler() del out_ds if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_41.jp2') @@ -2120,13 +1986,11 @@ def test_jp2openjpeg_42(): ds.SetMetadataItem('FOO', 'BAR') ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Add metadata and GCP ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetMetadata() != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') return 'fail' sr = osr.SpatialReference() sr.ImportFromEPSG(32631) @@ -2134,19 +1998,15 @@ def test_jp2openjpeg_42(): ds.SetGCPs(gcps, sr.ExportToWkt()) ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check we got metadata and GCP, and there's no GMLJP2 box ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetMetadata() != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPCount() != 1: - gdaltest.post_reason('fail') return 'fail' if len(ds.GetMetadataDomainList()) != 2: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' # Unset metadata and GCP @@ -2154,20 +2014,16 @@ def test_jp2openjpeg_42(): ds.SetGCPs([], '') ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check we have no longer metadata or GCP ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetMetadata() != {}: print(ds.GetMetadata()) - gdaltest.post_reason('fail') return 'fail' if ds.GetGCPCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataDomainList() != ['DERIVED_SUBDATASETS']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' # Add projection and geotransform @@ -2175,22 +2031,18 @@ def test_jp2openjpeg_42(): ds.SetGeoTransform([0, 1, 2, 3, 4, 5]) ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check them ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetProjectionRef().find('32631') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' if ds.GetGeoTransform() != (0, 1, 2, 3, 4, 5): - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' # Check that we have a GMLJP2 box if ds.GetMetadataDomainList() != ['xml:gml.root-instance', 'DERIVED_SUBDATASETS']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' # Remove projection and geotransform @@ -2198,21 +2050,17 @@ def test_jp2openjpeg_42(): ds.SetGeoTransform([0, 1, 0, 0, 0, 1]) ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check we have no longer anything ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' if ds.GetGeoTransform() != (0, 1, 0, 0, 0, 1): - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' if ds.GetMetadataDomainList() != ['DERIVED_SUBDATASETS']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' ds = None @@ -2229,17 +2077,14 @@ def test_jp2openjpeg_42(): ds.SetGeoTransform([1, 2, 3, 4, 5, 6]) ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check it and that we don't have GMLJP2 ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetGeoTransform() != (1, 2, 3, 4, 5, 6): - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' if ds.GetMetadataDomainList() != ['DERIVED_SUBDATASETS']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' ds = None @@ -2254,23 +2099,19 @@ def test_jp2openjpeg_42(): # Modify geotransform ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetGeoTransform() != (2, 3, 0, 4, 0, -5): - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' ds.SetGeoTransform([1, 2, 0, 3, 0, -4]) ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check it ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetGeoTransform() != (1, 2, 0, 3, 0, -4): - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' if ds.GetMetadataDomainList() != ['xml:gml.root-instance', 'DERIVED_SUBDATASETS']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' # Add GCPs @@ -2278,29 +2119,24 @@ def test_jp2openjpeg_42(): ds.SetGCPs(gcps, sr.ExportToWkt()) ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check it (a GeoJP2 box has been added and GMLJP2 removed) ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if not ds.GetGCPs(): - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataDomainList() != ['DERIVED_SUBDATASETS']: - gdaltest.post_reason('fail') print(ds.GetMetadataDomainList()) return 'fail' # Add IPR box ds.SetMetadata([''], 'xml:IPR') ds = None if gdal.VSIStatL('/vsimem/jp2openjpeg_42.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' # Check it ds = gdal.Open('/vsimem/jp2openjpeg_42.jp2', gdal.GA_Update) if ds.GetMetadata('xml:IPR')[0] != '': - gdaltest.post_reason('fail') print(ds.GetMetadata('xml:IPR')) return 'fail' ds = None @@ -2361,10 +2197,8 @@ def test_jp2openjpeg_45(): src_ds = gdal.Open('data/byte.tif') out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_45.jp2', src_ds, options=['GMLJP2V2_DEF=YES']) if out_ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetLayer(0) is not None: - gdaltest.post_reason('fail') return 'fail' del out_ds @@ -2429,13 +2263,11 @@ def test_jp2openjpeg_45(): """ if gmljp2 != minimal_instance: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' ret = validate('/vsimem/jp2openjpeg_45.jp2', inspire_tg=False) if ret == 'fail': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/jp2openjpeg_45.jp2') @@ -2446,7 +2278,6 @@ def test_jp2openjpeg_45(): ds = gdal.Open('/vsimem/jp2openjpeg_45.jp2') gmljp2 = ds.GetMetadata_List("xml:gml.root-instance")[0] if gmljp2 != minimal_instance: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' ds = None @@ -2458,7 +2289,6 @@ def test_jp2openjpeg_45(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_45.jp2', src_ds, options=['GMLJP2V2_DEF={']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Non existing file @@ -2467,7 +2297,6 @@ def test_jp2openjpeg_45(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_45.jp2', src_ds, options=['GMLJP2V2_DEF=/vsimem/i_do_not_exist']) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Test JSon conf file as a file @@ -2478,11 +2307,9 @@ def test_jp2openjpeg_45(): ds = gdal.Open('/vsimem/jp2openjpeg_45.jp2') gmljp2 = ds.GetMetadata_List("xml:gml.root-instance")[0] if gmljp2.find('some_gml_id') < 0: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' if gmljp2.find('urn:ogc:def:crs:EPSG::26711') < 0: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' ds = None @@ -2497,7 +2324,6 @@ def test_jp2openjpeg_45(): ds = gdal.Open('/vsimem/jp2openjpeg_45.jp2') gmljp2 = ds.GetMetadata_List("xml:gml.root-instance")[0] if gmljp2.find(predefined[1]) < 0: - gdaltest.post_reason('fail') print(predefined[0]) print(gmljp2) return 'fail' @@ -2513,7 +2339,6 @@ def test_jp2openjpeg_45(): ds = gdal.Open('/vsimem/jp2openjpeg_45.jp2') gmljp2 = ds.GetMetadata_List("xml:gml.root-instance")[0] if gmljp2.find('') < 0: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' ds = None @@ -2536,7 +2361,6 @@ def test_jp2openjpeg_45(): ds = gdal.Open('/vsimem/jp2openjpeg_45.jp2') gmljp2 = ds.GetMetadata_List("xml:gml.root-instance")[0] if gmljp2.find("custom_datarecord") < 0: - gdaltest.post_reason('fail') print(predefined[0]) print(gmljp2) return 'fail' @@ -2557,7 +2381,6 @@ def test_jp2openjpeg_45(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_45.jp2', src_ds, options=['GMLJP2V2_DEF=' + json.dumps(conf)]) gdal.PopErrorHandler() if out_ds is not None: - gdaltest.post_reason('fail') return 'fail' conf = { @@ -2913,14 +2736,12 @@ def test_jp2openjpeg_45(): # Now do the checks dircontent = gdal.ReadDir('/vsimem/gmljp2') if dircontent is not None: - gdaltest.post_reason('fail') print(dircontent) return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_45.jp2') gmljp2 = ds.GetMetadata_List("xml:gml.root-instance")[0] if gmljp2.find('my_GMLJP2RectifiedGridCoverage') < 0: - gdaltest.post_reason('fail') print(gmljp2) return 'fail' first_metadata_pos = gmljp2.find("First metadata") @@ -2970,54 +2791,45 @@ def test_jp2openjpeg_45(): style4_pos < extension1_pos and extension1_pos < extension3_pos and extension3_pos < extension4_pos): - gdaltest.post_reason('fail') print(gmljp2) return 'fail' # print(gmljp2) myshape_gml = ds.GetMetadata_List("xml:myshape.gml")[0] if myshape_gml.find("""""") < 0: - gdaltest.post_reason('fail') print(myshape_gml) return 'fail' if myshape_gml.find("""http://www.opengis.net/def/crs/EPSG/0/4326""") < 0: - gdaltest.post_reason('fail') print(myshape_gml) return 'fail' myshape_xsd = ds.GetMetadata_List("xml:myshape.xsd")[0] if myshape_xsd.find("""""") < 0: - gdaltest.post_reason('fail') print(myshape_xsd) return 'fail' myshape2_gml = ds.GetMetadata_List("xml:myshape2.gml")[0] if myshape2_gml.find("""""") < 0: - gdaltest.post_reason('fail') print(myshape2_gml) return 'fail' feature2_gml = ds.GetMetadata_List("xml:feature2.gml")[0] if feature2_gml.find("""""") < 0: - gdaltest.post_reason('fail') print(feature2_gml) return 'fail' feature3_gml = ds.GetMetadata_List("xml:feature3.gml")[0] if feature3_gml.find("""""") < 0: - gdaltest.post_reason('fail') print(feature3_gml) return 'fail' myshape2_xsd = ds.GetMetadata_List("xml:a_schema.xsd")[0] if myshape2_xsd.find("""1 str trueX my_value yeah: """) < 0: - gdaltest.post_reason('fail') print(gmljp2) if gmljp2.find("""1 str true""") >= 0: return 'skip' @@ -3219,7 +3019,6 @@ def test_jp2openjpeg_46(): gdal.Unlink('/vsimem/jp2openjpeg_46.jp2') if gmljp2.find('') >= 0: - gdaltest.post_reason('fail') print(invalid_template) print(gmljp2) return 'fail' @@ -3315,12 +3114,10 @@ def test_jp2openjpeg_47(): out_ds = gdaltest.jp2openjpeg_drv.CreateCopy('/vsimem/jp2openjpeg_47.jp2', src_ds) del out_ds if gdal.VSIStatL('/vsimem/jp2openjpeg_47.jp2.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/jp2openjpeg_47.jp2') if ds.GetMetadata('RPC') is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3340,11 +3137,9 @@ def test_jp2openjpeg_48(): ds = gdal.Open('data/byte_tile_2048.jp2') (blockxsize, blockysize) = ds.GetRasterBand(1).GetBlockSize() if (blockxsize, blockysize) != (20, 20): - gdaltest.post_reason('fail') print(blockxsize, blockysize) return 'fail' if ds.GetRasterBand(1).Checksum() != 4610: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3692,13 +3487,11 @@ def test_jp2openjpeg_codeblock_style(): gdaltest.jp2openjpeg_drv.CreateCopy(filename, gdal.Open('data/byte.tif'), options=options) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(filename) cs = ds.GetRasterBand(1).Checksum() ds = None if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -3706,14 +3499,12 @@ def test_jp2openjpeg_codeblock_style(): gdaltest.jp2openjpeg_drv.CreateCopy(filename, gdal.Open('data/byte.tif'), options=['CODEBLOCK_STYLE=64']) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): gdaltest.jp2openjpeg_drv.CreateCopy(filename, gdal.Open('data/byte.tif'), options=['CODEBLOCK_STYLE=UNSUPPORTED']) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdaltest.jp2openjpeg_drv.Delete(filename) diff --git a/autotest/gdrivers/jpeg.py b/autotest/gdrivers/jpeg.py index baa2a2732d48..0e64b2958b6a 100755 --- a/autotest/gdrivers/jpeg.py +++ b/autotest/gdrivers/jpeg.py @@ -583,16 +583,12 @@ def test_jpeg_16(): ds = gdal.Open('tmp/albania.jpg') if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' # "Internal" overview @@ -602,14 +598,12 @@ def test_jpeg_16(): else: expected_cs = 31892 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' # Build external overviews ds.BuildOverviews('NEAR', [2, 4]) if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' # Check updated checksum cs = ds.GetRasterBand(1).GetOverview(0).Checksum() @@ -618,7 +612,6 @@ def test_jpeg_16(): else: expected_cs = 32460 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -627,7 +620,6 @@ def test_jpeg_16(): # Check we are using external overviews ds = gdal.Open('tmp/albania.jpg') if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if gdaltest.jpeg_version in ('8', '9b'): @@ -635,7 +627,6 @@ def test_jpeg_16(): else: expected_cs = 32460 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -654,7 +645,6 @@ def test_jpeg_17(): if (ds is not None or gdal.GetLastErrorType() != gdal.CE_Failure or gdal.GetLastErrorMsg() == ''): - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -666,7 +656,6 @@ def test_jpeg_17(): gdal.GetLastErrorMsg() == ''): # libjpeg-turbo 1.4.0 doesn't emit errors... if cs != 4925: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -678,7 +667,6 @@ def test_jpeg_17(): if (gdal.GetLastErrorType() != gdal.CE_Warning or gdal.GetLastErrorMsg() == ''): - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -692,7 +680,6 @@ def test_jpeg_17(): if (gdal.GetLastErrorType() != gdal.CE_Failure or gdal.GetLastErrorMsg() == ''): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -734,11 +721,9 @@ def test_jpeg_18(): return 'fail' line1023_bis = ds.GetRasterBand(1).ReadRaster(0, height - 1, width, 1) if line1023_bis == line0 or line1023 != line1023_bis: - gdaltest.post_reason('fail') return 'fail' line0_bis = ds.GetRasterBand(1).ReadRaster(0, 0, width, 1) if line0 != line0_bis: - gdaltest.post_reason('fail') return 'fail' line255_ovr1 = ds.GetRasterBand(1).GetOverview(1).ReadRaster( 0, int(height / 4) - 1, int(width / 4), 1) @@ -747,17 +732,14 @@ def test_jpeg_18(): return 'fail' line0_bis = ds.GetRasterBand(1).ReadRaster(0, 0, width, 1) if line0 != line0_bis: - gdaltest.post_reason('fail') return 'fail' line0_ovr1_bis = ds.GetRasterBand(1).GetOverview(1).ReadRaster( 0, 0, int(width / 4), 1) if line0_ovr1 != line0_ovr1_bis: - gdaltest.post_reason('fail') return 'fail' line255_ovr1_bis = ds.GetRasterBand(1).GetOverview(1).ReadRaster( 0, int(height / 4) - 1, int(width / 4), 1) if line255_ovr1 != line255_ovr1_bis: - gdaltest.post_reason('fail') return 'fail' gdal.SetCacheMax(oldSize) @@ -811,11 +793,9 @@ def test_jpeg_19(): if (width, height, iX) == (24, 25, 8): if data1 != data2: - gdaltest.post_reason('fail') return 'fail' else: if data1 == data2: - gdaltest.post_reason('fail') return 'fail' # Check the file with the LSB bit mask order @@ -824,7 +804,6 @@ def test_jpeg_19(): 0, 0, width, height) ds = None if tiff_mask_data != jpg_mask_data: - gdaltest.post_reason('fail') return 'fail' # Check the file with the MSB bit mask order @@ -833,7 +812,6 @@ def test_jpeg_19(): 0, 0, width, height) ds = None if tiff_mask_data != jpg_mask_data: - gdaltest.post_reason('fail') return 'fail' gdal.GetDriverByName('GTiff').Delete('/vsimem/jpeg_19.tif') @@ -854,14 +832,11 @@ def test_jpeg_20(): ds = gdal.Open('/vsimem/jpeg_20.jpg') if ds.GetGCPProjection().find('GEOGCS["WGS 84"') != 0: - gdaltest.post_reason('failure') print(ds.GetGCPProjection()) return 'fail' if ds.GetGCPCount() != 4: - gdaltest.post_reason('failure') return 'fail' if len(ds.GetGCPs()) != 4: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -877,7 +852,6 @@ def test_jpeg_21(): ds = gdal.Open('data/black_with_white_exif_ovr.jpg') if ds.GetRasterBand(1).GetOverviewCount() != 3: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' expected_dim_cs = [[512, 512, 0], [256, 256, 0], [196, 196, 12681]] @@ -888,7 +862,6 @@ def test_jpeg_21(): if (ovr.XSize != expected_w or ovr.YSize != expected_h or cs != expected_cs): - gdaltest.post_reason('failure') print(ovr.XSize) print(ovr.YSize) print(cs) @@ -910,13 +883,11 @@ def test_jpeg_22(): '/vsimem/jpeg_22.jpg', src_ds, options=['EXIF_THUMBNAIL=YES']) src_ds = None if ds.GetRasterBand(1).GetOverviewCount() != 4: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' ovr = ds.GetRasterBand(1).GetOverview(3) cs = ovr.Checksum() if ovr.XSize != 128 or ovr.YSize != 64 or cs != 34957: - gdaltest.post_reason('failure') print(ovr.XSize) print(ovr.YSize) print(cs) @@ -931,7 +902,6 @@ def test_jpeg_22(): src_ds = None ovr = ds.GetRasterBand(1).GetOverview(3) if ovr.XSize != 64 or ovr.YSize != 128: - gdaltest.post_reason('failure') print(ovr.XSize) print(ovr.YSize) return 'fail' @@ -946,10 +916,8 @@ def test_jpeg_22(): src_ds = None ovr = ds.GetRasterBand(1).GetOverview(3) if ds.GetMetadataItem('COMMENT') != 'foo': - gdaltest.post_reason('failure') return 'fail' if ovr.XSize != 40 or ovr.YSize != 80: - gdaltest.post_reason('failure') print(ovr.XSize) print(ovr.YSize) return 'fail' @@ -963,7 +931,6 @@ def test_jpeg_22(): src_ds = None ovr = ds.GetRasterBand(1).GetOverview(3) if ovr.XSize != 30 or ovr.YSize != 60: - gdaltest.post_reason('failure') print(ovr.XSize) print(ovr.YSize) return 'fail' @@ -979,7 +946,6 @@ def test_jpeg_22(): src_ds = None ovr = ds.GetRasterBand(1).GetOverview(3) if ovr.XSize != 50 or ovr.YSize != 40: - gdaltest.post_reason('failure') print(ovr.XSize) print(ovr.YSize) return 'fail' @@ -1004,7 +970,6 @@ def test_jpeg_23(): tmp_ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data) got_cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != got_cs: - gdaltest.post_reason('failure') return 'fail' # Pixel interleaved @@ -1016,7 +981,6 @@ def test_jpeg_23(): buf_pixel_space=3, buf_band_space=1) got_cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != got_cs: - gdaltest.post_reason('failure') return 'fail' # Pixel interleaved with padding @@ -1028,7 +992,6 @@ def test_jpeg_23(): buf_pixel_space=4, buf_band_space=1) got_cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != got_cs: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1120,7 +1083,6 @@ def test_jpeg_27(): with gdaltest.error_handler(): cs = ds.GetRasterBand(1).Checksum() if cs != 0 or gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' # Should error out with 'Scan number... @@ -1133,7 +1095,6 @@ def test_jpeg_27(): gdal.SetConfigOption('GDAL_ALLOW_LARGE_LIBJPEG_MEM_ALLOC', None) gdal.SetConfigOption('GDAL_JPEG_MAX_ALLOWED_SCAN_NUMBER', None) if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1152,7 +1113,6 @@ def test_jpeg_28(): src_ds = None ds = gdal.Open(tmpfilename) if ds.GetMetadata(): - gdaltest.post_reason('fail') return 'fail' # EXIF tags only @@ -1184,13 +1144,11 @@ def test_jpeg_28(): gdal.GetDriverByName('JPEG').CreateCopy(tmpfilename, src_ds) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_md = ds.GetMetadata() expected_md = {'EXIF_DateTimeDigitized': '0123456789012345678', 'EXIF_DateTimeOriginal': '0123456789012345678', 'EXIF_Orientation': '10', 'EXIF_ApertureValue': '(0)', 'EXIF_YResolution': '(96)', 'EXIF_XResolution': '(96)', 'EXIF_TransferFunction': '0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0', 'EXIF_ExifVersion': '0123', 'EXIF_DateTime': 'dt ', 'EXIF_FlashpixVersion': 'ABCD', 'EXIF_ComponentsConfiguration': '0x1f 0x00 0x00 0x00', 'EXIF_Make': 'make', 'EXIF_StandardOutputSensitivity': '123456789', 'EXIF_ResolutionUnit': '2', 'EXIF_CompressedBitsPerPixel': '(0)', 'EXIF_SpatialFrequencyResponse': '0xab 0xcd', 'EXIF_ISOSpeedRatings': '1 2 3'} if got_md != expected_md: - gdaltest.post_reason('fail') print(got_md) return 'fail' @@ -1201,13 +1159,11 @@ def test_jpeg_28(): gdal.GetDriverByName('JPEG').CreateCopy(tmpfilename, src_ds) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_val = ds.GetMetadataItem('EXIF_ShutterSpeedValue') got_val = got_val.replace('(', '').replace(')', '') if float(got_val) != val: - gdaltest.post_reason('fail') print(val) print(ds.GetMetadataItem('EXIF_ShutterSpeedValue')) return 'fail' @@ -1219,13 +1175,11 @@ def test_jpeg_28(): gdal.GetDriverByName('JPEG').CreateCopy(tmpfilename, src_ds) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_val = ds.GetMetadataItem('EXIF_ApertureValue') got_val = got_val.replace('(', '').replace(')', '') if float(got_val) != val: - gdaltest.post_reason('fail') print(val) print(ds.GetMetadataItem('EXIF_ApertureValue')) return 'fail' @@ -1237,12 +1191,10 @@ def test_jpeg_28(): gdal.GetDriverByName('JPEG').CreateCopy(tmpfilename, src_ds) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_md = ds.GetMetadata() if got_md != {'EXIF_GPSLatitudeRef': 'N', 'EXIF_GPSLatitude': '(49) (34) (56.5)'}: - gdaltest.post_reason('fail') print(got_md) return 'fail' ds = None @@ -1254,12 +1206,10 @@ def test_jpeg_28(): gdal.GetDriverByName('JPEG').CreateCopy(tmpfilename, src_ds) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_md = ds.GetMetadata() if got_md != {'EXIF_ExifVersion': '0231', 'EXIF_GPSLatitudeRef': 'N'}: - gdaltest.post_reason('fail') print(got_md) return 'fail' ds = None @@ -1273,12 +1223,10 @@ def test_jpeg_28(): gdal.GetDriverByName('JPEG').CreateCopy(tmpfilename, src_ds) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_md = ds.GetMetadata() if got_md != {'EXIF_ExifVersion': '0231', 'EXIF_invalid': 'foo', 'FOO': 'BAR'}: - gdaltest.post_reason('fail') print(got_md) return 'fail' ds = None @@ -1299,16 +1247,13 @@ def test_jpeg_28(): options=['EXIF_THUMBNAIL=YES', 'THUMBNAIL_WIDTH=32', 'THUMBNAIL_HEIGHT=32']) src_ds = None if gdal.VSIStatL(tmpfilename + '.aux.xml') is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open(tmpfilename) got_md = ds.GetMetadata() if got_md != {'EXIF_ExifVersion': '0231', 'EXIF_GPSLatitudeRef': 'N'}: - gdaltest.post_reason('fail') print(got_md) return 'fail' if ds.GetRasterBand(1).GetOverview(ds.GetRasterBand(1).GetOverviewCount() - 1).XSize != 32: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/jpeg2000.py b/autotest/gdrivers/jpeg2000.py index 4f9554e30c3b..b98a1b8d15d1 100755 --- a/autotest/gdrivers/jpeg2000.py +++ b/autotest/gdrivers/jpeg2000.py @@ -290,7 +290,6 @@ def test_jpeg2000_11(): return 'fail' got_cs = fourth_band.Checksum() if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' jp2_bands_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize) @@ -306,22 +305,18 @@ def test_jpeg2000_11(): tmp_ds = None gdal.GetDriverByName('GTiff').Delete('/vsimem/jpeg2000_11.tif') if got_cs != 8527: - gdaltest.post_reason('fail') print(got_cs) return 'fail' if jp2_bands_data != gtiff_bands_data: - gdaltest.post_reason('fail') return 'fail' if jp2_fourth_band_data != gtiff_fourth_band_data: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/stefan_full_rgba_alpha_1bit.jp2', open_options=['1BIT_ALPHA_PROMOTION=NO']) fourth_band = ds.GetRasterBand(4) if fourth_band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '1': - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/jpeg_profile.py b/autotest/gdrivers/jpeg_profile.py index 08eabc5ea909..8396f5a9090a 100755 --- a/autotest/gdrivers/jpeg_profile.py +++ b/autotest/gdrivers/jpeg_profile.py @@ -63,7 +63,6 @@ def test_jpeg_copy_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -73,7 +72,6 @@ def test_jpeg_copy_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') @@ -106,7 +104,6 @@ def test_jpeg_copy_options_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -116,7 +113,6 @@ def test_jpeg_copy_options_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') @@ -157,17 +153,14 @@ def test_jpeg_copy_icc_64K(): try: os.stat('tmp/icc_test.jpg.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if comment != 'foo': - gdaltest.post_reason('fail') return 'fail' if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -177,13 +170,11 @@ def test_jpeg_copy_icc_64K(): try: os.stat('tmp/icc_test.jpg.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with GetMetadataItem() @@ -193,13 +184,11 @@ def test_jpeg_copy_icc_64K(): try: os.stat('tmp/icc_test.jpg.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if source_icc_profile != icc: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') diff --git a/autotest/gdrivers/kea.py b/autotest/gdrivers/kea.py index c1dacc0e3fe7..f9a6faa23df0 100755 --- a/autotest/gdrivers/kea.py +++ b/autotest/gdrivers/kea.py @@ -110,19 +110,15 @@ def test_kea_4(): ds = gdaltest.kea_driver.Create("/non_existing_path/non_existing_path", 1, 1) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' src_ds = gdaltest.kea_driver.Create('tmp/src.kea', 1, 1, 0) if src_ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdaltest.kea_driver.CreateCopy("tmp/out.kea", src_ds) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 0: - gdaltest.post_reason('fail') return 'fail' src_ds = None ds = None @@ -137,14 +133,12 @@ def test_kea_4(): ret = ds.SetProjection('a') gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ds.SetGeoTransform([1, 2, 3, 4, 5, 6]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Disabled for now since some of them cause memory leaks or @@ -154,42 +148,36 @@ def test_kea_4(): ret = ds.SetMetadataItem('foo', 'bar') gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ds.SetMetadata({'foo': 'bar'}) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ds.GetRasterBand(1).SetMetadataItem('foo', 'bar') gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ds.GetRasterBand(1).SetMetadata({'foo': 'bar'}) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ds.SetGCPs([], "") gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ds.AddBand(gdal.GDT_Byte) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).WriteRaster(0, 0, 1, 1, '\0') @@ -198,7 +186,6 @@ def test_kea_4(): ds.FlushCache() gdal.PopErrorHandler() if ds.GetRasterBand(1).Checksum() != 3: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -223,23 +210,18 @@ def test_kea_5(): ds = None ds = gdal.Open('tmp/out.kea') if ds.GetRasterBand(1).GetBlockSize() != [15, 15]: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetBlockSize()) return 'fail' if ds.GetRasterBand(1).GetMetadataItem('LAYER_TYPE') != 'thematic': - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMetadata()) return 'fail' if ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' if ds.GetGeoTransform() != (0, 1, 0, 0, 0, -1): - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' if ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' ds = None @@ -265,83 +247,63 @@ def test_kea_6(): ds.GetRasterBand(4).SetMetadataItem('LAYER_TYPE', 'thematic') ds.GetRasterBand(5).SetMetadataItem('LAYER_TYPE', 'athematic') if ds.SetMetadata({'foo': 'bar'}, 'other_domain') == 0: - gdaltest.post_reason('fail') return 'fail' if ds.SetMetadataItem('foo', 'bar', 'other_domain') == 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetMetadata({'foo': 'bar'}, 'other_domain') == 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetMetadataItem('foo', 'bar', 'other_domain') == 0: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('tmp/out.kea') if ds.GetMetadata('other_domain') != {}: - gdaltest.post_reason('fail') print(ds.GetMetadata('other_domain')) return 'fail' if ds.GetMetadataItem('item', 'other_domain') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadata('other_domain') != {}: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('item', 'other_domain') is not None: - gdaltest.post_reason('fail') return 'fail' md = ds.GetMetadata() if md['foo'] != 'bar': - gdaltest.post_reason('fail') print(md) return 'fail' if ds.GetMetadataItem('foo') != 'bar': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('foo')) return 'fail' if ds.GetMetadataItem('bar') != 'baw': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('bar')) return 'fail' if ds.GetRasterBand(1).GetDescription() != 'desc': - gdaltest.post_reason('fail') return 'fail' md = ds.GetRasterBand(1).GetMetadata() if md['bar'] != 'baz': - gdaltest.post_reason('fail') print(md) return 'fail' if ds.GetRasterBand(1).GetMetadataItem('bar') != 'baz': - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMetadataItem('bar')) return 'fail' if ds.GetRasterBand(2).GetMetadataItem('LAYER_TYPE') != 'thematic': - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).GetMetadataItem('LAYER_TYPE')) return 'fail' if ds.GetRasterBand(3).GetMetadataItem('LAYER_TYPE') != 'athematic': - gdaltest.post_reason('fail') print(ds.GetRasterBand(3).GetMetadataItem('LAYER_TYPE')) return 'fail' if ds.GetRasterBand(4).GetMetadataItem('LAYER_TYPE') != 'thematic': - gdaltest.post_reason('fail') print(ds.GetRasterBand(4).GetMetadataItem('LAYER_TYPE')) return 'fail' if ds.GetRasterBand(5).GetMetadataItem('LAYER_TYPE') != 'athematic': - gdaltest.post_reason('fail') print(ds.GetRasterBand(5).GetMetadataItem('LAYER_TYPE')) return 'fail' out2_ds = gdaltest.kea_driver.CreateCopy('tmp/out2.kea', ds) ds = None if out2_ds.GetMetadataItem('foo') != 'bar': - gdaltest.post_reason('fail') print(out2_ds.GetMetadataItem('foo')) return 'fail' if out2_ds.GetRasterBand(1).GetMetadataItem('bar') != 'baz': - gdaltest.post_reason('fail') print(out2_ds.GetRasterBand(1).GetMetadataItem('bar')) return 'fail' @@ -363,13 +325,10 @@ def test_kea_7(): # Geotransform ds = gdaltest.kea_driver.Create("tmp/out.kea", 1, 1) if ds.GetGCPCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.SetGeoTransform([1, 2, 3, 4, 5, 6]) != 0: - gdaltest.post_reason('fail') return 'fail' if ds.SetProjection('foo') != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -377,14 +336,11 @@ def test_kea_7(): out2_ds = gdaltest.kea_driver.CreateCopy('tmp/out2.kea', ds) ds = None if out2_ds.GetGCPCount() != 0: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetGeoTransform() != (1, 2, 3, 4, 5, 6): - gdaltest.post_reason('fail') print(out2_ds.GetGeoTransform()) return 'fail' if out2_ds.GetProjectionRef() != 'foo': - gdaltest.post_reason('fail') print(out2_ds.GetProjectionRef()) return 'fail' out2_ds = None @@ -407,10 +363,8 @@ def test_kea_7(): ds = None if out2_ds.GetGCPCount() != 2: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetGCPProjection() != 'foo': - gdaltest.post_reason('fail') return 'fail' got_gcps = out2_ds.GetGCPs() for i in range(2): @@ -420,7 +374,6 @@ def test_kea_7(): got_gcps[i].Info != gcps[i].Info: print(i) print(got_gcps[i]) - gdaltest.post_reason('fail') return 'fail' out2_ds = None @@ -440,22 +393,18 @@ def test_kea_8(): for i in range(2): ds = gdaltest.kea_driver.Create("tmp/out.kea", 1, 1) if ds.GetRasterBand(1).GetColorTable() is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetColorTable(None) == 0: # not allowed by the driver - gdaltest.post_reason('fail') return 'fail' ct = gdal.ColorTable() ct.SetColorEntry(0, (0, 255, 0, 255)) ct.SetColorEntry(1, (255, 0, 255, 255)) ct.SetColorEntry(2, (0, 0, 255, 255)) if ds.GetRasterBand(1).SetColorTable(ct) != 0: - gdaltest.post_reason('fail') return 'fail' if i == 1: # And again if ds.GetRasterBand(1).SetColorTable(ct) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -487,7 +436,6 @@ def test_kea_9(): ds = gdaltest.kea_driver.Create("tmp/out.kea", 1, 1, gdal.GCI_YCbCr_CrBand - gdal.GCI_GrayIndex + 1) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' for i in range(gdal.GCI_GrayIndex, gdal.GCI_YCbCr_CrBand + 1): ds.GetRasterBand(i).SetColorInterpretation(i) @@ -543,7 +491,6 @@ def test_kea_10(): ]: ds = gdaltest.kea_driver.Create("tmp/out.kea", 1, 1, 1, dt) if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetNoDataValue(nd) if ds.GetRasterBand(1).GetNoDataValue() != expected_nd: @@ -566,7 +513,6 @@ def test_kea_10(): ds = gdal.Open('tmp/out2.kea') if ds.GetRasterBand(1).GetNoDataValue() is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -588,22 +534,17 @@ def test_kea_11(): ds = gdal.Open('tmp/out.kea', gdal.GA_Update) if ds.AddBand(gdal.GDT_Byte) != 0: - gdaltest.post_reason('fail') return 'fail' if ds.AddBand(gdal.GDT_Int16, options=['DEFLATE=9']) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('tmp/out.kea') if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).DataType != gdal.GDT_Byte: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).DataType != gdal.GDT_Int16: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -621,15 +562,12 @@ def test_kea_12(): ds = gdaltest.kea_driver.Create("tmp/out.kea", 1, 1, 1, gdal.GDT_Byte) if ds.GetRasterBand(1).GetDefaultRAT().GetColumnCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).SetDefaultRAT(None) == 0: # not allowed by the driver - gdaltest.post_reason('fail') return 'fail' rat = ds.GetRasterBand(1).GetDefaultRAT() rat.CreateColumn('col_real_generic', gdal.GFT_Real, gdal.GFU_Generic) if ds.GetRasterBand(1).SetDefaultRAT(rat) != 0: - gdaltest.post_reason('fail') return 'fail' rat = ds.GetRasterBand(1).GetDefaultRAT() rat.CreateColumn('col_integer_pixelcount', gdal.GFT_Real, gdal.GFU_PixelCount) @@ -654,7 +592,6 @@ def test_kea_12(): cloned_rat = rat.Clone() if ds.GetRasterBand(1).SetDefaultRAT(rat) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -664,45 +601,33 @@ def test_kea_12(): for i in range(7): if rat.GetColOfUsage(rat.GetUsageOfCol(i)) != i: - gdaltest.post_reason('fail') print(i) print(rat.GetColOfUsage(rat.GetUsageOfCol(i))) return 'fail' if cloned_rat.GetNameOfCol(0) != 'col_real_generic': - gdaltest.post_reason('fail') return 'fail' if cloned_rat.GetTypeOfCol(0) != gdal.GFT_Real: - gdaltest.post_reason('fail') return 'fail' if cloned_rat.GetUsageOfCol(0) != gdal.GFU_Generic: - gdaltest.post_reason('fail') return 'fail' if cloned_rat.GetUsageOfCol(1) != gdal.GFU_PixelCount: - gdaltest.post_reason('fail') return 'fail' if cloned_rat.GetTypeOfCol(2) != gdal.GFT_String: - gdaltest.post_reason('fail') return 'fail' if cloned_rat.GetTypeOfCol(3) != gdal.GFT_Integer: - gdaltest.post_reason('fail') return 'fail' if rat.GetColumnCount() != cloned_rat.GetColumnCount(): - gdaltest.post_reason('fail') return 'fail' if rat.GetRowCount() != cloned_rat.GetRowCount(): - gdaltest.post_reason('fail') return 'fail' for i in range(rat.GetColumnCount()): if rat.GetNameOfCol(i) != cloned_rat.GetNameOfCol(i): - gdaltest.post_reason('fail') return 'fail' if rat.GetTypeOfCol(i) != cloned_rat.GetTypeOfCol(i): - gdaltest.post_reason('fail') return 'fail' if rat.GetUsageOfCol(i) != cloned_rat.GetUsageOfCol(i): - gdaltest.post_reason('fail') print(i) print(rat.GetUsageOfCol(i)) print(cloned_rat.GetUsageOfCol(i)) @@ -737,34 +662,25 @@ def test_kea_12(): gdal.PopErrorHandler() if rat.GetValueAsDouble(0, 0) != 1.23: - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsInt(0, 0) != 1: - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsString(0, 0) != '1.23': - gdaltest.post_reason('fail') print(rat.GetValueAsString(0, 0)) return 'fail' if rat.GetValueAsInt(0, 3) != 123: - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsDouble(0, 3) != 123: - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsString(0, 3) != '123': - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsString(0, 2) != 'foo': - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsInt(0, 2) != 0: - gdaltest.post_reason('fail') return 'fail' if rat.GetValueAsDouble(0, 2) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -791,22 +707,16 @@ def test_kea_13(): ds = gdal.Open('tmp/out.kea') out2_ds = gdaltest.kea_driver.CreateCopy('tmp/out2.kea', ds) # yes CreateCopy() of KEA copies overviews if out2_ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetRasterBand(1).GetOverview(0).Checksum() != 1087: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetRasterBand(1).GetOverview(0).GetDefaultRAT() is not None: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetRasterBand(1).GetOverview(0).SetDefaultRAT(None) == 0: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetRasterBand(1).GetOverview(1) is not None: - gdaltest.post_reason('fail') return 'fail' out2_ds = None ds = None @@ -826,35 +736,28 @@ def test_kea_14(): ds = gdaltest.kea_driver.Create("tmp/out.kea", 1, 1, 1, gdal.GDT_Byte) if ds.GetRasterBand(1).GetMaskFlags() != gdal.GMF_ALL_VALID: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskBand().Checksum() != 3: print(ds.GetRasterBand(1).GetMaskBand().Checksum()) - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).CreateMaskBand(0) if ds.GetRasterBand(1).GetMaskFlags() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskBand().Checksum() != 3: print(ds.GetRasterBand(1).GetMaskBand().Checksum()) - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).GetMaskBand().Fill(0) if ds.GetRasterBand(1).GetMaskBand().Checksum() != 0: print(ds.GetRasterBand(1).GetMaskBand().Checksum()) - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.Open('tmp/out.kea') out2_ds = gdaltest.kea_driver.CreateCopy('tmp/out2.kea', ds) # yes CreateCopy() of KEA copies overviews if out2_ds.GetRasterBand(1).GetMaskFlags() != 0: - gdaltest.post_reason('fail') return 'fail' if out2_ds.GetRasterBand(1).GetMaskBand().Checksum() != 0: print(out2_ds.GetRasterBand(1).GetMaskBand().Checksum()) - gdaltest.post_reason('fail') return 'fail' out2_ds = None ds = None diff --git a/autotest/gdrivers/kmlsuperoverlay.py b/autotest/gdrivers/kmlsuperoverlay.py index be22f66c7231..e08c75b5f0d1 100755 --- a/autotest/gdrivers/kmlsuperoverlay.py +++ b/autotest/gdrivers/kmlsuperoverlay.py @@ -146,27 +146,22 @@ def test_kmlsuperoverlay_4(): src_ds = gdal.Open("/vsimem/src.vrt") ds = gdal.GetDriverByName('KMLSUPEROVERLAY').CreateCopy('/vsimem/kmlsuperoverlay_4.kmz', src_ds, options=['FORMAT=PNG', 'NAME=myname', 'DESCRIPTION=mydescription', 'ALTITUDE=10', 'ALTITUDEMODE=absolute']) if ds.GetMetadataItem('NAME') != 'myname': - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadataItem('DESCRIPTION') != 'mydescription': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') ds = None src_ds = None gdal.Unlink("/vsimem/src.vrt") gdal.Unlink("/vsimem/kmlsuperoverlay_4.kmz") return 'fail' if ds.GetRasterBand(1).GetOverview(0).Checksum() != 30111: - gdaltest.post_reason('fail') ds = None src_ds = None gdal.Unlink("/vsimem/src.vrt") gdal.Unlink("/vsimem/kmlsuperoverlay_4.kmz") return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') ds = None src_ds = None gdal.Unlink("/vsimem/src.vrt") @@ -179,7 +174,6 @@ def test_kmlsuperoverlay_4(): ref_data = ds.ReadRaster(0, 0, 800, 400, 200, 100) vrt_ds = None if got_data != ref_data: - gdaltest.post_reason('fail') ds = None src_ds = None gdal.Unlink("/vsimem/src.vrt") @@ -271,31 +265,25 @@ def test_kmlsuperoverlay_6(): ds = gdal.Open('data/kmlimage.kmz') if ds.GetProjectionRef().find('WGS_1984') < 0: - gdaltest.post_reason('failure') return 'fail' got_gt = ds.GetGeoTransform() ref_gt = [1.2554125761846773, 1.6640895429971981e-05, 0.0, 43.452120815728101, 0.0, -1.0762348187666334e-05] for i in range(6): if abs(got_gt[i] - ref_gt[i]) > 1e-6: - gdaltest.post_reason('failure') print(got_gt) return 'fail' for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != 47673: print(cs) - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(i + 1).GetRasterColorInterpretation() != gdal.GCI_RedBand + i: - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('failure') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 61070: print(cs) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -308,23 +296,19 @@ def test_kmlsuperoverlay_7(): ds = gdal.Open('data/small_world.kml') if ds.GetProjectionRef().find('WGS_1984') < 0: - gdaltest.post_reason('failure') return 'fail' got_gt = ds.GetGeoTransform() ref_gt = [-180.0, 0.9, 0.0, 90.0, 0.0, -0.9] for i in range(6): if abs(got_gt[i] - ref_gt[i]) > 1e-6: - gdaltest.post_reason('failure') print(got_gt) return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 30111: print(cs) - gdaltest.post_reason('failure') return 'fail' if ds.GetRasterBand(1).GetRasterColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -418,15 +402,12 @@ def test_kmlsuperoverlay_8(): src_ds = None if set(os.listdir('tmp/0/0')) != set(('0.kml', '0.png')): - gdaltest.post_reason('failure') return 'fail' if set(os.listdir('tmp/3/1')) != set(('0.jpg', '0.kml', '1.jpg', '1.kml', '2.jpg', '2.kml', '3.jpg', '3.kml', '4.jpg', '4.kml', '5.jpg', '5.kml', '6.jpg', '6.kml', '7.jpg', '7.kml',)): - gdaltest.post_reason('failure') return 'fail' if set(os.listdir('tmp/3/2')) != set(): # dir should be empty - 3/2 is entirely transparent so we skip generating files. - gdaltest.post_reason('failure') return 'fail' shutil.rmtree('tmp/0') diff --git a/autotest/gdrivers/l1b.py b/autotest/gdrivers/l1b.py index 4a58a632eeb5..e92346183842 100755 --- a/autotest/gdrivers/l1b.py +++ b/autotest/gdrivers/l1b.py @@ -102,12 +102,10 @@ def test_l1b_geoloc(): ds = gdal.Open('L1BGCPS_INTERPOL:"tmp/cache/n12gac8bit.l1b"') cs = ds.GetRasterBand(1).Checksum() if cs != 62397: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(2).Checksum() if cs != 52616: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -138,7 +136,6 @@ def test_l1b_solar_zenith_angles_before_noaa_15(): ds = gdal.Open('L1B_SOLAR_ZENITH_ANGLES:"tmp/cache/n12gac10bit.l1b"') cs = ds.GetRasterBand(1).Checksum() if cs != 22924: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -201,17 +198,14 @@ def test_l1b_angles_after_noaa_15(): ds = gdal.Open('L1B_ANGLES:"tmp/cache/n16gac10bit.l1b"') cs = ds.GetRasterBand(1).Checksum() if cs != 31487: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(2).Checksum() if cs != 23380: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(3).Checksum() if cs != 64989: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -242,7 +236,6 @@ def test_l1b_clouds_after_noaa_15(): ds = gdal.Open('L1B_CLOUDS:"tmp/cache/n16gac10bit.l1b"') cs = ds.GetRasterBand(1).Checksum() if cs != 0: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -288,16 +281,12 @@ def test_l1b_little_endian(): ds = gdal.Open('/vsizip/data/hrpt_little_endian.l1b.zip') if ds.GetGCPProjection().find('GRS80') < 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).Checksum() != 14145: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskFlags() != gdal.GMF_PER_DATASET: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskBand().Checksum() != 25115: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/mbtiles.py b/autotest/gdrivers/mbtiles.py index afb2a9387778..fb556944fd43 100755 --- a/autotest/gdrivers/mbtiles.py +++ b/autotest/gdrivers/mbtiles.py @@ -342,41 +342,34 @@ def test_mbtiles_5(): ds = gdal.OpenEx('/vsimem/mbtiles_5.mbtiles', open_options=['BAND_COUNT=2']) if ds.RasterXSize != 19 or ds.RasterYSize != 19: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.RasterCount != 2: - gdaltest.post_reason('fail') print(ds.RasterCount) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-13095853.550435878, 76.437028285176254, 0.0, 4015708.8887064462, 0.0, -76.437028285176254) for i in range(6): if abs(expected_gt[i] - got_gt[i]) > 1e-6: - gdaltest.post_reason('fail') print(got_gt) print(expected_gt) return 'fail' got_cs = ds.GetRasterBand(1).Checksum() if got_cs != 4118: - gdaltest.post_reason('fail') print(got_cs) return 'fail' got_cs = ds.GetRasterBand(2).Checksum() if got_cs != 4406: - gdaltest.post_reason('fail') print(got_cs) return 'fail' got_md = ds.GetMetadata() expected_md = {'ZOOM_LEVEL': '11', 'minzoom': '11', 'maxzoom': '11', 'name': 'mbtiles_5', 'format': 'png', 'bounds': '-117.6420540294745,33.89160566594387,-117.6290077648261,33.90243460427036', 'version': '1.1', 'type': 'overlay', 'description': 'mbtiles_5'} if set(got_md.keys()) != set(expected_md.keys()): - gdaltest.post_reason('fail') print(got_md) return 'fail' for key in got_md: if key != 'bounds' and got_md[key] != expected_md[key]: - gdaltest.post_reason('fail') print(got_md) return 'fail' ds = None @@ -413,13 +406,11 @@ def test_mbtiles_6(): ds = gdal.Open('tmp/mbtiles_6.mbtiles') got_cs = ds.GetRasterBand(1).Checksum() if got_cs == 0: - gdaltest.post_reason('fail') print(got_cs) return 'fail' got_md = ds.GetMetadata() expected_md = {'ZOOM_LEVEL': '11', 'minzoom': '11', 'maxzoom': '11', 'format': 'jpg', 'version': 'version', 'type': 'baselayer', 'name': 'name', 'description': 'description'} if got_md != expected_md: - gdaltest.post_reason('fail') print(got_md) return 'fail' ds = None @@ -465,17 +456,14 @@ def test_mbtiles_7(): ds = gdal.Open('/vsimem/mbtiles_7.mbtiles') if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' expected_ovr_cs = [21179, 22577, 11996, 17849] got_ovr_cs = [ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(ds.RasterCount)] if expected_ovr_cs != got_ovr_cs: - gdaltest.post_reason('fail') print(got_ovr_cs) return 'fail' if ds.GetMetadataItem('minzoom') != '0': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -486,11 +474,9 @@ def test_mbtiles_7(): ds = gdal.Open('/vsimem/mbtiles_7.mbtiles') if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' if ds.GetMetadataItem('minzoom') != '1': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -520,15 +506,12 @@ def test_mbtiles_8(): out_ds = gdal.Open('/vsimem/mbtiles_8.mbtiles') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(1).GetBlockSize() != [256, 256]: - gdaltest.post_reason('fail') print(out_ds.GetRasterBand(1).GetBlockSize()) return 'fail' out_ds = None @@ -543,15 +526,12 @@ def test_mbtiles_8(): out_ds = gdal.Open('/vsimem/mbtiles_8.mbtiles') got_cs = [out_ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if got_cs != expected_cs: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (str(got_cs), str(expected_cs))) return 'fail' got_ct = out_ds.GetRasterBand(1).GetColorTable() if got_ct is not None: - gdaltest.post_reason('fail') return 'fail' if out_ds.GetRasterBand(1).GetBlockSize() != [512, 512]: - gdaltest.post_reason('fail') return 'fail' out_ds = None @@ -580,10 +560,8 @@ def test_mbtiles_9(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/mbtiles_9.mbtiles') if ds.RasterXSize != 256 or ds.RasterYSize != 256: - gdaltest.post_reason('fail') return 'fail' if abs(ds.GetGeoTransform()[0] - -13110479.091473430395126) > 1e-6: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' ds = None @@ -612,7 +590,6 @@ def test_mbtiles_10(): ds = gdal.Open('/vsimem/mbtiles_10.mbtiles') cs = ds.GetRasterBand(1).Checksum() if cs != 29925: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -667,7 +644,6 @@ def test_mbtiles_create(): gdaltest.mbtiles_drv.Create(filename, 1, 1, 1) with gdaltest.error_handler(): if gdal.Open(filename) is not None: - gdaltest.post_reason('fail') return 'fail' # Nominal case @@ -681,7 +657,6 @@ def test_mbtiles_create(): with gdaltest.error_handler(): ret = ds.SetGeoTransform(src_ds.GetGeoTransform()) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -690,13 +665,11 @@ def test_mbtiles_create(): with gdaltest.error_handler(): ret = ds.SetGeoTransform(src_ds.GetGeoTransform()) if ret == 0: - gdaltest.post_reason('fail') return 'fail' # SetProjection() not supported on read-only dataset with gdaltest.error_handler(): ret = ds.SetProjection(src_ds.GetProjectionRef()) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -706,7 +679,6 @@ def test_mbtiles_create(): with gdaltest.error_handler(): ret = ds.SetProjection('LOCAL_CS["foo"]') if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -716,7 +688,6 @@ def test_mbtiles_create(): with gdaltest.error_handler(): ret = ds.SetGeoTransform([0, 1, 0, 0, 0, 1]) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -726,7 +697,6 @@ def test_mbtiles_create(): with gdaltest.error_handler(): ret = ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/mem.py b/autotest/gdrivers/mem.py index b2c2d6837f7a..df13093ef5ab 100755 --- a/autotest/gdrivers/mem.py +++ b/autotest/gdrivers/mem.py @@ -297,7 +297,6 @@ def test_mem_6(): with gdaltest.error_handler(): ds = drv.Create('', 1, 1, 0x7FFFFFFF, gdal.GDT_Float64) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -305,7 +304,6 @@ def test_mem_6(): with gdaltest.error_handler(): ds = drv.Create('', 0x7FFFFFFF, 0x7FFFFFFF, 16) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -313,7 +311,6 @@ def test_mem_6(): with gdaltest.error_handler(): ds = drv.Create('', 0x7FFFFFFF, 0x7FFFFFFF, 1, gdal.GDT_Float64) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -321,7 +318,6 @@ def test_mem_6(): with gdaltest.error_handler(): ds = drv.Create('', 0x7FFFFFFF, 0x7FFFFFFF, 1, options=['INTERLEAVE=PIXEL']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -329,7 +325,6 @@ def test_mem_6(): with gdaltest.error_handler(): ds = drv.Create('', 0x7FFFFFFF, 0x7FFFFFFF, 1) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -343,7 +338,6 @@ def test_mem_6(): with gdaltest.error_handler(): ret = ds.AddBand(gdal.GDT_Float64) if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -402,55 +396,47 @@ def test_mem_9(): import struct print(struct.unpack('B' * 4 * 5, ref_data)) print(struct.unpack('B' * 4 * 5, got_data)) - gdaltest.post_reason('fail') return 'fail' ref_data = src_ds.GetRasterBand(2).ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_line_space=100) got_data = out_ds.GetRasterBand(2).ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_line_space=100) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' ref_data = src_ds.ReadRaster(20, 8, 4, 5) got_data = out_ds.ReadRaster(20, 8, 4, 5) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' ref_data = src_ds.ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_band_space=1) got_data = out_ds.ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_band_space=1) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' out_ds.WriteRaster(20, 8, 4, 5, got_data, buf_pixel_space=3, buf_band_space=1) got_data = out_ds.ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_band_space=1) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' ref_data = src_ds.ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_line_space=100, buf_band_space=1) got_data = out_ds.ReadRaster(20, 8, 4, 5, buf_pixel_space=3, buf_line_space=100, buf_band_space=1) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' ref_data = src_ds.ReadRaster(20, 20, 4, 5, buf_type=gdal.GDT_Int32, buf_pixel_space=12, buf_band_space=4) got_data = out_ds.ReadRaster(20, 20, 4, 5, buf_type=gdal.GDT_Int32, buf_pixel_space=12, buf_band_space=4) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' out_ds.WriteRaster(20, 20, 4, 5, got_data, buf_type=gdal.GDT_Int32, buf_pixel_space=12, buf_band_space=4) got_data = out_ds.ReadRaster(20, 20, 4, 5, buf_type=gdal.GDT_Int32, buf_pixel_space=12, buf_band_space=4) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' # Test IReadBlock @@ -461,7 +447,6 @@ def test_mem_9(): got_data = out_ds.GetRasterBand(1).ReadBlock(0, 10) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' # Test IRasterIO(GF_Write,) @@ -469,7 +454,6 @@ def test_mem_9(): out_ds.GetRasterBand(1).WriteRaster(6, 7, 4, 5, ref_data) got_data = out_ds.GetRasterBand(1).ReadRaster(6, 7, 4, 5) if ref_data != got_data: - gdaltest.post_reason('fail') return 'fail' # Test IRasterIO(GF_Write, change data type) + IWriteBlock() + IRasterIO(GF_Read, change data type) @@ -478,14 +462,12 @@ def test_mem_9(): got_data = out_ds.GetRasterBand(1).ReadRaster(10, 11, 4, 5, buf_type=gdal.GDT_Int32) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' ref_data = src_ds.GetRasterBand(1).ReadRaster(10, 11, 4, 5) got_data = out_ds.GetRasterBand(1).ReadRaster(10, 11, 4, 5) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' # Test IRasterIO(GF_Write, resampling) + IWriteBlock() + IRasterIO(GF_Read, resampling) @@ -495,13 +477,11 @@ def test_mem_9(): got_data = out_ds.GetRasterBand(1).ReadRaster(10, 11, 8, 10) if ref_data_zoomed != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' got_data = out_ds.GetRasterBand(1).ReadRaster(10, 11, 8, 10, 4, 5) if ref_data != got_data: print(interleave) - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -520,13 +500,10 @@ def test_mem_10(): # Requesting overviews when they are not ds = gdal.GetDriverByName('MEM').Create('', 1, 1) if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is not None: - gdaltest.post_reason('fail') return 'fail' # Single band case @@ -534,50 +511,39 @@ def test_mem_10(): for _ in range(2): ret = ds.BuildOverviews('NEAR', [2]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' ret = ds.BuildOverviews('NEAR', [4]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' ret = ds.BuildOverviews('NEAR', [2, 4]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -587,19 +553,15 @@ def test_mem_10(): ret = ds.BuildOverviews('AVERAGE', [2, 4]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1152: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 240: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -609,19 +571,15 @@ def test_mem_10(): ret = ds.BuildOverviews('AVERAGE', [2]) ret = ds.BuildOverviews('AVERAGE', [4]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1152: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 240: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -631,21 +589,17 @@ def test_mem_10(): ds = gdal.GetDriverByName('MEM').CreateCopy('', gdal.Open('data/rgbsmall.tif')) ret = ds.BuildOverviews('NEAR', [2]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 5057: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(2).GetOverview(0).Checksum() if cs != 5304: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(3).GetOverview(0).Checksum() if cs != 5304: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -654,14 +608,11 @@ def test_mem_10(): ds = gdal.GetDriverByName('MEM').CreateCopy('', gdal.Open('data/byte.tif')) ret = ds.BuildOverviews('NEAR', [2]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ret = ds.BuildOverviews('NONE', []) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -676,61 +627,50 @@ def test_mem_11(): # Error case: building overview on a 0 band dataset ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 0) if ds.CreateMaskBand(gdal.GMF_PER_DATASET) == 0: - gdaltest.post_reason('fail') return 'fail' # Per dataset mask on single band dataset ds = gdal.GetDriverByName('MEM').Create('', 1, 1) if ds.CreateMaskBand(gdal.GMF_PER_DATASET) != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaskFlags() != gdal.GMF_PER_DATASET: - gdaltest.post_reason('fail') return 'fail' mask = ds.GetRasterBand(1).GetMaskBand() cs = mask.Checksum() if cs != 0: - gdaltest.post_reason('fail') return 'fail' mask.Fill(255) cs = mask.Checksum() if cs != 3: - gdaltest.post_reason('fail') return 'fail' # Check that the per dataset mask is shared by all bands ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 2) if ds.CreateMaskBand(gdal.GMF_PER_DATASET) != 0: - gdaltest.post_reason('fail') return 'fail' mask1 = ds.GetRasterBand(1).GetMaskBand() mask1.Fill(255) mask2 = ds.GetRasterBand(2).GetMaskBand() cs = mask2.Checksum() if cs != 3: - gdaltest.post_reason('fail') return 'fail' # Same but call it on band 2 ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 2) if ds.GetRasterBand(2).CreateMaskBand(gdal.GMF_PER_DATASET) != 0: - gdaltest.post_reason('fail') return 'fail' mask2 = ds.GetRasterBand(2).GetMaskBand() mask2.Fill(255) mask1 = ds.GetRasterBand(1).GetMaskBand() cs = mask1.Checksum() if cs != 3: - gdaltest.post_reason('fail') return 'fail' # Per band masks ds = gdal.GetDriverByName('MEM').Create('', 1, 1, 2) if ds.GetRasterBand(1).CreateMaskBand(0) != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).CreateMaskBand(0) != 0: - gdaltest.post_reason('fail') return 'fail' mask1 = ds.GetRasterBand(1).GetMaskBand() mask2 = ds.GetRasterBand(2).GetMaskBand() @@ -738,7 +678,6 @@ def test_mem_11(): cs1 = mask1.Checksum() cs2 = mask2.Checksum() if cs1 != 0 or cs2 != 3: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -756,14 +695,12 @@ def test_mem_12(): ds.BuildOverviews('NEAR', [2]) cs = ds.GetRasterBand(1).GetOverview(0).GetMaskBand().Checksum() if cs != 267: - gdaltest.post_reason('fail') print(cs) return 'fail' # Default mask cs = ds.GetRasterBand(2).GetOverview(0).GetMaskBand().Checksum() if cs != 283: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -774,12 +711,10 @@ def test_mem_12(): ds.BuildOverviews('NEAR', [2]) cs = ds.GetRasterBand(1).GetOverview(0).GetMaskBand().Checksum() if cs != 267: - gdaltest.post_reason('fail') print(cs) return 'fail' cs2 = ds.GetRasterBand(2).GetOverview(0).GetMaskBand().Checksum() if cs2 != cs: - gdaltest.post_reason('fail') print(cs2) return 'fail' @@ -794,11 +729,9 @@ def test_mem_rat(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) ds.GetRasterBand(1).SetDefaultRAT(gdal.RasterAttributeTable()) if ds.GetRasterBand(1).GetDefaultRAT() is None: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetDefaultRAT(None) if ds.GetRasterBand(1).GetDefaultRAT() is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -812,11 +745,9 @@ def test_mem_categorynames(): ds = gdal.GetDriverByName('MEM').Create('', 1, 1) ds.GetRasterBand(1).SetCategoryNames(['foo']) if ds.GetRasterBand(1).GetCategoryNames() != ['foo']: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetCategoryNames([]) if ds.GetRasterBand(1).GetCategoryNames() is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -832,11 +763,9 @@ def test_mem_colortable(): ct.SetColorEntry(0, (255, 255, 255, 255)) ds.GetRasterBand(1).SetColorTable(ct) if ds.GetRasterBand(1).GetColorTable().GetCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).SetColorTable(None) if ds.GetRasterBand(1).GetColorTable() is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index 7db5f2a9d7ec..d8ad6ca1cbb7 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -152,7 +152,6 @@ def test_mrf_overview_near_fact_2(): ds = gdal.Open('/vsimem/out.mrf') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(dt) print(cs) print(expected_cs) @@ -186,7 +185,6 @@ def test_mrf_overview_near_with_nodata_fact_2(): cs = ds.GetRasterBand(1).GetOverview(0).Checksum() expected_cs = 1117 if cs != expected_cs: - gdaltest.post_reason('fail') print(dt) print(cs) print(expected_cs) @@ -220,7 +218,6 @@ def test_mrf_overview_avg_fact_2(): ds = gdal.Open('/vsimem/out.mrf') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(dt) print(cs) print(expected_cs) @@ -255,7 +252,6 @@ def test_mrf_overview_avg_with_nodata_fact_2(): ds = gdal.Open('/vsimem/out.mrf') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(dt) print(cs) print(expected_cs) @@ -283,7 +279,6 @@ def test_mrf_overview_near_fact_3(): cs = ds.GetRasterBand(1).GetOverview(0).Checksum() expected_cs = 478 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -310,7 +305,6 @@ def test_mrf_overview_avg_fact_3(): cs = ds.GetRasterBand(1).GetOverview(0).Checksum() expected_cs = 658 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -344,7 +338,6 @@ def test_mrf_overview_avg_with_nodata_fact_3(): ds = gdal.Open('/vsimem/out.mrf') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(dt) print(cs) print(expected_cs) @@ -370,7 +363,6 @@ def test_mrf_overview_partial_block(): ds = gdal.Open('/vsimem/out.mrf') cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -396,7 +388,6 @@ def test_mrf_overview_near_implicit_level(): ds = gdal.Open('/vsimem/out.mrf') cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -404,13 +395,11 @@ def test_mrf_overview_near_implicit_level(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.mrf:MRF:L2') if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/out.mrf:MRF:L1') cs = ds.GetRasterBand(1).Checksum() if cs != 328: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -435,7 +424,6 @@ def test_mrf_overview_external(): cs = ds.GetRasterBand(1).GetOverview(0).Checksum() expected_cs = 1087 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -458,13 +446,11 @@ def test_mrf_lerc_nodata(): ds = gdal.Open('/vsimem/out.mrf') nodata = ds.GetRasterBand(1).GetNoDataValue() if nodata != 107: - gdaltest.post_reason('fail') print(nodata) return 'fail' cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -487,7 +473,6 @@ def test_mrf_lerc_with_huffman(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 31204 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -512,7 +497,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 0 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -534,7 +518,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -545,7 +528,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -578,7 +560,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -589,7 +570,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -614,7 +594,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -630,7 +609,6 @@ def test_mrf_cached_source(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -674,7 +652,6 @@ def test_mrf_versioned(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 0 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -684,7 +661,6 @@ def test_mrf_versioned(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 0 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -694,7 +670,6 @@ def test_mrf_versioned(): cs = ds.GetRasterBand(1).Checksum() expected_cs = 4672 if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) print(expected_cs) return 'fail' @@ -703,7 +678,6 @@ def test_mrf_versioned(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/out.mrf:MRF:V2') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/out.mrf') diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index f15dcdeef784..5d0eac472000 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -337,7 +337,6 @@ def test_netcdf_2(): with gdaltest.error_handler(): ds = gdal.Open('tmp/netcdf2.nc', gdal.GA_Update) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdaltest.clean_tmp() @@ -1560,7 +1559,6 @@ def test_netcdf_39(): gdal.Unlink('tmp/two_vars_scale_offset.nc') gdal.Unlink('tmp/netcdf_39.vrt') if cs != 65463: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1577,7 +1575,6 @@ def test_netcdf_39(): gdal.Unlink('tmp/two_vars_scale_offset.nc') gdal.Unlink('tmp/netcdf_39.vrt') if cs != 65463: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1594,7 +1591,6 @@ def test_netcdf_39(): gdal.Unlink('tmp/two_vars_scale_offset.nc') gdal.Unlink('tmp/netcdf_39.vrt') if cs != 65463: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1609,7 +1605,6 @@ def test_netcdf_39(): gdal.Unlink('tmp/netcdf_39.vrt') if cs != 65463: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1638,11 +1633,9 @@ def test_netcdf_41(): with gdaltest.error_handler(): ds = gdal.Open('data/byte_no_cf.nc') if ds.GetGeoTransform() != (440720, 60, 0, 3751320, 0, -60): - gdaltest.post_reason('failure') print(ds.GetGeoTransform()) return 'fail' if ds.GetProjectionRef().find('26711') < 0: - gdaltest.post_reason('failure') print(ds.GetGeoTransform()) return 'fail' @@ -1685,19 +1678,16 @@ def test_netcdf_42(): 'LINE_STEP': '1', 'Y_DATASET': 'NETCDF:"tmp/netcdf_42.nc":lat', 'Y_BAND': '1'}: - gdaltest.post_reason('failure') print(ds.GetMetadata('GEOLOCATION')) return 'fail' ds = gdal.Open('NETCDF:"tmp/netcdf_42.nc":lon') if ds.GetRasterBand(1).Checksum() != 36043: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = gdal.Open('NETCDF:"tmp/netcdf_42.nc":lat') if ds.GetRasterBand(1).Checksum() != 33501: - gdaltest.post_reason('failure') print(ds.GetRasterBand(1).Checksum()) return 'fail' @@ -1726,7 +1716,6 @@ def test_netcdf_43(): 'LINE_STEP': '1', 'Y_DATASET': 'NETCDF:"tmp/netcdf_43.nc":lat', 'Y_BAND': '1'}: - gdaltest.post_reason('failure') print(ds.GetMetadata('GEOLOCATION')) return 'fail' @@ -1763,13 +1752,11 @@ def test_netcdf_45(): # Test that a vector cannot be opened in raster-only mode ds = gdal.OpenEx('data/test_ogr_nc3.nc', gdal.OF_RASTER) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Test that a raster cannot be opened in vector-only mode ds = gdal.OpenEx('data/cf-bug636.nc', gdal.OF_VECTOR) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/test_ogr_nc3.nc', gdal.OF_VECTOR) @@ -1787,7 +1774,6 @@ def test_netcdf_45(): ,,,,,,,,,,,,,,,,,,,, """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -1798,7 +1784,6 @@ def test_netcdf_45(): expected_content = """WKT,Integer,Integer,Real,Real,String(1),String(3),String,Date,DateTime,DateTime,Integer64,Integer64,Integer(Boolean),Integer(Boolean),Real(Float32),Real(Float32),Integer(Int16),Integer(Int16),Real,Integer """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' gdal.Unlink('/vsimem/netcdf_45.csv') @@ -1843,7 +1828,6 @@ def test_netcdf_47(): with gdaltest.error_handler(): ds = gdal.OpenEx('data/test_ogr_nc4.nc', gdal.OF_RASTER) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/test_ogr_nc4.nc', gdal.OF_VECTOR) @@ -1861,7 +1845,6 @@ def test_netcdf_47(): ,,,,,,,,,,,,,,,,,,,,,,,,,,, """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -1872,7 +1855,6 @@ def test_netcdf_47(): expected_content = """WKT,Integer,Integer,Real,Real,String(3),String,Date,DateTime,DateTime,Integer64,Integer64,Integer(Boolean),Integer(Boolean),Real(Float32),Real(Float32),Integer(Int16),Integer(Int16),Real,Integer,Integer,Integer,Integer,Integer,Integer64,Integer64,Real,Real """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' gdal.Unlink('/vsimem/netcdf_47.csv') @@ -1894,11 +1876,9 @@ def test_netcdf_48(): ds = gdal.OpenEx('data/test_ogr_no_xyz_var.nc', gdal.OF_VECTOR) lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbNone: - gdaltest.post_reason('failure') return 'fail' f = lyr.GetNextFeature() if f['int32'] != 1: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1926,7 +1906,6 @@ def test_netcdf_49(): ,, """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -1956,7 +1935,6 @@ def test_netcdf_50(): src_json = src_f.ExportToJson() out_json = out_f.ExportToJson() if src_json != out_json: - gdaltest.post_reason('failure') print(src_json) print(out_json) return 'fail' @@ -1966,14 +1944,12 @@ def test_netcdf_50(): out_lyr = out_ds.GetLayer(0) srs = out_lyr.GetSpatialRef().ExportToWkt() if srs.find('PROJCS["OSGB 1936') < 0: - gdaltest.post_reason('failure') print(srs) return 'fail' out_f = out_lyr.GetNextFeature() out_f.SetFID(-1) out_json = out_f.ExportToJson() if src_json != out_json: - gdaltest.post_reason('failure') print(src_json) print(out_json) return 'fail' @@ -2011,7 +1987,6 @@ def test_netcdf_51(): ,,,,,,,,,,,,,,,,,,,, """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2022,7 +1997,6 @@ def test_netcdf_51(): expected_content = """WKT,Integer,Integer,Real,Real,String(1),String(3),String,Date,DateTime,DateTime,Integer64,Integer64,Integer(Boolean),Integer(Boolean),Real(Float32),Real(Float32),Integer(Int16),Integer(Int16),Real,Integer """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2032,12 +2006,10 @@ def test_netcdf_51(): lyr.CreateField(ogr.FieldDefn('extra_str', ogr.OFTString)) f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('failure') return 'fail' f['extra'] = 5 f['extra_str'] = 'foobar' if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2045,7 +2017,6 @@ def test_netcdf_51(): lyr = ds.GetLayer(0) f = lyr.GetFeature(lyr.GetFeatureCount()) if f['int32'] != 1 or f['extra'] != 5 or f['extra_str'] != 'foobar': - gdaltest.post_reason('failure') return 'fail' f = None ds = None @@ -2091,7 +2062,6 @@ def test_netcdf_51_no_gdal_tags(): ,,,,,,,,,,,,,,,,,,,, """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2102,7 +2072,6 @@ def test_netcdf_51_no_gdal_tags(): expected_content = """WKT,Integer,Integer,Real,Real,String(1),String(3),String(10),Date,DateTime,DateTime,Real,Real,Integer,Integer,Real(Float32),Real(Float32),Integer(Int16),Integer(Int16),Real,Integer """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2145,7 +2114,6 @@ def test_netcdf_52(): ,,,,,,,,,,,,,,,,,,,,,,,,,,, """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2156,7 +2124,6 @@ def test_netcdf_52(): expected_content = """WKT,Integer,Integer,Real,Real,String(3),String,Date,DateTime,DateTime,Integer64,Integer64,Integer(Boolean),Integer(Boolean),Real(Float32),Real(Float32),Integer(Int16),Integer(Int16),Real,Integer,Integer,Integer,Integer,Integer,Integer64,Integer64,Real,Real """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2165,11 +2132,9 @@ def test_netcdf_52(): lyr.CreateField(ogr.FieldDefn('extra', ogr.OFTInteger)) f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('failure') return 'fail' f['extra'] = 5 if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2177,7 +2142,6 @@ def test_netcdf_52(): lyr = ds.GetLayer(0) f = lyr.GetFeature(lyr.GetFeatureCount()) if f['int32'] != 1 or f['extra'] != 5: - gdaltest.post_reason('failure') return 'fail' f = None ds = None @@ -2221,7 +2185,6 @@ def test_netcdf_53(): src_json = src_f.ExportToJson() out_json = out_f.ExportToJson() if src_json != out_json: - gdaltest.post_reason('failure') print(src_json) print(out_json) return 'fail' @@ -2231,14 +2194,12 @@ def test_netcdf_53(): out_lyr = out_ds.GetLayer(0) srs = out_lyr.GetSpatialRef().ExportToWkt() if srs.find('PROJCS["OSGB 1936') < 0: - gdaltest.post_reason('failure') print(srs) return 'fail' out_f = out_lyr.GetNextFeature() out_f.SetFID(-1) out_json = out_f.ExportToJson() if src_json != out_json: - gdaltest.post_reason('failure') print(src_json) print(out_json) return 'fail' @@ -2266,14 +2227,12 @@ def test_netcdf_54(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('failure') return 'fail' f['int32'] += 1 f.SetFID(-1) f.ExportToJson() src_json = f.ExportToJson() if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2288,7 +2247,6 @@ def test_netcdf_54(): gdal.Unlink('tmp/netcdf_54.nc') if src_json != out_json: - gdaltest.post_reason('failure') print(src_json) print(out_json) return 'fail' @@ -2313,14 +2271,12 @@ def test_netcdf_55(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('failure') return 'fail' f['twodimstringchar'] = 'abcd' f.SetFID(-1) f.ExportToJson() src_json = f.ExportToJson() if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2335,7 +2291,6 @@ def test_netcdf_55(): gdal.Unlink('tmp/netcdf_55.nc') if src_json != out_json: - gdaltest.post_reason('failure') print(src_json) print(out_json) return 'fail' @@ -2361,7 +2316,6 @@ def test_netcdf_56(): with gdaltest.error_handler(): ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2369,7 +2323,6 @@ def test_netcdf_56(): lyr = ds.GetLayer(0) f = lyr.GetFeature(lyr.GetFeatureCount()) if f['txt'] != '01234' or f.GetGeometryRef() is not None: - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' ds = None @@ -2395,7 +2348,6 @@ def test_netcdf_57(): with gdaltest.error_handler(): ds = ogr.GetDriverByName('netCDF').CreateDataSource('/not_existing_dir/invalid_subdir', options=['MULTIPLE_LAYERS=SEPARATE_FILES']) if ds is not None: - gdaltest.post_reason('failure') return 'fail' open('tmp/netcdf_57', 'wb').close() @@ -2403,7 +2355,6 @@ def test_netcdf_57(): with gdaltest.error_handler(): ds = ogr.GetDriverByName('netCDF').CreateDataSource('/not_existing_dir/invalid_subdir', options=['MULTIPLE_LAYERS=SEPARATE_FILES']) if ds is not None: - gdaltest.post_reason('failure') return 'fail' os.unlink('tmp/netcdf_57') @@ -2422,7 +2373,6 @@ def test_netcdf_57(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['lyr_id'] != ilayer: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2457,7 +2407,6 @@ def test_netcdf_58(): lyr = ds.GetLayer(ilayer) f = lyr.GetNextFeature() if f['lyr_id'] != 'lyr_%d' % ilayer: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2503,12 +2452,10 @@ def test_netcdf_60(): # Test that a vector cannot be opened in raster-only mode ds = gdal.OpenEx('data/profile.nc', gdal.OF_RASTER) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('data/profile.nc', gdal.OF_VECTOR) if ds is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): @@ -2525,7 +2472,6 @@ def test_netcdf_60(): "POINT Z (3 50 100)",2,4,Santa Fe,baz2 """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2561,7 +2507,6 @@ def test_netcdf_61(): "POINT Z (3 50 100)",2,4,Santa Fe,baz2 """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2594,7 +2539,6 @@ def test_netcdf_62(): "POINT Z (3 50 100)",2,4,Santa Fe,baz2 """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2622,7 +2566,6 @@ def test_netcdf_62_ncdump_check(): ret.find(':featureType = "profile"') < 0 or \ ret.find('char station(profile') < 0 or \ ret.find('char foo(record') < 0: - gdaltest.post_reason('failure') print(ret) return 'fail' else: @@ -2673,7 +2616,6 @@ def test_netcdf_63(): "POINT Z (3 50 100)",2,4,Santa Fe,baz2 """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2703,7 +2645,6 @@ def test_netcdf_63_ncdump_check(): ret.find('parentIndex:instance_dimension = "profile"') < 0 or \ ret.find(':featureType = "profile"') < 0 or \ ret.find('char station(record') < 0: - gdaltest.post_reason('failure') print(ret) return 'fail' else: @@ -2739,7 +2680,6 @@ def test_netcdf_64(): "POINT Z (3 50 100)",1,4,Santa Fe,baz2 """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2772,7 +2712,6 @@ def test_netcdf_65(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['str'] != '': - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' ds = None @@ -2880,7 +2819,6 @@ def test_netcdf_66(): "POINT Z (3 50 100)",2,4,Santa Fe,baz2 """ if content != expected_content: - gdaltest.post_reason('failure') print(content) return 'fail' @@ -2909,7 +2847,6 @@ def test_netcdf_66_ncdump_check(): ret.find('profile:cf_role = "profile_id"') < 0 or \ ret.find('parentIndex:instance_dimension = "profile"') < 0 or \ ret.find(':featureType = "profile"') < 0: - gdaltest.post_reason('failure') print(ret) return 'fail' else: @@ -2968,7 +2905,6 @@ def test_netcdf_68(): ds = gdal.Open('data/srid.nc') wkt = ds.GetProjectionRef() if wkt.find('6933') < 0: - gdaltest.post_reason('failure') print(wkt) return 'fail' @@ -3151,13 +3087,11 @@ def test_netcdf_77(): ds = gdal.Open('data/fake_Oa01_radiance.nc') subdatasets = ds.GetMetadata('SUBDATASETS') if len(subdatasets) != 2 * 2: - gdaltest.post_reason('fail') print(subdatasets) return 'fail' ds = gdal.Open('NETCDF:"data/fake_Oa01_radiance.nc":Oa01_radiance') if ds.GetMetadata('GEOLOCATION'): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3174,12 +3108,10 @@ def test_netcdf_78(): ds = gdal.Open('data/byte_with_valid_range.nc') if ds.GetRasterBand(1).GetNoDataValue() != 240: - gdaltest.post_reason('fail') return 'fail' data = ds.GetRasterBand(1).ReadRaster() data = struct.unpack('B' * 4, data) if data != (128, 129, 126, 127): - gdaltest.post_reason('fail') print(data) return 'fail' @@ -3197,12 +3129,10 @@ def test_netcdf_79(): ds = gdal.Open('data/byte_with_neg_fillvalue_and_unsigned_hint.nc') if ds.GetRasterBand(1).GetNoDataValue() != 240: - gdaltest.post_reason('fail') return 'fail' data = ds.GetRasterBand(1).ReadRaster() data = struct.unpack('B' * 4, data) if data != (128, 129, 126, 127): - gdaltest.post_reason('fail') print(data) return 'fail' diff --git a/autotest/gdrivers/nitf.py b/autotest/gdrivers/nitf.py index ec573c9b8cf9..a85406f8cc84 100755 --- a/autotest/gdrivers/nitf.py +++ b/autotest/gdrivers/nitf.py @@ -281,7 +281,6 @@ def test_nitf_10(): expected_cs = src_ds.GetRasterBand(2).Checksum() src_ds = None if expected_cs != 22296 and expected_cs != 22259: - gdaltest.post_reason('fail') return 'fail' tst = gdaltest.GDALTest('NITF', '../tmp/nitf9.ntf', 2, expected_cs) @@ -1102,7 +1101,6 @@ def test_nitf_38(): gdal.Unlink('tmp/nitf38.vrt') if cs != expected_cs: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1117,7 +1115,6 @@ def test_nitf_38(): gdal.Unlink('tmp/nitf38.vrt') if cs != expected_cs: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1132,7 +1129,6 @@ def test_nitf_38(): gdal.Unlink('tmp/nitf38.vrt') if cs != expected_cs: - gdaltest.post_reason('failure') print(cs) return 'fail' @@ -1876,7 +1872,6 @@ def test_nitf_read_IMRFCA_IMASDA(): ds = None gdal.Unlink(tmpfile) if md is None or md == {}: - gdaltest.post_reason('fail') print(md) return 'fail' @@ -1887,7 +1882,6 @@ def test_nitf_read_IMRFCA_IMASDA(): ds = None gdal.Unlink(tmpfile) if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' @@ -1898,7 +1892,6 @@ def test_nitf_read_IMRFCA_IMASDA(): ds = None gdal.Unlink(tmpfile) if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' @@ -1910,7 +1903,6 @@ def test_nitf_read_IMRFCA_IMASDA(): ds = None gdal.Unlink(tmpfile) if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' @@ -1922,7 +1914,6 @@ def test_nitf_read_IMRFCA_IMASDA(): ds = None gdal.Unlink(tmpfile) if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' diff --git a/autotest/gdrivers/ntv2.py b/autotest/gdrivers/ntv2.py index 4e7b1ab05827..8ead21d1f7d9 100755 --- a/autotest/gdrivers/ntv2.py +++ b/autotest/gdrivers/ntv2.py @@ -83,13 +83,11 @@ def test_ntv2_5(): gdal.GetDriverByName('NTv2').Create('/vsimem/ntv2_5.gsb', 1, 1, 4, gdal.GDT_Float32, options=['ENDIANNESS=LE']) ds = gdal.GetDriverByName('NTv2').CreateCopy('/vsimem/ntv2_5.gsb', src_ds, options=['APPEND_SUBDATASET=YES']) if ds.GetRasterBand(2).Checksum() != 10: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).Checksum()) return 'fail' ds = None ds = gdal.Open('NTv2:1:/vsimem/ntv2_5.gsb') if ds.GetRasterBand(2).Checksum() != 10: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).Checksum()) return 'fail' ds = None @@ -107,13 +105,11 @@ def test_ntv2_6(): gdal.GetDriverByName('NTv2').Create('/vsimem/ntv2_6.gsb', 1, 1, 4, gdal.GDT_Float32, options=['ENDIANNESS=BE']) ds = gdal.GetDriverByName('NTv2').CreateCopy('/vsimem/ntv2_6.gsb', src_ds, options=['APPEND_SUBDATASET=YES']) if ds.GetRasterBand(2).Checksum() != 10: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).Checksum()) return 'fail' ds = None ds = gdal.Open('NTv2:1:/vsimem/ntv2_6.gsb') if ds.GetRasterBand(2).Checksum() != 10: - gdaltest.post_reason('fail') print(ds.GetRasterBand(2).Checksum()) return 'fail' ds = None diff --git a/autotest/gdrivers/pcidsk.py b/autotest/gdrivers/pcidsk.py index 19d7ae63478a..b4efb150fceb 100755 --- a/autotest/gdrivers/pcidsk.py +++ b/autotest/gdrivers/pcidsk.py @@ -409,10 +409,8 @@ def test_pcidsk_15(): ds = gdal.Open('/vsimem/pcidsk_15.pix') if ds.RasterCount != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds2 = gdal.GetDriverByName('PCIDSK').CreateCopy('/vsimem/pcidsk_15_2.pix', ds) @@ -421,10 +419,8 @@ def test_pcidsk_15(): ds = gdal.Open('/vsimem/pcidsk_15_2.pix') if ds.RasterCount != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -435,10 +431,8 @@ def test_pcidsk_15(): ds = gdal.OpenEx('/vsimem/pcidsk_15.pix') if ds.RasterCount != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds2 = gdal.GetDriverByName('PCIDSK').CreateCopy('/vsimem/pcidsk_15_2.pix', ds) @@ -447,10 +441,8 @@ def test_pcidsk_15(): ds = gdal.OpenEx('/vsimem/pcidsk_15_2.pix') if ds.RasterCount != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -460,10 +452,8 @@ def test_pcidsk_15(): ds = gdal.OpenEx('/vsimem/pcidsk_15.pix') if ds.RasterCount != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds2 = gdal.GetDriverByName('PCIDSK').CreateCopy('/vsimem/pcidsk_15_2.pix', ds) @@ -472,10 +462,8 @@ def test_pcidsk_15(): ds = gdal.OpenEx('/vsimem/pcidsk_15_2.pix') if ds.RasterCount != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -494,11 +482,9 @@ def test_pcidsk_external_ovr(): ds.BuildOverviews('NEAR', [2]) ds = None if gdal.VSIStatL('/vsimem/test.pix.ovr') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/test.pix') if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -517,7 +503,6 @@ def test_pcidsk_external_ovr_rrd(): ds.BuildOverviews('NEAR', [2]) ds = None if gdal.VSIStatL('/vsimem/test.aux') is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/test.pix') if ds.GetRasterBand(1).GetOverviewCount() != 1: diff --git a/autotest/gdrivers/pdf.py b/autotest/gdrivers/pdf.py index a6de15b96be4..1b82863e6c41 100755 --- a/autotest/gdrivers/pdf.py +++ b/autotest/gdrivers/pdf.py @@ -639,12 +639,10 @@ def pdf_xmp(): gdal.GetDriverByName('PDF').Delete('tmp/pdf_xmp.pdf') if ref_md[0] != got_md[0]: - gdaltest.post_reason('fail') print(got_md[0]) return 'fail' if len(base_md) != 2: # NEATLINE and DPI - gdaltest.post_reason('fail') print(base_md) return 'fail' @@ -721,7 +719,6 @@ def pdf_update_gt(): ds = None if os.path.exists('tmp/pdf_update_gt.pdf.aux.xml'): - gdaltest.post_reason('fail') return 'fail' # Check geotransform @@ -1563,14 +1560,12 @@ def pdf_write_ogr(): # print('Checksum %s: %d' % (rendering_options[i], cs_tab[i]) ) for j in range(i + 1, len(rendering_options)): if cs_tab[i] == cs_tab[j] and cs_tab[i] >= 0 and cs_tab[j] >= 0: - gdaltest.post_reason('fail') print('Checksum %s: %d' % (roi, cs_tab[i])) print('Checksum %s: %d' % (rendering_options[j], cs_tab[j])) return 'fail' # And test that RASTER,VECTOR,TEXT is the default rendering if abs(cs_tab[len(rendering_options) - 1]) != cs_ref: - gdaltest.post_reason('fail') print(cs_ref) print(cs_tab[len(rendering_options) - 1]) return 'fail' @@ -1680,13 +1675,10 @@ def pdf_jpeg_direct_copy(): ds = gdal.Open('tmp/pdf_jpeg_direct_copy.pdf') # No XMP at PDF level if ds.GetMetadata('xml:XMP') is not None: - gdaltest.post_reason('failed') return 'fail' if ds.RasterXSize != 20: - gdaltest.post_reason('failed') return 'fail' if pdf_checksum_available() and ds.GetRasterBand(1).Checksum() == 0: - gdaltest.post_reason('failed') return 'fail' ds = None @@ -1699,7 +1691,6 @@ def pdf_jpeg_direct_copy(): gdal.Unlink('tmp/pdf_jpeg_direct_copy.pdf') if offset == -1: - gdaltest.post_reason('failed') return 'fail' return 'success' @@ -1736,13 +1727,10 @@ def pdf_jpeg_in_vrt_direct_copy(): ds = gdal.Open('tmp/pdf_jpeg_in_vrt_direct_copy.pdf') # No XMP at PDF level if ds.GetMetadata('xml:XMP') is not None: - gdaltest.post_reason('failed') return 'fail' if ds.RasterXSize != 20: - gdaltest.post_reason('failed') return 'fail' if pdf_checksum_available() and ds.GetRasterBand(1).Checksum() == 0: - gdaltest.post_reason('failed') return 'fail' ds = None @@ -1755,7 +1743,6 @@ def pdf_jpeg_in_vrt_direct_copy(): gdal.Unlink('tmp/pdf_jpeg_in_vrt_direct_copy.pdf') if offset == -1: - gdaltest.post_reason('failed') return 'fail' return 'success' @@ -1830,12 +1817,10 @@ def pdf_write_huge(): ds = None ds = gdal.Open(tmp_filename) if int(ds.GetMetadataItem('DPI')) != 96: - gdaltest.post_reason('failure') print(ds.GetMetadataItem('DPI')) return 'fail' if ds.RasterXSize != src_ds.RasterXSize or \ ds.RasterYSize != src_ds.RasterYSize: - gdaltest.post_reason('failure') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' @@ -1847,12 +1832,10 @@ def pdf_write_huge(): gdal.PopErrorHandler() msg = gdal.GetLastErrorMsg() if msg == '': - gdaltest.post_reason('failure') return 'fail' ds = None ds = gdal.Open(tmp_filename) if int(ds.GetMetadataItem('DPI')) != 72: - gdaltest.post_reason('failure') print(ds.GetMetadataItem('DPI')) return 'fail' ds = None @@ -1867,12 +1850,10 @@ def pdf_write_huge(): gdal.PopErrorHandler() msg = gdal.GetLastErrorMsg() if msg == '': - gdaltest.post_reason('failure') return 'fail' ds = None ds = gdal.Open(tmp_filename) if int(ds.GetMetadataItem('DPI')) != 72: - gdaltest.post_reason('failure') print(ds.GetMetadataItem('DPI')) return 'fail' ds = None @@ -1912,7 +1893,6 @@ def pdf_overviews(): return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 5934: - gdaltest.post_reason('failure') print(cs) return 'fail' elif pdf_is_pdfium(): @@ -1921,12 +1901,10 @@ def pdf_overviews(): ds.BuildOverviews('NONE', [2]) after = ds.GetRasterBand(1).GetOverviewCount() if after != 1: - gdaltest.post_reason('failure') print(after) return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 0: - gdaltest.post_reason('failure') print(cs) return 'fail' ds = None @@ -1951,20 +1929,17 @@ def pdf_password(): with gdaltest.error_handler(): ds = gdal.Open('data/byte_enc.pdf') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Wrong password with gdaltest.error_handler(): ds = gdal.OpenEx('data/byte_enc.pdf', open_options=['USER_PWD=wrong_password']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Correct password ds = gdal.OpenEx('data/byte_enc.pdf', open_options=['USER_PWD=user_password']) if ds is None: - gdaltest.post_reason('fail') return 'fail' import test_cli_utilities @@ -1980,7 +1955,6 @@ def pdf_password(): ret = os.system(cmd_line) os.unlink('tmp/password.txt') if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Test ASK_INTERACTIVE with correct password @@ -1988,7 +1962,6 @@ def pdf_password(): ret = os.system(cmd_line) os.unlink('tmp/password.txt') if ret != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2032,19 +2005,16 @@ def pdf_multipage(): with gdaltest.error_handler(): ds3 = gdal.Open('PDF:0:data/byte_and_rgbsmall_2pages.pdf') if ds3 is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds3 = gdal.Open('PDF:3:data/byte_and_rgbsmall_2pages.pdf') if ds3 is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('PDF:1:/does/not/exist.pdf') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2062,13 +2032,11 @@ def pdf_metadata(): ds = gdal.Open('tmp/pdf_metadata.pdf') md = ds.GetMetadata() if 'FOO' not in md: - gdaltest.post_reason('fail') print(md) return 'fail' ds = None ds = gdal.Open('tmp/pdf_metadata.pdf') if ds.GetMetadataItem('FOO') != 'BAR': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2090,21 +2058,17 @@ def pdf_pam_georef(): # Default behaviour should result in no PAM file gdaltest.pdf_drv.CreateCopy('tmp/pdf_pam_georef.pdf', src_ds) if os.path.exists('tmp/pdf_pam_georef.pdf.aux.xml'): - gdaltest.post_reason('fail') return 'fail' # Now disable internal georeferencing, so georef should go to PAM gdaltest.pdf_drv.CreateCopy('tmp/pdf_pam_georef.pdf', src_ds, options=['GEO_ENCODING=NONE']) if not os.path.exists('tmp/pdf_pam_georef.pdf.aux.xml'): - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('tmp/pdf_pam_georef.pdf') if ds.GetGeoTransform() != src_ds.GetGeoTransform(): - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef() != src_ds.GetProjectionRef(): - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/pds.py b/autotest/gdrivers/pds.py index 71356bcdbf06..460501adfe24 100755 --- a/autotest/gdrivers/pds.py +++ b/autotest/gdrivers/pds.py @@ -251,12 +251,10 @@ def test_pds_9(): got_nd = ds.GetRasterBand(1).GetNoDataValue() expected_nd = -3.40282265508890445e+38 if abs((got_nd - expected_nd) / expected_nd) > 1e-5: - gdaltest.post_reason('fail') print(got_nd) return 'fail' if not ds.GetProjectionRef(): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -291,12 +289,10 @@ def test_pds_10(): ds = gdal.Open('/vsimem/pds_10') if ds.GetMetadataItem('NOTE') != '((1,2,3))': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('NOTE')) return 'fail' if ds.GetMetadataItem('PRODUCT_ID') != '({1,2},{3,4})': - gdaltest.post_reason('fail') print(ds.GetMetadataItem('NOTE')) return 'fail' diff --git a/autotest/gdrivers/pds4.py b/autotest/gdrivers/pds4.py index 385e5c7db4c1..de2bbe53b0a6 100755 --- a/autotest/gdrivers/pds4.py +++ b/autotest/gdrivers/pds4.py @@ -248,7 +248,6 @@ def test_pds4_8(): got_gt = ds.GetGeoTransform() expected_gt = (85151.12354629935, 42575.561773149675, 0.0, 2086202.5268843342, 0.0, -85151.12354629935) if max([abs(got_gt[i] - expected_gt[i]) for i in range(6)]) > 1: - gdaltest.post_reason('fail') print('') print(got_gt) print(expected_gt) @@ -267,13 +266,11 @@ def test_pds4_9(): ds = gdal.Open('data/byte_pds4.xml') ndv = ds.GetRasterBand(1).GetNoDataValue() if ndv != 74: - gdaltest.post_reason('fail') print(ndv) return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 4800: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -291,13 +288,11 @@ def test_pds4_9(): ds = gdal.Open(filename) ndv = ds.GetRasterBand(1).GetNoDataValue() if ndv != 74: - gdaltest.post_reason('fail') print(ndv) return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 4800: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -319,19 +314,16 @@ def test_pds4_9(): ds = gdal.Open(filename) ndv = ds.GetRasterBand(1).GetNoDataValue() if ndv != 75: - gdaltest.post_reason('fail') print(ndv) return 'fail' flag = ds.GetRasterBand(1).GetMaskFlags() if flag != 0: - gdaltest.post_reason('fail') print(flag) return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 4833: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -352,7 +344,6 @@ def test_pds4_9(): ds = gdal.Open(filename) ndv = ds.GetRasterBand(1).GetNoDataValue() if ndv != 74: - gdaltest.post_reason('fail') print(frmt) print(ndv) return 'fail' @@ -369,7 +360,6 @@ def test_pds4_9(): ds = gdal.Open(filename) cs = ds.GetRasterBand(1).Checksum() if cs != 1: - gdaltest.post_reason('fail') print(frmt) print(cs) return 'fail' @@ -386,7 +376,6 @@ def test_pds4_9(): ds = gdal.Open(filename) cs = ds.GetRasterBand(1).Checksum() if cs != 1: - gdaltest.post_reason('fail') print(frmt) print(cs) return 'fail' @@ -449,7 +438,6 @@ def test_pds4_9(): ds = gdal.Open(filename) ndv = ds.GetRasterBand(1).GetNoDataValue() if ndv != 10: - gdaltest.post_reason('fail') print(ndv) return 'fail' ds = None @@ -516,7 +504,6 @@ def test_pds4_9(): ds = gdal.Open(filename) ndv = ds.GetRasterBand(1).GetNoDataValue() if ndv != 10: - gdaltest.post_reason('fail') print(ndv) return 'fail' ds = None @@ -551,12 +538,10 @@ def test_pds4_10(): ds = gdal.Open(filename2) scale = ds.GetRasterBand(1).GetScale() if scale != 2: - gdaltest.post_reason('fail') print(scale) return 'fail' offset = ds.GetRasterBand(1).GetOffset() if offset != 3: - gdaltest.post_reason('fail') print(offset) return 'fail' ds = None @@ -590,18 +575,15 @@ def test_pds4_11(): with gdaltest.config_option('PDS4_FORCE_MASK', 'YES'): ds = gdal.Open(filename) if ds.GetRasterBand(1).DataType != dt: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).DataType) print(dt) return 'fail' got_data = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) if got_data != data: - gdaltest.post_reason('fail') print(dt) return 'fail' cs = ds.GetRasterBand(1).GetMaskBand().Checksum() if cs != 3: - gdaltest.post_reason('fail') print(dt) print(cs) return 'fail' @@ -641,35 +623,27 @@ def test_pds4_12(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) if data.find('logical_identifier') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('1') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('3') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('4') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('2') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('planetographic') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('Positive West') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('myimage.raw') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -692,28 +666,24 @@ def test_pds4_13(): ('PDS4:data/byte_pds4_multi_sds.xml:2:1', 'Image file byte_pds4.img, array third_sds')] if subds != expected_subds: - gdaltest.post_reason('fail') print(subds) return 'fail' ds = gdal.Open('PDS4:data/byte_pds4_multi_sds.xml:1:1') cs = ds.GetRasterBand(1).Checksum() if cs != 2315: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = gdal.Open('PDS4:data/byte_pds4_multi_sds.xml:1:2') cs = ds.GetRasterBand(1).Checksum() if cs != 2302: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = gdal.Open('PDS4:data/byte_pds4_multi_sds.xml:2:1') cs = ds.GetRasterBand(1).Checksum() if cs != 3496: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -721,37 +691,31 @@ def test_pds4_13(): subds_name = ds.GetSubDatasets()[0][0] ds = gdal.Open(subds_name) if ds is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('PDS4:c:\do_not\exist.xml:1:1') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('PDS4:i_do_not_exist.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('PDS4:i_do_not_exist.xml:1:1') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('PDS4:data/byte_pds4_multi_sds.xml:3:1') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('PDS4:data/byte_pds4_multi_sds.xml:1:3') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -768,7 +732,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = gdal.Open(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(filename, """ @@ -842,7 +805,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = gdal.Open(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(filename, """ @@ -878,7 +840,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = gdal.Open(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(filename, """ @@ -909,7 +870,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = gdal.Open(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(filename, """ @@ -940,7 +900,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = gdal.Open(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(filename, """ @@ -971,7 +930,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = gdal.Open(filename) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink(filename) @@ -981,7 +939,6 @@ def test_pds4_14(): ds = gdal.GetDriverByName('PDS4').Create('/vsimem/out.xml', 1, 1, options=['INTERLEAVE=INVALID']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # INTERLEAVE=BIL not supported for GeoTIFF in PDS4 @@ -990,7 +947,6 @@ def test_pds4_14(): options=['INTERLEAVE=BIL', 'IMAGE_FORMAT=GEOTIFF']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Cannot create GeoTIFF file @@ -998,7 +954,6 @@ def test_pds4_14(): ds = gdal.GetDriverByName('PDS4').Create('/i/do_not/exist.xml', 1, 1, options=['IMAGE_FORMAT=GEOTIFF']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Translate('/vsimem/test.tif', 'data/byte.tif') @@ -1007,7 +962,6 @@ def test_pds4_14(): ds = gdal.Translate('/vsimem/test.xml', '/vsimem/test.tif', format='PDS4', creationOptions=['IMAGE_FORMAT=GEOTIFF']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/test.tif') @@ -1021,7 +975,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = None if gdal.GetLastErrorMsg() != 'Cannot find Product_Observational element in template': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1041,7 +994,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = None if gdal.GetLastErrorMsg() != 'Cannot find Target_Identification element in template': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1057,7 +1009,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = None if gdal.GetLastErrorMsg() != 'Cannot find Observation_Area in template': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1076,7 +1027,6 @@ def test_pds4_14(): with gdaltest.error_handler(): ds = None if gdal.GetLastErrorMsg() != 'Unexpected content found after Observation_Area in template': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1107,7 +1057,6 @@ def test_pds4_15(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) if data.find('') >= 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1186,15 +1135,12 @@ def test_pds4_16(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) if data.find('http://pds.nasa.gov/pds4/pds/v1 https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1800.xsd http://pds.nasa.gov/pds4/cart/v1 https://pds.nasa.gov/pds4/cart/v1/PDS4_CART_1700.xsd"') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('xmlns:cart="http://pds.nasa.gov/pds4/cart/v1"') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1226,7 +1172,6 @@ def test_pds4_17(): if data.find('') < 0 or data.find('2') < 0 or \ data.find('Band') >= 0 or \ data.find('3') >= 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1253,7 +1198,6 @@ def test_pds4_17(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) if data.find('') < 0 or data.find('3') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1284,7 +1228,6 @@ def test_pds4_18(): if data.find('1') < 0 or \ data.find('1') < 0 or \ data.find('2') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' diff --git a/autotest/gdrivers/plmosaic.py b/autotest/gdrivers/plmosaic.py index e52c2cafc067..1c654457fa6a 100755 --- a/autotest/gdrivers/plmosaic.py +++ b/autotest/gdrivers/plmosaic.py @@ -66,7 +66,6 @@ def test_plmosaic_2(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -86,7 +85,6 @@ def test_plmosaic_3(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -108,7 +106,6 @@ def test_plmosaic_4(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -130,7 +127,6 @@ def test_plmosaic_5(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -152,7 +148,6 @@ def test_plmosaic_6(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -174,7 +169,6 @@ def test_plmosaic_7(): ds = gdal.OpenEx('PLMosaic:', gdal.OF_RASTER, open_options=['API_KEY=foo']) gdal.SetConfigOption('PL_URL', None) if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -231,7 +225,6 @@ def test_plmosaic_8(): ds = gdal.OpenEx('PLMosaic:', gdal.OF_RASTER, open_options=['API_KEY=foo']) gdal.SetConfigOption('PL_URL', None) if ds.GetMetadata("SUBDATASETS") != {'SUBDATASET_2_NAME': 'PLMOSAIC:mosaic=another_mosaic_name', 'SUBDATASET_2_DESC': 'Mosaic another_mosaic_name', 'SUBDATASET_1_NAME': 'PLMOSAIC:mosaic=my_mosaic_name', 'SUBDATASET_1_DESC': 'Mosaic my_mosaic_name'}: - gdaltest.post_reason('fail') print(ds.GetMetadata("SUBDATASETS")) return 'fail' ds = None @@ -253,7 +246,6 @@ def test_plmosaic_9(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if ds is not None or gdal.GetLastErrorMsg().find('/vsimem/root/?name__is=does_not_exist') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -275,7 +267,6 @@ def test_plmosaic_9bis(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('JSON parsing error') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -297,7 +288,6 @@ def test_plmosaic_9ter(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('No mosaic my_mosaic') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -324,7 +314,6 @@ def test_plmosaic_10(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('Missing required parameter') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -357,7 +346,6 @@ def test_plmosaic_11(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('Unsupported coordinate_system') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -390,7 +378,6 @@ def test_plmosaic_12(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('Unsupported data_type') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -423,7 +410,6 @@ def test_plmosaic_13(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('Unsupported resolution') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -456,7 +442,6 @@ def test_plmosaic_14(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('Unsupported quad_size') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -495,15 +480,12 @@ def test_plmosaic_15(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if gdal.GetLastErrorMsg().find('Invalid _links.tiles') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' if ds.GetRasterBand(1).GetOverview(0) is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -563,7 +545,6 @@ def test_plmosaic_16(): gdal.PopErrorHandler() gdal.SetConfigOption('PL_URL', None) if ds is not None or gdal.GetLastErrorMsg().find('Unsupported option unsupported_option') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -571,11 +552,9 @@ def test_plmosaic_16(): ds = gdal.OpenEx('PLMosaic:', gdal.OF_RASTER, open_options=['API_KEY=foo']) gdal.SetConfigOption('PL_URL', None) if ds.GetMetadata("SUBDATASETS") != {}: - gdaltest.post_reason('fail') print(ds.GetMetadata("SUBDATASETS")) return 'fail' if ds.GetMetadata() != {'LAST_ACQUIRED': 'last_date', 'NAME': 'my_mosaic', 'FIRST_ACQUIRED': 'first_date'}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -595,48 +574,37 @@ def test_plmosaic_17(): ds = gdal.OpenEx('PLMosaic:', gdal.OF_RASTER, open_options=['API_KEY=foo', 'MOSAIC=my_mosaic', 'CACHE_PATH=tmp']) gdal.SetConfigOption('PL_URL', None) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadata() != {'LAST_ACQUIRED': 'last_date', 'NAME': 'my_mosaic', 'FIRST_ACQUIRED': 'first_date'}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' if ds.GetProjectionRef().find('3857') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' if ds.RasterXSize != 8388608: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 8388608: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-20037508.34, 4.7773142671600004, 0.0, 20037508.34, 0.0, -4.7773142671600004) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) return 'fail' if ds.GetMetadataItem('INTERLEAVE', 'IMAGE_STRUCTURE') != 'PIXEL': - gdaltest.post_reason('fail') print(ds.GetMetadata('IMAGE_STRUCTURE')) print(ds.GetMetadataItem('INTERLEAVE', 'IMAGE_STRUCTURE')) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 15: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(ds.GetRasterBand(1).GetOverviewCount()) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' try: @@ -648,19 +616,16 @@ def test_plmosaic_17(): # Read at one nonexistent position. ds.GetRasterBand(1).ReadRaster(4096 * i, 0, 1, 1) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' for i in range(11, -1, -1): # Again in the same quad, but in different block, to test cache ds.GetRasterBand(1).ReadRaster(4096 * i + 256, 0, 1, 1) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' for i in range(12): # Again in the same quad, but in different block, to test cache ds.GetRasterBand(1).ReadRaster(4096 * i + 512, 256, 1, 1) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds.FlushCache() @@ -695,7 +660,6 @@ def test_plmosaic_17(): val = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) val = struct.unpack('B', val)[0] if val != 255: - gdaltest.post_reason('fail') print(val) return 'fail' @@ -712,7 +676,6 @@ def test_plmosaic_17(): val = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) val = struct.unpack('B', val)[0] if val != 255: - gdaltest.post_reason('fail') print(val) return 'fail' @@ -728,7 +691,6 @@ def test_plmosaic_17(): val = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) val = struct.unpack('B', val)[0] if val != 255: - gdaltest.post_reason('fail') print(val) return 'fail' ds = None @@ -746,7 +708,6 @@ def test_plmosaic_17(): val = ds.ReadRaster(0, 0, 1, 1) val = struct.unpack('B' * 4, val) if val != (254, 0, 0, 0): - gdaltest.post_reason('fail') print(val) return 'fail' @@ -770,13 +731,11 @@ def test_plmosaic_18(): ret = ds.GetRasterBand(1).GetMetadataItem('Pixel_0_0', 'LocationInfo') if ret != """ """: - gdaltest.post_reason('fail') print(ret) return 'fail' old_ret = ret ret = ds.GetRasterBand(1).GetMetadataItem('Pixel_0_0', 'LocationInfo') if ret != old_ret: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -797,7 +756,6 @@ def test_plmosaic_18(): """: - gdaltest.post_reason('fail') print(ret) return 'fail' ds = None @@ -821,14 +779,12 @@ def test_plmosaic_19(): gdal.PopErrorHandler() val = struct.unpack('B' * 4, val) if val != (254, 0, 0, 0): - gdaltest.post_reason('fail') print(val) return 'fail' val = ds.ReadRaster(256, 0, 1, 1) val = struct.unpack('B' * 4, val) if val != (254, 0, 0, 0): - gdaltest.post_reason('fail') print(val) return 'fail' ds = None @@ -850,14 +806,12 @@ def test_plmosaic_20(): val = ds.ReadRaster(0, 0, 1, 1) val = struct.unpack('B' * 4, val) if val != (254, 0, 0, 0): - gdaltest.post_reason('fail') print(val) return 'fail' val = ds.ReadRaster(256, 0, 1, 1) val = struct.unpack('B' * 4, val) if val != (254, 0, 0, 0): - gdaltest.post_reason('fail') print(val) return 'fail' ds = None @@ -882,7 +836,6 @@ def test_plmosaic_21(): ds.ReadRaster(256, 512, 1, 1) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -890,7 +843,6 @@ def test_plmosaic_21(): ds.GetRasterBand(1).ReadRaster(256, 512, 1, 1) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -898,7 +850,6 @@ def test_plmosaic_21(): ds.GetRasterBand(1).ReadBlock(1, 2) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/root/?name__is=mosaic_uint16', """{ @@ -928,7 +879,6 @@ def test_plmosaic_21(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if gdal.GetLastErrorMsg().find('Cannot use tile API for full resolution data on non Byte mosaic') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -956,7 +906,6 @@ def test_plmosaic_21(): gdal.SetConfigOption('PL_URL', None) gdal.PopErrorHandler() if gdal.GetLastErrorMsg().find('Cannot find tile definition, so use_tiles will be ignored') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1020,18 +969,15 @@ def test_plmosaic_with_bbox(): ds = gdal.OpenEx('PLMosaic:', gdal.OF_RASTER, open_options=['API_KEY=foo']) gdal.SetConfigOption('PL_URL', None) if ds.RasterXSize != 233472: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 286720: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-11134123.286585508, 4.77731426716, 0.0, 4872401.930333553, 0.0, -4.77731426716) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -1043,7 +989,6 @@ def test_plmosaic_with_bbox(): val = ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) val = struct.unpack('B', val)[0] if val != 125: - gdaltest.post_reason('fail') print(val) return 'fail' @@ -1062,7 +1007,6 @@ def test_plmosaic_with_bbox(): """: - gdaltest.post_reason('fail') print(ret) return 'fail' diff --git a/autotest/gdrivers/png.py b/autotest/gdrivers/png.py index 6d629524dc3e..86facd8a1b0f 100755 --- a/autotest/gdrivers/png.py +++ b/autotest/gdrivers/png.py @@ -261,7 +261,6 @@ def test_png_12(): tmp_ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data) got_cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if cs != got_cs: - gdaltest.post_reason('failure') return 'fail' # Pixel interleaved @@ -270,7 +269,6 @@ def test_png_12(): tmp_ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data, buf_pixel_space=ds.RasterCount, buf_band_space=1) got_cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if cs != got_cs: - gdaltest.post_reason('failure') return 'fail' # Pixel interleaved with padding @@ -279,7 +277,6 @@ def test_png_12(): tmp_ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data, buf_pixel_space=5, buf_band_space=1) got_cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(ds.RasterCount)] if cs != got_cs: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -297,13 +294,11 @@ def test_png_13(): out_ds = gdal.GetDriverByName('PNG').CreateCopy('/vsimem/tmp.png', src_ds, options=['WRITE_METADATA_AS_TEXT=YES', 'DESCRIPTION=my desc']) md = out_ds.GetMetadata() if len(md) != 3 or md['foo'] != 'bar' or md['Copyright'] != 'copyright value' or md['Description'] != 'my desc': - gdaltest.post_reason('failure') print(md) return 'fail' out_ds = None # check that no PAM file is created if gdal.VSIStatL('/vsimem/tmp.png.aux.xml') == 0: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink('/vsimem/tmp.png') return 'success' @@ -323,18 +318,15 @@ def test_png_14(): gdal.Unlink('/vsimem/tmp.png') if cs != expected_cs: - gdaltest.post_reason('failure') print(cs) return 'fail' if nbits != '1': - gdaltest.post_reason('failure') print(nbits) return 'fail' # check that no PAM file is created if gdal.VSIStatL('/vsimem/tmp.png.aux.xml') == 0: - gdaltest.post_reason('failure') return 'fail' # Test explicit NBITS @@ -343,7 +335,6 @@ def test_png_14(): nbits = out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') gdal.Unlink('/vsimem/tmp.png') if nbits != '2': - gdaltest.post_reason('failure') print(nbits) return 'fail' @@ -354,7 +345,6 @@ def test_png_14(): nbits = out_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') gdal.Unlink('/vsimem/tmp.png') if nbits is not None: - gdaltest.post_reason('failure') print(nbits) return 'fail' diff --git a/autotest/gdrivers/png_profile.py b/autotest/gdrivers/png_profile.py index 7c8b00d9a527..fd892f83f134 100755 --- a/autotest/gdrivers/png_profile.py +++ b/autotest/gdrivers/png_profile.py @@ -63,12 +63,10 @@ def test_png_copy_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' try: os.stat('tmp/icc_test.png.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -80,13 +78,11 @@ def test_png_copy_icc(): try: os.stat('tmp/icc_test.png.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with GetMetadataItem() @@ -96,13 +92,11 @@ def test_png_copy_icc(): try: os.stat('tmp/icc_test.png.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if source_icc_profile != icc: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') @@ -139,7 +133,6 @@ def test_png_copy_options_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -149,7 +142,6 @@ def test_png_copy_options_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') @@ -186,7 +178,6 @@ def test_png_copy_options_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -197,11 +188,9 @@ def test_png_copy_options_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' if float(md['PNG_GAMMA']) != 1.5: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -214,7 +203,6 @@ def test_png_copy_options_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -225,11 +213,9 @@ def test_png_copy_options_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' if float(md['PNG_GAMMA']) != 1.5: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') @@ -269,7 +255,6 @@ def test_png_copy_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -280,11 +265,9 @@ def test_png_copy_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' if float(md['PNG_GAMMA']) != 1.5: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -297,7 +280,6 @@ def test_png_copy_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -308,11 +290,9 @@ def test_png_copy_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' if float(md['PNG_GAMMA']) != 1.5: - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') @@ -339,7 +319,6 @@ def test_png_sRGB(): ds2 = None if md['SOURCE_ICC_PROFILE_NAME'] != 'sRGB': - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -349,7 +328,6 @@ def test_png_sRGB(): ds2 = None if md['SOURCE_ICC_PROFILE_NAME'] != 'sRGB': - gdaltest.post_reason('fail') return 'fail' driver_tiff.Delete('tmp/icc_test.tiff') diff --git a/autotest/gdrivers/postgisraster.py b/autotest/gdrivers/postgisraster.py index b7348a30cf17..92f410749edf 100755 --- a/autotest/gdrivers/postgisraster.py +++ b/autotest/gdrivers/postgisraster.py @@ -366,7 +366,6 @@ def test_postgisraster_test_create_copy_and_delete_phases(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_copy' mode=2") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' ds = None @@ -453,7 +452,6 @@ def test_postgisraster_test_norid(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_noid' mode=2") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -488,7 +486,6 @@ def test_postgisraster_test_serial(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_serial' mode=2") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -523,7 +520,6 @@ def test_postgisraster_test_unique(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_unique' mode=2") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -537,7 +533,6 @@ def test_postgisraster_test_constraint(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_constraint' mode=2") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -551,7 +546,6 @@ def test_postgisraster_test_constraint_with_spi(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_constraint_with_spi' mode=2") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -579,7 +573,6 @@ def test_postgisraster_test_outdb(): cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] expected_cs = [30111, 32302, 40026] if has_guc else [0, 0, 0] if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -593,7 +586,6 @@ def test_postgisraster_test_outdb_client_side(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_outdb_constraint' mode=2 outdb_resolution=client_side") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -608,7 +600,6 @@ def test_postgisraster_test_outdb_client_side_force_ireadblock(): with gdaltest.SetCacheMax(0): cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -622,7 +613,6 @@ def test_postgisraster_test_outdb_client_side_if_possible(): ds = gdal.Open(gdaltest.postgisraster_connection_string + "table='small_world_outdb_constraint' mode=2 outdb_resolution=client_side_if_possible") cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [30111, 32302, 40026]: - gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/autotest/gdrivers/rda.py b/autotest/gdrivers/rda.py index 5281e6c7630b..b79ca8096cde 100755 --- a/autotest/gdrivers/rda.py +++ b/autotest/gdrivers/rda.py @@ -72,21 +72,18 @@ def test_rda_bad_connection_string(): with gdaltest.error_handler(): ds = gdal.Open('graph-id node-id') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Missing graph-id with gdaltest.error_handler(): ds = gdal.Open('"graph-id node-id"') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Missing node-id with gdaltest.error_handler(): ds = gdal.Open('{"graph-id": "node-id"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -102,7 +99,6 @@ def test_rda_missing_credentials(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -125,7 +121,6 @@ def test_rda_failed_authentication(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # invalid URL @@ -135,7 +130,6 @@ def test_rda_failed_authentication(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # 404 @@ -148,7 +142,6 @@ def test_rda_failed_authentication(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid json @@ -161,7 +154,6 @@ def test_rda_failed_authentication(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No access token @@ -174,7 +166,6 @@ def test_rda_failed_authentication(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -202,7 +193,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # 404 with payload @@ -218,7 +208,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # invalid json @@ -234,7 +223,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # a lot of missing elements @@ -248,7 +236,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Bad dataType @@ -285,7 +272,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Huge numBands @@ -322,7 +308,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid dataset dimensions @@ -359,7 +344,6 @@ def test_rda_error_metadata(): with gdaltest.error_handler(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar"}') if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -420,16 +404,12 @@ def test_rda_graph_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 320: - gdaltest.post_reason('fail') return 'fail' if ds.RasterYSize != 300: - gdaltest.post_reason('fail') return 'fail' expected_md = { 'SENSOR_NAME': 'SENSOR_NAME', @@ -444,15 +424,12 @@ def test_rda_graph_nominal(): } got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') print(got_md) return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -464,16 +441,12 @@ def test_rda_graph_nominal(): fd.write('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') ds = gdal.Open('tmp/rda_test1.dgrda') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 320: - gdaltest.post_reason('fail') return 'fail' if ds.RasterYSize != 300: - gdaltest.post_reason('fail') return 'fail' expected_md = { 'SENSOR_NAME': 'SENSOR_NAME', @@ -488,15 +461,12 @@ def test_rda_graph_nominal(): } got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') print(got_md) return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' try: @@ -509,10 +479,8 @@ def test_rda_graph_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -527,15 +495,12 @@ def test_rda_graph_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef().find('32631') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (125.0, 1.0, 0.0, 462.0, 0.0, 2.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -546,7 +511,6 @@ def test_rda_graph_nominal(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') got_gt = ds.GetGeoTransform() if got_gt != (125.0, 1.0, 0.0, 462.0, 0.0, 2.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -562,10 +526,8 @@ def test_rda_graph_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadata('RPC') != {}: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -582,10 +544,8 @@ def test_rda_graph_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetMetadata('RPC') != {}: - gdaltest.post_reason('fail') return 'fail' tile_ds = gdal.GetDriverByName('GTiff').Create('/vsimem/tile_00.tif', 256, 256, 3) @@ -636,7 +596,6 @@ def test_rda_graph_nominal(): with webserver.install_http_handler(handler): cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [54287, 50451, 21110]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -645,33 +604,26 @@ def test_rda_graph_nominal(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [54287, 50451, 21110]: - gdaltest.post_reason('fail') print(cs) return 'fail' data = struct.unpack('B' * (320 * 300 * 3), ds.ReadRaster()) if data[0] != 255: - gdaltest.post_reason('fail') return 'fail' if data[0 + 320 * 300] != 250: - gdaltest.post_reason('fail') return 'fail' if data[0 + 320 * 300 * 2] != 245: - gdaltest.post_reason('fail') return 'fail' if data[319] != 240: - gdaltest.post_reason('fail') return 'fail' if data[320 * 299] != 225: - gdaltest.post_reason('fail') return 'fail' if data[320 * 299 + 319] != 210: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -727,10 +679,8 @@ def test_rda_graph_nominal(): data = struct.unpack('B' * (256 * 256), data) if data[0] != 255: - gdaltest.post_reason('fail') return 'fail' if data[256 * (256 - 2)] != 225: - gdaltest.post_reason('fail') return 'fail' @@ -739,7 +689,6 @@ def test_rda_graph_nominal(): data = ds.GetRasterBand(1).ReadBlock(0, 0) data = struct.unpack('B' * (256 * 256), data) if data[0] != 255: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -756,7 +705,6 @@ def test_rda_graph_nominal(): with gdaltest.error_handler(): data = ds.GetRasterBand(1).ReadBlock(0, 0) if data is not None: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -811,19 +759,14 @@ def test_rda_template_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"template-id": "foo","params": [{"nodeId": "bar"}],"options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 320: - gdaltest.post_reason('fail') return 'fail' if ds.RasterYSize != 300: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -832,10 +775,8 @@ def test_rda_template_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"template-id": "foo","params": [{"nodeId": "bar"}],"options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -850,15 +791,12 @@ def test_rda_template_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"template-id": "foo","params": [{"nodeId": "bar"}],"options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef().find('32631') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (125.0, 1.0, 0.0, 462.0, 0.0, 2.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -869,7 +807,6 @@ def test_rda_template_nominal(): ds = gdal.Open('{"template-id": "foo","params": [{"nodeId": "bar"}],"options":{"delete-on-close":false}}') got_gt = ds.GetGeoTransform() if got_gt != (125.0, 1.0, 0.0, 462.0, 0.0, 2.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -928,7 +865,6 @@ def test_rda_template_nominal(): cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [54287, 50451, 21110]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -937,33 +873,26 @@ def test_rda_template_nominal(): ds = gdal.Open('{"template-id": "foo","params": [{"nodeId": "bar"}],"options":{"delete-on-close":false}}') cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [54287, 50451, 21110]: - gdaltest.post_reason('fail') print(cs) return 'fail' data = struct.unpack('B' * (320 * 300 * 3), ds.ReadRaster()) if data[0] != 255: - gdaltest.post_reason('fail') return 'fail' if data[0 + 320 * 300] != 250: - gdaltest.post_reason('fail') return 'fail' if data[0 + 320 * 300 * 2] != 245: - gdaltest.post_reason('fail') return 'fail' if data[319] != 240: - gdaltest.post_reason('fail') return 'fail' if data[320 * 299] != 225: - gdaltest.post_reason('fail') return 'fail' if data[320 * 299 + 319] != 210: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1051,19 +980,14 @@ def test_rda_template_image_reference_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"templateId": "foo", "nodeId": "bar", "parameters": {"p1": "baz"},"options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 320: - gdaltest.post_reason('fail') return 'fail' if ds.RasterYSize != 300: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1072,10 +996,8 @@ def test_rda_template_image_reference_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"templateId": "foo", "nodeId": "bar", "parameters": {"p1": "baz"},"options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -1090,15 +1012,12 @@ def test_rda_template_image_reference_nominal(): with gdaltest.config_options(config_options): ds = gdal.Open('{"templateId": "foo", "nodeId": "bar", "parameters": {"p1": "baz"},"options":{"delete-on-close":false}}') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetProjectionRef().find('32631') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (125.0, 1.0, 0.0, 462.0, 0.0, 2.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -1109,7 +1028,6 @@ def test_rda_template_image_reference_nominal(): ds = gdal.Open('{"templateId": "foo", "nodeId": "bar", "parameters": {"p1": "baz"},"options":{"delete-on-close":false}}') got_gt = ds.GetGeoTransform() if got_gt != (125.0, 1.0, 0.0, 462.0, 0.0, 2.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' @@ -1168,7 +1086,6 @@ def test_rda_template_image_reference_nominal(): cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [54287, 50451, 21110]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1177,33 +1094,26 @@ def test_rda_template_image_reference_nominal(): ds = gdal.Open('{"templateId": "foo", "nodeId": "bar", "parameters": {"p1": "baz"},"options":{"delete-on-close":false}}') cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] if cs != [54287, 50451, 21110]: - gdaltest.post_reason('fail') print(cs) return 'fail' data = struct.unpack('B' * (320 * 300 * 3), ds.ReadRaster()) if data[0] != 255: - gdaltest.post_reason('fail') return 'fail' if data[0 + 320 * 300] != 250: - gdaltest.post_reason('fail') return 'fail' if data[0 + 320 * 300 * 2] != 245: - gdaltest.post_reason('fail') return 'fail' if data[319] != 240: - gdaltest.post_reason('fail') return 'fail' if data[320 * 299] != 225: - gdaltest.post_reason('fail') return 'fail' if data[320 * 299 + 319] != 210: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1343,7 +1253,6 @@ def test_rda_download_queue(): with webserver.install_http_handler(handler): data = ds.ReadRaster(0, 1, 4, 2) if data != ref_data: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1403,7 +1312,6 @@ def test_rda_rpc(): ds = gdal.Open('{"graph-id":"foo","node-id":"bar","options":{"delete-on-close":false}}') md = ds.GetMetadata('RPC') if md != {}: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -1420,7 +1328,6 @@ def test_rda_rpc(): with gdaltest.error_handler(): md = ds.GetMetadata('RPC') if md != {}: - gdaltest.post_reason('fail') return 'fail' gdal.RmdirRecursive('/vsimem/cache_dir') @@ -1438,7 +1345,6 @@ def test_rda_rpc(): for key in expected_md: if not key.endswith('_COEFF'): if abs(float(expected_md[key]) - float(md[key])) > 1e-8 * abs(float(expected_md[key])): - gdaltest.post_reason('fail') print(key, md) return 'fail' else: @@ -1446,7 +1352,6 @@ def test_rda_rpc(): got_vals = [float(v) for v in md[key].split(' ')] for x in range(20): if abs(expected_vals[x] - got_vals[x]) > 1e-8 * abs(expected_vals[x]): - gdaltest.post_reason('fail') print(key, md) return 'fail' ds = None @@ -1672,7 +1577,6 @@ def test_rda_bad_tile(): with gdaltest.error_handler(): data = ds.ReadRaster() if data is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1688,7 +1592,6 @@ def test_rda_bad_tile(): with gdaltest.error_handler(): data = ds.GetRasterBand(1).ReadBlock(0, 0) if data is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1704,7 +1607,6 @@ def test_rda_bad_tile(): with gdaltest.error_handler(): data = ds.ReadRaster() if data is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1720,7 +1622,6 @@ def test_rda_bad_tile(): with gdaltest.error_handler(): data = ds.GetRasterBand(1).ReadBlock(0, 0) if data is not None: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/rl2.py b/autotest/gdrivers/rl2.py index 59ec832cf174..2df7ba3c6e85 100755 --- a/autotest/gdrivers/rl2.py +++ b/autotest/gdrivers/rl2.py @@ -71,7 +71,6 @@ def test_rl2_2(): cs = ds.GetRasterBand(1).Checksum() if cs != 4672: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -85,29 +84,23 @@ def test_rl2_2(): wkt = ds.GetProjectionRef() if wkt.find('26711') < 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_GrayIndex: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMinimum() != 74: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is not None: - gdaltest.post_reason('fail') return 'fail' subds = ds.GetSubDatasets() expected_subds = [] if subds != expected_subds: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('RL2_SHOW_ALL_PYRAMID_LEVELS', 'YES') @@ -116,7 +109,6 @@ def test_rl2_2(): cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 1087: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -134,37 +126,31 @@ def test_rl2_3(): ds = gdal.Open('data/small_world.rl2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).GetNoDataValue() cs = ds.GetRasterBand(1).Checksum() if cs != 25550: - gdaltest.post_reason('fail') print(cs) return 'fail' cs = ds.GetRasterBand(2).Checksum() if cs != 28146: - gdaltest.post_reason('fail') print(cs) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(1).Checksum() if cs != 51412: - gdaltest.post_reason('fail') print(cs) return 'fail' subds = ds.GetSubDatasets() expected_subds = [('RASTERLITE2:data/small_world.rl2:small_world:1:world_west', 'Coverage small_world, section world_west / 1'), ('RASTERLITE2:data/small_world.rl2:small_world:2:world_east', 'Coverage small_world, section world_east / 2')] if subds != expected_subds: - gdaltest.post_reason('fail') print(subds) return 'fail' @@ -172,17 +158,14 @@ def test_rl2_3(): cs = ds.GetRasterBand(1).Checksum() if cs != 3721: - gdaltest.post_reason('fail') print(cs) return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 35686: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -200,32 +183,26 @@ def test_rl2_4(): ds = gdal.Open('data/small_world_pct.rl2') if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_PaletteIndex: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 14890: - gdaltest.post_reason('fail') print(cs) return 'fail' pct = ds.GetRasterBand(1).GetColorTable() if pct.GetCount() != 256: - gdaltest.post_reason('fail') return 'fail' if pct.GetColorEntry(1) != (176, 184, 176, 255): - gdaltest.post_reason('fail') print(pct.GetColorEntry(1)) return 'fail' pct = ds.GetRasterBand(1).GetColorTable() if pct.GetCount() != 256: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs != 35614: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -245,7 +222,6 @@ def test_rl2_5(): subds = ds.GetSubDatasets() expected_subds = [('RASTERLITE2:data/multi_type.rl2:uint8', 'Coverage uint8'), ('RASTERLITE2:data/multi_type.rl2:int8', 'Coverage int8'), ('RASTERLITE2:data/multi_type.rl2:uint16', 'Coverage uint16'), ('RASTERLITE2:data/multi_type.rl2:int16', 'Coverage int16'), ('RASTERLITE2:data/multi_type.rl2:uint32', 'Coverage uint32'), ('RASTERLITE2:data/multi_type.rl2:int32', 'Coverage int32'), ('RASTERLITE2:data/multi_type.rl2:float', 'Coverage float'), ('RASTERLITE2:data/multi_type.rl2:double', 'Coverage double'), ('RASTERLITE2:data/multi_type.rl2:1bit', 'Coverage 1bit'), ('RASTERLITE2:data/multi_type.rl2:2bit', 'Coverage 2bit'), ('RASTERLITE2:data/multi_type.rl2:4bit', 'Coverage 4bit')] if subds != expected_subds: - gdaltest.post_reason('fail') print(subds) return 'fail' @@ -261,17 +237,14 @@ def test_rl2_5(): for (subds_name, dt, expected_cs) in tests: ds = gdal.Open(subds_name) if ds.GetRasterBand(1).DataType != dt: - gdaltest.post_reason('fail') print(subds_name) return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != expected_cs: - gdaltest.post_reason('fail') print(cs) return 'fail' if subds_name == 'RASTERLITE2:data/multi_type.rl2:int8': if ds.GetRasterBand(1).GetMetadataItem('PIXELTYPE', 'IMAGE_STRUCTURE') != 'SIGNEDBYTE': - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetMetadataItem('PIXELTYPE', 'IMAGE_STRUCTURE')) return 'fail' @@ -557,16 +530,13 @@ def test_rl2_22(): ds = None ds = gdaltest.rl2_drv.CreateCopy('/vsimem/rl2_22.rl2', src_ds, options=['APPEND_SUBDATASET=YES', 'COVERAGE=byte']) if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None ds = gdal.OpenEx('/vsimem/rl2_22.rl2') if ds.RasterXSize != 20: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' left_ds = gdal.Translate('left', src_ds, srcWin=[0, 0, 10, 20], format='MEM') @@ -575,14 +545,12 @@ def test_rl2_22(): gdaltest.rl2_drv.CreateCopy('/vsimem/rl2_22.rl2', left_ds, options=['COVERAGE=left_right']) ds = gdaltest.rl2_drv.CreateCopy('/vsimem/rl2_22.rl2', right_ds, options=['APPEND_SUBDATASET=YES', 'COVERAGE=left_right', 'SECTION=right']) if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' src_ds = gdal.Open('data/rgbsmall.tif') ds = gdaltest.rl2_drv.CreateCopy('/vsimem/rl2_22.rl2', src_ds, options=['APPEND_SUBDATASET=YES', 'COVERAGE=rgbsmall']) if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).Checksum()) return 'fail' ds = None @@ -605,24 +573,19 @@ def test_rl2_23(): ds = gdaltest.rl2_drv.CreateCopy('/vsimem/rl2_23.rl2', src_ds) ret = ds.BuildOverviews('NEAR', [2]) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 5: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' cs = ds.GetRasterBand(1).GetOverview(0).Checksum() if cs == 0: - gdaltest.post_reason('fail') print(cs) return 'fail' ret = ds.BuildOverviews('NONE', []) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('/vsimem/rl2_23.rl2') if ds.GetRasterBand(1).GetOverviewCount() == 5: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetOverviewCount()) return 'fail' ds = None diff --git a/autotest/gdrivers/rraster.py b/autotest/gdrivers/rraster.py index 40ecec87f809..8754f8881bc5 100755 --- a/autotest/gdrivers/rraster.py +++ b/autotest/gdrivers/rraster.py @@ -55,11 +55,9 @@ def test_rraster_1(filename='data/byte_rraster.grd', check_prj=None): ds = gdal.Open(filename) md = ds.GetMetadata() if md != {'CREATOR': "R package 'raster'", 'CREATED': '2016-06-25 17:32:47'}: - gdaltest.post_reason('fail') print(md) return 'fail' if ds.GetRasterBand(1).GetDescription() != 'byte': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -352,10 +350,8 @@ def test_rraster_signedbyte(): ds = gdal.Open(filename2) if ds.GetRasterBand(1).GetMetadataItem('PIXELTYPE', 'IMAGE_STRUCTURE') != 'SIGNEDBYTE': - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMinimum() != -124: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -381,11 +377,9 @@ def test_rraster_datatypes(): gdal.Translate(filename, src_ds, format='RRASTER') ds = gdal.Open(filename) if ds.GetRasterBand(1).DataType != src_ds.GetRasterBand(1).DataType: - gdaltest.post_reason('fail') print(srcfilename) return 'fail' if ds.GetRasterBand(1).Checksum() != src_ds.GetRasterBand(1).Checksum(): - gdaltest.post_reason('fail') print(srcfilename) return 'fail' @@ -408,10 +402,8 @@ def test_rraster_nodata_and_metadata(): ds = None ds = gdal.Open(filename) if ds.GetMetadata() != {'CREATOR': 'GDAL', 'CREATED': 'Today'}: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -429,13 +421,11 @@ def test_rraster_update(): gdal.Open(filename, gdal.GA_Update) ds = gdal.Open(filename, gdal.GA_Update) if ds.GetRasterBand(1).Checksum() != 4672: - gdaltest.post_reason('fail') return 'fail' ds.GetRasterBand(1).Fill(0) ds = None ds = gdal.Open(filename) if ds.GetRasterBand(1).Checksum() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -457,16 +447,12 @@ def test_rraster_colorinterpretation(): ds = None ds = gdal.Open(filename) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(2).GetColorInterpretation() != gdal.GCI_GreenBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(3).GetColorInterpretation() != gdal.GCI_BlueBand: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/gdrivers/rs2.py b/autotest/gdrivers/rs2.py index af83ace77396..d84120607564 100755 --- a/autotest/gdrivers/rs2.py +++ b/autotest/gdrivers/rs2.py @@ -72,7 +72,6 @@ def test_rs2_3(): 'SAMP_OFF': 'pixelOffset', 'SAMP_SCALE': 'pixelScale'} if got_rpc != expected_rpc: - gdaltest.post_reason('fail') print(got_rpc) return 'fail' return 'success' diff --git a/autotest/gdrivers/sentinel2.py b/autotest/gdrivers/sentinel2.py index 7f29ccf547c4..b7cbd430c4c9 100755 --- a/autotest/gdrivers/sentinel2.py +++ b/autotest/gdrivers/sentinel2.py @@ -46,7 +46,6 @@ def test_sentinel2_l1c_1(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUD_COVERAGE_ASSESSMENT': '0.0', @@ -79,7 +78,6 @@ def test_sentinel2_l1c_1(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -94,7 +92,6 @@ def test_sentinel2_l1c_1(): 'SUBDATASET_4_NAME': 'SENTINEL2_L1C:data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/S2A_OPER_MTD_SAFL1C.xml:PREVIEW:EPSG_32632'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -105,7 +102,6 @@ def test_sentinel2_l1c_1(): if os.path.exists('tmp/S2A_OPER_PRD_MSIL1C.zip'): ds = gdal.Open('tmp/S2A_OPER_PRD_MSIL1C.zip') if ds is None: - gdaltest.post_reason('fail') return 'fail' os.unlink('tmp/S2A_OPER_PRD_MSIL1C.zip') @@ -114,7 +110,6 @@ def test_sentinel2_l1c_1(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -131,7 +126,6 @@ def test_sentinel2_l1c_1(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -147,7 +141,6 @@ def test_sentinel2_l1c_2(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L1C:%s:10m:EPSG_32632' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUD_COVERAGE_ASSESSMENT': '0.0', @@ -179,29 +172,24 @@ def test_sentinel2_l1c_2(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 20984 or ds.RasterYSize != 20980: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32632') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (699960.0, 10.0, 0.0, 5100060.0, 0.0, -10.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 4: - gdaltest.post_reason('fail') return 'fail' vrt = ds.GetMetadata('xml:VRT')[0] @@ -220,12 +208,10 @@ def test_sentinel2_l1c_2(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -238,27 +224,22 @@ def test_sentinel2_l1c_2(): 'WAVELENGTH': '665', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '12': - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(4) if band.GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' got_md = band.GetMetadata() @@ -270,7 +251,6 @@ def test_sentinel2_l1c_2(): 'WAVELENGTH': '842', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -286,23 +266,19 @@ def test_sentinel2_l1c_3(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/S2A_OPER_MTD_SAFL1C.xml' ds = gdal.OpenEx('SENTINEL2_L1C:%s:60m:EPSG_32632' % filename_xml, open_options=['ALPHA=YES']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 4: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(4) if band.GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() cs = band.Checksum() if cs != 0 or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' band.ReadRaster() @@ -318,28 +294,23 @@ def test_sentinel2_l1c_4(): filename_xml = 'data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/S2A_OPER_MTD_SAFL1C.xml' ds = gdal.OpenEx('SENTINEL2_L1C:%s:PREVIEW:EPSG_32632' % filename_xml) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' fl = ds.GetFileList() # main XML + 2 granule XML + 2 jp2 if len(fl) != 1 + 2 + 2: - gdaltest.post_reason('fail') import pprint pprint.pprint(fl) return 'fail' band = ds.GetRasterBand(1) if band.GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if band.DataType != gdal.GDT_Byte: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -358,13 +329,11 @@ def test_sentinel2_l1c_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1C:/vsimem/test.xml:10m:EPSG_32632') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # File is OK, but granule MTD are missing @@ -439,14 +408,12 @@ def test_sentinel2_l1c_5(): with gdaltest.error_handler(): gdal.Open('/vsimem/test.xml') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1C:/vsimem/test.xml:10m:EPSG_32632') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Product_Info @@ -460,14 +427,12 @@ def test_sentinel2_l1c_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1C:/vsimem/test.xml:10m:EPSG_32632') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Product_Organisation @@ -482,14 +447,12 @@ def test_sentinel2_l1c_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1C:/vsimem/test.xml:10m:EPSG_32632') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Band_List @@ -507,7 +470,6 @@ def test_sentinel2_l1c_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No valid bands @@ -530,7 +492,6 @@ def test_sentinel2_l1c_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/test.xml') @@ -552,14 +513,12 @@ def test_sentinel2_l1c_6(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' subds_name = ds.GetMetadataItem('SUBDATASET_1_NAME', 'SUBDATASETS') gdal.ErrorReset() ds = gdal.Open(subds_name) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -630,7 +589,6 @@ def test_sentinel2_l1c_7(): ds = gdal.Open('SENTINEL2_L1C:/vsimem/test.xml:60m:EPSG_32753') nbits = ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') if nbits != '10': - gdaltest.post_reason('fail') print(nbits) return 'fail' @@ -649,7 +607,6 @@ def test_sentinel2_l1c_tile_1(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUDY_PIXEL_PERCENTAGE': '0', @@ -685,7 +642,6 @@ def test_sentinel2_l1c_tile_1(): 'TILE_ID': 'S2A_OPER_MSI_L1C_TL_MTI__20151231T235959_A000123_T32TQR_N01.03'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -700,7 +656,6 @@ def test_sentinel2_l1c_tile_1(): 'SUBDATASET_4_NAME': 'SENTINEL2_L1C_TILE:data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml:PREVIEW'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -710,7 +665,6 @@ def test_sentinel2_l1c_tile_1(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -722,7 +676,6 @@ def test_sentinel2_l1c_tile_1(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -740,7 +693,6 @@ def test_sentinel2_l1c_tile_2(): ds = gdal.Open(filename_xml) gdal.SetConfigOption('SENTINEL2_USE_MAIN_MTD', None) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUDY_PIXEL_PERCENTAGE': '0', @@ -751,7 +703,6 @@ def test_sentinel2_l1c_tile_2(): 'TILE_ID': 'S2A_OPER_MSI_L1C_TL_MTI__20151231T235959_A000123_T32TQR_N01.03'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -766,7 +717,6 @@ def test_sentinel2_l1c_tile_2(): 'SUBDATASET_4_NAME': 'SENTINEL2_L1C_TILE:data/fake_sentinel2_l1c/S2A_OPER_PRD_MSIL1C.SAFE/GRANULE/S2A_OPER_MSI_L1C_T32TQR_N01.03/S2A_OPER_MTD_L1C_T32TQR.xml:PREVIEW'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -783,7 +733,6 @@ def test_sentinel2_l1c_tile_3(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L1C_TILE:%s:10m' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUDY_PIXEL_PERCENTAGE': '0', @@ -819,29 +768,24 @@ def test_sentinel2_l1c_tile_3(): 'TILE_ID': 'S2A_OPER_MSI_L1C_TL_MTI__20151231T235959_A000123_T32TQR_N01.03'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 10980 or ds.RasterYSize != 10980: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32632') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (699960.0, 10.0, 0.0, 5100060.0, 0.0, -10.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 4: - gdaltest.post_reason('fail') return 'fail' vrt = ds.GetMetadata('xml:VRT')[0] @@ -853,12 +797,10 @@ def test_sentinel2_l1c_tile_3(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -871,27 +813,22 @@ def test_sentinel2_l1c_tile_3(): 'WAVELENGTH': '665', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '12': - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(4) if band.GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' got_md = band.GetMetadata() @@ -903,7 +840,6 @@ def test_sentinel2_l1c_tile_3(): 'WAVELENGTH': '842', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -922,7 +858,6 @@ def test_sentinel2_l1c_tile_4(): ds = gdal.OpenEx('SENTINEL2_L1C_TILE:%s:10m' % filename_xml, open_options=['ALPHA=YES']) gdal.SetConfigOption('SENTINEL2_USE_MAIN_MTD', None) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUDY_PIXEL_PERCENTAGE': '0', @@ -933,29 +868,24 @@ def test_sentinel2_l1c_tile_4(): 'TILE_ID': 'S2A_OPER_MSI_L1C_TL_MTI__20151231T235959_A000123_T32TQR_N01.03'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 10980 or ds.RasterYSize != 10980: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32632') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (699960.0, 10.0, 0.0, 5100060.0, 0.0, -10.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 5: - gdaltest.post_reason('fail') return 'fail' vrt = ds.GetMetadata('xml:VRT')[0] @@ -967,12 +897,10 @@ def test_sentinel2_l1c_tile_4(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -983,27 +911,22 @@ def test_sentinel2_l1c_tile_4(): 'WAVELENGTH': '665', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '12': - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(5) if band.GetColorInterpretation() != gdal.GCI_AlphaBand: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1018,27 +941,22 @@ def test_sentinel2_l1c_tile_5(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L1C_TILE:%s:PREVIEW' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 343 or ds.RasterYSize != 343: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32632') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (699960.0, 320.0, 0.0, 5100060.0, 0.0, -320.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' vrt = ds.GetMetadata('xml:VRT')[0] @@ -1050,7 +968,6 @@ def test_sentinel2_l1c_tile_5(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' @@ -1070,13 +987,11 @@ def test_sentinel2_l1c_tile_6(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1C_TILE:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/GRANULE/S2A_OPER_MSI_L1C_bla_N01.03/S2A_OPER_MTD_L1C_bla.xml', @@ -1110,7 +1025,6 @@ def test_sentinel2_l1c_tile_6(): with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1C_TILE:/vsimem/GRANULE/S2A_OPER_MSI_L1C_bla_N01.03/S2A_OPER_MTD_L1C_bla.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/test.xml') @@ -1128,7 +1042,6 @@ def test_sentinel2_l1b_1(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUD_COVERAGE_ASSESSMENT': '0.0', @@ -1158,7 +1071,6 @@ def test_sentinel2_l1b_1(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1171,7 +1083,6 @@ def test_sentinel2_l1b_1(): 'SUBDATASET_3_NAME': 'SENTINEL2_L1B:data/fake_sentinel2_l1b/S2B_OPER_PRD_MSIL1B.SAFE/GRANULE/S2B_OPER_MSI_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1181,7 +1092,6 @@ def test_sentinel2_l1b_1(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -1194,7 +1104,6 @@ def test_sentinel2_l1b_1(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -1210,7 +1119,6 @@ def test_sentinel2_l1b_2(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUDY_PIXEL_PERCENTAGE': '0', @@ -1249,7 +1157,6 @@ def test_sentinel2_l1b_2(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1262,7 +1169,6 @@ def test_sentinel2_l1b_2(): 'SUBDATASET_3_NAME': 'SENTINEL2_L1B:data/fake_sentinel2_l1b/S2B_OPER_PRD_MSIL1B.SAFE/GRANULE/S2B_OPER_MSI_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != subdatasets_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1275,11 +1181,9 @@ def test_sentinel2_l1b_2(): finally: os.chdir(cwd) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1295,7 +1199,6 @@ def test_sentinel2_l1b_3(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L1B:data/fake_sentinel2_l1b/S2B_OPER_PRD_MSIL1B.SAFE/GRANULE/S2B_OPER_MSI_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m') if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUDY_PIXEL_PERCENTAGE': '0', @@ -1334,24 +1237,20 @@ def test_sentinel2_l1b_3(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 1276 or ds.RasterYSize != 384: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetGCPProjection().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' gcps = ds.GetGCPs() if len(gcps) != 5: - gdaltest.post_reason('fail') print(len(gcps)) return 'fail' @@ -1360,7 +1259,6 @@ def test_sentinel2_l1b_3(): gcps[0].GCPX != 11 or \ gcps[0].GCPY != 46 or \ gcps[0].GCPZ != 1: - gdaltest.post_reason('fail') print(gcps[0]) return 'fail' @@ -1369,7 +1267,6 @@ def test_sentinel2_l1b_3(): gcps[1].GCPX != 11 or \ gcps[1].GCPY != 45 or \ gcps[1].GCPZ != 2: - gdaltest.post_reason('fail') print(gcps[1]) return 'fail' @@ -1378,7 +1275,6 @@ def test_sentinel2_l1b_3(): gcps[2].GCPX != 13 or \ gcps[2].GCPY != 45 or \ gcps[2].GCPZ != 3: - gdaltest.post_reason('fail') print(gcps[2]) return 'fail' @@ -1387,7 +1283,6 @@ def test_sentinel2_l1b_3(): gcps[3].GCPX != 13 or \ gcps[3].GCPY != 46 or \ gcps[3].GCPZ != 4: - gdaltest.post_reason('fail') print(gcps[3]) return 'fail' @@ -1396,12 +1291,10 @@ def test_sentinel2_l1b_3(): gcps[4].GCPX != 12 or \ gcps[4].GCPY != 45.5 or \ gcps[4].GCPZ != 2.5: - gdaltest.post_reason('fail') print(gcps[4]) return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' vrt = ds.GetMetadata('xml:VRT')[0] @@ -1413,12 +1306,10 @@ def test_sentinel2_l1b_3(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -1429,17 +1320,14 @@ def test_sentinel2_l1b_3(): 'WAVELENGTH': '443', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '12': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1510,7 +1398,6 @@ def test_sentinel2_l1b_4(): """) ds = gdal.Open('SENTINEL2_L1B:/vsimem/foo/GRANULE/S2B_OPER_MTD_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m') if ds.RasterXSize != 500: - gdaltest.post_reason('fail') return 'fail' # With standard granule metadata (with Granule_Dimensions) @@ -1536,7 +1423,6 @@ def test_sentinel2_l1b_4(): 'SUBDATASET_1_NAME': 'SENTINEL2_L1B:/vsimem/foo/GRANULE/S2B_OPER_MTD_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1544,10 +1430,8 @@ def test_sentinel2_l1b_4(): ds = gdal.OpenEx('SENTINEL2_L1B:/vsimem/foo/GRANULE/S2B_OPER_MTD_L1B_N01.03/S2B_OPER_MTD_L1B.xml:60m', open_options=['ALPHA=YES']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 2: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1570,7 +1454,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Product_Info @@ -1584,7 +1467,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Product_Organisation @@ -1599,14 +1481,12 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1B:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Band_List @@ -1624,7 +1504,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No valid bands @@ -1647,7 +1526,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid XML @@ -1658,14 +1536,12 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1B:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No Granule_Dimensions @@ -1681,7 +1557,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1B:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No ROWS @@ -1703,7 +1578,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1B:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # No NCOLS @@ -1725,7 +1599,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1B:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Not the desired resolution @@ -1743,7 +1616,6 @@ def test_sentinel2_l1b_5(): with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L1B:/vsimem/test.xml:10m') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/test.xml') @@ -1761,7 +1633,6 @@ def test_sentinel2_l2a_1(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'AOT_RETRIEVAL_ACCURACY': '0', @@ -1816,7 +1687,6 @@ def test_sentinel2_l2a_1(): 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1827,7 +1697,6 @@ def test_sentinel2_l2a_1(): 'SUBDATASET_2_NAME': 'SENTINEL2_L2A:data/fake_sentinel2_l2a/S2A_USER_PRD_MSIL2A.SAFE/S2A_USER_MTD_SAFL2A.xml:PREVIEW:EPSG_32632'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -1837,7 +1706,6 @@ def test_sentinel2_l2a_1(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -1854,7 +1722,6 @@ def test_sentinel2_l2a_1(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -1870,7 +1737,6 @@ def test_sentinel2_l2a_2(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L2A:%s:60m:EPSG_32632' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'AOT_RETRIEVAL_ACCURACY': '0', @@ -1924,29 +1790,24 @@ def test_sentinel2_l2a_2(): 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 1830 or ds.RasterYSize != 1830: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32632') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (699960.0, 60.0, 0.0, 5100060.0, 0.0, -60.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 17: - gdaltest.post_reason('fail') print(ds.RasterCount) return 'fail' @@ -1959,12 +1820,10 @@ def test_sentinel2_l2a_2(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -1977,25 +1836,21 @@ def test_sentinel2_l2a_2(): 'WAVELENGTH': '443', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(13) if band.GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' got_md = band.GetMetadata() expected_md = {'BANDNAME': 'AOT'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2005,7 +1860,6 @@ def test_sentinel2_l2a_2(): if ds.GetRasterBand(i + 1).GetMetadataItem('BANDNAME') == 'SCL': scl_band = i + 1 if scl_band == 0: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(scl_band) expected_categories = ['NODATA', @@ -2022,7 +1876,6 @@ def test_sentinel2_l2a_2(): 'SNOW_ICE'] got_categories = band.GetCategoryNames() if got_categories != expected_categories: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_categories) return 'fail' @@ -2043,13 +1896,11 @@ def test_sentinel2_l2a_3(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/test.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L2A:/vsimem/test.xml:10m:EPSG_32632') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # File is OK, but granule MTD are missing @@ -2095,14 +1946,12 @@ def test_sentinel2_l2a_3(): with gdaltest.error_handler(): gdal.Open('/vsimem/test.xml') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): ds = gdal.Open('SENTINEL2_L2A:/vsimem/test.xml:10m:EPSG_32632') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/test.xml') @@ -2119,7 +1968,6 @@ def test_sentinel2_l2a_4(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = { @@ -2173,7 +2021,6 @@ def test_sentinel2_l2a_4(): 'WVP_QUANTIFICATION_VALUE_UNIT': 'cm'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2197,7 +2044,6 @@ def test_sentinel2_l2a_4(): 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2A/S2A_MSIL2A_20180818T094031_N0208_R036_T34VFJ_20180818T120345.SAFE/MTD_MSIL2A.xml:TCI:EPSG_32634'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2207,7 +2053,6 @@ def test_sentinel2_l2a_4(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -2224,7 +2069,6 @@ def test_sentinel2_l2a_4(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -2241,7 +2085,6 @@ def test_sentinel2_l2a_5(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L2A:%s:60m:EPSG_32634' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = { @@ -2294,29 +2137,24 @@ def test_sentinel2_l2a_5(): 'WVP_QUANTIFICATION_VALUE_UNIT': 'cm'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 1830 or ds.RasterYSize != 1830: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32634') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (600000.0, 60.0, 0.0, 6400020.0, 0.0, -60.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 2: - gdaltest.post_reason('fail') print(ds.RasterCount) return 'fail' @@ -2329,12 +2167,10 @@ def test_sentinel2_l2a_5(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -2347,13 +2183,11 @@ def test_sentinel2_l2a_5(): 'WAVELENGTH': '443', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2368,7 +2202,6 @@ def test_sentinel2_l2a_6(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = { @@ -2427,7 +2260,6 @@ def test_sentinel2_l2a_6(): 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0.0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2451,7 +2283,6 @@ def test_sentinel2_l2a_6(): 'SENTINEL2_L2A:data/fake_sentinel2_l2a_MSIL2Ap/S2A_MSIL2A_20170823T094031_N0205_R036_T34VFJ_20170823T094252.SAFE/MTD_MSIL2A.xml:TCI:EPSG_32634'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2461,7 +2292,6 @@ def test_sentinel2_l2a_6(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -2478,7 +2308,6 @@ def test_sentinel2_l2a_6(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -2495,7 +2324,6 @@ def test_sentinel2_l2a_7(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L2A:%s:60m:EPSG_32634' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = { @@ -2553,29 +2381,24 @@ def test_sentinel2_l2a_7(): 'WATER_VAPOUR_RETRIEVAL_ACCURACY': '0.0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 1830 or ds.RasterYSize != 1830: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32634') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (600000.0, 60.0, 0.0, 6400020.0, 0.0, -60.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 2: - gdaltest.post_reason('fail') print(ds.RasterCount) return 'fail' @@ -2588,12 +2411,10 @@ def test_sentinel2_l2a_7(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -2606,13 +2427,11 @@ def test_sentinel2_l2a_7(): 'WAVELENGTH': '443', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2628,7 +2447,6 @@ def test_sentinel2_l1c_safe_compact_1(): gdal.ErrorReset() ds = gdal.Open(filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUD_COVERAGE_ASSESSMENT': '0.0', @@ -2661,7 +2479,6 @@ def test_sentinel2_l1c_safe_compact_1(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2676,7 +2493,6 @@ def test_sentinel2_l1c_safe_compact_1(): 'SUBDATASET_4_NAME': 'SENTINEL2_L1C:data/fake_sentinel2_l1c_safecompact/S2A_MSIL1C_test.SAFE/MTD_MSIL1C.xml:TCI:EPSG_32632'} got_md = ds.GetMetadata('SUBDATASETS') if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2686,7 +2502,6 @@ def test_sentinel2_l1c_safe_compact_1(): gdal.ErrorReset() ds = gdal.Open(got_md['SUBDATASET_%d_NAME' % (i + 1)]) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(got_md['SUBDATASET_%d_NAME' % (i + 1)]) return 'fail' @@ -2703,7 +2518,6 @@ def test_sentinel2_l1c_safe_compact_1(): with gdaltest.error_handler(): ds = gdal.Open(name) if ds is not None: - gdaltest.post_reason('fail') print(name) return 'fail' @@ -2713,7 +2527,6 @@ def test_sentinel2_l1c_safe_compact_1(): if os.path.exists('tmp/S2A_MSIL1C_test.zip'): ds = gdal.Open('tmp/S2A_MSIL1C_test.zip') if ds is None: - gdaltest.post_reason('fail') return 'fail' os.unlink('tmp/S2A_MSIL1C_test.zip') @@ -2729,7 +2542,6 @@ def test_sentinel2_l1c_safe_compact_2(): gdal.ErrorReset() ds = gdal.Open('SENTINEL2_L1C:%s:10m:EPSG_32632' % filename_xml) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' expected_md = {'CLOUD_COVERAGE_ASSESSMENT': '0.0', @@ -2761,29 +2573,24 @@ def test_sentinel2_l1c_safe_compact_2(): 'SPECIAL_VALUE_SATURATED': '0'} got_md = ds.GetMetadata() if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if ds.RasterXSize != 10980 or ds.RasterYSize != 10980: - gdaltest.post_reason('fail') print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if ds.GetProjectionRef().find('32632') < 0: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() if got_gt != (699960.0, 10.0, 0.0, 5100060.0, 0.0, -10.0): - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.RasterCount != 4: - gdaltest.post_reason('fail') return 'fail' vrt = ds.GetMetadata('xml:VRT')[0] @@ -2796,12 +2603,10 @@ def test_sentinel2_l1c_safe_compact_2(): """ if vrt.find(placement_vrt) < 0: - gdaltest.post_reason('fail') print(vrt) return 'fail' if ds.GetMetadata('xml:SENTINEL2') is None: - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(1) @@ -2814,27 +2619,22 @@ def test_sentinel2_l1c_safe_compact_2(): 'WAVELENGTH': '665', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' if band.GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if band.DataType != gdal.GDT_UInt16: - gdaltest.post_reason('fail') return 'fail' if band.GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != '12': - gdaltest.post_reason('fail') return 'fail' band = ds.GetRasterBand(4) if band.GetColorInterpretation() != gdal.GCI_Undefined: - gdaltest.post_reason('fail') return 'fail' got_md = band.GetMetadata() @@ -2846,7 +2646,6 @@ def test_sentinel2_l1c_safe_compact_2(): 'WAVELENGTH': '842', 'WAVELENGTH_UNIT': 'nm'} if got_md != expected_md: - gdaltest.post_reason('fail') import pprint pprint.pprint(got_md) return 'fail' @@ -2862,28 +2661,23 @@ def test_sentinel2_l1c_safe_compact_3(): filename_xml = 'data/fake_sentinel2_l1c_safecompact/S2A_MSIL1C_test.SAFE/MTD_MSIL1C.xml' ds = gdal.OpenEx('SENTINEL2_L1C:%s:TCI:EPSG_32632' % filename_xml) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 3: - gdaltest.post_reason('fail') return 'fail' fl = ds.GetFileList() # main XML + 1 granule XML + 1 jp2 if len(fl) != 1 + 1 + 1: - gdaltest.post_reason('fail') import pprint pprint.pprint(fl) return 'fail' band = ds.GetRasterBand(1) if band.GetColorInterpretation() != gdal.GCI_RedBand: - gdaltest.post_reason('fail') return 'fail' if band.DataType != gdal.GDT_Byte: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/srp.py b/autotest/gdrivers/srp.py index d034266fe66a..ae49b07792dd 100755 --- a/autotest/gdrivers/srp.py +++ b/autotest/gdrivers/srp.py @@ -51,21 +51,17 @@ def test_srp_1(filename='USRP_PCB0/FKUSRP01.IMG'): ds = gdal.Open('data/' + filename) if ds.GetRasterBand(1).GetColorInterpretation() != gdal.GCI_PaletteIndex: - gdaltest.post_reason('fail') return 'fail' ct = ds.GetRasterBand(1).GetColorTable() if ct.GetCount() != 4: - gdaltest.post_reason('fail') return 'fail' if ct.GetColorEntry(0) != (0, 0, 0, 255): - gdaltest.post_reason('fail') print(ct.GetColorEntry(0)) return 'fail' if ct.GetColorEntry(1) != (255, 0, 0, 255): - gdaltest.post_reason('fail') print(ct.GetColorEntry(1)) return 'fail' @@ -124,12 +120,10 @@ def test_srp_5(): subdatasets = ds.GetMetadata('SUBDATASETS') if subdatasets['SUBDATASET_1_NAME'] != 'SRP:data/USRP_PCB0/FKUSRP01.GEN,data/USRP_PCB0/FKUSRP01.IMG' and \ subdatasets['SUBDATASET_1_NAME'] != 'SRP:data/USRP_PCB0\\FKUSRP01.GEN,data/USRP_PCB0\\FKUSRP01.IMG': - gdaltest.post_reason('fail') print(subdatasets) return 'fail' if subdatasets['SUBDATASET_1_DESC'] != 'SRP:data/USRP_PCB0/FKUSRP01.GEN,data/USRP_PCB0/FKUSRP01.IMG' and \ subdatasets['SUBDATASET_1_DESC'] != 'SRP:data/USRP_PCB0\\FKUSRP01.GEN,data/USRP_PCB0\\FKUSRP01.IMG': - gdaltest.post_reason('fail') print(subdatasets) return 'fail' diff --git a/autotest/gdrivers/srtmhgt.py b/autotest/gdrivers/srtmhgt.py index 1042ff145e8d..d9c39002c0d2 100755 --- a/autotest/gdrivers/srtmhgt.py +++ b/autotest/gdrivers/srtmhgt.py @@ -141,7 +141,6 @@ def test_srtmhgt_4(): ds = gdal.Open('/vsimem/N43W080.SRTMSWBD.raw.zip') if ds is None: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() ds = None diff --git a/autotest/gdrivers/tiff_profile.py b/autotest/gdrivers/tiff_profile.py index 983aed76ffcd..921f7c178689 100755 --- a/autotest/gdrivers/tiff_profile.py +++ b/autotest/gdrivers/tiff_profile.py @@ -61,13 +61,11 @@ def test_tiff_write_icc(): try: os.stat('tmp/icc_test.tiff.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -77,13 +75,11 @@ def test_tiff_write_icc(): try: os.stat('tmp/icc_test.tiff.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with GetMetadataItem() @@ -93,13 +89,11 @@ def test_tiff_write_icc(): try: os.stat('tmp/icc_test.tiff.aux.xml') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if source_icc_profile != icc: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') @@ -130,7 +124,6 @@ def test_tiff_copy_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -140,7 +133,6 @@ def test_tiff_copy_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') @@ -172,7 +164,6 @@ def test_tiff_copy_options_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -182,7 +173,6 @@ def test_tiff_copy_options_icc(): ds2 = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') @@ -236,7 +226,6 @@ def test_tiff_copy_options_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' tifftag_transferfunction2 = ( @@ -245,7 +234,6 @@ def test_tiff_copy_options_colorimetric_data(): eval('[' + md['TIFFTAG_TRANSFERFUNCTION_BLUE'] + ']')) if tifftag_transferfunction2 != tifftag_transferfunction: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -258,7 +246,6 @@ def test_tiff_copy_options_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -269,7 +256,6 @@ def test_tiff_copy_options_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' tifftag_transferfunction2 = ( @@ -278,7 +264,6 @@ def test_tiff_copy_options_colorimetric_data(): eval('[' + md['TIFFTAG_TRANSFERFUNCTION_BLUE'] + ']')) if tifftag_transferfunction2 != tifftag_transferfunction: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') @@ -320,7 +305,6 @@ def test_tiff_copy_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -331,7 +315,6 @@ def test_tiff_copy_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' tifftag_transferfunction2 = ( @@ -340,7 +323,6 @@ def test_tiff_copy_colorimetric_data(): eval('[' + md['TIFFTAG_TRANSFERFUNCTION_BLUE'] + ']')) if tifftag_transferfunction2 != tifftag_transferfunction: - gdaltest.post_reason('fail') return 'fail' # Check again with dataset from Open() @@ -353,7 +335,6 @@ def test_tiff_copy_colorimetric_data(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -364,7 +345,6 @@ def test_tiff_copy_colorimetric_data(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' tifftag_transferfunction2 = ( @@ -373,7 +353,6 @@ def test_tiff_copy_colorimetric_data(): eval('[' + md['TIFFTAG_TRANSFERFUNCTION_BLUE'] + ']')) if tifftag_transferfunction2 != tifftag_transferfunction: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') @@ -406,7 +385,6 @@ def test_tiff_update_icc(): ds = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' # Reopen the file to verify it was written. @@ -415,7 +393,6 @@ def test_tiff_update_icc(): ds = None if md['SOURCE_ICC_PROFILE'] != icc: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') @@ -452,7 +429,6 @@ def test_tiff_update_colorimetric(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -463,7 +439,6 @@ def test_tiff_update_colorimetric(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' tifftag_transferfunction2 = ( @@ -472,7 +447,6 @@ def test_tiff_update_colorimetric(): eval('[' + md['TIFFTAG_TRANSFERFUNCTION_BLUE'] + ']')) if tifftag_transferfunction2 != tifftag_transferfunction: - gdaltest.post_reason('fail') return 'fail' # Reopen the file to verify it was written. @@ -484,7 +458,6 @@ def test_tiff_update_colorimetric(): for i in range(0, 3): if abs(source_whitepoint2[i] - source_whitepoint[i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' source_primaries2 = [ @@ -495,7 +468,6 @@ def test_tiff_update_colorimetric(): for j in range(0, 3): for i in range(0, 3): if abs(source_primaries2[j][i] - source_primaries[j][i]) > 0.0001: - gdaltest.post_reason('fail') return 'fail' tifftag_transferfunction2 = ( @@ -504,7 +476,6 @@ def test_tiff_update_colorimetric(): eval('[' + md['TIFFTAG_TRANSFERFUNCTION_BLUE'] + ']')) if tifftag_transferfunction2 != tifftag_transferfunction: - gdaltest.post_reason('fail') return 'fail' driver.Delete('tmp/icc_test.tiff') diff --git a/autotest/gdrivers/vicar.py b/autotest/gdrivers/vicar.py index 4f34ac92d57d..68086937b20c 100755 --- a/autotest/gdrivers/vicar.py +++ b/autotest/gdrivers/vicar.py @@ -59,26 +59,21 @@ def test_vicar_1(): got_gt = ds.GetGeoTransform() for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('failure') print(got_gt) print(expected_gt) return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 0: - gdaltest.post_reason('fail') return 'fail' if abs(ds.GetRasterBand(1).GetScale() - 2.34) > 1e-5: - gdaltest.post_reason('fail') print(ds.GetRasterBand(1).GetScale()) return 'fail' if abs(ds.GetRasterBand(1).GetOffset() - 4.56) > 1e-5: - gdaltest.post_reason('fail') return 'fail' expected_md = {'DLRTO8.REFLECTANCE_OFFSET': '4.56', 'PRODUCT_TYPE': 'IMAGE', 'PIXEL-SHIFT-BUG': 'CORRECTED', 'M94_ORBIT.STOP_TIME': 'stop_time', 'FILE.EVENT_TYPE': 'EVENT_TYPE', 'M94_CAMERAS.MACROPIXEL_SIZE': '1', 'M94_INSTRUMENT.DETECTOR_ID': 'MEX_HRSC_NADIR', 'HRORTHO.SPICE_FILE_NAME': 'SPICE_FILE_NAME', 'DLRTO8.RADIANCE_SCALING_FACTOR': '1.23', 'CONVERSION_DETAILS': 'http://www.lpi.usra.edu/meetings/lpsc2014/pdf/1088.pdf', 'HRORTHO.GEOMETRIC_CALIB_FILE_NAME': 'calib_file_name', 'HRORTHO.EXTORI_FILE_NAME': "extori'_file_name", 'M94_INSTRUMENT.MISSION_PHASE_NAME': 'MISSION_PHASE_NAME', 'HRCONVER.MISSING_FRAMES': '0', 'DLRTO8.RADIANCE_OFFSET': '1.23', 'HRCONVER.OVERFLOW_FRAMES': '0', 'SPACECRAFT_NAME': 'MARS EXPRESS', 'HRFOOT.BEST_GROUND_SAMPLING_DISTANCE': '1.23', 'M94_ORBIT.START_TIME': 'start_time', 'HRORTHO.DTM_NAME': 'dtm_name', 'DLRTO8.REFLECTANCE_SCALING_FACTOR': '2.34', 'HRCONVER.ERROR_FRAMES': '1'} md = ds.GetMetadata() if len(md) != len(expected_md): - gdaltest.post_reason('fail') print(md) print(len(md)) print(len(expected_md)) @@ -87,7 +82,6 @@ def test_vicar_1(): return 'fail' for key in expected_md: if md[key] != expected_md[key]: - gdaltest.post_reason('fail') print(md) return 'fail' diff --git a/autotest/gdrivers/vrtderived.py b/autotest/gdrivers/vrtderived.py index c0918c6e8636..79d60bd12a12 100755 --- a/autotest/gdrivers/vrtderived.py +++ b/autotest/gdrivers/vrtderived.py @@ -77,7 +77,6 @@ def test_vrtderived_1(): 'BlockXSize="20" BlockYSize="20" />\n' '\n') if md_read['source_0'] != expected_md_read: - gdaltest.post_reason('fail') print(md_read['source_0']) return 'fail' @@ -121,12 +120,10 @@ def test_vrtderived_2(): with gdaltest.error_handler(): cs = vrt_ds.GetRasterBand(1).Checksum() if cs != 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = vrt_ds.GetRasterBand(1).WriteRaster(0, 0, 1, 1, ' ') if ret == 0: - gdaltest.post_reason('fail') return 'fail' vrt_ds = None @@ -272,7 +269,6 @@ def test_vrtderived_7(): if ret.find('Checksum=0') >= 0: print('Did not manage to find a Python library') elif ret.find('Checksum=50577') < 0: - gdaltest.post_reason('fail') print(ret) print(err) return 'fail' @@ -284,7 +280,6 @@ def test_vrtderived_7(): if ret.find('Checksum=0') >= 0: print('Did not manage to find a Python library') elif ret.find('Checksum=50577') < 0: - gdaltest.post_reason('fail') print(ret) print(err) return 'fail' @@ -296,7 +291,6 @@ def test_vrtderived_7(): if ret.find('Checksum=0') >= 0: print('Did not manage to find a Python library') elif ret.find('Checksum=50577') < 0: - gdaltest.post_reason('fail') print(ret) print(err) return 'fail' @@ -306,7 +300,6 @@ def test_vrtderived_7(): if gdal.GetConfigOption('CPL_DEBUG') is not None: print(err) if ret.find('Checksum=0') < 0: - gdaltest.post_reason('fail') print(ret) print(err) return 'fail' @@ -318,7 +311,6 @@ def test_vrtderived_7(): if gdal.GetConfigOption('CPL_DEBUG') is not None: print(err) if ret.find('Checksum=0') < 0: - gdaltest.post_reason('fail') print(ret) print(err) return 'fail' @@ -378,7 +370,6 @@ def test_vrtderived_9(): """) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Unsupported PixelFunctionLanguage @@ -391,7 +382,6 @@ def test_vrtderived_9(): """) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # PixelFunctionCode can only be used with Python @@ -408,7 +398,6 @@ def identity(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize """) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # PixelFunctionArguments can only be used with Python @@ -421,7 +410,6 @@ def identity(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize """) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # BufferRadius can only be used with Python @@ -434,7 +422,6 @@ def identity(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize """) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid BufferRadius @@ -448,7 +435,6 @@ def identity(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize """) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Error at Python code compilation (indentation error) diff --git a/autotest/gdrivers/vrtmask.py b/autotest/gdrivers/vrtmask.py index 3187043fd0ac..30b23c5f342b 100755 --- a/autotest/gdrivers/vrtmask.py +++ b/autotest/gdrivers/vrtmask.py @@ -437,7 +437,6 @@ def test_vrtmask_11(): ds = gdal.Translate('', 'data/byte.tif', format='VRT') ret = ds.GetRasterBand(1).CreateMaskBand(gdal.GMF_PER_DATASET) if ret != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/vrtovr.py b/autotest/gdrivers/vrtovr.py index 37fbb96e2fd6..13e29087d270 100755 --- a/autotest/gdrivers/vrtovr.py +++ b/autotest/gdrivers/vrtovr.py @@ -154,7 +154,6 @@ def test_vrtovr_none(): return 'fail' if ds.GetRasterBand(1).GetOverview(0): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -189,16 +188,13 @@ def test_vrtovr_errors(): return 'fail' if ds.GetRasterBand(1).GetOverview(-1): - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(1): - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if ds.GetRasterBand(1).GetOverview(0): - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/vrtpansharpen.py b/autotest/gdrivers/vrtpansharpen.py index 31ceb3738140..a1cbafec32d9 100755 --- a/autotest/gdrivers/vrtpansharpen.py +++ b/autotest/gdrivers/vrtpansharpen.py @@ -70,7 +70,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # PanchroBand missing @@ -109,7 +108,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # PanchroBand.SourceFilename missing @@ -150,7 +148,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid dataset name @@ -193,7 +190,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Inconsistent declared VRT dimensions with panchro dataset. @@ -236,7 +232,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # VRTRasterBand of unrecognized subclass 'blabla' @@ -279,7 +274,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Algorithm unsupported_alg unsupported @@ -322,7 +316,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # 10 invalid band of tmp/small_world_pan.tif @@ -365,7 +358,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # SpectralBand.dstBand = '-1' invalid @@ -408,7 +400,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # SpectralBand.SourceFilename missing @@ -450,7 +441,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Invalid dataset name @@ -493,7 +483,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # 10 invalid band of data/small_world.tif @@ -536,7 +525,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Another spectral band is already mapped to output band 1 @@ -579,7 +567,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # No spectral band defined @@ -610,7 +597,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Hole in SpectralBand.dstBand numbering @@ -644,7 +630,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Band 4 of type VRTPansharpenedRasterBand, but no corresponding SpectralBand @@ -689,7 +674,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # SpectralBand.dstBand = '3' invalid @@ -729,7 +713,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # 2 weights defined, but 3 input spectral bands @@ -772,7 +755,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Dimensions of input spectral band 1 different from first spectral band @@ -795,7 +777,6 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Just warnings @@ -819,10 +800,8 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' # Just warnings @@ -859,10 +838,8 @@ def test_vrtpansharpen_1(): """) gdal.PopErrorHandler() if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' # Unsupported @@ -870,7 +847,6 @@ def test_vrtpansharpen_1(): ret = vrt_ds.AddBand(gdal.GDT_Byte) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -923,28 +899,21 @@ def test_vrtpansharpen_2(): """) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' if vrt_ds.GetFileList() != ['tmp/small_world_pan.tif', 'data/small_world.tif']: - gdaltest.post_reason('fail') print(vrt_ds.GetFileList()) return 'fail' if vrt_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') is not None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([4735, 10000, 9742], [4731, 9991, 9734]): - gdaltest.post_reason('fail') print(cs) return 'fail' if vrt_ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' if vrt_ds.GetRasterBand(1).GetOverview(-1) is not None: - gdaltest.post_reason('fail') return 'fail' if vrt_ds.GetRasterBand(1).GetOverview(0) is not None: - gdaltest.post_reason('fail') return 'fail' # Check VRTPansharpenedDataset::IRasterIO() in non-resampling case @@ -953,7 +922,6 @@ def test_vrtpansharpen_2(): tmp_ds.WriteRaster(0, 0, 800, 400, data) cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(tmp_ds.RasterCount)] if cs not in ([4735, 10000, 9742], [4731, 9991, 9734]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -961,7 +929,6 @@ def test_vrtpansharpen_2(): data = vrt_ds.ReadRaster(0, 0, 800, 400, 400, 200) ref_data = tmp_ds.ReadRaster(0, 0, 800, 400, 400, 200) if data != ref_data: - gdaltest.post_reason('fail') return 'fail' # Compact case @@ -986,11 +953,9 @@ def test_vrtpansharpen_2(): """) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([4735, 10000, 9742], [4731, 9991, 9734]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1040,12 +1005,10 @@ def test_vrtpansharpen_2(): """) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' # gdal.GetDriverByName('GTiff').CreateCopy('out1.tif', vrt_ds) cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([50261, 4735, 10000, 9742], [50261, 4731, 9991, 9734]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1096,12 +1059,10 @@ def test_vrtpansharpen_2(): """) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' # gdal.GetDriverByName('GTiff').CreateCopy('out2.tif', vrt_ds) cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([50261, 4735, 10000, 9742], [50261, 4727, 9998, 9732]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1141,14 +1102,11 @@ def test_vrtpansharpen_3(): # Test when only Pan band has overviews vrt_ds = gdal.Open(xml) if vrt_ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if vrt_ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([7123, 7445, 5025], [7120, 7440, 5025]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1160,14 +1118,12 @@ def test_vrtpansharpen_3(): data2 += vrt_ds.GetRasterBand(3).ReadRaster(0, 0, 800, 400, 400, 200) if data != data2: - gdaltest.post_reason('fail') return 'fail' tmp_ds = gdal.GetDriverByName('MEM').Create('', 400, 200, 3) tmp_ds.WriteRaster(0, 0, 400, 200, data) cs = [tmp_ds.GetRasterBand(i + 1).Checksum() for i in range(tmp_ds.RasterCount)] if cs not in ([7123, 7445, 5025], [7120, 7440, 5025]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1180,14 +1136,11 @@ def test_vrtpansharpen_3(): # Test when both Pan and spectral bands have overviews vrt_ds = gdal.Open(xml) if vrt_ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if vrt_ds.GetRasterBand(1).GetOverview(0) is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).GetOverview(0).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([18033, 18395, 16824], [18033, 18395, 16822]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1233,7 +1186,6 @@ def test_vrtpansharpen_4(): else: expected_cs = [4735, 4731] if cs not in expected_cs: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(cs) return 'fail' @@ -1311,13 +1263,11 @@ def test_vrtpansharpen_5(): cs = tmp_ds.GetRasterBand(1).Checksum() if dt == gdal.GDT_UInt16: if cs not in (4553, 4549): - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(cs) return 'fail' else: if cs != 4450: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(cs) return 'fail' @@ -1389,7 +1339,6 @@ def test_vrtpansharpen_6(): vrt_ds = gdal.Open(xml) if vrt_ds.GetRasterBand(1).GetMetadataItem('NBITS', 'IMAGE_STRUCTURE') != str(nbits): - gdaltest.post_reason('fail') return 'fail' ar = vrt_ds.GetRasterBand(1).ReadAsArray() @@ -1401,7 +1350,6 @@ def test_vrtpansharpen_6(): expected_ar = [97280, 113920, 131071, 131071, 131071, 131071, 113920, 97280] if list(ar[0]) != expected_ar: - gdaltest.post_reason('fail') print(gdal.GetDataTypeName(dt)) print(i) print(list(ar[0])) @@ -1439,7 +1387,6 @@ def test_vrtpansharpen_7(): """ ds = gdal.Open(xml) if ds.GetGeoTransform() != (100.0, 1.0, 0.0, 100.0, 0.0, -1.0) or ds.RasterXSize != 40 or ds.RasterYSize != 60: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) print(ds.RasterXSize) print(ds.RasterYSize) @@ -1459,7 +1406,6 @@ def test_vrtpansharpen_7(): """ ds = gdal.Open(xml) if ds.GetGeoTransform() != (100.0, 1.0, 0.0, 100.0, 0.0, -1.0) or ds.RasterXSize != 40 or ds.RasterYSize != 60: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) print(ds.RasterXSize) print(ds.RasterYSize) @@ -1482,13 +1428,11 @@ def test_vrtpansharpen_7(): ds = gdal.Open(xml) gdal.PopErrorHandler() if ds.GetGeoTransform() != (100.0, 1.0, 0.0, 100.0, 0.0, -1.0) or ds.RasterXSize != 40 or ds.RasterYSize != 60: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1505,7 +1449,6 @@ def test_vrtpansharpen_7(): """ ds = gdal.Open(xml) if ds.GetGeoTransform() != (120.0, 1.0, 0.0, 80.0, 0.0, -1.0) or ds.RasterXSize != 10 or ds.RasterYSize != 40: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) print(ds.RasterXSize) print(ds.RasterYSize) @@ -1528,13 +1471,11 @@ def test_vrtpansharpen_7(): ds = gdal.Open(xml) gdal.PopErrorHandler() if ds.GetGeoTransform() != (120.0, 1.0, 0.0, 80.0, 0.0, -1.0) or ds.RasterXSize != 20 or ds.RasterYSize != 40: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1552,13 +1493,11 @@ def test_vrtpansharpen_7(): gdal.ErrorReset() ds = gdal.Open(xml) if ds.GetGeoTransform() != (120.0, 1.0, 0.0, 80.0, 0.0, -1.0) or ds.RasterXSize != 20 or ds.RasterYSize != 40: - gdaltest.post_reason('fail') print(ds.GetGeoTransform()) print(ds.RasterXSize) print(ds.RasterYSize) return 'fail' if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1582,7 +1521,6 @@ def test_vrtpansharpen_7(): ds = gdal.Open(xml) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1637,7 +1575,6 @@ def test_vrtpansharpen_8(): gdal.Unlink('tmp/vrtpansharpen_8.vrt') if cs1 != expected_cs1 or cs2 != expected_cs2 or cs3 != expected_cs3: - gdaltest.post_reason('fail') print(cs1) print(expected_cs1) print(cs2) @@ -1677,11 +1614,9 @@ def test_vrtpansharpen_9(): """) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([6950, 11745, 8965],): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1719,11 +1654,9 @@ def test_vrtpansharpen_9(): """) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in ([6950, 11745, 8965],): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1774,7 +1707,6 @@ def test_vrtpansharpen_10(): """) cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs != [62009, 62009, 62009, 62009]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1786,7 +1718,6 @@ def test_vrtpansharpen_10(): tmp_ds.WriteRaster(0, 0, vrt_ds.RasterXSize, vrt_ds.RasterYSize, data_int32) ref_data = tmp_ds.ReadRaster(buf_type=gdal.GDT_UInt16) if data != ref_data: - gdaltest.post_reason('fail') return 'fail' # 4 bands -> 3 bands @@ -1817,7 +1748,6 @@ def test_vrtpansharpen_10(): """) cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs != [62009, 62009, 62009]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1829,7 +1759,6 @@ def test_vrtpansharpen_10(): tmp_ds.WriteRaster(0, 0, vrt_ds.RasterXSize, vrt_ds.RasterYSize, data_int32) ref_data = tmp_ds.ReadRaster(buf_type=gdal.GDT_UInt16) if data != ref_data: - gdaltest.post_reason('fail') return 'fail' # 3 bands @@ -1856,7 +1785,6 @@ def test_vrtpansharpen_10(): """) cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs != [62009, 62009, 62009]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1868,7 +1796,6 @@ def test_vrtpansharpen_10(): tmp_ds.WriteRaster(0, 0, vrt_ds.RasterXSize, vrt_ds.RasterYSize, data_int32) ref_data = tmp_ds.ReadRaster(buf_type=gdal.GDT_UInt16) if data != ref_data: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1893,11 +1820,9 @@ def test_vrtpansharpen_11(): """, pan_ds.GetRasterBand(1), [ms_ds.GetRasterBand(i + 1) for i in range(3)]) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in([4735, 10000, 9742], [4731, 9991, 9734]): - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -1918,11 +1843,9 @@ def test_vrtpansharpen_11(): """, pan_mem_ds.GetRasterBand(1), [ms_mem_ds.GetRasterBand(i + 1) for i in range(3)]) if vrt_ds is None: - gdaltest.post_reason('fail') return 'fail' cs = [vrt_ds.GetRasterBand(i + 1).Checksum() for i in range(vrt_ds.RasterCount)] if cs not in([4735, 10000, 9742], [4731, 9991, 9734]): - gdaltest.post_reason('fail') print(cs) return 'fail' vrt_ds = None @@ -1944,7 +1867,6 @@ def test_vrtpansharpen_11(): """, pan_mem_ds.GetRasterBand(1), [ms_mem_ds.GetRasterBand(i + 1) for i in range(3)]) if vrt_ds.GetGeoTransform() != (100.0, 1.0, 0.0, 100.0, 0.0, -1.0) or vrt_ds.RasterXSize != 40 or vrt_ds.RasterYSize != 60: - gdaltest.post_reason('fail') print(vrt_ds.GetGeoTransform()) print(vrt_ds.RasterXSize) print(vrt_ds.RasterYSize) @@ -1956,7 +1878,6 @@ def test_vrtpansharpen_11(): vrt_ds = gdal.CreatePansharpenedVRT("""""", pan_mem_ds.GetRasterBand(1), [ms_mem_ds.GetRasterBand(i + 1) for i in range(3)]) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' # Too many bands @@ -1990,7 +1910,6 @@ def test_vrtpansharpen_11(): """, pan_mem_ds.GetRasterBand(1), [ms_mem_ds.GetRasterBand(i + 1) for i in range(3)]) gdal.PopErrorHandler() if vrt_ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/gdrivers/vrtrawlink.py b/autotest/gdrivers/vrtrawlink.py index fffeb6810081..b0f14d703978 100755 --- a/autotest/gdrivers/vrtrawlink.py +++ b/autotest/gdrivers/vrtrawlink.py @@ -211,7 +211,6 @@ def test_vrtrawlink_5(): if xmlstring.find('100') < 0 or \ xmlstring.find('3') < 0 or \ xmlstring.find('93') < 0: - gdaltest.post_reason('fail') print(xmlstring) return 'fail' diff --git a/autotest/gdrivers/vrtwarp.py b/autotest/gdrivers/vrtwarp.py index 00133cd951af..3ae343a2b43d 100755 --- a/autotest/gdrivers/vrtwarp.py +++ b/autotest/gdrivers/vrtwarp.py @@ -116,17 +116,13 @@ def test_vrtwarp_4(): for i in range(3): if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: print(i) - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != cs_ov0: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != cs_ov1: - gdaltest.post_reason('fail') return 'fail' if i == 0: vrtwarp_ds.SetDescription('tmp/vrtwarp_4.vrt') @@ -151,19 +147,14 @@ def test_vrtwarp_4(): vrtwarp_ds = gdal.Open('tmp/vrtwarp_4.vrt') if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 3: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != cs_ov0: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != cs_ov1: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(2).Checksum() != expected_cs_ov2: - gdaltest.post_reason('fail') return 'fail' vrtwarp_ds = None @@ -202,16 +193,12 @@ def test_vrtwarp_5(): vrtwarp_ds.SetMetadataItem('SrcOvrLevel', 'AUTO-1') tmp_ds = None if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != expected_cs_ov0: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != expected_cs_ov1: - gdaltest.post_reason('fail') return 'fail' vrtwarp_ds = None @@ -258,16 +245,12 @@ def test_vrtwarp_6(): vrtwarp_ds = gdal.Open('tmp/vrtwarp_6.vrt') if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != cs_ov0: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != cs_ov1: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('tmp/vrtwarp_6.vrt') @@ -309,16 +292,13 @@ def test_vrtwarp_7(): vrtwarp_ds = gdal.Warp('tmp/vrtwarp_7.vrt', 'tmp/vrtwarp_7.tif', options='-overwrite -of VRT -tps') if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: print(cs_main) return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != cs_ov0: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != cs_ov1: - gdaltest.post_reason('fail') return 'fail' vrtwarp_ds = None @@ -345,13 +325,10 @@ def test_vrtwarp_8(): vrtwarp_ds = gdal.Warp('tmp/vrtwarp_8.vrt', 'tmp/vrtwarp_8.tif', options='-overwrite -of VRT -rpc') if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != expected_cs_main: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != 1214: - gdaltest.post_reason('fail') print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).XSize) print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).YSize) print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum()) @@ -408,13 +385,10 @@ def test_vrtwarp_9(): vrtwarp_ds = gdal.Warp('tmp/vrtwarp_9.vrt', 'tmp/sstgeo.vrt', options='-overwrite -of VRT -geoloc') if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 1: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != expected_cs_main: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != 63859: - gdaltest.post_reason('fail') print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).XSize) print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).YSize) print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum()) @@ -457,16 +431,12 @@ def test_vrtwarp_10(): vrtwarp_ds.SetMetadataItem('SrcOvrLevel', 'NONE') tmp_ds = None if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 2: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != expected_cs_ov0: - gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != expected_cs_ov1: - gdaltest.post_reason('fail') return 'fail' vrtwarp_ds = None @@ -487,7 +457,6 @@ def test_vrtwarp_11(): ds = None if cs1 != 22122 or cs2 != 56685 or cs3 != 22122: - gdaltest.post_reason('fail') print(cs1) print(cs2) print(cs3) diff --git a/autotest/gdrivers/wmts.py b/autotest/gdrivers/wmts.py index 24a1d0200302..0584e544a822 100755 --- a/autotest/gdrivers/wmts.py +++ b/autotest/gdrivers/wmts.py @@ -70,28 +70,24 @@ def test_wmts_2(): ds = gdal.Open('WMTS:') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ds = gdal.Open('') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ds = gdal.Open('') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ds = gdal.Open('') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -109,7 +105,6 @@ def test_wmts_3(): ds = gdal.Open('WMTS:https://non_existing') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -127,7 +122,6 @@ def test_wmts_4(): ds = gdal.Open('WMTS:/vsimem/non_existing') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -147,7 +141,6 @@ def test_wmts_5(): ds = gdal.Open('WMTS:/vsimem/invalid_getcapabilities.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -167,7 +160,6 @@ def test_wmts_6(): ds = gdal.Open('WMTS:/vsimem/invalid_getcapabilities.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -187,7 +179,6 @@ def test_wmts_7(): ds = gdal.Open('WMTS:/vsimem/empty_getcapabilities.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -213,7 +204,6 @@ def test_wmts_8(): ds = gdal.Open('WMTS:/vsimem/missing.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -246,7 +236,6 @@ def test_wmts_9(): ds = gdal.Open('WMTS:/vsimem/missing_tms.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -282,7 +271,6 @@ def test_wmts_10(): ds = gdal.Open('WMTS:/vsimem/missing_SupportedCRS.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -319,7 +307,6 @@ def test_wmts_11(): ds = gdal.Open('WMTS:/vsimem/no_tilematrix.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -357,7 +344,6 @@ def test_wmts_12(): ds = gdal.Open('WMTS:/vsimem/missing_required_element_in_tilematrix.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -402,7 +388,6 @@ def test_wmts_12bis(): ds = gdal.Open('WMTS:/vsimem/wmts_12bis.xml') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -446,52 +431,39 @@ def test_wmts_13(): ds = gdal.Open('WMTS:/vsimem/minimal.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-20037508.342799999, 156543.03392811998, 0.0, 20037508.342799999, 0.0, -156543.03392811998) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('3857') < 0: - gdaltest.post_reason('fail') return 'fail' if ds.RasterCount != 4: - gdaltest.post_reason('fail') return 'fail' for i in range(4): if ds.GetRasterBand(i + 1).GetColorInterpretation() != gdal.GCI_RedBand + i: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverviewCount() != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetOverview(0) is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() cs = ds.GetRasterBand(1).Checksum() gdal.PopErrorHandler() if cs != 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetSubDatasets() != []: - gdaltest.post_reason('fail') print(ds.GetSubDatasets()) return 'fail' if ds.GetRasterBand(1).GetMetadataItem('Pixel_0_0', 'LocationInfo') is not None: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMetadataItem('foo') is not None: - gdaltest.post_reason('fail') return 'fail' for connection_str in ['WMTS:/vsimem/minimal.xml,layer=', @@ -502,7 +474,6 @@ def test_wmts_13(): 'WMTS:/vsimem/minimal.xml,layer=,style=,tilematrixset=']: ds = gdal.Open(connection_str) if ds is None: - gdaltest.post_reason('fail') print(connection_str) return 'fail' ds = None @@ -516,7 +487,6 @@ def test_wmts_13(): ds = gdal.Open(connection_str) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') print(connection_str) return 'fail' ds = None @@ -529,19 +499,16 @@ def test_wmts_13(): for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != tmp_ds.GetRasterBand(i + 1).Checksum(): - gdaltest.post_reason('fail') return 'fail' ref_data = tmp_ds.ReadRaster(0, 0, 256, 256) got_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 256, 256) if ref_data != got_data: - gdaltest.post_reason('fail') return 'fail' ref_data = tmp_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) got_data = ds.GetRasterBand(1).ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 256, 256) if ref_data != got_data: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -645,7 +612,6 @@ def test_wmts_14(): ds = gdal.Open('WMTS:/vsimem/nominal.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetSubDatasets() != [('WMTS:/vsimem/nominal.xml,layer=lyr1,tilematrixset=tms,style="style=auto"', 'Layer My layer1, tile matrix set tms, style "Default style"'), @@ -655,21 +621,17 @@ def test_wmts_14(): 'Layer My layer1, tile matrix set another_tms, style "Default style"'), ('WMTS:/vsimem/nominal.xml,layer=lyr1,tilematrixset=another_tms,style=another_style', 'Layer My layer1, tile matrix set another_tms, style "Another style"')]: - gdaltest.post_reason('fail') print(ds.GetSubDatasets()) return 'fail' if ds.RasterXSize != 67108864: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') gdal.PopErrorHandler() if res != '': - gdaltest.post_reason('fail') print(res) return 'fail' if ds.GetMetadata() != {'ABSTRACT': 'My abstract', 'TITLE': 'My layer1'}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' @@ -701,7 +663,6 @@ def test_wmts_14(): true """: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -709,30 +670,25 @@ def test_wmts_14(): gdal.FileFromMemBuffer('/vsimem/2011-10-04/style=auto/tms/tm_18/0/0/2/1.txt', 'foo') res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') if res != 'foo': - gdaltest.post_reason('fail') print(res) return 'fail' res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') if res != 'foo': - gdaltest.post_reason('fail') print(res) return 'fail' ds = gdal.Open('/vsimem/nominal.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' for open_options in [['URL=/vsimem/nominal.xml'], ['URL=/vsimem/nominal.xml', 'STYLE=style=auto', 'TILEMATRIXSET=tms']]: ds = gdal.OpenEx('WMTS:', open_options=open_options) if ds is None: - gdaltest.post_reason('fail') return 'fail' for open_options in [['URL=/vsimem/nominal.xml', 'STYLE=x', 'TILEMATRIXSET=y'], @@ -742,7 +698,6 @@ def test_wmts_14(): ds = gdal.OpenEx('WMTS:', open_options=open_options) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = gdal.Open('WMTS:/vsimem/nominal.xml') @@ -750,43 +705,34 @@ def test_wmts_14(): res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') if res != """ """: - gdaltest.post_reason('fail') print(res) return 'fail' ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml,tilematrix=tm_0') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' ds = gdal.OpenEx('WMTS:/vsimem/gdal_nominal.xml', open_options=['tilematrix=tm_0']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml,zoom_level=0') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' ds = gdal.OpenEx('WMTS:/vsimem/gdal_nominal.xml', open_options=['zoom_level=0']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' @@ -810,10 +756,8 @@ def test_wmts_14(): """) ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' @@ -837,10 +781,8 @@ def test_wmts_14(): """) ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 256: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' @@ -953,16 +895,13 @@ def test_wmts_15(): ds = gdal.Open('/vsimem/nominal_kvp.xml?service=WMTS&request=GetCapabilities') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 67108864: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') gdal.PopErrorHandler() if res != '': - gdaltest.post_reason('fail') print(res) return 'fail' @@ -973,13 +912,11 @@ def test_wmts_15(): gdal.FileFromMemBuffer('/vsimem/nominal_kvp.xml?service=WMTS&request=GetFeatureInfo&version=1.0.0&layer=lyr1&style=default_style&InfoFormat=text/plain&TileMatrixSet=tms&TileMatrix=18&TileRow=0&TileCol=0&J=2&I=1&time=2011-10-04', 'bar') res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') if res != 'bar': - gdaltest.post_reason('fail') print(res) return 'fail' ds = gdal.Open('WMTS:/vsimem/gdal_nominal_kvp.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' tmp_ds = gdal.GetDriverByName('MEM').Create('', 256, 256, 4) for i in range(4): @@ -988,19 +925,16 @@ def test_wmts_15(): for i in range(4): cs = ds.GetRasterBand(i + 1).GetOverview(0).Checksum() if cs != tmp_ds.GetRasterBand(i + 1).Checksum(): - gdaltest.post_reason('fail') return 'fail' ref_data = tmp_ds.ReadRaster(0, 0, 256, 256) got_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 256, 256) if ref_data != got_data: - gdaltest.post_reason('fail') return 'fail' ref_data = tmp_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) got_data = ds.GetRasterBand(1).ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 256, 256) if ref_data != got_data: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1074,25 +1008,20 @@ def test_wmts_16(): ds = gdal.Open('WMTS:/vsimem/wmts_16.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 512: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1164,25 +1093,20 @@ def test_wmts_17(): ds = gdal.Open('WMTS:/vsimem/wmts_17.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 512: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1254,25 +1178,20 @@ def test_wmts_18(): ds = gdal.Open('WMTS:/vsimem/wmts_18.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 512: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1349,25 +1268,20 @@ def test_wmts_19(): ds = gdal.Open('WMTS:/vsimem/wmts_19.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 512: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1448,25 +1362,20 @@ def test_wmts_20(): ds = gdal.Open('WMTS:/vsimem/wmts_20.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 512: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1543,25 +1452,20 @@ def test_wmts_21(): ds = gdal.Open('WMTS:/vsimem/wmts_21.xml,extendbeyonddateline=yes') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 512: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 256: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (90, 0.3515625, 0.0, 0.0, 0.0, -0.3515625) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1576,11 +1480,9 @@ def test_wmts_21(): tmp0_ds = gdal.GetDriverByName('PNG').CreateCopy('/vsimem/wmts_21/default_style/tms/GoogleCRS84Quad:2/1/0.png', tmp_ds) if ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) != tmp3_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256): - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).ReadRaster(256, 0, 256, 256) != tmp0_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1633,25 +1535,20 @@ def test_wmts_22(): ds = gdal.Open('WMTS:/vsimem/wmts_22.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 2097152: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 2097152: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-548576.0, 1.0000000000004, 0.0, 8388608.0, 0.0, -1.0000000000004) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) return 'fail' if ds.GetProjectionRef().find('3067') < 0: - gdaltest.post_reason('fail') print(ds.GetProjectionRef()) return 'fail' @@ -1707,22 +1604,18 @@ def wmts_23(imagetype, expected_cs): ds = gdal.Open('WMTS:' + inputXml) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.RasterXSize != 128: - gdaltest.post_reason('fail') print(ds.RasterXSize) return 'fail' if ds.RasterYSize != 128: - gdaltest.post_reason('fail') print(ds.RasterYSize) return 'fail' for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() if cs != expected_cs[i]: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -2067,12 +1960,10 @@ def test_wmts_check_no_overflow_zoom_level(): ds = gdal.Open(inputXml) if ds.RasterXSize != 1073741766 or ds.RasterYSize != 1070224430: - gdaltest.post_reason('fail') print(ds.RasterXSize, ds.RasterYSize) return 'fail' count_levels = 1 + ds.GetRasterBand(1).GetOverviewCount() if count_levels != 23: # there are 24 in total, but we discard the one labelled 23 - gdaltest.post_reason('fail') print(count_levels) return 'fail' ds = None diff --git a/autotest/gdrivers/xyz.py b/autotest/gdrivers/xyz.py index c9cb545bac3c..8950ccf20537 100755 --- a/autotest/gdrivers/xyz.py +++ b/autotest/gdrivers/xyz.py @@ -134,23 +134,18 @@ def test_xyz_4(): expected_gt = (440660.0, 60.0, 0.0, 3751350.0, 0.0, -120.0) for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(got_gt) print(expected_gt) return 'fail' if ds.GetRasterBand(1).GetMinimum() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetMaximum() != 7: - gdaltest.post_reason('fail') return 'fail' if ds.GetRasterBand(1).GetNoDataValue() != 0: - gdaltest.post_reason('fail') return 'fail' for i in [0, 1, 2, 1, 0, 2, 0, 2, 0, 1, 2]: if not xyz_4_checkline(ds, i, expected[i]): - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/grid.xyz') @@ -173,7 +168,6 @@ def test_xyz_5(): ds = gdal.Open('/vsimem/grid.xyz') if ds.RasterXSize != 3 or ds.RasterYSize != 2: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-0.25, 0.5, 0.0, 0.5, 0.0, 1.0) @@ -182,7 +176,6 @@ def test_xyz_5(): for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(got_gt) print(expected_gt) return 'fail' @@ -206,7 +199,6 @@ def test_xyz_6(): ds = gdal.Open('/vsimem/grid.xyz') if ds.RasterXSize != 3 or ds.RasterYSize != 2: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (-0.25, 0.5, 0.0, 0.5, 0.0, 1.0) @@ -215,7 +207,6 @@ def test_xyz_6(): for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-5: - gdaltest.post_reason('fail') print(got_gt) print(expected_gt) return 'fail' @@ -249,7 +240,6 @@ def test_xyz_7(): ds = gdal.Open('/vsimem/grid.xyz') if ds.RasterXSize != 3 or ds.RasterYSize != 5: - gdaltest.post_reason('fail') return 'fail' got_gt = ds.GetGeoTransform() expected_gt = (354.46666625, 0.0333335, 0.0, 51.5125, 0.0, -0.025) @@ -259,13 +249,11 @@ def test_xyz_7(): for i in range(6): if abs(got_gt[i] - expected_gt[i]) > 1e-8: - gdaltest.post_reason('fail') print(got_gt) print(expected_gt) return 'fail' if cs != 146: - gdaltest.post_reason('fail') print(cs) return 'fail' @@ -287,14 +275,12 @@ def test_xyz_8(): ds = gdal.Open('/vsimem/grid.xyz') if ds.RasterXSize != 4 or ds.RasterYSize != 2: - gdaltest.post_reason('fail') return 'fail' cs = ds.GetRasterBand(1).Checksum() ds = None gdal.Unlink('/vsimem/grid.xyz') if cs != 35: - gdaltest.post_reason('fail') print(cs) return 'fail' diff --git a/autotest/gnm/gnm_test.py b/autotest/gnm/gnm_test.py index 5e01cfac4791..814368305e37 100755 --- a/autotest/gnm/gnm_test.py +++ b/autotest/gnm/gnm_test.py @@ -64,7 +64,6 @@ def test_gnm_filenetwork_create(): # cast to GNM dn = gnm.CastToNetwork(ds) if dn is None: - gdaltest.post_reason('fail') return 'fail' if dn.GetVersion() != 100: gdaltest.post_reason('GNM: Check GNM version failed') @@ -93,7 +92,6 @@ def test_gnm_filenetwork_open(): # cast to GNM dn = gnm.CastToNetwork(ds) if dn is None: - gdaltest.post_reason('fail') return 'fail' if dn.GetVersion() != 100: gdaltest.post_reason('GNM: Check GNM version failed') diff --git a/autotest/ogr/ogr_avc.py b/autotest/ogr/ogr_avc.py index 4d445a2ef260..ac54d0357e29 100755 --- a/autotest/ogr/ogr_avc.py +++ b/autotest/ogr/ogr_avc.py @@ -125,18 +125,15 @@ def test_ogr_avc_4(): count += 1 last_feature = f if count != 80: - gdaltest.post_reason('fail') print(filename) print(count) return 'fail' count = lyr.GetFeatureCount() if count != 80: - gdaltest.post_reason('fail') print(filename) print(count) return 'fail' if last_feature.GetFieldCount() != 7: - gdaltest.post_reason('fail') print(filename) f.DumpReadable() return 'fail' @@ -145,7 +142,6 @@ def test_ogr_avc_4(): else: fld_name = 'WELLS-ID' if last_feature.GetField('ValueId') != 80 or last_feature.GetField(fld_name) != 80: - gdaltest.post_reason('fail') print(filename) f.DumpReadable() return 'fail' @@ -167,23 +163,19 @@ def test_ogr_avc_5(): count += 1 last_feature = f if count != 3: - gdaltest.post_reason('fail') print(filename) print(count) return 'fail' count = lyr.GetFeatureCount() if count != 3: - gdaltest.post_reason('fail') print(filename) print(count) return 'fail' if last_feature.GetFieldCount() != 5: - gdaltest.post_reason('fail') print(filename) f.DumpReadable() return 'fail' if last_feature.GetField('ArcIds') != [-4, -5] or abs(last_feature.GetField('AREA') - 9939.059) > 1e-3: - gdaltest.post_reason('fail') print(filename) f.DumpReadable() return 'fail' @@ -193,7 +185,6 @@ def test_ogr_avc_5(): # Likely a bug in AVCE00 driver expected_wkt = 'POLYGON ((340299.94 4100199.8,340099.88 4100200.0,340299.94 4100199.8))' if last_feature.GetGeometryRef().ExportToWkt() != expected_wkt: - gdaltest.post_reason('fail') print(filename) f.DumpReadable() return 'fail' diff --git a/autotest/ogr/ogr_basic_test.py b/autotest/ogr/ogr_basic_test.py index b4f149415462..3b808af98df7 100755 --- a/autotest/ogr/ogr_basic_test.py +++ b/autotest/ogr/ogr_basic_test.py @@ -44,7 +44,6 @@ def test_ogr_basic_1(): gdaltest.ds = ogr.Open('data/poly.shp') if gdaltest.ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -422,7 +421,6 @@ def test_ogr_basic_9(): for geom_type_tuple in geom_type_tuples: if ogr.GeometryTypeToName(geom_type_tuple[0]) != geom_type_tuple[1]: - gdaltest.post_reason('fail') print('Got %s, expected %s' % (ogr.GeometryTypeToName(geom_type_tuple[0]), geom_type_tuple[1])) return 'fail' @@ -475,12 +473,10 @@ def test_ogr_basic_12(): # boolean integer feat_def = ogr.FeatureDefn() if ogr.GetFieldSubTypeName(ogr.OFSTBoolean) != 'Boolean': - gdaltest.post_reason('fail') return 'fail' field_def = ogr.FieldDefn('fld', ogr.OFTInteger) field_def.SetSubType(ogr.OFSTBoolean) if field_def.GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) @@ -492,10 +488,8 @@ def test_ogr_basic_12(): f.SetField('fld', 2) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if f.GetField('fld') != 1: - gdaltest.post_reason('fail') return 'fail' f.SetField('fld', '0') @@ -505,10 +499,8 @@ def test_ogr_basic_12(): f.SetField('fld', '2') gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if f.GetField('fld') != 1: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -517,10 +509,8 @@ def test_ogr_basic_12(): field_def.SetSubType(ogr.OFSTBoolean) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if field_def.GetSubType() != ogr.OFSTNone: - gdaltest.post_reason('fail') return 'fail' # boolean list @@ -528,7 +518,6 @@ def test_ogr_basic_12(): field_def = ogr.FieldDefn('fld', ogr.OFTIntegerList) field_def.SetSubType(ogr.OFSTBoolean) if field_def.GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) @@ -539,22 +528,18 @@ def test_ogr_basic_12(): f.SetFieldIntegerList(0, [0, 1, 2, 1]) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if f.GetField('fld') != [0, 1, 1, 1]: print(f.GetField('fld')) - gdaltest.post_reason('fail') return 'fail' # int16 integer feat_def = ogr.FeatureDefn() if ogr.GetFieldSubTypeName(ogr.OFSTInt16) != 'Int16': - gdaltest.post_reason('fail') return 'fail' field_def = ogr.FieldDefn('fld', ogr.OFTInteger) field_def.SetSubType(ogr.OFSTInt16) if field_def.GetSubType() != ogr.OFSTInt16: - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) @@ -566,20 +551,16 @@ def test_ogr_basic_12(): f.SetField('fld', -32769) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if f.GetField('fld') != -32768: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', 32768) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if f.GetField('fld') != 32767: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -588,21 +569,17 @@ def test_ogr_basic_12(): field_def.SetSubType(ogr.OFSTInt16) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if field_def.GetSubType() != ogr.OFSTNone: - gdaltest.post_reason('fail') return 'fail' # float32 feat_def = ogr.FeatureDefn() if ogr.GetFieldSubTypeName(ogr.OFSTFloat32) != 'Float32': - gdaltest.post_reason('fail') return 'fail' field_def = ogr.FieldDefn('fld', ogr.OFTReal) field_def.SetSubType(ogr.OFSTFloat32) if field_def.GetSubType() != ogr.OFSTFloat32: - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) @@ -611,17 +588,14 @@ def test_ogr_basic_12(): gdal.ErrorReset() f.SetField('fld', '1.23') if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', 1.230000000001) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if abs(f.GetField('fld') - 1.23) < 1e-8: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -631,10 +605,8 @@ def test_ogr_basic_12(): field_def.SetSubType(ogr.OFSTInt16) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if field_def.GetSubType() != ogr.OFSTNone: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -675,7 +647,6 @@ def test_ogr_basic_13(): f = ogr.Feature(feat_defn) f.SetField('date', val) if f.GetField('date') != expected_ret: - gdaltest.post_reason('fail') print(val) print(f.GetField('date')) return 'fail' @@ -783,19 +754,16 @@ def test_ogr_basic_dataset_slice(): lyrs = [lyr.GetName() for lyr in ds[1:3]] if lyrs != ['lyr2', 'lyr3']: - gdaltest.post_reason('fail') print(lyrs) return 'fail' lyrs = [lyr.GetName() for lyr in ds[0:4]] if lyrs != ['lyr1', 'lyr2', 'lyr3']: - gdaltest.post_reason('fail') print(lyrs) return 'fail' lyrs = [lyr.GetName() for lyr in ds[0:3:2]] if lyrs != ['lyr1', 'lyr3']: - gdaltest.post_reason('fail') print(lyrs) return 'fail' diff --git a/autotest/ogr/ogr_cad.py b/autotest/ogr/ogr_cad.py index 7503507541a4..dbf66df144a9 100755 --- a/autotest/ogr/ogr_cad.py +++ b/autotest/ogr/ogr_cad.py @@ -438,11 +438,9 @@ def test_ogr_cad_9(): with gdaltest.error_handler(): ds = gdal.OpenEx('data/AC1018_signature.dwg', allowed_drivers=['CAD']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' msg = gdal.GetLastErrorMsg() if msg.find('does not support this version') < 0: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_carto.py b/autotest/ogr/ogr_carto.py index b7f974fed208..20a3802db68c 100755 --- a/autotest/ogr/ogr_carto.py +++ b/autotest/ogr/ogr_carto.py @@ -72,7 +72,6 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', @@ -83,7 +82,6 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() if ds is not None or gdal.GetLastErrorMsg().find('HTML error page') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -91,7 +89,6 @@ def test_ogr_carto_vsimem(): """""") ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -101,7 +98,6 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() if ds is not None or gdal.GetLastErrorMsg().find('JSON parsing error') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -109,7 +105,6 @@ def test_ogr_carto_vsimem(): """ "not_expected_json" """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -119,7 +114,6 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() if ds is not None or gdal.GetLastErrorMsg().find('Error returned by server : bla') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -127,7 +121,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : null } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -135,7 +128,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : "invalid" } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -143,7 +135,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : {} } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -151,7 +142,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : { "foo": "invalid" } } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -159,7 +149,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : { "foo": {} } } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -167,7 +156,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : { "foo": { "type" : null } } } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -175,7 +163,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : { "foo": { "type" : {} } } } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -183,7 +170,6 @@ def test_ogr_carto_vsimem(): """{ "fields" : { "foo": { "type" : "string" } } } """) ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -191,7 +177,6 @@ def test_ogr_carto_vsimem(): """{"rows":[ {"field1": "foo", "field2": "bar"} ],"fields":{"field1":{"type":"string"}, "field2":{"type":"string"}}}""") ds = ogr.Open('CARTO:foo') if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -201,7 +186,6 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -211,7 +195,6 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -219,7 +202,6 @@ def test_ogr_carto_vsimem(): """{"rows":[{"cdb_usertables":"table1"}],"fields":{"cdb_usertables":{"type":"string"}}}""") ds = ogr.Open('CARTO:foo') if ds is None or ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -228,7 +210,6 @@ def test_ogr_carto_vsimem(): gdal.PopErrorHandler() if lyr_defn.GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' # Empty layer @@ -238,14 +219,12 @@ def test_ogr_carto_vsimem(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT * FROM "table1" LIMIT 500 OFFSET 0', """{"rows":[{}],"fields":{}}}""") f = lyr.GetNextFeature() if f.GetFID() != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -256,24 +235,19 @@ def test_ogr_carto_vsimem(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetFieldCount() != 4: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetFieldDefn(0).GetName() != 'strfield' or \ lyr_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetFieldDefn(1).GetName() != 'realfield' or \ lyr_defn.GetFieldDefn(1).GetType() != ogr.OFTReal: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetFieldDefn(2).GetName() != 'boolfield' or \ lyr_defn.GetFieldDefn(2).GetType() != ogr.OFTInteger or \ lyr_defn.GetFieldDefn(2).GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetFieldDefn(3).GetName() != 'datefield' or \ lyr_defn.GetFieldDefn(3).GetType() != ogr.OFTDateTime: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT "strfield", "realfield", "boolfield", "datefield" FROM "table1" LIMIT 500 OFFSET 0', @@ -281,7 +255,6 @@ def test_ogr_carto_vsimem(): f = lyr.GetNextFeature() if f['strfield'] != 'foo' or f['realfield'] != 1.23 or f['boolfield'] != 1 or \ f['datefield'] != '2015/04/24 12:34:56.123+00': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -295,7 +268,6 @@ def test_ogr_carto_vsimem(): lyr_defn = ds.GetLayer(0).GetLayerDefn() gdal.PopErrorHandler() if lyr_defn.GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' get_full_details_fields_url = """/vsimem/carto&POSTFIELDS=q=SELECT a.attname, t.typname, a.attlen, format_type(a.atttypid,a.atttypmod), a.attnum, a.attnotnull, i.indisprimary, pg_get_expr(def.adbin, c.oid) AS defaultexpr, postgis_typmod_dims(a.atttypmod) dim, postgis_typmod_srid(a.atttypmod) srid, postgis_typmod_type(a.atttypmod)::text geomtyp, srtext FROM pg_class c JOIN pg_attribute a ON a.attnum > 0 AND a.attrelid = c.oid AND c.relname = 'table1' JOIN pg_type t ON a.atttypid = t.oid JOIN pg_namespace n ON c.relnamespace=n.oid AND n.nspname= 'public' LEFT JOIN pg_index i ON c.oid = i.indrelid AND i.indisprimary = 't' AND a.attnum = ANY(i.indkey) LEFT JOIN pg_attrdef def ON def.adrelid = c.oid AND def.adnum = a.attnum LEFT JOIN spatial_ref_sys srs ON srs.srid = postgis_typmod_srid(a.atttypmod) ORDER BY a.attnum LIMIT 500 OFFSET 0&api_key=foo""" @@ -305,7 +277,6 @@ def test_ogr_carto_vsimem(): lyr_defn = ds.GetLayer(0).GetLayerDefn() gdal.PopErrorHandler() if lyr_defn.GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(get_full_details_fields_url, @@ -316,14 +287,12 @@ def test_ogr_carto_vsimem(): lyr_defn = lyr.GetLayerDefn() gdal.PopErrorHandler() if lyr_defn.GetFieldCount() != 1: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() f = lyr.GetFeature(0) gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer(get_full_details_fields_url, @@ -355,32 +324,25 @@ def test_ogr_carto_vsimem(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetFieldCount() != 5: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetFieldDefn(0).GetName() != 'strfield' or \ lyr_defn.GetFieldDefn(0).GetType() != ogr.OFTString or \ lyr_defn.GetFieldDefn(0).IsNullable() or \ lyr_defn.GetFieldDefn(0).GetDefault() != 'def_value': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldCount() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetName() != 'my_geom': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbPoint25D: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetSpatialRef().ExportToWkt().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1"&api_key=foo""", @@ -389,7 +351,6 @@ def test_ogr_carto_vsimem(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1"&api_key=foo""", @@ -399,21 +360,18 @@ def test_ogr_carto_vsimem(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1"&api_key=foo""", """{"rows":[{"count":9876543210}], "fields":{"count":{"type":"number"}}}""") if lyr.GetFeatureCount() != 9876543210: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() extent = lyr.GetExtent() gdal.PopErrorHandler() if extent != (0, 0, 0, 0): - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", @@ -424,7 +382,6 @@ def test_ogr_carto_vsimem(): extent = lyr.GetExtent() gdal.PopErrorHandler() if extent != (0, 0, 0, 0): - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", @@ -435,7 +392,6 @@ def test_ogr_carto_vsimem(): lyr.GetExtent() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", @@ -446,7 +402,6 @@ def test_ogr_carto_vsimem(): lyr.GetExtent() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", @@ -457,14 +412,12 @@ def test_ogr_carto_vsimem(): lyr.GetExtent() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", """{"rows":[{"st_extent":"BOX(0,1,2,3)"}], "fields":{"st_extent":{"type":"string"}}}""") if lyr.GetExtent() != (0.0, 2.0, 1.0, 3.0): - gdaltest.post_reason('fail') print(lyr.GetExtent()) return 'fail' @@ -472,7 +425,6 @@ def test_ogr_carto_vsimem(): f = lyr.GetFeature(0) gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" = 0&api_key=foo""", @@ -482,7 +434,6 @@ def test_ogr_carto_vsimem(): f = lyr.GetFeature(0) gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" = 0&api_key=foo""", @@ -491,7 +442,6 @@ def test_ogr_carto_vsimem(): f = lyr.GetFeature(0) if f.GetFID() != -1 or not f.IsFieldNull(0): - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" = 0&api_key=foo""", @@ -500,7 +450,6 @@ def test_ogr_carto_vsimem(): f = lyr.GetFeature(0) if f.GetFID() != 0: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() @@ -508,7 +457,6 @@ def test_ogr_carto_vsimem(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 500&api_key=foo""", @@ -517,13 +465,11 @@ def test_ogr_carto_vsimem(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('CARTO_PAGE_SIZE', '2') @@ -533,11 +479,9 @@ def test_ogr_carto_vsimem(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 10: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" >= 11 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", @@ -545,12 +489,10 @@ def test_ogr_carto_vsimem(): "fields":{"cartodb_id":{"type":"numeric"}}}""") f = lyr.GetNextFeature() if f.GetFID() != 12: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() f = lyr.GetNextFeature() if f is not None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter('strfield is NULL') @@ -559,7 +501,6 @@ def test_ogr_carto_vsimem(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE (strfield is NULL) AND "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", @@ -568,7 +509,6 @@ def test_ogr_carto_vsimem(): lyr.ResetReading() f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE (strfield is NULL) AND "cartodb_id" >= 1 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", """{"rows":[], @@ -576,14 +516,12 @@ def test_ogr_carto_vsimem(): gdal.ErrorReset() f = lyr.GetNextFeature() if f is not None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1" WHERE (strfield is NULL)&api_key=foo""", """{"rows":[{"count":9876543210}], "fields":{"count":{"type":"number"}}}""") if lyr.GetFeatureCount() != 9876543210: - gdaltest.post_reason('fail') return 'fail' lyr.SetSpatialFilterRect(-180, -90, 180, 90) @@ -592,7 +530,6 @@ def test_ogr_carto_vsimem(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE ("my_geom" %26%26 'BOX3D(-180 -90, 180 90)'::box3d) AND (strfield is NULL) AND "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", @@ -602,21 +539,18 @@ def test_ogr_carto_vsimem(): lyr.ResetReading() f = lyr.GetNextFeature() if f is None or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 1: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1" WHERE ("my_geom" %26%26 'BOX3D(-180 -90, 180 90)'::box3d) AND (strfield is NULL)&api_key=foo""", """{"rows":[{"count":9876543210}], "fields":{"count":{"type":"number"}}}""") if lyr.GetFeatureCount() != 9876543210: - gdaltest.post_reason('fail') return 'fail' # Not permitted in read-only mode @@ -644,7 +578,6 @@ def test_ogr_carto_vsimem(): lyr.GetNextFeature() gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT cdb_cartodbfytable('my_layer')&api_key=foo""", @@ -673,7 +606,6 @@ def test_ogr_carto_vsimem(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -682,14 +614,12 @@ def test_ogr_carto_vsimem(): with gdaltest.error_handler(): ret = lyr.CreateField(fld_defn) if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" ADD COLUMN "intfield" INTEGER&api_key=foo""", """{"rows":[], "fields":{}}""") if lyr.CreateField(fld_defn) != 0: - gdaltest.post_reason('fail') return 'fail' fld_defn = ogr.FieldDefn('boolfield', ogr.OFTInteger) @@ -699,19 +629,16 @@ def test_ogr_carto_vsimem(): """{"rows":[], "fields":{}}""") if lyr.CreateField(fld_defn) != 0: - gdaltest.post_reason('fail') return 'fail' # Invalid field with gdaltest.error_handler(): if lyr.DeleteField(-1) == 0: - gdaltest.post_reason('fail') return 'fail' # No server answer with gdaltest.error_handler(): if lyr.DeleteField(0) == 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" DROP COLUMN "boolfield"&api_key=foo""", @@ -719,14 +646,12 @@ def test_ogr_carto_vsimem(): "fields":{}}""") fld_pos = lyr.GetLayerDefn().GetFieldIndex(fld_defn.GetName()) if lyr.DeleteField(fld_pos) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" ADD COLUMN "boolfield" BOOLEAN&api_key=foo""", """{"rows":[], "fields":{}}""") if lyr.CreateField(fld_defn) != 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -734,7 +659,6 @@ def test_ogr_carto_vsimem(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -747,7 +671,6 @@ def test_ogr_carto_vsimem(): "fields":{"cartodb_id":{"type":"integer"}}}""") ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' f.SetFID(-1) @@ -755,7 +678,6 @@ def test_ogr_carto_vsimem(): ret = lyr.SetFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f.SetFID(3) @@ -763,21 +685,18 @@ def test_ogr_carto_vsimem(): ret = lyr.SetFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=UPDATE "my_layer" SET "strfield" = 'foo', "intfield" = 1, "boolfield" = 't', "the_geom" = '0101000020E610000000000000000000400000000000804840' WHERE "cartodb_id" = 3&api_key=foo""", """{"total_rows": 0}""") ret = lyr.SetFeature(f) if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=UPDATE "my_layer" SET "strfield" = 'foo', "intfield" = 1, "boolfield" = 't', "the_geom" = '0101000020E610000000000000000000400000000000804840' WHERE "cartodb_id" = 3&api_key=foo""", """{"total_rows": 1}""") ret = lyr.SetFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -785,7 +704,6 @@ def test_ogr_carto_vsimem(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=INSERT INTO "my_layer" DEFAULT VALUES RETURNING "cartodb_id"&api_key=foo""", @@ -793,28 +711,24 @@ def test_ogr_carto_vsimem(): "fields":{"cartodb_id":{"type":"integer"}}}""") ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 4: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = lyr.DeleteFeature(0) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=DELETE FROM "my_layer" WHERE "cartodb_id" = 0&api_key=foo""", """{"total_rows": 0}""") ret = lyr.DeleteFeature(0) if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=DELETE FROM "my_layer" WHERE "cartodb_id" = 0&api_key=foo""", """{"total_rows": 1}""") ret = lyr.DeleteFeature(0) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT cdb_cartodbfytable('my_layer')&api_key=foo""", @@ -836,7 +750,6 @@ def test_ogr_carto_vsimem(): f.SetField('strfield', 'foo') ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 11: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -847,7 +760,6 @@ def test_ogr_carto_vsimem(): ret = lyr.CreateFeature(f) ds = None if ret != 0 or f.GetFID() != 12: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -862,7 +774,6 @@ def test_ogr_carto_vsimem(): ds = None if ret != 0 or f.GetFID() != 11: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -901,21 +812,18 @@ def test_ogr_carto_vsimem(): """{"rows":[{"nextid":11}],"fields":{"nextid":{"type":"number"}}}"""): ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 11: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'bar') ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 12: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'baz') ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 13: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -923,7 +831,6 @@ def test_ogr_carto_vsimem(): """{"rows":[], "fields":{}}"""): ds = None if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('CARTO:foo', gdal.OF_VECTOR | gdal.OF_UPDATE, open_options=['COPY_MODE=NO']) @@ -932,7 +839,6 @@ def test_ogr_carto_vsimem(): lyr = ds.CreateLayer('table1') gdal.PopErrorHandler() if lyr is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=DROP TABLE "table1"&api_key=foo""", @@ -944,7 +850,6 @@ def test_ogr_carto_vsimem(): with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=CREATE TABLE "table1" ( cartodb_id SERIAL,the_geom Geometry(MULTIPOLYGON,0),PRIMARY KEY (cartodb_id) );DROP SEQUENCE IF EXISTS "table1_cartodb_id_seq" CASCADE;CREATE SEQUENCE "table1_cartodb_id_seq" START 1;ALTER SEQUENCE "table1_cartodb_id_seq" OWNED BY "table1".cartodb_id;ALTER TABLE "table1" ALTER COLUMN cartodb_id SET DEFAULT nextval('"table1_cartodb_id_seq"')&api_key=foo""", """{"rows":[], "fields":{}}"""): if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() @@ -953,7 +858,6 @@ def test_ogr_carto_vsimem(): "fields":{}}"""): ds = None if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = gdal.OpenEx('CARTO:foo', gdal.OF_VECTOR | gdal.OF_UPDATE, open_options=['COPY_MODE=NO']) @@ -970,10 +874,8 @@ def test_ogr_carto_vsimem(): with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=BEGIN;INSERT INTO "table1" ("cartodb_id") VALUES (100);COMMIT;&api_key=foo""", """{"rows":[], "fields":{}}"""): if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' if f.GetFID() != 100: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -983,17 +885,14 @@ def test_ogr_carto_vsimem(): ret = ds.DeleteLayer(0) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() ds = gdal.OpenEx('CARTO:foo', gdal.OF_VECTOR | gdal.OF_UPDATE, open_options=['COPY_MODE=YES']) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('table1') if lyr is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.tempfile("""/vsimem/carto/copyfrom?q=COPY%20"table1"%20("strfield","my_geom","cartodb_id")%20FROM%20STDIN%20WITH%20(FORMAT%20text,%20ENCODING%20UTF8)&api_key=foo&POSTFIELDS=copytest\t0101000020E610000000000000000059400000000000005940\t11\n\\.\n""","""{}"""): @@ -1004,14 +903,12 @@ def test_ogr_carto_vsimem(): f.SetField('strfield', 'copytest') f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(100 100)')) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('intfield', 12) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(100 100)')) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None # force flush @@ -1023,7 +920,6 @@ def test_ogr_carto_vsimem(): """{"rows":[], "fields":{}}"""): ds.ExecuteSQL('DELLAYER:table1') if gdal.GetLastErrorMsg() != '' or ds.GetLayerByName('table1') is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.tempfile('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0&api_key=foo', @@ -1034,7 +930,6 @@ def test_ogr_carto_vsimem(): """{"rows":[{"relname": "a_layer"}],"fields":{"relname":{"type":"string"}}}"""): ds = ogr.Open('CARTO:foo') if ds.GetLayerByName('a_layer') is None: - gdaltest.post_reason('fail') return 'fail' @@ -1150,7 +1045,6 @@ def ogr_carto_rw_1(): ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f.SetFID(-1) @@ -1163,7 +1057,6 @@ def ogr_carto_rw_1(): f.SetGeometry(ogr.CreateGeometryFromWkt('POINT (1 2)')) ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f.SetField('intfield', 456) @@ -1171,7 +1064,6 @@ def ogr_carto_rw_1(): f.SetGeometry(ogr.CreateGeometryFromWkt('POINT (3 4)')) ret = lyr.SetFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' fid = f.GetFID() @@ -1184,7 +1076,6 @@ def ogr_carto_rw_1(): if lyr.GetName() == lyr_name: found = True if not found: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName(lyr_name) found = False @@ -1192,7 +1083,6 @@ def ogr_carto_rw_1(): if lyr.GetLayerDefn().GetFieldDefn(i).GetName() == 'strfield': found = True if not found: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(fid) if f.GetField('strfield') != "fo'o" or \ @@ -1202,7 +1092,6 @@ def ogr_carto_rw_1(): f.GetField('dt') != '2014/12/04 12:34:56+00' or \ f.GetField('bool') != 1 or \ f.GetGeometryRef().ExportToWkt() != 'POINT (3 4)': - gdaltest.post_reason('fail') f.DumpReadable() ds.ExecuteSQL("DELLAYER:" + lyr_name) return 'fail' @@ -1210,7 +1099,6 @@ def ogr_carto_rw_1(): lyr.DeleteFeature(fid) f = lyr.GetFeature(fid) if f is not None: - gdaltest.post_reason('fail') ds.ExecuteSQL("DELLAYER:" + lyr_name) return 'fail' @@ -1238,7 +1126,6 @@ def ogr_carto_rw_1(): sql_lyr = ds.ExecuteSQL('SELECT ST_AsText(the_geom_webmercator) AS foo FROM ' + lyr_name) f = sql_lyr.GetNextFeature() if not f.GetField(0).startswith('POINT'): - gdaltest.post_reason('fail') ds.ExecuteSQL("DELLAYER:" + lyr_name) ds.ReleaseResultSet(sql_lyr) return 'fail' @@ -1274,23 +1161,18 @@ def ogr_carto_rw_1(): lyr = ds.GetLayerByName(lyr_name) if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('nullable')).IsNullable() != 1: ds.ExecuteSQL("DELLAYER:" + lyr_name) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('not_nullable')).IsNullable() != 0: ds.ExecuteSQL("DELLAYER:" + lyr_name) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() != "'a''b'": ds.ExecuteSQL("DELLAYER:" + lyr_name) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime_with_default')).GetDefault() != 'CURRENT_TIMESTAMP': ds.ExecuteSQL("DELLAYER:" + lyr_name) - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is None or f.GetField('field_string') != 'a\'b' or not f.IsFieldSet('field_datetime_with_default'): - gdaltest.post_reason('fail') ds.ExecuteSQL("DELLAYER:" + lyr_name) return 'fail' ds.ExecuteSQL("DELLAYER:" + lyr_name) diff --git a/autotest/ogr/ogr_couchdb.py b/autotest/ogr/ogr_couchdb.py index 83e00280e880..61a0904b50dd 100755 --- a/autotest/ogr/ogr_couchdb.py +++ b/autotest/ogr/ogr_couchdb.py @@ -82,7 +82,6 @@ def test_ogr_couchdb_1(): lyr = ds.GetLayerByName(ogrtest.couchdb_temp_layer_name) f = lyr.GetNextFeature() if f['AREA'] != 215229.266 or f['EAS_ID'] != '168' or f.GetGeometryRef() is None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ExecuteSQL('DELLAYER:' + ogrtest.couchdb_temp_layer_name) @@ -116,19 +115,16 @@ def test_ogr_couchdb_2(): f = lyr.GetNextFeature() if f['str_field'] != 'foo': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['str_field'] is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('str_field'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' diff --git a/autotest/ogr/ogr_csv.py b/autotest/ogr/ogr_csv.py index 43aed35ae336..ab187208bff0 100755 --- a/autotest/ogr/ogr_csv.py +++ b/autotest/ogr/ogr_csv.py @@ -90,10 +90,8 @@ def test_ogr_csv_2(): with gdaltest.error_handler(): if gdaltest.csv_ds.CreateLayer('foo') is not None: - gdaltest.post_reason('fail') return 'fail' if gdaltest.csv_ds.DeleteLayer(0) == 0: - gdaltest.post_reason('fail') return 'fail' lyr = gdaltest.csv_ds.GetLayerByName('prime_meridian') @@ -101,10 +99,8 @@ def test_ogr_csv_2(): f = ogr.Feature(lyr.GetLayerDefn()) with gdaltest.error_handler(): if lyr.CreateField(ogr.FieldDefn('foo')) == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.CreateFeature(f) == 0: - gdaltest.post_reason('fail') return 'fail' return ogr_csv_check_layer(lyr, False) @@ -177,14 +173,12 @@ def test_ogr_csv_3(): if False: # pylint: disable=using-constant-test # Check that we cannot add a new field now if gdaltest.csv_lyr1.TestCapability(ogr.OLCCreateField) != 0: - gdaltest.post_reason('fail') return 'fail' field_defn = ogr.FieldDefn('dummy', ogr.OFTString) gdal.PushErrorHandler('CPLQuietErrorHandler') ret = gdaltest.csv_lyr1.CreateField(field_defn) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -255,10 +249,8 @@ def test_ogr_csv_7(): with gdaltest.error_handler(): if gdaltest.csv_tmpds.DeleteLayer(-1) == 0: - gdaltest.post_reason('fail') return 'fail' if gdaltest.csv_tmpds.DeleteLayer(gdaltest.csv_tmpds.GetLayerCount()) == 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.csv_tmpds = None @@ -536,7 +528,6 @@ def test_ogr_csv_12(): with gdaltest.error_handler(): if gdaltest.csv_tmpds.CreateLayer('testcsvt_copy') is not None: - gdaltest.post_reason('fail') return 'fail' ####################################################### @@ -1050,15 +1041,12 @@ def test_ogr_csv_24(): ds = ogr.Open('/vsimem/single.csv') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 1: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField(0) != '': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField(0) != 'bar': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1135,7 +1123,6 @@ def test_ogr_csv_27(): lyr = ds.GetLayer(0) layer_defn = lyr.GetLayerDefn() if layer_defn.GetFieldCount() != 8: - gdaltest.post_reason('fail') return 'fail' expected_fields = [('unit', ogr.OFTString), @@ -1152,12 +1139,10 @@ def test_ogr_csv_27(): if fld.GetName() != expected_field[0]: print(fld.GetName()) print(expected_field[0]) - gdaltest.post_reason('fail') return 'fail' if fld.GetType() != expected_field[1]: print(fld.GetType()) print(expected_field[1]) - gdaltest.post_reason('fail') return 'fail' i = i + 1 @@ -1171,7 +1156,6 @@ def test_ogr_csv_27(): feat.GetField('time_2012') != 2.34 or \ feat.IsFieldSet('time_2012_flag'): feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1196,7 +1180,6 @@ def test_ogr_csv_28(): os.unlink('tmp/ogr_csv_28.csv') if data != '1,2\n': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1210,18 +1193,14 @@ def test_ogr_csv_29(): ds = ogr.GetDriverByName('CSV').CreateDataSource('tmp/ogr_csv_29', options=['GEOMETRY=AS_WKT']) if ds.TestCapability(ogr.ODsCCurveGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('test', geom_type=ogr.wkbNone) if lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr1_EPSG_4326", ogr.wkbPoint)) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr2_EPSG_32632", ogr.wkbPolygon)) != 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr2_EPSG_32632", ogr.wkbPolygon)) == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1236,26 +1215,21 @@ def test_ogr_csv_29(): ds = ogr.Open('tmp/ogr_csv_29') lyr = ds.GetLayerByName('test') if lyr.GetLayerDefn().GetGeomFieldCount() != 2: - gdaltest.post_reason('fail') return 'fail' srs = lyr.GetLayerDefn().GetGeomFieldDefn(0).GetSpatialRef() if srs.GetAuthorityCode(None) != '4326': - gdaltest.post_reason('fail') return 'fail' srs = lyr.GetLayerDefn().GetGeomFieldDefn(1).GetSpatialRef() if srs.GetAuthorityCode(None) != '32632': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() geom = feat.GetGeomFieldRef('geom__WKT_lyr1_EPSG_4326') if geom.ExportToWkt() != 'POINT (1 2)': feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' geom = feat.GetGeomFieldRef('geom__WKT_lyr2_EPSG_32632') if geom.ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1290,19 +1264,16 @@ def test_ogr_csv_31(): f = lyr.GetNextFeature() if f.GetField('GEONAMEID') != '3038814' or f.GetField('LATITUDE') != 42.5 or \ f.GetGeometryRef().ExportToWkt() != 'POINT (1.48333 42.5)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f.GetField('GEONAMEID') != '3038814': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if lyr.GetFeatureCount() != 10: - gdaltest.post_reason('fail') print(lyr.GetFeatureCount()) return 'fail' @@ -1324,13 +1295,11 @@ def test_ogr_csv_32(): for i in range(lyr.GetLayerDefn().GetFieldCount()): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTString or \ lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1343,13 +1312,11 @@ def test_ogr_csv_32(): for i in range(lyr.GetLayerDefn().GetFieldCount()): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTString or \ lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1367,13 +1334,11 @@ def test_ogr_csv_32(): for i in range(lyr.GetLayerDefn().GetFieldCount()): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1383,7 +1348,6 @@ def test_ogr_csv_32(): open_options=['AUTODETECT_TYPE=YES', 'AUTODETECT_SIZE_LIMIT=300']) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str3')).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' # We limit to the first 2 lines @@ -1399,13 +1363,11 @@ def test_ogr_csv_32(): for i in range(lyr.GetLayerDefn().GetFieldCount()): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1422,14 +1384,12 @@ def test_ogr_csv_32(): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != col_width[i] or \ lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision() != col_precision[i]: - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1446,14 +1406,12 @@ def test_ogr_csv_32(): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != col_width[i] or \ lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision() != col_precision[i]: - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) print(lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1471,13 +1429,11 @@ def test_ogr_csv_32(): for i in range(lyr.GetLayerDefn().GetFieldCount()): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTString and \ lyr.GetLayerDefn().GetFieldDefn(i + 1).GetNameRef() != lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef() + '_original': - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef()) print(lyr.GetLayerDefn().GetFieldDefn(i + 1).GetNameRef()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1499,7 +1455,6 @@ def test_ogr_csv_32(): lyr.GetFeature(fid) gdal.PopErrorHandler() if gdal.GetLastErrorType() != gdal.CE_Warning: - gdaltest.post_reason('fail') print(fid) f.DumpReadable() return 'fail' @@ -1515,7 +1470,6 @@ def test_ogr_csv_32(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetField(0) != 1.2: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1535,12 +1489,10 @@ def test_ogr_csv_33(): for i in range(lyr.GetLayerDefn().GetFieldCount()): if (i < 10 and lyr.GetLayerDefn().GetFieldDefn(i).GetSubType() != ogr.OFSTBoolean) or \ (i >= 10 and lyr.GetLayerDefn().GetFieldDefn(i).GetSubType() == ogr.OFSTBoolean): - gdaltest.post_reason('fail') print(i) print(lyr.GetLayerDefn().GetFieldDefn(i).GetSubType()) return 'fail' if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1569,19 +1521,15 @@ def test_ogr_csv_33(): lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTInteger or \ lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(1).GetType() != ogr.OFTInteger or \ lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTInt16: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(2).GetType() != ogr.OFTReal or \ lyr.GetLayerDefn().GetFieldDefn(2).GetSubType() != ogr.OFSTFloat32: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetField(0) != 1 or f.GetField(1) != -32768 or f.GetField(2) != 1.23: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1604,7 +1552,6 @@ def test_ogr_csv_34(): col_values = [1, 10000000000, 10000000000, 10000000000.0] for i in range(lyr.GetLayerDefn().GetFieldCount()): if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1612,7 +1559,6 @@ def test_ogr_csv_34(): col_values = [10000000000, 1, 10000000000, 1.0] for i in range(lyr.GetLayerDefn().GetFieldCount()): if f.GetField(i) != col_values[i]: - gdaltest.post_reason('fail') print(i) f.DumpReadable() return 'fail' @@ -1632,7 +1578,6 @@ def test_ogr_csv_34(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetField(0) != 10000000000: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1658,7 +1603,6 @@ def test_ogr_csv_35(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['FIELD_1'] != 'VAL1' or f['FIELD 2'] != 'VAL 2' or f['FIELD_3'] != 'VAL 3': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1680,7 +1624,6 @@ def test_ogr_csv_35(): gdal.VSIFCloseL(f) if data.find('FIELD_1 "FIELD 2"') < 0 or data.find('VAL1 "VAL 2"') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1708,27 +1651,22 @@ def test_ogr_csv_36(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)' or f['id'] != '1' or f['mygeometry'] != 'POINT(1 2)' or f['format'] != 'wkt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef() is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1739,7 +1677,6 @@ def test_ogr_csv_36(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1750,7 +1687,6 @@ def test_ogr_csv_36(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1761,7 +1697,6 @@ def test_ogr_csv_36(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1771,7 +1706,6 @@ def test_ogr_csv_36(): open_options=['GEOM_POSSIBLE_NAMES=bla']) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetGeomFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1780,11 +1714,9 @@ def test_ogr_csv_36(): open_options=['GEOM_POSSIBLE_NAMES=mygeometry', 'KEEP_GEOM_COLUMNS=NO']) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 2: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)' or f['id'] != '1' or f['format'] != 'wkt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1811,17 +1743,14 @@ def test_ogr_csv_37(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)' or f['id'] != '1' or f['x'] != 2 or f['y'] != 49 or f['other'] != 'a' or f['z'] != '100': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef() is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1832,17 +1761,14 @@ def test_ogr_csv_37(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49 100)' or f['id'] != '1' or f['x'] != 2 or f['y'] != 49 or f['other'] != 'a' or f['z'] != 100: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef() is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1852,11 +1778,9 @@ def test_ogr_csv_37(): open_options=['X_POSSIBLE_NAMES=long,x', 'Y_POSSIBLE_NAMES=lat,y', 'KEEP_GEOM_COLUMNS=NO']) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 3: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)' or f['id'] != '1' or f['other'] != 'a': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1885,14 +1809,11 @@ def test_ogr_csv_38(): ds = ogr.Open('/vsimem/ogr_csv_38.csv') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetGeomFieldDefn(0).GetName() != 'mygeom': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(0).GetSpatialRef().ExportToWkt().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1922,7 +1843,6 @@ def test_ogr_csv_39(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1948,7 +1868,6 @@ def test_ogr_csv_40(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)' or f['id'] != '1' or f['the_geom'] != '0101000020E61000004486E281C5C257C068B89DDA998F4640': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() @@ -1966,7 +1885,6 @@ def test_ogr_csv_40(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt().find('POINT (-95.04') < 0 or f['id'] != '1' or f['longitude'] != '2' or f['latitude'] != '49': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() @@ -1992,7 +1910,6 @@ def test_ogr_csv_41(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef() is not None or f['id'] != '1' or f['foo'] != 'bar': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2014,7 +1931,6 @@ def test_ogr_csv_42(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 1) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2034,80 +1950,63 @@ def test_ogr_csv_43(): f.SetField('id', 1) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(2 49)')) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = None lyr.SetNextByIndex(0) f = lyr.GetNextFeature() if f['id'] != 1: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None if lyr.TestCapability(ogr.OLCCreateField) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) != 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) == 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(1) f.SetField('foo', 'bar') if lyr.TestCapability(ogr.OLCRandomWrite) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.SetFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(1) if f['id'] != 1 or f['foo'] != 'bar' or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f['id'] != 1 or f['foo'] != 'bar' or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 2) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(3 50)')) f.SetField('foo', 'baz') if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' if f.GetFID() != 2: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(2) if f['id'] != 2 or f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' lyr.SetNextByIndex(1) f = lyr.GetNextFeature() if f['id'] != 2: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None @@ -2118,66 +2017,49 @@ def test_ogr_csv_43(): lyr = ds.GetLayer(0) f = lyr.GetFeature(2) if f['id'] != 2 or f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None if lyr.TestCapability(ogr.OLCDeleteField) != 1: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if lyr.DeleteField(-1) == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foo')) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCDeleteFeature) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteFeature(2) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteFeature(2) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteFeature(3) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeature(2) is not None: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeature(3) is not None: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f['id'] = 3 if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' if f.GetFID() != 3: - gdaltest.post_reason('fail') return 'fail' f = None if lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(1) if f['foo'] == 'bar': - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(3) if f.GetFID() != 3: - gdaltest.post_reason('fail') return 'fail' f = None ds = None @@ -2186,30 +2068,23 @@ def test_ogr_csv_43(): lyr = ds.GetLayer(0) f = lyr.GetFeature(2) if f['id'] != 3: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foo')) != 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(4 51)')) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' if f.GetFID() != 3: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if lyr.GetExtent() != (2.0, 4.0, 49.0, 51.0): - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteFeature(f.GetFID()) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): @@ -2221,74 +2096,57 @@ def test_ogr_csv_43(): lyr.SetSpatialFilter(0, lyr.GetSpatialFilter()) lyr.SetSpatialFilter(lyr.GetSpatialFilter()) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetExtent() != (2.0, 2.0, 49.0, 49.0): - gdaltest.post_reason('fail') return 'fail' if lyr.GetExtent(geom_field=0) != (2.0, 2.0, 49.0, 49.0): - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): lyr.GetExtent(geom_field=-1) lyr.SetAttributeFilter(None) if lyr.TestCapability(ogr.OLCCurveGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCTransactions) != 0: - gdaltest.post_reason('fail') return 'fail' lyr.StartTransaction() lyr.RollbackTransaction() lyr.CommitTransaction() if lyr.GetGeometryColumn() != '': - gdaltest.post_reason('fail') return 'fail' if lyr.GetFIDColumn() != '': - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCReorderFields) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.ReorderFields([0, 1]) != 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if lyr.ReorderFields([0, -1]) == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCAlterFieldDefn) != 1: - gdaltest.post_reason('fail') return 'fail' fld_defn = lyr.GetLayerDefn().GetFieldDefn(0) if lyr.AlterFieldDefn(0, fld_defn, 0) != 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if lyr.AlterFieldDefn(-1, fld_defn, 0) == 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(2) f.SetGeomField(0, ogr.CreateGeometryFromWkt('POINT (1 2)')) if lyr.SetFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = None if lyr.TestCapability(ogr.OLCCreateGeomField) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.CreateGeomField(ogr.GeomFieldDefn('geom__WKT_2')) != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(2) f.SetGeomField(1, ogr.CreateGeometryFromWkt('POINT (3 4)')) if lyr.SetFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -2298,21 +2156,16 @@ def test_ogr_csv_43(): lyr = ds.GetLayer(0) f = lyr.GetFeature(2) if f['WKT'] != 'POINT (1 2)' or f['_WKT_2'] != 'POINT (3 4)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if lyr.SetFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = None if lyr.DeleteFeature(2) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeature(2) is not None: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteFeature(2) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2333,22 +2186,18 @@ def test_ogr_csv_44(): f.SetField('id', 1) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(2 49)')) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = None f = lyr.GetFeature(1) if f['id'] != 1 or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 2) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(2) if f['id'] != 2 or f.GetGeometryRef() is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2415,11 +2264,9 @@ def test_ogr_csv_46(): ds = ogr.Open('/vsimem/ogr_csv_46.csv') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 4: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f['id'] != '1' or f['X'] != '10' or f['Y'] != '20' or f['Z'] != '3': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2435,11 +2282,9 @@ def test_ogr_csv_46(): ds = ogr.Open('/vsimem/ogr_csv_46.csv') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 4: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f['id'] != '1' or f['X'] != '-10' or f['Y'] != '-20' or f['Z'] != '3': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2455,11 +2300,9 @@ def test_ogr_csv_46(): ds = ogr.Open('/vsimem/ogr_csv_46.csv') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 4: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f['id'] != '1' or f['X'] != '-1' or f['Y'] != '-2' or f['Z'] != '-3': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2476,11 +2319,9 @@ def test_ogr_csv_47(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_47.csv') if ds.TestCapability(ogr.ODsCMeasuredGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('ogr_csv_47', options=['GEOMETRY=AS_WKT']) if lyr.TestCapability(ogr.OLCMeasuredGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' lyr.CreateField(ogr.FieldDefn('id', ogr.OFTInteger)) f = ogr.Feature(lyr.GetLayerDefn()) @@ -2494,7 +2335,6 @@ def test_ogr_csv_47(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT ZM (1 2 3 4)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2522,7 +2362,6 @@ def test_ogr_csv_48(): gdal.VSIFCloseL(f) if data.find('stringlist,intlist,int64list,reallist\n"[ ""a"", """" ]",[ 1 ],[ 1234567890123 ],[ 0.125') != 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2531,7 +2370,6 @@ def test_ogr_csv_48(): gdal.VSIFCloseL(f) if data.find('JSonStringList,JSonIntegerList,JSonInteger64List,JSonRealList') != 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2556,7 +2394,6 @@ def test_ogr_csv_49(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if not f.IsFieldNull('str'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2592,7 +2429,6 @@ def test_ogr_csv_string_quoting_always(): gdal.VSIFCloseL(f) if data.find('"AREA","EAS_ID","PRFEDEA"\n215229.266,"168","35043411"') != 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2607,7 +2443,6 @@ def test_ogr_csv_string_quoting_always(): gdal.VSIFCloseL(f) if data.find('"AREA","EAS_ID","PRFEDEA"\n215229.266,"168","35043411"\n247328.172,"179","35043423"') != 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2641,7 +2476,6 @@ def test_ogr_csv_string_quoting_if_ambiguous(): gdal.VSIFCloseL(f) if data.find('"00123",x,"1.25"') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2674,7 +2508,6 @@ def test_ogr_csv_string_quoting_if_needed(): gdal.VSIFCloseL(f) if data.find('00123,x,1.25') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' diff --git a/autotest/ogr/ogr_csw.py b/autotest/ogr/ogr_csw.py index 7b8178072cb7..1a69504c6cc9 100755 --- a/autotest/ogr/ogr_csw.py +++ b/autotest/ogr/ogr_csw.py @@ -116,10 +116,8 @@ def test_ogr_csw_vsimem_fail_because_empty_response(): ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Empty content returned by server') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -137,10 +135,8 @@ def test_ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Cannot find Capabilities.version') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -158,10 +154,8 @@ def test_ogr_csw_vsimem_fail_because_exception(): ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Error returned by server : ') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -179,10 +173,8 @@ def test_ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Invalid XML content : full""", @@ -257,7 +242,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None or gdal.GetLastErrorMsg().find('Empty content returned by server') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -268,7 +252,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None or gdal.GetLastErrorMsg().find('Error: cannot parse') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -279,7 +262,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None or gdal.GetLastErrorMsg().find('Error: cannot parse') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -290,7 +272,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None or gdal.GetLastErrorMsg().find('Error returned by server') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -334,38 +315,32 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): lyr.ResetReading() f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' if f['identifier'] != 'an_identifier' or f['other_identifiers'] != ['another_identifier'] or \ f['subject'] != 'a_subject' or f['other_subjects'] != ['another_subject'] or \ f['references'] != 'http://foo/' or f['other_references'] != ['http://bar/'] or \ f['format'] != 'a_format' or f['other_formats'] != ['another_format'] or \ f['boundingbox'].ExportToWkt() != 'POLYGON ((-180 -90,-180 90,180 90,180 -90,-180 -90))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 2: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """ @@ -386,11 +361,9 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", @@ -410,7 +383,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", @@ -419,7 +391,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 3: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -429,7 +400,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 3: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -439,7 +409,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 3: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -449,7 +418,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 3: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -470,7 +438,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) fc = lyr.GetFeatureCount() if fc != 200: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("identifier = 'an_identifier'") @@ -494,7 +461,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=fullows:BoundingBox-90 -18090 180dc:identifieran_identifier""", @@ -514,7 +480,6 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) fc = lyr.GetFeatureCount() if fc != 300: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("identifier = 'an_identifier' AND " + @@ -545,7 +510,6 @@ def test_ogr_csw_vsimem_csw_output_schema_csw(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", @@ -555,7 +519,6 @@ def test_ogr_csw_vsimem_csw_output_schema_csw(): f = lyr.GetNextFeature() gdal.PopErrorHandler() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", @@ -585,7 +548,6 @@ def test_ogr_csw_vsimem_csw_output_schema_csw(): f = lyr.GetNextFeature() if f['raw_xml'].find('= 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f['str_field'] != 'foo' or \ f['superobject'] != '{ "subfield": 5, "subobject": { "subfield": "foo", "another_subfield": 6 }, "another_geoshape": { "type": "point", "coordinates": [ 3, 50 ] }, "another_geoshape2": { "type": "point", "coordinates": [ 2, 50 ] } }' or \ f['a_geopoint'].ExportToWkt() != 'POINT (2 49)' or \ f['a_geoshape'].ExportToWkt() != 'LINESTRING (2 49,3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1392,7 +1305,6 @@ def test_ogr_elasticsearch_5(): f['a_geopoint'].ExportToWkt() != 'POINT (2 49)' or \ f['a_geoshape'].ExportToWkt() != 'LINESTRING (2 49,3 50)' or \ f['superobject.another_geoshape'].ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1402,7 +1314,6 @@ def test_ogr_elasticsearch_5(): """/vsimem/fakeelasticsearch/non_geojson/my_mapping/my_id&POSTFIELDS={ "foo": "bar" }""", "{}") ret = lyr.SetFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1483,26 +1394,22 @@ def test_ogr_elasticsearch_6(): }""") f = lyr.GetNextFeature() if f['geometry'].ExportToWkt() != 'POLYGON ((2 49,3 49,3 50,2 50,2 49))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() ref_txt = f['geometry'].ExportToWkt() if ref_txt.find('POLYGON ((') != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['geometry'].ExportToWkt() != ref_txt: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['geometry'].ExportToWkt() != ref_txt: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1532,7 +1439,6 @@ def test_ogr_elasticsearch_7(): f = gdal.VSIFOpenL('/vsimem/map.txt', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) @@ -1540,7 +1446,6 @@ def test_ogr_elasticsearch_7(): gdal.Unlink('/vsimem/map.txt') if data != '{ "FeatureCollection": { "properties": { "type": { "type": "string" }, "properties": { "properties": { } }, "geometry": { "type": "geo_shape" } } } }': - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1586,7 +1491,6 @@ def test_ogr_elasticsearch_8(): gdaltest.post_reason('warning expected') return 'fail' if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Non EPSG-4326 SRS @@ -1605,7 +1509,6 @@ def test_ogr_elasticsearch_8(): """, "{}") ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1691,7 +1594,6 @@ def test_ogr_elasticsearch_9(): count = lyr.GetFeatureCount() if count != 2: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "geo_shape": { "a_geoshape": { "shape": { "type": "envelope", "coordinates": [ [ 2.0, 50.0 ], [ 3.0, 49.0 ] ] } } } } } } }""", @@ -1717,7 +1619,6 @@ def test_ogr_elasticsearch_9(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1803,7 +1704,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("text_field = 'foo'") @@ -1826,7 +1726,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("text_field_with_raw = 'foo'") @@ -1849,7 +1748,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("\"_id\" = 'my_id2'") @@ -1871,7 +1769,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field != 'foo'") @@ -1894,7 +1791,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field IS NULL") @@ -1916,7 +1812,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field BETWEEN 'bar' AND 'foo'") @@ -1939,7 +1834,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field IN ('foo', 'bar')") @@ -1962,7 +1856,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("text_field IN ('foo', 'bar')") @@ -1985,7 +1878,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("text_field_with_raw IN ('foo', 'bar')") @@ -2008,7 +1900,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("\"_id\" IN ('my_id', 'bar')") @@ -2031,7 +1922,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter( @@ -2057,7 +1947,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("dt_field > '2016/01/01 12:34:56.123'") @@ -2080,7 +1969,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("NOT dt_field < '2016/01/01 12:34:56.123'") @@ -2103,7 +1991,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field LIKE '_o%'") @@ -2126,7 +2013,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' # Evaluated client-side since the pattern uses ? or * @@ -2150,7 +2036,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' # Evaluated client-side since the field is analyzed @@ -2174,7 +2059,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("text_field_with_raw LIKE '_xo%' ESCAPE 'x'") @@ -2197,7 +2081,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field = 'foo' AND 1 = 1") @@ -2220,13 +2103,11 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("1 = 1 AND keyword_field = 'foo'") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field = 'bar' OR 1 = 0") @@ -2249,7 +2130,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' lyr.SetAttributeFilter("keyword_field = 'foo2'") @@ -2277,7 +2157,6 @@ def test_ogr_elasticsearch_10(): }""") f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' # SQL with WHERE @@ -2285,7 +2164,6 @@ def test_ogr_elasticsearch_10(): "SELECT * FROM a_layer WHERE keyword_field = 'foo'") f = sql_lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2311,7 +2189,6 @@ def test_ogr_elasticsearch_10(): }""") f = sql_lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2336,7 +2213,6 @@ def test_ogr_elasticsearch_10(): }""") f = sql_lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2361,7 +2237,6 @@ def test_ogr_elasticsearch_10(): }""") f = sql_lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2456,19 +2331,16 @@ def test_ogr_elasticsearch_11(): f = lyr.GetNextFeature() if f['str_field'] != 'foo': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['str_field'] is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('str_field'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2491,18 +2363,15 @@ def test_ogr_elasticsearch_11(): f.SetFieldNull('str_field') ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f = None f = ogr.Feature(lyr.GetLayerDefn()) ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f = None if lyr.SyncToDisk() != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2550,7 +2419,6 @@ def test_ogr_elasticsearch_authentication(): ds = gdal.OpenEx('ES:/vsimem/fakeelasticsearch', open_options=['USERPWD=user:pwd']) if ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_factory.py b/autotest/ogr/ogr_factory.py index 0f23543f8c10..7ccdd3ed4d61 100755 --- a/autotest/ogr/ogr_factory.py +++ b/autotest/ogr/ogr_factory.py @@ -584,14 +584,12 @@ def test_ogr_factory_8(): if exp_wkt is None: exp_wkt = src_wkt elif target_type != ogr.wkbUnknown and dst_geom.GetGeometryType() != target_type: - gdaltest.post_reason('fail') print(src_wkt) print(target_type) print(dst_geom.ExportToWkt()) return 'fail' if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - gdaltest.post_reason('fail') print(src_wkt) print(target_type) print(dst_geom.ExportToWkt()) diff --git a/autotest/ogr/ogr_feature.py b/autotest/ogr/ogr_feature.py index 4af512d72cbd..bff89a400941 100755 --- a/autotest/ogr/ogr_feature.py +++ b/autotest/ogr/ogr_feature.py @@ -110,7 +110,6 @@ def mk_src_feature(): expected_vals = [2011, 11, 11, 14, 10, 35.123, 0] for i, exp_val in enumerate(expected_vals): if abs(got_vals[i] - exp_val) > 1e-4: - gdaltest.post_reason('fail') print(got_vals) print(expected_vals) src_feature.field_integerlist = '(3:10,20,30)' @@ -189,7 +188,6 @@ def test_ogr_feature_cp_integer(): vals.append(val) if vals != [17, 2147483647, 18, 0, None, None, None, None, 15, 2147483647, 17, None]: - gdaltest.post_reason('fail') print(vals) return 'fail' @@ -217,7 +215,6 @@ def test_ogr_feature_cp_integer64(): int32_ovflw = dst_feature.GetFieldAsInteger('field_integer64') gdal.PopErrorHandler() if int32_ovflw != 2147483647: - gdaltest.post_reason('fail') return 'fail' if not check(dst_feature, 'field_real', 18): @@ -800,14 +797,12 @@ def test_ogr_feature_overflow_64bit_integer(): f.SetField(0, '9999999999999999999') gdal.PopErrorHandler() if f.GetField(0) != 9223372036854775807: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' gdal.PushErrorHandler() f.SetField(0, '-9999999999999999999') gdal.PopErrorHandler() if f.GetField(0) != -9223372036854775808: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' return 'success' @@ -821,22 +816,18 @@ def test_ogr_feature_nullable_validate(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) if f.Validate() != 1: - gdaltest.post_reason('fail') return 'fail' # Field with default parameter and empty feature feat_def = ogr.FeatureDefn('test') field_def = ogr.FieldDefn('field_string', ogr.OFTString) if field_def.IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' if feat_def.GetGeomFieldDefn(0).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) if f.Validate() != 1: - gdaltest.post_reason('fail') return 'fail' # Field with not NULL constraint and empty feature @@ -844,7 +835,6 @@ def test_ogr_feature_nullable_validate(): field_def = ogr.FieldDefn('field_string', ogr.OFTString) field_def.SetNullable(0) if field_def.IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) @@ -852,7 +842,6 @@ def test_ogr_feature_nullable_validate(): ret = f.Validate() gdal.PopErrorHandler() if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Field with not NULL constraint and non-empty feature @@ -863,7 +852,6 @@ def test_ogr_feature_nullable_validate(): f = ogr.Feature(feat_def) f.SetField(0, 'foo') if f.Validate() != 1: - gdaltest.post_reason('fail') return 'fail' # Field with width constraint that is met @@ -874,7 +862,6 @@ def test_ogr_feature_nullable_validate(): f = ogr.Feature(feat_def) f.SetField(0, 'foo') if f.Validate() != 1: - gdaltest.post_reason('fail') return 'fail' # Field with width constraint that is not met @@ -888,7 +875,6 @@ def test_ogr_feature_nullable_validate(): ret = f.Validate() gdal.PopErrorHandler() if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Geometry field with not-null geometry constraint that is met @@ -897,13 +883,11 @@ def test_ogr_feature_nullable_validate(): gfield_def = ogr.GeomFieldDefn('test', ogr.wkbUnknown) gfield_def.SetNullable(0) if gfield_def.IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' feat_def.AddGeomFieldDefn(gfield_def) f = ogr.Feature(feat_def) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(0 1)')) if f.Validate() != 1: - gdaltest.post_reason('fail') return 'fail' # Geometry field with not-null geometry constraint that is not met @@ -917,7 +901,6 @@ def test_ogr_feature_nullable_validate(): ret = f.Validate() gdal.PopErrorHandler() if ret != 0: - gdaltest.post_reason('fail') return 'fail' # Geometry field with Point geometry type that is met @@ -926,7 +909,6 @@ def test_ogr_feature_nullable_validate(): f = ogr.Feature(feat_def) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(0 1)')) if f.Validate() != 1: - gdaltest.post_reason('fail') return 'fail' # Geometry field with LineString geometry type that is not met @@ -938,7 +920,6 @@ def test_ogr_feature_nullable_validate(): ret = f.Validate() gdal.PopErrorHandler() if ret != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -953,45 +934,36 @@ def test_ogr_feature_default(): field_def = ogr.FieldDefn('field_string', ogr.OFTString) if field_def.GetDefault() is not None: - gdaltest.post_reason('fail') return 'fail' if field_def.IsDefaultDriverSpecific(): - gdaltest.post_reason('fail') return 'fail' field_def.SetDefault("(some_expr)") if field_def.GetDefault() != "(some_expr)": - gdaltest.post_reason('fail') return 'fail' if not field_def.IsDefaultDriverSpecific(): - gdaltest.post_reason('fail') return 'fail' field_def.SetDefault("'a") if field_def.GetDefault() != "'a": - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() field_def.SetDefault("'a''") gdal.PopErrorHandler() if field_def.GetDefault() is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() field_def.SetDefault("'a'b'") gdal.PopErrorHandler() if field_def.GetDefault() is not None: - gdaltest.post_reason('fail') return 'fail' field_def.SetDefault("'a''b'''") if field_def.GetDefault() != "'a''b'''": - gdaltest.post_reason('fail') return 'fail' if field_def.IsDefaultDriverSpecific(): - gdaltest.post_reason('fail') return 'fail' feat_def.AddFieldDefn(field_def) @@ -1018,7 +990,6 @@ def test_ogr_feature_default(): f.GetField('field_int') != 123 or \ f.IsFieldSet('field_nodefault'): f.DumpReadable() - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(feat_def) @@ -1026,7 +997,6 @@ def test_ogr_feature_default(): f.FillUnsetWithDefault() if f.GetField('field_string') != 'b': f.DumpReadable() - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1040,45 +1010,35 @@ def test_ogr_feature_native_data(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) if f.GetNativeData() is not None: - gdaltest.post_reason('fail') return 'fail' if f.GetNativeMediaType() is not None: - gdaltest.post_reason('fail') return 'fail' f.SetNativeData('native_data') if f.GetNativeData() != 'native_data': - gdaltest.post_reason('fail') return 'fail' f.SetNativeMediaType('native_media_type') if f.GetNativeMediaType() != 'native_media_type': - gdaltest.post_reason('fail') print(f.GetNativeMediaType()) return 'fail' f2 = ogr.Feature(feat_def) f2.SetFrom(f) if f2.GetNativeData() != 'native_data': - gdaltest.post_reason('fail') return 'fail' if f2.GetNativeMediaType() != 'native_media_type': - gdaltest.post_reason('fail') return 'fail' f_clone = f.Clone() if f_clone.GetNativeData() != 'native_data': - gdaltest.post_reason('fail') return 'fail' if f_clone.GetNativeMediaType() != 'native_media_type': - gdaltest.post_reason('fail') return 'fail' f_clone.SetNativeData(None) f_clone.SetNativeMediaType(None) if f_clone.GetNativeData() is not None: - gdaltest.post_reason('fail') return 'fail' if f_clone.GetNativeMediaType() is not None: - gdaltest.post_reason('fail') return 'fail' ds = ogr.GetDriverByName('Memory').CreateDataSource('') @@ -1098,24 +1058,20 @@ def test_ogr_feature_native_data(): sql_lyr = ds.ExecuteSQL('SELECT * FROM %s' % lyr.GetName(), dialect=dialect) native_data = sql_lyr.GetMetadataItem('NATIVE_DATA', 'NATIVE_DATA') if native_data != 'native_data': - gdaltest.post_reason('fail') print(dialect) print(native_data) return 'fail' native_media_type = sql_lyr.GetMetadataItem('NATIVE_MEDIA_TYPE', 'NATIVE_DATA') if native_media_type != 'native_media_type': - gdaltest.post_reason('fail') print(dialect) print(native_media_type) return 'fail' f = sql_lyr.GetNextFeature() if f.GetNativeData() != 'native_data': - gdaltest.post_reason('fail') print(dialect) print(f.GetNativeData()) return 'fail' if f.GetNativeMediaType() != 'native_media_type': - gdaltest.post_reason('fail') print(dialect) print(f.GetNativeMediaType()) return 'fail' @@ -1137,7 +1093,6 @@ def test_ogr_feature_set_geometry_self(): f.SetGeometry(f.GetGeometryRef()) f.SetGeometry(f.GetGeometryRef()) if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1153,22 +1108,17 @@ def test_ogr_feature_null_field(): feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) if f.IsFieldNull(feat_def.GetFieldIndex("field_string")): - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull("field_string"): - gdaltest.post_reason('fail') return 'fail' f.SetFieldNull(feat_def.GetFieldIndex("field_string")) if f.IsFieldNull(feat_def.GetFieldIndex("field_string")) == 0: - gdaltest.post_reason('fail') return 'fail' f.SetField("field_string", "foo") if f.IsFieldNull("field_string"): - gdaltest.post_reason('fail') return 'fail' f.SetFieldNull("field_string") if f.IsFieldNull(feat_def.GetFieldIndex("field_string")) == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -1194,19 +1144,14 @@ def test_ogr_feature_null_field(): f.field_reallist = [123.5, 567.0] f.field_stringlist = ['abc', 'def'] if f.IsFieldNull('field_binary') != 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_integerlist') != 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_integer64list') != 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_reallist') != 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_stringlist') != 0: - gdaltest.post_reason('fail') return 'fail' f.SetField('field_binary', None) f.SetFieldNull('field_integerlist') @@ -1214,27 +1159,20 @@ def test_ogr_feature_null_field(): f.SetFieldNull('field_reallist') f.SetFieldNull('field_stringlist') if f.IsFieldNull('field_binary') == 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_integerlist') == 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_integer64list') == 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_reallist') == 0: - gdaltest.post_reason('fail') return 'fail' if f.IsFieldNull('field_stringlist') == 0: - gdaltest.post_reason('fail') return 'fail' f_clone = f.Clone() if f_clone.IsFieldNull('field_binary') == 0: - gdaltest.post_reason('fail') return 'fail' if not f.Equal(f_clone): - gdaltest.post_reason('fail') return 'fail' f = None diff --git a/autotest/ogr/ogr_fgdb.py b/autotest/ogr/ogr_fgdb.py index c40a8cd9cb5b..7e2032033f88 100755 --- a/autotest/ogr/ogr_fgdb.py +++ b/autotest/ogr/ogr_fgdb.py @@ -175,7 +175,6 @@ def test_ogr_fgdb_1(): lyr = ds.GetLayerByName(data[0]) if data[1] != ogr.wkbNone: if lyr.GetSpatialRef().IsSame(srs) != 1: - gdaltest.post_reason('fail') print(lyr.GetSpatialRef()) return 'fail' feat = lyr.GetNextFeature() @@ -186,12 +185,10 @@ def test_ogr_fgdb_1(): expected_wkt = data[2] if expected_wkt is None: if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') print(data) feat.DumpReadable() return 'fail' elif ogrtest.check_feature_geometry(feat, expected_wkt) != 0: - gdaltest.post_reason('fail') print(data) feat.DumpReadable() return 'fail' @@ -207,21 +204,17 @@ def test_ogr_fgdb_1(): feat.GetField('binary') != "00FF7F" or \ feat.GetField('binary2') != "123456" or \ feat.GetField('smallint2') != -32768: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' sql_lyr = ds.ExecuteSQL("GetLayerDefinition %s" % lyr.GetName()) if sql_lyr is None: - gdaltest.post_reason('failure') return 'fail' feat = sql_lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failure') return 'fail' feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('failure') return 'fail' lyr.ResetReading() lyr.TestCapability("foo") @@ -229,22 +222,18 @@ def test_ogr_fgdb_1(): sql_lyr = ds.ExecuteSQL("GetLayerMetadata %s" % lyr.GetName()) if sql_lyr is None: - gdaltest.post_reason('failure') return 'fail' feat = sql_lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failure') return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("GetLayerDefinition foo") if sql_lyr is not None: - gdaltest.post_reason('failure') return 'fail' sql_lyr = ds.ExecuteSQL("GetLayerMetadata foo") if sql_lyr is not None: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -263,26 +252,19 @@ def test_ogr_fgdb_DeleteField(): lyr = ds.GetLayerByIndex(0) if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint')).GetSubType() != ogr.OFSTInt16: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint2')).GetSubType() != ogr.OFSTInt16: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetSubType() != ogr.OFSTFloat32: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float2')).GetSubType() != ogr.OFSTFloat32: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint')).GetWidth() != 0: - gdaltest.post_reason('failure') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str')).GetWidth() != 0: - gdaltest.post_reason('failure') return 'fail' if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('str')) != 0: - gdaltest.post_reason('failure') return 'fail' # Needed since FileGDB v1.4, otherwise crash/error ... @@ -314,14 +296,11 @@ def test_ogr_fgdb_DeleteField(): ds = ogr.Open("tmp/test.gdb") lyr = ds.GetLayerByIndex(0) if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str2')).GetWidth() != 80: - gdaltest.post_reason('failure') return 'fail' if lyr.GetLayerDefn().GetFieldIndex('str') != -1: - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsString("str2") != "foo2_\xc3\xa9": - gdaltest.post_reason('failure') return 'fail' ds = None @@ -705,23 +684,18 @@ def test_ogr_fgdb_10(): ds = ogr.Open('tmp/test.gdb') lyr = ds.GetLayerByName("srs_exact_4326") if lyr.GetSpatialRef().ExportToWkt().find('4326') == -1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName("srs_approx_4326") if lyr.GetSpatialRef().ExportToWkt().find('4326') == -1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName("srs_exact_2193") if lyr.GetSpatialRef().ExportToWkt().find('2193') == -1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName("srs_approx_2193") if lyr.GetSpatialRef().ExportToWkt().find('2193') == -1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName("srs_approx_4230") if lyr.GetSpatialRef().ExportToWkt().find('4230') == -1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -810,7 +784,6 @@ def test_ogr_fgdb_12(): ds = ogr.Open('tmp/non_existing.gdb') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('tmp/dummy.gdb') @@ -824,7 +797,6 @@ def test_ogr_fgdb_12(): ds = ogr.Open('tmp/dummy.gdb') if ds is not None: - gdaltest.post_reason('fail') return 'fail' os.unlink('tmp/dummy.gdb') @@ -835,7 +807,6 @@ def test_ogr_fgdb_12(): ds = ogr.Open('tmp/dummy.gdb') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' shutil.rmtree('tmp/dummy.gdb') @@ -854,7 +825,6 @@ def test_ogr_fgdb_13(): ds = ogrtest.fgdb_drv.CreateDataSource('tmp/foo') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' f = open('tmp/dummy.gdb', 'wb') @@ -864,7 +834,6 @@ def test_ogr_fgdb_13(): ds = ogrtest.fgdb_drv.CreateDataSource('tmp/dummy.gdb') gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' os.unlink('tmp/dummy.gdb') @@ -880,14 +849,12 @@ def test_ogr_fgdb_13(): ds = ogrtest.fgdb_drv.CreateDataSource(name) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ogrtest.fgdb_drv.DeleteDataSource(name) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -903,11 +870,9 @@ def test_ogr_fgdb_14(): for _ in range(3): ds1 = ogr.Open("tmp/test.gdb") if ds1 is None: - gdaltest.post_reason('fail') return 'fail' ds2 = ogr.Open("tmp/test.gdb") if ds2 is None: - gdaltest.post_reason('fail') return 'fail' ds2 = None ds1 = None @@ -934,7 +899,6 @@ def test_ogr_fgdb_15(): sr.ImportFromEPSG(3005) expected_wkt = sr.ExportToWkt() if got_wkt != expected_wkt: - gdaltest.post_reason('fail') print(got_wkt) print(expected_wkt) return 'fail' @@ -997,7 +961,6 @@ def test_ogr_fgdb_17(): sr.ImportFromEPSG(4326) lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, srs=sr, options=['GEOMETRY_NULLABLE=NO']) if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' field_defn = ogr.FieldDefn('field_not_nullable', ogr.OFTString) field_defn.SetNullable(0) @@ -1010,7 +973,6 @@ def test_ogr_fgdb_17(): f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)')) ret = lyr.CreateFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -1021,7 +983,6 @@ def test_ogr_fgdb_17(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -1032,7 +993,6 @@ def test_ogr_fgdb_17(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -1041,13 +1001,10 @@ def test_ogr_fgdb_17(): ds = ogr.Open('tmp/test.gdb', update=1) lyr = ds.GetLayerByName('test') if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1114,18 +1071,14 @@ def ogr_fgdb_18_test_results(): ds = ogr.Open('tmp/test.gdb', update=1) lyr = ds.GetLayerByName('test') if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() != "'a''b'": - gdaltest.post_reason('fail') return 'fail' if ogrtest.openfilegdb_drv is not None: if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_int')).GetDefault() != '123': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault() != '1.23': print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault()) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nodefault')).GetDefault() is not None: - gdaltest.post_reason('fail') return 'fail' # if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime')).GetDefault() != 'CURRENT_TIMESTAMP': # gdaltest.post_reason('fail') @@ -1139,7 +1092,6 @@ def ogr_fgdb_18_test_results(): f.GetField('field_real') != 1.23 or \ not f.IsFieldNull('field_nodefault') or not f.IsFieldSet('field_datetime') or \ f.GetField('field_datetime2') != '2015/06/30 12:34:56': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -1200,14 +1152,12 @@ def test_ogr_fgdb_19(): ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None (bPerLayerCopyingForTransaction, ds) = ogr_fgdb_19_open_update('tmp/test.gdb') if ds.TestCapability(ogr.ODsCEmulatedTransactions) != 1: - gdaltest.post_reason('fail') return 'fail' # Error case: try in non-forced mode @@ -1215,7 +1165,6 @@ def test_ogr_fgdb_19(): ret = ds.StartTransaction(force=False) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Error case: try StartTransaction() with a ExecuteSQL layer still active @@ -1224,7 +1173,6 @@ def test_ogr_fgdb_19(): ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -1233,7 +1181,6 @@ def test_ogr_fgdb_19(): ret = ds.CommitTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Error case: call RollbackTransaction() while there is no transaction @@ -1241,7 +1188,6 @@ def test_ogr_fgdb_19(): ret = ds.RollbackTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Error case: try StartTransaction() with another active connection @@ -1250,7 +1196,6 @@ def test_ogr_fgdb_19(): ret = ds2.StartTransaction(force=True) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds2 = None @@ -1263,50 +1208,42 @@ def test_ogr_fgdb_19(): layer_created_before_transaction_defn = layer_created_before_transaction.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' try: os.stat('tmp/test.gdb.ogredited') except OSError: - gdaltest.post_reason('fail') return 'fail' try: os.stat('tmp/test.gdb.ogrtmp') - gdaltest.post_reason('fail') return 'fail' except OSError: pass ret = lyr.CreateField(ogr.FieldDefn('foobar', ogr.OFTString)) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ret = lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foobar')) if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = lyr.CreateGeomField(ogr.GeomFieldDefn('foobar', ogr.wkbPoint)) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = lyr.ReorderFields([i for i in range(lyr.GetLayerDefn().GetFieldCount())]) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('foo', ogr.OFTString), 0) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr_defn) @@ -1315,18 +1252,15 @@ def test_ogr_fgdb_19(): lyr.SetFeature(f) fid = f.GetFID() if fid <= 0: - gdaltest.post_reason('fail') print(fid) return 'fail' lyr.ResetReading() for i in range(fid): f = lyr.GetNextFeature() if f.GetFID() != fid or f.GetField('field_string') != 'foo': - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(fid) if f.GetFID() != fid or f.GetField('field_string') != 'foo': - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(layer_created_before_transaction_defn) @@ -1337,7 +1271,6 @@ def test_ogr_fgdb_19(): ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # Error case: try CommitTransaction() with a ExecuteSQL layer still active @@ -1346,7 +1279,6 @@ def test_ogr_fgdb_19(): ret = ds.CommitTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -1356,25 +1288,21 @@ def test_ogr_fgdb_19(): ret = ds.RollbackTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) # Test that CommitTransaction() works if ds.CommitTransaction() != 0: - gdaltest.post_reason('fail') return 'fail' try: os.stat('tmp/test.gdb.ogredited') - gdaltest.post_reason('fail') return 'fail' except OSError: pass try: os.stat('tmp/test.gdb.ogrtmp') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -1382,7 +1310,6 @@ def test_ogr_fgdb_19(): lst = gdal.ReadDir('tmp/test.gdb') for filename in lst: if filename.find('.tmp') >= 0: - gdaltest.post_reason('fail') print(lst) return 'fail' @@ -1390,12 +1317,10 @@ def test_ogr_fgdb_19(): lyr_tmp = ds.GetLayer(0) new_count = lyr_tmp.GetFeatureCount() if new_count != old_count + 1: - gdaltest.post_reason('fail') return 'fail' old_count = new_count if layer_created_before_transaction.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' for i in range(ds.GetLayerCount()): @@ -1409,22 +1334,18 @@ def test_ogr_fgdb_19(): ds.CreateLayer('layer_tmp', geom_type=ogr.wkbNone) ret = ds.StartTransaction(force=True) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds.DeleteLayer(ds.GetLayerCount() - 1) if ds.CommitTransaction() != 0: - gdaltest.post_reason('fail') return 'fail' new_lyr_count = ds.GetLayerCount() if new_lyr_count != lyr_count: - gdaltest.post_reason('fail') return 'fail' # Test that RollbackTransaction() works ret = ds.StartTransaction(force=True) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr_defn) @@ -1434,36 +1355,30 @@ def test_ogr_fgdb_19(): layer_created_during_transaction.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) if ds.RollbackTransaction() != 0: - gdaltest.post_reason('fail') return 'fail' try: os.stat('tmp/test.gdb.ogredited') - gdaltest.post_reason('fail') return 'fail' except OSError: pass try: os.stat('tmp/test.gdb.ogrtmp') - gdaltest.post_reason('fail') return 'fail' except OSError: pass if lyr.GetFeatureCount() != old_count: - gdaltest.post_reason('fail') print(lyr.GetFeatureCount()) print(old_count) return 'fail' # Cannot retrieve the layer any more from fresh if ds.GetLayerByName('layer_created_during_transaction') is not None: - gdaltest.post_reason('fail') return 'fail' # Pointer is in ghost state if layer_created_during_transaction.GetLayerDefn().GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' # Simulate an error case where StartTransaction() cannot copy backup files @@ -1474,11 +1389,9 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != lyr_count: - gdaltest.post_reason('fail') print(lyr_count) print(ds.GetLayerCount()) return 'fail' @@ -1490,11 +1403,9 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' shutil.rmtree('tmp/test.gdb.ogredited') @@ -1568,7 +1479,6 @@ def test_ogr_fgdb_19(): layer_tmp.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' ds.DeleteLayer(ds.GetLayerCount() - 1) @@ -1579,7 +1489,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1589,7 +1498,6 @@ def test_ogr_fgdb_19(): lst = gdal.ReadDir('tmp/test.gdb') for filename in lst: if filename.find('.tmp') >= 0: - gdaltest.post_reason('fail') print(lst) return 'fail' @@ -1603,7 +1511,6 @@ def test_ogr_fgdb_19(): break if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) @@ -1617,7 +1524,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1627,7 +1533,6 @@ def test_ogr_fgdb_19(): lst = gdal.ReadDir('tmp/test.gdb') for filename in lst: if filename.find('.tmp') >= 0: - gdaltest.post_reason('fail') print(lst) return 'fail' @@ -1636,7 +1541,6 @@ def test_ogr_fgdb_19(): (bPerLayerCopyingForTransaction, ds) = ogr_fgdb_19_open_update('tmp/test.gdb') if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) @@ -1650,7 +1554,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1668,7 +1571,6 @@ def test_ogr_fgdb_19(): (bPerLayerCopyingForTransaction, ds) = ogr_fgdb_19_open_update('tmp/test.gdb') if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) @@ -1682,7 +1584,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret != 0: - gdaltest.post_reason('fail') print(case) return 'fail' @@ -1691,7 +1592,6 @@ def test_ogr_fgdb_19(): if case == 'CASE4': try: os.stat('tmp/test.gdb.ogredited') - gdaltest.post_reason('fail') print(case) return 'fail' except OSError: @@ -1712,7 +1612,6 @@ def test_ogr_fgdb_19(): lyr_defn = lyr.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE1') @@ -1721,7 +1620,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1732,7 +1630,6 @@ def test_ogr_fgdb_19(): lyr_defn = lyr.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE2') @@ -1741,7 +1638,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1753,7 +1649,6 @@ def test_ogr_fgdb_19(): lyr_defn = lyr.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE3') @@ -1762,7 +1657,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1774,7 +1668,6 @@ def test_ogr_fgdb_19(): lyr_defn = lyr.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE_REOPEN') @@ -1783,11 +1676,9 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1798,7 +1689,6 @@ def test_ogr_fgdb_19(): lyr_defn = lyr.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE1') @@ -1807,7 +1697,6 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1819,7 +1708,6 @@ def test_ogr_fgdb_19(): lyr_defn = lyr.GetLayerDefn() if ds.StartTransaction(force=True) != 0: - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE2') @@ -1828,11 +1716,9 @@ def test_ogr_fgdb_19(): gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) if ret == 0: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1902,7 +1788,6 @@ def test_ogr_fgdb_20(): f.SetField('id', 1) ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 1 or lyr.GetMetadataItem('1', 'MAP_OGR_FID_TO_FGDB_FID') is not None: - gdaltest.post_reason('fail') return 'fail' # Existing FID @@ -1910,7 +1795,6 @@ def test_ogr_fgdb_20(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' for invalid_fid in [-2, 0, 9876543210]: @@ -1920,7 +1804,6 @@ def test_ogr_fgdb_20(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') print(invalid_fid) return 'fail' @@ -1929,7 +1812,6 @@ def test_ogr_fgdb_20(): f.SetField('id', 2) ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 2 or lyr.GetMetadataItem('2', 'MAP_OGR_FID_TO_FGDB_FID') is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1944,13 +1826,11 @@ def test_ogr_fgdb_20(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds2 = None ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 4 or lyr.GetMetadataItem('4', 'MAP_OGR_FID_TO_FGDB_FID') != '3': - gdaltest.post_reason('fail') f.DumpReadable() print(lyr.GetMetadataItem('4', 'MAP_OGR_FID_TO_FGDB_FID')) return 'fail' @@ -1960,7 +1840,6 @@ def test_ogr_fgdb_20(): ds2 = ogr.Open('tmp/test.gdb', update=1) gdal.PopErrorHandler() if ds2 is not None: - gdaltest.post_reason('fail') return 'fail' ds2 = None @@ -1969,22 +1848,18 @@ def test_ogr_fgdb_20(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' # This FID exists as a FGDB ID, but should not be user visible. f.SetFID(3) ret = lyr.SetFeature(f) if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' ret = lyr.DeleteFeature(3) if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' ret = lyr.GetFeature(3) if ret is not None: - gdaltest.post_reason('fail') return 'fail' # Trying to set OGR FID = 3 --> FileGDB FID = 4 @@ -1994,7 +1869,6 @@ def test_ogr_fgdb_20(): ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 3 or lyr.GetMetadataItem('3', 'MAP_OGR_FID_TO_FGDB_FID') != '4': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2007,20 +1881,16 @@ def test_ogr_fgdb_20(): else: f = lyr.GetFeature(fid) if f is None: - gdaltest.post_reason('fail') return 'fail' if f.GetFID() != fid or f.GetField('id') != fid: - gdaltest.post_reason('fail') f.DumpReadable() print(fid) return 'fail' got_fgdb_fid = lyr.GetMetadataItem(str(f.GetFID()), 'MAP_OGR_FID_TO_FGDB_FID') if got_fgdb_fid is None: if fgdb_fid is not None: - gdaltest.post_reason('fail') return 'fail' elif int(got_fgdb_fid) != fgdb_fid: - gdaltest.post_reason('fail') print(got_fgdb_fid) print(fgdb_fid) return 'fail' @@ -2028,7 +1898,6 @@ def test_ogr_fgdb_20(): for fid in [-9876543210, 0, 100]: f = lyr.GetFeature(fid) if f is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2037,33 +1906,27 @@ def test_ogr_fgdb_20(): f.SetFID(invalid_fid) ret = lyr.SetFeature(f) if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' ret = lyr.DeleteFeature(invalid_fid) if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(3) f.SetField('str', '3') ret = lyr.SetFeature(f) if ret != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(3) if f.GetField('str') != '3': - gdaltest.post_reason('fail') return 'fail' ret = lyr.DeleteFeature(1) if ret != 0: - gdaltest.post_reason('fail') return 'fail' ret = lyr.DeleteFeature(3) if ret != 0: - gdaltest.post_reason('fail') return 'fail' for (fid, fgdb_fid) in [(3, 5), (2049, 6), (10, 7), (7, 8), (9, None), (8, 10), (12, 11)]: @@ -2072,7 +1935,6 @@ def test_ogr_fgdb_20(): f.SetField('id', fid) ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != fid or str(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) != str(fgdb_fid): - gdaltest.post_reason('fail') f.DumpReadable() print(fid) print(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) @@ -2082,7 +1944,6 @@ def test_ogr_fgdb_20(): f = ogr.Feature(lyr.GetLayerDefn()) ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != 13: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f.SetField('id', f.GetFID()) @@ -2093,10 +1954,8 @@ def test_ogr_fgdb_20(): for (fid, fgdb_fid) in expected: f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' if f.GetFID() != fid or f.GetField('id') != fid or str(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) != str(fgdb_fid): - gdaltest.post_reason('fail') f.DumpReadable() print(fid) print(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) @@ -2106,7 +1965,6 @@ def test_ogr_fgdb_20(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 3: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2115,7 +1973,6 @@ def test_ogr_fgdb_20(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 3: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2132,7 +1989,6 @@ def test_ogr_fgdb_20(): sql_lyr = ds.ExecuteSQL('SELECT * FROM ogr_fgdb_20_simple') f = sql_lyr.GetNextFeature() if f.GetFID() != 2: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2144,7 +2000,6 @@ def test_ogr_fgdb_20(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2184,7 +2039,6 @@ def test_ogr_fgdb_20(): ds = ogr.Open('tmp/test.gdb', update=update) lyr = ds.GetLayerByName('ogr_fgdb_20') if lyr.GetFeatureCount() != 10: - gdaltest.post_reason('fail') print(lyr.GetFeatureCount()) return 'fail' lyr.ResetReading() @@ -2192,14 +2046,11 @@ def test_ogr_fgdb_20(): for fid in expected: f = lyr.GetNextFeature() if gdal.GetLastErrorType() != 0: - gdaltest.post_reason('fail') return 'fail' if f is None: - gdaltest.post_reason('fail') print(fid) return 'fail' if f.GetFID() != fid or f.GetField('id') != fid: - gdaltest.post_reason('fail') f.DumpReadable() print(fid) return 'fail' @@ -2209,7 +2060,6 @@ def test_ogr_fgdb_20(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != fid or f.GetField('id') != fid: - gdaltest.post_reason('fail') f.DumpReadable() print(fid) return 'fail' @@ -2217,11 +2067,9 @@ def test_ogr_fgdb_20(): lyr = ds.GetLayerByName('ogr_fgdb_20_simple') f = lyr.GetNextFeature() if f.GetFID() != 2: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 3: - gdaltest.post_reason('fail') return 'fail' # Check attribute index @@ -2232,7 +2080,6 @@ def test_ogr_fgdb_20(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != fid: - gdaltest.post_reason('fail') print(f.GetFID()) print(fid) return 'fail' @@ -2246,7 +2093,6 @@ def test_ogr_fgdb_20(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != fid: - gdaltest.post_reason('fail') print(f.GetFID()) print(fid) return 'fail' @@ -2260,7 +2106,6 @@ def test_ogr_fgdb_20(): f.SetField('id', fid) ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != fid or str(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) != str(fgdb_fid): - gdaltest.post_reason('fail') f.DumpReadable() print(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) return 'fail' @@ -2277,7 +2122,6 @@ def test_ogr_fgdb_20(): f.SetField('id', fid) ret = lyr.CreateFeature(f) if ret != 0 or f.GetFID() != fid or lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID') != str(fgdb_fid): - gdaltest.post_reason('fail') f.DumpReadable() print(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) return 'fail' @@ -2289,7 +2133,6 @@ def test_ogr_fgdb_20(): ds = ogr.Open('tmp/test.gdb', update=update) lyr = ds.GetLayerByName('ogr_fgdb_20') if lyr.GetFeatureCount() != 16: - gdaltest.post_reason('fail') print(lyr.GetFeatureCount()) return 'fail' lyr.ResetReading() @@ -2297,14 +2140,11 @@ def test_ogr_fgdb_20(): for fid in expected: f = lyr.GetNextFeature() if gdal.GetLastErrorType() != 0: - gdaltest.post_reason('fail') return 'fail' if f is None: - gdaltest.post_reason('fail') print(fid) return 'fail' if f.GetFID() != fid or f.GetField('id') != fid: - gdaltest.post_reason('fail') f.DumpReadable() print(fid) return 'fail' @@ -2333,43 +2173,33 @@ def test_ogr_fgdb_20(): gdal.PopErrorHandler() if case == 'CASE3': if sql_lyr is None: - gdaltest.post_reason('fail') print(case) return 'fail' ds.ReleaseResultSet(sql_lyr) else: if sql_lyr is not None: - gdaltest.post_reason('fail') print(case) return 'fail' # Everything will fail, but hopefully without crashing lyr.ResetReading() if lyr.GetNextFeature() is not None: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeature(1) is not None: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteFeature(1) == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.CreateFeature(f) == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.SetFeature(f) == 0: - gdaltest.post_reason('fail') return 'fail' if case != 'CASE3': if ds.CreateLayer('bar', geom_type=ogr.wkbNone) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.DeleteLayer(0) == 0: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT * FROM foo') if case != 'CASE3' and sql_lyr is not None: - gdaltest.post_reason('fail') print(case) return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2446,7 +2276,6 @@ def test_ogr_fgdb_21(): expected_geom_type = ogr.wkbMultiPolygonZM if lyr.GetGeomType() != expected_geom_type: - gdaltest.post_reason('fail') print(data) print(lyr.GetGeomType()) return 'fail' @@ -2457,12 +2286,10 @@ def test_ogr_fgdb_21(): expected_wkt = data[2] if expected_wkt is None: if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') print(data) feat.DumpReadable() return 'fail' elif ogrtest.check_feature_geometry(feat, expected_wkt) != 0: - gdaltest.post_reason('fail') print(data) feat.DumpReadable() return 'fail' @@ -2485,7 +2312,6 @@ def test_ogr_fgdb_22(): for f in lyr: f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: - gdaltest.post_reason('fail') print(f.GetGeometryRef().ExportToWkt()) print(f_ref.GetGeometryRef().ExportToWkt()) return 'fail' @@ -2496,7 +2322,6 @@ def test_ogr_fgdb_22(): for f in lyr: f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: - gdaltest.post_reason('fail') print(f.GetGeometryRef().ExportToWkt()) print(f_ref.GetGeometryRef().ExportToWkt()) return 'fail' @@ -2508,7 +2333,6 @@ def test_ogr_fgdb_22(): for f in lyr: f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: - gdaltest.post_reason('fail') print(f.GetGeometryRef().ExportToWkt()) print(f_ref.GetGeometryRef().ExportToWkt()) return 'fail' @@ -2546,7 +2370,6 @@ def test_ogr_fgdb_24(): for f in lyr: f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: - gdaltest.post_reason('fail') print(f.GetGeometryRef().ExportToIsoWkt()) print(f_ref.GetGeometryRef().ExportToIsoWkt()) return 'fail' @@ -2558,7 +2381,6 @@ def test_ogr_fgdb_24(): for f in lyr: f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: - gdaltest.post_reason('fail') print(f.GetGeometryRef().ExportToIsoWkt()) print(f_ref.GetGeometryRef().ExportToIsoWkt()) return 'fail' @@ -2574,16 +2396,13 @@ def test_ogr_fgdb_25(): ds = ogr.Open('data/curves.gdb') sql_lyr = ds.ExecuteSQL('SELECT OBJECTID FROM polygon WHERE OBJECTID = 2') if sql_lyr is None: - gdaltest.post_reason('fail') return 'fail' f = sql_lyr.GetNextFeature() if f.GetFID() != 2: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = sql_lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2591,7 +2410,6 @@ def test_ogr_fgdb_25(): lyr.SetAttributeFilter('OBJECTID = 2') f = lyr.GetNextFeature() if f.GetFID() != 2: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' diff --git a/autotest/ogr/ogr_fgdb_stress_test.py b/autotest/ogr/ogr_fgdb_stress_test.py index 3e37ce4c5ced..8155297b91a9 100755 --- a/autotest/ogr/ogr_fgdb_stress_test.py +++ b/autotest/ogr/ogr_fgdb_stress_test.py @@ -126,7 +126,6 @@ def ogr_fgdb_stress_test_1(): fid = f.GetFID() # print("created %d" % fid) if ret[0] != ret[1]: - gdaltest.post_reason('fail') print(ret) return 'fail' if ret[0] == 0: @@ -148,7 +147,6 @@ def ogr_fgdb_stress_test_1(): ret.append(lyr.SetFeature(f)) # gdal.PopErrorHandler() if ret[0] != ret[1]: - gdaltest.post_reason('fail') print(ret) return 'fail' # Same for DeleteFeature() @@ -162,7 +160,6 @@ def ogr_fgdb_stress_test_1(): ret.append(lyr.DeleteFeature(fid)) # gdal.PopErrorHandler() if ret[0] != ret[1]: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -189,14 +186,12 @@ def ogr_fgdb_stress_test_2(): f_test = lyr_test.GetNextFeature() f_ref = lyr_ref.GetNextFeature() if (f_test is None and f_ref is not None) or (f_test is not None and f_ref is None): - gdaltest.post_reason('fail') return 'fail' if f_test is None: break if f_test.GetFID() != f_ref.GetFID() or \ f_test['str'] != f_ref['str'] or \ ogrtest.check_feature_geometry(f_test, f_ref.GetGeometryRef()) != 0: - gdaltest.post_reason('fail') f_test.DumpReadable() f_ref.DumpReadable() return 'fail' @@ -205,7 +200,6 @@ def ogr_fgdb_stress_test_2(): lyr_test.SetAttributeFilter("str = '%d'" % val) lyr_ref.SetAttributeFilter("str = '%d'" % val) if lyr_test.GetFeatureCount() != lyr_ref.GetFeatureCount(): - gdaltest.post_reason('fail') print(val) print(lyr_test.GetFeatureCount()) print(lyr_ref.GetFeatureCount()) diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index 52520a8c2c24..d3505a4f6f02 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -660,7 +660,6 @@ def test_ogr_geojson_15(): out_json = json.loads(out) expected_out_json = json.loads(expected_out) if out_json != expected_out_json: - gdaltest.post_reason('fail') print(out) return 'fail' @@ -668,7 +667,6 @@ def test_ogr_geojson_15(): expected_out = {'geometry': {'type': 'Point', 'coordinates': [1.0, 2.0]}, 'type': 'Feature', 'properties': {'foo': 'bar', "boolfield": True}, 'id': 0} if out != expected_out: - gdaltest.post_reason('fail') print(out) return 'fail' @@ -1127,15 +1125,12 @@ def test_ogr_geojson_25(): ds = ogr.Open('data/topojson1.topojson') lyr = ds.GetLayer(0) if lyr.GetName() != 'a_layer': - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') != 0: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayer(1) if lyr.GetName() != 'TopoJSON': - gdaltest.post_reason('failure') return 'fail' expected_results = [ (None, None, 'POINT EMPTY'), @@ -1175,7 +1170,6 @@ def test_ogr_geojson_25(): (None, None, 'MULTILINESTRING ((100 1000,110 1000,110 1100,100 1100,100 1000),(101 1010,101 1090,109 1090,109 1010,101 1010))'), ] if lyr.GetFeatureCount() != len(expected_results): - gdaltest.post_reason('failure') return 'fail' for i, exp_result in enumerate(expected_results): feat = lyr.GetNextFeature() @@ -1192,38 +1186,30 @@ def test_ogr_geojson_25(): ds = ogr.Open('data/topojson2.topojson') lyr = ds.GetLayer(0) if lyr.GetName() != 'a_layer': - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') != 0: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayer(1) if lyr.GetName() != 'TopoJSON': - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') != 0: - gdaltest.post_reason('failure') return 'fail' ds = None ds = ogr.Open('data/topojson3.topojson') lyr = ds.GetLayer(0) if lyr.GetName() != 'a_layer': - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,10 0,0 10,10 0,0 0)') != 0: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayer(1) if lyr.GetName() != 'TopoJSON': - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,10 0,0 10,10 0,0 0)') != 0: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -1252,34 +1238,27 @@ def test_ogr_geojson_26(): lyr = ds.GetLayerByName('OGRGeoJSON') if lyr.GetMetadataItem(ogr.OLMD_FID64) is None: - gdaltest.post_reason('fail') return 'fail' feature = lyr.GetNextFeature() if feature.GetFID() != 1: - gdaltest.post_reason('fail') feature.DumpReadable() return 'fail' if feature.GetField("intvalue") != 1: - gdaltest.post_reason('fail') feature.DumpReadable() return 'fail' if feature.GetField("int64") != 1234567890123: - gdaltest.post_reason('fail') feature.DumpReadable() return 'fail' feature = lyr.GetNextFeature() if feature.GetFID() != 1234567890123: - gdaltest.post_reason('fail') feature.DumpReadable() return 'fail' if feature.GetField("intvalue") != 1234567890123: - gdaltest.post_reason('fail') feature.DumpReadable() return 'fail' if feature.GetField("intlist") != [1, 1234567890123]: - gdaltest.post_reason('fail') feature.DumpReadable() return 'fail' @@ -1305,7 +1284,6 @@ def test_ogr_geojson_26(): gdal.Unlink('/vsimem/ogr_geojson_26.json') if data.find('{ "type": "Feature", "id": 1234567890123, "properties": { "int64": 1234567890123, "int64list": [ 1234567890123 ] }, "geometry": null }') < 0: - gdaltest.post_reason('failure') print(data) return 'fail' @@ -1732,12 +1710,10 @@ def test_ogr_geojson_35(): gdal.Unlink('/vsimem/ogr_geojson_35.json') if data.find('-1.79') == -1 and data.find('e+308') == -1: - gdaltest.post_reason('fail') print(data) return 'fail' for ident in range(2, 8): if data.find('{ "type": "Feature", "id": %d, "properties": { }, "geometry": null }' % ident) == -1: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -1778,21 +1754,16 @@ def test_ogr_geojson_37(): feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool')).GetType() != ogr.OFTInteger or \ feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool')).GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('not_bool')).GetSubType() != ogr.OFSTNone: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool_list')).GetType() != ogr.OFTIntegerList or \ feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool_list')).GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('notbool_list')).GetSubType() != ogr.OFSTNone: - gdaltest.post_reason('failure') return 'fail' f = lyr.GetNextFeature() if f.GetField('bool') != 0 or f.GetField('bool_list') != [0, 1]: - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' @@ -1812,7 +1783,6 @@ def test_ogr_geojson_37(): gdal.Unlink('/vsimem/ogr_geojson_37.json') if data.find('"bool": false, "not_bool": 0, "bool_list": [ false, true ], "notbool_list": [ 0, 3 ]') < 0: - gdaltest.post_reason('failure') print(data) return 'fail' @@ -1835,33 +1805,25 @@ def test_ogr_geojson_38(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('dt')).GetType() != ogr.OFTDateTime: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('dt2')).GetType() != ogr.OFTDateTime: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('date')).GetType() != ogr.OFTDate: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('time')).GetType() != ogr.OFTTime: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('no_dt')).GetType() != ogr.OFTString: - gdaltest.post_reason('failure') return 'fail' if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('no_dt2')).GetType() != ogr.OFTString: - gdaltest.post_reason('failure') return 'fail' f = lyr.GetNextFeature() if f.GetField('dt') != '2014/11/20 12:34:56+01' or f.GetField('dt2') != '2014/11/20 00:00:00' or \ f.GetField('date') != '2014/11/20' or f.GetField('time') != '12:34:56': - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetField('dt') != '2014/11/20 00:00:00' or f.GetField('dt2') != '2014/11/20 12:34:56+00' or \ f.GetField('date') != '2014/11/20' or f.GetField('time') != '12:34:56': - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' @@ -1882,11 +1844,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != 'foo' or feat.GetField('bar') != 'baz': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -1897,11 +1857,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != 6: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -1913,11 +1871,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != 6: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -1928,11 +1884,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != 'baz': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -1943,11 +1897,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'ID' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetFID() != 1 or feat.GetField('ID') != 2: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -1966,17 +1918,14 @@ def test_ogr_geojson_39(): feat_defn = lyr.GetLayerDefn() feat = lyr.GetNextFeature() if feat.GetFID() != 1 or feat.GetField('foo') != 'bar': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetFID() != 2 or feat.GetField('foo') != 'baz': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetFID() != 3 or feat.GetField('foo') != 'baw': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -1987,11 +1936,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != -1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2003,11 +1950,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger64: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != -1234567890123: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2019,11 +1964,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger64: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != -2: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2035,11 +1978,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(1).GetName() != 'id' or feat_defn.GetFieldDefn(1).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != 1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2052,11 +1993,9 @@ def test_ogr_geojson_39(): lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('id') != '-2': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2110,7 +2049,6 @@ def test_ogr_geojson_40(): feat = lyr.GetNextFeature() if feat.GetField('a_property') != 'foo' or feat.GetField('some_object.a_property') != 1 or \ feat.GetField('some_object.another_property') != 2.34: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2128,27 +2066,23 @@ def test_ogr_geojson_41(): # Check that by default we return a WGS 84 SRS g = ogr.CreateGeometryFromJson("{ 'type': 'Point', 'coordinates' : [ 2, 49] }") if g.ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' srs = g.GetSpatialReference() g = None if srs.ExportToWkt().find('WGS 84') < 0: - gdaltest.post_reason('fail') return 'fail' # But if a crs object is set (allowed originally, but not recommended!), we use it g = ogr.CreateGeometryFromJson('{ "type": "Point", "coordinates" : [ 2, 49], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4322" } } }') srs = g.GetSpatialReference() if srs.ExportToWkt().find('4322') < 0: - gdaltest.post_reason('fail') return 'fail' # But if a crs object is set to null, set no crs g = ogr.CreateGeometryFromJson('{ "type": "Point", "coordinates" : [ 2, 49], "crs": null }') srs = g.GetSpatialReference() if srs: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2188,11 +2122,9 @@ def test_ogr_geojson_42(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f is None or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=1') @@ -2204,11 +2136,9 @@ def test_ogr_geojson_42(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f is None or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=10') @@ -2220,16 +2150,13 @@ def test_ogr_geojson_42(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f is None or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f is None or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' resultOffset1 = """ @@ -2250,32 +2177,27 @@ def test_ogr_geojson_42(): gdal.FileFromMemBuffer('/vsimem/geojson/test.json?resultRecordCount=1&resultOffset=1', resultOffset1) f = lyr.GetNextFeature() if f is None or f.GetFID() != 2: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() if fc != 2: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/geojson/test.json?resultRecordCount=1&returnCountOnly=true', """{ "count": 123456}""") fc = lyr.GetFeatureCount() if fc != 123456: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() extent = lyr.GetExtent() gdal.PopErrorHandler() if extent != (2, 2, 49, 49): - gdaltest.post_reason('fail') print(extent) return 'fail' @@ -2283,20 +2205,16 @@ def test_ogr_geojson_42(): """{"type":"FeatureCollection","bbox":[1, 2, 3, 4],"features":[]}""") extent = lyr.GetExtent() if extent != (1.0, 3.0, 2.0, 4.0): - gdaltest.post_reason('fail') print(extent) return 'fail' if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastGetExtent) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability('foo') != 0: - gdaltest.post_reason('fail') return 'fail' # Test scrolling with ESRI json @@ -2357,11 +2275,9 @@ def test_ogr_geojson_42(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f is None or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is None or f.GetFID() != 20: - gdaltest.post_reason('fail') return 'fail' ds = None gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=1') @@ -2428,12 +2344,10 @@ def test_ogr_geojson_45(): lyr = ds.GetLayer(0) native_data = lyr.GetMetadataItem("NATIVE_DATA", "NATIVE_DATA") if native_data != '{ "foo": "bar", "bar": "baz" }': - gdaltest.post_reason('fail') print(native_data) return 'fail' native_media_type = lyr.GetMetadataItem("NATIVE_MEDIA_TYPE", "NATIVE_DATA") if native_media_type != 'application/vnd.geo+json': - gdaltest.post_reason('fail') print(native_media_type) return 'fail' f = lyr.GetNextFeature() @@ -2445,12 +2359,10 @@ def test_ogr_geojson_45(): else: expected = ['{"type":"Feature","foo":["bar","baz",1.0,true,false,[],{}],"properties":{"myprop":"myvalue"},"geometry":null}'] if native_data not in expected: - gdaltest.post_reason('fail') print(native_data) return 'fail' native_media_type = f.GetNativeMediaType() if native_media_type != 'application/vnd.geo+json': - gdaltest.post_reason('fail') print(native_media_type) return 'fail' ds = None @@ -2492,7 +2404,6 @@ def test_ogr_geojson_45(): data.find('"foo_multilinestring": "bar_multilinestring"') < 0 or data.find('6') < 0 or \ data.find('"foo_polygon": "bar_polygon"') < 0 or data.find('7') < 0 or \ data.find('"foo_multipolygon": "bar_multipolygon"') < 0 or data.find('8') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2520,7 +2431,6 @@ def test_ogr_geojson_45(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -2548,7 +2458,6 @@ def test_ogr_geojson_45(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -2577,7 +2486,6 @@ def test_ogr_geojson_46(): gdal.Unlink('/vsimem/ogr_geojson_46.json') if data.find('{ "myprop": { "a": "b" } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2595,7 +2503,6 @@ def test_ogr_geojson_47(): with gdaltest.error_handler(): ds = ogr.Open('{"type": "FeatureCollection", "features":[]}', update=1) if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/ogr_geojson_47.json', @@ -2621,7 +2528,6 @@ def test_ogr_geojson_47(): if data.find('"foo": "bar"') < 0 or data.find('"bar": "baz"') < 0 or \ data.find('crs') >= 0 or \ data.find('"myprop": "another_value"') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2632,7 +2538,6 @@ def test_ogr_geojson_47(): f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1 2)')) lyr.CreateFeature(f) if f.GetFID() != 1: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -2640,7 +2545,6 @@ def test_ogr_geojson_47(): lyr.CreateFeature(f) f = lyr.GetNextFeature() if f.GetFID() != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2658,7 +2562,6 @@ def test_ogr_geojson_47(): ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 4: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2675,7 +2578,6 @@ def test_ogr_geojson_47(): data.find('"myprop": "another_value"') < 0 or \ data.find('"myprop": "value_of_point_4_5"') < 0 or \ data.find('id') >= 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2691,7 +2593,6 @@ def test_ogr_geojson_47(): ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2705,7 +2606,6 @@ def test_ogr_geojson_47(): ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2719,7 +2619,6 @@ def test_ogr_geojson_47(): ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2731,7 +2630,6 @@ def test_ogr_geojson_47(): data = None if data.find('something') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2745,7 +2643,6 @@ def test_ogr_geojson_47(): ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2757,7 +2654,6 @@ def test_ogr_geojson_47(): data = None if data.find('bbox') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2800,7 +2696,6 @@ def test_ogr_geojson_48(): data.find('crs') >= 0 or \ data.find('FeatureCollection') >= 0 or \ data.find('"myprop": "another_value"') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2821,11 +2716,9 @@ def test_ogr_geojson_49(): ds = gdal.OpenEx('/vsimem/ogr_geojson_49.json', open_options=['ARRAY_AS_STRING=YES']) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f['foo'] != '[ "bar" ]': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2862,7 +2755,6 @@ def test_ogr_geojson_50(): gdal.Unlink('/vsimem/ogr_geojson_50.json') if data.find('1.23456789012456') < 0 and data.find('5268.813 ') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2884,7 +2776,6 @@ def test_ogr_geojson_50(): gdal.Unlink('/vsimem/ogr_geojson_50.json') if data.find('1.23456789012456') < 0 and data.find('-5') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2907,7 +2798,6 @@ def test_ogr_geojson_50(): gdal.Unlink('/vsimem/ogr_geojson_50.json') if data.find('0.00001234') < 0 or data.find('1.23456789012456') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -2962,37 +2852,30 @@ def test_ogr_geojson_51(): gdal.Unlink('/vsimem/ogr_geojson_51.json') if data.find('{ "id": 1 }, "geometry": null') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('{ "id": 2 }, "geometry": { "type": "LineString", "coordinates": [ ] } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('{ "id": 3 }, "geometry": { "type": "Polygon", "coordinates": [ ] } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('{ "id": 4 }, "geometry": { "type": "MultiPoint", "coordinates": [ ] } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('{ "id": 5 }, "geometry": { "type": "MultiLineString", "coordinates": [ ] } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('{ "id": 6 }, "geometry": { "type": "MultiPolygon", "coordinates": [ ] } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('{ "id": 7 }, "geometry": { "type": "GeometryCollection", "geometries": [ ] } }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -3060,7 +2943,6 @@ def test_ogr_geojson_53(): gdal.Unlink('/vsimem/ogr_geojson_53.json') if data.find('{ "type": "Point", "coordinates": [ 1.0, 2.0, 3.0 ] }') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -3087,33 +2969,25 @@ def test_ogr_geojson_54(): fld = lyr.GetLayerDefn().GetFieldDefn(0) if fld.GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' fld = lyr.GetLayerDefn().GetFieldDefn(1) if fld.GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' fld = lyr.GetLayerDefn().GetFieldDefn(2) if fld.GetType() != ogr.OFTReal: - gdaltest.post_reason('fail') return 'fail' fld = lyr.GetLayerDefn().GetFieldDefn(3) if fld.GetType() != ogr.OFTDateTime: - gdaltest.post_reason('fail') return 'fail' fld = lyr.GetLayerDefn().GetFieldDefn(4) if fld.GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' if fld.GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' if fld.GetWidth() != 1: - gdaltest.post_reason('fail') return 'fail' fld = lyr.GetLayerDefn().GetFieldDefn(5) if fld.GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3155,7 +3029,6 @@ def test_ogr_geojson_55(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3181,7 +3054,6 @@ def test_ogr_geojson_55(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3233,7 +3105,6 @@ def test_ogr_geojson_55(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3278,7 +3149,6 @@ def test_ogr_geojson_56(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3309,7 +3179,6 @@ def test_ogr_geojson_56(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3347,7 +3216,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3377,7 +3245,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3403,7 +3270,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3429,7 +3295,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3455,7 +3320,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3481,7 +3345,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3528,7 +3391,6 @@ def test_ogr_geojson_57(): """ if json.loads(got) != json.loads(expected) and json.loads(got) != json.loads(expected2): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3554,7 +3416,6 @@ def test_ogr_geojson_57(): } """ if json.loads(got) != json.loads(expected): - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3638,17 +3499,14 @@ def test_ogr_geojson_60(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['foo'] != 'bar': - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if not f.IsFieldNull('foo'): - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('foo'): - gdaltest.post_reason('failure') f.DumpReadable() return 'fail' @@ -3663,7 +3521,6 @@ def test_ogr_geojson_60(): if data.find('"properties": { "foo": "bar" }') < 0 or \ data.find('"properties": { "foo": null }') < 0 or \ data.find('"properties": { }') < 0: - gdaltest.post_reason('failure') print(data) return 'fail' @@ -3681,7 +3538,6 @@ def test_ogr_geojson_61(): with gdaltest.error_handler(): ds = gdal.OpenEx('/vsimem/ogr_geojson_61.json') if ds is not None: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink('/vsimem/ogr_geojson_61.json') @@ -3689,7 +3545,6 @@ def test_ogr_geojson_61(): with gdaltest.error_handler(): ds = gdal.OpenEx("""{ "type": "Point", "x" : { "coordinates" : null } } """) if ds is not None: - gdaltest.post_reason('failure') return 'fail' # Empty property name @@ -3699,7 +3554,6 @@ def test_ogr_geojson_61(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetField("") != 1: - gdaltest.post_reason('failure') return 'fail' ds = None gdal.Unlink('/vsimem/ogr_geojson_61.json') @@ -3729,7 +3583,6 @@ def test_ogr_geojson_62(): lyr = ds.GetLayer(0) srs = lyr.GetSpatialRef() if srs.ExportToWkt().find('32631') < 0: - gdaltest.post_reason('failure') return 'fail' # crs type=EPSG (not even documented in GJ2008 spec!) tests. Just for coverage completeness @@ -3751,7 +3604,6 @@ def test_ogr_geojson_62(): lyr = ds.GetLayer(0) srs = lyr.GetSpatialRef() if srs.ExportToWkt().find('32631') < 0: - gdaltest.post_reason('failure') return 'fail' # crs type=link tests @@ -3788,7 +3640,6 @@ def test_ogr_geojson_62(): lyr = ds.GetLayer(0) srs = lyr.GetSpatialRef() if srs.ExportToWkt().find('32631') < 0: - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -3894,14 +3745,11 @@ def test_ogr_geojson_67(): ds = ogr.Open('data/grenada.geojson') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetDriver().GetName() != 'GeoJSON': - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3913,14 +3761,11 @@ def test_ogr_geojson_68(): ds = ogr.Open('data/esrijsonstartingwithfeaturesgeometry.json') if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetDriver().GetName() != 'ESRIJSON': - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3932,21 +3777,18 @@ def test_ogr_geojson_id_field_and_id_type(): gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', options='-f GeoJSON -lco ID_TYPE=String -preserve_fid -limit 1 -fid 2') got = read_file('/vsimem/out.json') if got.find('"id": "2", "properties": { "AREA": 261752.781, "EAS_ID": 171, "PRFEDEA": "35043414" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', options='-f GeoJSON -lco ID_TYPE=Integer -preserve_fid -limit 1 -fid 2') got = read_file('/vsimem/out.json') if got.find('"id": 2, "properties": { "AREA": 261752.781, "EAS_ID": 171, "PRFEDEA": "35043414" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', format='GeoJSON', layerCreationOptions=['ID_FIELD=EAS_ID'], limit=1) got = read_file('/vsimem/out.json') if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3956,7 +3798,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3966,7 +3807,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3976,7 +3816,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3985,7 +3824,6 @@ def test_ogr_geojson_id_field_and_id_type(): gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', format='GeoJSON', layerCreationOptions=['ID_FIELD=EAS_ID', 'ID_TYPE=String'], limit=1) got = read_file('/vsimem/out.json') if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -3995,7 +3833,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -4005,7 +3842,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -4015,7 +3851,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -4025,7 +3860,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out.json') gdal.Unlink('/vsimem/out.json') if got.find('"id": "35043411", "properties": { "AREA": 215229.266, "EAS_ID": 168 }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -4033,7 +3867,6 @@ def test_ogr_geojson_id_field_and_id_type(): got = read_file('/vsimem/out.json') gdal.Unlink('/vsimem/out.json') if got.find('"id": 35043411, "properties": { "AREA": 215229.266, "EAS_ID": 168 }') < 0: - gdaltest.post_reason('fail') print(got) return 'fail' @@ -4047,14 +3880,12 @@ def test_ogr_geojson_geom_export_failure(): g = ogr.CreateGeometryFromWkt('POINT EMPTY') geojson = g.ExportToJson() if geojson is not None: - gdaltest.post_reason('fail') print(geojson) return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(TIN EMPTY)') geojson = json.loads(g.ExportToJson()) if geojson != {"type": "GeometryCollection", "geometries": None}: - gdaltest.post_reason('fail') print(geojson) return 'fail' @@ -4063,7 +3894,6 @@ def test_ogr_geojson_geom_export_failure(): with gdaltest.error_handler(): geojson = g.ExportToJson() if geojson is not None: - gdaltest.post_reason('fail') print(geojson) return 'fail' @@ -4083,7 +3913,6 @@ def test_ogr_geojson_geom_export_failure(): with gdaltest.error_handler(): geojson = g.ExportToJson() if geojson is not None: - gdaltest.post_reason('fail') print(geojson) return 'fail' @@ -4273,20 +4102,16 @@ def test_ogr_geojson_non_finite(): f = lyr.GetNextFeature() for i in range(3): if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTReal: - gdaltest.post_reason('fail') print(i) return 'fail' if f['inf_prop'] != float('inf'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f['minus_inf_prop'] != float('-inf'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if not math.isnan(f['nan_prop']): - gdaltest.post_reason('fail') print(str(f['nan_prop'])) f.DumpReadable() return 'fail' @@ -4299,7 +4124,6 @@ def test_ogr_geojson_non_finite(): ds = ogr.Open(tmpfilename) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4307,19 +4131,15 @@ def test_ogr_geojson_non_finite(): ds = ogr.Open(tmpfilename) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 3: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f['inf_prop'] != float('inf'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f['minus_inf_prop'] != float('-inf'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if not math.isnan(f['nan_prop']): - gdaltest.post_reason('fail') print(str(f['nan_prop'])) f.DumpReadable() return 'fail' diff --git a/autotest/ogr/ogr_geojsonseq.py b/autotest/ogr/ogr_geojsonseq.py index 6b391aadfa27..2b41c676eeb5 100755 --- a/autotest/ogr/ogr_geojsonseq.py +++ b/autotest/ogr/ogr_geojsonseq.py @@ -57,12 +57,10 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): lyr.CreateFeature(f) if ds.TestCapability(ogr.ODsCCreateLayer): - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): if ds.CreateLayer('foo') is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -72,11 +70,9 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): gdal.VSIFCloseL(f) if expect_rs: if first != '\x1e': - gdaltest.post_reason('fail') return 'fail' else: if first != '{': - gdaltest.post_reason('fail') return 'fail' ds = ogr.Open(filename) @@ -84,16 +80,13 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): f = lyr.GetNextFeature() if f['foo'] != 'bar"d' or \ f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 4)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if lyr.GetNextFeature() is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -146,7 +139,6 @@ def test_ogr_geojsonseq_seq_geometries(): return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -171,7 +163,6 @@ def test_ogr_geojsonseq_reprojection(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -188,16 +179,13 @@ def test_ogr_geojsonseq_read_rs_json_pretty(): f = lyr.GetNextFeature() if f['foo'] != 'bar' or \ f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 4)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if lyr.GetNextFeature() is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_geom.py b/autotest/ogr/ogr_geom.py index 3fd3664f48ab..3c53c137b30e 100755 --- a/autotest/ogr/ogr_geom.py +++ b/autotest/ogr/ogr_geom.py @@ -238,13 +238,11 @@ def test_ogr_geom_polyhedral_surface(): polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbPolygon).ExportToWkt() if polygon_wkt != wkt_original: - gdaltest.post_reason("fail") print(polygon_wkt) return 'fail' polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbMultiPolygon).ExportToWkt() if polygon_wkt != 'MULTIPOLYGON (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))': - gdaltest.post_reason("fail") print(polygon_wkt) return 'fail' @@ -286,7 +284,6 @@ def test_ogr_geom_polyhedral_surface(): g = ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)))') if g.Equals(g) == 0: - gdaltest.post_reason("fail") return 'fail' for wkt in ['MULTIPOLYGON (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)))', @@ -301,12 +298,10 @@ def test_ogr_geom_polyhedral_surface(): # Error if g.AddGeometry(ogr.CreateGeometryFromWkt('POINT (0 0)')) == 0: - gdaltest.post_reason("fail") return 'fail' # Error if g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('POINT (0 0)')) == 0: - gdaltest.post_reason("fail") return 'fail' # Test dimension promotion @@ -315,7 +310,6 @@ def test_ogr_geom_polyhedral_surface(): g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('POLYGON ((10 10,10 11,11 11,10 10))')) wkt = g.ExportToIsoWkt() if wkt != 'POLYHEDRALSURFACE ZM (((0 0 1 2,0 1 1 2,1 1 1 2,0 0 1 2)),((10 10 0 0,10 11 0 0,11 11 0 0,10 10 0 0)))': - gdaltest.post_reason("fail") print(wkt) return 'fail' @@ -425,7 +419,6 @@ def test_ogr_geom_tin(): with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt(invalid_wkt) if g is not None: - gdaltest.post_reason('fail') return 'fail' # hole @@ -433,23 +426,19 @@ def test_ogr_geom_tin(): with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt(invalid_wkt) if g is not None: - gdaltest.post_reason('fail') return 'fail' invalid_wkt = 'TIN (POLYGON((0 0,0 1,1 1,0 0)))' with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt(invalid_wkt) if g is not None: - gdaltest.post_reason('fail') return 'fail' # Add a POLYGON that can be cast as a TRIANGLE g = ogr.Geometry(ogr.wkbTIN) if g.AddGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,0 0))')) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToIsoWkt() != 'TIN (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -729,7 +718,6 @@ def test_ogr_geom_transform_to(): ret = geom.TransformTo(sr2) if ret != 0 or abs(geom.GetX() - 426857) > 1 or abs(geom.GetY() - 5427937) > 1: - gdaltest.post_reason('failure') print(geom.ExportToWkt()) return 'fail' @@ -739,7 +727,6 @@ def test_ogr_geom_transform_to(): with gdaltest.error_handler(): ret = geom.TransformTo(sr2) if ret == 0 or gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -820,7 +807,6 @@ def test_ogr_geom_segmentize(): g2.Segmentize(0.25) for i in range(g1.GetPointCount()): if g1.GetPoint(i) != g2.GetPoint(g1.GetPointCount() - 1 - i): - gdaltest.post_reason('fail') print(i) print('%.18g' % (g1.GetPoint(i)[0] - g2.GetPoint(g1.GetPointCount() - 1 - i)[0])) print('%.18g' % (g1.GetPoint(i)[1] - g2.GetPoint(g1.GetPointCount() - 1 - i)[1])) @@ -841,35 +827,30 @@ def test_ogr_geom_value(): p = geom.Value(-1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (2 3)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = geom.Value(geom.Length() / 4) expected_p = ogr.CreateGeometryFromWkt('POINT (3.5 3)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = geom.Value(geom.Length() / 2) expected_p = ogr.CreateGeometryFromWkt('POINT (5 3)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = geom.Value(3 * geom.Length() / 4) expected_p = ogr.CreateGeometryFromWkt('POINT (5 1.5)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = geom.Value(geom.Length() + 1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (5 0)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' @@ -885,23 +866,19 @@ def test_ogr_geom_flattenTo2D(): # Point is 0 dimension, LineString 1, ... if geom.GetDimension() != 0: - gdaltest.post_reason('fail') print(geom.GetDimension()) return 'fail' if geom.GetCoordinateDimension() != 3: - gdaltest.post_reason('fail') print(geom.GetCoordinateDimension()) return 'fail' geom.FlattenTo2D() if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('fail') print(geom.GetCoordinateDimension()) return 'fail' if geom.ExportToWkt() != 'POINT (1 2)': - gdaltest.post_reason('fail') print(geom.ExportToWkt()) return 'fail' @@ -917,23 +894,19 @@ def test_ogr_geom_flattenTo2D_triangle(): # Point is 0 dimension, LineString 1, ... if geom.GetDimension() != 2: - gdaltest.post_reason('fail') print(geom.GetDimension()) return 'fail' if geom.GetCoordinateDimension() != 3: - gdaltest.post_reason('fail') print(geom.GetCoordinateDimension()) return 'fail' geom.FlattenTo2D() if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('fail') print(geom.GetCoordinateDimension()) return 'fail' if geom.ExportToWkt() != 'TRIANGLE ((0 0,100 0,0 100,0 0))': - gdaltest.post_reason('fail') print(geom.ExportToWkt()) return 'fail' @@ -1316,14 +1289,12 @@ def test_ogr_geom_z_empty(): g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToIsoWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToIsoWkb()) out_wkt = g2.ExportToIsoWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -1350,29 +1321,23 @@ def test_ogr_geom_getlineargeometry(): g = ogr.CreateGeometryFromWkt(in_wkt) g2 = g.GetLinearGeometry() if geom_in != geom_out and not g.HasCurveGeometry(): - gdaltest.post_reason('fail') print(g) return 'fail' if g2.ExportToWkt() != geom_out + ' EMPTY': - gdaltest.post_reason('fail') print(g) print(g2) return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT (0 1))') if g.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if g.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(CIRCULARSTRING (0 0,0 1,0 0))') if not g.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1399,19 +1364,16 @@ def test_ogr_geom_getdimension(): ('TIN EMPTY', 2)]: g = ogr.CreateGeometryFromWkt(geom) if g.GetDimension() != dim: - gdaltest.post_reason('fail') print(g) print(dim) return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(LINESTRING EMPTY, POINT (0 1))') if g.GetDimension() != 1: - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT (0 1), LINESTRING EMPTY, POLYGON EMPTY)') if g.GetDimension() != 2: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1439,13 +1401,11 @@ def test_ogr_geom_triangle(): polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbPolygon).ExportToWkt() if polygon_wkt != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason("fail") print(polygon_wkt) return 'fail' polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbMultiPolygon).ExportToWkt() if polygon_wkt != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason("fail") print(polygon_wkt) return 'fail' @@ -1461,14 +1421,12 @@ def test_ogr_geom_triangle_invalid_wkt(): with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) if geom is not None: - gdaltest.post_reason('fail') return 'fail' geom_wkt = 'TRIANGLE ((0 0))' with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) if geom is not None: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -1476,7 +1434,6 @@ def test_ogr_geom_triangle_invalid_wkt(): with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) if geom is not None: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -1484,7 +1441,6 @@ def test_ogr_geom_triangle_invalid_wkt(): with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) if geom is not None: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -1492,7 +1448,6 @@ def test_ogr_geom_triangle_invalid_wkt(): with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) if geom is not None: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -1510,7 +1465,6 @@ def test_ogr_geom_triangle_sfcgal(): g1 = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,100 0 100,0 100 100,0 0))') g2 = ogr.CreateGeometryFromWkt('TRIANGLE ((-1 -1,100 0 100,0 100 100,-1 -1))') if not g2.Intersects(g1): - gdaltest.post_reason('fail') return 'fail' g1 = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,1 0,0 1,0 0))') @@ -1518,7 +1472,6 @@ def test_ogr_geom_triangle_sfcgal(): g3 = g1.Intersection(g2) g4 = ogr.CreateGeometryFromWkt('TRIANGLE ((0.5 0.5 0,0 0 0,1 0 0,0.5 0.5 0))') if not g4.Equals(g3): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1534,17 +1487,14 @@ def test_ogr_geom_circularstring(): # Test export/import Wkt g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCircularString: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' if ogrtest.have_geos(): if not g1.IsValid(): - gdaltest.post_reason('fail') return 'fail' # Test GetEnvelope() @@ -1552,7 +1502,6 @@ def test_ogr_geom_circularstring(): expected_env = (0.0, 2.0, -1.0, 1.0) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -1560,7 +1509,6 @@ def test_ogr_geom_circularstring(): length = g1.Length() expected_length = 1.5 * math.pi if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1568,55 +1516,47 @@ def test_ogr_geom_circularstring(): p = g1.Value(-1) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(0) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(length / 6.0) expected_p = ogr.CreateGeometryFromWkt('POINT (0.292893218813453 0.707106781186548)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) p = g1.Value(length / 3.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1 1)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(length / 2.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1.707106781186547 0.707106781186547)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(2 * length / 3.0) expected_p = ogr.CreateGeometryFromWkt('POINT (2 0)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(length) expected_p = ogr.CreateGeometryFromWkt('POINT (1 -1)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(length + 1) expected_p = ogr.CreateGeometryFromWkt('POINT (1 -1)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' @@ -1624,7 +1564,6 @@ def test_ogr_geom_circularstring(): g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -1632,23 +1571,19 @@ def test_ogr_geom_circularstring(): in_wkt = 'CIRCULARSTRING Z (0 0 10,1 1 20,2 0 30)' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCircularStringZ: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' wkb = g1.ExportToWkb() isowkb = g1.ExportToIsoWkb() if wkb != isowkb: - gdaltest.post_reason('fail') return 'fail' g2 = ogr.CreateGeometryFromWkb(wkb) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -1662,7 +1597,6 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1)') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -1677,22 +1611,18 @@ def test_ogr_geom_circularstring(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' # Test HasCurveGeometry if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1701,7 +1631,6 @@ def test_ogr_geom_circularstring(): g2 = ogr.ForceToLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1711,7 +1640,6 @@ def test_ogr_geom_circularstring(): g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1719,7 +1647,6 @@ def test_ogr_geom_circularstring(): if ogrtest.have_geos(): g2 = g1.Intersection(g1) if g2 is None: - gdaltest.post_reason('fail') return 'fail' # Test CIRCULARSTRING wrapped in a GEOMETRYCOLLECTION @@ -1730,7 +1657,6 @@ def test_ogr_geom_circularstring(): if ogrtest.have_geos(): g2 = g1.Intersection(g1) if g2 is None: - gdaltest.post_reason('fail') return 'fail' # Test ForceToLineString @@ -1738,7 +1664,6 @@ def test_ogr_geom_circularstring(): g2 = ogr.ForceToLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1747,7 +1672,6 @@ def test_ogr_geom_circularstring(): g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1761,14 +1685,12 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0)') g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' length = g1.Length() expected_length = 2 * math.pi * 0.5 if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1778,14 +1700,12 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.049515566048791 0.216941869558781,0.188255099070638 0.390915741234018,0.388739533021848 0.48746395609092,0.611260466978166 0.48746395609092,0.811744900929369 0.390915741234018,0.950484433951232 0.216941869558781,1 0,0.950484433951232 -0.216941869558781,0.811744900929369 -0.390915741234018,0.611260466978166 -0.48746395609092,0.388739533021848 -0.48746395609092,0.188255099070638 -0.390915741234018,0.049515566048791 -0.216941869558781,0 0)') g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' length = g1.Length() expected_length = 2 * math.pi * 0.5 if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1793,7 +1713,6 @@ def test_ogr_geom_circularstring(): g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.146446609406726 0.353553390593274,0.5 0.5,0.853553390593274 0.353553390593274,1 0,0.853553390593274 -0.353553390593274,0.5 -0.5,0.146446609406726 -0.353553390593274,0 0)') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -1801,7 +1720,6 @@ def test_ogr_geom_circularstring(): length = g1.Length() expected_length = 2 * math.pi * 0.5 if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1814,7 +1732,6 @@ def test_ogr_geom_circularstring(): g2.Segmentize(0.25) for i in range(g1.GetPointCount()): if g1.GetPoint(i) != g2.GetPoint(g1.GetPointCount() - 1 - i): - gdaltest.post_reason('fail') print(i) print('%.18g' % (g1.GetPoint(i)[0] - g2.GetPoint(g1.GetPointCount() - 1 - i)[0])) print('%.18g' % (g1.GetPoint(i)[1] - g2.GetPoint(g1.GetPointCount() - 1 - i)[1])) @@ -1828,7 +1745,6 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0 1,0.116977778440514 -0.321393804843282 1,0.413175911166547 -0.49240387650611 1,0.75 -0.433012701892224 1,0.969846310392967 -0.171010071662835 1,0.969846310392967 0.171010071662835 1,0.75 0.433012701892224 1,0.413175911166547 0.49240387650611 1,0.116977778440514 0.321393804843282 1,0 0 1)') g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1836,7 +1752,6 @@ def test_ogr_geom_circularstring(): g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING Z (0 0 1,0.146446609406726 -0.353553390593274 1.25,0.5 -0.5 1.5,0.853553390593274 -0.353553390593274 1.75,1 0 2,0.853553390593274 0.353553390593274 1.75,0.5 0.5 1.5,0.146446609406727 0.353553390593274 1.25,0 0 1)') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -1846,14 +1761,12 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.049515566048791 -0.216941869558781,0.188255099070638 -0.390915741234018,0.388739533021848 -0.48746395609092,0.611260466978166 -0.48746395609092,0.811744900929369 -0.390915741234018,0.950484433951232 -0.216941869558781,1 0,0.950484433951232 0.216941869558781,0.811744900929369 0.390915741234018,0.611260466978166 0.48746395609092,0.388739533021848 0.48746395609092,0.188255099070638 0.390915741234018,0.049515566048791 0.216941869558781,0 0)') g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' length = g1.Length() expected_length = 2 * math.pi * 0.5 if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1863,14 +1776,12 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,1 1,2 2)') g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' length = g1.Length() expected_length = 2 * math.sqrt(2) if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1878,13 +1789,11 @@ def test_ogr_geom_circularstring(): p = g1.Value(length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (0.5 0.5)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(3.0 * length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1.5 1.5)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' @@ -1892,7 +1801,6 @@ def test_ogr_geom_circularstring(): g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.166666666666667 0.166666666666667,0.333333333333333 0.333333333333333,0.5 0.5,0.666666666666667 0.666666666666667,0.833333333333333 0.833333333333333,1 1,1.166666666666667 1.166666666666667,1.333333333333333 1.333333333333333,1.5 1.5,1.666666666666667 1.666666666666667,1.833333333333333 1.833333333333333,2 2)') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -1900,7 +1808,6 @@ def test_ogr_geom_circularstring(): length = g1.Length() expected_length = 2 * math.sqrt(2) if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' @@ -1910,7 +1817,6 @@ def test_ogr_geom_circularstring(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0 1,1 1 2,2 2 1)') g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -1918,7 +1824,6 @@ def test_ogr_geom_circularstring(): g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING Z (0 0 1,0.166666666666667 0.166666666666667 1.166666666666667,0.333333333333333 0.333333333333333 1.333333333333333,0.5 0.5 1.5,0.666666666666667 0.666666666666667 1.666666666666667,0.833333333333333 0.833333333333333 1.833333333333333,1 1 2,1.166666666666667 1.166666666666667 1.833333333333333,1.333333333333333 1.333333333333333 1.666666666666667,1.5 1.5 1.5,1.666666666666667 1.666666666666667 1.333333333333333,1.833333333333333 1.833333333333333 1.166666666666667,2 2 1)') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -1926,13 +1831,11 @@ def test_ogr_geom_circularstring(): p = g1.Value(length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (0.5 0.5 1.5)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(3.0 * length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1.5 1.5 1.5)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' in_wkt = 'CIRCULARSTRING (0 0,1 1,1 -1)' @@ -1955,7 +1858,6 @@ def test_ogr_geom_circularstring(): expected_env = (cx + r * math.cos(a0), cx + r * math.cos(a2), cy + r * math.sin(a2), cy + r * math.sin(a0)) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -1972,7 +1874,6 @@ def test_ogr_geom_circularstring(): expected_env = (cx + r * math.cos(a0), cx + r, cy + r * math.sin(a2), cy + r * math.sin(a0)) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -1989,7 +1890,6 @@ def test_ogr_geom_circularstring(): expected_env = (cx - r, cx + r * math.cos(a2), cy - r, cy + r) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -2006,7 +1906,6 @@ def test_ogr_geom_circularstring(): expected_env = (cx - r, cx + r, cy - r, cy + r) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -2023,7 +1922,6 @@ def test_ogr_geom_circularstring(): expected_env = (cx - r, cx + r, cy - r, cy + r) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -2033,7 +1931,6 @@ def test_ogr_geom_circularstring(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # EMPTY @@ -2041,19 +1938,16 @@ def test_ogr_geom_circularstring(): g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(in_wkt) print(out_wkt) return 'fail' if g1.Length() != 0.0: - gdaltest.post_reason('fail') print(in_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(in_wkt) print(out_wkt) return 'fail' @@ -2069,70 +1963,57 @@ def test_ogr_geom_compoundcurve(): in_wkt = 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCompoundCurve: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' if g1.GetGeometryCount() != 1: - gdaltest.post_reason('fail') return 'fail' if g1.GetGeometryRef(0).ExportToWkt() != 'CIRCULARSTRING (0 0,1 1,1 -1)': - gdaltest.post_reason('fail') return 'fail' env = g1.GetEnvelope() expected_env = (0.0, 2.0, -1.0, 1.0) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' length = g1.Length() expected_length = 1.5 * math.pi if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' g1 = ogr.CreateGeometryFromWkt(in_wkt) if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # CreateGeometryFromWkt of LINESTRING in_wkt = 'COMPOUNDCURVE ((0 0,0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # With Z in_wkt = 'COMPOUNDCURVE Z (CIRCULARSTRING Z (0 0 10,1 1 20,2 0 30),(2 0 30,0 0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCompoundCurveZ: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2140,7 +2021,6 @@ def test_ogr_geom_compoundcurve(): expected_env = (0.0, 2.0, 0.0, 1.0) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -2148,7 +2028,6 @@ def test_ogr_geom_compoundcurve(): expected_env = (0.0, 2.0, 0.0, 1.0, 10, 30) for i in range(6): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' @@ -2156,47 +2035,40 @@ def test_ogr_geom_compoundcurve(): p = g1.Value(-1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0 10)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(math.pi / 2.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1 1 20)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(math.pi) expected_p = ogr.CreateGeometryFromWkt('POINT (2 0 30)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(math.pi + 1) expected_p = ogr.CreateGeometryFromWkt('POINT (1 0 20)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' p = g1.Value(math.pi + 2 + 1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0 10)') if ogrtest.check_feature_geometry(p, expected_p) != 0: - gdaltest.post_reason('fail') print(p) return 'fail' wkb = g1.ExportToWkb() isowkb = g1.ExportToIsoWkb() if wkb != isowkb: - gdaltest.post_reason('fail') return 'fail' g2 = ogr.CreateGeometryFromWkb(wkb) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2204,45 +2076,36 @@ def test_ogr_geom_compoundcurve(): in_wkt = 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCompoundCurve: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' if not g1.Equals(g1): - gdaltest.post_reason('fail') return 'fail' if not g1.Equals(g1.Clone()): - gdaltest.post_reason('fail') return 'fail' if g1.Equals(ogr.CreateGeometryFromWkt('POINT(0 0)')): - gdaltest.post_reason('fail') return 'fail' if g1.Equals(ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))')): - gdaltest.post_reason('fail') return 'fail' if g1.Equals(ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,0 1))')): - gdaltest.post_reason('fail') return 'fail' length = g1.Length() expected_length = 1.5 * math.pi + math.sqrt(2) if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2256,7 +2119,6 @@ def test_ogr_geom_compoundcurve(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1)') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -2272,27 +2134,22 @@ def test_ogr_geom_compoundcurve(): expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1)') if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2300,7 +2157,6 @@ def test_ogr_geom_compoundcurve(): g2 = ogr.ForceToLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2309,7 +2165,6 @@ def test_ogr_geom_compoundcurve(): g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2317,7 +2172,6 @@ def test_ogr_geom_compoundcurve(): g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,0.076120467488713 0.38268343236509,0.292893218813453 0.707106781186548,0.61731656763491 0.923879532511287,1 1,1.38268343236509 0.923879532511287,1.707106781186547 0.707106781186547,1.923879532511287 0.38268343236509,2 0,1.923879532511287 -0.38268343236509,1.707106781186547 -0.707106781186547,1.38268343236509 -0.923879532511287,1 -1))') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -2327,7 +2181,6 @@ def test_ogr_geom_compoundcurve(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Error case : invalid curve @@ -2336,7 +2189,6 @@ def test_ogr_geom_compoundcurve(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Error case : non contiguous curves @@ -2345,7 +2197,6 @@ def test_ogr_geom_compoundcurve(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Error case : non contiguous curves @@ -2354,7 +2205,6 @@ def test_ogr_geom_compoundcurve(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Error case : non contiguous curves @@ -2363,33 +2213,28 @@ def test_ogr_geom_compoundcurve(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' g = ogr.Geometry(ogr.wkbCompoundCurve) g.AddGeometry(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1))': - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') g.AddGeometry(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) gdal.PopErrorHandler() if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1),(1 1,0 0))': - gdaltest.post_reason('fail') return 'fail' g = ogr.Geometry(ogr.wkbCompoundCurve) g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1))': - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler('CPLQuietErrorHandler') g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) gdal.PopErrorHandler() if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1),(1 1,0 0))': - gdaltest.post_reason('fail') return 'fail' # Cannot add compoundcurve in compoundcurve @@ -2398,7 +2243,6 @@ def test_ogr_geom_compoundcurve(): g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('COMPOUNDCURVE((1 1,2 2))')) gdal.PopErrorHandler() if g.ExportToWkt() != 'COMPOUNDCURVE EMPTY': - gdaltest.post_reason('fail') return 'fail' # Check that discretization is not sensitive to winding order @@ -2412,7 +2256,6 @@ def test_ogr_geom_compoundcurve(): # The curves must be exactly the same, despite our stealth mode if g2.GetX(i) != g3.GetX(p_count - 1 - i) or \ g2.GetY(i) != g3.GetY(p_count - 1 - i): - gdaltest.post_reason('fail') print(g2) print(g3) print(i) @@ -2440,7 +2283,6 @@ def test_ogr_geom_compoundcurve(): g = ogr.CreateGeometryFromWkb(wkb) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') print(wkb) return 'fail' @@ -2449,19 +2291,16 @@ def test_ogr_geom_compoundcurve(): g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(in_wkt) print(out_wkt) return 'fail' if g1.Length() != 0.0: - gdaltest.post_reason('fail') print(in_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(in_wkt) print(out_wkt) return 'fail' @@ -2477,18 +2316,15 @@ def test_ogr_geom_curvepolygon(): in_wkt = 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCurvePolygon: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' if ogrtest.have_geos(): p1 = g1.PointOnSurface() if (p1.GetX() - 0.5) * (p1.GetX() - 0.5) + p1.GetY() * p1.GetY() > 0.5 * 0.5: - gdaltest.post_reason('fail') print(p1) return 'fail' @@ -2496,14 +2332,12 @@ def test_ogr_geom_curvepolygon(): expected_env = (0.0, 1.0, -0.5, 0.5) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' area = g1.Area() expected_area = math.pi * 0.5 * 0.5 if abs(area - expected_area) > 1e-8: - gdaltest.post_reason('fail') print(area) print(expected_area) return 'fail' @@ -2511,7 +2345,6 @@ def test_ogr_geom_curvepolygon(): g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2519,33 +2352,27 @@ def test_ogr_geom_curvepolygon(): in_wkt = 'CURVEPOLYGON ((0 0,0 10,10 10,10 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # With Z in_wkt = 'CURVEPOLYGON Z (CIRCULARSTRING Z (0 0 10,1 0 10,0 0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbCurvePolygonZ: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' wkb = g1.ExportToWkb() isowkb = g1.ExportToIsoWkb() if wkb != isowkb: - gdaltest.post_reason('fail') return 'fail' g2 = ogr.CreateGeometryFromWkb(wkb) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2559,7 +2386,6 @@ def test_ogr_geom_curvepolygon(): expected_g = ogr.CreateGeometryFromWkt('POLYGON ((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0))') if ogrtest.check_feature_geometry(g1, expected_g) != 0: - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -2574,22 +2400,18 @@ def test_ogr_geom_curvepolygon(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' # Test HasCurveGeometry if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2598,7 +2420,6 @@ def test_ogr_geom_curvepolygon(): g2 = ogr.ForceToPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2608,7 +2429,6 @@ def test_ogr_geom_curvepolygon(): g2 = ogr.ForceToMultiPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2618,7 +2438,6 @@ def test_ogr_geom_curvepolygon(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g3 = ogr.CreateGeometryFromWkt('MULTILINESTRING ((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0))') if ogrtest.check_feature_geometry(g2, expected_g3) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2626,7 +2445,6 @@ def test_ogr_geom_curvepolygon(): if ogrtest.have_geos(): g2 = g1.Intersection(g1) if g2 is None: - gdaltest.post_reason('fail') return 'fail' # Test CURVEPOLYGON and COMPOUNDCURVE, CIRCULARSTRING, LINESTRING @@ -2634,7 +2452,6 @@ def test_ogr_geom_curvepolygon(): g1 = ogr.CreateGeometryFromWkt(in_wkt) g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) if g2.ExportToWkt() != in_wkt: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2643,7 +2460,6 @@ def test_ogr_geom_curvepolygon(): g1 = ogr.CreateGeometryFromWkt(in_wkt) g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) if not g1.Equals(g2): - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2651,7 +2467,6 @@ def test_ogr_geom_curvepolygon(): if ogrtest.have_geos(): g2 = g1.Intersection(g1) if g2 is None: - gdaltest.post_reason('fail') return 'fail' # Test ForceToPolygon @@ -2659,7 +2474,6 @@ def test_ogr_geom_curvepolygon(): g2 = ogr.ForceToPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2668,7 +2482,6 @@ def test_ogr_geom_curvepolygon(): g2 = ogr.ForceToMultiPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2678,7 +2491,6 @@ def test_ogr_geom_curvepolygon(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Error case : wrong sub-geometry type @@ -2687,7 +2499,6 @@ def test_ogr_geom_curvepolygon(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Error case: non closed ring @@ -2696,46 +2507,37 @@ def test_ogr_geom_curvepolygon(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' # Area g = ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0))') if g.Area() != 0.5: - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('CURVEPOLYGON (COMPOUNDCURVE((0 0,1 1,1 0,0 0)))') if g.Area() != 0.5: - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('CURVEPOLYGON (COMPOUNDCURVE((0 0,1 1),(1 1,1 0,0 0)))') if g.Area() != 0.5: - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('CURVEPOLYGON ((100000000 100000000,100000001 100000001,100000001 100000000,100000000 100000000))') if g.Area() != 0.5: - gdaltest.post_reason('fail') return 'fail' # Equals g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0),CIRCULARSTRING(0.75 0.5,0.85 0.5,0.75 0.5))') if not g1.Equals(g1): - gdaltest.post_reason('fail') return 'fail' if not g1.Equals(g1.Clone()): - gdaltest.post_reason('fail') return 'fail' if g1.Equals(ogr.CreateGeometryFromWkt('POINT(0 0)')): - gdaltest.post_reason('fail') return 'fail' if g1.Equals(ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0))')): - gdaltest.post_reason('fail') return 'fail' # Intersects optimizations on a circle @@ -2750,32 +2552,27 @@ def test_ogr_geom_curvepolygon(): res = res & p1.Within(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) if not res: - gdaltest.post_reason('fail') return 'fail' # Test point slightly outside circle p2 = ogr.CreateGeometryFromWkt('POINT (%.16g %.16g)' % (1 + math.cos(math.pi / 6) + 1e-4, math.sin(math.pi / 6))) if p2.Within(g1): - gdaltest.post_reason('fail') return 'fail' # Full circle defined by 2 arcs g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0))') if not p1.Within(g1): - gdaltest.post_reason('fail') return 'fail' # Same but in reverse order g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 -1,2 0,1 1,0 0))') if not p1.Within(g1): - gdaltest.post_reason('fail') return 'fail' # This is not a circle p2 = ogr.CreateGeometryFromWkt('POINT (%.16g %.16g)' % (1 + math.cos(math.pi / 6) - 1e-2, math.sin(math.pi / 6))) g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,1 1,0 0))') if p2.Within(g1): - gdaltest.post_reason('fail') return 'fail' # Test area on circle in 2 pieces @@ -2783,7 +2580,6 @@ def test_ogr_geom_curvepolygon(): area = g1.Area() expected_area = math.pi if abs(area - expected_area) > 1e-10: - gdaltest.post_reason('fail') print(area) print(expected_area) return 'fail' @@ -2793,7 +2589,6 @@ def test_ogr_geom_curvepolygon(): area = g1.Area() expected_area = math.pi + 2 * 2 if abs(area - expected_area) > 1e-10: - gdaltest.post_reason('fail') print(area) print(expected_area) return 'fail' @@ -2803,7 +2598,6 @@ def test_ogr_geom_curvepolygon(): area = g1.Area() expected_area = math.pi + 2 * 2 if abs(area - expected_area) > 1e-10: - gdaltest.post_reason('fail') print(area) print(expected_area) return 'fail' @@ -2813,7 +2607,6 @@ def test_ogr_geom_curvepolygon(): area = g1.Area() expected_area = 2 * 2 if abs(area - expected_area) > 1e-10: - gdaltest.post_reason('fail') print(area) print(expected_area) return 'fail' @@ -2823,19 +2616,16 @@ def test_ogr_geom_curvepolygon(): g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(in_wkt) print(out_wkt) return 'fail' if g1.Area() != 0.0: - gdaltest.post_reason('fail') print(in_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(in_wkt) print(out_wkt) return 'fail' @@ -2844,14 +2634,12 @@ def test_ogr_geom_curvepolygon(): g = ogr.Geometry(ogr.wkbCurvePolygon) g.AddGeometry(ogr.Geometry(ogr.wkbCircularString)) if g.Area() != 0: - gdaltest.post_reason('fail') print(g.Area()) return 'fail' # Non-convex CircularString g = ogr.CreateGeometryFromWkt('CURVEPOLYGON( COMPOUNDCURVE( CIRCULARSTRING(0 0,0.5 -0.5,1 0,1.5 0.5,2 0), (2 0,2 1,0 1,0 0) ) )') if abs(g.Area() - 2.0) > 1e-10: - gdaltest.post_reason('fail') print(g.Area()) return 'fail' @@ -2867,11 +2655,9 @@ def test_ogr_geom_multicurve(): in_wkt = 'MULTICURVE (CIRCULARSTRING (0 0,1 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbMultiCurve: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2883,57 +2669,47 @@ def test_ogr_geom_multicurve(): expected_env = (0.0, 1.0, -0.5, 0.5) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' length = g1.Length() expected_length = 2 * math.pi * 0.5 if abs(length - expected_length) > 1e-8: - gdaltest.post_reason('fail') print(length) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # MULTICURVE of LINESTRING in_wkt = 'MULTICURVE ((0 0,1 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # Z in_wkt = 'MULTICURVE Z (CIRCULARSTRING Z (0 0 10,1 0 10,0 0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbMultiCurveZ: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2942,14 +2718,12 @@ def test_ogr_geom_multicurve(): g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -2959,14 +2733,12 @@ def test_ogr_geom_multicurve(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = 'MULTILINESTRING ((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0),(0 0,1 1),(0 0,1 1,2 2,3 3))' if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' @@ -2976,7 +2748,6 @@ def test_ogr_geom_multicurve(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2991,11 +2762,9 @@ def test_ogr_geom_multisurface(): in_wkt = 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbMultiSurface: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -3007,47 +2776,39 @@ def test_ogr_geom_multisurface(): expected_env = (0.0, 1.0, -0.5, 0.5) for i in range(4): if abs(env[i] - expected_env[i]) > 1e-8: - gdaltest.post_reason('fail') print(env) return 'fail' area = g1.Area() expected_area = math.pi * 0.5 * 0.5 if abs(area - expected_area) > 1e-8: - gdaltest.post_reason('fail') print(area) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if not g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # Z in_wkt = 'MULTISURFACE Z (CURVEPOLYGON Z (CIRCULARSTRING Z (0 0 10,1 0 10,0 0 10)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if g1.GetGeometryType() != ogr.wkbMultiSurfaceZ: - gdaltest.post_reason('fail') return 'fail' out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -3055,10 +2816,8 @@ def test_ogr_geom_multisurface(): in_wkt = 'MULTISURFACE (((0 0,0 10,10 10,10 0,0 0)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) if not g1.HasCurveGeometry(): - gdaltest.post_reason('fail') return 'fail' if g1.HasCurveGeometry(True): - gdaltest.post_reason('fail') return 'fail' # WKT with all possible sub geometries @@ -3066,14 +2825,12 @@ def test_ogr_geom_multisurface(): g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() if in_wkt != out_wkt: - gdaltest.post_reason('fail') print(out_wkt) return 'fail' @@ -3083,20 +2840,17 @@ def test_ogr_geom_multisurface(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = 'MULTIPOLYGON (((0 0,0 10,10 10,10 0,0 0)),((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0)))' if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) if ogrtest.check_feature_geometry(g2, expected_g) != 0: - gdaltest.post_reason('fail') print(g2) return 'fail' # Check that GetLinearGeometry() is idem-potent on MULTIPOLYGON g3 = g2.GetLinearGeometry(45) if not g3.Equals(g2): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3106,7 +2860,6 @@ def test_ogr_geom_multisurface(): g1 = ogr.CreateGeometryFromWkt(in_wkt) p1 = g1.PointOnSurface() if p1.ExportToWkt() != 'POINT (0.5 5.0)': - gdaltest.post_reason('fail') print(p1) return 'fail' @@ -3116,7 +2869,6 @@ def test_ogr_geom_multisurface(): g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() if g is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -3138,7 +2890,6 @@ def test_ogr_geom_getcurvegeometry(): g = ogr.CreateGeometryFromWkt(in_wkt) g2 = g.GetCurveGeometry() if g2.ExportToWkt() != in_wkt: - gdaltest.post_reason('fail') print(g) print(g2) return 'fail' @@ -3146,25 +2897,21 @@ def test_ogr_geom_getcurvegeometry(): g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT (0 1))') g2 = g.GetCurveGeometry() if not g.Equals(g2): - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(LINESTRING (0 0,0 1,0 0))') g2 = g.GetCurveGeometry() if not g.Equals(g2): - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('POLYGON((0 0,0 1,1 1,1 0,0 0))') g2 = g.GetCurveGeometry() if not g.Equals(g2): - gdaltest.post_reason('fail') return 'fail' g = ogr.CreateGeometryFromWkt('POLYGON Z ((0 0 10,0 1 10,1 1 10,1 0 10,0 0 10))') g2 = g.GetCurveGeometry() if not g.Equals(g2): - gdaltest.post_reason('fail') return 'fail' # CircularString with large step @@ -3174,7 +2921,6 @@ def test_ogr_geom_getcurvegeometry(): if g3.GetGeometryType() != ogr.wkbCircularString or \ g1.GetPoint(0) != g3.GetPoint(0) or g1.GetPoint(2) != g3.GetPoint(2) or \ abs((g3.GetX(1) - 1) * (g3.GetX(1) - 1) + g3.GetY(1) * g3.GetY(1) - 1) > 1e-8: - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3183,7 +2929,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry(15) g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3192,7 +2937,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if g3.ExportToWkt() != 'LINESTRING (1 2,3 4,5 6)': - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3214,7 +2958,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g1) print(g3) return 'fail' @@ -3280,7 +3023,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3294,7 +3036,6 @@ def test_ogr_geom_getcurvegeometry(): g1.GetPoint(2) != g3.GetPoint(4) or \ abs((g3.GetX(1) - 0.5) * (g3.GetX(1) - 0.5) + g3.GetY(1) * g3.GetY(1) - 0.5 * 0.5) > 1e-12 or \ abs((g3.GetX(3) - 0.5) * (g3.GetX(3) - 0.5) + g3.GetY(3) * g3.GetY(3) - 0.5 * 0.5) > 1e-12: - gdaltest.post_reason('fail') print(g3) # print(abs((g3.GetX(1) - 0.5)*(g3.GetX(1) - 0.5)+g3.GetY(1)*g3.GetY(1) - 0.5*0.5)) # print(abs((g3.GetX(3) - 0.5)*(g3.GetX(3) - 0.5)+g3.GetY(3)*g3.GetY(3) - 0.5*0.5)) @@ -3309,7 +3050,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g1) print(g3) return 'fail' @@ -3319,7 +3059,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3328,7 +3067,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3337,7 +3075,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3346,7 +3083,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3355,7 +3091,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.000997093138961 0.068920262501281,0.006738548124866 0.137608197923873,0.017197098230267 0.205737600590167,0.032323074784779 0.272984917348872,0.052044643056421 0.339030784160355,0.076268143401735 0.403561542787492,0.104878536064531 0.466270730389102,0.137739947510866 0.526860534941749,0.174696315705653 0.585043209577972,0.215572131266425 0.640542439124111,0.260173270974444 0.693094652347904,0.30828791968472 0.742450273683876,0.359687576256715 0.788374908491942,0.414128138728451 0.830650456220319,0.471351063580441 0.869076146186235,0.531084593583979 0.903469491055406,0.593045048402615 0.933667153492107,0.656938171817632 0.959525721864054,0.722460529179411 0.980922391318168,0.789300948448056 0.99775554699276,0.857141997979641 1.009945246596371,0.925661494039921 1.017433600061489,0.994534030886182 1.020185044470095,1.063432526150724 1.01818651294542,1.132029774186796 1.01144749670781,1.2 1.0,1.267547127648721 0.983752320094182,1.333803428245673 0.962854851656094,1.398449236893265 0.937408418110045,1.461172658788815 0.907535790143504,1.521671074014578 0.873381093378847,1.579652597579492 0.835109113014538,1.634837487668428 0.792904498790658,1.686959495304612 0.746970874114522,1.73576714891352 0.697529853644598,1.781024967590663 0.644819974072535,1.822514597219645 0.589095543261942,1.860035863959079 0.53062541329644,1.89340774001566 0.469691683356621,1.922469217043826 0.406588338684124,1.94708008295817 0.341619832199361,1.967121598410718 0.27509961561613,1.982497069669296 0.207348627140011,1.993132315133044 0.138693743046887,1.998976023234287 0.069466200612231,2 0)') g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3364,7 +3099,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,-0.000199980003999 0.02,0.002236456877416 0.089770423644023,0.009533897446083 0.159200932797352,0.021656789305088 0.227953268998521,0.038546070943884 0.295692477776518,0.060119459480029 0.362088540515299,0.086271851533127 0.426817982271309,0.116875835277923 0.489565447710894,0.151782311181914 0.550025237489786,0.190821218403283 0.607902797589577,0.233802363310224 0.662916154355295,0.280516346085201 0.7147972882427,0.330735580899807 0.763293439582565,0.384215404690045 0.80816834000038,0.440695269130182 0.849203363492117,0.499900009998002 0.886198591548151,0.561541187747236 0.918973787136141,0.62531849275604 0.947369272797732,0.690921208405283 0.971246708581086,0.758029724858684 0.990489766019218,0.826317096169807 1.005004694870594,0.895450633129846 1.014720779860886,0.965093524096011 1.019590685200679,1.034906475903993 1.019590685200679,1.104549366870158 1.014720779860886,1.173682903830197 1.005004694870593,1.2 1.0,1.241970275141317 0.990489766019217,1.309078791594718 0.971246708581085,1.374681507243961 0.947369272797731,1.438458812252765 0.91897378713614,1.500099990002 0.886198591548151,1.559304730869819 0.849203363492116,1.615784595309956 0.808168340000379,1.669264419100194 0.763293439582565,1.7194836539148 0.714797288242699,1.766197636689777 0.662916154355294,1.809178781596718 0.607902797589576,1.848217688818087 0.550025237489785,1.883124164722078 0.489565447710893,1.913728148466874 0.426817982271308,1.939880540519971 0.362088540515298,1.961453929056117 0.295692477776516,1.978343210694912 0.227953268998519,1.990466102553917 0.15920093279735,1.997763543122584 0.089770423644022,2.000199980003999 0.02,2 0)') g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3374,7 +3108,6 @@ def test_ogr_geom_getcurvegeometry(): g3 = g2.GetCurveGeometry() g1_expected = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.98 1.02,2 0)') if not g3.Equals(g1_expected): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3383,7 +3116,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3392,7 +3124,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3400,7 +3131,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3409,7 +3139,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry(options=['ADD_INTERMEDIATE_POINT=STEALTH']) g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3418,7 +3147,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry(options=['ADD_INTERMEDIATE_POINT=YES']) g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3427,7 +3155,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if ogrtest.check_feature_geometry(g3, g1) != 0: - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3436,7 +3163,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3446,7 +3172,6 @@ def test_ogr_geom_getcurvegeometry(): g3 = g2.GetCurveGeometry() g1_expected = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.0 1.020199980003999,2 0)') if ogrtest.check_feature_geometry(g3, g1_expected) != 0: - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3455,7 +3180,6 @@ def test_ogr_geom_getcurvegeometry(): g2_new = g1.GetLinearGeometry(options=['bla', 'ADD_INTERMEDIATE_POINT=FALSE', 'foo=bar']) gdal.PopErrorHandler() if not g2_new.Equals(g2): - gdaltest.post_reason('fail') print(g2_new) return 'fail' @@ -3464,7 +3188,6 @@ def test_ogr_geom_getcurvegeometry(): g2.AddPoint_2D(2 - 1e-9, 0) g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3476,7 +3199,6 @@ def test_ogr_geom_getcurvegeometry(): g2_new.AddPoint_2D(g2.GetX(i), g2.GetY(i)) g3 = g2_new.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3505,7 +3227,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if (eps == 0 and not g3.Equals(g1)) or (eps > 0 and ogrtest.check_feature_geometry(g3, g1, eps) != 0): - gdaltest.post_reason('fail') print('') print(g1) print(g3) @@ -3517,7 +3238,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3526,7 +3246,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3535,7 +3254,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() if not g3.Equals(g1): - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3544,7 +3262,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (1 0,3 1,1 0))') g3 = g1.Intersection(g2) if g3.GetGeometryType() != ogr.wkbCurvePolygon: - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3552,7 +3269,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = ogr.CreateGeometryFromWkt('CURVEPOLYGON((1 -1,1 1,3 1,3 -1,1 -1))') g3 = g1.Intersection(g2) if g3.GetGeometryType() != ogr.wkbCurvePolygon: - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3560,7 +3276,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (3 0,5 0,3 0))') g3 = g1.Union(g2) if g3.ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,2 0,0 0)),CURVEPOLYGON (CIRCULARSTRING (3 0,5 0,3 0)))': - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3568,7 +3283,6 @@ def test_ogr_geom_getcurvegeometry(): g2 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (2 0,1 -1,0 0))') g3 = g1.Union(g2) if g3.ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,1 -1,0 0))': - gdaltest.post_reason('fail') print(g3) return 'fail' @@ -3576,7 +3290,6 @@ def test_ogr_geom_getcurvegeometry(): g1 = g1.Buffer(0.5) g1 = g1.GetCurveGeometry() if g1.ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (1.5 2.0,0.5 2.0,1.5 2.0))': - gdaltest.post_reason('fail') print(g1) return 'fail' @@ -3599,7 +3312,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringZM, 1)] for (gt, res) in tuples: if ogr.GT_HasZ(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3614,7 +3326,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringZM, ogr.wkbCircularStringZM)] for (gt, res) in tuples: if ogr.GT_SetZ(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3629,7 +3340,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringZM, 1)] for (gt, res) in tuples: if ogr.GT_HasM(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3644,7 +3354,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringZM, ogr.wkbCircularStringZM)] for (gt, res) in tuples: if ogr.GT_SetM(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3669,7 +3378,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringZ, 0, 0, ogr.wkbCircularString)] for (gt, modZ, modM, res) in tuples: if ogr.GT_SetModifier(gt, modZ, modM) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3685,7 +3393,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringZM, ogr.wkbCircularString)] for (gt, res) in tuples: if ogr.GT_Flatten(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3707,7 +3414,6 @@ def test_ogr_geom_gt_functions(): ] for (gt, gt2, res) in tuples: if ogr.GT_IsSubClassOf(gt, gt2) != res: - gdaltest.post_reason('fail') print(gt) print(gt2) return 'fail' @@ -3730,7 +3436,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbTIN, 0)] for (gt, res) in tuples: if ogr.GT_IsCurve(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3750,7 +3455,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbTIN, 1)] for (gt, res) in tuples: if ogr.GT_IsSurface(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3766,7 +3470,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbPolygon, ogr.wkbMultiPolygon)] for (gt, res) in tuples: if ogr.GT_GetCollection(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3788,7 +3491,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbTriangle, 0)] for (gt, res) in tuples: if ogr.GT_IsNonLinear(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3811,7 +3513,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbMultiSurface, ogr.wkbMultiSurface)] for (gt, res) in tuples: if ogr.GT_GetCurve(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3834,7 +3535,6 @@ def test_ogr_geom_gt_functions(): (ogr.wkbMultiSurface, ogr.wkbMultiPolygon)] for (gt, res) in tuples: if ogr.GT_GetLinear(gt) != res: - gdaltest.post_reason('fail') print(gt) return 'fail' @@ -3899,63 +3599,46 @@ def test_ogr_geom_equals(): p_0 = ogr.CreateGeometryFromWkt('POINT (0 0)') p_1 = ogr.CreateGeometryFromWkt('POINT (1 1)') if not p_empty.Equals(p_empty): - gdaltest.post_reason('fail') return 'fail' if not p_0.Equals(p_0): - gdaltest.post_reason('fail') return 'fail' if not p_0.Equals(p_0.Clone()): - gdaltest.post_reason('fail') return 'fail' if p_empty.Equals(p_0): - gdaltest.post_reason('fail') return 'fail' if p_0.Equals(p_empty): - gdaltest.post_reason('fail') return 'fail' if p_0.Equals(p_1): - gdaltest.post_reason('fail') return 'fail' l_empty = ogr.Geometry(ogr.wkbLineString) l_0_1 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,1 1)') l_0_1_2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,1 1,2 2)') if not l_0_1.Equals(l_0_1): - gdaltest.post_reason('fail') return 'fail' if not l_0_1.Equals(l_0_1.Clone()): - gdaltest.post_reason('fail') return 'fail' if l_empty.Equals(l_0_1): - gdaltest.post_reason('fail') return 'fail' if l_0_1.Equals(l_empty): - gdaltest.post_reason('fail') return 'fail' if l_0_1.Equals(l_0_1_2): - gdaltest.post_reason('fail') return 'fail' gc_empty = ogr.Geometry(ogr.wkbGeometryCollection) gc_p_0 = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (0 0))') gc_p_1 = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 1))') if not gc_empty.Equals(gc_empty): - gdaltest.post_reason('fail') return 'fail' if not gc_p_0.Equals(gc_p_0): - gdaltest.post_reason('fail') return 'fail' if not gc_p_0.Equals(gc_p_0.Clone()): - gdaltest.post_reason('fail') return 'fail' if gc_empty.Equals(gc_p_0): - gdaltest.post_reason('fail') return 'fail' if gc_p_0.Equals(gc_empty): - gdaltest.post_reason('fail') return 'fail' if gc_p_0.Equals(gc_p_1): - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -4008,7 +3691,6 @@ def test_ogr_geom_measured_geometries_to_2D_or_3D(): geom = ogr.CreateGeometryFromWkt(before) geom.FlattenTo2D() if geom.ExportToIsoWkt() != after_2D: - gdaltest.post_reason('fail') print(before) print(after_2D) print(geom.ExportToIsoWkt()) @@ -4017,7 +3699,6 @@ def test_ogr_geom_measured_geometries_to_2D_or_3D(): geom = ogr.CreateGeometryFromWkt(before) geom.SetCoordinateDimension(2) if geom.ExportToIsoWkt() != after_2D: - gdaltest.post_reason('fail') print(before) print(after_2D) print(geom.ExportToIsoWkt()) @@ -4026,7 +3707,6 @@ def test_ogr_geom_measured_geometries_to_2D_or_3D(): geom = ogr.CreateGeometryFromWkt(before) geom.SetCoordinateDimension(3) if geom.ExportToIsoWkt() != after_3D: - gdaltest.post_reason('fail') print(before) print(after_3D) print(geom.ExportToIsoWkt()) @@ -4037,31 +3717,25 @@ def test_ogr_geom_measured_geometries_to_2D_or_3D(): geom.Set3D(geom.Is3D()) geom.SetMeasured(geom.IsMeasured()) if geom.ExportToIsoWkt() != before: - gdaltest.post_reason('fail') print(before) print(geom.ExportToIsoWkt()) return 'fail' if ogr.CreateGeometryFromWkt('POINT (1 2)').CoordinateDimension() != 2: - gdaltest.post_reason('fail') return 'fail' if ogr.CreateGeometryFromWkt('POINT M (1 2 3)').CoordinateDimension() != 3: - gdaltest.post_reason('fail') return 'fail' if ogr.CreateGeometryFromWkt('POINT Z (1 2 3)').CoordinateDimension() != 3: - gdaltest.post_reason('fail') return 'fail' if ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)').CoordinateDimension() != 4: - gdaltest.post_reason('fail') return 'fail' # Unrelated test. Test old-style unqualified non-bracketted ZM import g = ogr.CreateGeometryFromWkt('MULTIPOINT (1 2 3 4)') if g.ExportToIsoWkt() != 'MULTIPOINT ZM ((1 2 3 4))': - gdaltest.post_reason('fail') print(g.ExportToIsoWkt()) return 'fail' @@ -4079,7 +3753,6 @@ def test_ogr_geom_postgis_ewkt_xym(): for (before, after) in list_wkt: geom = ogr.CreateGeometryFromWkt(before) if geom.ExportToIsoWkt() != after: - gdaltest.post_reason('fail') print(before) print(after) print(geom.ExportToIsoWkt()) @@ -4104,7 +3777,6 @@ def test_ogr_geom_curve_surface(): for (wkb_type, name) in tests: if ogr.GeometryTypeToName(wkb_type) != name: - gdaltest.post_reason('fail') print(wkb_type) print(name) print(ogr.GeometryTypeToName(wkb_type)) @@ -4158,7 +3830,6 @@ def test_ogr_geom_import_corrupted_wkb(): if g: g2 = ogr.CreateGeometryFromWkb(g.ExportToIsoWkb()) if not g.Equals(g2): - gdaltest.post_reason('fail') print(wkt, i, method) return 'fail' wkb[i] = init_val @@ -4171,7 +3842,6 @@ def test_ogr_geom_import_corrupted_wkb(): else: g = ogr.CreateGeometryFromWkb(str(wkb[0:i])) if g is not None: - gdaltest.post_reason('fail') print(wkt, i) return 'fail' @@ -4204,55 +3874,46 @@ def test_ogr_geom_triangle_ps_tin_conversion(): if (g.GetGeometryType() == ogr.wkbTIN or g.GetGeometryType() == ogr.wkbPolyhedralSurface) and g2.GetGeometryType() == ogr.wkbCurvePolygon: wkt_expected = wkt if got_wkt != wkt_expected: - gdaltest.post_reason('fail') print(wkt, wkt_target, got_wkt, wkt_expected) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,1 0,0 0))'), ogr.wkbTriangle) if g.GetGeometryType() != ogr.wkbPolygon: - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE (((0 0,0 1,1 1,1 0,0 0)))'), ogr.wkbTIN) if g.GetGeometryType() != ogr.wkbPolyhedralSurface: - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POLYHEDRALSURFACE (((0 0,0 1,1 1,1 0,0 0))))'), ogr.wkbMultiPolygon) if g.ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)))': - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (TRIANGLE ((0 0,0 1,1 1,0 0)))'), ogr.wkbMultiPolygon) if g.ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('MULTIPOLYGON (((0 0,0 1,1 1,0 0)))'), ogr.wkbGeometryCollection) if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,0 1,1 1,0 0))'), ogr.wkbGeometryCollection) if g.ExportToWkt() != 'GEOMETRYCOLLECTION (TRIANGLE ((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('TIN (((0 0,0 1,1 1,0 0)))'), ogr.wkbGeometryCollection) if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE (((0 0,0 1,1 1,0 0)))'), ogr.wkbGeometryCollection) if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') print(g.ExportToWkt()) return 'fail' @@ -4266,14 +3927,12 @@ def test_ogr_geom_multipoint_envelope_bug(): g = ogr.CreateGeometryFromWkt('MULTIPOINT(0 0,1 1)') minx, maxx, miny, maxy = g.GetEnvelope() if (minx, maxx, miny, maxy) != (0, 1, 0, 1): - gdaltest.post_reason('fail') print(minx, maxx, miny, maxy) return 'fail' g = ogr.CreateGeometryFromWkt('MULTIPOINT(0 0 0,1 1 1)') minx, maxx, miny, maxy, minz, maxz = g.GetEnvelope3D() if (minx, maxx, miny, maxy, minz, maxz) != (0, 1, 0, 1, 0, 1): - gdaltest.post_reason('fail') print(minx, maxx, miny, maxy, minz, maxz) return 'fail' @@ -4304,10 +3963,8 @@ def test_ogr_geom_polygon_intersects_point(): point = ogr.Geometry(ogr.wkbPoint) point.AddPoint(10, 0) if poly.Intersects(point) != 1: - gdaltest.post_reason('fail') return 'fail' if poly.Contains(point) != 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -4387,108 +4044,84 @@ def test_ogr_geom_remove_geometry(): # With GEOMETRYCOLLECTION g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 2),LINESTRING (1 2,2 3),POINT (3 4))') if g.RemoveGeometry(3) == 0 or g.RemoveGeometry(-2) == 0: - gdaltest.post_reason('fail') return 'fail' if g.RemoveGeometry(1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (1 2),POINT (3 4))': - gdaltest.post_reason('fail') print(g) return 'fail' if g.RemoveGeometry(1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (1 2))': - gdaltest.post_reason('fail') print(g) return 'fail' if g.RemoveGeometry(0) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': - gdaltest.post_reason('fail') print(g) return 'fail' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 2),LINESTRING (1 2,2 3),POINT (3 4))') if g.RemoveGeometry(-1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': - gdaltest.post_reason('fail') print(g) return 'fail' # With POLYHEDRALSURFACE/TIN g = ogr.CreateGeometryFromWkt('TIN (((0 0,0 1,1 1,0 0)),((0 0,1 0,1 1,0 0)))') if g.RemoveGeometry(2) == 0 or g.RemoveGeometry(-2) == 0: - gdaltest.post_reason('fail') return 'fail' if g.RemoveGeometry(1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'TIN (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') print(g) return 'fail' if g.RemoveGeometry(0) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'TIN EMPTY': - gdaltest.post_reason('fail') print(g) return 'fail' g = ogr.CreateGeometryFromWkt('TIN (((0 0,0 1,1 1,0 0)),((0 0,1 0,1 1,0 0)))') if g.RemoveGeometry(-1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'TIN EMPTY': - gdaltest.post_reason('fail') print(g) return 'fail' # With POLYGON g = ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,1 9,9 9,1 1))') if g.RemoveGeometry(2) == 0 or g.RemoveGeometry(-2) == 0: - gdaltest.post_reason('fail') return 'fail' if g.RemoveGeometry(1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'POLYGON ((0 0,0 10,10 10,10 0,0 0))': - gdaltest.post_reason('fail') print(g) return 'fail' if g.RemoveGeometry(0) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'POLYGON EMPTY': - gdaltest.post_reason('fail') print(g) return 'fail' g = ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,1 9,9 9,1 1))') if g.RemoveGeometry(-1) != 0: - gdaltest.post_reason('fail') return 'fail' if g.ExportToWkt() != 'POLYGON EMPTY': - gdaltest.post_reason('fail') print(g) return 'fail' # Unsupported type g = ogr.CreateGeometryFromWkt('POINT (0 0)') if g.RemoveGeometry(0) == 0: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index ef7e15d48914..d21a10e89231 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -1860,7 +1860,6 @@ def test_gml_srsDimension_topgeometry(): geom = ogr.CreateGeometryFromGML(gml) if geom.ExportToWkt() != 'POLYGON ((0 0 10,0 1 10,1 1 10,1 0 10,0 0 10))': - gdaltest.post_reason('fail') print(geom.ExportToWkt()) return 'fail' @@ -1876,20 +1875,17 @@ def test_gml_Arc(): geom = ogr.CreateGeometryFromGML(gml) if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 0,0 1,-1 0)')) != 0: - gdaltest.post_reason('fail') print(geom) return 'fail' gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '1 0 0 1 -1 0' if gml2 != expected_gml2: - gdaltest.post_reason('fail') print(gml2) return 'fail' geom2 = ogr.CreateGeometryFromGML(gml2) if not geom.Equals(geom2): - gdaltest.post_reason('fail') print(geom2) return 'fail' @@ -1905,7 +1901,6 @@ def test_gml_ArcByBulge(): geom = ogr.CreateGeometryFromGML(gml) if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (2 0,0 2,-2 0)')) != 0: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -1921,7 +1916,6 @@ def test_gml_ArcByCenterPoint(): geom = ogr.CreateGeometryFromGML(gml) if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 4,-1 2,1 0)')) != 0: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -1984,7 +1978,6 @@ def test_gml_CompoundCurve_of_ArcByCenterPoint(): geom = ogr.CreateGeometryFromGML(gml) if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('POLYGON ((-80.4 33.86,-80.27 33.63,-80.305028054229538 33.622017309598967,-80.335422529369936 33.613343178471617,-80.366464292754429 33.606448070493634,-80.398003921948742 33.601365147653873,-80.429889693662162 33.598118851265042,-80.461968286017793 33.596724788982847,-80.494085487001527 33.597189662699385,-80.52608690656875 33.599511237590342,-80.557818688893789 33.603678352435914,-80.589128223167393 33.609670971175497,-80.619864849221443 33.617460275496377,-80.63 33.62,-80.39 33.85))')) != 0: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -2000,7 +1993,6 @@ def test_gml_CircleByCenterPoint(): geom = ogr.CreateGeometryFromGML(gml) if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (-1 2,3 2,-1 2)')) != 0: - gdaltest.post_reason('fail') print(geom) return 'fail' @@ -2027,13 +2019,11 @@ def test_gml_Circle(): gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 1 1 2 0' if gml2 != expected_gml2: - gdaltest.post_reason('fail') print(gml2) return 'fail' geom2 = ogr.CreateGeometryFromGML(gml2) if geom2.ExportToWkt() != 'CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0)': - gdaltest.post_reason('fail') print(geom2) return 'fail' @@ -2041,7 +2031,6 @@ def test_gml_Circle(): gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 10 1 1 10 2 0 10' if gml2 != expected_gml2: - gdaltest.post_reason('fail') print(gml2) return 'fail' @@ -2091,13 +2080,11 @@ def test_gml_ArcString(): gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '-2 0 -1 -1 0 0 1 -1 2 0 0 2 -2 0' if gml2 != expected_gml2: - gdaltest.post_reason('fail') print(gml2) return 'fail' geom2 = ogr.CreateGeometryFromGML(gml2) if geom2.ExportToWkt() != 'CIRCULARSTRING (-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0)': - gdaltest.post_reason('fail') print(geom2) return 'fail' @@ -2114,7 +2101,6 @@ def test_gml_OGRCompoundCurve(): gml = geom.ExportToGML(['FORMAT=GML3']) expected_gml = '0 0 1 1 2 0' if gml != expected_gml: - gdaltest.post_reason('fail') print(gml) return 'fail' @@ -2136,7 +2122,6 @@ def test_gml_OGRCompoundCurve(): gml2 = geom.ExportToGML(['FORMAT=GML3']) if gml2 != gml: - gdaltest.post_reason('fail') print(gml2) return 'fail' @@ -2205,7 +2190,6 @@ def test_gml_OGRCurvePolygon(): gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 0.5 0.5 1 0' if gml2 != expected_gml2: - gdaltest.post_reason('fail') print(gml2) return 'fail' @@ -2319,7 +2303,6 @@ def test_gml_OGRMultiSurface(): gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 0 1 1 1 1 0 0 0' if gml2 != expected_gml2: - gdaltest.post_reason('fail') print(gml2) return 'fail' @@ -2342,7 +2325,6 @@ def test_gml_OGRMultiCurve(): gml2 = geom.ExportToGML(['FORMAT=GML3']) if gml2 != gml: - gdaltest.post_reason('fail') print(gml2) return 'fail' diff --git a/autotest/ogr/ogr_gml_read.py b/autotest/ogr/ogr_gml_read.py index ebae82bd1e09..cc5833dbf31d 100755 --- a/autotest/ogr/ogr_gml_read.py +++ b/autotest/ogr/ogr_gml_read.py @@ -1123,7 +1123,6 @@ def test_ogr_gml_27(): lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbPolygon25D: - gdaltest.post_reason('fail') print(lyr.GetGeomType()) return 'fail' @@ -1150,7 +1149,6 @@ def test_ogr_gml_28(): ds = ogr.Open('tmp/ogr_gml_28.gml') lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbNone: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1159,7 +1157,6 @@ def test_ogr_gml_28(): ds = ogr.Open('tmp/ogr_gml_28.gml') lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbNone: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1167,7 +1164,6 @@ def test_ogr_gml_28(): ds = ogr.Open('tmp/ogr_gml_28.gml') lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbNone: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2015,11 +2011,9 @@ def test_ogr_gml_48(): lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbUnknown: - gdaltest.post_reason('failure') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2051,7 +2045,6 @@ def test_ogr_gml_49(): lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetGeometryRef().GetGeometryType() != ogr.wkbPolygon: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2060,7 +2053,6 @@ def test_ogr_gml_49(): lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetGeometryRef().GetGeometryType() != ogr.wkbPolygon: - gdaltest.post_reason('failure') return 'fail' ds = None @@ -2098,15 +2090,12 @@ def test_ogr_gml_50(): lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetFieldAsStringList(lyr.GetLayerDefn().GetFieldIndex('stringlist')) != ['a', 'b']: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if feat.GetFieldAsIntegerList(lyr.GetLayerDefn().GetFieldIndex('intlist')) != [2, 3]: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if feat.GetFieldAsDoubleList(lyr.GetLayerDefn().GetFieldIndex('reallist')) != [4.56, 5.67]: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' ds = None @@ -2137,25 +2126,20 @@ def test_ogr_gml_51(): content = f.read() f.close() if content.find("") == -1: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find("""215229.266""") == -1: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find("""479647""") != -1: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2188,15 +2172,12 @@ def test_ogr_gml_52(): lyr = ds.GetLayerByName('A') if lyr.GetGeomType() != ogr.wkbPoint25D: - gdaltest.post_reason('fail') return 'fail' srs = lyr.GetSpatialRef() if srs is None: - gdaltest.post_reason('fail') return 'fail' wkt = srs.ExportToWkt() if wkt.find('3067') < 0: - gdaltest.post_reason('fail') print(wkt) return 'fail' @@ -2207,31 +2188,25 @@ def test_ogr_gml_52(): feat.GetField('teksti') != 'En francais !' or \ feat.GetField('teksti_kieli') != 'fr' or \ ogrtest.check_feature_geometry(feat, 'POINT (280000 7000000 0)') != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('B') if lyr.GetGeomType() != ogr.wkbPolygon25D: - gdaltest.post_reason('fail') return 'fail' srs = lyr.GetSpatialRef() if srs is None: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'POLYGON ((280000 7000000 0,281000 7000000 0,281000 7001000 0,280000 7001000 0,280000 7000000 0))') != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('C') if lyr.GetGeomType() != ogr.wkbLineString25D: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (280000 7000000 0,281000 7000000 0,281000 7001000 0,280000 7001000 0,280000 7000000 0)') != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2252,7 +2227,6 @@ def test_ogr_gml_53(): ds = ogr.Open('data/archsites.xsd') if ds is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2271,14 +2245,12 @@ def test_ogr_gml_54(): ds = ogr.Open('data/empty.gml') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = None # with .gfs now ds = ogr.Open('data/empty.gml') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2327,49 +2299,37 @@ def test_ogr_gml_56(): gdal.SetConfigOption('GML_REGISTRY', None) lyr = ds.GetLayerByName('mainFeature') if lyr.GetSpatialRef() is None: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsString(feat.GetFieldIndex('subFeatureProperty_href')) != '#subFeature.0': - gdaltest.post_reason('fail') return 'fail' if feat.GetFieldAsStringList(feat.GetFieldIndex('subFeatureRepeatedProperty_href')) != ['#subFeatureRepeated.0', '#subFeatureRepeated.1']: - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(1).ExportToWkt() != 'POINT (10 10)': - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('subFeature') if lyr.GetLayerDefn().GetGeomFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsStringList(feat.GetFieldIndex('subFeatureRepeatedProperty_href')) != ['#subFeatureRepeated.2']: - gdaltest.post_reason('fail') return 'fail' if feat.GetField('foo') != 'bar': - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('subFeatureRepeated') feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'subFeatureRepeated.2': - gdaltest.post_reason('fail') return 'fail' if feat.GetField('bar') != 'baz': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'subFeatureRepeated.0': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'subFeatureRepeated.1': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2396,11 +2356,9 @@ def test_ogr_gml_57(): options = ['FORMAT=GML3.2'] ds = ogr.GetDriverByName('GML').CreateDataSource('/vsimem/ogr_gml_57.gml', options=options) if ds.TestCapability(ogr.ODsCCreateGeomFieldAfterCreateLayer) != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('myLayer', geom_type=ogr.wkbNone) if lyr.TestCapability(ogr.OLCCreateGeomField) != 1: - gdaltest.post_reason('fail') return 'fail' geomfielddefn = ogr.GeomFieldDefn('first_geometry', ogr.wkbPoint) if i == 1 or i == 2: @@ -2434,19 +2392,14 @@ def test_ogr_gml_57(): lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if i == 1 and feat.GetGeomFieldRef(0).GetSpatialReference().ExportToWkt().find('32630') < 0: - gdaltest.post_reason('fail') return 'fail' if i == 1 and feat.GetGeomFieldRef(1).GetSpatialReference().ExportToWkt().find('32630') < 0: - gdaltest.post_reason('fail') return 'fail' if i == 2 and feat.GetGeomFieldRef(1).GetSpatialReference().ExportToWkt().find('32631') < 0: - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'POINT (0 1)': - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(1).ExportToWkt() != 'LINESTRING (2 3,4 5)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2470,19 +2423,14 @@ def test_ogr_gml_58(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetGeomFieldCount() != 2: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetName() != 'geometry': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbMultiPolygon: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(1).GetName() != 'referencePoint': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(1).GetType() != ogr.wkbPoint: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2505,13 +2453,10 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(1).ExportToWkt() != 'POINT (2.5 49.5)': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2534,13 +2479,10 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(1) is not None: - gdaltest.post_reason('fail') return 'fail' feat = None lyr = None @@ -2550,7 +2492,6 @@ def test_ogr_gml_58(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetGeomFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2570,7 +2511,6 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2590,7 +2530,6 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' feat = None lyr = None @@ -2600,13 +2539,10 @@ def test_ogr_gml_58(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetGeomFieldCount() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetName() != 'geometry': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbLineString: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2625,10 +2561,8 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'LINESTRING (2 49,3 50)': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2647,10 +2581,8 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'LINESTRING (2 49,3 50)': - gdaltest.post_reason('fail') return 'fail' feat = None lyr = None @@ -2660,19 +2592,14 @@ def test_ogr_gml_58(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() if lyr_defn.GetGeomFieldCount() != 2: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetName() != 'geometry': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbMultiPolygon: - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(1).GetName() != 'referencePoint': - gdaltest.post_reason('fail') return 'fail' if lyr_defn.GetGeomFieldDefn(1).GetType() != ogr.wkbPoint: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2702,13 +2629,10 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(1).ExportToWkt() != 'POINT (2.5 49.5)': - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -2738,13 +2662,10 @@ def test_ogr_gml_58(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - gdaltest.post_reason('fail') return 'fail' if feat.GetGeomFieldRef(1) is not None: - gdaltest.post_reason('fail') return 'fail' feat = None lyr = None @@ -2788,7 +2709,6 @@ def test_ogr_gml_59(): print(key) print(val) print(feat.GetField(key)) - gdaltest.post_reason('fail') return 'fail' feat = None lyr = None @@ -2813,19 +2733,15 @@ def test_ogr_gml_60(): ds = ogr.Open('data/wfs_200_multiplelayers.gml') lyr = ds.GetLayerByName('road') if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'road.21': - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('popplace') if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'popplace.BACMK': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2865,23 +2781,19 @@ def test_ogr_gml_61(): feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'Object.1' or feat.GetField('foo') != 'bar': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' geom = feat.GetGeometryRef() if geom.ExportToWkt() != 'POLYGON ((2 48,2 49,3 49,3 48,2 48))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'Object.2' or feat.GetField('foo') != 'baz': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' geom = feat.GetGeometryRef() if geom.ExportToWkt() != 'POLYGON ((2 -48,2 -49,3 -49,3 -48,2 -48))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -2905,7 +2817,6 @@ def test_ogr_gml_62(): ds = ogr.Open('tmp/gmlattributes.gml') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2921,7 +2832,6 @@ def test_ogr_gml_62(): gdal.SetConfigOption('GML_ATTRIBUTES_TO_OGR_FIELDS', None) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 4: - gdaltest.post_reason('fail') print(i) return 'fail' feat = lyr.GetNextFeature() @@ -2929,7 +2839,6 @@ def test_ogr_gml_62(): feat.GetField('element2_attr1') != 'a' or \ feat.GetField('element2') != 'foo' or \ feat.IsFieldSet('element3_attr1'): - gdaltest.post_reason('fail') feat.DumpReadable() print(i) return 'fail' @@ -2938,7 +2847,6 @@ def test_ogr_gml_62(): feat.IsFieldSet('element2_attr1') or \ feat.IsFieldSet('element2') or \ feat.GetField('element3_attr1') != 1: - gdaltest.post_reason('fail') feat.DumpReadable() print(i) return 'fail' @@ -2947,7 +2855,6 @@ def test_ogr_gml_62(): feat.IsFieldSet('element2_attr1') or \ feat.IsFieldSet('element2') or \ feat.IsFieldSet('element3_attr1'): - gdaltest.post_reason('fail') feat.DumpReadable() print(i) return 'fail' @@ -3052,14 +2959,12 @@ def test_ogr_gml_65(): gdal.VSIFCloseL(f) if data.find(expected) < 0: - gdaltest.post_reason('fail') return 'fail' ds = ogr.Open(filename) lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != "MULTIPOLYGON (((0 1 2,3 4 5,6 7 8,0 1 2)))": - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' ds = None @@ -3214,107 +3119,86 @@ def test_ogr_gml_66(): lyr = ds.GetLayerByName('compoundcurve') if lyr.GetGeomType() != ogr.wkbCompoundCurve: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1,2 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('curvepolygon') if lyr.GetGeomType() != ogr.wkbCurvePolygon: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'CURVEPOLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multisurface') if lyr.GetGeomType() != ogr.wkbMultiSurface: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0)))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTISURFACE (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multicurve') if lyr.GetGeomType() != ogr.wkbMultiCurve: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTICURVE ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('polygon') if lyr.GetGeomType() != ogr.wkbPolygon: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('linestring') if lyr.GetGeomType() != ogr.wkbLineString: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (0 0,0 1,1 1,0 0)': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multipolygon') if lyr.GetGeomType() != ogr.wkbMultiPolygon: print(lyr.GetGeomType()) - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multilinestring') if lyr.GetGeomType() != ogr.wkbMultiLineString: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTILINESTRING ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -3322,88 +3206,72 @@ def test_ogr_gml_66(): if i != 0: if lyr.GetGeomType() != ogr.wkbCompoundCurve: print(lyr.GetGeomType()) - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1,2 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' else: feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (0 0,1 1,2 0)': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('curvepolygon_untyped') if i != 0: if lyr.GetGeomType() != ogr.wkbCurvePolygon: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'CURVEPOLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' else: feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multisurface_untyped') if i != 0: if lyr.GetGeomType() != ogr.wkbMultiSurface: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTISURFACE (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' else: feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0)))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multicurve_untyped') if i != 0: if lyr.GetGeomType() != ogr.wkbMultiCurve: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTICURVE ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' else: feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTILINESTRING ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,1 1,2 0))': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -3474,43 +3342,35 @@ def test_ogr_gml_67(): if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('b1')).GetType() != ogr.OFTInteger or \ lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('b1')).GetSubType() != ogr.OFSTBoolean: print(i) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('bool_list')).GetType() != ogr.OFTIntegerList or \ lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('bool_list')).GetSubType() != ogr.OFSTBoolean: print(i) - gdaltest.post_reason('fail') return 'fail' if i == 0: if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('short')).GetType() != ogr.OFTInteger or \ lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('short')).GetSubType() != ogr.OFSTInt16: print(i) - gdaltest.post_reason('fail') return 'fail' if i == 0: if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetType() != ogr.OFTReal or \ lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetSubType() != ogr.OFSTFloat32: print(i) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('int64')).GetType() != ogr.OFTInteger64: print(i) - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('int64list')).GetType() != ogr.OFTInteger64List: print(i) - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetField('b1') != 1 or f.GetField('b2') != 0 or f.GetFieldAsString('bool_list') != '(2:1,0)' or f.GetField('short') != -32768 or f.GetField('float') != 1.23: print(i) - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 1234567890123 or f.GetField('int64') != 1234567890123 or f.GetField('int64list') != [1, 1234567890123]: print(i) - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3587,7 +3447,6 @@ def test_ogr_gml_69(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -3598,7 +3457,6 @@ def test_ogr_gml_69(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -3607,16 +3465,12 @@ def test_ogr_gml_69(): ds = gdal.OpenEx('/vsimem/ogr_gml_69.gml', open_options=['EMPTY_AS_NULL=NO']) lyr = ds.GetLayerByName('test') if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_nullable')).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3653,7 +3507,6 @@ def test_ogr_gml_70(): lyr = ds.GetLayerByName('test') f = lyr.GetNextFeature() if f.GetField('field_string') != 'a': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3670,12 +3523,10 @@ def test_ogr_gml_70(): def ogr_gml_71_helper(ds): if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' lyr = ds.GetLayer(0) if lyr.GetName() != 'join_table1_table2': - gdaltest.post_reason('fail') print(lyr.GetName()) return 'fail' fields = [('table1.gml_id', ogr.OFTString), @@ -3686,31 +3537,25 @@ def ogr_gml_71_helper(ds): ('table2.baz', ogr.OFTString)] layer_defn = lyr.GetLayerDefn() if layer_defn.GetFieldCount() != len(fields): - gdaltest.post_reason('fail') print(layer_defn.GetFieldCount()) return 'fail' for i, field in enumerate(fields): fld_defn = layer_defn.GetFieldDefn(i) if fld_defn.GetName() != field[0]: - gdaltest.post_reason('fail') print(i) print(fld_defn.GetName()) return 'fail' if fld_defn.GetType() != field[1]: - gdaltest.post_reason('fail') print(i) print(fld_defn.GetType()) return 'fail' if layer_defn.GetGeomFieldCount() != 2: - gdaltest.post_reason('fail') print(layer_defn.GetGeomFieldCount()) return 'fail' if layer_defn.GetGeomFieldDefn(0).GetName() != 'table1.geometry': - gdaltest.post_reason('fail') print(layer_defn.GetGeomFieldDefn(0).GetName()) return 'fail' if layer_defn.GetGeomFieldDefn(1).GetName() != 'table2.geometry': - gdaltest.post_reason('fail') print(layer_defn.GetGeomFieldDefn(1).GetName()) return 'fail' f = lyr.GetNextFeature() @@ -3722,7 +3567,6 @@ def ogr_gml_71_helper(ds): f.GetField('table2.baz') != 'foo' or \ f.GetGeomFieldRef(0) is not None or \ f.GetGeomFieldRef(1).ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() @@ -3734,7 +3578,6 @@ def ogr_gml_71_helper(ds): f.GetField('table2.baz') != 'bar' or \ f.GetGeomFieldRef(0).ExportToWkt() != 'POINT (3 50)' or \ f.GetGeomFieldRef(1).ExportToWkt() != 'POINT (2 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3754,7 +3597,6 @@ def test_ogr_gml_71(): try: os.unlink('data/wfsjointlayer.gfs') - gdaltest.post_reason('fail') return 'fail' except OSError: pass @@ -3767,7 +3609,6 @@ def test_ogr_gml_71(): try: os.unlink('data/wfsjointlayer.gfs') except OSError: - gdaltest.post_reason('fail') return 'fail' # Without .xsd nor .gfs @@ -3780,7 +3621,6 @@ def test_ogr_gml_71(): try: os.stat('tmp/wfsjointlayer.gfs') except OSError: - gdaltest.post_reason('fail') return 'fail' # With .gfs @@ -3805,7 +3645,6 @@ def test_ogr_gml_72(): ds = ogr.Open('/vsimem/ogr_gml_72.gml') if ds.GetMetadata() != {'NAME': 'name', 'DESCRIPTION': 'description'}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -3820,7 +3659,6 @@ def test_ogr_gml_72(): ds = ogr.Open('/vsimem/ogr_gml_72.gml') if ds.GetMetadata() != {'NAME': 'name', 'DESCRIPTION': 'description'}: - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -3962,7 +3800,6 @@ def test_ogr_gml_75(): ds = ogr.Open('/vsimem/ogr_gml_75.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/ogr_gml_75.xml') @@ -4020,11 +3857,9 @@ def test_ogr_gml_77(): ds = ogr.Open('/vsimem/ogr_gml_77.xml') lyr = ds.GetLayer(0) if lyr.GetSpatialRef().ExportToWkt().find('AXIS') >= 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4032,7 +3867,6 @@ def test_ogr_gml_77(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4040,7 +3874,6 @@ def test_ogr_gml_77(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (49 2)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4076,11 +3909,9 @@ def test_ogr_gml_78(): ds = ogr.Open('/vsimem/ogr_gml_78.xml') lyr = ds.GetLayer(0) if lyr.GetSpatialRef().ExportToWkt().find('AXIS') >= 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4088,7 +3919,6 @@ def test_ogr_gml_78(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (49 2)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4096,7 +3926,6 @@ def test_ogr_gml_78(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4135,7 +3964,6 @@ def test_ogr_gml_79(): gdal.VSIFCloseL(f) if data.find(expected_srsname) < 0 or data.find(expected_coords) < 0: - gdaltest.post_reason('fail') print(srsname_format) print(data) return 'fail' @@ -4175,19 +4003,16 @@ def test_ogr_gml_80(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['int_field'] != 4: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['int_field'] is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('int_field'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None @@ -4237,7 +4062,6 @@ def test_ogr_gml_82(): ds = ogr.Open('/vsimem/ogr_gml_82.gml') lyr = ds.GetLayer(0) if lyr.GetFeatureCount() != 10: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4246,7 +4070,6 @@ def test_ogr_gml_82(): data = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) if data.find('gml:FeatureCollection') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -4255,11 +4078,9 @@ def test_ogr_gml_82(): data = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) if data.find('name = "FeatureCollection"') >= 0: - gdaltest.post_reason('fail') print(data) return 'fail' if data.find('gmlsf') >= 0: - gdaltest.post_reason('fail') print(data) return 'fail' diff --git a/autotest/ogr/ogr_gmlas.py b/autotest/ogr/ogr_gmlas.py index 10a9b8affdae..4e7ff84e1df7 100755 --- a/autotest/ogr/ogr_gmlas.py +++ b/autotest/ogr/ogr_gmlas.py @@ -72,7 +72,6 @@ def compare_ogrinfo_output(gmlfile, reffile, options=''): expected = open(reffile, 'rb').read().decode('utf-8') expected = expected.replace('\r\n', '\n') if ret != expected: - gdaltest.post_reason('fail') print('Got:') print(ret.encode('utf-8')) open(tmpfilename, 'wb').write(ret.encode('utf-8')) @@ -100,7 +99,6 @@ def test_ogr_gmlas_basic(): ds = ogr.Open('GMLAS:data/gmlas/gmlas_test1.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -163,7 +161,6 @@ def test_ogr_gmlas_virtual_file(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_8.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/ogr_gmlas_8.xml') @@ -182,7 +179,6 @@ def test_ogr_gmlas_datafile_with_xsd_option(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['XSD=data/gmlas/gmlas_test1.xsd']) if ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -198,7 +194,6 @@ def test_ogr_gmlas_no_datafile_with_xsd_option(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xsd']) if ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -215,10 +210,8 @@ def test_ogr_gmlas_no_datafile_xsd_which_is_not_xsd(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xml']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find("invalid content in 'schema' element") < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -236,10 +229,8 @@ def test_ogr_gmlas_no_datafile_no_xsd(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:') if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('XSD open option must be provided when no XML data file is passed') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -257,10 +248,8 @@ def test_ogr_gmlas_non_existing_gml(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:/vsimem/i_do_not_exist.gml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Cannot open /vsimem/i_do_not_exist.gml') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -278,10 +267,8 @@ def test_ogr_gmlas_non_existing_xsd(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=/vsimem/i_do_not_exist.xsd']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('Cannot resolve /vsimem/i_do_not_exist.xsd') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -302,10 +289,8 @@ def test_ogr_gmlas_gml_without_schema_location(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_gml_without_schema_location.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('No schema locations found when analyzing data file: XSD open option must be provided') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -325,10 +310,8 @@ def test_ogr_gmlas_invalid_schema(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_invalid_schema.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('invalid content') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -348,10 +331,8 @@ def test_ogr_gmlas_invalid_xml(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg().find('input ended before all started tags were ended') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -368,7 +349,6 @@ def test_ogr_gmlas_gml_Reference(): ds = ogr.Open('GMLAS:data/gmlas/gmlas_test_targetelement.xml') if ds.GetLayerCount() != 3: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' @@ -382,7 +362,6 @@ def test_ogr_gmlas_gml_Reference(): f['reference_existing_abstract_target_elt_href'] != '#BAW' or \ f.IsFieldSet('reference_existing_abstract_target_elt_nillable_href') or \ f['reference_existing_abstract_target_elt_nillable_nil'] != 1: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -399,32 +378,25 @@ def test_ogr_gmlas_same_element_in_different_ns(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_same_element_in_different_ns.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' # for i in range(ds.GetLayerCount()): # print(ds.GetLayer(i).GetName()) if ds.GetLayerCount() != 5: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' lyr = ds.GetLayerByName('elt') f = lyr.GetNextFeature() if f.IsFieldSet('abstractElt_other_ns_realizationOfAbstractElt_pkid') == 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if ds.GetLayerByName('myns_realizationOfAbstractElt') is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerByName('other_ns_realizationOfAbstractElt') is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerByName('elt_elt2_abstractElt_myns_realizationOfAbstractElt') is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerByName('elt_elt2_abstractElt_other_ns_realizationOfAbstractElt') is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -440,7 +412,6 @@ def test_ogr_gmlas_corner_case_relative_path(): ds = ogr.Open('GMLAS:../ogr/data/gmlas/gmlas_test1.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -459,16 +430,13 @@ def test_ogr_gmlas_unexpected_repeated_element(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f is None or f['foo'] != 'foo_again': # somewhat arbitrary to keep the latest one! - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if gdal.GetLastErrorMsg().find('Unexpected element myns:main_elt/myns:foo') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -488,16 +456,13 @@ def test_ogr_gmlas_unexpected_repeated_element_variant(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f is None or f['foo'] != 'foo_again': # somewhat arbitrary to keep the latest one! - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if gdal.GetLastErrorMsg().find('Unexpected element myns:main_elt/myns:foo') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -518,87 +483,71 @@ def test_ogr_gmlas_geometryproperty(): with gdaltest.error_handler(): geom_field_count = lyr.GetLayerDefn().GetGeomFieldCount() if geom_field_count != 15: - gdaltest.post_reason('fail') print(geom_field_count) return 'fail' f = lyr.GetNextFeature() if f['geometryProperty_xml'] != ' 49 2 ': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if not f.IsFieldNull('geometryPropertyEmpty_xml'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f['pointProperty_xml'] != '50 3': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f['pointPropertyRepeated_xml'] != [ '0 1', '1 2', '3 4']: - gdaltest.post_reason('fail') print(f['pointPropertyRepeated_xml']) f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryProperty') sr = lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetSpatialRef() if sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(sr) return 'fail' wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() # Axis swapping if wkt != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryPropertyEmpty') if f.GetGeomFieldRef(geom_idx) is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('pointProperty') sr = lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetSpatialRef() if sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(sr) return 'fail' wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'POINT (3 50)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('lineStringProperty') sr = lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetSpatialRef() if sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0: - gdaltest.post_reason('fail') print(sr) return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType() != ogr.wkbLineString: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType()) return 'fail' wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'LINESTRING (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('pointPropertyRepeated') if lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType() != ogr.wkbUnknown: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType()) return 'fail' wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'GEOMETRYCOLLECTION (POINT (0 1),POINT (1 2),POINT (3 4))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('mycustompointproperty_point') wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'POINT (5 6)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -607,7 +556,6 @@ def test_ogr_gmlas_geometryproperty(): geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryProperty') geom = f.GetGeomFieldRef(geom_idx) if ogrtest.check_feature_geometry(geom, 'POINT (3.0 0.0)') != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -616,7 +564,6 @@ def test_ogr_gmlas_geometryproperty(): f = lyr.GetNextFeature() geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryProperty') if f.GetGeomFieldRef(geom_idx) is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -630,14 +577,12 @@ def test_ogr_gmlas_geometryproperty(): wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() # Axis swapping if wkt != 'POINT (49 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('lineStringProperty') wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() # Axis swapping if wkt != 'LINESTRING (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -651,14 +596,12 @@ def test_ogr_gmlas_geometryproperty(): wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() # Axis swapping if wkt != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('lineStringProperty') wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() # Axis swapping if wkt != 'LINESTRING (49 2)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -677,29 +620,24 @@ def test_ogr_gmlas_abstractgeometry(): 'CONFIG_FILE=true']) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetGeomFieldCount() != 2: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetGeomFieldCount()) return 'fail' f = lyr.GetNextFeature() if f['AbstractGeometry_xml'] != '0 1': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f['repeated_AbstractGeometry_xml'] != [ '0 1', '1 2']: - gdaltest.post_reason('fail') print(f['repeated_AbstractGeometry_xml']) f.DumpReadable() return 'fail' wkt = f.GetGeomFieldRef(0).ExportToWkt() if wkt != 'POINT (0 1)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' wkt = f.GetGeomFieldRef(1).ExportToWkt() if wkt != 'GEOMETRYCOLLECTION (POINT (0 1),POINT (1 2))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -726,7 +664,6 @@ def test_ogr_gmlas_validate(): # By default check we are silent about validation error ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) @@ -736,13 +673,11 @@ def test_ogr_gmlas_validate(): gdal.SetConfigOption('GMLAS_WARN_UNEXPECTED', 'YES') gdal.PopErrorHandler() if myhandler.error_list: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml') if ds is None: - gdaltest.post_reason('fail') return 'fail' myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) @@ -751,7 +686,6 @@ def test_ogr_gmlas_validate(): gdal.PopErrorHandler() # Unexpected element with xpath=myns:main_elt/myns:bar (subxpath=myns:main_elt/myns:bar) found if len(myhandler.error_list) < 2: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' @@ -761,11 +695,9 @@ def test_ogr_gmlas_validate(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['VALIDATE=YES']) gdal.PopErrorHandler() if ds is None: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' if myhandler.error_list: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' @@ -779,11 +711,9 @@ def test_ogr_gmlas_validate(): gdal.PopErrorHandler() gdal.Unlink('/vsimem/gmlas_test1.xml') if ds is None: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' if myhandler.error_list: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' @@ -793,10 +723,8 @@ def test_ogr_gmlas_validate(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml', open_options=['VALIDATE=YES']) gdal.PopErrorHandler() if ds is None: - gdaltest.post_reason('fail') return 'fail' if len(myhandler.error_list) != 5: - gdaltest.post_reason('fail') print(myhandler.error_list) print(len(myhandler.error_list)) return 'fail' @@ -807,10 +735,8 @@ def test_ogr_gmlas_validate(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml', open_options=['VALIDATE=YES', 'FAIL_IF_VALIDATION_ERROR=YES']) gdal.PopErrorHandler() if ds is not None: - gdaltest.post_reason('fail') return 'fail' if len(myhandler.error_list) != 6: - gdaltest.post_reason('fail') print(myhandler.error_list) print(len(myhandler.error_list)) return 'fail' @@ -821,11 +747,9 @@ def test_ogr_gmlas_validate(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xsd', 'VALIDATE=YES']) gdal.PopErrorHandler() if ds is None: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' if myhandler.error_list: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' @@ -846,7 +770,6 @@ def test_ogr_gmlas_test_ns_prefix(): lyr = ds.GetLayerByName('_ogr_fields_metadata') f = lyr.GetNextFeature() if f['field_xpath'] != 'myns:main_elt/myns:reference_missing_target_elt/@xlink:href': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -865,7 +788,6 @@ def test_ogr_gmlas_no_namespace(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['foo'] != 'bar': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -884,7 +806,6 @@ def test_ogr_gmlas_conf(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['CONFIG_FILE=not_existing']) if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Broken conf file @@ -893,7 +814,6 @@ def test_ogr_gmlas_conf(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['CONFIG_FILE=/vsimem/my_conf.xml']) gdal.Unlink('/vsimem/my_conf.xml') if ds is not None: - gdaltest.post_reason('fail') return 'fail' # Valid XML, but not validating @@ -906,24 +826,20 @@ def test_ogr_gmlas_conf(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=[ 'CONFIG_FILE=false']) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('main_elt_string_array') if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' # AlwaysGenerateOGRId = true ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=[ 'CONFIG_FILE=true']) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('main_elt') f = lyr.GetNextFeature() if f['ogr_pkid'].find('main_elt_1') < 0 or \ f['otherns_id'] != 'otherns_id': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -931,18 +847,15 @@ def test_ogr_gmlas_conf(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_geometryproperty_gml32.gml', open_options=[ 'CONFIG_FILE=false']) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) with gdaltest.error_handler(): if lyr.GetLayerDefn().GetFieldIndex('geometryProperty_xml') >= 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryProperty') wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -950,10 +863,8 @@ def test_ogr_gmlas_conf(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_abstractgeometry_gml32.gml', open_options=[ 'CONFIG_FILE=true']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 5: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' # Test override with open option @@ -961,10 +872,8 @@ def test_ogr_gmlas_conf(): 'EXPOSE_METADATA_LAYERS=NO', 'CONFIG_FILE=true']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' @@ -973,7 +882,6 @@ def test_ogr_gmlas_conf(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml', open_options=[ 'CONFIG_FILE=true']) if ds is not None or gdal.GetLastErrorMsg().find('Validation') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1010,7 +918,6 @@ def test_ogr_gmlas_conf_ignored_xpath(): """ % xpath]) if gdal.GetLastErrorMsg().find('XPath syntax') < 0: - gdaltest.post_reason('fail') print(xpath) print(gdal.GetLastErrorMsg()) return 'fail' @@ -1028,7 +935,6 @@ def test_ogr_gmlas_conf_ignored_xpath(): """]) if gdal.GetLastErrorMsg().find('Prefix ns was already mapped') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1041,16 +947,13 @@ def test_ogr_gmlas_conf_ignored_xpath(): """]) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('main_elt') if lyr.GetLayerDefn().GetFieldIndex('otherns_id') >= 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): lyr.GetNextFeature() if gdal.GetLastErrorMsg().find('Attribute with xpath=myns:main_elt/@otherns:id found in document but ignored') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1065,12 +968,10 @@ def test_ogr_gmlas_conf_ignored_xpath(): """]) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('main_elt') lyr.GetNextFeature() if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1093,33 +994,25 @@ def test_ogr_gmlas_conf_ignored_xpath(): """]) if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('main_elt') # Ignored fields if lyr.GetLayerDefn().GetFieldIndex('optionalStrAttr') >= 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldIndex('fixedValUnset') >= 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldIndex('base_int') >= 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldIndex('string') >= 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldIndex('string_array') >= 0: - gdaltest.post_reason('fail') return 'fail' # Present fields if lyr.GetLayerDefn().GetFieldIndex('int_array') < 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldIndex('long') < 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1214,7 +1107,6 @@ def test_ogr_gmlas_cache(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=false/vsimem/my/gmlas_cache']) if ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1223,11 +1115,9 @@ def test_ogr_gmlas_cache(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/inexisting_directory/not/exist']) if ds is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1236,11 +1126,9 @@ def test_ogr_gmlas_cache(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/vsimem/my/gmlas_cache']) if ds is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1251,11 +1139,9 @@ def test_ogr_gmlas_cache(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/vsimem/my/gmlas_cache']) if ds is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1264,11 +1150,9 @@ def test_ogr_gmlas_cache(): 'XSD=http://localhost:%d/vsimem/ogr_gmlas_cache.xsd' % webserver_port, 'CONFIG_FILE=/vsimem/my/gmlas_cache']) if ds is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1278,10 +1162,8 @@ def test_ogr_gmlas_cache(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/vsimem/my/gmlas_cache']) if ds is None: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' # Re try but ask for refresh @@ -1290,7 +1172,6 @@ def test_ogr_gmlas_cache(): 'REFRESH_CACHE=YES', 'CONFIG_FILE=/vsimem/my/gmlas_cache']) if ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1302,7 +1183,6 @@ def test_ogr_gmlas_cache(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/vsimem/my/gmlas_cache']) if ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -1332,7 +1212,6 @@ def test_ogr_gmlas_link_nested_independant_child(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['second_my_id'] != 'second_id': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1352,24 +1231,20 @@ def test_ogr_gmlas_composition_compositionPart(): lyr = ds.GetLayerByName('first_composition') f = lyr.GetNextFeature() if f.IsFieldSet('parent_ogr_pkid') == 0 or f.IsFieldSet('CompositionPart_pkid') == 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('parent_ogr_pkid') == 0 or f.IsFieldSet('CompositionPart_pkid') == 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr = ds.GetLayerByName('CompositionPart') f = lyr.GetNextFeature() if f.IsFieldSet('my_id') == 0 or f.IsFieldSet('a') == 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('my_id') == 0 or f.IsFieldSet('a') == 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -1388,7 +1263,6 @@ def test_ogr_gmlas_instantiate_only_gml_feature(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_instantiate_only_gml_feature.xsd']) if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1412,7 +1286,6 @@ def test_ogr_gmlas_timestamp_ignored_for_hash(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['ogr_pkid'] != pkid: - gdaltest.post_reason('fail') print(pkid) f.DumpReadable() return 'fail' @@ -1431,7 +1304,6 @@ def test_ogr_gmlas_dataset_getnextfeature(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml') if ds.TestCapability(ogr.ODsCRandomLayerRead) != 1: - gdaltest.post_reason('fail') return 'fail' count = 0 @@ -1440,7 +1312,6 @@ def test_ogr_gmlas_dataset_getnextfeature(): f, lyr = ds.GetNextFeature() if f is None: if lyr is not None: - gdaltest.post_reason('fail') return 'fail' break count += 1 @@ -1448,18 +1319,15 @@ def test_ogr_gmlas_dataset_getnextfeature(): base_count = 59 if count != base_count: - gdaltest.post_reason('fail') print(count) return 'fail' if last_l.GetName() != 'main_elt': - gdaltest.post_reason('fail') print(last_l.GetName()) return 'fail' f, lyr = ds.GetNextFeature() if f is not None or lyr is not None: - gdaltest.post_reason('fail') return 'fail' ds.ResetReading() @@ -1469,11 +1337,9 @@ def test_ogr_gmlas_dataset_getnextfeature(): last_pct = pct if f is None: if l is not None: - gdaltest.post_reason('fail') return 'fail' break if last_pct != 1.0: - gdaltest.post_reason('fail') print(last_pct - 1.0) return 'fail' @@ -1492,7 +1358,6 @@ def test_ogr_gmlas_dataset_getnextfeature(): f, lyr = ds.GetNextFeature() if f is None: if lyr is not None: - gdaltest.post_reason('fail') return 'fail' break count += 1 @@ -1503,13 +1368,11 @@ def test_ogr_gmlas_dataset_getnextfeature(): expected_count += fc_map['_ogr_layer_relationships'] expected_count += fc_map['_ogr_other_metadata'] if count != expected_count: - gdaltest.post_reason('fail') print(count) return 'fail' f, lyr = ds.GetNextFeature() if f is not None or lyr is not None: - gdaltest.post_reason('fail') return 'fail' ds.ResetReading() @@ -1519,13 +1382,11 @@ def test_ogr_gmlas_dataset_getnextfeature(): f, lyr = ds.GetNextFeature() if f is None: if lyr is not None: - gdaltest.post_reason('fail') return 'fail' break count += 1 if count != expected_count: - gdaltest.post_reason('fail') print(count) print(expected_count) return 'fail' @@ -1549,20 +1410,17 @@ def test_ogr_gmlas_dataset_getnextfeature(): f, lyr = ds.GetNextFeature() if f is None: if lyr is not None: - gdaltest.post_reason('fail') return 'fail' break count += 1 if count != expected_count: - gdaltest.post_reason('fail') print(count) print(expected_count) return 'fail' f, lyr = ds.GetNextFeature() if f is not None or lyr is not None: - gdaltest.post_reason('fail') return 'fail' # Test iterating over metadata layers on XSD-only based dataset @@ -1573,14 +1431,12 @@ def test_ogr_gmlas_dataset_getnextfeature(): f, lyr = ds.GetNextFeature() if f is None: if lyr is not None: - gdaltest.post_reason('fail') return 'fail' break count += 1 last_l = lyr if count == 0: - gdaltest.post_reason('fail') print(count) return 'fail' @@ -1598,14 +1454,12 @@ def test_ogr_gmlas_inline_identifier(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_inline_identifier.xsd']) if ds.GetLayerCount() != 2: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) for i in range(ds.GetLayerCount()): print(ds.GetLayer(i).GetName()) return 'fail' lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldIndex('identifier_foo') < 0: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1621,16 +1475,13 @@ def test_ogr_gmlas_avoid_same_name_inlined_classes(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_avoid_same_name_inlined_classes.xsd']) if ds.GetLayerCount() != 3: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' lyr = ds.GetLayerByName('myFeature_ns1_dt') if lyr is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('myFeature_ns2_dt') if lyr is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -1651,7 +1502,6 @@ def test_ogr_gmlas_validate_ignored_fixed_attribute(): 'CONFIG_FILE=@bar']) gdal.PopErrorHandler() if myhandler.error_list: - gdaltest.post_reason('fail') print(myhandler.error_list) return 'fail' @@ -1670,36 +1520,30 @@ def test_ogr_gmlas_remove_unused_layers_and_fields(): open_options=['REMOVE_UNUSED_LAYERS=YES', 'REMOVE_UNUSED_FIELDS=YES']) if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if lyr.GetLayerDefn().GetFieldCount() != 4: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) f.DumpReadable() return 'fail' if f['used1'] != 'foo' or f['used2'] != 'bar' or f['nillable_nilReason'] != 'unknown': - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('_ogr_layers_metadata') if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') for f in lyr: f.DumpReadable() return 'fail' lyr = ds.GetLayerByName('_ogr_fields_metadata') if lyr.GetFeatureCount() != 7: - gdaltest.post_reason('fail') for f in lyr: f.DumpReadable() return 'fail' lyr = ds.GetLayerByName('_ogr_layer_relationships') if lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') for f in lyr: f.DumpReadable() return 'fail' @@ -1784,7 +1628,6 @@ def test_ogr_gmlas_xlink_resolver(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_xlink_resolver.xml') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldIndex('my_link_rawcontent') >= 0: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' ds = None @@ -1800,12 +1643,10 @@ def test_ogr_gmlas_xlink_resolver(): """]) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldIndex('my_link_rawcontent') < 0: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' f = lyr.GetNextFeature() if f.IsFieldSet('my_link_rawcontent'): - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1815,7 +1656,6 @@ def test_ogr_gmlas_xlink_resolver(): lyr.ResetReading() f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'foo': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' ds = None @@ -1837,12 +1677,10 @@ def test_ogr_gmlas_xlink_resolver(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'bar': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' # Check that the content is not cached if gdal.VSIStatL(cached_file) is not None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1851,13 +1689,11 @@ def test_ogr_gmlas_xlink_resolver(): lyr.ResetReading() f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'bar': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'baz': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1867,13 +1703,11 @@ def test_ogr_gmlas_xlink_resolver(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f['my_link_rawcontent'] is not None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'baz': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1893,12 +1727,10 @@ def test_ogr_gmlas_xlink_resolver(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'bar': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' # Check that the content is cached if gdal.VSIStatL(cached_file) is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' ds = None @@ -1917,12 +1749,10 @@ def test_ogr_gmlas_xlink_resolver(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['my_link_rawcontent'] != 'baz': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' # Check that the content is cached if gdal.VSIStatL(cached_file) is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' ds = None @@ -1947,7 +1777,6 @@ def test_ogr_gmlas_xlink_resolver(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f.IsFieldSet('my_link_rawcontent'): - gdaltest.post_reason('fail') f.DumpReadable() webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -1969,12 +1798,10 @@ def test_ogr_gmlas_xlink_resolver(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' # Check that the content is not cached if gdal.VSIStatL(cached_file) is not None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' ds = None @@ -1998,13 +1825,11 @@ def test_ogr_gmlas_xlink_resolver(): f['my_link_href'] != 'http://localhost:%d/vsimem/resource.xml' % webserver_port or \ f['my_link_rawcontent'] != 'bar' or \ f['my_link_attr_after'] != 'b': - gdaltest.post_reason('fail') f.DumpReadable() webserver.server_stop(webserver_process, webserver_port) return 'fail' # Check that the content is cached if gdal.VSIStatL(cached_file) is None: - gdaltest.post_reason('fail') webserver.server_stop(webserver_process, webserver_port) return 'fail' ds = None @@ -2129,14 +1954,12 @@ def test_ogr_gmlas_xlink_resolver(): f['my_link2_datetime'] != '2016/10/07 12:34:56+00' or \ f['my_link2_bar'] is not None or \ f['my_link2_attr_after'] != 'b2': - gdaltest.post_reason('fail') f.DumpReadable() webserver.server_stop(webserver_process, webserver_port) return 'fail' f = lyr.GetNextFeature() if f['my_link2_bar'] != 123: - gdaltest.post_reason('fail') f.DumpReadable() webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -2160,7 +1983,6 @@ def test_ogr_gmlas_xlink_resolver(): f['my_link2_baz'] != 345 or \ f['my_link2_bar'] is not None or \ f['my_link2_attr_after'] != 'b2': - gdaltest.post_reason('fail') f.DumpReadable() webserver.server_stop(webserver_process, webserver_port) return 'fail' @@ -2205,7 +2027,6 @@ def test_ogr_gmlas_recoding(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['attr'] != accent: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2225,7 +2046,6 @@ def test_ogr_gmlas_schema_without_namespace_prefix(): lyr = ds.GetLayerByName('_ogr_layers_metadata') f = lyr.GetNextFeature() if f['layer_xpath'] != 'my_ns:main_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2237,7 +2057,6 @@ def test_ogr_gmlas_schema_without_namespace_prefix(): lyr = ds.GetLayerByName('_ogr_layers_metadata') f = lyr.GetNextFeature() if f['layer_xpath'] != 'fake_3_0:main_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2249,7 +2068,6 @@ def test_ogr_gmlas_schema_without_namespace_prefix(): lyr = ds.GetLayerByName('_ogr_layers_metadata') f = lyr.GetNextFeature() if f['layer_xpath'] != 'my_namespace:main_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2269,7 +2087,6 @@ def test_ogr_gmlas_truncated_xml(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2289,57 +2106,46 @@ def test_ogr_gmlas_identifier_truncation(): 'CONFIG_FILE=10false']) lyr = ds.GetLayerByName('v_l_i_clas') if lyr is None: - gdaltest.post_reason('fail') print(ds.GetLayer(0).GetName()) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(1).GetName() if s != 'v_l_idTifi': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(2).GetName() if s != 'an_lo_ide1': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(3).GetName() if s != 'an_lo_ide2': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(4).GetName() if s != 'x': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(5).GetName() if s != 'noTCAMELCa': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(6).GetName() if s != 'suuuuuuuuu': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(7).GetName() if s != '_r_l_o_n_g': - gdaltest.post_reason('fail') print(s) return 'fail' lyr = ds.GetLayerByName('a_l_i_cla1') if lyr is None: - gdaltest.post_reason('fail') print(ds.GetLayer(1).GetName()) return 'fail' lyr = ds.GetLayerByName('a_l_i_cla2') if lyr is None: - gdaltest.post_reason('fail') print(ds.GetLayer(2).GetName()) return 'fail' lyr = ds.GetLayerByName('y') if lyr is None: - gdaltest.post_reason('fail') print(ds.GetLayer(3).GetName()) return 'fail' ds = None @@ -2360,22 +2166,18 @@ def test_ogr_gmlas_identifier_case_ambiguity(): 'CONFIG_FILE=false']) lyr = ds.GetLayerByName('differentcase1') if lyr is None: - gdaltest.post_reason('fail') print(ds.GetLayer(0).GetName()) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(1).GetName() if s != 'differentcase1': - gdaltest.post_reason('fail') print(s) return 'fail' s = lyr.GetLayerDefn().GetFieldDefn(2).GetName() if s != 'DifferentCASE2': - gdaltest.post_reason('fail') print(s) return 'fail' lyr = ds.GetLayerByName('DifferentCASE2') if lyr is None: - gdaltest.post_reason('fail') print(ds.GetLayer(0).GetName()) return 'fail' ds = None @@ -2404,7 +2206,6 @@ def test_ogr_gmlas_writer(): gdal.Unlink('/vsimem/ogr_gmlas_writer.db') if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -2427,7 +2228,6 @@ def test_ogr_gmlas_writer_check_xml_xsd(): pos_end = got.find('"', pos) absolute_xsd = got[pos:pos_end] if not absolute_xsd.endswith('gmlas_test1.xsd') or not os.path.exists(absolute_xsd): - gdaltest.post_reason('fail') print(absolute_xsd) return 'fail' got = got.replace(absolute_xsd, 'gmlas_test1.xsd') @@ -2436,8 +2236,6 @@ def test_ogr_gmlas_writer_check_xml_xsd(): expected = expected.replace('\r\n', '\n') if got != expected: - gdaltest.post_reason('fail') - print('Got:') print(got) print('') @@ -2452,7 +2250,6 @@ def test_ogr_gmlas_writer_check_xml_xsd(): pos_end = got.find('"', pos) absolute_xsd = got[pos:pos_end] if not absolute_xsd.endswith('gmlas_test1.xsd') or not os.path.exists(absolute_xsd): - gdaltest.post_reason('fail') print(absolute_xsd) return 'fail' got = got.replace(absolute_xsd, 'gmlas_test1.xsd') @@ -2461,8 +2258,6 @@ def test_ogr_gmlas_writer_check_xml_xsd(): expected = expected.replace('\r\n', '\n') if got != expected: - gdaltest.post_reason('fail') - print('Got:') print(got) print('') @@ -2515,8 +2310,6 @@ def test_ogr_gmlas_writer_check_xml_read_back(): ret_for_comparison = ret_for_comparison.replace('fake_hash', '3CF9893502A592E8CF5EA6EF3D8F8C7B') if ret_for_comparison != expected: - gdaltest.post_reason('fail') - print('XML:') print(open('tmp/gmlas_test1_generated.xml', 'rt').read()) print('') @@ -2565,12 +2358,10 @@ def test_ogr_gmlas_writer_gml(): tmp_ds = None if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_gml.xml', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) @@ -2579,27 +2370,22 @@ def test_ogr_gmlas_writer_gml(): gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xsd') if content.find('xmlns:gml="http://fake_gml32"') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find('49 2') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find('50 3') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find(' 0 1') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find(' 1 2') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2626,12 +2412,10 @@ def test_ogr_gmlas_writer_gml_assign_srs(): tmp_ds = None if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_gml.xml', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) @@ -2640,7 +2424,6 @@ def test_ogr_gmlas_writer_gml_assign_srs(): gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xsd') if content.find('http://www.opengis.net/def/crs/EPSG/0/32631') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2663,7 +2446,6 @@ def test_ogr_gmlas_writer_gml_assign_srs(): gdal.Unlink('/vsimem/ogr_gmlas_writer.db') if gdal.VSIStatL('/vsimem/gmlas_test1_generated_ref0.xml').size != gdal.VSIStatL('/vsimem/gmlas_test1_generated_asrs.xml').size: - gdaltest.post_reason('fail') print(gdal.VSIStatL('/vsimem/gmlas_test1_generated_ref0.xml').size) print(gdal.VSIStatL('/vsimem/gmlas_test1_generated_asrs.xml').size) return 'fail' @@ -2694,19 +2476,16 @@ def test_ogr_gmlas_writer_gml_original_xml(): tmp_ds = None if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' ret_ds = None ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_writer_gml.xml', open_options=['VALIDATE=YES']) if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_gml.xml', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) @@ -2715,17 +2494,14 @@ def test_ogr_gmlas_writer_gml_original_xml(): gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xsd') if content.find(' 49 2 ') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find(' 0 1') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' if content.find(' 1 2') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2754,12 +2530,10 @@ def test_ogr_gmlas_writer_options(): tmp_ds = None if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_options.xml', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) @@ -2767,32 +2541,27 @@ def test_ogr_gmlas_writer_options(): gdal.Unlink('/vsimem/ogr_gmlas_writer_options.xml') if gdal.VSIStatL('/vsimem/my_schema.xsd') is None: - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/my_schema.xsd') # Test indentation size if content.find('\n ') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' # Test comment if content.find('\n') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' # Test OUTPUT_XSD_FILENAME if content.find('/vsimem/my_schema.xsd') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' # Test SRSNAME_FORMAT=OGC_URN if content.find('49 2') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2806,12 +2575,10 @@ def test_ogr_gmlas_writer_options(): tmp_ds = None if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_options.xml', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) @@ -2819,12 +2586,10 @@ def test_ogr_gmlas_writer_options(): gdal.Unlink('/vsimem/ogr_gmlas_writer_options.xml') if gdal.VSIStatL('/vsimem/my_schema.xsd') is not None: - gdaltest.post_reason('fail') return 'fail' if content.find('timeStamp="1970-01-01T12:34:56Z"') < 0 or \ content.find('xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd ') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2838,7 +2603,6 @@ def test_ogr_gmlas_writer_options(): tmp_ds = None if ret_ds is None: - gdaltest.post_reason('fail') return 'fail' gdal.FileFromMemBuffer('/vsimem/fake_wfs.xsd', @@ -2863,13 +2627,11 @@ def test_ogr_gmlas_writer_options(): gdal.Unlink('/vsimem/fake_wfs.xsd') if ds is None or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_options.xml', 'rb') if f is None: - gdaltest.post_reason('fail') return 'fail' content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) @@ -2877,11 +2639,9 @@ def test_ogr_gmlas_writer_options(): gdal.Unlink('/vsimem/ogr_gmlas_writer_options.xml') if gdal.VSIStatL('/vsimem/my_schema.xsd') is not None: - gdaltest.post_reason('fail') return 'fail' if content.find('xsi:schemaLocation="http://www.opengis.net/wfs/2.0 /vsimem/fake_wfs.xsd ') < 0: - gdaltest.post_reason('fail') print(content) return 'fail' @@ -2900,7 +2660,6 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', gdal.GetDriverByName('Memory').Create('', 0, 0, 0, 0), format='GMLAS') if ret_ds is not None or gdal.GetLastErrorMsg().find('Source dataset has no layers') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2911,7 +2670,6 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS') if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot establish schema since no INPUT_XSD creation option specified and no _ogr_other_metadata found in source dataset') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2920,7 +2678,6 @@ def test_ogr_gmlas_writer_errors(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['INPUT_XSD=/i_do_not/exist.xsd']) if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve /i_do_not/exist.xsd') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2933,7 +2690,6 @@ def test_ogr_gmlas_writer_errors(): ret_ds = gdal.VectorTranslate('/i_am/not/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['GENERATE_XSD=NO']) if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot create /i_am/not/valid.xml') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2942,7 +2698,6 @@ def test_ogr_gmlas_writer_errors(): ret_ds = gdal.VectorTranslate('/i_am/not/valid.xsd', tmp_ds, format='GMLAS', datasetCreationOptions=['GENERATE_XSD=NO']) if ret_ds is not None or gdal.GetLastErrorMsg().find('.xsd extension is not valid') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2952,7 +2707,6 @@ def test_ogr_gmlas_writer_errors(): datasetCreationOptions=['WRAPPING=GMLAS_FEATURECOLLECTION', 'OUTPUT_XSD_FILENAME=/i_am/not/valid.xsd']) if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot create /i_am/not/valid.xsd') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' gdal.Unlink('/vsimem/valid.xml') @@ -2962,7 +2716,6 @@ def test_ogr_gmlas_writer_errors(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['CONFIG_FILE=/i/do_not/exist']) if ret_ds is not None or gdal.GetLastErrorMsg().find('Loading of configuration failed') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2971,7 +2724,6 @@ def test_ogr_gmlas_writer_errors(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['LAYERS=foo']) if ret_ds is not None or gdal.GetLastErrorMsg().find('Layer foo specified in LAYERS option does not exist') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' gdal.Unlink('/vsimem/valid.xml') @@ -2982,7 +2734,6 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') if ret_ds is not None or gdal.GetLastErrorMsg().find('_ogr_layers_metadata not found') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -2993,7 +2744,6 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') if ret_ds is not None or gdal.GetLastErrorMsg().find('_ogr_fields_metadata not found') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -3005,7 +2755,6 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') if ret_ds is not None or gdal.GetLastErrorMsg().find('_ogr_layer_relationships not found') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -3018,7 +2767,6 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot find field layer_name in _ogr_layers_metadata layer') < 0: - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' gdal.Unlink('/vsimem/valid.xml') @@ -3043,13 +2791,11 @@ def test_ogr_gmlas_read_fake_gmljp2(): f, lyr = ds.GetNextFeature() if f is None: if lyr is not None: - gdaltest.post_reason('fail') return 'fail' break count += 1 if count != 5: - gdaltest.post_reason('fail') print(count) return 'fail' @@ -3082,13 +2828,11 @@ def test_ogr_gmlas_typing_constraints(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if not f.IsFieldSetAndNotNull('foo_bar_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr = ds.GetLayer(1) f = lyr.GetNextFeature() if f.GetField('value') != 'baz': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3111,17 +2855,14 @@ def test_ogr_gmlas_typing_constraints(): """]) lyr = ds.GetLayer('main_elt_foo_bar') if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer('bar') f = lyr.GetNextFeature() if f.GetField('value') != 'baz': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetField('value') != 'baz2': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3145,17 +2886,14 @@ def test_ogr_gmlas_typing_constraints(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if not f.IsFieldSetAndNotNull('foo_bar_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f.IsFieldSetAndNotNull('foo_baz_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr = ds.GetLayer(1) f = lyr.GetNextFeature() if f.GetField('value') != 'baz': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3182,19 +2920,16 @@ def test_ogr_gmlas_swe_dataarray(): f.GetField('myCount') != 3 or \ f.GetField('myText') != 'foo' or \ f.GetField('myBoolean') is False: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetField('myTime') != '2017/09/01 00:00:00' or \ f.GetField('myCategory') != '2' or \ f.GetField('myQuantity') != 3.45: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3203,19 +2938,16 @@ def test_ogr_gmlas_swe_dataarray(): if f.GetField('myTime') != '2016/09/01 00:00:00+01' or \ f.GetField('myCategory') != '1' or \ f.GetField('myQuantity') != 2.34: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetField('myTime') != '2017/09/01 00:00:00' or \ f.GetField('myCategory') is not None or \ f.GetField('myQuantity') != 3.45: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3224,19 +2956,16 @@ def test_ogr_gmlas_swe_dataarray(): if f.GetField('myTime') != '2016/09/01 00:00:00+01' or \ f.GetField('myCategory') != '1' or \ f.GetField('myQuantity') != 2.34: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetField('myTime') != '2017/09/01 00:00:00' or \ f.GetField('myCategory') is not None or \ f.GetField('myQuantity') != 3.45: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3256,14 +2985,12 @@ def test_ogr_gmlas_swe_datarecord(): gdal.ErrorReset() ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_swe_datarecord.xml', open_options=['VALIDATE=YES']) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_swe_datarecord.xml') lyr = ds.GetLayerByName('main_elt_foo') if lyr.GetLayerDefn().GetFieldCount() != 12: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) return 'fail' f = lyr.GetNextFeature() @@ -3275,7 +3002,6 @@ def test_ogr_gmlas_swe_datarecord(): f.GetField('mycount_value') != 2 or \ f.GetField('mytext_value') != 'foo' or \ f.GetField('myboolean_value') is False: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3303,10 +3029,8 @@ def test_ogr_gmlas_any_field_at_end_of_declaration(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' if f.GetField('foo') != 'bar': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' if f.GetField('value') != 'baz': @@ -3390,7 +3114,6 @@ def test_ogr_gmlas_no_element_in_first_choice_schema(): lyr = ds.GetLayerByName('_ogr_layers_metadata') f = lyr.GetNextFeature() if f['layer_xpath'] != 'my_ns:main_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3413,7 +3136,6 @@ def test_ogr_gmlas_internal_xlink_href(): f.IsFieldSet('link_to_second_or_third_elt_second_elt_pkid') or \ f.IsFieldSet('link_to_second_or_third_elt_third_elt_pkid') or \ f.IsFieldSet('link_to_third_elt_third_elt_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3422,7 +3144,6 @@ def test_ogr_gmlas_internal_xlink_href(): f['link_to_second_or_third_elt_second_elt_pkid'] != 'id2' or \ f.IsFieldSet('link_to_second_or_third_elt_third_elt_pkid') or \ f.IsFieldSet('link_to_third_elt_third_elt_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3431,7 +3152,6 @@ def test_ogr_gmlas_internal_xlink_href(): f['link_to_second_or_third_elt_second_elt_pkid'] != 'id3' or \ f.IsFieldSet('link_to_second_or_third_elt_third_elt_pkid') or \ f.IsFieldSet('link_to_third_elt_third_elt_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3440,7 +3160,6 @@ def test_ogr_gmlas_internal_xlink_href(): f.IsFieldSet('link_to_second_or_third_elt_second_elt_pkid') or \ f['link_to_second_or_third_elt_third_elt_pkid'] != 'D1013B7E44F28C976B976A4314FA4A09_third_elt_1' or \ f.IsFieldSet('link_to_third_elt_third_elt_pkid'): - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3449,7 +3168,6 @@ def test_ogr_gmlas_internal_xlink_href(): f.IsFieldSet('link_to_second_or_third_elt_second_elt_pkid') or \ f.IsFieldSet('link_to_second_or_third_elt_third_elt_pkid') or \ f['link_to_third_elt_third_elt_pkid'] != 'D1013B7E44F28C976B976A4314FA4A09_third_elt_1': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3457,7 +3175,6 @@ def test_ogr_gmlas_internal_xlink_href(): f = lyr.GetNextFeature() if f['layer_name'] != 'main_elt' or f['field_index'] != 1 or \ f['field_name'] != 'link_to_second_or_third_elt_href': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3471,7 +3188,6 @@ def test_ogr_gmlas_internal_xlink_href(): f['field_max_occurs'] != 1 or \ f['field_category'] != 'PATH_TO_CHILD_ELEMENT_WITH_LINK' or \ f['field_related_layer'] != 'second_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3485,35 +3201,30 @@ def test_ogr_gmlas_internal_xlink_href(): f['field_max_occurs'] != 1 or \ f['field_category'] != 'PATH_TO_CHILD_ELEMENT_WITH_LINK' or \ f['field_related_layer'] != 'third_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['layer_name'] != 'main_elt' or f['field_index'] != 4 or \ f['field_name'] != 'link_to_second_or_third_elt': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['layer_name'] != 'main_elt' or f['field_index'] != 5 or \ f['field_name'] != 'link_to_third_elt_href': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['layer_name'] != 'main_elt' or f['field_index'] != 6 or \ f['field_name'] != 'link_to_third_elt_third_elt_pkid': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f['layer_name'] != 'third_elt' or f['field_index'] != 1 or \ f['field_name'] != 'id': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3524,7 +3235,6 @@ def test_ogr_gmlas_internal_xlink_href(): f['parent_element_name'] != 'link_to_third_elt_third_elt_pkid' or \ f['child_layer'] != 'third_elt' or \ f['child_pkid'] != 'ogr_pkid': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3534,7 +3244,6 @@ def test_ogr_gmlas_internal_xlink_href(): f['parent_element_name'] != 'link_to_second_or_third_elt_second_elt_pkid' or \ f['child_layer'] != 'second_elt' or \ f['child_pkid'] != 'id': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3544,7 +3253,6 @@ def test_ogr_gmlas_internal_xlink_href(): f['parent_element_name'] != 'link_to_second_or_third_elt_third_elt_pkid' or \ f['child_layer'] != 'third_elt' or \ f['child_pkid'] != 'ogr_pkid': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' diff --git a/autotest/ogr/ogr_gpkg.py b/autotest/ogr/ogr_gpkg.py index 86ebd1933cee..96872de1a072 100755 --- a/autotest/ogr/ogr_gpkg.py +++ b/autotest/ogr/ogr_gpkg.py @@ -134,7 +134,6 @@ def test_ogr_gpkg_2(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT COUNT(*) FROM sqlite_master WHERE name = 'ogr_empty_table'") f = sql_lyr.GetNextFeature() if f.GetField(0) != 1: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -142,14 +141,12 @@ def test_ogr_gpkg_2(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('PRAGMA application_id') f = sql_lyr.GetNextFeature() if f['application_id'] != 1196444487: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('PRAGMA user_version') f = sql_lyr.GetNextFeature() if f['user_version'] != 10200: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -211,7 +208,6 @@ def test_ogr_gpkg_4(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT COUNT(*) FROM sqlite_master WHERE name = 'ogr_empty_table'") f = sql_lyr.GetNextFeature() if f.GetField(0) != 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -250,7 +246,6 @@ def test_ogr_gpkg_4(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -520,13 +515,10 @@ def test_ogr_gpkg_8(): gdaltest.gpkg_ds = gdaltest.gpkg_dr.Open('tmp/gpkg_test.gpkg', update=1) lyr = gdaltest.gpkg_ds.GetLayerByName('tbl_linestring') if lyr.GetLayerDefn().GetFieldDefn(6).GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(7).GetSubType() != ogr.OFSTInt16: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(8).GetSubType() != ogr.OFSTFloat32: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField(0) != 10 or feat.GetField(1) != 'test string 0 test' or \ @@ -534,7 +526,6 @@ def test_ogr_gpkg_8(): feat.GetField(4) != '2014/05/17 12:34:56+00' or feat.GetField(5) != 'FFFE' or \ feat.GetField(6) != 1 or feat.GetField(7) != -32768 or feat.GetField(8) != 1.23 or \ feat.GetField(9) != 1000000000000: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -647,35 +638,25 @@ def test_ogr_gpkg_12(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT * FROM tbl_linestring_renamed') if sql_lyr.GetFIDColumn() != 'fid': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetGeomType() != ogr.wkbLineString: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetGeometryColumn() != 'geom': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetSpatialRef().ExportToWkt().find('32631') < 0: - gdaltest.post_reason('fail') return 'fail' feat = sql_lyr.GetNextFeature() if feat.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetFeatureCount() != 11: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldCount() != 10: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(6).GetSubType() != ogr.OFSTBoolean: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(7).GetSubType() != ogr.OFSTInt16: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(8).GetSubType() != ogr.OFSTFloat32: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -694,53 +675,39 @@ def test_ogr_gpkg_12(): 'CAST(fld_integer64 AS INTEGER) AS FLD_INTEGER64 ' 'FROM tbl_linestring_renamed') if sql_lyr.GetFIDColumn() != 'FID': - gdaltest.post_reason('fail') print(sql_lyr.GetFIDColumn()) return 'fail' if sql_lyr.GetGeometryColumn() != 'GEOM': - gdaltest.post_reason('fail') print(sql_lyr.GetGeometryColumn()) return 'fail' if sql_lyr.GetLayerDefn().GetFieldCount() != 5: - gdaltest.post_reason('fail') print(sql_lyr.GetLayerDefn().GetFieldCount()) return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(0).GetName() != 'FLD_INTEGER': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(1).GetName() != 'FLD_STRING': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(1).GetType() != ogr.OFTString: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(2).GetName() != 'FLD_REAL': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(2).GetType() != ogr.OFTReal: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(3).GetName() != 'FLD_BINARY': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(3).GetType() != ogr.OFTBinary: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(4).GetName() != 'FLD_INTEGER64': - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldDefn(4).GetType() != ogr.OFTInteger64: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT * FROM tbl_linestring_renamed WHERE 0=1') feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -750,27 +717,21 @@ def test_ogr_gpkg_12(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL(sql) feat = sql_lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('fail') return 'fail' feat = sql_lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT sqlite_version()') feat = sql_lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetFieldCount() != 1: - gdaltest.post_reason('fail') return 'fail' if sql_lyr.GetLayerDefn().GetGeomFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -798,12 +759,10 @@ def test_ogr_gpkg_13(): feat = lyr.GetNextFeature() if not feat.IsFieldNull('fld_integer'): feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('fld_integer') != 1: feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' # Test second aspatial layer @@ -815,25 +774,20 @@ def test_ogr_gpkg_13(): gdaltest.post_reason('fail : warning NOT expected') return 'fail' if gdaltest.gpkg_ds.GetLayerCount() != 5: - gdaltest.post_reason('fail') return 'fail' lyr = gdaltest.gpkg_ds.GetLayer('non_spatial') if lyr.GetGeomType() != ogr.wkbNone: - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if not feat.IsFieldNull('fld_integer'): - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('fld_integer') != 1: feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name IS NULL AND extension_name = 'gdal_aspatial'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -853,7 +807,6 @@ def test_ogr_gpkg_14(): lyr = gdaltest.gpkg_ds.CreateLayer('point_no_spi-but-with-dashes', geom_type=ogr.wkbPoint, options=['SPATIAL_INDEX=NO'], srs=sr) if lyr.TestCapability(ogr.OLCFastSpatialFilter) != 0: - gdaltest.post_reason('fail') return 'fail' feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1000 30000000)')) @@ -877,12 +830,10 @@ def test_ogr_gpkg_14(): f = lyr.GetFeature(5) if f.GetGeometryRef() is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetFeature(6) if f.GetGeometryRef().ExportToWkt() != 'POINT EMPTY': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None @@ -891,12 +842,10 @@ def test_ogr_gpkg_14(): res = sql_lyr.TestCapability(ogr.OLCFastSpatialFilter) gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) if res != 0: - gdaltest.post_reason('fail') return 'fail' lyr = gdaltest.gpkg_ds.CreateLayer('point-with-spi-and-dashes', geom_type=ogr.wkbPoint) if lyr.TestCapability(ogr.OLCFastSpatialFilter) != 1: - gdaltest.post_reason('fail') return 'fail' feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1000 30000000)')) @@ -922,7 +871,6 @@ def test_ogr_gpkg_14(): res = sql_lyr.TestCapability(ogr.OLCFastSpatialFilter) gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) if res != 1: - gdaltest.post_reason('fail') return 'fail' # Test spatial filer right away @@ -930,11 +878,9 @@ def test_ogr_gpkg_14(): lyr.ResetReading() f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -957,7 +903,6 @@ def test_ogr_gpkg_15(): feat.GetField(3) != 1000 or feat.GetField(4) != 30000000 or \ feat.GetField(5) != 1000 or feat.GetField(6) != 30000000: feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -968,7 +913,6 @@ def test_ogr_gpkg_15(): if not feat.IsFieldNull(0) or not feat.IsFieldNull(1) or not feat.IsFieldNull(2) or \ not feat.IsFieldNull(3) or not feat.IsFieldNull(4) or not feat.IsFieldNull(5) or not feat.IsFieldNull(6): feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -985,7 +929,6 @@ def test_ogr_gpkg_15(): gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) if got_result != expected_result: print("expected_type=%s actual_type=%s expected_result=%d got_result=%d" % (expected_type, actual_type, expected_result, got_result)) - gdaltest.post_reason('fail') return 'fail' for (sql, expected_result) in [ @@ -1023,14 +966,12 @@ def test_ogr_gpkg_15(): gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) if got_result != expected_result: print(sql) - gdaltest.post_reason('fail') return 'fail' # NULL argument sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT SridFromAuthCRS(NULL, 4326)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != -1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1039,7 +980,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT SridFromAuthCRS('epsg', NULL)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != -1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1048,7 +988,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT SridFromAuthCRS('epsg', 4326)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 4326: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1057,7 +996,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT SridFromAuthCRS('epsg', 1234)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != -1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1066,7 +1004,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ImportFromEPSG(NULL)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != -1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1075,7 +1012,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ImportFromEPSG(4326)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 4326: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1084,7 +1020,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ImportFromEPSG(32633)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 32633: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1094,7 +1029,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ImportFromEPSG(0)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != -1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1103,7 +1037,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(NULL, 4326)") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1113,7 +1046,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(x'00', 4326)") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1122,7 +1054,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(geom, NULL) FROM tbl_linestring_renamed") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1132,7 +1063,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(geom, 0) FROM tbl_linestring_renamed") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1142,7 +1072,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(geom, 4326) FROM \"point-with-spi-and-dashes\"") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1152,7 +1081,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(x'0001E610000000000000000000000000000000000000000000000000000000000000000000007C04000000000000FE', 4326) FROM tbl_linestring_renamed") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef() is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1161,7 +1089,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_Transform(geom, ST_SRID(geom)) FROM tbl_linestring_renamed") feat = sql_lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (5 5,10 5,10 10,5 10)': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1169,7 +1096,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_SRID(ST_Transform(geom, 4326)) FROM tbl_linestring_renamed") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 4326: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1178,7 +1104,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_SRID(ST_Transform(x'0001E610000000000000000000000000000000000000000000000000000000000000000000007C0400000000000000FE', 4326)) FROM tbl_linestring_renamed") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 4326: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1187,7 +1112,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_MinX(x'00')") feat = sql_lyr.GetNextFeature() if feat.IsFieldSetAndNotNull(0): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1197,7 +1121,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_MinX(x'0001020304050607')") feat = sql_lyr.GetNextFeature() if feat.IsFieldSetAndNotNull(0): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1207,7 +1130,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_GeometryType(x'4750001100000000')") feat = sql_lyr.GetNextFeature() if feat.IsFieldSetAndNotNull(0): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1217,7 +1139,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_GeometryType(x'475000110000000001040000')") feat = sql_lyr.GetNextFeature() if feat.IsFieldSetAndNotNull(0): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1227,7 +1148,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_GeometryType(x'47500011000000000104000000')") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 'MULTIPOINT': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1237,7 +1157,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_GeometryType(x'00010000000000000000000000000000000000000000000000000000000000000000000000007C0400000000000000FE')") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 'MULTIPOINT': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1247,7 +1166,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_IsEmpty(x'00010000000000000000000000000000000000000000000000000000000000000000000000007C0400000000000000FE')") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 1: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1258,7 +1176,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT ST_GeometryType(x'475000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')") feat = sql_lyr.GetNextFeature() if feat.IsFieldSetAndNotNull(0): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1280,7 +1197,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT hstore_get_value('a=>b', 'a')") feat = sql_lyr.GetNextFeature() if feat.GetField(0) != 'b': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1290,7 +1206,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT hstore_get_value('a=>b', 'x')") feat = sql_lyr.GetNextFeature() if feat.GetField(0) is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1300,7 +1215,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT hstore_get_value('a=>b', NULL)") feat = sql_lyr.GetNextFeature() if feat.GetField(0) is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1310,7 +1224,6 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT hstore_get_value(NULL, 'a')") feat = sql_lyr.GetNextFeature() if feat.GetField(0) is not None: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = None @@ -1332,11 +1245,9 @@ def test_ogr_gpkg_15(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL( "SELECT ST_Buffer(geom, 0) FROM tbl_linestring_renamed") if sql_lyr.GetGeomType() != ogr.wkbPolygon: - gdaltest.post_reason('fail') print(sql_lyr.GetGeomType()) return 'fail' if sql_lyr.GetSpatialRef().ExportToWkt().find('32631') < 0: - gdaltest.post_reason('fail') print(sql_lyr.GetSpatialRef()) return 'fail' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) @@ -1519,17 +1430,14 @@ def test_ogr_gpkg_18(): lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbCircularString: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() g = f.GetGeometryRef() if g.GetGeometryType() != ogr.wkbCircularString: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'wkbCircularString' AND extension_name = 'gpkg_geom_CIRCULARSTRING'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -1546,7 +1454,6 @@ def test_ogr_gpkg_18(): sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'test' AND extension_name = 'gpkg_geom_CIRCULARSTRING'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -1561,7 +1468,6 @@ def test_ogr_gpkg_18(): f = lyr.GetNextFeature() g = f.GetGeometryRef() if g.GetGeometryType() != ogr.wkbCircularString: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -1572,7 +1478,6 @@ def test_ogr_gpkg_18(): f.SetGeometry(ogr.CreateGeometryFromWkt('CIRCULARSTRING(0 0,1 0,0 0)')) ret = lyr.CreateFeature(f) if ret != 0 or gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' f = None ds = None @@ -1584,7 +1489,6 @@ def test_ogr_gpkg_18(): ds.FlushCache() sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'test' AND extension_name = 'gpkg_geom_TRIANGLE'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -1603,7 +1507,6 @@ def test_ogr_gpkg_18(): f = None sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'test' AND extension_name LIKE 'gpkg_geom_%'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -1623,11 +1526,9 @@ def test_ogr_gpkg_19(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_19.gpkg') if ds.GetMetadata(): - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('test_without_md') if lyr.GetMetadata(): - gdaltest.post_reason('fail') return 'fail' ds.SetMetadataItem('foo', 'bar') @@ -1643,18 +1544,15 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') if ds.GetMetadataDomainList() != ['']: print(ds.GetMetadataDomainList()) - gdaltest.post_reason('fail') return 'fail' ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') if len(ds.GetMetadata()) != 1: print(ds.GetMetadata()) - gdaltest.post_reason('fail') return 'fail' ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') if ds.GetMetadataItem('foo') != 'bar': - gdaltest.post_reason('fail') print(ds.GetMetadata()) return 'fail' ds = None @@ -1669,18 +1567,15 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') lyr = ds.GetLayer('test_with_md') if lyr.GetMetadataItem('IDENTIFIER') != 'ident': - gdaltest.post_reason('fail') print(lyr.GetMetadataItem('IDENTIFIER')) return 'fail' if lyr.GetMetadataItem('DESCRIPTION') != 'desc': - gdaltest.post_reason('fail') print(lyr.GetMetadataItem('DESCRIPTION')) return 'fail' ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') if lyr.GetMetadata() != {'IDENTIFIER': 'ident', 'DESCRIPTION': 'desc'}: - gdaltest.post_reason('fail') print(lyr.GetMetadata()) return 'fail' lyr.SetMetadataItem('IDENTIFIER', 'another_ident') @@ -1693,7 +1588,6 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') if lyr.GetMetadata() != {'IDENTIFIER': 'another_ident', 'DESCRIPTION': 'another_desc'}: - gdaltest.post_reason('fail') print(lyr.GetMetadata()) return 'fail' lyr.SetMetadataItem('foo', 'bar') @@ -1703,7 +1597,6 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') if lyr.GetMetadataDomainList() != ['', 'another_domain']: - gdaltest.post_reason('fail') print(lyr.GetMetadataDomainList()) return 'fail' ds = None @@ -1711,11 +1604,9 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') if lyr.GetMetadata() != {'IDENTIFIER': 'another_ident', 'foo': 'bar', 'DESCRIPTION': 'another_desc'}: - gdaltest.post_reason('fail') print(lyr.GetMetadata()) return 'fail' if lyr.GetMetadata('another_domain') != {'bar': 'baz'}: - gdaltest.post_reason('fail') print(lyr.GetMetadata('another_domain')) return 'fail' lyr.SetMetadata(None) @@ -1725,11 +1616,9 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') if lyr.GetMetadata() != {'IDENTIFIER': 'another_ident', 'DESCRIPTION': 'another_desc'}: - gdaltest.post_reason('fail') print(lyr.GetMetadata()) return 'fail' if lyr.GetMetadataDomainList() != ['']: - gdaltest.post_reason('fail') print(lyr.GetMetadataDomainList()) return 'fail' ds = None @@ -1777,7 +1666,6 @@ def test_ogr_gpkg_20(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 1: - gdaltest.post_reason('fail') print(fc) return 'fail' @@ -1785,18 +1673,15 @@ def test_ogr_gpkg_20(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 1: - gdaltest.post_reason('fail') print(fc) return 'fail' lyr = ds.GetLayer('my_org_4326') if lyr.GetSpatialRef().ExportToWkt().find('my geogcs') < 0: - gdaltest.post_reason('fail') print(lyr.GetSpatialRef().ExportToWkt()) return 'fail' lyr = ds.GetLayer('without_org') if lyr.GetSpatialRef().ExportToWkt().find('another geogcs') < 0: - gdaltest.post_reason('fail') print(lyr.GetSpatialRef().ExportToWkt()) return 'fail' ds = None @@ -1874,14 +1759,12 @@ def test_ogr_gpkg_21(): ds = ogr.Open('/vsimem/ogr_gpkg_21.gpkg', update=1) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldDefn(0).GetWidth() != 2: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField(0, 'ab') gdal.ErrorReset() lyr.CreateFeature(f) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -1891,7 +1774,6 @@ def test_ogr_gpkg_21(): lyr.CreateFeature(f) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -1901,12 +1783,10 @@ def test_ogr_gpkg_21(): lyr.CreateFeature(f) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(f.GetFID()) if f.GetField(0) != 'abc': - gdaltest.post_reason('fail') return 'fail' gdal.Unlink('/vsimem/ogr_gpkg_21.gpkg') @@ -1924,12 +1804,10 @@ def test_ogr_gpkg_21(): lyr.CreateFeature(f) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(f.GetFID()) if f.GetField(0) != 'A_': - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -1939,14 +1817,11 @@ def test_ogr_gpkg_21(): lyr.CreateFeature(f) gdal.PopErrorHandler() if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' f = lyr.GetFeature(f.GetFID()) if f.GetField(0) != 'ab': - gdaltest.post_reason('fail') - - gdal.Unlink('/vsimem/ogr_gpkg_21.gpkg') + gdal.Unlink('/vsimem/ogr_gpkg_21.gpkg') return 'success' @@ -1975,11 +1850,9 @@ def test_ogr_gpkg_22(): ds = ogr.Open('/vsimem/ogr_gpkg_22.gpkg') lyr = ds.GetLayerByName('test') if lyr.GetMetadataItem(ogr.OLMD_FID64) is None: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 1234567890123: - gdaltest.post_reason('failure') return 'fail' gdal.Unlink('/vsimem/ogr_gpkg_22.gpkg') @@ -2019,7 +1892,6 @@ def test_ogr_gpkg_23(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -2030,7 +1902,6 @@ def test_ogr_gpkg_23(): ret = lyr.CreateFeature(f) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = None @@ -2042,7 +1913,6 @@ def test_ogr_gpkg_23(): ret = lyr.CreateGeomField(ogr.GeomFieldDefn('foo', ogr.wkbPoint)) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -2067,7 +1937,6 @@ def test_ogr_gpkg_23(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 2: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions") @@ -2076,14 +1945,12 @@ def test_ogr_gpkg_23(): ds.ReleaseResultSet(sql_lyr) if fc != 2: # r-tree and aspatial print(fc) - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 2: - gdaltest.post_reason('fail') return 'fail' field_defn = ogr.GeomFieldDefn('geomfield_not_nullable', ogr.wkbPoint) @@ -2094,7 +1961,6 @@ def test_ogr_gpkg_23(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 3: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions") @@ -2103,14 +1969,12 @@ def test_ogr_gpkg_23(): ds.ReleaseResultSet(sql_lyr) if fc != 1: # r-tree print(fc) - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 3: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -2122,7 +1986,6 @@ def test_ogr_gpkg_23(): # Not Nullable geometry field lyr = ds.CreateLayer('test4', geom_type=ogr.wkbPoint, options=['GEOMETRY_NULLABLE=NO']) if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)')) @@ -2139,39 +2002,30 @@ def test_ogr_gpkg_23(): field_defn = ogr.GeomFieldDefn('', ogr.wkbPoint) with gdaltest.error_handler(): if lyr.CreateGeomField(field_defn) == 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('test') if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('test2') if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('test3') if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('test4') if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2259,35 +2113,26 @@ def test_ogr_gpkg_24(): ds = ogr.Open('/vsimem/ogr_gpkg_24.gpkg', update=1) lyr = ds.GetLayerByName('test') if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() != "'a''b'": - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_int')).GetDefault() != '123': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault() != '1.23': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nodefault')).GetDefault() is not None: - gdaltest.post_reason('fail') return 'fail' # Translated from "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))" to CURRENT_TIMESTAMP if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime')).GetDefault() != 'CURRENT_TIMESTAMP': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime2')).GetDefault() != "'2015/06/30 12:34:56'": - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime2')).GetDefault()) return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime3')).GetDefault() != "CURRENT_TIMESTAMP": - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime3')).GetDefault()) return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime4')).GetDefault() != "'2015/06/30 12:34:56.123'": - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime4')).GetDefault()) return 'fail' if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_date')).GetDefault() != "CURRENT_DATE": - gdaltest.post_reason('fail') return 'fail' # if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_time')).GetDefault() != "CURRENT_TIME": # gdaltest.post_reason('fail') @@ -2303,7 +2148,6 @@ def test_ogr_gpkg_24(): f.GetField('field_datetime5') != '2016/06/30 12:34:56.123+00' or \ f.GetField('field_datetime6') != '2016/06/30 12:34:56+00' or \ f.GetField('field_string2') != 'X': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2330,12 +2174,10 @@ def test_ogr_gpkg_25(): ret = lyr.CreateField(ogr.FieldDefn('myfid', ogr.OFTString)) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ret = lyr.CreateField(ogr.FieldDefn('myfid', ogr.OFTInteger)) if ret != 0: - gdaltest.post_reason('fail') return 'fail' lyr.CreateField(ogr.FieldDefn('str2', ogr.OFTString)) @@ -2345,31 +2187,25 @@ def test_ogr_gpkg_25(): feat.SetField('str2', 'second string') ret = lyr.CreateFeature(feat) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if feat.GetFID() != 10: - gdaltest.post_reason('fail') return 'fail' feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetField('str2', 'second string') ret = lyr.CreateFeature(feat) if ret != 0: - gdaltest.post_reason('fail') return 'fail' if feat.GetFID() < 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if feat.GetField('myfid') != feat.GetFID(): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat.SetField('str', 'foo') ret = lyr.SetFeature(feat) if ret != 0: - gdaltest.post_reason('fail') return 'fail' feat = ogr.Feature(lyr.GetLayerDefn()) @@ -2379,14 +2215,12 @@ def test_ogr_gpkg_25(): ret = lyr.CreateFeature(feat) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = lyr.SetFeature(feat) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' feat.UnsetField('myfid') @@ -2394,18 +2228,15 @@ def test_ogr_gpkg_25(): ret = lyr.SetFeature(feat) gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 10 or f.GetField('str') != 'first string' or f.GetField('str2') != 'second string' or f.GetField('myfid') != 10: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetFeature(f.GetFID()) if f.GetFID() != 10 or f.GetField('str') != 'first string' or f.GetField('str2') != 'second string' or f.GetField('myfid') != 10: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None @@ -2428,66 +2259,55 @@ def test_ogr_gpkg_26(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_26.gpkg') if ds.TestCapability(ogr.ODsCTransactions) != 1: - gdaltest.post_reason('fail') return 'fail' ret = ds.StartTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = ds.StartTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) ret = ds.RollbackTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = ds.RollbackTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None ds = ogr.Open('/vsimem/ogr_gpkg_26.gpkg', update=1) if ds.GetLayerCount() != 0: - gdaltest.post_reason('fail') return 'fail' ret = ds.StartTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = ds.StartTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) ret = ds.CommitTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None ds = ogr.Open('/vsimem/ogr_gpkg_26.gpkg', update=1) if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('test') @@ -2496,14 +2316,11 @@ def test_ogr_gpkg_26(): lyr.ResetReading() f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.RollbackTransaction() if lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds.StartTransaction() @@ -2512,16 +2329,13 @@ def test_ogr_gpkg_26(): lyr.ResetReading() f = lyr.GetNextFeature() if f is None or f.GetFID() != 1: - gdaltest.post_reason('fail') return 'fail' ds.CommitTransaction() # the cursor is still valid after CommitTransaction(), which isn't the case for other backends such as PG ! f = lyr.GetNextFeature() if f is None or f.GetFID() != 2: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' ds.StartTransaction() @@ -2533,7 +2347,6 @@ def test_ogr_gpkg_26(): ret = lyr.CreateFeature(f) ds.CommitTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds.StartTransaction() @@ -2542,7 +2355,6 @@ def test_ogr_gpkg_26(): ret = lyr.CreateFeature(f) ds.CommitTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' if False: # pylint: disable=using-constant-test @@ -2568,7 +2380,6 @@ def test_ogr_gpkg_26(): # For some reason fails with SQLite 3.6.X with 'failed to execute insert : callback requested query abort' # but not with later versions... if ret != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2603,7 +2414,6 @@ def test_ogr_gpkg_27(): sql_lyr = ds.ExecuteSQL('SELECT GeomFromGPB(geom) FROM test') f = sql_lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -2644,18 +2454,15 @@ def test_ogr_gpkg_29(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_29.gpkg') if ds.TestCapability(ogr.ODsCMeasuredGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.CreateLayer('pointm', geom_type=ogr.wkbPointM) if lyr.TestCapability(ogr.OLCMeasuredGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT M (1 2 3)')) lyr.CreateFeature(f) lyr = ds.CreateLayer('pointzm', geom_type=ogr.wkbPointZM) if lyr.TestCapability(ogr.OLCMeasuredGeometries) != 1: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)')) @@ -2669,11 +2476,9 @@ def test_ogr_gpkg_29(): ds = ogr.Open('/vsimem/ogr_gpkg_29.gpkg', update=1) lyr = ds.GetLayerByName('pointm') if lyr.GetGeomType() != ogr.wkbPointM: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT M (1 2 3)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2682,11 +2487,9 @@ def test_ogr_gpkg_29(): lyr = ds.GetLayerByName('pointzm') if lyr.GetGeomType() != ogr.wkbPointZM: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT ZM (1 2 3 4)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -2699,20 +2502,16 @@ def test_ogr_gpkg_29(): ds = ogr.Open('/vsimem/ogr_gpkg_29.gpkg') lyr = ds.GetLayerByName('pointm') if lyr.GetGeomType() != ogr.wkbPointM: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT M (1 2 3)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr = ds.GetLayerByName('pointzm') if lyr.GetGeomType() != ogr.wkbPointZM: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT ZM (1 2 3 4)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -2733,20 +2532,16 @@ def test_ogr_gpkg_30(): with gdaltest.error_handler(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_30.geopkg') if ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_30.geopkg', update=1) if ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2784,11 +2579,9 @@ def test_ogr_gpkg_31(): ds = ogr.Open('/vsimem/ogr_gpkg_31.gpkg') lyr = ds.GetLayerByName('curve') if lyr.GetGeomType() != ogr.wkbCurve: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayerByName('surface') if lyr.GetGeomType() != ogr.wkbSurface: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -2816,21 +2609,17 @@ def test_ogr_gpkg_32(): ds = ogr.Open('/vsimem/ogr_gpkg_32.gpkg') if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE table_name != 'ogr_empty_table'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns WHERE table_name != 'ogr_empty_table'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -2861,7 +2650,6 @@ def test_ogr_gpkg_33(): ds = ogr.Open('/vsimem/ogr_gpkg_33.gpkg') sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE last_change = '2000-01-01T:00:00:00.000Z' AND table_name != 'ogr_empty_table'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -2896,14 +2684,12 @@ def test_ogr_gpkg_test_ogrsf(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/gpkg_test.gpkg --config OGR_SQLITE_SYNCHRONOUS OFF') if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - gdaltest.post_reason('fail') print(ret) return 'fail' ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/gpkg_test.gpkg -sql "select * from tbl_linestring_renamed" --config OGR_SQLITE_SYNCHRONOUS OFF') if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -2948,7 +2734,6 @@ def test_ogr_gpkg_34(): gdal.VSIFCloseL(f) if content.find(layer_name) < 0: - gdaltest.post_reason('fail') return 'fail' ds = ogr.Open(dbname, update=1) @@ -2956,7 +2741,6 @@ def test_ogr_gpkg_34(): with gdaltest.error_handler(): ds.ExecuteSQL('ALTER TABLE "weird\'layer""name" RENAME TO gpkg_contents') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() ds.ExecuteSQL('ALTER TABLE "weird\'layer""name" RENAME TO "weird2\'layer""name"') @@ -2969,7 +2753,6 @@ def test_ogr_gpkg_34(): gdal.VSIFCloseL(f) if content.find(layer_name) >= 0: - gdaltest.post_reason('fail') return 'fail' layer_name = new_layer_name @@ -2977,12 +2760,10 @@ def test_ogr_gpkg_34(): with gdaltest.error_handler(): ds.ExecuteSQL('DELLAYER:does_not_exist') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() ds.ExecuteSQL('DELLAYER:' + layer_name) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds.ExecuteSQL('VACUUM') ds = None @@ -2993,7 +2774,6 @@ def test_ogr_gpkg_34(): gdal.VSIFCloseL(f) if content.find(layer_name) >= 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3011,16 +2791,13 @@ def test_ogr_gpkg_34(): ds = ogr.Open(dbname, update=1) ds.ExecuteSQL('DROP TABLE "weird2\'layer""name"') if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds.ExecuteSQL('DROP TABLE another_layer_name') if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds.ExecuteSQL('DROP TABLE "foobar"') if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.ErrorReset() ds.ExecuteSQL('VACUUM') @@ -3032,11 +2809,9 @@ def test_ogr_gpkg_34(): gdal.VSIFCloseL(f) if content.find(layer_name) >= 0: - gdaltest.post_reason('fail') return 'fail' if content.find('another_layer_name') >= 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3092,33 +2867,27 @@ def test_ogr_gpkg_35(): ds.ExecuteSQL("INSERT INTO gpkg_extensions VALUES('test', 'bar_i_will_disappear', 'extension_name', 'definition', 'scope')") if lyr.TestCapability(ogr.OLCDeleteField) != 1: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.DeleteField(-1) if ret == 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.DeleteField(lyr.GetLayerDefn().GetFieldCount()) if ret == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.DeleteField(1) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldCount() != 2: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 10 or f['foo'] != 'fooval' or f['baz'] != 'bazval' or \ f.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3126,12 +2895,10 @@ def test_ogr_gpkg_35(): ret = lyr_nonspatial.DeleteField(1) lyr.CommitTransaction() if ret != 0: - gdaltest.post_reason('fail') return 'fail' lyr_nonspatial.ResetReading() f = lyr_nonspatial.GetNextFeature() if f.GetFID() != 10 or f['foo'] != 'fooval' or f['baz'] != 'bazval': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -3145,7 +2912,6 @@ def test_ogr_gpkg_35(): with gdaltest.error_handler(): ret = lyr.DeleteField(0) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3155,7 +2921,6 @@ def test_ogr_gpkg_35(): gdal.VSIFCloseL(f) if content.find('bar_i_will_disappear') >= 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3199,50 +2964,42 @@ def test_ogr_gpkg_36(): ds.ExecuteSQL("CREATE INDEX my_idx ON test(foo)") if lyr.TestCapability(ogr.OLCAlterFieldDefn) != 1: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(-1, ogr.FieldDefn('foo'), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(1, ogr.FieldDefn('foo'), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn(lyr.GetGeometryColumn()), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn(lyr.GetFIDColumn()), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('baz'), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' new_field_defn = ogr.FieldDefn('bar', ogr.OFTReal) new_field_defn.SetSubType(ogr.OFSTFloat32) if lyr.AlterFieldDefn(0, new_field_defn, ogr.ALTER_ALL_FLAG) != 0: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f.GetFID() != 10 or f['bar'] != 10.5 or \ f.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None @@ -3250,7 +3007,6 @@ def test_ogr_gpkg_36(): lyr.StartTransaction() new_field_defn = ogr.FieldDefn('baw', ogr.OFTString) if lyr.AlterFieldDefn(0, new_field_defn, ogr.ALTER_ALL_FLAG) != 0: - gdaltest.post_reason('fail') return 'fail' lyr.CommitTransaction() @@ -3258,7 +3014,6 @@ def test_ogr_gpkg_36(): f = lyr.GetNextFeature() if f.GetFID() != 10 or f['baw'] != '10.5' or \ f.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = None @@ -3267,7 +3022,6 @@ def test_ogr_gpkg_36(): sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'my_idx'") f = sql_lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' f = None ds.ReleaseResultSet(sql_lyr) @@ -3282,7 +3036,6 @@ def test_ogr_gpkg_36(): with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('foo'), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3292,7 +3045,6 @@ def test_ogr_gpkg_36(): gdal.VSIFCloseL(f) if content.find('foo') >= 0: - gdaltest.post_reason('fail') return 'fail' gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3307,7 +3059,6 @@ def test_ogr_gpkg_36(): with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('bar'), ogr.ALTER_ALL_FLAG) if ret == 0: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ds = None @@ -3354,34 +3105,28 @@ def test_ogr_gpkg_37(): ds.ExecuteSQL("CREATE INDEX my_idx_bar ON test(bar)") if lyr.TestCapability(ogr.OLCReorderFields) != 1: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): ret = lyr.ReorderFields([-1, -1]) if ret == 0: - gdaltest.post_reason('fail') return 'fail' if lyr.ReorderFields([1, 0]) != 0: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() if lyr.GetLayerDefn().GetFieldIndex('foo') != 1 or lyr.GetLayerDefn().GetFieldIndex('bar') != 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 10 or f['foo'] != 'fooval' or f['bar'] != 'barval' or \ f.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' # Check that index has been recreated sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'my_idx_foo' OR name = 'my_idx_bar'") if sql_lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) @@ -3393,7 +3138,6 @@ def test_ogr_gpkg_37(): with gdaltest.error_handler(): ret = lyr.ReorderFields([1, 0]) if ret == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3427,25 +3171,21 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): lyr = ds.GetLayer(0) extent = lyr.GetExtent(force=0, can_return_null=True) if extent is not None: - gdaltest.post_reason('fail') print(extent) return 'fail' # Test that we can compute the extent of a layer that has none registered in gpkg_contents extent = lyr.GetExtent(force=1) if extent != (1, 3, 2, 4): - gdaltest.post_reason('fail') print(extent) return 'fail' sql_lyr = ds.ExecuteSQL('SELECT min_x, min_y, max_x, max_y FROM gpkg_contents') f = sql_lyr.GetNextFeature() if f['min_x'] != 1 or f['min_y'] != 2 or f['max_x'] != 3 or f['max_y'] != 4: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) extent = lyr.GetExtent(force=0) if extent != (1, 3, 2, 4): - gdaltest.post_reason('fail') print(extent) return 'fail' @@ -3457,14 +3197,12 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): # The extent has grown extent = lyr.GetExtent(force=0) if extent != (-3.0, 3.0, -4.0, 4.0): - gdaltest.post_reason('fail') print(extent) return 'fail' ds.ExecuteSQL('RECOMPUTE EXTENT ON test') extent = lyr.GetExtent(force=0) if extent != (-3.0, -1.0, -4.0, -2.0): - gdaltest.post_reason('fail') print(extent) return 'fail' ds = None @@ -3473,7 +3211,6 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): lyr = ds.GetLayer(0) extent = lyr.GetExtent(force=0) if extent != (-3.0, -1.0, -4.0, -2.0): - gdaltest.post_reason('fail') print(extent) return 'fail' ds = None @@ -3487,7 +3224,6 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): ds.ExecuteSQL('RECOMPUTE EXTENT ON test') extent = lyr.GetExtent(force=0, can_return_null=True) if extent is not None: - gdaltest.post_reason('fail') print(extent) return 'fail' ds = None @@ -3496,7 +3232,6 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): lyr = ds.GetLayer(0) extent = lyr.GetExtent(force=0, can_return_null=True) if extent is not None: - gdaltest.post_reason('fail') print(extent) return 'fail' ds = None @@ -3526,32 +3261,27 @@ def test_ogr_gpkg_39(): lyr = ds.CreateLayer('test_with_explicit_identifier', options=['IDENTIFIER=explicit_identifier']) if lyr is None: - gdaltest.post_reason('fail') return 'fail' # Allow overwriting lyr = ds.CreateLayer('test_with_explicit_identifier', options=['IDENTIFIER=explicit_identifier', 'OVERWRITE=YES']) if lyr is None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): lyr = ds.CreateLayer('test2', options=['IDENTIFIER=test']) if lyr is not None: - gdaltest.post_reason('fail') return 'fail' with gdaltest.error_handler(): lyr = ds.CreateLayer('test2', options=['IDENTIFIER=explicit_identifier']) if lyr is not None: - gdaltest.post_reason('fail') return 'fail' ds.ExecuteSQL("INSERT INTO gpkg_contents ( table_name, identifier, data_type ) VALUES ( 'some_table', 'another_identifier', 'some_data_type' )") with gdaltest.error_handler(): lyr = ds.CreateLayer('test2', options=['IDENTIFIER=another_identifier']) if lyr is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3575,21 +3305,17 @@ def test_ogr_gpkg_40(): ds = ogr.Open('/vsimem/ogr_gpkg_40.gpkg') if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE table_name != 'ogr_empty_table'") if sql_lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns WHERE table_name != 'ogr_empty_table'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_extensions'") if sql_lyr.GetFeatureCount() != 0: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -3622,7 +3348,6 @@ def test_ogr_gpkg_41(): with gdaltest.error_handler(): f = lyr.GetNextFeature() if f['mycol'] != 'myval' or f.GetFID() != 1: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3632,7 +3357,6 @@ def test_ogr_gpkg_41(): with gdaltest.error_handler(): f = lyr.GetFeature(1) if f['mycol'] != 'myval' or f.GetFID() != 1: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -3681,13 +3405,10 @@ def test_ogr_gpkg_42(): ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg') lyr = ds.GetLayer(0) if get_feature_count_from_gpkg_contents(ds) != 5: - gdaltest.post_reason('fail') return 'fail' if not foo_has_trigger(ds): - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastFeatureCount) == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3699,37 +3420,30 @@ def test_ogr_gpkg_42(): # Has been invalidated for now if get_feature_count_from_gpkg_contents(ds) is not None: - gdaltest.post_reason('fail') return 'fail' if foo_has_trigger(ds): - gdaltest.post_reason('fail') return 'fail' fc = lyr.GetFeatureCount() if fc != 6: - gdaltest.post_reason('fail') print(fc) return 'fail' ds.ExecuteSQL('DELETE FROM foo WHERE i = 1') if not foo_has_trigger(ds): - gdaltest.post_reason('fail') return 'fail' if get_feature_count_from_gpkg_contents(ds) is not None: - gdaltest.post_reason('fail') return 'fail' fc = lyr.GetFeatureCount() if fc != 5: - gdaltest.post_reason('fail') print(fc) return 'fail' if get_feature_count_from_gpkg_contents(ds) != 5: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3738,7 +3452,6 @@ def test_ogr_gpkg_42(): lyr = ds.GetLayer(0) fc = lyr.GetFeatureCount() if fc != 5: - gdaltest.post_reason('fail') print(fc) return 'fail' ds.ExecuteSQL('UPDATE gpkg_ogr_contents SET feature_count = NULL') @@ -3747,18 +3460,15 @@ def test_ogr_gpkg_42(): ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) lyr = ds.GetLayer(0) if get_feature_count_from_gpkg_contents(ds) is not None: - gdaltest.post_reason('fail') return 'fail' fc = lyr.GetFeatureCount() if fc != 5: - gdaltest.post_reason('fail') print(fc) return 'fail' ds = None ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) if get_feature_count_from_gpkg_contents(ds) != 5: - gdaltest.post_reason('fail') return 'fail' # So as to test that we really read from gpkg_ogr_contents @@ -3768,7 +3478,6 @@ def test_ogr_gpkg_42(): lyr = ds.GetLayer(0) fc = lyr.GetFeatureCount() if fc != 5000: - gdaltest.post_reason('fail') print(fc) return 'fail' @@ -3782,7 +3491,6 @@ def test_ogr_gpkg_42(): f = None ds.ReleaseResultSet(sql_lyr) if val != 5000: - gdaltest.post_reason('fail') return 'fail' # Test layer deletion @@ -3790,7 +3498,6 @@ def test_ogr_gpkg_42(): sql_lyr = ds.ExecuteSQL("SELECT feature_count FROM gpkg_ogr_contents WHERE table_name != 'ogr_empty_table'", dialect='DEBUG') f = sql_lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -3813,20 +3520,16 @@ def test_ogr_gpkg_42(): fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 10: - gdaltest.post_reason('fail') return 'fail' if foo_has_trigger(ds): - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) if lyr.TestCapability(ogr.OLCFastFeatureCount) != 0: - gdaltest.post_reason('fail') return 'fail' fc = lyr.GetFeatureCount() if fc != 5: - gdaltest.post_reason('fail') print(fc) return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -3835,13 +3538,11 @@ def test_ogr_gpkg_42(): lyr = ds.GetLayer(0) fc = lyr.GetFeatureCount() if fc != 6: - gdaltest.post_reason('fail') print(fc) return 'fail' ds.ExecuteSQL('DELETE FROM foo WHERE i = 1') fc = lyr.GetFeatureCount() if fc != 5: - gdaltest.post_reason('fail') print(fc) return 'fail' ds = None @@ -3876,7 +3577,6 @@ def test_ogr_gpkg_43(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/ogr_gpkg_43.gpkg') if len(ds.GetMetadata_List('SUBDATASETS')) != 2 * 1000: - gdaltest.post_reason('fail') print(len(ds.GetMetadata_List('SUBDATASETS'))) return 'fail' ds = None @@ -3885,7 +3585,6 @@ def test_ogr_gpkg_43(): ds = ogr.Open('/vsimem/ogr_gpkg_43.gpkg') gdal.SetConfigOption('OGR_TABLE_LIMIT', None) if ds.GetLayerCount() != 1000: - gdaltest.post_reason('fail') print(ds.GetLayerCount()) return 'fail' ds = None @@ -3916,19 +3615,16 @@ def test_ogr_gpkg_44(): ds = ogr.Open('/vsimem/ogr_gpkg_44.gpkg') md = ds.GetMetadata() if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' md = ds.GetLayer(0).GetMetadata() if md != {}: - gdaltest.post_reason('fail') print(md) return 'fail' sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_metadata'") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -3939,7 +3635,6 @@ def test_ogr_gpkg_44(): ds = ogr.Open('/vsimem/ogr_gpkg_44.gpkg') md = ds.GetMetadata() if md != {'FOO': 'BAR'}: - gdaltest.post_reason('fail') print(md) return 'fail' ds = None @@ -3964,10 +3659,8 @@ def test_ogr_gpkg_45(): ds = ogr.Open('/vsimem/ogr_gpkg_45.gpkg') lyr = ds.GetLayer(0) if lyr.GetFIDColumn() != '': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldCount() != 2: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4009,11 +3702,9 @@ def test_ogr_gpkg_46(): ds = ogr.Open('/vsimem/ogr_gpkg_46.gpkg', update=1) lyr = ds.GetLayerByName('my_view') if lyr.GetLayerDefn().GetFieldCount() != 1: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) return 'fail' if lyr.GetGeometryColumn() != 'my_geom': - gdaltest.post_reason('fail') print(lyr.GetGeometryColumn()) return 'fail' @@ -4040,51 +3731,41 @@ def test_ogr_gpkg_46(): # Effectively test spatial index lyr.SetSpatialFilterRect(-0.5, -0.5, 0.5, 0.5) if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is None: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f is not None: - gdaltest.post_reason('fail') return 'fail' # View with FID lyr = ds.GetLayerByName('my_view2') if lyr.GetLayerDefn().GetFieldCount() != 1: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) return 'fail' if lyr.GetFIDColumn() != 'OGC_FID': - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 1 or f.GetField(0) != 'bla': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' # View without valid rowid lyr = ds.GetLayerByName('my_view3') if lyr.GetLayerDefn().GetFieldCount() != 2: - gdaltest.post_reason('fail') print(lyr.GetLayerDefn().GetFieldCount()) return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 0: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetFID() != 1: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f2 = lyr.GetFeature(1) if not f.Equal(f2): - gdaltest.post_reason('fail') f.DumpReadable() f2.DumpReadable() return 'fail' @@ -4114,17 +3795,14 @@ def test_ogr_gpkg_47(): with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) if ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', 'NO') ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') print(gdal.GetLastErrorMsg()) return 'fail' @@ -4138,10 +3816,8 @@ def test_ogr_gpkg_47(): with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) if ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4149,7 +3825,6 @@ def test_ogr_gpkg_47(): ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' # Set GPKG 1.2.1 @@ -4162,10 +3837,8 @@ def test_ogr_gpkg_47(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) if ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4173,7 +3846,6 @@ def test_ogr_gpkg_47(): ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' # Set GPKG 1.3.0 @@ -4187,17 +3859,14 @@ def test_ogr_gpkg_47(): with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) if ds is None: - gdaltest.post_reason('fail') return 'fail' if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail') return 'fail' gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', 'NO') ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail') return 'fail' # Just for the sake of coverage testing in DEBUG mode @@ -4235,7 +3904,6 @@ def test_ogr_gpkg_47(): gdal.VSIFCloseL(fzip) ds = ogr.Open('/vsizip//vsimem/ogr_gpkg_47.zip') if ds.GetDriver().GetName() != 'GPKG': - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4268,12 +3936,10 @@ def test_ogr_gpkg_48(): lyr.ResetReading() f = lyr.GetNextFeature() if f.GetField('a') != 'a' or f.GetField('b') is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = lyr.GetNextFeature() if f.GetField('b') != 'b' or f.GetField('c') != 'c' or f.GetField('a') is not None: - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' @@ -4284,23 +3950,19 @@ def test_ogr_gpkg_48(): lyr.CreateField(fld_defn) f = ogr.Feature(lyr.GetLayerDefn()) if lyr.CreateFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f.GetField('foo') != 'x': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetFID(1) if lyr.SetFeature(f) != 0: - gdaltest.post_reason('fail') return 'fail' lyr.ResetReading() f = lyr.GetNextFeature() if f.GetField('foo') != 'x': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -4329,7 +3991,6 @@ def test_ogr_gpkg_49(): field_defn = ogr.GeomFieldDefn('', ogr.wkbPoint) if lyr.CreateGeomField(field_defn) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4371,16 +4032,13 @@ def test_ogr_gpkg_50(): ds = ogr.Open('/vsimem/ogr_gpkg_50.gpkg') lyr = ds.GetLayer('test') if not lyr.GetSpatialRef().IsSame(srs32631): - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer('without_org') if not lyr.GetSpatialRef().IsSame(srs_without_org): - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL('SELECT definition_12_063 FROM gpkg_spatial_ref_sys WHERE srs_id = 32631') f = sql_lyr.GetNextFeature() if f.GetField(0) != 'undefined': - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(sql_lyr) ds = None @@ -4441,7 +4099,6 @@ def test_ogr_gpkg_53(): ds = ogr.Open('data/poly_inconsistent_case.gpkg.sql') if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) f = lyr.GetNextFeature() @@ -4453,7 +4110,6 @@ def test_ogr_gpkg_53(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' data/poly_inconsistent_case.gpkg.sql') if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - gdaltest.post_reason('fail') print(ret) return 'fail' @@ -4513,13 +4169,11 @@ def test_ogr_gpkg_54(): lyr1 = ds.GetLayer(0) f = lyr1.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (5 6)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' lyr2 = ds.GetLayer(1) f = lyr2.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (7 8)': - gdaltest.post_reason('fail') f.DumpReadable() return 'fail' ds = None @@ -4777,7 +4431,6 @@ def test_ogr_gpkg_json(): fld_defn.SetSubType(ogr.OFSTJSON) lyr.CreateField(fld_defn) if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: - gdaltest.post_reason('fail') return 'fail' ds.ReleaseResultSet(ds.ExecuteSQL('SELECT 1 FROM test')) # will crystalize @@ -4786,7 +4439,6 @@ def test_ogr_gpkg_json(): fld_defn.SetSubType(ogr.OFSTJSON) lyr.CreateField(fld_defn) if lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTJSON: - gdaltest.post_reason('fail') return 'fail' fld_defn = ogr.FieldDefn('test_string', ogr.OFTString) @@ -4797,28 +4449,23 @@ def test_ogr_gpkg_json(): ds = ogr.Open(filename, update = 1) lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTJSON: - gdaltest.post_reason('fail') return 'fail' # Demote field from JSON new_defn = ogr.FieldDefn('test_was_json_now_string', ogr.OFTString) if lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test2_json'), new_defn, ogr.ALTER_ALL_FLAG) != 0: - gdaltest.post_reason('fail') return 'fail' # Alter field to JSON new_defn = ogr.FieldDefn('test_was_string_now_json', ogr.OFTString) new_defn.SetSubType(ogr.OFSTJSON) if lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test_string'), new_defn, ogr.ALTER_ALL_FLAG) != 0: - gdaltest.post_reason('fail') return 'fail' # Delete JSON field if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('test_json')) != 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -4831,18 +4478,15 @@ def test_ogr_gpkg_json(): lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldDefn( lyr.GetLayerDefn().GetFieldIndex('test_was_json_now_string')).GetSubType() != ogr.OFSTNone: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn( lyr.GetLayerDefn().GetFieldIndex('test_was_string_now_json')).GetSubType() != ogr.OFSTJSON: - gdaltest.post_reason('fail') return 'fail' sql_lyr = ds.ExecuteSQL("SELECT 1 FROM gpkg_data_columns WHERE table_name = 'test'") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) if fc != 1: # only test_was_string_now_json remaining - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/ogr/ogr_idrisi.py b/autotest/ogr/ogr_idrisi.py index 95c71b567e19..31f9303ece09 100755 --- a/autotest/ogr/ogr_idrisi.py +++ b/autotest/ogr/ogr_idrisi.py @@ -43,79 +43,63 @@ def test_ogr_idrisi_1(): ds = ogr.Open('data/points.vct') if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbPoint: - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(1).GetName() != 'IntegerField': - gdaltest.post_reason('fail') return 'fail' if lyr.GetLayerDefn().GetFieldDefn(1).GetType() != ogr.OFTInteger: - gdaltest.post_reason('fail') return 'fail' sr = lyr.GetSpatialRef() if sr.ExportToWkt().find('PROJCS["UTM Zone 31, Northern Hemisphere"') != 0: - gdaltest.post_reason('fail') print(sr.ExportToWkt()) return 'fail' if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastGetExtent) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetExtent() != (400000.0, 600000.0, 4000000.0, 5000000.0): - gdaltest.post_reason('fail') print(lyr.GetExtent()) return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 1.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if feat.GetFieldAsInteger(1) != 2: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if feat.GetFieldAsDouble(2) != 3.45: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if feat.GetFieldAsString(3) != 'foo': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if ogrtest.check_feature_geometry(feat, ogr.CreateGeometryFromWkt('POINT(400000 5000000)')) != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 2.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if ogrtest.check_feature_geometry(feat, ogr.CreateGeometryFromWkt('POINT (600000 4000000)')) != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -123,7 +107,6 @@ def test_ogr_idrisi_1(): lyr.ResetReading() feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 2.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -131,7 +114,6 @@ def test_ogr_idrisi_1(): lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -146,50 +128,40 @@ def test_ogr_idrisi_2(): ds = ogr.Open('data/lines.vct') if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbLineString: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastGetExtent) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetExtent() != (400000.0, 600000.0, 4000000.0, 5000000.0): - gdaltest.post_reason('fail') print(lyr.GetExtent()) return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 10.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if ogrtest.check_feature_geometry(feat, ogr.CreateGeometryFromWkt('LINESTRING (400000 5000000,600000 4500000)')) != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 20.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if ogrtest.check_feature_geometry(feat, ogr.CreateGeometryFromWkt('LINESTRING (450000 4000000,550000 4500000)')) != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -197,7 +169,6 @@ def test_ogr_idrisi_2(): lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -212,50 +183,40 @@ def test_ogr_idrisi_3(): ds = ogr.Open('data/polygons.vct') if ds is None: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) if lyr.GetGeomType() != ogr.wkbPolygon: - gdaltest.post_reason('fail') return 'fail' if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCFastGetExtent) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.GetExtent() != (400000.0, 600000.0, 4000000.0, 5000000.0): - gdaltest.post_reason('fail') print(lyr.GetExtent()) return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 1.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if ogrtest.check_feature_geometry(feat, ogr.CreateGeometryFromWkt('POLYGON ((400000 4000000,400000 5000000,600000 5000000,600000 4000000,400000 4000000),(450000 4250000,450000 4750000,550000 4750000,550000 4250000,450000 4250000))')) != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 2.0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' if ogrtest.check_feature_geometry(feat, ogr.CreateGeometryFromWkt('POLYGON ((400000 4000000,400000 5000000,600000 5000000,600000 4000000,400000 4000000))')) != 0: - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' @@ -263,7 +224,6 @@ def test_ogr_idrisi_3(): lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('fail') return 'fail' ds = None diff --git a/autotest/ogr/ogr_index_test.py b/autotest/ogr/ogr_index_test.py index 72fab8dcc0e5..3d6e96d22afb 100755 --- a/autotest/ogr/ogr_index_test.py +++ b/autotest/ogr/ogr_index_test.py @@ -304,119 +304,102 @@ def test_ogr_index_10(): lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('intfield = 1') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('intfield IN (2)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('intfield IN (1.0)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('intfield = 1.0') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('intfield IN (1.1)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter("intfield IN ('1')") lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('realfield IN (1.0)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('realfield = 1.0') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('realfield IN (1.1)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('realfield IN (1)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('realfield = 1') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter('realfield IN (2)') lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter("realfield IN ('1')") lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter("strfield IN ('foo')") lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter("strfield = 'foo'") lyr.ResetReading() feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' lyr.SetAttributeFilter("strfield IN ('bar')") lyr.ResetReading() feat = lyr.GetNextFeature() if feat is not None: - gdaltest.post_reason('failed') return 'fail' ds = None @@ -433,10 +416,8 @@ def ogr_index_11_check(lyr, expected_fids): for expected_fid in expected_fids: feat = lyr.GetNextFeature() if feat is None: - gdaltest.post_reason('failed') return 'fail' if feat.GetFID() != expected_fid: - gdaltest.post_reason('failed') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_jml.py b/autotest/ogr/ogr_jml.py index 04b7c464915d..916dbed55147 100755 --- a/autotest/ogr/ogr_jml.py +++ b/autotest/ogr/ogr_jml.py @@ -61,16 +61,12 @@ def test_ogr_jml_1(): ds = ogr.Open('data/test.jml') if ds.GetLayerCount() != 1: - gdaltest.post_reason('fail') return 'fail' if ds.GetLayer(1) is not None: - gdaltest.post_reason('fail') return 'fail' if ds.TestCapability(ogr.ODsCCreateLayer) != 0: - gdaltest.post_reason('fail') return 'fail' if ds.TestCapability(ogr.ODsCDeleteLayer) != 0: - gdaltest.post_reason('fail') return 'fail' lyr = ds.GetLayer(0) fields = [('first_property', ogr.OFTString), @@ -85,13 +81,11 @@ def test_ogr_jml_1(): ('R_G_B', ogr.OFTString), ('not_ignored', ogr.OFTString)] if lyr.GetLayerDefn().GetFieldCount() != len(fields): - gdaltest.post_reason('fail') return 'fail' for i, field in enumerate(fields): field_defn = lyr.GetLayerDefn().GetFieldDefn(i) if field_defn.GetName() != field[0] or field_defn.GetType() != field[1]: print(i) - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetField('first_property') != 'even' or \ @@ -108,7 +102,6 @@ def test_ogr_jml_1(): feat.GetStyleString() != 'BRUSH(fc:#0000FF)' or \ feat.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 10,10 10,10 0,0 0))': feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() @@ -117,13 +110,11 @@ def test_ogr_jml_1(): feat.GetStyleString() != 'PEN(c:#FF00FF)' or \ feat.GetGeometryRef().ExportToWkt() != 'POINT (-1 -1)': feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef() is not None: feat.DumpReadable() - gdaltest.post_reason('fail') return 'fail' return 'success' @@ -170,7 +161,6 @@ def test_ogr_jml_2(): """: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -192,16 +182,12 @@ def test_ogr_jml_2(): lyr.CreateField(ogr.FieldDefn('time_as_str', ogr.OFTTime)) if lyr.TestCapability(ogr.OLCCreateField) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCSequentialWrite) != 1: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCRandomWrite) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.TestCapability(ogr.OLCStringsAsUTF8) != 1: - gdaltest.post_reason('fail') return 'fail' # empty feature @@ -209,10 +195,8 @@ def test_ogr_jml_2(): lyr.CreateFeature(f) if lyr.TestCapability(ogr.OLCCreateField) != 0: - gdaltest.post_reason('fail') return 'fail' if lyr.CreateField(ogr.FieldDefn('that_wont_work')) == 0: - gdaltest.post_reason('fail') return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) @@ -344,7 +328,6 @@ def test_ogr_jml_2(): """: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -372,7 +355,6 @@ def test_ogr_jml_2(): gdal.VSIFCloseL(f) if data.find('112233') < 0 or data.find('445566') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -391,7 +373,6 @@ def test_ogr_jml_2(): gdal.VSIFCloseL(f) if data.find('R_G_B') >= 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -411,7 +392,6 @@ def test_ogr_jml_2(): gdal.VSIFCloseL(f) if data.find('OGR_STYLE') < 0 or data.find('PEN(c:#445566)') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -433,7 +413,6 @@ def test_ogr_jml_2(): gdal.VSIFCloseL(f) if data.find('OGR_STYLE') < 0 or data.find('PEN(c:#445566)') < 0 or data.find('112233') < 0: - gdaltest.post_reason('fail') print(data) return 'fail' @@ -491,7 +470,6 @@ def test_ogr_jml_4(): lyr.GetLayerDefn() gdal.PopErrorHandler() if gdal.GetLastErrorType() == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -515,7 +493,6 @@ def test_ogr_jml_4(): lyr.GetLayerDefn() gdal.PopErrorHandler() if gdal.GetLastErrorType() == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -545,7 +522,6 @@ def test_ogr_jml_4(): lyr.GetLayerDefn().GetFieldCount() gdal.PopErrorHandler() if gdal.GetLastErrorType() == 0: - gdaltest.post_reason('fail') return 'fail' ds = None @@ -576,7 +552,6 @@ def test_ogr_jml_4(): lyr.GetLayerDefn().GetFieldCount() gdal.PopErrorHandler() if gdal.GetLastErrorType() == 0: - gdaltest.post_reason('fail') return 'fail' del ds @@ -646,7 +621,6 @@ def test_ogr_jml_4(): ds = ogr.Open('/vsimem/ogr_jml.jml') lyr = ds.GetLayer(0) if lyr.GetLayerDefn().GetFieldCount() != 0: - gdaltest.post_reason('fail') return 'fail' lyr.GetNextFeature() ds = None @@ -665,11 +639,9 @@ def test_ogr_jml_read_srs(): ds = ogr.Open('data/one_point_srid_4326.jml') lyr = ds.GetLayer(0) if lyr.GetSpatialRef().ExportToWkt().find('4326') < 0: - gdaltest.post_reason('fail') return 'fail' f = lyr.GetNextFeature() if f.GetGeometryRef() is None: - gdaltest.post_reason('fail') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_join_test.py b/autotest/ogr/ogr_join_test.py index 9e4f065c5abe..7dceca704427 100755 --- a/autotest/ogr/ogr_join_test.py +++ b/autotest/ogr/ogr_join_test.py @@ -330,12 +330,10 @@ def test_ogr_join_15(): gdal.Unlink('/vsimem/ogr_join_14') if val1 != 'c2': - gdaltest.post_reason('fail') print(val1) return 'fail' if val2 != 'c2': - gdaltest.post_reason('fail') print(val2) return 'fail' @@ -489,7 +487,6 @@ def test_ogr_join_22(): ds = None if val != '2': - gdaltest.post_reason('fail') print(val) return 'fail' @@ -515,12 +512,10 @@ def test_ogr_join_23(): sql_lyr = ds.ExecuteSQL("SELECT * FROM first JOIN second ON first.f = second.f") feat = sql_lyr.GetNextFeature() if feat.IsFieldSetAndNotNull('second.f'): - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' feat = sql_lyr.GetNextFeature() if feat['f'] != 'key1' or feat['second.f'] != 'key1': - gdaltest.post_reason('fail') feat.DumpReadable() return 'fail' ds.ReleaseResultSet(sql_lyr) diff --git a/autotest/ogr/ogr_kml.py b/autotest/ogr/ogr_kml.py index ee3c3752dacc..67c2694e4547 100755 --- a/autotest/ogr/ogr_kml.py +++ b/autotest/ogr/ogr_kml.py @@ -649,7 +649,6 @@ def test_ogr_kml_read_empty(): ds = ogr.Open('data/empty.kml') if ds.GetLayerCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' @@ -666,17 +665,14 @@ def test_ogr_kml_read_emptylayers(): ds = ogr.Open('data/emptylayers.kml') if ds.GetLayerCount() != 2: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' if ds.GetLayer(0).GetFeatureCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayer(0).GetFeatureCount()) return 'fail' if ds.GetLayer(1).GetFeatureCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayer(1).GetFeatureCount()) return 'fail' @@ -690,12 +686,10 @@ def compare_output(content, expected_content): expected_lines = expected_content.strip().split('\n') if len(content_lines) != len(expected_lines): - gdaltest.post_reason('fail') print(content) return 'fail' for i, content_line in enumerate(content_lines): if content_line.strip() != expected_lines[i].strip(): - gdaltest.post_reason('fail') print(content) return 'fail' @@ -844,12 +838,10 @@ def test_ogr_kml_read_folder_with_subfolder_placemark(): ds = ogr.Open('data/folder_with_subfolder_placemark.kml') if ds.GetLayerCount() != 1: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' if ds.GetLayer(0).GetFeatureCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayer(0).GetFeatureCount()) return 'fail' @@ -882,12 +874,10 @@ def test_ogr_kml_read_weird_empty_folders(): ds = ogr.Open('data/weird_empty_folders.kml') if ds.GetLayerCount() != 1: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' if ds.GetLayer(0).GetFeatureCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayer(0).GetFeatureCount()) return 'fail' @@ -938,12 +928,10 @@ def test_ogr_kml_read_duplicate_folder_name(): ds = ogr.Open('data/duplicate_folder_name.kml') lyr = ds.GetLayer(0) if lyr.GetName() != 'layer': - gdaltest.post_reason('failure') print(lyr.GetName()) return 'fail' lyr = ds.GetLayer(1) if lyr.GetName() != 'layer (#2)': - gdaltest.post_reason('failure') print(lyr.GetName()) return 'fail' @@ -961,18 +949,14 @@ def test_ogr_kml_read_placemark_in_root_and_subfolder(): ds = ogr.Open('data/placemark_in_root_and_subfolder.kml') lyr = ds.GetLayerByName('TopLevel') if lyr is None: - gdaltest.post_reason('failure') return 'fail' if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('failure') return 'fail' lyr = ds.GetLayerByName('SubFolder1') if lyr is None: - gdaltest.post_reason('failure') return 'fail' if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('failure') return 'fail' return 'success' diff --git a/autotest/ogr/ogr_libkml.py b/autotest/ogr/ogr_libkml.py index 8e40d0340920..000db62e2cfd 100755 --- a/autotest/ogr/ogr_libkml.py +++ b/autotest/ogr/ogr_libkml.py @@ -694,7 +694,6 @@ def test_ogr_libkml_read_empty(): ds = ogr.Open('data/empty.kml') if ds.GetLayerCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' @@ -713,18 +712,15 @@ def test_ogr_libkml_read_emptylayers(): ds = ogr.Open('data/emptylayers.kml') if ds.GetLayerCount() != 2: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' # --> One difference with the old KML driver if ds.GetLayer(0).GetFeatureCount() != 1: - gdaltest.post_reason('failed') print(ds.GetLayer(0).GetFeatureCount()) return 'fail' if ds.GetLayer(1).GetFeatureCount() != 0: - gdaltest.post_reason('failed') print(ds.GetLayer(1).GetFeatureCount()) return 'fail' @@ -746,13 +742,11 @@ def test_ogr_libkml_read_emptylayers_without_folder(): ds = ogr.Open('data/emptylayers_without_folder.kml') if ds.GetLayerCount() != 1: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' # --> One difference with the old KML driver if ds.GetLayer(0).GetName() != 'Test': - gdaltest.post_reason('failed') print("Layer name must be '" + ds.GetLayer(0).GetName() + "'.") return 'fail' @@ -771,32 +765,27 @@ def test_ogr_libkml_read_schema(): ds = ogr.Open('data/test_schema.kml') if ds.GetLayerCount() != 4: - gdaltest.post_reason('failed') print(ds.GetLayerCount()) return 'fail' lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('foo') != 'bar': - gdaltest.post_reason('failed') feat.DumpReadable() return 'fail' lyr = ds.GetLayer(1) feat = lyr.GetNextFeature() if feat.GetField('foo') != 'baz': - gdaltest.post_reason('failed') feat.DumpReadable() return 'fail' lyr = ds.GetLayer(2) if lyr.GetLayerDefn().GetFieldIndex('foo') != -1: - gdaltest.post_reason('failed') return 'fail' lyr = ds.GetLayer(3) if lyr.GetLayerDefn().GetFieldIndex('foo') != -1: - gdaltest.post_reason('failed') return 'fail' ds = None @@ -817,21 +806,17 @@ def test_ogr_libkml_extended_data_without_schema_data(): lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('field1') != '1_1': - gdaltest.post_reason('failed') feat.DumpReadable() return 'fail' if feat.GetField('field2') != '1_2': - gdaltest.post_reason('failed') feat.DumpReadable() return 'fail' feat = lyr.GetNextFeature() if feat.GetField('field1') != '2_1': - gdaltest.post_reason('failed') feat.DumpReadable() return 'fail' if feat.IsFieldSet('field2'): - gdaltest.post_reason('failed') feat.DumpReadable() return 'fail' @@ -856,7 +841,6 @@ def test_ogr_libkml_gxtrack(): feat.GetField('end') != '2013/05/28 13:00:00' or \ feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (2 49,3 50)': feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' ds = None @@ -879,7 +863,6 @@ def test_ogr_libkml_gxmultitrack(): feat.GetField('end') != '2013/05/28 13:00:00' or \ feat.GetGeometryRef().ExportToWkt() != 'MULTILINESTRING ((2 49,3 50))': feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' ds = None @@ -929,7 +912,6 @@ def test_ogr_libkml_camera(): data.find('10') == -1 or \ data.find('relativeToGround') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' ds = ogr.Open('/vsimem/ogr_libkml_camera.kml') @@ -941,7 +923,6 @@ def test_ogr_libkml_camera(): feat.GetField("tilt") != 75.0 or feat.GetField("roll") != 10.0): feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() @@ -951,7 +932,6 @@ def test_ogr_libkml_camera(): feat.IsFieldSet("roll") or feat.GetField("altitudeMode") != 'relativeToGround'): feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' ds = None @@ -984,7 +964,6 @@ def test_ogr_libkml_write_layer_lookat(): data.find('49') == -1 or \ data.find('150') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' if data.find('') == -1 or \ @@ -996,7 +975,6 @@ def test_ogr_libkml_write_layer_lookat(): data.find('150') == -1 or \ data.find('relativeToGround') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1030,7 +1008,6 @@ def test_ogr_libkml_write_layer_camera(): data.find('10') == -1 or \ data.find('relativeToGround') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1063,12 +1040,10 @@ def test_ogr_libkml_write_multigeometry(): feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'POINT (0 1 0)': feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1098,7 +1073,6 @@ def test_ogr_libkml_write_snippet(): if data.find('test_snippet') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' ds = ogr.Open("/vsimem/ogr_libkml_write_snippet.kml") @@ -1106,11 +1080,9 @@ def test_ogr_libkml_write_snippet(): feat = lyr.GetNextFeature() if feat.GetField('snippet') != 'test_snippet': feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' if feat.GetGeometryRef().ExportToWkt() != 'POINT (0 1 0)': feat.DumpReadable() - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1172,7 +1144,6 @@ def test_ogr_libkml_write_atom_link(): if data.find('') == -1 or \ data.find('') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1201,7 +1172,6 @@ def test_ogr_libkml_write_phonenumber(): if data.find('tel:911') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1238,7 +1208,6 @@ def test_ogr_libkml_write_region(): data.find('256') == -1 or \ data.find('-1') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' if data.find('90') == -1 or \ @@ -1250,7 +1219,6 @@ def test_ogr_libkml_write_region(): data.find('1') == -1 or \ data.find('2') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1291,7 +1259,6 @@ def test_ogr_libkml_write_screenoverlay(): if data.find('http://foo') == -1 or \ data.find('') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' if data.find('') == -1 or \ @@ -1300,7 +1267,6 @@ def test_ogr_libkml_write_screenoverlay(): data.find('name') == -1 or \ data.find('description') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1365,7 +1331,6 @@ def test_ogr_libkml_write_model(): data.find('http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.dae') == -1 or \ data.find('http://foo') == -1: print(data) - gdaltest.post_reason('failure') return 'fail' # This can only appear if HTTP resource is available and GDAL is built with curl/http support @@ -1375,7 +1340,6 @@ def test_ogr_libkml_write_model(): if gdaltest.gdalurlopen('http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.dae') is not None: print(data) - gdaltest.post_reason('failure') return 'fail' return 'success' @@ -1483,7 +1447,6 @@ def test_ogr_libkml_read_write_style(): if lines_got != lines_ref: print(data) print(styles) - gdaltest.post_reason('failure') return 'fail' lines_got = lines[lines.index(' @@ -662,34 +617,25 @@ def test_wmts_14(): 204,404 true -""": - print(data) - return 'fail' +""" ds = gdal.Open('/vsimem/gdal_nominal.xml') gdal.FileFromMemBuffer('/vsimem/2011-10-04/style=auto/tms/tm_18/0/0/2/1.txt', 'foo') res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') - if res != 'foo': - print(res) - return 'fail' + assert res == 'foo' res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') - if res != 'foo': - print(res) - return 'fail' + assert res == 'foo' ds = gdal.Open('/vsimem/nominal.xml') - if ds is None: - return 'fail' + assert ds is not None ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml') - if ds is None: - return 'fail' + assert ds is not None for open_options in [['URL=/vsimem/nominal.xml'], ['URL=/vsimem/nominal.xml', 'STYLE=style=auto', 'TILEMATRIXSET=tms']]: ds = gdal.OpenEx('WMTS:', open_options=open_options) - if ds is None: - return 'fail' + assert ds is not None for open_options in [['URL=/vsimem/nominal.xml', 'STYLE=x', 'TILEMATRIXSET=y'], ['URL=/vsimem/nominal.xml', 'STYLE=style=auto', 'TILEMATRIX=30'], @@ -697,44 +643,29 @@ def test_wmts_14(): gdal.PushErrorHandler() ds = gdal.OpenEx('WMTS:', open_options=open_options) gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None ds = gdal.Open('WMTS:/vsimem/nominal.xml') gdal.FileFromMemBuffer('/vsimem/2011-10-04/style=auto/tms/tm_18/0/0/2/1.txt', '') res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') - if res != """ -""": - print(res) - return 'fail' + assert res == """ +""" ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml,tilematrix=tm_0') - if ds is None: - return 'fail' - if ds.RasterXSize != 256: - print(ds.RasterXSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 256 ds = gdal.OpenEx('WMTS:/vsimem/gdal_nominal.xml', open_options=['tilematrix=tm_0']) - if ds is None: - return 'fail' - if ds.RasterXSize != 256: - print(ds.RasterXSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 256 ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml,zoom_level=0') - if ds is None: - return 'fail' - if ds.RasterXSize != 256: - print(ds.RasterXSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 256 ds = gdal.OpenEx('WMTS:/vsimem/gdal_nominal.xml', open_options=['zoom_level=0']) - if ds is None: - return 'fail' - if ds.RasterXSize != 256: - print(ds.RasterXSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 256 gdal.FileFromMemBuffer('/vsimem/gdal_nominal.xml', """ /vsimem/nominal.xml @@ -755,11 +686,8 @@ def test_wmts_14(): true """) ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 256: - print(ds.RasterXSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 256 gdal.FileFromMemBuffer('/vsimem/gdal_nominal.xml', """ /vsimem/nominal.xml @@ -780,11 +708,8 @@ def test_wmts_14(): true """) ds = gdal.Open('WMTS:/vsimem/gdal_nominal.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 256: - print(ds.RasterXSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 256 return 'success' @@ -894,16 +819,12 @@ def test_wmts_15(): """) ds = gdal.Open('/vsimem/nominal_kvp.xml?service=WMTS&request=GetCapabilities') - if ds is None: - return 'fail' - if ds.RasterXSize != 67108864: - return 'fail' + assert ds is not None + assert ds.RasterXSize == 67108864 gdal.PushErrorHandler() res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') gdal.PopErrorHandler() - if res != '': - print(res) - return 'fail' + assert res == '' gdaltest.wmts_drv.CreateCopy('/vsimem/gdal_nominal_kvp.xml', ds) ds = None @@ -911,31 +832,25 @@ def test_wmts_15(): ds = gdal.Open('/vsimem/gdal_nominal_kvp.xml') gdal.FileFromMemBuffer('/vsimem/nominal_kvp.xml?service=WMTS&request=GetFeatureInfo&version=1.0.0&layer=lyr1&style=default_style&InfoFormat=text/plain&TileMatrixSet=tms&TileMatrix=18&TileRow=0&TileCol=0&J=2&I=1&time=2011-10-04', 'bar') res = ds.GetRasterBand(1).GetMetadataItem('Pixel_1_2', 'LocationInfo') - if res != 'bar': - print(res) - return 'fail' + assert res == 'bar' ds = gdal.Open('WMTS:/vsimem/gdal_nominal_kvp.xml') - if ds is None: - return 'fail' + assert ds is not None tmp_ds = gdal.GetDriverByName('MEM').Create('', 256, 256, 4) for i in range(4): tmp_ds.GetRasterBand(i + 1).Fill((i + 1) * 255 / 4) tmp_ds = gdal.GetDriverByName('PNG').CreateCopy('/vsimem/nominal_kvp.xml?service=WMTS&request=GetTile&version=1.0.0&layer=lyr1&style=default_style&format=image/png&TileMatrixSet=tms&TileMatrix=0&TileRow=0&TileCol=0&time=2011-10-04', tmp_ds) for i in range(4): cs = ds.GetRasterBand(i + 1).GetOverview(0).Checksum() - if cs != tmp_ds.GetRasterBand(i + 1).Checksum(): - return 'fail' + assert cs == tmp_ds.GetRasterBand(i + 1).Checksum() ref_data = tmp_ds.ReadRaster(0, 0, 256, 256) got_data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 256, 256) - if ref_data != got_data: - return 'fail' + assert ref_data == got_data ref_data = tmp_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) got_data = ds.GetRasterBand(1).ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, 256, 256) - if ref_data != got_data: - return 'fail' + assert ref_data == got_data ds = None wmts_CleanCache() @@ -1007,23 +922,14 @@ def test_wmts_16(): """) ds = gdal.Open('WMTS:/vsimem/wmts_16.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 512: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 256: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 512 + assert ds.RasterYSize == 256 got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('4326') >= 0 and ds.GetProjectionRef().find('AXIS') < 0 return 'success' @@ -1092,23 +998,14 @@ def test_wmts_17(): """) ds = gdal.Open('WMTS:/vsimem/wmts_17.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 512: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 256: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 512 + assert ds.RasterYSize == 256 got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('4326') >= 0 and ds.GetProjectionRef().find('AXIS') < 0 return 'success' @@ -1177,23 +1074,14 @@ def test_wmts_18(): """) ds = gdal.Open('WMTS:/vsimem/wmts_18.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 512: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 256: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 512 + assert ds.RasterYSize == 256 got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('4326') >= 0 and ds.GetProjectionRef().find('AXIS') < 0 return 'success' @@ -1267,23 +1155,14 @@ def test_wmts_19(): """) ds = gdal.Open('WMTS:/vsimem/wmts_19.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 512: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 256: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 512 + assert ds.RasterYSize == 256 got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('4326') >= 0 and ds.GetProjectionRef().find('AXIS') < 0 return 'success' @@ -1361,23 +1240,14 @@ def test_wmts_20(): """) ds = gdal.Open('WMTS:/vsimem/wmts_20.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 512: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 256: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 512 + assert ds.RasterYSize == 256 got_gt = ds.GetGeoTransform() expected_gt = (-90, 0.3515625, 0.0, 90.0, 0.0, -0.3515625) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('4326') >= 0 and ds.GetProjectionRef().find('AXIS') < 0 return 'success' @@ -1451,23 +1321,14 @@ def test_wmts_21(): """) ds = gdal.Open('WMTS:/vsimem/wmts_21.xml,extendbeyonddateline=yes') - if ds is None: - return 'fail' - if ds.RasterXSize != 512: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 256: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 512 + assert ds.RasterYSize == 256 got_gt = ds.GetGeoTransform() expected_gt = (90, 0.3515625, 0.0, 0.0, 0.0, -0.3515625) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('4326') < 0 or ds.GetProjectionRef().find('AXIS') >= 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('4326') >= 0 and ds.GetProjectionRef().find('AXIS') < 0 tmp_ds = gdal.GetDriverByName('MEM').Create('', 256, 256, 4) for i in range(4): @@ -1479,11 +1340,9 @@ def test_wmts_21(): tmp_ds.GetRasterBand(i + 1).Fill(128) tmp0_ds = gdal.GetDriverByName('PNG').CreateCopy('/vsimem/wmts_21/default_style/tms/GoogleCRS84Quad:2/1/0.png', tmp_ds) - if ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) != tmp3_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256): - return 'fail' + assert ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) == tmp3_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) - if ds.GetRasterBand(1).ReadRaster(256, 0, 256, 256) != tmp0_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256): - return 'fail' + assert ds.GetRasterBand(1).ReadRaster(256, 0, 256, 256) == tmp0_ds.GetRasterBand(1).ReadRaster(0, 0, 256, 256) return 'success' @@ -1534,23 +1393,14 @@ def test_wmts_22(): """) ds = gdal.Open('WMTS:/vsimem/wmts_22.xml') - if ds is None: - return 'fail' - if ds.RasterXSize != 2097152: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 2097152: - print(ds.RasterYSize) - return 'fail' + assert ds is not None + assert ds.RasterXSize == 2097152 + assert ds.RasterYSize == 2097152 got_gt = ds.GetGeoTransform() expected_gt = (-548576.0, 1.0000000000004, 0.0, 8388608.0, 0.0, -1.0000000000004) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - return 'fail' - if ds.GetProjectionRef().find('3067') < 0: - print(ds.GetProjectionRef()) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 + assert ds.GetProjectionRef().find('3067') >= 0 return 'success' ############################################################################### @@ -1593,31 +1443,20 @@ def wmts_23(imagetype, expected_cs): """) tmp_ds = gdal.Open('data/wms/' + imagetype + '.png') - if tmp_ds is None: - gdaltest.post_reason('fail - cannot open tmp_ds') - return 'fail' + assert tmp_ds is not None, 'fail - cannot open tmp_ds' tile0_ds = gdal.GetDriverByName('PNG').CreateCopy(serviceUrl + '/0/0/0.png', tmp_ds) - if tile0_ds is None: - gdaltest.post_reason('fail - cannot create tile0') - return 'fail' + assert tile0_ds is not None, 'fail - cannot create tile0' ds = gdal.Open('WMTS:' + inputXml) - if ds is None: - return 'fail' + assert ds is not None - if ds.RasterXSize != 128: - print(ds.RasterXSize) - return 'fail' - if ds.RasterYSize != 128: - print(ds.RasterYSize) - return 'fail' + assert ds.RasterXSize == 128 + assert ds.RasterYSize == 128 for i in range(4): cs = ds.GetRasterBand(i + 1).Checksum() - if cs != expected_cs[i]: - print(cs) - return 'fail' + assert cs == expected_cs[i] return 'success' @@ -1691,8 +1530,7 @@ def test_wmts_invalid_global_to_tm_reprojection(): """) ds = gdal.Open('WMTS:' + inputXml) - if ds.RasterXSize != 512 or ds.RasterYSize != 1024: - return 'fail' + assert ds.RasterXSize == 512 and ds.RasterYSize == 1024 ds = None gdal.Unlink(inputXml) @@ -1959,13 +1797,9 @@ def test_wmts_check_no_overflow_zoom_level(): """) ds = gdal.Open(inputXml) - if ds.RasterXSize != 1073741766 or ds.RasterYSize != 1070224430: - print(ds.RasterXSize, ds.RasterYSize) - return 'fail' + assert ds.RasterXSize == 1073741766 and ds.RasterYSize == 1070224430 count_levels = 1 + ds.GetRasterBand(1).GetOverviewCount() - if count_levels != 23: # there are 24 in total, but we discard the one labelled 23 - print(count_levels) - return 'fail' + assert count_levels == 23 ds = None gdal.Unlink(inputXml) diff --git a/autotest/gdrivers/xyz.py b/autotest/gdrivers/xyz.py index 8950ccf20537..aaee59699139 100755 --- a/autotest/gdrivers/xyz.py +++ b/autotest/gdrivers/xyz.py @@ -57,9 +57,7 @@ def test_xyz_2(): expected_cs = src_ds.GetRasterBand(1).Checksum() ds = None gdal.GetDriverByName('XYZ').Delete('tmp/float.xyz') - if got_cs != expected_cs and got_cs != 24387: - print(got_cs) - return 'fail' + assert got_cs == expected_cs or got_cs == 24387 return 'success' ############################################################################### @@ -85,21 +83,13 @@ def test_xyz_3(): gdal.FileFromMemBuffer('/vsimem/grid.xyz', content) ds = gdal.Open('/vsimem/grid.xyz') buf = ds.ReadRaster(0, 2, 2, 1) - if struct.unpack('B' * 2, buf) != (69, 70): - print(buf) - return 'fail' + assert struct.unpack('B' * 2, buf) == (69, 70) buf = ds.ReadRaster(0, 1, 2, 1) - if struct.unpack('B' * 2, buf) != (67, 68): - print(buf) - return 'fail' + assert struct.unpack('B' * 2, buf) == (67, 68) buf = ds.ReadRaster(0, 0, 2, 1) - if struct.unpack('B' * 2, buf) != (65, 66): - print(buf) - return 'fail' + assert struct.unpack('B' * 2, buf) == (65, 66) buf = ds.ReadRaster(0, 2, 2, 1) - if struct.unpack('B' * 2, buf) != (69, 70): - print(buf) - return 'fail' + assert struct.unpack('B' * 2, buf) == (69, 70) ds = None gdal.Unlink('/vsimem/grid.xyz') return 'success' @@ -133,20 +123,13 @@ def test_xyz_4(): got_gt = ds.GetGeoTransform() expected_gt = (440660.0, 60.0, 0.0, 3751350.0, 0.0, -120.0) for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-5: - print(got_gt) - print(expected_gt) - return 'fail' - - if ds.GetRasterBand(1).GetMinimum() != 1: - return 'fail' - if ds.GetRasterBand(1).GetMaximum() != 7: - return 'fail' - if ds.GetRasterBand(1).GetNoDataValue() != 0: - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-5 + + assert ds.GetRasterBand(1).GetMinimum() == 1 + assert ds.GetRasterBand(1).GetMaximum() == 7 + assert ds.GetRasterBand(1).GetNoDataValue() == 0 for i in [0, 1, 2, 1, 0, 2, 0, 2, 0, 1, 2]: - if not xyz_4_checkline(ds, i, expected[i]): - return 'fail' + assert xyz_4_checkline(ds, i, expected[i]) ds = None gdal.Unlink('/vsimem/grid.xyz') return 'success' @@ -167,18 +150,14 @@ def test_xyz_5(): gdal.FileFromMemBuffer('/vsimem/grid.xyz', content) ds = gdal.Open('/vsimem/grid.xyz') - if ds.RasterXSize != 3 or ds.RasterYSize != 2: - return 'fail' + assert ds.RasterXSize == 3 and ds.RasterYSize == 2 got_gt = ds.GetGeoTransform() expected_gt = (-0.25, 0.5, 0.0, 0.5, 0.0, 1.0) ds = None gdal.Unlink('/vsimem/grid.xyz') for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-5: - print(got_gt) - print(expected_gt) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-5 return 'success' @@ -198,18 +177,14 @@ def test_xyz_6(): gdal.FileFromMemBuffer('/vsimem/grid.xyz', content) ds = gdal.Open('/vsimem/grid.xyz') - if ds.RasterXSize != 3 or ds.RasterYSize != 2: - return 'fail' + assert ds.RasterXSize == 3 and ds.RasterYSize == 2 got_gt = ds.GetGeoTransform() expected_gt = (-0.25, 0.5, 0.0, 0.5, 0.0, 1.0) ds = None gdal.Unlink('/vsimem/grid.xyz') for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-5: - print(got_gt) - print(expected_gt) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-5 return 'success' @@ -239,8 +214,7 @@ def test_xyz_7(): gdal.FileFromMemBuffer('/vsimem/grid.xyz', content) ds = gdal.Open('/vsimem/grid.xyz') - if ds.RasterXSize != 3 or ds.RasterYSize != 5: - return 'fail' + assert ds.RasterXSize == 3 and ds.RasterYSize == 5 got_gt = ds.GetGeoTransform() expected_gt = (354.46666625, 0.0333335, 0.0, 51.5125, 0.0, -0.025) cs = ds.GetRasterBand(1).Checksum() @@ -248,14 +222,9 @@ def test_xyz_7(): gdal.Unlink('/vsimem/grid.xyz') for i in range(6): - if abs(got_gt[i] - expected_gt[i]) > 1e-8: - print(got_gt) - print(expected_gt) - return 'fail' + assert abs(got_gt[i] - expected_gt[i]) <= 1e-8 - if cs != 146: - print(cs) - return 'fail' + assert cs == 146 return 'success' @@ -274,15 +243,12 @@ def test_xyz_8(): gdal.FileFromMemBuffer('/vsimem/grid.xyz', content) ds = gdal.Open('/vsimem/grid.xyz') - if ds.RasterXSize != 4 or ds.RasterYSize != 2: - return 'fail' + assert ds.RasterXSize == 4 and ds.RasterYSize == 2 cs = ds.GetRasterBand(1).Checksum() ds = None gdal.Unlink('/vsimem/grid.xyz') - if cs != 35: - print(cs) - return 'fail' + assert cs == 35 return 'success' diff --git a/autotest/gnm/gnm_test.py b/autotest/gnm/gnm_test.py index 814368305e37..aa1e111d9df5 100755 --- a/autotest/gnm/gnm_test.py +++ b/autotest/gnm/gnm_test.py @@ -63,17 +63,11 @@ def test_gnm_filenetwork_create(): ds = ogrtest.drv.Create('tmp/', 0, 0, 0, gdal.GDT_Unknown, options=['net_name=test_gnm', 'net_description=Test file based GNM', 'net_srs=EPSG:4326']) # cast to GNM dn = gnm.CastToNetwork(ds) - if dn is None: - return 'fail' - if dn.GetVersion() != 100: - gdaltest.post_reason('GNM: Check GNM version failed') - return 'fail' - if dn.GetName() != 'test_gnm': - gdaltest.post_reason('GNM: Check GNM name failed') - return 'fail' - if dn.GetDescription() != 'Test file based GNM': - gdaltest.post_reason('GNM: Check GNM description failed') - return 'fail' + assert dn is not None + assert dn.GetVersion() == 100, 'GNM: Check GNM version failed' + assert dn.GetName() == 'test_gnm', 'GNM: Check GNM name failed' + assert dn.GetDescription() == 'Test file based GNM', \ + 'GNM: Check GNM description failed' dn = None ogrtest.have_gnm = 1 @@ -91,17 +85,11 @@ def test_gnm_filenetwork_open(): ds = gdal.OpenEx('tmp/test_gnm') # cast to GNM dn = gnm.CastToNetwork(ds) - if dn is None: - return 'fail' - if dn.GetVersion() != 100: - gdaltest.post_reason('GNM: Check GNM version failed') - return 'fail' - if dn.GetName() != 'test_gnm': - gdaltest.post_reason('GNM: Check GNM name failed') - return 'fail' - if dn.GetDescription() != 'Test file based GNM': - gdaltest.post_reason('GNM: Check GNM description failed') - return 'fail' + assert dn is not None + assert dn.GetVersion() == 100, 'GNM: Check GNM version failed' + assert dn.GetName() == 'test_gnm', 'GNM: Check GNM name failed' + assert dn.GetDescription() == 'Test file based GNM', \ + 'GNM: Check GNM description failed' dn = None return 'success' @@ -121,9 +109,7 @@ def test_gnm_import(): dspipes = gdal.OpenEx('data/pipes.shp', gdal.OF_VECTOR) lyrpipes = dspipes.GetLayerByIndex(0) new_lyr = ds.CopyLayer(lyrpipes, 'pipes') - if new_lyr is None: - gdaltest.post_reason('failed to import pipes') - return 'fail' + assert new_lyr is not None, 'failed to import pipes' dspipes = None new_lyr = None @@ -131,15 +117,11 @@ def test_gnm_import(): dswells = gdal.OpenEx('data/wells.shp', gdal.OF_VECTOR) lyrwells = dswells.GetLayerByIndex(0) new_lyr = ds.CopyLayer(lyrwells, 'wells') - if new_lyr is None: - gdaltest.post_reason('failed to import wells') - return 'fail' + assert new_lyr is not None, 'failed to import wells' dswells = None new_lyr = None - if ds.GetLayerCount() != 2: - gdaltest.post_reason('expected 2 layers') - return 'fail' + assert ds.GetLayerCount() == 2, 'expected 2 layers' ds = None return 'success' @@ -155,14 +137,10 @@ def test_gnm_autoconnect(): ds = gdal.OpenEx('tmp/test_gnm') dgn = gnm.CastToGenericNetwork(ds) - if dgn is None: - gdaltest.post_reason('cast to GNMGenericNetwork failed') - return 'fail' + assert dgn is not None, 'cast to GNMGenericNetwork failed' ret = dgn.ConnectPointsByLines(['pipes', 'wells'], 0.000001, 1, 1, gnm.GNM_EDGE_DIR_BOTH) - if ret != 0: - gdaltest.post_reason('failed to connect') - return 'fail' + assert ret == 0, 'failed to connect' dgn = None return 'success' @@ -178,14 +156,10 @@ def test_gnm_graph_dijkstra(): ds = gdal.OpenEx('tmp/test_gnm') dn = gnm.CastToNetwork(ds) - if dn is None: - gdaltest.post_reason('cast to GNMNetwork failed') - return 'fail' + assert dn is not None, 'cast to GNMNetwork failed' lyr = dn.GetPath(61, 50, gnm.GATDijkstraShortestPath) - if lyr is None: - gdaltest.post_reason('failed to get path') - return 'fail' + assert lyr is not None, 'failed to get path' if lyr.GetFeatureCount() == 0: dn.ReleaseResultSet(lyr) @@ -209,14 +183,10 @@ def test_gnm_graph_kshortest(): ds = gdal.OpenEx('tmp/test_gnm') dn = gnm.CastToNetwork(ds) - if dn is None: - gdaltest.post_reason('cast to GNMNetwork failed') - return 'fail' + assert dn is not None, 'cast to GNMNetwork failed' lyr = dn.GetPath(61, 50, gnm.GATKShortestPath, options=['num_paths=3']) - if lyr is None: - gdaltest.post_reason('failed to get path') - return 'fail' + assert lyr is not None, 'failed to get path' if lyr.GetFeatureCount() < 20: dn.ReleaseResultSet(lyr) @@ -238,14 +208,10 @@ def test_gnm_graph_connectedcomponents(): ds = gdal.OpenEx('tmp/test_gnm') dn = gnm.CastToNetwork(ds) - if dn is None: - gdaltest.post_reason('cast to GNMNetwork failed') - return 'fail' + assert dn is not None, 'cast to GNMNetwork failed' lyr = dn.GetPath(61, 50, gnm.GATConnectedComponents) - if lyr is None: - gdaltest.post_reason('failed to get path') - return 'fail' + assert lyr is not None, 'failed to get path' if lyr.GetFeatureCount() == 0: dn.ReleaseResultSet(lyr) diff --git a/autotest/ogr/ogr_arcgen.py b/autotest/ogr/ogr_arcgen.py index 95183d8b90d0..9d724d2bf81a 100755 --- a/autotest/ogr/ogr_arcgen.py +++ b/autotest/ogr/ogr_arcgen.py @@ -42,22 +42,14 @@ def test_ogr_arcgen_points(): ds = ogr.Open('data/points.gen') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' - if ds.GetLayerCount() != 1: - gdaltest.post_reason('bad layer count') - return 'fail' + assert ds.GetLayerCount() == 1, 'bad layer count' lyr = ds.GetLayer(0) - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' - if lyr.GetGeomType() != ogr.wkbPoint: - gdaltest.post_reason('bad layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPoint, 'bad layer geometry type' feat = lyr.GetNextFeature() if feat.GetField(0) != 1: @@ -79,22 +71,14 @@ def test_ogr_arcgen_points(): def test_ogr_arcgen_points25d(): ds = ogr.Open('data/points25d.gen') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' - if ds.GetLayerCount() != 1: - gdaltest.post_reason('bad layer count') - return 'fail' + assert ds.GetLayerCount() == 1, 'bad layer count' lyr = ds.GetLayer(0) - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' - if lyr.GetGeomType() != ogr.wkbPoint25D: - gdaltest.post_reason('bad layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPoint25D, 'bad layer geometry type' feat = lyr.GetNextFeature() if feat.GetField(0) != 1: @@ -116,18 +100,12 @@ def test_ogr_arcgen_points25d(): def test_ogr_arcgen_lines(): ds = ogr.Open('data/lines.gen') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' lyr = ds.GetLayer(0) - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' - if lyr.GetGeomType() != ogr.wkbLineString: - gdaltest.post_reason('bad layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbLineString, 'bad layer geometry type' feat = lyr.GetNextFeature() if feat.GetField(0) != 1: @@ -149,18 +127,12 @@ def test_ogr_arcgen_lines(): def test_ogr_arcgen_lines25d(): ds = ogr.Open('data/lines25d.gen') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' lyr = ds.GetLayer(0) - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' - if lyr.GetGeomType() != ogr.wkbLineString25D: - gdaltest.post_reason('bad layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbLineString25D, 'bad layer geometry type' feat = lyr.GetNextFeature() if feat.GetField(0) != 1: @@ -182,18 +154,12 @@ def test_ogr_arcgen_lines25d(): def test_ogr_arcgen_polygons(): ds = ogr.Open('data/polygons.gen') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' lyr = ds.GetLayer(0) - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' - if lyr.GetGeomType() != ogr.wkbPolygon: - gdaltest.post_reason('bad layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon, 'bad layer geometry type' feat = lyr.GetNextFeature() if feat.GetField(0) != 1: @@ -215,18 +181,12 @@ def test_ogr_arcgen_polygons(): def test_ogr_arcgen_polygons25d(): ds = ogr.Open('data/polygons25d.gen') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' lyr = ds.GetLayer(0) - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' - if lyr.GetGeomType() != ogr.wkbPolygon25D: - gdaltest.post_reason('bad layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon25D, 'bad layer geometry type' feat = lyr.GetNextFeature() if feat.GetField(0) != 1: diff --git a/autotest/ogr/ogr_avc.py b/autotest/ogr/ogr_avc.py index ac54d0357e29..2fe3b07e861c 100755 --- a/autotest/ogr/ogr_avc.py +++ b/autotest/ogr/ogr_avc.py @@ -46,15 +46,13 @@ def check_content(ds): expect = ['1', '2', '3', '4', '5', '6', '7'] tr = ogrtest.check_features_against_list(lyr, 'UserID', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (340099.875 4100200.0,340400.0625 4100399.5,340900.125 4100200.0,340700.03125 4100199.5)', - max_error=0.01) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'LINESTRING (340099.875 4100200.0,340400.0625 4100399.5,340900.125 4100200.0,340700.03125 4100199.5)', + max_error=0.01) == 0) return 'success' @@ -66,9 +64,7 @@ def test_ogr_avc_1(): # Example given at Annex A of http://avce00.maptools.org/docs/v7_e00_cover.html avc_ds = ogr.Open('data/test.e00') - if avc_ds.GetLayer(0).GetSpatialRef() is None: - gdaltest.post_reason('expected SRS') - return 'fail' + assert avc_ds.GetLayer(0).GetSpatialRef() is not None, 'expected SRS' if avc_ds is not None: return check_content(avc_ds) @@ -81,9 +77,7 @@ def test_ogr_avc_1(): def test_ogr_avc_2(): avc_ds = ogr.Open('data/testavc/testavc') - if avc_ds.GetLayer(0).GetSpatialRef() is None: - gdaltest.post_reason('expected SRS') - return 'fail' + assert avc_ds.GetLayer(0).GetSpatialRef() is not None, 'expected SRS' if avc_ds is not None: return check_content(avc_ds) @@ -100,13 +94,9 @@ def test_ogr_avc_3(): gdal.PopErrorHandler() last_error_msg = gdal.GetLastErrorMsg() - if avc_ds is not None: - gdaltest.post_reason('expected failure') - return 'fail' + assert avc_ds is None, 'expected failure' - if last_error_msg == '': - gdaltest.post_reason('expected error message') - return 'fail' + assert last_error_msg != '', 'expected error message' return 'success' @@ -124,15 +114,9 @@ def test_ogr_avc_4(): for f in lyr: count += 1 last_feature = f - if count != 80: - print(filename) - print(count) - return 'fail' + assert count == 80, filename count = lyr.GetFeatureCount() - if count != 80: - print(filename) - print(count) - return 'fail' + assert count == 80, filename if last_feature.GetFieldCount() != 7: print(filename) f.DumpReadable() @@ -162,15 +146,9 @@ def test_ogr_avc_5(): for f in lyr: count += 1 last_feature = f - if count != 3: - print(filename) - print(count) - return 'fail' + assert count == 3, filename count = lyr.GetFeatureCount() - if count != 3: - print(filename) - print(count) - return 'fail' + assert count == 3, filename if last_feature.GetFieldCount() != 5: print(filename) f.DumpReadable() diff --git a/autotest/ogr/ogr_basic_test.py b/autotest/ogr/ogr_basic_test.py index 3b808af98df7..b9e970df3a97 100755 --- a/autotest/ogr/ogr_basic_test.py +++ b/autotest/ogr/ogr_basic_test.py @@ -43,8 +43,7 @@ def test_ogr_basic_1(): gdaltest.ds = ogr.Open('data/poly.shp') - if gdaltest.ds is None: - return 'fail' + assert gdaltest.ds is not None return 'success' @@ -56,20 +55,15 @@ def test_ogr_basic_2(): gdaltest.lyr = gdaltest.ds.GetLayerByName('poly') - if gdaltest.lyr.GetName() != 'poly': - return 'fail' - if gdaltest.lyr.GetGeomType() != ogr.wkbPolygon: - return 'fail' + assert gdaltest.lyr.GetName() == 'poly' + assert gdaltest.lyr.GetGeomType() == ogr.wkbPolygon - if gdaltest.lyr.GetLayerDefn().GetName() != 'poly': - return 'fail' - if gdaltest.lyr.GetLayerDefn().GetGeomType() != ogr.wkbPolygon: - return 'fail' + assert gdaltest.lyr.GetLayerDefn().GetName() == 'poly' + assert gdaltest.lyr.GetLayerDefn().GetGeomType() == ogr.wkbPolygon count = gdaltest.lyr.GetFeatureCount() - if count != 10: - gdaltest.post_reason('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) - return 'fail' + assert count == 10, \ + ('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) # Now actually iterate through counting the features and ensure they agree. gdaltest.lyr.ResetReading() @@ -80,9 +74,8 @@ def test_ogr_basic_2(): count2 = count2 + 1 feat = gdaltest.lyr.GetNextFeature() - if count2 != 10: - gdaltest.post_reason('Got wrong count with GetNextFeature() - %d, expecting 10' % count2) - return 'fail' + assert count2 == 10, \ + ('Got wrong count with GetNextFeature() - %d, expecting 10' % count2) return 'success' @@ -115,22 +108,19 @@ def test_ogr_basic_3(): gdaltest.lyr.ResetReading() count = gdaltest.lyr.GetFeatureCount() - if count != 1: - gdaltest.post_reason('Got wrong feature count with spatial filter, expected 1, got %d' % count) - return 'fail' + assert count == 1, \ + ('Got wrong feature count with spatial filter, expected 1, got %d' % count) feat1 = gdaltest.lyr.GetNextFeature() feat2 = gdaltest.lyr.GetNextFeature() - if feat1 is None or feat2 is not None: - gdaltest.post_reason('Got too few or too many features with spatial filter.') - return 'fail' + assert feat1 is not None and feat2 is None, \ + 'Got too few or too many features with spatial filter.' gdaltest.lyr.SetSpatialFilter(None) count = gdaltest.lyr.GetFeatureCount() - if count != 10: - gdaltest.post_reason('Clearing spatial query may not have worked properly, getting\n%d features instead of expected 10 features.' % count) - return 'fail' + assert count == 10, \ + ('Clearing spatial query may not have worked properly, getting\n%d features instead of expected 10 features.' % count) return 'success' @@ -140,13 +130,10 @@ def test_ogr_basic_3(): def test_ogr_basic_4(): driver = gdaltest.ds.GetDriver() - if driver is None: - gdaltest.post_reason('GetDriver() returns None') - return 'fail' + assert driver is not None, 'GetDriver() returns None' - if driver.GetName() != 'ESRI Shapefile': - gdaltest.post_reason('Got wrong driver name: ' + driver.GetName()) - return 'fail' + assert driver.GetName() == 'ESRI Shapefile', \ + ('Got wrong driver name: ' + driver.GetName()) return 'success' @@ -164,13 +151,9 @@ def test_ogr_basic_5(): gdaltest.lyr.SetAttributeFilter(None) - if feat1 is None or feat2 is not None: - gdaltest.post_reason('unexpected result count.') - return 'fail' + assert feat1 is not None and feat2 is None, 'unexpected result count.' - if feat1.GetFID() != 3: - gdaltest.post_reason('got wrong feature.') - return 'fail' + assert feat1.GetFID() == 3, 'got wrong feature.' return 'success' @@ -180,11 +163,9 @@ def test_ogr_basic_5(): def test_ogr_basic_6(): # Put inside try/except for OG python bindings - if ogr.Open('') is not None: - return 'fail' + assert ogr.Open('') is None - if ogr.Open('non_existing') is not None: - return 'fail' + assert ogr.Open('non_existing') is None return 'success' @@ -196,8 +177,7 @@ def test_ogr_basic_7(): feat_defn = ogr.FeatureDefn() feat = ogr.Feature(feat_defn) - if not feat.Equal(feat): - return 'fail' + assert feat.Equal(feat) try: feat.SetFieldIntegerList @@ -205,8 +185,7 @@ def test_ogr_basic_7(): return 'skip' feat_clone = feat.Clone() - if not feat.Equal(feat_clone): - return 'fail' + assert feat.Equal(feat_clone) # We MUST delete now as we are changing the feature defn afterwards! # Crash guaranteed otherwise @@ -420,9 +399,7 @@ def test_ogr_basic_9(): ] for geom_type_tuple in geom_type_tuples: - if ogr.GeometryTypeToName(geom_type_tuple[0]) != geom_type_tuple[1]: - print('Got %s, expected %s' % (ogr.GeometryTypeToName(geom_type_tuple[0]), geom_type_tuple[1])) - return 'fail' + assert ogr.GeometryTypeToName(geom_type_tuple[0]) == geom_type_tuple[1] return 'success' @@ -438,9 +415,7 @@ def test_ogr_basic_10(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -all_drivers') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -472,12 +447,10 @@ def test_ogr_basic_12(): # boolean integer feat_def = ogr.FeatureDefn() - if ogr.GetFieldSubTypeName(ogr.OFSTBoolean) != 'Boolean': - return 'fail' + assert ogr.GetFieldSubTypeName(ogr.OFSTBoolean) == 'Boolean' field_def = ogr.FieldDefn('fld', ogr.OFTInteger) field_def.SetSubType(ogr.OFSTBoolean) - if field_def.GetSubType() != ogr.OFSTBoolean: - return 'fail' + assert field_def.GetSubType() == ogr.OFSTBoolean feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) @@ -487,10 +460,8 @@ def test_ogr_basic_12(): gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', 2) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if f.GetField('fld') != 1: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert f.GetField('fld') == 1 f.SetField('fld', '0') f.SetField('fld', '1') @@ -498,27 +469,22 @@ def test_ogr_basic_12(): gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', '2') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if f.GetField('fld') != 1: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert f.GetField('fld') == 1 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') field_def = ogr.FieldDefn('fld', ogr.OFTString) field_def.SetSubType(ogr.OFSTBoolean) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if field_def.GetSubType() != ogr.OFSTNone: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert field_def.GetSubType() == ogr.OFSTNone # boolean list feat_def = ogr.FeatureDefn() field_def = ogr.FieldDefn('fld', ogr.OFTIntegerList) field_def.SetSubType(ogr.OFSTBoolean) - if field_def.GetSubType() != ogr.OFSTBoolean: - return 'fail' + assert field_def.GetSubType() == ogr.OFSTBoolean feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) @@ -527,20 +493,15 @@ def test_ogr_basic_12(): gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetFieldIntegerList(0, [0, 1, 2, 1]) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if f.GetField('fld') != [0, 1, 1, 1]: - print(f.GetField('fld')) - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert f.GetField('fld') == [0, 1, 1, 1] # int16 integer feat_def = ogr.FeatureDefn() - if ogr.GetFieldSubTypeName(ogr.OFSTInt16) != 'Int16': - return 'fail' + assert ogr.GetFieldSubTypeName(ogr.OFSTInt16) == 'Int16' field_def = ogr.FieldDefn('fld', ogr.OFTInteger) field_def.SetSubType(ogr.OFSTInt16) - if field_def.GetSubType() != ogr.OFSTInt16: - return 'fail' + assert field_def.GetSubType() == ogr.OFSTInt16 feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) @@ -550,51 +511,41 @@ def test_ogr_basic_12(): gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', -32769) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if f.GetField('fld') != -32768: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert f.GetField('fld') == -32768 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', 32768) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if f.GetField('fld') != 32767: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert f.GetField('fld') == 32767 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') field_def = ogr.FieldDefn('fld', ogr.OFTString) field_def.SetSubType(ogr.OFSTInt16) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if field_def.GetSubType() != ogr.OFSTNone: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert field_def.GetSubType() == ogr.OFSTNone # float32 feat_def = ogr.FeatureDefn() - if ogr.GetFieldSubTypeName(ogr.OFSTFloat32) != 'Float32': - return 'fail' + assert ogr.GetFieldSubTypeName(ogr.OFSTFloat32) == 'Float32' field_def = ogr.FieldDefn('fld', ogr.OFTReal) field_def.SetSubType(ogr.OFSTFloat32) - if field_def.GetSubType() != ogr.OFSTFloat32: - return 'fail' + assert field_def.GetSubType() == ogr.OFSTFloat32 feat_def.AddFieldDefn(field_def) if False: # pylint: disable=using-constant-test f = ogr.Feature(feat_def) gdal.ErrorReset() f.SetField('fld', '1.23') - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') f.SetField('fld', 1.230000000001) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' if abs(f.GetField('fld') - 1.23) < 1e-8: f.DumpReadable() return 'fail' @@ -604,10 +555,8 @@ def test_ogr_basic_12(): field_def = ogr.FieldDefn('fld', ogr.OFSTFloat32) field_def.SetSubType(ogr.OFSTInt16) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' - if field_def.GetSubType() != ogr.OFSTNone: - return 'fail' + assert gdal.GetLastErrorMsg() != '' + assert field_def.GetSubType() == ogr.OFSTNone return 'success' @@ -646,10 +595,7 @@ def test_ogr_basic_13(): for (val, expected_ret) in tests: f = ogr.Feature(feat_defn) f.SetField('date', val) - if f.GetField('date') != expected_ret: - print(val) - print(f.GetField('date')) - return 'fail' + assert f.GetField('date') == expected_ret, val return 'success' @@ -664,8 +610,7 @@ def test_ogr_basic_14(): ds = ogr.Open('.') os.chdir('../..') - if ds is not None: - return 'fail' + assert ds is None os.rmdir('tmp/ogr_basic_14') @@ -686,9 +631,7 @@ def test_ogr_basic_15(): lyr.CreateFeature(ogr.Feature(lyr.GetLayerDefn())) except RuntimeError as e: ok = str(e).find('CreateFeature : unsupported operation on a read-only datasource') >= 0 - if not ok: - print('Got: %s' + str(e)) - return 'fail' + assert ok, ('Got: %s' + str(e)) return 'success' finally: if used_exceptions_before == 0: @@ -715,8 +658,7 @@ def ogr_basic_16_gen_list(N): def test_ogr_basic_16(): - if list(ogr_basic_16_gen_list(2)) != [0, 1]: - return 'fail' + assert list(ogr_basic_16_gen_list(2)) == [0, 1] return 'success' @@ -753,19 +695,13 @@ def test_ogr_basic_dataset_slice(): ds.CreateLayer('lyr3') lyrs = [lyr.GetName() for lyr in ds[1:3]] - if lyrs != ['lyr2', 'lyr3']: - print(lyrs) - return 'fail' + assert lyrs == ['lyr2', 'lyr3'] lyrs = [lyr.GetName() for lyr in ds[0:4]] - if lyrs != ['lyr1', 'lyr2', 'lyr3']: - print(lyrs) - return 'fail' + assert lyrs == ['lyr1', 'lyr2', 'lyr3'] lyrs = [lyr.GetName() for lyr in ds[0:3:2]] - if lyrs != ['lyr1', 'lyr3']: - print(lyrs) - return 'fail' + assert lyrs == ['lyr1', 'lyr3'] return 'success' diff --git a/autotest/ogr/ogr_bna.py b/autotest/ogr/ogr_bna.py index 2fa0c6e4c552..2cfb1e3ae406 100755 --- a/autotest/ogr/ogr_bna.py +++ b/autotest/ogr/ogr_bna.py @@ -50,19 +50,16 @@ def test_ogr_bna_1(): expect = ['PID5', 'PID4'] tr = ogrtest.check_features_against_list(lyr, 'Primary ID', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (573.736 476.563)', - max_error=0.0001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'POINT (573.736 476.563)', + max_error=0.0001) == 0) feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (532.991 429.121)', - max_error=0.0001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'POINT (532.991 429.121)', + max_error=0.0001) == 0) return 'success' @@ -79,13 +76,11 @@ def test_ogr_bna_2(): expect = ['PID3'] tr = ogrtest.check_features_against_list(lyr, 'Primary ID', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (224.598 307.425,333.043 341.461,396.629 304.952)', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (224.598 307.425,333.043 341.461,396.629 304.952)', max_error=0.0001) == 0 return 'success' @@ -102,26 +97,20 @@ def test_ogr_bna_3(): expect = ['PID2', 'PID1', 'PID7', 'PID8', 'PID9', 'PID10'] tr = ogrtest.check_features_against_list(lyr, 'Primary ID', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() feat = lyr.GetNextFeature() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,1 0,1 1,0 1,0 0)))', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,1 0,1 1,0 1,0 0)))', max_error=0.0001) == 0 feat = lyr.GetFeature(2) - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,1 0,1 1,0 1,0 0)))', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,1 0,1 1,0 1,0 0)))', max_error=0.0001) == 0 feat = lyr.GetFeature(3) - if ogrtest.check_feature_geometry(feat, 'POLYGON ((0 0,0 10,10 10,10 0,0 0),(2 2,2 8,8 8,8 2,2 2))', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'POLYGON ((0 0,0 10,10 10,10 0,0 0),(2 2,2 8,8 8,8 2,2 2))', max_error=0.0001) == 0 feat = lyr.GetFeature(4) - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,0 10,10 10,10 0,0 0)))', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,0 10,10 10,10 0,0 0)))', max_error=0.0001) == 0 feat = lyr.GetFeature(5) - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,0 10,10 10,10 0,0 0)))', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((0 0,0 10,10 10,10 0,0 0)))', max_error=0.0001) == 0 return 'success' @@ -138,8 +127,7 @@ def test_ogr_bna_4(): expect = ['PID6'] tr = ogrtest.check_features_against_list(lyr, 'Primary ID', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() lyr.GetNextFeature() @@ -152,19 +140,16 @@ def test_ogr_bna_4(): def ogr_bna_check_content(lyr1, lyr2): - if lyr1.GetFeatureCount() != lyr2.GetFeatureCount(): - return 'fail' + assert lyr1.GetFeatureCount() == lyr2.GetFeatureCount() feat1 = lyr1.GetNextFeature() feat2 = lyr2.GetNextFeature() while feat1 is not None: for i in range(lyr1.GetLayerDefn().GetFieldCount()): - if feat1.GetField(i) != feat2.GetField(i): - return 'fail' + assert feat1.GetField(i) == feat2.GetField(i) - if ogrtest.check_feature_geometry(feat1, feat2.GetGeometryRef(), - max_error=0.000000001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat1, feat2.GetGeometryRef(), + max_error=0.000000001) == 0) feat1 = lyr1.GetNextFeature() feat2 = lyr2.GetNextFeature() @@ -192,9 +177,7 @@ def ogr_bna_write(creation_options): while feat is not None: dst_feat.SetFrom(feat) - if dst_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert dst_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = src_lyr.GetNextFeature() @@ -225,18 +208,14 @@ def test_ogr_bna_6(): ret = ogr_bna_write(['LINEFORMAT=LF', 'MULTILINE=NO', 'COORDINATE_PRECISION=3']) size = os.stat('tmp/out.bna').st_size - if size != 1601: - gdaltest.post_reason('Got size %d. Expected %d' % (size, 1601)) - return 'fail' + assert size == 1601, ('Got size %d. Expected %d' % (size, 1601)) os.remove('tmp/out.bna') ret = ogr_bna_write(['LINEFORMAT=CRLF', 'MULTILINE=NO', 'COORDINATE_PRECISION=3']) size = os.stat('tmp/out.bna').st_size - if size != 1611: - gdaltest.post_reason('Got size %d. Expected %d' % (size, 1611)) - return 'fail' + assert size == 1611, ('Got size %d. Expected %d' % (size, 1611)) return 'success' diff --git a/autotest/ogr/ogr_cad.py b/autotest/ogr/ogr_cad.py index dbf66df144a9..bebd37285367 100755 --- a/autotest/ogr/ogr_cad.py +++ b/autotest/ogr/ogr_cad.py @@ -63,70 +63,51 @@ def test_ogr_cad_2(): gdaltest.cad_ds = gdal.OpenEx('data/cad/ellipse_r2000.dwg', allowed_drivers=['CAD']) - if gdaltest.cad_ds is None: - return 'fail' + assert gdaltest.cad_ds is not None - if gdaltest.cad_ds.GetLayerCount() != 1: - gdaltest.post_reason('expected exactly one layer.') - return 'fail' + assert gdaltest.cad_ds.GetLayerCount() == 1, 'expected exactly one layer.' gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(0) - if gdaltest.cad_layer.GetName() != '0': - gdaltest.post_reason('layer name is expected to be default = 0.') - return 'fail' + assert gdaltest.cad_layer.GetName() == '0', \ + 'layer name is expected to be default = 0.' defn = gdaltest.cad_layer.GetLayerDefn() - if defn.GetFieldCount() != 5: - gdaltest.post_reason('did not get expected number of fields in defn. got %d' + assert defn.GetFieldCount() == 5, \ + ('did not get expected number of fields in defn. got %d' % defn.GetFieldCount()) - return 'fail' fc = gdaltest.cad_layer.GetFeatureCount() - if fc != 1: - gdaltest.post_reason('did not get expected feature count, got %d' % fc) - return 'fail' + assert fc == 1, ('did not get expected feature count, got %d' % fc) gdaltest.cad_layer.ResetReading() feat = gdaltest.cad_layer.GetNextFeature() - if feat is None: - gdaltest.post_reason('cad feature 0 get failed.') - return 'fail' + assert feat is not None, 'cad feature 0 get failed.' - if feat.cadgeom_type != 'CADEllipse': - gdaltest.post_reason('cad geometry type is wrong. Expected CADEllipse, got: %s' + assert feat.cadgeom_type == 'CADEllipse', \ + ('cad geometry type is wrong. Expected CADEllipse, got: %s' % feat.cadgeom_type) - return 'fail' - if feat.GetFID() != 0: - gdaltest.post_reason('did not get expected FID for feature 0.') - return 'fail' + assert feat.GetFID() == 0, 'did not get expected FID for feature 0.' - if feat.thickness != 0: - gdaltest.post_reason('did not get expected thickness. expected 0, got: %f' + assert feat.thickness == 0, ('did not get expected thickness. expected 0, got: %f' % feat.thickness) - return 'fail' - if feat.extentity_data is not None: - gdaltest.post_reason('expected feature ExtendedEntityData to be null.') - return 'fail' + assert feat.extentity_data is None, \ + 'expected feature ExtendedEntityData to be null.' expected_style = 'PEN(c:#FFFFFFFF,w:5px)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' + assert feat.GetStyleString() == expected_style, \ + ('got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' geom = feat.GetGeometryRef() - if geom is None: - gdaltest.post_reason('cad geometry is None.') - return 'fail' + assert geom is not None, 'cad geometry is None.' - if geom.GetGeometryType() != ogr.wkbLineString25D: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString25D, \ + 'did not get expected geometry type.' gdaltest.cad_ds = None return 'success' @@ -141,153 +122,121 @@ def test_ogr_cad_3(): gdaltest.cad_ds = gdal.OpenEx('data/cad/triple_circles_r2000.dwg', allowed_drivers=['CAD']) - if gdaltest.cad_ds is None: - return 'fail' + assert gdaltest.cad_ds is not None - if gdaltest.cad_ds.GetLayerCount() != 3: - gdaltest.post_reason('expected 3 layers.') - return 'fail' + assert gdaltest.cad_ds.GetLayerCount() == 3, 'expected 3 layers.' # test first layer and circle gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(0) - if gdaltest.cad_layer.GetName() != '0': - gdaltest.post_reason('layer name is expected to be default = 0.') - return 'fail' + assert gdaltest.cad_layer.GetName() == '0', \ + 'layer name is expected to be default = 0.' defn = gdaltest.cad_layer.GetLayerDefn() - if defn.GetFieldCount() != 5: - gdaltest.post_reason('did not get expected number of fields in defn. got %d' + assert defn.GetFieldCount() == 5, \ + ('did not get expected number of fields in defn. got %d' % defn.GetFieldCount()) - return 'fail' fc = gdaltest.cad_layer.GetFeatureCount() - if fc != 1: - gdaltest.post_reason('did not get expected feature count, got %d' % fc) - return 'fail' + assert fc == 1, ('did not get expected feature count, got %d' % fc) gdaltest.cad_layer.ResetReading() feat = gdaltest.cad_layer.GetNextFeature() - if feat.cadgeom_type != 'CADCircle': - gdaltest.post_reason('cad geometry type is wrong. Expected CADCircle, got: %s' + assert feat.cadgeom_type == 'CADCircle', \ + ('cad geometry type is wrong. Expected CADCircle, got: %s' % feat.cadgeom_type) - return 'fail' - if feat.thickness != 1.2: - gdaltest.post_reason('did not get expected thickness. expected 1.2, got: %f' + assert feat.thickness == 1.2, \ + ('did not get expected thickness. expected 1.2, got: %f' % feat.thickness) - return 'fail' - if feat.extentity_data is not None: - gdaltest.post_reason('expected feature ExtendedEntityData to be null.') - return 'fail' + assert feat.extentity_data is None, \ + 'expected feature ExtendedEntityData to be null.' expected_style = 'PEN(c:#FFFFFFFF,w:5px)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbCircularStringZ: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbCircularStringZ, \ + 'did not get expected geometry type.' # test second layer and circle gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(1) - if gdaltest.cad_layer.GetName() != '1': - gdaltest.post_reason('layer name is expected to be 1.') - return 'fail' + assert gdaltest.cad_layer.GetName() == '1', 'layer name is expected to be 1.' defn = gdaltest.cad_layer.GetLayerDefn() - if defn.GetFieldCount() != 5: - gdaltest.post_reason('did not get expected number of fields in defn. got %d' + assert defn.GetFieldCount() == 5, \ + ('did not get expected number of fields in defn. got %d' % defn.GetFieldCount()) - return 'fail' fc = gdaltest.cad_layer.GetFeatureCount() - if fc != 1: - gdaltest.post_reason('did not get expected feature count, got %d' % fc) - return 'fail' + assert fc == 1, ('did not get expected feature count, got %d' % fc) gdaltest.cad_layer.ResetReading() feat = gdaltest.cad_layer.GetNextFeature() - if feat.cadgeom_type != 'CADCircle': - gdaltest.post_reason('cad geometry type is wrong. Expected CADCircle, got: %s' + assert feat.cadgeom_type == 'CADCircle', \ + ('cad geometry type is wrong. Expected CADCircle, got: %s' % feat.cadgeom_type) - return 'fail' - if feat.thickness != 0.8: - gdaltest.post_reason('did not get expected thickness. expected 0.8, got: %f' + assert feat.thickness == 0.8, \ + ('did not get expected thickness. expected 0.8, got: %f' % feat.thickness) - return 'fail' - if feat.extentity_data is not None: - gdaltest.post_reason('expected feature ExtendedEntityData to be null.') - return 'fail' + assert feat.extentity_data is None, \ + 'expected feature ExtendedEntityData to be null.' expected_style = 'PEN(c:#FFFFFFFF,w:5px)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbCircularStringZ: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbCircularStringZ, \ + 'did not get expected geometry type.' # test third layer and circle gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(2) - if gdaltest.cad_layer.GetName() != '2': - gdaltest.post_reason('layer name is expected to be 2.') - return 'fail' + assert gdaltest.cad_layer.GetName() == '2', 'layer name is expected to be 2.' defn = gdaltest.cad_layer.GetLayerDefn() - if defn.GetFieldCount() != 5: - gdaltest.post_reason('did not get expected number of fields in defn. got %d' + assert defn.GetFieldCount() == 5, \ + ('did not get expected number of fields in defn. got %d' % defn.GetFieldCount()) - return 'fail' fc = gdaltest.cad_layer.GetFeatureCount() - if fc != 1: - gdaltest.post_reason('did not get expected feature count, got %d' % fc) - return 'fail' + assert fc == 1, ('did not get expected feature count, got %d' % fc) gdaltest.cad_layer.ResetReading() feat = gdaltest.cad_layer.GetNextFeature() - if feat.cadgeom_type != 'CADCircle': - gdaltest.post_reason('cad geometry type is wrong. Expected CADCircle, got: %s' + assert feat.cadgeom_type == 'CADCircle', \ + ('cad geometry type is wrong. Expected CADCircle, got: %s' % feat.cadgeom_type) - return 'fail' - if feat.thickness != 1.8: - gdaltest.post_reason('did not get expected thickness. expected 1.8, got: %f' + assert feat.thickness == 1.8, \ + ('did not get expected thickness. expected 1.8, got: %f' % feat.thickness) - return 'fail' - if feat.extentity_data is not None: - gdaltest.post_reason('expected feature ExtendedEntityData to be null.') - return 'fail' + assert feat.extentity_data is None, \ + 'expected feature ExtendedEntityData to be null.' expected_style = 'PEN(c:#FFFFFFFF,w:5px)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string on feature 0:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbCircularStringZ: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbCircularStringZ, \ + 'did not get expected geometry type.' gdaltest.cad_ds = None return 'success' @@ -302,21 +251,16 @@ def test_ogr_cad_4(): gdaltest.cad_ds = gdal.OpenEx('data/cad/point2d_r2000.dwg', allowed_drivers=['CAD']) - if gdaltest.cad_ds.GetLayerCount() != 1: - gdaltest.post_reason('expected exactly one layer.') - return 'fail' + assert gdaltest.cad_ds.GetLayerCount() == 1, 'expected exactly one layer.' gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(0) - if gdaltest.cad_layer.GetFeatureCount() != 1: - gdaltest.post_reason('expected exactly one feature.') - return 'fail' + assert gdaltest.cad_layer.GetFeatureCount() == 1, 'expected exactly one feature.' feat = gdaltest.cad_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (50 50 0)'): - gdaltest.post_reason('got feature which does not fit expectations.') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (50 50 0)'), \ + 'got feature which does not fit expectations.' gdaltest.cad_ds = None return 'success' @@ -331,21 +275,16 @@ def test_ogr_cad_5(): gdaltest.cad_ds = gdal.OpenEx('data/cad/line_r2000.dwg', allowed_drivers=['CAD']) - if gdaltest.cad_ds.GetLayerCount() != 1: - gdaltest.post_reason('expected exactly one layer.') - return 'fail' + assert gdaltest.cad_ds.GetLayerCount() == 1, 'expected exactly one layer.' gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(0) - if gdaltest.cad_layer.GetFeatureCount() != 1: - gdaltest.post_reason('expected exactly one feature.') - return 'fail' + assert gdaltest.cad_layer.GetFeatureCount() == 1, 'expected exactly one feature.' feat = gdaltest.cad_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (50 50 0,100 100 0)'): - gdaltest.post_reason('got feature which does not fit expectations.') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (50 50 0,100 100 0)'), \ + 'got feature which does not fit expectations.' gdaltest.cad_ds = None return 'success' @@ -361,21 +300,16 @@ def test_ogr_cad_6(): gdaltest.cad_ds = gdal.OpenEx('data/cad/text_mtext_attdef_r2000.dwg', allowed_drivers=['CAD']) - if gdaltest.cad_ds.GetLayerCount() != 1: - gdaltest.post_reason('expected exactly one layer.') - return 'fail' + assert gdaltest.cad_ds.GetLayerCount() == 1, 'expected exactly one layer.' gdaltest.cad_layer = gdaltest.cad_ds.GetLayer(0) - if gdaltest.cad_layer.GetFeatureCount() != 3: - gdaltest.post_reason('expected 3 features, got: %d' + assert gdaltest.cad_layer.GetFeatureCount() == 3, ('expected 3 features, got: %d' % gdaltest.cad_layer.GetFeatureCount()) - return 'fail' feat = gdaltest.cad_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT(0.7413 1.7794 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT(0.7413 1.7794 0)') expected_style = 'LABEL(f:"Arial",t:"Русские буквы",c:#FFFFFFFF)' if feat.GetStyleString() != expected_style: @@ -395,14 +329,12 @@ def test_ogr_cad_7(): feat = gdaltest.cad_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT(2.8139 5.7963 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT(2.8139 5.7963 0)') expected_style = 'LABEL(f:"Arial",t:"English letters",c:#FFFFFFFF)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string:\n%s\ninstead of:\n%s.' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' return 'success' @@ -416,14 +348,12 @@ def test_ogr_cad_8(): feat = gdaltest.cad_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT(4.98953601938918 2.62670161690571 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT(4.98953601938918 2.62670161690571 0)') expected_style = 'LABEL(f:"Arial",t:"TESTTAG",c:#FFFFFFFF)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string:\n%s\ninstead of:\n%s.' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' return 'success' @@ -437,11 +367,9 @@ def test_ogr_cad_9(): with gdaltest.error_handler(): ds = gdal.OpenEx('data/AC1018_signature.dwg', allowed_drivers=['CAD']) - if ds is not None: - return 'fail' + assert ds is None msg = gdal.GetLastErrorMsg() - if msg.find('does not support this version') < 0: - return 'fail' + assert msg.find('does not support this version') >= 0 return 'success' diff --git a/autotest/ogr/ogr_carto.py b/autotest/ogr/ogr_carto.py index 20a3802db68c..619d11b5c794 100755 --- a/autotest/ogr/ogr_carto.py +++ b/autotest/ogr/ogr_carto.py @@ -71,8 +71,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """Content-Type: text/html\r @@ -81,136 +80,101 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() - if ds is not None or gdal.GetLastErrorMsg().find('HTML error page') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None and gdal.GetLastErrorMsg().find('HTML error page') >= 0 gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """""") ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{""") gdal.PushErrorHandler() ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() - if ds is not None or gdal.GetLastErrorMsg().find('JSON parsing error') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None and gdal.GetLastErrorMsg().find('JSON parsing error') >= 0 gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """ "not_expected_json" """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "error" : [ "bla"] }""") gdal.PushErrorHandler() ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() - if ds is not None or gdal.GetLastErrorMsg().find('Error returned by server : bla') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None and gdal.GetLastErrorMsg().find('Error returned by server : bla') >= 0 gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : null } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : "invalid" } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : {} } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : { "foo": "invalid" } } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : { "foo": {} } } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : { "foo": { "type" : null } } } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : { "foo": { "type" : {} } } } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{ "fields" : { "foo": { "type" : "string" } } } """) ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{"rows":[ {"field1": "foo", "field2": "bar"} ],"fields":{"field1":{"type":"string"}, "field2":{"type":"string"}}}""") ds = ogr.Open('CARTO:foo') - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{"rows":[],"fields":{"current_schema":{"type":"string"}}}""") gdal.PushErrorHandler() ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0', """{"rows":[{"current_schema":"public"}],"fields":{"current_schema":{"type":"unknown(19)"}}}""") gdal.PushErrorHandler() ds = ogr.Open('CARTO:foo') gdal.PopErrorHandler() - if ds is not None: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT CDB_UserTables() LIMIT 500 OFFSET 0', """{"rows":[{"cdb_usertables":"table1"}],"fields":{"cdb_usertables":{"type":"string"}}}""") ds = ogr.Open('CARTO:foo') - if ds is None or ds.GetLayerCount() != 1: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is not None and ds.GetLayerCount() == 1, gdal.GetLastErrorMsg() gdal.PushErrorHandler() lyr_defn = ds.GetLayer(0).GetLayerDefn() gdal.PopErrorHandler() - if lyr_defn.GetFieldCount() != 0: - return 'fail' + assert lyr_defn.GetFieldCount() == 0 # Empty layer gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT * FROM "table1" LIMIT 0', @@ -218,8 +182,7 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetFieldCount() != 0: - return 'fail' + assert lyr_defn.GetFieldCount() == 0 gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT * FROM "table1" LIMIT 500 OFFSET 0', """{"rows":[{}],"fields":{}}}""") @@ -234,21 +197,16 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetFieldCount() != 4: - return 'fail' - if lyr_defn.GetFieldDefn(0).GetName() != 'strfield' or \ - lyr_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' - if lyr_defn.GetFieldDefn(1).GetName() != 'realfield' or \ - lyr_defn.GetFieldDefn(1).GetType() != ogr.OFTReal: - return 'fail' - if lyr_defn.GetFieldDefn(2).GetName() != 'boolfield' or \ - lyr_defn.GetFieldDefn(2).GetType() != ogr.OFTInteger or \ - lyr_defn.GetFieldDefn(2).GetSubType() != ogr.OFSTBoolean: - return 'fail' - if lyr_defn.GetFieldDefn(3).GetName() != 'datefield' or \ - lyr_defn.GetFieldDefn(3).GetType() != ogr.OFTDateTime: - return 'fail' + assert lyr_defn.GetFieldCount() == 4 + assert (lyr_defn.GetFieldDefn(0).GetName() == 'strfield' and \ + lyr_defn.GetFieldDefn(0).GetType() == ogr.OFTString) + assert (lyr_defn.GetFieldDefn(1).GetName() == 'realfield' and \ + lyr_defn.GetFieldDefn(1).GetType() == ogr.OFTReal) + assert (lyr_defn.GetFieldDefn(2).GetName() == 'boolfield' and \ + lyr_defn.GetFieldDefn(2).GetType() == ogr.OFTInteger and \ + lyr_defn.GetFieldDefn(2).GetSubType() == ogr.OFSTBoolean) + assert (lyr_defn.GetFieldDefn(3).GetName() == 'datefield' and \ + lyr_defn.GetFieldDefn(3).GetType() == ogr.OFTDateTime) gdal.FileFromMemBuffer('/vsimem/carto&POSTFIELDS=q=SELECT "strfield", "realfield", "boolfield", "datefield" FROM "table1" LIMIT 500 OFFSET 0', """{"rows":[{ "strfield": "foo", "realfield": 1.23, "boolfield": true, "datefield": "2015-04-24T12:34:56.123Z" }],"fields":{"strfield":{"type":"string"}, "realfield":{"type":"number"}, "boolfield":{"type":"boolean"}, "datefield":{"type":"date"}}}""") @@ -267,8 +225,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr_defn = ds.GetLayer(0).GetLayerDefn() gdal.PopErrorHandler() - if lyr_defn.GetFieldCount() != 0: - return 'fail' + assert lyr_defn.GetFieldCount() == 0 get_full_details_fields_url = """/vsimem/carto&POSTFIELDS=q=SELECT a.attname, t.typname, a.attlen, format_type(a.atttypid,a.atttypmod), a.attnum, a.attnotnull, i.indisprimary, pg_get_expr(def.adbin, c.oid) AS defaultexpr, postgis_typmod_dims(a.atttypmod) dim, postgis_typmod_srid(a.atttypmod) srid, postgis_typmod_type(a.atttypmod)::text geomtyp, srtext FROM pg_class c JOIN pg_attribute a ON a.attnum > 0 AND a.attrelid = c.oid AND c.relname = 'table1' JOIN pg_type t ON a.atttypid = t.oid JOIN pg_namespace n ON c.relnamespace=n.oid AND n.nspname= 'public' LEFT JOIN pg_index i ON c.oid = i.indrelid AND i.indisprimary = 't' AND a.attnum = ANY(i.indkey) LEFT JOIN pg_attrdef def ON def.adrelid = c.oid AND def.adnum = a.attnum LEFT JOIN spatial_ref_sys srs ON srs.srid = postgis_typmod_srid(a.atttypmod) ORDER BY a.attnum LIMIT 500 OFFSET 0&api_key=foo""" gdal.FileFromMemBuffer(get_full_details_fields_url, '') @@ -276,8 +233,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr_defn = ds.GetLayer(0).GetLayerDefn() gdal.PopErrorHandler() - if lyr_defn.GetFieldCount() != 0: - return 'fail' + assert lyr_defn.GetFieldCount() == 0 gdal.FileFromMemBuffer(get_full_details_fields_url, """{"rows":[{"attname":"foo"}], "fields":{"attname":{"type":"string"}}}""") @@ -286,14 +242,12 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr_defn = lyr.GetLayerDefn() gdal.PopErrorHandler() - if lyr_defn.GetFieldCount() != 1: - return 'fail' + assert lyr_defn.GetFieldCount() == 1 gdal.PushErrorHandler() f = lyr.GetFeature(0) gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer(get_full_details_fields_url, """{"rows":[{"attname":"strfield", "typname":"varchar", "attnotnull": true, "defaultexpr": "def_value"}, @@ -323,35 +277,27 @@ def test_ogr_carto_vsimem(): ds = ogr.Open('CARTO:foo') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetFieldCount() != 5: - return 'fail' - if lyr_defn.GetFieldDefn(0).GetName() != 'strfield' or \ - lyr_defn.GetFieldDefn(0).GetType() != ogr.OFTString or \ - lyr_defn.GetFieldDefn(0).IsNullable() or \ - lyr_defn.GetFieldDefn(0).GetDefault() != 'def_value': - return 'fail' - if lyr_defn.GetGeomFieldCount() != 1: - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetName() != 'my_geom': - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbPoint25D: - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetSpatialRef().ExportToWkt().find('4326') < 0: - return 'fail' + assert lyr_defn.GetFieldCount() == 5 + assert (lyr_defn.GetFieldDefn(0).GetName() == 'strfield' and \ + lyr_defn.GetFieldDefn(0).GetType() == ogr.OFTString and not \ + lyr_defn.GetFieldDefn(0).IsNullable() and \ + lyr_defn.GetFieldDefn(0).GetDefault() == 'def_value') + assert lyr_defn.GetGeomFieldCount() == 1 + assert lyr_defn.GetGeomFieldDefn(0).GetName() == 'my_geom' + assert lyr_defn.GetGeomFieldDefn(0).GetType() == ogr.wkbPoint25D + assert lyr_defn.GetGeomFieldDefn(0).GetSpatialRef().ExportToWkt().find('4326') >= 0 gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 0: - return 'fail' + assert fc == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1"&api_key=foo""", """{}""") gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 0: - return 'fail' + assert fc == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1"&api_key=foo""", """{"rows":[{"foo":1}], @@ -359,20 +305,17 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 0: - return 'fail' + assert fc == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1"&api_key=foo""", """{"rows":[{"count":9876543210}], "fields":{"count":{"type":"number"}}}""") - if lyr.GetFeatureCount() != 9876543210: - return 'fail' + assert lyr.GetFeatureCount() == 9876543210 gdal.PushErrorHandler() extent = lyr.GetExtent() gdal.PopErrorHandler() - if extent != (0, 0, 0, 0): - return 'fail' + assert extent == (0, 0, 0, 0) gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", """{"rows":[{"foo":1}], @@ -381,8 +324,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() extent = lyr.GetExtent() gdal.PopErrorHandler() - if extent != (0, 0, 0, 0): - return 'fail' + assert extent == (0, 0, 0, 0) gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", """{"rows":[{"st_extent":""}], @@ -391,8 +333,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr.GetExtent() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", """{"rows":[{"st_extent":"("}], @@ -401,8 +342,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr.GetExtent() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", """{"rows":[{"st_extent":"BOX()"}], @@ -411,21 +351,17 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr.GetExtent() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT ST_Extent("my_geom") FROM "table1"&api_key=foo""", """{"rows":[{"st_extent":"BOX(0,1,2,3)"}], "fields":{"st_extent":{"type":"string"}}}""") - if lyr.GetExtent() != (0.0, 2.0, 1.0, 3.0): - print(lyr.GetExtent()) - return 'fail' + assert lyr.GetExtent() == (0.0, 2.0, 1.0, 3.0) gdal.PushErrorHandler() f = lyr.GetFeature(0) gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" = 0&api_key=foo""", """""") @@ -433,44 +369,38 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() f = lyr.GetFeature(0) gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" = 0&api_key=foo""", """{"rows":[{"st_extent":"BOX(0,1,2,3)"}], "fields":{"st_extent":{"type":"string"}}}""") f = lyr.GetFeature(0) - if f.GetFID() != -1 or not f.IsFieldNull(0): - return 'fail' + assert f.GetFID() == -1 and f.IsFieldNull(0) gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" = 0&api_key=foo""", """{"rows":[{"cartodb_id":0}], "fields":{"cartodb_id":{"type":"numeric"}}}""") f = lyr.GetFeature(0) - if f.GetFID() != 0: - return 'fail' + assert f.GetFID() == 0 lyr.ResetReading() gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 500&api_key=foo""", """{"rows":[{"cartodb_id":0}], "fields":{"cartodb_id":{"type":"numeric"}}}""") lyr.ResetReading() f = lyr.GetNextFeature() - if f.GetFID() != 0: - return 'fail' + assert f.GetFID() == 0 gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.SetConfigOption('CARTO_PAGE_SIZE', '2') gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", @@ -478,59 +408,50 @@ def test_ogr_carto_vsimem(): "fields":{"cartodb_id":{"type":"numeric"}}}""") lyr.ResetReading() f = lyr.GetNextFeature() - if f.GetFID() != 0: - return 'fail' + assert f.GetFID() == 0 f = lyr.GetNextFeature() - if f.GetFID() != 10: - return 'fail' + assert f.GetFID() == 10 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE "cartodb_id" >= 11 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", """{"rows":[{"cartodb_id":12}], "fields":{"cartodb_id":{"type":"numeric"}}}""") f = lyr.GetNextFeature() - if f.GetFID() != 12: - return 'fail' + assert f.GetFID() == 12 gdal.ErrorReset() f = lyr.GetNextFeature() - if f is not None or gdal.GetLastErrorMsg() != '': - return 'fail' + assert f is None and gdal.GetLastErrorMsg() == '' lyr.SetAttributeFilter('strfield is NULL') gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 0: - return 'fail' + assert fc == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE (strfield is NULL) AND "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", """{"rows":[{"cartodb_id":0}], "fields":{"cartodb_id":{"type":"numeric"}}}""") lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE (strfield is NULL) AND "cartodb_id" >= 1 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", """{"rows":[], "fields":{"cartodb_id":{"type":"numeric"}}}""") gdal.ErrorReset() f = lyr.GetNextFeature() - if f is not None or gdal.GetLastErrorMsg() != '': - return 'fail' + assert f is None and gdal.GetLastErrorMsg() == '' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1" WHERE (strfield is NULL)&api_key=foo""", """{"rows":[{"count":9876543210}], "fields":{"count":{"type":"number"}}}""") - if lyr.GetFeatureCount() != 9876543210: - return 'fail' + assert lyr.GetFeatureCount() == 9876543210 lyr.SetSpatialFilterRect(-180, -90, 180, 90) gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 0: - return 'fail' + assert fc == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT "cartodb_id", "my_geom", "strfield", "intfield", "doublefield", "boolfield", "datetimefield" FROM "table1" WHERE ("my_geom" %26%26 'BOX3D(-180 -90, 180 90)'::box3d) AND (strfield is NULL) AND "cartodb_id" >= 0 ORDER BY "cartodb_id" ASC LIMIT 2&api_key=foo""", """{"rows":[{"cartodb_id":20, "my_geom": "010100000000000000000000400000000000804840" }], @@ -538,20 +459,17 @@ def test_ogr_carto_vsimem(): lyr.ResetReading() f = lyr.GetNextFeature() - if f is None or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert f is not None and f.GetGeometryRef().ExportToWkt() == 'POINT (2 49)' gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 1: - return 'fail' + assert fc == 1 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT COUNT(*) FROM "table1" WHERE ("my_geom" %26%26 'BOX3D(-180 -90, 180 90)'::box3d) AND (strfield is NULL)&api_key=foo""", """{"rows":[{"count":9876543210}], "fields":{"count":{"type":"number"}}}""") - if lyr.GetFeatureCount() != 9876543210: - return 'fail' + assert lyr.GetFeatureCount() == 9876543210 # Not permitted in read-only mode f = ogr.Feature(lyr.GetLayerDefn()) @@ -577,8 +495,7 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() lyr.GetNextFeature() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT cdb_cartodbfytable('my_layer')&api_key=foo""", """{"rows":[], @@ -605,22 +522,19 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None fld_defn = ogr.FieldDefn('INTFIELD', ogr.OFTInteger) # No server answer with gdaltest.error_handler(): ret = lyr.CreateField(fld_defn) - if ret == 0: - return 'fail' + assert ret != 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" ADD COLUMN "intfield" INTEGER&api_key=foo""", """{"rows":[], "fields":{}}""") - if lyr.CreateField(fld_defn) != 0: - return 'fail' + assert lyr.CreateField(fld_defn) == 0 fld_defn = ogr.FieldDefn('boolfield', ogr.OFTInteger) fld_defn.SetSubType(ogr.OFSTBoolean) @@ -628,38 +542,32 @@ def test_ogr_carto_vsimem(): gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" ADD COLUMN "boolfield" BOOLEAN&api_key=foo""", """{"rows":[], "fields":{}}""") - if lyr.CreateField(fld_defn) != 0: - return 'fail' + assert lyr.CreateField(fld_defn) == 0 # Invalid field with gdaltest.error_handler(): - if lyr.DeleteField(-1) == 0: - return 'fail' + assert lyr.DeleteField(-1) != 0 # No server answer with gdaltest.error_handler(): - if lyr.DeleteField(0) == 0: - return 'fail' + assert lyr.DeleteField(0) != 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" DROP COLUMN "boolfield"&api_key=foo""", """{"rows":[], "fields":{}}""") fld_pos = lyr.GetLayerDefn().GetFieldIndex(fld_defn.GetName()) - if lyr.DeleteField(fld_pos) != 0: - return 'fail' + assert lyr.DeleteField(fld_pos) == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=ALTER TABLE "my_layer" ADD COLUMN "boolfield" BOOLEAN&api_key=foo""", """{"rows":[], "fields":{}}""") - if lyr.CreateField(fld_defn) != 0: - return 'fail' + assert lyr.CreateField(fld_defn) == 0 f = ogr.Feature(lyr.GetLayerDefn()) gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'foo') @@ -670,66 +578,56 @@ def test_ogr_carto_vsimem(): """{"rows":[ {"cartodb_id": 1} ], "fields":{"cartodb_id":{"type":"integer"}}}""") ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 1: - return 'fail' + assert ret == 0 and f.GetFID() == 1 f.SetFID(-1) gdal.PushErrorHandler() ret = lyr.SetFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f.SetFID(3) gdal.PushErrorHandler() ret = lyr.SetFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=UPDATE "my_layer" SET "strfield" = 'foo', "intfield" = 1, "boolfield" = 't', "the_geom" = '0101000020E610000000000000000000400000000000804840' WHERE "cartodb_id" = 3&api_key=foo""", """{"total_rows": 0}""") ret = lyr.SetFeature(f) - if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert ret == ogr.OGRERR_NON_EXISTING_FEATURE gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=UPDATE "my_layer" SET "strfield" = 'foo', "intfield" = 1, "boolfield" = 't', "the_geom" = '0101000020E610000000000000000000400000000000804840' WHERE "cartodb_id" = 3&api_key=foo""", """{"total_rows": 1}""") ret = lyr.SetFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f = ogr.Feature(lyr.GetLayerDefn()) gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=INSERT INTO "my_layer" DEFAULT VALUES RETURNING "cartodb_id"&api_key=foo""", """{"rows":[ {"cartodb_id": 4} ], "fields":{"cartodb_id":{"type":"integer"}}}""") ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 4: - return 'fail' + assert ret == 0 and f.GetFID() == 4 gdal.PushErrorHandler() ret = lyr.DeleteFeature(0) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=DELETE FROM "my_layer" WHERE "cartodb_id" = 0&api_key=foo""", """{"total_rows": 0}""") ret = lyr.DeleteFeature(0) - if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert ret == ogr.OGRERR_NON_EXISTING_FEATURE gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=DELETE FROM "my_layer" WHERE "cartodb_id" = 0&api_key=foo""", """{"total_rows": 1}""") ret = lyr.DeleteFeature(0) - if ret != 0: - return 'fail' + assert ret == 0 gdal.FileFromMemBuffer("""/vsimem/carto&POSTFIELDS=q=SELECT cdb_cartodbfytable('my_layer')&api_key=foo""", """{"rows":[], @@ -749,8 +647,7 @@ def test_ogr_carto_vsimem(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'foo') ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 11: - return 'fail' + assert ret == 0 and f.GetFID() == 11 f = ogr.Feature(lyr.GetLayerDefn()) @@ -811,35 +708,30 @@ def test_ogr_carto_vsimem(): with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=SELECT nextval('table1_cartodb_id_seq') AS nextid&api_key=foo""", """{"rows":[{"nextid":11}],"fields":{"nextid":{"type":"number"}}}"""): ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 11: - return 'fail' + assert ret == 0 and f.GetFID() == 11 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'bar') ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 12: - return 'fail' + assert ret == 0 and f.GetFID() == 12 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'baz') ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 13: - return 'fail' + assert ret == 0 and f.GetFID() == 13 gdal.ErrorReset() with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=BEGIN;INSERT INTO "table1" ("strfield", "cartodb_id") VALUES ('foo', 11);INSERT INTO "table1" ("strfield", "intfield", "doublefield", "boolfield", "datetimefield", "my_geom") VALUES ('bar', NULL, NULL, NULL, NULL, NULL), ('baz', NULL, NULL, NULL, NULL, NULL);COMMIT;&api_key=foo""", """{"rows":[], "fields":{}}"""): ds = None - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' ds = gdal.OpenEx('CARTO:foo', gdal.OF_VECTOR | gdal.OF_UPDATE, open_options=['COPY_MODE=NO']) gdal.PushErrorHandler() lyr = ds.CreateLayer('table1') gdal.PopErrorHandler() - if lyr is not None: - return 'fail' + assert lyr is None with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=DROP TABLE "table1"&api_key=foo""", """{"rows":[], "fields":{}}"""): @@ -849,16 +741,14 @@ def test_ogr_carto_vsimem(): f.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON((0 0,0 1,1 0,0 0))')) with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=CREATE TABLE "table1" ( cartodb_id SERIAL,the_geom Geometry(MULTIPOLYGON,0),PRIMARY KEY (cartodb_id) );DROP SEQUENCE IF EXISTS "table1_cartodb_id_seq" CASCADE;CREATE SEQUENCE "table1_cartodb_id_seq" START 1;ALTER SEQUENCE "table1_cartodb_id_seq" OWNED BY "table1".cartodb_id;ALTER TABLE "table1" ALTER COLUMN cartodb_id SET DEFAULT nextval('"table1_cartodb_id_seq"')&api_key=foo""", """{"rows":[], "fields":{}}"""): - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 gdal.ErrorReset() with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=BEGIN;INSERT INTO "table1" ("the_geom") VALUES ('0106000020E61000000100000001030000000100000004000000000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000');COMMIT;&api_key=foo""", """{"rows":[], "fields":{}}"""): ds = None - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' ds = gdal.OpenEx('CARTO:foo', gdal.OF_VECTOR | gdal.OF_UPDATE, open_options=['COPY_MODE=NO']) @@ -873,10 +763,8 @@ def test_ogr_carto_vsimem(): """{"rows":[], "fields":{}}"""): with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=BEGIN;INSERT INTO "table1" ("cartodb_id") VALUES (100);COMMIT;&api_key=foo""", """{"rows":[], "fields":{}}"""): - if lyr.CreateFeature(f) != 0: - return 'fail' - if f.GetFID() != 100: - return 'fail' + assert lyr.CreateFeature(f) == 0 + assert f.GetFID() == 100 ds = None ds = ogr.Open('CARTO:foo', update=1) @@ -884,16 +772,13 @@ def test_ogr_carto_vsimem(): gdal.PushErrorHandler() ret = ds.DeleteLayer(0) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.ErrorReset() ds = gdal.OpenEx('CARTO:foo', gdal.OF_VECTOR | gdal.OF_UPDATE, open_options=['COPY_MODE=YES']) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('table1') - if lyr is None: - return 'fail' + assert lyr is not None with gdaltest.tempfile("""/vsimem/carto/copyfrom?q=COPY%20"table1"%20("strfield","my_geom","cartodb_id")%20FROM%20STDIN%20WITH%20(FORMAT%20text,%20ENCODING%20UTF8)&api_key=foo&POSTFIELDS=copytest\t0101000020E610000000000000000059400000000000005940\t11\n\\.\n""","""{}"""): @@ -902,14 +787,12 @@ def test_ogr_carto_vsimem(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('strfield', 'copytest') f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(100 100)')) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('intfield', 12) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(100 100)')) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 ds = None # force flush @@ -919,8 +802,7 @@ def test_ogr_carto_vsimem(): with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=DROP TABLE "table1"&api_key=foo""", """{"rows":[], "fields":{}}"""): ds.ExecuteSQL('DELLAYER:table1') - if gdal.GetLastErrorMsg() != '' or ds.GetLayerByName('table1') is not None: - return 'fail' + assert gdal.GetLastErrorMsg() == '' and ds.GetLayerByName('table1') is None with gdaltest.tempfile('/vsimem/carto&POSTFIELDS=q=SELECT current_schema() LIMIT 500 OFFSET 0&api_key=foo', """{"rows":[{"current_schema":"my_schema"}],"fields":{"current_schema":{"type":"unknown(19)"}}}"""): @@ -929,8 +811,7 @@ def test_ogr_carto_vsimem(): with gdaltest.tempfile("""/vsimem/carto&POSTFIELDS=q=SELECT c.relname FROM pg_class c, pg_namespace n WHERE c.relkind in ('r', 'v') AND c.relname !~ '^pg_' AND c.relnamespace=n.oid AND n.nspname = 'my_schema' LIMIT 500 OFFSET 0&api_key=foo""", """{"rows":[{"relname": "a_layer"}],"fields":{"relname":{"type":"string"}}}"""): ds = ogr.Open('CARTO:foo') - if ds.GetLayerByName('a_layer') is None: - return 'fail' + assert ds.GetLayerByName('a_layer') is not None @@ -980,9 +861,7 @@ def test_ogr_carto_test_ogrsf(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' --config CARTO_HTTPS NO --config CARTO_PAGE_SIZE 300 -ro "CARTO:gdalautotest2 tables=tm_world_borders_simpl_0_3"') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -1018,8 +897,7 @@ def ogr_carto_rw_1(): return 'skip' ds = ogr.Open(ogrtest.carto_connection, update=1) - if ds is None: - return 'fail' + assert ds is not None a_uuid = str(uuid.uuid1()).replace('-', '_') lyr_name = "LAYER_" + a_uuid @@ -1044,8 +922,7 @@ def ogr_carto_rw_1(): f = ogr.Feature(lyr.GetLayerDefn()) ret = lyr.CreateFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f.SetFID(-1) f.SetField('STRFIELD', "fo'o") @@ -1056,15 +933,13 @@ def ogr_carto_rw_1(): f.SetField('bool', 0) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT (1 2)')) ret = lyr.CreateFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f.SetField('intfield', 456) f.SetField('bool', 1) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT (3 4)')) ret = lyr.SetFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 fid = f.GetFID() ds = None @@ -1075,15 +950,13 @@ def ogr_carto_rw_1(): for lyr in ds: if lyr.GetName() == lyr_name: found = True - if not found: - return 'fail' + assert found lyr = ds.GetLayerByName(lyr_name) found = False for i in range(lyr.GetLayerDefn().GetFieldCount()): if lyr.GetLayerDefn().GetFieldDefn(i).GetName() == 'strfield': found = True - if not found: - return 'fail' + assert found f = lyr.GetFeature(fid) if f.GetField('strfield') != "fo'o" or \ f.GetField('intfield') != 456 or \ diff --git a/autotest/ogr/ogr_cloudant.py b/autotest/ogr/ogr_cloudant.py index 249dcfc899dc..cfda17131733 100755 --- a/autotest/ogr/ogr_cloudant.py +++ b/autotest/ogr/ogr_cloudant.py @@ -79,18 +79,13 @@ def test_ogr_cloudant_GetFeatureCount(): return 'skip' ds = ogr.Open('cloudant:%s/%s' % (ogrtest.cloudant_test_server, ogrtest.cloudant_test_layer)) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None count = lyr.GetFeatureCount() - if count != 52: - gdaltest.post_reason('did not get expected feature count') - print(count) - return 'fail' + assert count == 52, 'did not get expected feature count' return 'success' @@ -103,17 +98,13 @@ def test_ogr_cloudant_GetNextFeature(): return 'skip' ds = ogr.Open('cloudant:%s/%s' % (ogrtest.cloudant_test_server, ogrtest.cloudant_test_layer)) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('did not get expected feature') - return 'fail' + assert feat is not None, 'did not get expected feature' if feat.GetField('_id') != '0400000US01': gdaltest.post_reason('did not get expected feature') feat.DumpReadable() @@ -130,12 +121,10 @@ def test_ogr_cloudant_GetSpatialRef(): return 'skip' ds = ogr.Open('cloudant:%s/%s' % (ogrtest.cloudant_test_server, ogrtest.cloudant_test_layer)) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None sr = lyr.GetSpatialRef() @@ -153,22 +142,16 @@ def test_ogr_cloudant_GetExtent(): return 'skip' ds = ogr.Open('cloudant:%s/%s' % (ogrtest.cloudant_test_server, ogrtest.cloudant_test_layer)) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None extent = lyr.GetExtent() - if extent is None: - gdaltest.post_reason('did not get expected extent') - return 'fail' + assert extent is not None, 'did not get expected extent' - if extent != (-179.14734, 179.77847, 17.884813, 71.352561): - gdaltest.post_reason('did not get expected extent') - print(extent) - return 'fail' + assert extent == (-179.14734, 179.77847, 17.884813, 71.352561), \ + 'did not get expected extent' return 'success' @@ -184,19 +167,15 @@ def test_ogr_cloudant_SetSpatialFilter(): return 'skip' ds = ogr.Open('cloudant:%s/%s' % (ogrtest.cloudant_test_server, ogrtest.cloudant_test_layer)) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None lyr.SetSpatialFilterRect(-104.9847, 39.7392, -104.9847, 39.7392) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('did not get expected feature') - return 'fail' + assert feat is not None, 'did not get expected feature' if feat.GetField('NAME') != 'Colorado': gdaltest.post_reason('did not get expected feature') feat.DumpReadable() diff --git a/autotest/ogr/ogr_couchdb.py b/autotest/ogr/ogr_couchdb.py index 61a0904b50dd..14817d984c69 100755 --- a/autotest/ogr/ogr_couchdb.py +++ b/autotest/ogr/ogr_couchdb.py @@ -77,8 +77,7 @@ def test_ogr_couchdb_1(): layerName=ogrtest.couchdb_temp_layer_name, layerCreationOptions=['UPDATE_PERMISSIONS=ALL']) ds = ogr.Open('couchdb:%s' % ogrtest.couchdb_test_server, update=1) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName(ogrtest.couchdb_temp_layer_name) f = lyr.GetNextFeature() if f['AREA'] != 215229.266 or f['EAS_ID'] != '168' or f.GetGeometryRef() is None: @@ -97,8 +96,7 @@ def test_ogr_couchdb_2(): return 'skip' ds = ogr.Open('couchdb:%s' % ogrtest.couchdb_test_server, update=1) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.CreateLayer(ogrtest.couchdb_temp_layer_name, geom_type=ogr.wkbNone, options=['UPDATE_PERMISSIONS=ALL']) lyr.CreateField(ogr.FieldDefn('str_field', ogr.OFTString)) @@ -139,8 +137,7 @@ def test_ogr_couchdb_cleanup(): return 'skip' ds = ogr.Open('couchdb:%s' % ogrtest.couchdb_test_server, update=1) - if ds is None: - return 'fail' + assert ds is not None ds.ExecuteSQL('DELLAYER:' + ogrtest.couchdb_temp_layer_name) return 'success' diff --git a/autotest/ogr/ogr_csv.py b/autotest/ogr/ogr_csv.py index ab187208bff0..9878569412ad 100755 --- a/autotest/ogr/ogr_csv.py +++ b/autotest/ogr/ogr_csv.py @@ -62,8 +62,7 @@ def ogr_csv_check_layer(lyr, expect_code_as_numeric): expect = ['8901', '8902', '8903', '8904'] tr = ogrtest.check_features_against_list(lyr, 'PRIME_MERIDIAN_CODE', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() @@ -72,8 +71,7 @@ def ogr_csv_check_layer(lyr, expect_code_as_numeric): 'Instituto Geografico "Augustin Cadazzi" (IGAC); Bogota'] tr = ogrtest.check_features_against_list(lyr, 'INFORMATION_SOURCE', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() @@ -89,19 +87,15 @@ def test_ogr_csv_2(): return 'skip' with gdaltest.error_handler(): - if gdaltest.csv_ds.CreateLayer('foo') is not None: - return 'fail' - if gdaltest.csv_ds.DeleteLayer(0) == 0: - return 'fail' + assert gdaltest.csv_ds.CreateLayer('foo') is None + assert gdaltest.csv_ds.DeleteLayer(0) != 0 lyr = gdaltest.csv_ds.GetLayerByName('prime_meridian') f = ogr.Feature(lyr.GetLayerDefn()) with gdaltest.error_handler(): - if lyr.CreateField(ogr.FieldDefn('foo')) == 0: - return 'fail' - if lyr.CreateFeature(f) == 0: - return 'fail' + assert lyr.CreateField(ogr.FieldDefn('foo')) != 0 + assert lyr.CreateFeature(f) != 0 return ogr_csv_check_layer(lyr, False) @@ -172,14 +166,12 @@ def test_ogr_csv_3(): # No longer valid since we have editing capabilities if False: # pylint: disable=using-constant-test # Check that we cannot add a new field now - if gdaltest.csv_lyr1.TestCapability(ogr.OLCCreateField) != 0: - return 'fail' + assert gdaltest.csv_lyr1.TestCapability(ogr.OLCCreateField) == 0 field_defn = ogr.FieldDefn('dummy', ogr.OFTString) gdal.PushErrorHandler('CPLQuietErrorHandler') ret = gdaltest.csv_lyr1.CreateField(field_defn) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 return 'success' @@ -231,27 +223,19 @@ def test_ogr_csv_7(): return 'skip' lyr = gdaltest.csv_tmpds.GetLayer(0) - if lyr.GetName() != 'pm1': - gdaltest.post_reason('unexpected name for first layer') - return 'fail' + assert lyr.GetName() == 'pm1', 'unexpected name for first layer' gdaltest.csv_lyr1 = None err = gdaltest.csv_tmpds.DeleteLayer(0) - if err != 0: - gdaltest.post_reason('got error code from DeleteLayer') - return 'fail' + assert err == 0, 'got error code from DeleteLayer' - if gdaltest.csv_tmpds.GetLayerCount() != 1 \ - or gdaltest.csv_tmpds.GetLayer(0).GetName() != 'pm2': - gdaltest.post_reason('Layer not destroyed properly?') - return 'fail' + assert gdaltest.csv_tmpds.GetLayerCount() == 1 and gdaltest.csv_tmpds.GetLayer(0).GetName() == 'pm2', \ + 'Layer not destroyed properly?' with gdaltest.error_handler(): - if gdaltest.csv_tmpds.DeleteLayer(-1) == 0: - return 'fail' - if gdaltest.csv_tmpds.DeleteLayer(gdaltest.csv_tmpds.GetLayerCount()) == 0: - return 'fail' + assert gdaltest.csv_tmpds.DeleteLayer(-1) != 0 + assert gdaltest.csv_tmpds.DeleteLayer(gdaltest.csv_tmpds.GetLayerCount()) != 0 gdaltest.csv_tmpds = None @@ -297,8 +281,7 @@ def test_ogr_csv_9(): expect = ['8901', '8902', '8903', '8904', '7000'] tr = ogrtest.check_features_against_list(lyr, 'PRIME_MERIDIAN_CODE', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() @@ -308,8 +291,7 @@ def test_ogr_csv_9(): 'This is a newline test\n'] tr = ogrtest.check_features_against_list(lyr, 'INFORMATION_SOURCE', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() @@ -326,52 +308,40 @@ def test_ogr_csv_10(): lyr = gdaltest.csv_ds.GetLayerByName('prime_meridian') - if lyr.TestCapability('SequentialWrite'): - gdaltest.post_reason('should not have write access to readonly layer') - return 'fail' + assert not lyr.TestCapability('SequentialWrite'), \ + 'should not have write access to readonly layer' - if lyr.TestCapability('RandomRead'): - gdaltest.post_reason('CSV files do not efficiently support ' + assert not lyr.TestCapability('RandomRead'), \ + ('CSV files do not efficiently support ' 'random reading.') - return 'fail' - if lyr.TestCapability('FastGetExtent'): - gdaltest.post_reason('CSV files do not support getextent') - return 'fail' + assert not lyr.TestCapability('FastGetExtent'), 'CSV files do not support getextent' - if lyr.TestCapability('FastFeatureCount'): - gdaltest.post_reason('CSV files do not support fast feature count') - return 'fail' + assert not lyr.TestCapability('FastFeatureCount'), \ + 'CSV files do not support fast feature count' - if not ogr.GetDriverByName('CSV').TestCapability('DeleteDataSource'): - gdaltest.post_reason('CSV files do support DeleteDataSource') - return 'fail' + assert ogr.GetDriverByName('CSV').TestCapability('DeleteDataSource'), \ + 'CSV files do support DeleteDataSource' - if not ogr.GetDriverByName('CSV').TestCapability('CreateDataSource'): - gdaltest.post_reason('CSV files do support CreateDataSource') - return 'fail' + assert ogr.GetDriverByName('CSV').TestCapability('CreateDataSource'), \ + 'CSV files do support CreateDataSource' - if gdaltest.csv_ds.TestCapability('CreateLayer'): - gdaltest.post_reason('readonly datasource should not CreateLayer') - return 'fail' + assert not gdaltest.csv_ds.TestCapability('CreateLayer'), \ + 'readonly datasource should not CreateLayer' - if gdaltest.csv_ds.TestCapability('DeleteLayer'): - gdaltest.post_reason('should not have deletelayer on readonly ds.') - return 'fail' + assert not gdaltest.csv_ds.TestCapability('DeleteLayer'), \ + 'should not have deletelayer on readonly ds.' lyr = gdaltest.csv_tmpds.GetLayer(0) - if not lyr.TestCapability('SequentialWrite'): - gdaltest.post_reason('should have write access to updatable layer') - return 'fail' + assert lyr.TestCapability('SequentialWrite'), \ + 'should have write access to updatable layer' - if not gdaltest.csv_tmpds.TestCapability('CreateLayer'): - gdaltest.post_reason('should have createlayer on updatable ds.') - return 'fail' + assert gdaltest.csv_tmpds.TestCapability('CreateLayer'), \ + 'should have createlayer on updatable ds.' - if not gdaltest.csv_tmpds.TestCapability('DeleteLayer'): - gdaltest.post_reason('should have deletelayer on updatable ds.') - return 'fail' + assert gdaltest.csv_tmpds.TestCapability('DeleteLayer'), \ + 'should have deletelayer on updatable ds.' return 'success' @@ -384,83 +354,61 @@ def ogr_csv_check_testcsvt(lyr): expect = [12, None] tr = ogrtest.check_features_against_list(lyr, 'INTCOL', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = [5.7, None] tr = ogrtest.check_features_against_list(lyr, 'REALCOL', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['foo', ''] tr = ogrtest.check_features_against_list(lyr, 'STRINGCOL', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if feat.GetFieldAsString('DATETIME') != '2008/12/25 11:22:33': - print(feat.GetFieldAsString('DATETIME')) - return 'fail' + assert feat.GetFieldAsString('DATETIME') == '2008/12/25 11:22:33' feat = lyr.GetNextFeature() - if feat.GetFieldAsString('DATETIME') != '': - print(feat.GetFieldAsString('DATETIME')) - return 'fail' + assert feat.GetFieldAsString('DATETIME') == '' lyr.ResetReading() feat = lyr.GetNextFeature() - if feat.GetFieldAsString('DATE') != '2008/12/25': - print(feat.GetFieldAsString('DATE')) - return 'fail' + assert feat.GetFieldAsString('DATE') == '2008/12/25' feat = lyr.GetNextFeature() - if feat.GetFieldAsString('DATE') != '': - print(feat.GetFieldAsString('DATE')) - return 'fail' + assert feat.GetFieldAsString('DATE') == '' lyr.ResetReading() feat = lyr.GetNextFeature() - if feat.GetFieldAsString('TIME') != '11:22:33': - print(feat.GetFieldAsString('TIME')) - return 'fail' + assert feat.GetFieldAsString('TIME') == '11:22:33' feat = lyr.GetNextFeature() - if feat.GetFieldAsString('TIME') != '': - print(feat.GetFieldAsString('TIME')) - return 'fail' + assert feat.GetFieldAsString('TIME') == '' - if lyr.GetLayerDefn().GetFieldDefn(0).GetWidth() != 5: - gdaltest.post_reason('Field 0 : expecting width = 5') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetWidth() == 5, \ + 'Field 0 : expecting width = 5' - if lyr.GetLayerDefn().GetFieldDefn(1).GetWidth() != 10: - gdaltest.post_reason('Field 1 : expecting width = 10') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(1).GetWidth() == 10, \ + 'Field 1 : expecting width = 10' - if lyr.GetLayerDefn().GetFieldDefn(1).GetPrecision() != 7: - gdaltest.post_reason('Field 1 : expecting precision = 7') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(1).GetPrecision() == 7, \ + 'Field 1 : expecting precision = 7' - if lyr.GetLayerDefn().GetFieldDefn(2).GetWidth() != 15: - gdaltest.post_reason('Field 2 : expecting width = 15') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(2).GetWidth() == 15, \ + 'Field 2 : expecting width = 15' - if lyr.GetLayerDefn().GetFieldDefn(6).GetType() != ogr.OFTDateTime: - gdaltest.post_reason('Field DATETIME : wrong type') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(6).GetType() == ogr.OFTDateTime, \ + 'Field DATETIME : wrong type' - if lyr.GetLayerDefn().GetFieldDefn(7).GetType() != ogr.OFTDate: - gdaltest.post_reason('Field DATETIME : wrong type') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(7).GetType() == ogr.OFTDate, \ + 'Field DATETIME : wrong type' - if lyr.GetLayerDefn().GetFieldDefn(8).GetType() != ogr.OFTTime: - gdaltest.post_reason('Field DATETIME : wrong type') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(8).GetType() == ogr.OFTTime, \ + 'Field DATETIME : wrong type' lyr.ResetReading() @@ -479,8 +427,7 @@ def test_ogr_csv_11(): gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/testcsvt.csv') - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testcsvt') @@ -527,8 +474,7 @@ def test_ogr_csv_12(): feat = srclyr.GetNextFeature() with gdaltest.error_handler(): - if gdaltest.csv_tmpds.CreateLayer('testcsvt_copy') is not None: - return 'fail' + assert gdaltest.csv_tmpds.CreateLayer('testcsvt_copy') is None ####################################################### # Closes everything and reopen @@ -539,8 +485,7 @@ def test_ogr_csv_12(): ####################################################### # Checks copy - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testcsvt_copy') @@ -565,8 +510,7 @@ def test_ogr_csv_13(): lyr.CreateField(field_defn) # Some applications expect the WKT column not to be exposed. Check it - if lyr.GetLayerDefn().GetFieldCount() != 1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 1 dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1 2)')) @@ -634,85 +578,71 @@ def test_ogr_csv_13(): expect = ['POINT (1 2)'] tr = ogrtest.check_features_against_list(lyr, 'WKT', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['avalue'] tr = ogrtest.check_features_against_list(lyr, 'ADATA', expect) - if not tr: - return 'fail' + assert tr # Test as_wkt_no_field lyr = gdaltest.csv_tmpds.GetLayerByName('as_wkt_no_field') expect = ['POINT (1 2)'] tr = ogrtest.check_features_against_list(lyr, 'WKT', expect) - if not tr: - return 'fail' + assert tr # Test AS_XY lyr = gdaltest.csv_tmpds.GetLayerByName('as_xy') - if lyr.GetLayerDefn().GetFieldDefn(0).GetName() != 'X': - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetName() == 'X' expect = [1, None] tr = ogrtest.check_features_against_list(lyr, 'X', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = [2, None] tr = ogrtest.check_features_against_list(lyr, 'Y', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['avalue', 'avalue'] tr = ogrtest.check_features_against_list(lyr, 'ADATA', expect) - if not tr: - return 'fail' + assert tr # Test AS_YX lyr = gdaltest.csv_tmpds.GetLayerByName('as_yx') - if lyr.GetLayerDefn().GetFieldDefn(0).GetName() != 'Y': - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetName() == 'Y' expect = [1] tr = ogrtest.check_features_against_list(lyr, 'X', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = [2] tr = ogrtest.check_features_against_list(lyr, 'Y', expect) - if not tr: - return 'fail' + assert tr # Test AS_XYZ lyr = gdaltest.csv_tmpds.GetLayerByName('as_xyz') - if lyr.GetLayerDefn().GetFieldDefn(0).GetName() != 'X': - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetName() == 'X' expect = [1] tr = ogrtest.check_features_against_list(lyr, 'X', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = [2] tr = ogrtest.check_features_against_list(lyr, 'Y', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = [3] tr = ogrtest.check_features_against_list(lyr, 'Z', expect) - if not tr: - return 'fail' + assert tr return 'success' @@ -772,23 +702,19 @@ def test_ogr_csv_17(): csv_ds = ogr.Open('data/wkt.csv') csv_lyr = csv_ds.GetLayer(0) - if csv_lyr.GetLayerDefn().GetGeomType() != ogr.wkbUnknown: - gdaltest.post_reason('did not get wktUnknown for geometry type.') - return 'fail' + assert csv_lyr.GetLayerDefn().GetGeomType() == ogr.wkbUnknown, \ + 'did not get wktUnknown for geometry type.' feat = csv_lyr.GetNextFeature() - if feat.GetField('WKT') != 'POLYGON((6.25 1.25,7.25 1.25,7.25 2.25,6.25 2.25,6.25 1.25))': - gdaltest.post_reason('feature 1: expected wkt value') - return 'fail' + assert feat.GetField('WKT') == 'POLYGON((6.25 1.25,7.25 1.25,7.25 2.25,6.25 2.25,6.25 1.25))', \ + 'feature 1: expected wkt value' - if ogrtest.check_feature_geometry(feat, 'POLYGON((6.25 1.25,7.25 1.25,7.25 2.25,6.25 2.25,6.25 1.25))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON((6.25 1.25,7.25 1.25,7.25 2.25,6.25 2.25,6.25 1.25))') feat = csv_lyr.GetNextFeature() feat = csv_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POLYGON((1.001 1.001,3.999 3.999,3.2 1.6,1.001 1.001))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON((1.001 1.001,3.999 3.999,3.2 1.6,1.001 1.001))') return 'success' @@ -823,27 +749,21 @@ def test_ogr_csv_19(): gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/testnull.csv') - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testnull') lyr.ResetReading() with gdaltest.error_handler(): - if not ogrtest.check_features_against_list(lyr, 'INTCOL', [12]): - return 'fail' + assert ogrtest.check_features_against_list(lyr, 'INTCOL', [12]) lyr.ResetReading() - if not ogrtest.check_features_against_list(lyr, 'REALCOL', [5.7]): - return 'fail' + assert ogrtest.check_features_against_list(lyr, 'REALCOL', [5.7]) lyr.ResetReading() - if not ogrtest.check_features_against_list(lyr, 'INTCOL2', [None]): - return 'fail' + assert ogrtest.check_features_against_list(lyr, 'INTCOL2', [None]) lyr.ResetReading() - if not ogrtest.check_features_against_list(lyr, 'REALCOL2', [None]): - return 'fail' + assert ogrtest.check_features_against_list(lyr, 'REALCOL2', [None]) lyr.ResetReading() - if not ogrtest.check_features_against_list(lyr, 'STRINGCOL', ['foo']): - return 'fail' + assert ogrtest.check_features_against_list(lyr, 'STRINGCOL', ['foo']) return 'success' @@ -859,44 +779,36 @@ def test_ogr_csv_20(): gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/testnumheader1.csv') - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testnumheader1') - if lyr is None: - return 'fail' + assert lyr is not None lyr.ResetReading() expect = ['1 - 2', '2-3'] got = [lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef(), lyr.GetLayerDefn().GetFieldDefn(1).GetNameRef()] - if got[0] != expect[0]: - print('column 0 got name %s expected %s' % (str(got[0]), str(expect[0]))) - return 'fail' - if got[1] != expect[1]: - print('column 1 got name %s expected %s' % (str(got[1]), str(expect[1]))) - return 'fail' + assert got[0] == expect[0], \ + ('column 0 got name %s expected %s' % (str(got[0]), str(expect[0]))) + assert got[1] == expect[1], \ + ('column 1 got name %s expected %s' % (str(got[1]), str(expect[1]))) gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/testnumheader2.csv') - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testnumheader2') - if lyr is None: - return 'fail' + assert lyr is not None lyr.ResetReading() expect = ['field_1', 'field_2'] got = [lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef(), lyr.GetLayerDefn().GetFieldDefn(1).GetNameRef()] - if got[0] != expect[0]: - print('column 0 got name %s expected %s' % (str(got[0]), str(expect[0]))) - return 'fail' - if got[1] != expect[1]: - print('column 1 got name %s expected %s' % (str(got[1]), str(expect[1]))) - return 'fail' + assert got[0] == expect[0], \ + ('column 0 got name %s expected %s' % (str(got[0]), str(expect[0]))) + assert got[1] == expect[1], \ + ('column 1 got name %s expected %s' % (str(got[1]), str(expect[1]))) return 'success' @@ -912,38 +824,32 @@ def test_ogr_csv_21(): gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/testquoteheader1.csv') - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testquoteheader1') - if lyr is None: - return 'fail' + assert lyr is not None lyr.ResetReading() expect = ['test', '2000', '2000.12'] for i in range(0, 3): got = lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef() - if got != expect[i]: - print('column %d got name %s expected %s' % (i, str(got), str(expect[i]))) - return 'fail' + assert got == expect[i], \ + ('column %d got name %s expected %s' % (i, str(got), str(expect[i]))) gdaltest.csv_ds = None gdaltest.csv_ds = ogr.Open('data/testquoteheader2.csv') - if gdaltest.csv_ds is None: - return 'fail' + assert gdaltest.csv_ds is not None lyr = gdaltest.csv_ds.GetLayerByName('testquoteheader2') - if lyr is None: - return 'fail' + assert lyr is not None lyr.ResetReading() expect = ['field_1', 'field_2', 'field_3'] for i in range(0, 3): got = lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef() - if got != expect[i]: - print('column %d got name %s expected %s' % (i, str(got), str(expect[i]))) - return 'fail' + assert got == expect[i], \ + ('column %d got name %s expected %s' % (i, str(got), str(expect[i]))) return 'success' @@ -957,10 +863,7 @@ def test_ogr_csv_22(): lyr = ds.GetLayer(0) fld0_name = lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef() - if fld0_name != 'id': - gdaltest.post_reason('bad field name') - print(fld0_name) - return 'fail' + assert fld0_name == 'id', 'bad field name' return 'success' @@ -988,9 +891,7 @@ def test_ogr_csv_23(): exec("ogrtest.ret = (data[:6] == b'\\xef\\xbb\\xbfWKT')") else: ogrtest.ret = (data[:6] == '\xef\xbb\xbfWKT') - if not ogrtest.ret: - gdaltest.post_reason("No UTF8 BOM header on output") - return 'fail' + assert ogrtest.ret, "No UTF8 BOM header on output" # create a CSV file without UTF8 BOM ds = ogr.Open('tmp/csvwrk', update=1) @@ -1009,9 +910,7 @@ def test_ogr_csv_23(): ds = None data = open('tmp/csvwrk/utf8no.csv', 'rb').read() - if data[:3] == '\xef\xbb\xbfWKT': - gdaltest.post_reason("Found UTF8 BOM header on output!") - return 'fail' + assert data[:3] != '\xef\xbb\xbfWKT', "Found UTF8 BOM header on output!" return 'success' @@ -1040,14 +939,11 @@ def test_ogr_csv_24(): ds = ogr.Open('/vsimem/single.csv') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 1 feat = lyr.GetNextFeature() - if feat.GetField(0) != '': - return 'fail' + assert feat.GetField(0) == '' feat = lyr.GetNextFeature() - if feat.GetField(0) != 'bar': - return 'fail' + assert feat.GetField(0) == 'bar' ds = None gdal.Unlink('/vsimem/single.csv') @@ -1074,9 +970,8 @@ def test_ogr_csv_25(): EXPECTED = 'foo,\n"windows newline:\r\nlinux newline:\nend of string:"\n' data = open('tmp/csvwrk/newlines.csv', 'rb').read().decode('ascii') - if data != EXPECTED: - gdaltest.post_reason("Newlines changed:\n\texpected=%s\n\tgot= %s" % (repr(EXPECTED), repr(data))) - return 'fail' + assert data == EXPECTED, \ + ("Newlines changed:\n\texpected=%s\n\tgot= %s" % (repr(EXPECTED), repr(data))) return 'success' @@ -1107,9 +1002,7 @@ def test_ogr_csv_26(): EXPECTED = 'foo,\n10.5000000000000000000000000\n' data = open('tmp/csvwrk/num_padding.csv', 'rb').read().decode('ascii') - if data != EXPECTED: - gdaltest.post_reason("expected=%s got= %s" % (repr(EXPECTED), repr(data))) - return 'fail' + assert data == EXPECTED, ("expected=%s got= %s" % (repr(EXPECTED), repr(data))) return 'success' @@ -1122,8 +1015,7 @@ def test_ogr_csv_27(): ds = ogr.Open('data/test_eurostat.tsv') lyr = ds.GetLayer(0) layer_defn = lyr.GetLayerDefn() - if layer_defn.GetFieldCount() != 8: - return 'fail' + assert layer_defn.GetFieldCount() == 8 expected_fields = [('unit', ogr.OFTString), ('geo', ogr.OFTString), @@ -1136,14 +1028,8 @@ def test_ogr_csv_27(): i = 0 for expected_field in expected_fields: fld = layer_defn.GetFieldDefn(i) - if fld.GetName() != expected_field[0]: - print(fld.GetName()) - print(expected_field[0]) - return 'fail' - if fld.GetType() != expected_field[1]: - print(fld.GetType()) - print(expected_field[1]) - return 'fail' + assert fld.GetName() == expected_field[0] + assert fld.GetType() == expected_field[1] i = i + 1 feat = lyr.GetNextFeature() @@ -1179,9 +1065,7 @@ def test_ogr_csv_28(): os.unlink('tmp/ogr_csv_28.csv') - if data != '1,2\n': - print(data) - return 'fail' + assert data == '1,2\n' return 'success' @@ -1192,16 +1076,12 @@ def test_ogr_csv_28(): def test_ogr_csv_29(): ds = ogr.GetDriverByName('CSV').CreateDataSource('tmp/ogr_csv_29', options=['GEOMETRY=AS_WKT']) - if ds.TestCapability(ogr.ODsCCurveGeometries) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCCurveGeometries) == 1 lyr = ds.CreateLayer('test', geom_type=ogr.wkbNone) - if lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr1_EPSG_4326", ogr.wkbPoint)) != 0: - return 'fail' - if lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr2_EPSG_32632", ogr.wkbPolygon)) != 0: - return 'fail' + assert lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr1_EPSG_4326", ogr.wkbPoint)) == 0 + assert lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr2_EPSG_32632", ogr.wkbPolygon)) == 0 with gdaltest.error_handler(): - if lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr2_EPSG_32632", ogr.wkbPolygon)) == 0: - return 'fail' + assert lyr.CreateGeomField(ogr.GeomFieldDefn("geom__WKT_lyr2_EPSG_32632", ogr.wkbPolygon)) != 0 ds = None ds = ogr.Open('tmp/ogr_csv_29', update=1) @@ -1214,14 +1094,11 @@ def test_ogr_csv_29(): ds = ogr.Open('tmp/ogr_csv_29') lyr = ds.GetLayerByName('test') - if lyr.GetLayerDefn().GetGeomFieldCount() != 2: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldCount() == 2 srs = lyr.GetLayerDefn().GetGeomFieldDefn(0).GetSpatialRef() - if srs.GetAuthorityCode(None) != '4326': - return 'fail' + assert srs.GetAuthorityCode(None) == '4326' srs = lyr.GetLayerDefn().GetGeomFieldDefn(1).GetSpatialRef() - if srs.GetAuthorityCode(None) != '32632': - return 'fail' + assert srs.GetAuthorityCode(None) == '32632' feat = lyr.GetNextFeature() geom = feat.GetGeomFieldRef('geom__WKT_lyr1_EPSG_4326') if geom.ExportToWkt() != 'POINT (1 2)': @@ -1247,9 +1124,7 @@ def test_ogr_csv_30(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/ogr_csv_29') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -1273,9 +1148,7 @@ def test_ogr_csv_31(): f.DumpReadable() return 'fail' - if lyr.GetFeatureCount() != 10: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 10 return 'success' @@ -1293,12 +1166,8 @@ def test_ogr_csv_32(): col_values = ['', '1.5', '1', '1.5', '2', '', '2014-09-27 19:01:00', '2014-09-27', '2014-09-27 20:00:00', '2014-09-27', '12:34:56', 'a', 'a', '1', '1', '1.5', '2014-09-27 19:01:00', '2014-09-27', '19:01:00', '2014-09-27T00:00:00Z'] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTString or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == ogr.OFTString and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() == 0) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1310,12 +1179,8 @@ def test_ogr_csv_32(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTString or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == ogr.OFTString and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() == 0) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1332,12 +1197,8 @@ def test_ogr_csv_32(): col_values = ['', 1.5, 1, 1.5, 2, '', '2014/09/27 19:01:00', '2014/09/27', '2014/09/27 20:00:00', '2014/09/27', '12:34:56', 'a', 'a', '1', 1, 1.5, '2014/09/27 19:01:00', '2014/09/27', '19:01:00', '2014/09/27 00:00:00+00'] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == col_type[i] and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() == 0) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1347,8 +1208,7 @@ def test_ogr_csv_32(): ds = gdal.OpenEx('data/testtypeautodetect.csv', gdal.OF_VECTOR, open_options=['AUTODETECT_TYPE=YES', 'AUTODETECT_SIZE_LIMIT=300']) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str3')).GetType() != ogr.OFTInteger: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str3')).GetType() == ogr.OFTInteger # We limit to the first 2 lines ds = gdal.OpenEx('data/testtypeautodetect.csv', gdal.OF_VECTOR, @@ -1361,12 +1221,8 @@ def test_ogr_csv_32(): col_values = ['', 1.5, 1, 1.5, 2, None, '2014/09/27 19:01:00', '2014/09/27 00:00:00', '2014/09/27 20:00:00', '2014/09/27', '12:34:56', 'a', 'a', '1', '1', '1.5', '2014-09-27 19:01:00', '2014-09-27', '19:01:00', '2014/09/27 00:00:00+00'] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != 0: - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == col_type[i] and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() == 0) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1381,14 +1237,9 @@ def test_ogr_csv_32(): col_precision = [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != col_width[i] or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision() != col_precision[i]: - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == col_type[i] and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() == col_width[i] and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision() == col_precision[i]) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1403,14 +1254,9 @@ def test_ogr_csv_32(): col_precision = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != col_type[i] or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() != col_width[i] or \ - lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision() != col_precision[i]: - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetType()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetWidth()) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == col_type[i] and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetWidth() == col_width[i] and \ + lyr.GetLayerDefn().GetFieldDefn(i).GetPrecision() == col_precision[i]) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1427,12 +1273,8 @@ def test_ogr_csv_32(): '2014/09/27 00:00:00+00', '2014-09-27T00:00:00Z'] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTString and \ - lyr.GetLayerDefn().GetFieldDefn(i + 1).GetNameRef() != lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef() + '_original': - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef()) - print(lyr.GetLayerDefn().GetFieldDefn(i + 1).GetNameRef()) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(i).GetType() == ogr.OFTString or \ + lyr.GetLayerDefn().GetFieldDefn(i + 1).GetNameRef() == lyr.GetLayerDefn().GetFieldDefn(i).GetNameRef() + '_original') if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1487,11 +1329,8 @@ def test_ogr_csv_33(): f = lyr.GetNextFeature() col_values = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 'y'] for i in range(lyr.GetLayerDefn().GetFieldCount()): - if (i < 10 and lyr.GetLayerDefn().GetFieldDefn(i).GetSubType() != ogr.OFSTBoolean) or \ - (i >= 10 and lyr.GetLayerDefn().GetFieldDefn(i).GetSubType() == ogr.OFSTBoolean): - print(i) - print(lyr.GetLayerDefn().GetFieldDefn(i).GetSubType()) - return 'fail' + assert (not (i < 10 and lyr.GetLayerDefn().GetFieldDefn(i).GetSubType() != ogr.OFSTBoolean) or \ + (i >= 10 and lyr.GetLayerDefn().GetFieldDefn(i).GetSubType() == ogr.OFSTBoolean)) if f.GetField(i) != col_values[i]: print(i) f.DumpReadable() @@ -1519,15 +1358,12 @@ def test_ogr_csv_33(): ds = ogr.Open('/vsimem/subtypes.csv') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTInteger or \ - lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTBoolean: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(1).GetType() != ogr.OFTInteger or \ - lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTInt16: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(2).GetType() != ogr.OFTReal or \ - lyr.GetLayerDefn().GetFieldDefn(2).GetSubType() != ogr.OFSTFloat32: - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(0).GetType() == ogr.OFTInteger and \ + lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() == ogr.OFSTBoolean) + assert (lyr.GetLayerDefn().GetFieldDefn(1).GetType() == ogr.OFTInteger and \ + lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() == ogr.OFSTInt16) + assert (lyr.GetLayerDefn().GetFieldDefn(2).GetType() == ogr.OFTReal and \ + lyr.GetLayerDefn().GetFieldDefn(2).GetSubType() == ogr.OFSTFloat32) f = lyr.GetNextFeature() if f.GetField(0) != 1 or f.GetField(1) != -32768 or f.GetField(2) != 1.23: f.DumpReadable() @@ -1623,9 +1459,7 @@ def test_ogr_csv_35(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('FIELD_1 "FIELD 2"') < 0 or data.find('VAL1 "VAL 2"') < 0: - print(data) - return 'fail' + assert data.find('FIELD_1 "FIELD 2"') >= 0 and data.find('VAL1 "VAL 2"') >= 0 gdal.Unlink('/vsimem/ogr_csv_35.csv') @@ -1705,16 +1539,14 @@ def test_ogr_csv_36(): ds = gdal.OpenEx('/vsimem/ogr_csv_36.csv', gdal.OF_VECTOR, open_options=['GEOM_POSSIBLE_NAMES=bla']) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetGeomFieldCount() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldCount() == 0 ds = None # Check KEEP_GEOM_COLUMNS=NO ds = gdal.OpenEx('/vsimem/ogr_csv_36.csv', gdal.OF_VECTOR, open_options=['GEOM_POSSIBLE_NAMES=mygeometry', 'KEEP_GEOM_COLUMNS=NO']) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 2: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 2 f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (1 2)' or f['id'] != '1' or f['format'] != 'wkt': f.DumpReadable() @@ -1777,8 +1609,7 @@ def test_ogr_csv_37(): ds = gdal.OpenEx('/vsimem/ogr_csv_37.csv', gdal.OF_VECTOR, open_options=['X_POSSIBLE_NAMES=long,x', 'Y_POSSIBLE_NAMES=lat,y', 'KEEP_GEOM_COLUMNS=NO']) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 3: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 3 f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)' or f['id'] != '1' or f['other'] != 'a': f.DumpReadable() @@ -1808,10 +1639,8 @@ def test_ogr_csv_38(): ds = ogr.Open('/vsimem/ogr_csv_38.csv') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetGeomFieldDefn(0).GetName() != 'mygeom': - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(0).GetSpatialRef().ExportToWkt().find('4326') < 0: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).GetName() == 'mygeom' + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).GetSpatialRef().ExportToWkt().find('4326') >= 0 f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': f.DumpReadable() @@ -1930,8 +1759,7 @@ def test_ogr_csv_42(): lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTInteger)) f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 1) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 ds = None gdal.Unlink('/vsimem/ogr_csv_42.csv') @@ -1949,8 +1777,7 @@ def test_ogr_csv_43(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 1) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(2 49)')) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 f = None lyr.SetNextByIndex(0) f = lyr.GetNextFeature() @@ -1959,19 +1786,14 @@ def test_ogr_csv_43(): return 'fail' f = None - if lyr.TestCapability(ogr.OLCCreateField) != 1: - return 'fail' - if lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCCreateField) == 1 + assert lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) == 0 with gdaltest.error_handler(): - if lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) == 0: - return 'fail' + assert lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) != 0 f = lyr.GetFeature(1) f.SetField('foo', 'bar') - if lyr.TestCapability(ogr.OLCRandomWrite) != 1: - return 'fail' - if lyr.SetFeature(f) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCRandomWrite) == 1 + assert lyr.SetFeature(f) == 0 f = lyr.GetFeature(1) if f['id'] != 1 or f['foo'] != 'bar' or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': f.DumpReadable() @@ -1982,24 +1804,19 @@ def test_ogr_csv_43(): f.DumpReadable() return 'fail' f = lyr.GetNextFeature() - if f is not None: - return 'fail' - if lyr.GetFeatureCount() != 1: - return 'fail' + assert f is None + assert lyr.GetFeatureCount() == 1 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 2) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(3 50)')) f.SetField('foo', 'baz') - if lyr.CreateFeature(f) != 0: - return 'fail' - if f.GetFID() != 2: - return 'fail' + assert lyr.CreateFeature(f) == 0 + assert f.GetFID() == 2 f = lyr.GetFeature(2) if f['id'] != 2 or f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 50)': f.DumpReadable() return 'fail' - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 lyr.SetNextByIndex(1) f = lyr.GetNextFeature() if f['id'] != 2: @@ -2020,47 +1837,31 @@ def test_ogr_csv_43(): f.DumpReadable() return 'fail' f = None - if lyr.TestCapability(ogr.OLCDeleteField) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCDeleteField) == 1 with gdaltest.error_handler(): - if lyr.DeleteField(-1) == 0: - return 'fail' - if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foo')) != 0: - return 'fail' - if lyr.TestCapability(ogr.OLCDeleteFeature) != 1: - return 'fail' - if lyr.DeleteFeature(2) != 0: - return 'fail' - if lyr.DeleteFeature(2) != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' - if lyr.DeleteFeature(3) != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' - if lyr.GetFeature(2) is not None: - return 'fail' - if lyr.GetFeature(3) is not None: - return 'fail' + assert lyr.DeleteField(-1) != 0 + assert lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foo')) == 0 + assert lyr.TestCapability(ogr.OLCDeleteFeature) == 1 + assert lyr.DeleteFeature(2) == 0 + assert lyr.DeleteFeature(2) == ogr.OGRERR_NON_EXISTING_FEATURE + assert lyr.DeleteFeature(3) == ogr.OGRERR_NON_EXISTING_FEATURE + assert lyr.GetFeature(2) is None + assert lyr.GetFeature(3) is None lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None f = ogr.Feature(lyr.GetLayerDefn()) f['id'] = 3 - if lyr.CreateFeature(f) != 0: - return 'fail' - if f.GetFID() != 3: - return 'fail' + assert lyr.CreateFeature(f) == 0 + assert f.GetFID() == 3 f = None - if lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) != 0: - return 'fail' + assert lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) == 0 f = lyr.GetFeature(1) - if f['foo'] == 'bar': - return 'fail' + assert f['foo'] != 'bar' f = lyr.GetFeature(3) - if f.GetFID() != 3: - return 'fail' + assert f.GetFID() == 3 f = None ds = None @@ -2071,21 +1872,16 @@ def test_ogr_csv_43(): f.DumpReadable() return 'fail' f = None - if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foo')) != 0: - return 'fail' + assert lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foo')) == 0 f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(4 51)')) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 if f.GetFID() != 3: f.DumpReadable() return 'fail' - if lyr.GetExtent() != (2.0, 4.0, 49.0, 51.0): - return 'fail' - if lyr.DeleteFeature(f.GetFID()) != 0: - return 'fail' - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetExtent() == (2.0, 4.0, 49.0, 51.0) + assert lyr.DeleteFeature(f.GetFID()) == 0 + assert lyr.GetFeatureCount() == 2 with gdaltest.error_handler(): lyr.SetSpatialFilter(-1, None) @@ -2095,59 +1891,42 @@ def test_ogr_csv_43(): lyr.SetSpatialFilterRect(0, 0, 0, 100, 100) lyr.SetSpatialFilter(0, lyr.GetSpatialFilter()) lyr.SetSpatialFilter(lyr.GetSpatialFilter()) - if lyr.GetFeatureCount() != 1: - return 'fail' - if lyr.GetExtent() != (2.0, 2.0, 49.0, 49.0): - return 'fail' - if lyr.GetExtent(geom_field=0) != (2.0, 2.0, 49.0, 49.0): - return 'fail' + assert lyr.GetFeatureCount() == 1 + assert lyr.GetExtent() == (2.0, 2.0, 49.0, 49.0) + assert lyr.GetExtent(geom_field=0) == (2.0, 2.0, 49.0, 49.0) with gdaltest.error_handler(): lyr.GetExtent(geom_field=-1) lyr.SetAttributeFilter(None) - if lyr.TestCapability(ogr.OLCCurveGeometries) != 1: - return 'fail' - if lyr.TestCapability(ogr.OLCTransactions) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCCurveGeometries) == 1 + assert lyr.TestCapability(ogr.OLCTransactions) == 0 lyr.StartTransaction() lyr.RollbackTransaction() lyr.CommitTransaction() - if lyr.GetGeometryColumn() != '': - return 'fail' - if lyr.GetFIDColumn() != '': - return 'fail' + assert lyr.GetGeometryColumn() == '' + assert lyr.GetFIDColumn() == '' - if lyr.TestCapability(ogr.OLCReorderFields) != 1: - return 'fail' - if lyr.ReorderFields([0, 1]) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCReorderFields) == 1 + assert lyr.ReorderFields([0, 1]) == 0 with gdaltest.error_handler(): - if lyr.ReorderFields([0, -1]) == 0: - return 'fail' + assert lyr.ReorderFields([0, -1]) != 0 - if lyr.TestCapability(ogr.OLCAlterFieldDefn) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCAlterFieldDefn) == 1 fld_defn = lyr.GetLayerDefn().GetFieldDefn(0) - if lyr.AlterFieldDefn(0, fld_defn, 0) != 0: - return 'fail' + assert lyr.AlterFieldDefn(0, fld_defn, 0) == 0 with gdaltest.error_handler(): - if lyr.AlterFieldDefn(-1, fld_defn, 0) == 0: - return 'fail' + assert lyr.AlterFieldDefn(-1, fld_defn, 0) != 0 f = lyr.GetFeature(2) f.SetGeomField(0, ogr.CreateGeometryFromWkt('POINT (1 2)')) - if lyr.SetFeature(f) != 0: - return 'fail' + assert lyr.SetFeature(f) == 0 f = None - if lyr.TestCapability(ogr.OLCCreateGeomField) != 1: - return 'fail' - if lyr.CreateGeomField(ogr.GeomFieldDefn('geom__WKT_2')) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCCreateGeomField) == 1 + assert lyr.CreateGeomField(ogr.GeomFieldDefn('geom__WKT_2')) == 0 f = lyr.GetFeature(2) f.SetGeomField(1, ogr.CreateGeometryFromWkt('POINT (3 4)')) - if lyr.SetFeature(f) != 0: - return 'fail' + assert lyr.SetFeature(f) == 0 f = None ds = None @@ -2158,15 +1937,11 @@ def test_ogr_csv_43(): if f['WKT'] != 'POINT (1 2)' or f['_WKT_2'] != 'POINT (3 4)': f.DumpReadable() return 'fail' - if lyr.SetFeature(f) != 0: - return 'fail' + assert lyr.SetFeature(f) == 0 f = None - if lyr.DeleteFeature(2) != 0: - return 'fail' - if lyr.GetFeature(2) is not None: - return 'fail' - if lyr.DeleteFeature(2) != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert lyr.DeleteFeature(2) == 0 + assert lyr.GetFeature(2) is None + assert lyr.DeleteFeature(2) == ogr.OGRERR_NON_EXISTING_FEATURE ds = None gdal.Unlink('/vsimem/ogr_csv_43.csv') @@ -2185,8 +1960,7 @@ def test_ogr_csv_44(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 1) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(2 49)')) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 f = None f = lyr.GetFeature(1) if f['id'] != 1 or f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': @@ -2194,8 +1968,7 @@ def test_ogr_csv_44(): return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 2) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 f = lyr.GetFeature(2) if f['id'] != 2 or f.GetGeometryRef() is not None: f.DumpReadable() @@ -2223,8 +1996,7 @@ def test_ogr_csv_45(): ds2 = ogr.Open('/vsimem/ogr_csv_45.csv') lyr2 = ds2.GetLayer(0) - if lyr2.GetLayerDefn().GetFieldCount() != 3: - return 'fail' + assert lyr2.GetLayerDefn().GetFieldCount() == 3 ds2 = None ds = None @@ -2263,8 +2035,7 @@ def test_ogr_csv_46(): ds = ogr.Open('/vsimem/ogr_csv_46.csv') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 4: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 4 f = lyr.GetNextFeature() if f['id'] != '1' or f['X'] != '10' or f['Y'] != '20' or f['Z'] != '3': f.DumpReadable() @@ -2281,8 +2052,7 @@ def test_ogr_csv_46(): ds = ogr.Open('/vsimem/ogr_csv_46.csv') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 4: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 4 f = lyr.GetNextFeature() if f['id'] != '1' or f['X'] != '-10' or f['Y'] != '-20' or f['Z'] != '3': f.DumpReadable() @@ -2299,8 +2069,7 @@ def test_ogr_csv_46(): ds = ogr.Open('/vsimem/ogr_csv_46.csv') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 4: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 4 f = lyr.GetNextFeature() if f['id'] != '1' or f['X'] != '-1' or f['Y'] != '-2' or f['Z'] != '-3': f.DumpReadable() @@ -2318,11 +2087,9 @@ def test_ogr_csv_46(): def test_ogr_csv_47(): ds = ogr.GetDriverByName('CSV').CreateDataSource('/vsimem/ogr_csv_47.csv') - if ds.TestCapability(ogr.ODsCMeasuredGeometries) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCMeasuredGeometries) == 1 lyr = ds.CreateLayer('ogr_csv_47', options=['GEOMETRY=AS_WKT']) - if lyr.TestCapability(ogr.OLCMeasuredGeometries) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCMeasuredGeometries) == 1 lyr.CreateField(ogr.FieldDefn('id', ogr.OFTInteger)) f = ogr.Feature(lyr.GetLayerDefn()) f['id'] = 1 @@ -2361,17 +2128,13 @@ def test_ogr_csv_48(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('stringlist,intlist,int64list,reallist\n"[ ""a"", """" ]",[ 1 ],[ 1234567890123 ],[ 0.125') != 0: - print(data) - return 'fail' + assert data.find('stringlist,intlist,int64list,reallist\n"[ ""a"", """" ]",[ 1 ],[ 1234567890123 ],[ 0.125') == 0 f = gdal.VSIFOpenL('/vsimem/ogr_csv_48_out.csvt', 'rb') data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('JSonStringList,JSonIntegerList,JSonInteger64List,JSonRealList') != 0: - print(data) - return 'fail' + assert data.find('JSonStringList,JSonIntegerList,JSonInteger64List,JSonRealList') == 0 gdal.Unlink('/vsimem/ogr_csv_48.csv') gdal.Unlink('/vsimem/ogr_csv_48.csvt') @@ -2428,9 +2191,7 @@ def test_ogr_csv_string_quoting_always(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('"AREA","EAS_ID","PRFEDEA"\n215229.266,"168","35043411"') != 0: - print(data) - return 'fail' + assert data.find('"AREA","EAS_ID","PRFEDEA"\n215229.266,"168","35043411"') == 0 ds = gdal.OpenEx('/vsimem/ogr_csv_string_quoting_always.csv', gdal.OF_UPDATE | gdal.OF_VECTOR) gdal.VectorTranslate(ds, 'data/poly.shp', @@ -2442,9 +2203,7 @@ def test_ogr_csv_string_quoting_always(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('"AREA","EAS_ID","PRFEDEA"\n215229.266,"168","35043411"\n247328.172,"179","35043423"') != 0: - print(data) - return 'fail' + assert data.find('"AREA","EAS_ID","PRFEDEA"\n215229.266,"168","35043411"\n247328.172,"179","35043423"') == 0 gdal.Unlink('/vsimem/ogr_csv_string_quoting_always.csv') gdal.Unlink('/vsimem/ogr_csv_string_quoting_always.csvt') @@ -2475,9 +2234,7 @@ def test_ogr_csv_string_quoting_if_ambiguous(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('"00123",x,"1.25"') < 0: - print(data) - return 'fail' + assert data.find('"00123",x,"1.25"') >= 0 gdal.Unlink('/vsimem/ogr_csv_string_quoting_if_ambiguous.csv') @@ -2507,9 +2264,7 @@ def test_ogr_csv_string_quoting_if_needed(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('00123,x,1.25') < 0: - print(data) - return 'fail' + assert data.find('00123,x,1.25') >= 0 gdal.Unlink('/vsimem/ogr_csv_string_quoting_if_needed.csv') @@ -2536,9 +2291,7 @@ def test_ogr_csv_iter_and_set_feature(): gdal.Unlink('/vsimem/ogr_csv_iter_and_set_feature.csv') - if count != 2: - print(count) - return 'fail' + assert count == 2 return 'success' diff --git a/autotest/ogr/ogr_csw.py b/autotest/ogr/ogr_csw.py index 1a69504c6cc9..40ed75b23cc1 100755 --- a/autotest/ogr/ogr_csw.py +++ b/autotest/ogr/ogr_csw.py @@ -73,9 +73,7 @@ def test_ogr_csw_pycsw(): return 'skip' lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None: - gdaltest.post_reason('did not get expected layer name') - return 'fail' + assert f is not None, 'did not get expected layer name' return 'success' @@ -86,8 +84,7 @@ def test_ogr_csw_vsimem_fail_because_not_enabled(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None return 'success' @@ -99,8 +96,7 @@ def test_ogr_csw_vsimem_fail_because_no_get_capabilities(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None return 'success' @@ -115,11 +111,8 @@ def test_ogr_csw_vsimem_fail_because_empty_response(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Empty content returned by server') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('Empty content returned by server') >= 0 return 'success' @@ -134,11 +127,8 @@ def test_ogr_csw_vsimem_fail_because_no_CSW_Capabilities(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Cannot find Capabilities.version') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('Cannot find Capabilities.version') >= 0 return 'success' @@ -153,11 +143,8 @@ def test_ogr_csw_vsimem_fail_because_exception(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Error returned by server : ') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('Error returned by server : ') >= 0 return 'success' @@ -172,11 +159,8 @@ def test_ogr_csw_vsimem_fail_because_invalid_xml_capabilities(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Invalid XML content : = 0 return 'success' @@ -193,11 +177,8 @@ def test_ogr_csw_vsimem_fail_because_missing_version(): gdal.PushErrorHandler() ds = ogr.Open('CSW:/vsimem/csw_endpoint') gdal.PopErrorHandler() - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Cannot find Capabilities.version') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('Cannot find Capabilities.version') >= 0 return 'success' @@ -213,27 +194,22 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) ds = ogr.Open('CSW:/vsimem/csw_endpoint') - if ds is None: - return 'fail' + assert ds is not None ds.TestCapability('foo') - if ds.GetLayerCount() != 1: - return 'fail' - if ds.GetLayer(-1) is not None or ds.GetLayer(1) is not None: - return 'fail' + assert ds.GetLayerCount() == 1 + assert ds.GetLayer(-1) is None and ds.GetLayer(1) is None lyr = ds.GetLayer(0) lyr.TestCapability('foo') gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 0: - return 'fail' + assert fc == 0 gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") @@ -241,9 +217,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None or gdal.GetLastErrorMsg().find('Empty content returned by server') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert f is None and gdal.GetLastErrorMsg().find('Empty content returned by server') >= 0 gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """= 0 gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") @@ -261,9 +233,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None or gdal.GetLastErrorMsg().find('Error: cannot parse') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert f is None and gdal.GetLastErrorMsg().find('Error: cannot parse') >= 0 gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") @@ -271,9 +241,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None or gdal.GetLastErrorMsg().find('Error returned by server') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert f is None and gdal.GetLastErrorMsg().find('Error returned by server') >= 0 gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """ @@ -314,8 +282,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None if f['identifier'] != 'an_identifier' or f['other_identifiers'] != ['another_identifier'] or \ f['subject'] != 'a_subject' or f['other_subjects'] != ['another_subject'] or \ f['references'] != 'http://foo/' or f['other_references'] != ['http://bar/'] or \ @@ -324,24 +291,20 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): f.DumpReadable() return 'fail' f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 2: - return 'fail' + assert fc == 2 lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """ """) f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """ @@ -382,44 +343,35 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 3: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert fc == 3, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 3: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert fc == 3, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 3: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert fc == 3, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 3: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert fc == 3, gdal.GetLastErrorMsg() gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """ @@ -437,8 +389,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) fc = lyr.GetFeatureCount() - if fc != 200: - return 'fail' + assert fc == 200 lyr.SetAttributeFilter("identifier = 'an_identifier'") lyr.SetSpatialFilterRect(-180, -90, 180, 90) @@ -460,8 +411,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=fullows:BoundingBox-90 -18090 180dc:identifieran_identifier""", """ @@ -479,8 +429,7 @@ def test_ogr_csw_vsimem_csw_minimal_instance(): """) fc = lyr.GetFeatureCount() - if fc != 300: - return 'fail' + assert fc == 300 lyr.SetAttributeFilter("identifier = 'an_identifier' AND " + "references = 'http://foo/' AND " + @@ -509,8 +458,7 @@ def test_ogr_csw_vsimem_csw_output_schema_csw(): gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """""") @@ -518,8 +466,7 @@ def test_ogr_csw_vsimem_csw_output_schema_csw(): gdal.PushErrorHandler() f = lyr.GetNextFeature() gdal.PopErrorHandler() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/csw_endpoint&POSTFIELDS=full""", """ diff --git a/autotest/ogr/ogr_db2.py b/autotest/ogr/ogr_db2.py index e20cd2d56002..2285dee6ca83 100755 --- a/autotest/ogr/ogr_db2.py +++ b/autotest/ogr/ogr_db2.py @@ -89,18 +89,14 @@ def test_ogr_db2_GetFeatureCount(): ds = ogr.Open(ogrtest.db2_test_server) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None count = lyr.GetFeatureCount() - if count != 5: - gdaltest.post_reason('did not get expected feature count') - return 'fail' + assert count == 5, 'did not get expected feature count' return 'success' @@ -115,26 +111,19 @@ def test_ogr_db2_GetSpatialRef(): ds = ogr.Open(ogrtest.db2_test_server) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None sr = lyr.GetSpatialRef() - if sr is None: - gdaltest.post_reason('did not get expected srs') - return 'fail' + assert sr is not None, 'did not get expected srs' txt = sr.ExportToWkt() - if txt.find('GEOGCS[\"GCS_WGS_1984') == -1: - gdaltest.post_reason('did not get expected srs') - print(txt) - return 'fail' + assert txt.find('GEOGCS[\"GCS_WGS_1984') != -1, 'did not get expected srs' return 'success' @@ -148,23 +137,17 @@ def test_ogr_db2_GetExtent(): ds = ogr.Open(ogrtest.db2_test_server) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None extent = lyr.GetExtent() - if extent is None: - gdaltest.post_reason('did not get extent') - return 'fail' + assert extent is not None, 'did not get extent' - if extent != (-122.030745, -121.95672, 37.278665, 37.440885): - gdaltest.post_reason('did not get expected extent') - print(extent) - return 'fail' + assert extent == (-122.030745, -121.95672, 37.278665, 37.440885), \ + 'did not get expected extent' return 'success' @@ -179,18 +162,14 @@ def test_ogr_db2_GetFeature(): ds = ogr.Open(ogrtest.db2_test_server) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None feat = lyr.GetFeature(5) - if feat is None: - gdaltest.post_reason('did not get a feature') - return 'fail' + assert feat is not None, 'did not get a feature' if feat.GetField('ZIP') != '95008': gdaltest.post_reason('did not get expected feature') @@ -210,28 +189,21 @@ def test_ogr_db2_SetSpatialFilter(): ds = ogr.Open(ogrtest.db2_test_server) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None # set a query envelope so we only get one feature lyr.SetSpatialFilterRect(-122.02, 37.42, -122.01, 37.43) count = lyr.GetFeatureCount() - if count != 1: - gdaltest.post_reason('did not get expected feature count (1)') - print(count) - return 'fail' + assert count == 1, 'did not get expected feature count (1)' feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('did not get a feature') - return 'fail' + assert feat is not None, 'did not get a feature' if feat.GetField('ZIP') != '94089': gdaltest.post_reason('did not get expected feature') @@ -244,10 +216,7 @@ def test_ogr_db2_SetSpatialFilter(): count = lyr.GetFeatureCount() - if count != 3: - gdaltest.post_reason('did not get expected feature count (3)') - print(count) - return 'fail' + assert count == 3, 'did not get expected feature count (3)' # iterate through the features to make sure we get the same count count = 0 @@ -256,10 +225,7 @@ def test_ogr_db2_SetSpatialFilter(): count = count + 1 feat = lyr.GetNextFeature() - if count != 3: - gdaltest.post_reason('did not get expected feature count (3)') - print(count) - return 'fail' + assert count == 3, 'did not get expected feature count (3)' return 'success' @@ -275,8 +241,7 @@ def test_ogr_db2_capabilities(): ds = ogr.Open(ogrtest.db2_test_server) - if ds is None: - return 'fail' + assert ds is not None layer = ds.GetLayer() capabilities = [ diff --git a/autotest/ogr/ogr_db2_hack.py b/autotest/ogr/ogr_db2_hack.py index c7e9ea7cffe7..3b99970f1f7f 100755 --- a/autotest/ogr/ogr_db2_hack.py +++ b/autotest/ogr/ogr_db2_hack.py @@ -47,18 +47,14 @@ def test_ogr_db2_hack_1(): wkb = geom.ExportToWkb(byte_order=ogr.wkbXDR).decode('latin1') geom.Destroy() - if wkb[0] != '0': - gdaltest.post_reason('WKB wkbXDR point geometry has wrong byte order') - return 'fail' + assert wkb[0] == '0', 'WKB wkbXDR point geometry has wrong byte order' # NDR Case. geom = ogr.CreateGeometryFromWkt('POINT(10 20)') wkb = geom.ExportToWkb(byte_order=ogr.wkbNDR).decode('latin1') geom.Destroy() - if wkb[0] != '1': - gdaltest.post_reason('WKB wkbNDR point geometry has wrong byte order') - return 'fail' + assert wkb[0] == '1', 'WKB wkbNDR point geometry has wrong byte order' return 'success' @@ -68,27 +64,22 @@ def test_ogr_db2_hack_1(): def test_ogr_db2_hack_2(): - if ogr.SetGenerate_DB2_V72_BYTE_ORDER(0) != 0: - gdaltest.post_reason('SetGenerate to turn off hack failed!') - return 'fail' + assert ogr.SetGenerate_DB2_V72_BYTE_ORDER(0) == 0, \ + 'SetGenerate to turn off hack failed!' # XDR Case. geom = ogr.CreateGeometryFromWkt('POINT(10 20)') wkb = geom.ExportToWkb(byte_order=ogr.wkbXDR).decode('latin1') geom.Destroy() - if wkb[0] != chr(0): - gdaltest.post_reason('WKB wkbXDR point geometry has wrong byte order') - return 'fail' + assert wkb[0] == chr(0), 'WKB wkbXDR point geometry has wrong byte order' # NDR Case. geom = ogr.CreateGeometryFromWkt('POINT(10 20)') wkb = geom.ExportToWkb(byte_order=ogr.wkbNDR).decode('latin1') geom.Destroy() - if wkb[0] != chr(1): - gdaltest.post_reason('WKB wkbNDR point geometry has wrong byte order') - return 'fail' + assert wkb[0] == chr(1), 'WKB wkbNDR point geometry has wrong byte order' return 'success' @@ -108,20 +99,16 @@ def test_ogr_db2_hack_3(): geom.Destroy() # Check primary byte order value. - if wkb.decode('latin1')[0] != '0' and wkb.decode('latin1')[0] != '1': - gdaltest.post_reason('corrupt primary geometry byte order') - return 'fail' + assert wkb.decode('latin1')[0] == '0' or wkb.decode('latin1')[0] == '1', \ + 'corrupt primary geometry byte order' # Check component geometry byte order - if wkb.decode('latin1')[9] != '0' and wkb.decode('latin1')[9] != '1': - gdaltest.post_reason('corrupt sub-geometry byte order') - return 'fail' + assert wkb.decode('latin1')[9] == '0' or wkb.decode('latin1')[9] == '1', \ + 'corrupt sub-geometry byte order' geom = ogr.CreateGeometryFromWkb(wkb) - if geom.ExportToWkt() != wkt: - gdaltest.post_reason('Conversion to/from DB2 format seems to have ' + assert geom.ExportToWkt() == wkt, ('Conversion to/from DB2 format seems to have ' 'corrupted geometry.') - return 'fail' geom.Destroy() diff --git a/autotest/ogr/ogr_dgn.py b/autotest/ogr/ogr_dgn.py index e8c71e280254..520e4f902224 100755 --- a/autotest/ogr/ogr_dgn.py +++ b/autotest/ogr/ogr_dgn.py @@ -39,9 +39,7 @@ def test_ogr_dgn_1(): gdaltest.dgn_ds = ogr.Open('data/smalltest.dgn') - if gdaltest.dgn_ds is None: - gdaltest.post_reason('failed to open test file.') - return 'fail' + assert gdaltest.dgn_ds is not None, 'failed to open test file.' gdaltest.dgn_lyr = gdaltest.dgn_ds.GetLayer(0) @@ -56,20 +54,15 @@ def test_ogr_dgn_2(): return 'skip' feat = gdaltest.dgn_lyr.GetNextFeature() - if feat.GetField('Type') != 17 or feat.GetField('Level') != 1: - gdaltest.post_reason('feature 1: expected attributes') - return 'fail' + assert feat.GetField('Type') == 17 and feat.GetField('Level') == 1, \ + 'feature 1: expected attributes' - if feat.GetField('Text') != 'Demo Text': - gdaltest.post_reason('feature 1: expected text') - return 'fail' + assert feat.GetField('Text') == 'Demo Text', 'feature 1: expected text' - if ogrtest.check_feature_geometry(feat, 'POINT (0.73650000 4.21980000)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (0.73650000 4.21980000)') - if feat.GetStyleString() != 'LABEL(t:"Demo Text",c:#ffffff,s:1.000g,f:ENGINEERING)': - gdaltest.post_reason('Style string different than expected.') - return 'fail' + assert feat.GetStyleString() == 'LABEL(t:"Demo Text",c:#ffffff,s:1.000g,f:ENGINEERING)', \ + 'Style string different than expected.' return 'success' @@ -82,30 +75,21 @@ def test_ogr_dgn_3(): return 'skip' feat = gdaltest.dgn_lyr.GetNextFeature() - if feat.GetField('Type') != 15 or feat.GetField('Level') != 2: - gdaltest.post_reason('feature 2: expected attributes') - return 'fail' + assert feat.GetField('Type') == 15 and feat.GetField('Level') == 2, \ + 'feature 2: expected attributes' geom = feat.GetGeometryRef() - if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('expected 2d circle.') - return 'fail' + assert geom.GetCoordinateDimension() == 2, 'expected 2d circle.' - if geom.GetGeometryName() != 'LINESTRING': - gdaltest.post_reason('Expected circle to be translated as LINESTRING.') - return 'fail' + assert geom.GetGeometryName() == 'LINESTRING', \ + 'Expected circle to be translated as LINESTRING.' - if geom.GetPointCount() < 15: - gdaltest.post_reason('Unexpected small number of circle interpolation points.') - return 'fail' + assert geom.GetPointCount() >= 15, \ + 'Unexpected small number of circle interpolation points.' genvelope = geom.GetEnvelope() - if genvelope[0] < 0.328593 or genvelope[0] > 0.328594 \ - or genvelope[1] < 9.68780 or genvelope[1] > 9.68781 \ - or genvelope[2] < -0.09611 or genvelope[2] > -0.09610 \ - or genvelope[3] < 9.26310 or genvelope[3] > 9.26311: - gdaltest.post_reason('geometry extents seem odd') - return 'fail' + assert genvelope[0] >= 0.328593 and genvelope[0] <= 0.328594 and genvelope[1] >= 9.68780 and genvelope[1] <= 9.68781 and genvelope[2] >= -0.09611 and genvelope[2] <= -0.09610 and genvelope[3] >= 9.26310 and genvelope[3] <= 9.26311, \ + 'geometry extents seem odd' return 'success' @@ -118,19 +102,15 @@ def test_ogr_dgn_4(): return 'skip' feat = gdaltest.dgn_lyr.GetNextFeature() - if feat.GetField('Type') != 6 or feat.GetField('Level') != 2 \ - or feat.GetField('ColorIndex') != 83: - gdaltest.post_reason('feature 3: expected attributes') - return 'fail' + assert feat.GetField('Type') == 6 and feat.GetField('Level') == 2 and feat.GetField('ColorIndex') == 83, \ + 'feature 3: expected attributes' wkt = 'POLYGON ((4.53550000 3.31700000,4.38320000 2.65170000,4.94410000 2.52350000,4.83200000 3.33310000,4.53550000 3.31700000))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) - if feat.GetStyleString() != 'BRUSH(fc:#b40000,id:"ogr-brush-0")': - gdaltest.post_reason('Style string different than expected.') - return 'fail' + assert feat.GetStyleString() == 'BRUSH(fc:#b40000,id:"ogr-brush-0")', \ + 'Style string different than expected.' gdaltest.dgn_lyr.ResetReading() @@ -193,9 +173,7 @@ def test_ogr_dgn_7(): feat = gdaltest.dgn_lyr.GetNextFeature() while feat is not None: dst_feat.SetFrom(feat) - if dgn2_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert dgn2_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = gdaltest.dgn_lyr.GetNextFeature() @@ -223,63 +201,45 @@ def test_ogr_dgn_8(): # Test first first, a text element. feat = dgn2_lyr.GetNextFeature() - if feat.GetField('Type') != 17 or feat.GetField('Level') != 1: - gdaltest.post_reason('feature 1: expected attributes') - return 'fail' + assert feat.GetField('Type') == 17 and feat.GetField('Level') == 1, \ + 'feature 1: expected attributes' - if feat.GetField('Text') != 'Demo Text': - gdaltest.post_reason('feature 1: expected text') - return 'fail' + assert feat.GetField('Text') == 'Demo Text', 'feature 1: expected text' - if ogrtest.check_feature_geometry(feat, 'POINT (0.73650000 4.21980000)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (0.73650000 4.21980000)') - if feat.GetStyleString() != 'LABEL(t:"Demo Text",c:#ffffff,s:1.000g,f:ENGINEERING)': - gdaltest.post_reason('feature 1: Style string different than expected.') - return 'fail' + assert feat.GetStyleString() == 'LABEL(t:"Demo Text",c:#ffffff,s:1.000g,f:ENGINEERING)', \ + 'feature 1: Style string different than expected.' # Check second element, a circle. feat = dgn2_lyr.GetNextFeature() - if feat.GetField('Type') != 12 or feat.GetField('Level') != 2: - gdaltest.post_reason('feature 2: expected attributes') - return 'fail' + assert feat.GetField('Type') == 12 and feat.GetField('Level') == 2, \ + 'feature 2: expected attributes' geom = feat.GetGeometryRef() - if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('feature 2: expected 2d circle.') - return 'fail' + assert geom.GetCoordinateDimension() == 2, 'feature 2: expected 2d circle.' - if geom.GetGeometryName() != 'MULTILINESTRING': - gdaltest.post_reason('feature 2: Expected MULTILINESTRING.') - return 'fail' + assert geom.GetGeometryName() == 'MULTILINESTRING', \ + 'feature 2: Expected MULTILINESTRING.' genvelope = geom.GetEnvelope() - if genvelope[0] < 0.3285 or genvelope[0] > 0.3287 \ - or genvelope[1] < 9.6878 or genvelope[1] > 9.6879 \ - or genvelope[2] < -0.0962 or genvelope[2] > -0.0960 \ - or genvelope[3] < 9.26310 or genvelope[3] > 9.2632: - gdaltest.post_reason('feature 2: geometry extents seem odd') - print(genvelope) - return 'fail' + assert genvelope[0] >= 0.3285 and genvelope[0] <= 0.3287 and genvelope[1] >= 9.6878 and genvelope[1] <= 9.6879 and genvelope[2] >= -0.0962 and genvelope[2] <= -0.0960 and genvelope[3] >= 9.26310 and genvelope[3] <= 9.2632, \ + 'feature 2: geometry extents seem odd' # Check 3rd feature, a polygon feat = dgn2_lyr.GetNextFeature() - if feat.GetField('Type') != 6 or feat.GetField('Level') != 2 \ - or feat.GetField('ColorIndex') != 83: - gdaltest.post_reason('feature 3: expected attributes') - return 'fail' + assert feat.GetField('Type') == 6 and feat.GetField('Level') == 2 and feat.GetField('ColorIndex') == 83, \ + 'feature 3: expected attributes' wkt = 'POLYGON ((4.53550000 3.31700000,4.38320000 2.65170000,4.94410000 2.52350000,4.83200000 3.33310000,4.53550000 3.31700000))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) # should be: 'BRUSH(fc:#b40000,id:"ogr-brush-0")' - if feat.GetStyleString() != 'PEN(id:"ogr-pen-0",c:#b40000)': - gdaltest.post_reason('feature 3: Style string different than expected: ' + feat.GetStyleString()) - return 'fail' + assert feat.GetStyleString() == 'PEN(id:"ogr-pen-0",c:#b40000)', \ + ('feature 3: Style string different than expected: ' + feat.GetStyleString()) dgn2_ds = None @@ -295,14 +255,12 @@ def test_ogr_dgn_online_1(): return 'skip' ds = ogr.Open('tmp/cache/DGNSample_v7.dgn') - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) feat = lyr.GetFeature(35) wkt = 'LINESTRING (82.9999500717185 23.2084166997284,83.0007450788903 23.2084495986816,83.00081490524 23.2068095339824,82.9999503769036 23.2067737968078)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' diff --git a/autotest/ogr/ogr_dgnv8.py b/autotest/ogr/ogr_dgnv8.py index 6d659c0e7e10..cfe4711fe2c7 100755 --- a/autotest/ogr/ogr_dgnv8.py +++ b/autotest/ogr/ogr_dgnv8.py @@ -48,9 +48,7 @@ def test_ogr_dgnv8_1(): return 'skip' ds = ogr.Open('data/test_dgnv8.dgn') - if ds is None: - gdaltest.post_reason('failed to open test file.') - return 'fail' + assert ds is not None, 'failed to open test file.' return 'success' @@ -91,17 +89,13 @@ def test_ogr_dgnv8_3(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro data/test_dgnv8.dgn') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 shutil.copy('data/test_dgnv8.dgn', 'tmp/test_dgnv8.dgn') ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/test_dgnv8.dgn') os.unlink('tmp/test_dgnv8.dgn') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -162,24 +156,17 @@ def test_ogr_dgnv8_5(): ds = None ds = ogr.Open(tmp_dgn) got_md = ds.GetMetadata_List('DGN') - if got_md != options: - print(got_md) - return 'fail' + assert got_md == options ds = None tmp2_dgn = 'tmp/ogr_dgnv8_5_2.dgn' gdaltest.dgnv8_drv.CreateDataSource(tmp2_dgn, options=['SEED=' + tmp_dgn, 'TITLE=another_title']) ds = ogr.Open(tmp2_dgn) - if ds.GetMetadataItem('TITLE', 'DGN') != 'another_title' or ds.GetMetadataItem('APPLICATION', 'DGN') != 'application': - print(ds.GetMetadata('DGN')) - return 'fail' + assert ds.GetMetadataItem('TITLE', 'DGN') == 'another_title' and ds.GetMetadataItem('APPLICATION', 'DGN') == 'application', \ + ds.GetMetadata('DGN') lyr = ds.GetLayer(0) - if lyr.GetName() != 'my_layer': - print(lyr.GetName()) - return 'fail' - if lyr.GetFeatureCount() != 0: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetName() == 'my_layer' + assert lyr.GetFeatureCount() == 0 ds = None ds = gdaltest.dgnv8_drv.CreateDataSource(tmp2_dgn, options=['SEED=' + tmp_dgn]) @@ -190,12 +177,8 @@ def test_ogr_dgnv8_5(): ds = None ds = ogr.Open(tmp2_dgn, update=1) lyr = ds.GetLayer(0) - if lyr.GetName() != 'a_layer': - print(lyr.GetName()) - return 'fail' - if lyr.GetFeatureCount() != 1: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetName() == 'a_layer' + assert lyr.GetFeatureCount() == 1 f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 3)': f.DumpReadable() diff --git a/autotest/ogr/ogr_dods.py b/autotest/ogr/ogr_dods.py index dc2f4678c288..1f1831bb7fa1 100755 --- a/autotest/ogr/ogr_dods.py +++ b/autotest/ogr/ogr_dods.py @@ -54,8 +54,7 @@ def ogr_dods_1(): gdaltest.dods_ds = ogr.Open('DODS:' + srv) - if gdaltest.dods_ds is None: - return 'fail' + assert gdaltest.dods_ds is not None try: gdaltest.dods_profiles = gdaltest.dods_ds.GetLayerByName('profiles') @@ -84,17 +83,11 @@ def ogr_dods_2(): gdaltest.dods_profiles.ResetReading() feat = gdaltest.dods_profiles.GetNextFeature() - if feat.GetField('time') != -1936483200000: - gdaltest.post_reason('time wrong') - return 'fail' + assert feat.GetField('time') == -1936483200000, 'time wrong' - if feat.GetField('profile.depth') != [0, 10, 20, 30, 39]: - gdaltest.post_reason('depth wrong') - return 'fail' + assert feat.GetField('profile.depth') == [0, 10, 20, 30, 39], 'depth wrong' - if ogrtest.check_feature_geometry(feat, 'POINT (4.30000019 5.36999989)')\ - != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'POINT (4.30000019 5.36999989)') == 0 feat.Destroy() @@ -120,8 +113,7 @@ def ogr_dods_3(): expect = [0, 10, 20, 30, 39] tr = ogrtest.check_features_against_list(gdaltest.dods_normalized, 'depth', expect) - if tr == 0: - return 'fail' + assert tr != 0 expected = [14.8100004196167, 14.8100004196167, 14.8100004196167, 14.60999965667725, 14.60999965667725] @@ -129,17 +121,11 @@ def ogr_dods_3(): for i in range(5): feat = gdaltest.dods_normalized.GetNextFeature() - if feat.GetField('time') != -1936483200000: - gdaltest.post_reason('time wrong') - return 'fail' + assert feat.GetField('time') == -1936483200000, 'time wrong' - if abs(feat.GetField('T_20') - expected[i]) > 0.001: - gdaltest.post_reason('T_20 wrong') - return 'fail' + assert abs(feat.GetField('T_20') - expected[i]) <= 0.001, 'T_20 wrong' - if ogrtest.check_feature_geometry(feat, 'POINT (4.30000019 5.36999989)')\ - != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'POINT (4.30000019 5.36999989)') == 0 feat.Destroy() feat = None @@ -165,19 +151,14 @@ def ogr_dods_4(): gdaltest.dods_lines.ResetReading() feat = gdaltest.dods_lines.GetNextFeature() - if feat.GetField('time') != -1936483200000: - gdaltest.post_reason('time wrong') - return 'fail' + assert feat.GetField('time') == -1936483200000, 'time wrong' - if feat.GetField('profile.depth') != [0, 10, 20, 30, 39]: - gdaltest.post_reason('depth wrong') - return 'fail' + assert feat.GetField('profile.depth') == [0, 10, 20, 30, 39], 'depth wrong' wkt_geom = 'LINESTRING (0.00000000 14.81000042,10.00000000 14.81000042,20.00000000 14.81000042,30.00000000 14.60999966,39.00000000 14.60999966)' - if ogrtest.check_feature_geometry(feat, wkt_geom) != 0: - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert ogrtest.check_feature_geometry(feat, wkt_geom) == 0, \ + feat.GetGeometryRef().ExportToWkt() feat.Destroy() @@ -204,15 +185,13 @@ def ogr_dods_5(): return 'skip' grid_ds = ogr.Open('DODS:' + srv) - if grid_ds is None: - return 'fail' + assert grid_ds is not None lat_lyr = grid_ds.GetLayerByName('latitude') expect = [-0.53166663646698] tr = ogrtest.check_features_against_list(lat_lyr, 'latitude', expect) - if tr == 0: - return 'fail' + assert tr != 0 return 'success' diff --git a/autotest/ogr/ogr_dxf.py b/autotest/ogr/ogr_dxf.py index 5f5d0bcccdae..f1a5bebcf04b 100644 --- a/autotest/ogr/ogr_dxf.py +++ b/autotest/ogr/ogr_dxf.py @@ -39,6 +39,7 @@ import gdaltest from osgeo import gdal from osgeo import ogr +import pytest ############################################################################### # Check some general things to see if they meet expectations. @@ -48,28 +49,20 @@ def test_ogr_dxf_1(): gdaltest.dxf_ds = ogr.Open('data/assorted.dxf') - if gdaltest.dxf_ds is None: - return 'fail' + assert gdaltest.dxf_ds is not None - if gdaltest.dxf_ds.GetLayerCount() != 1: - gdaltest.post_reason('expected exactly one layer!') - return 'fail' + assert gdaltest.dxf_ds.GetLayerCount() == 1, 'expected exactly one layer!' gdaltest.dxf_layer = gdaltest.dxf_ds.GetLayer(0) - if gdaltest.dxf_layer.GetName() != 'entities': - gdaltest.post_reason('did not get expected layer name.') - return 'fail' + assert gdaltest.dxf_layer.GetName() == 'entities', \ + 'did not get expected layer name.' defn = gdaltest.dxf_layer.GetLayerDefn() - if defn.GetFieldCount() != 6: - gdaltest.post_reason('did not get expected number of fields.') - return 'fail' + assert defn.GetFieldCount() == 6, 'did not get expected number of fields.' fc = gdaltest.dxf_layer.GetFeatureCount() - if fc != 22: - gdaltest.post_reason('did not get expected feature count, got %d' % fc) - return 'fail' + assert fc == 22, ('did not get expected feature count, got %d' % fc) # Setup the utf-8 string. if version_info >= (3, 0, 0): @@ -97,52 +90,37 @@ def test_ogr_dxf_2(): feat = gdaltest.dxf_layer.GetNextFeature() - if feat.Layer != '0': - gdaltest.post_reason('did not get expected layer for feature 0') - return 'fail' + assert feat.Layer == '0', 'did not get expected layer for feature 0' - if feat.PaperSpace != None: - gdaltest.post_reason( 'did not get expected PaperSpace for feature 0' ) - return 'fail' + assert feat.PaperSpace == None, 'did not get expected PaperSpace for feature 0' - if feat.GetFID() != 0: - gdaltest.post_reason('did not get expected fid for feature 0') - return 'fail' + assert feat.GetFID() == 0, 'did not get expected fid for feature 0' - if feat.SubClasses != 'AcDbEntity:AcDbEllipse': - gdaltest.post_reason('did not get expected SubClasses on feature 0.') - return 'fail' + assert feat.SubClasses == 'AcDbEntity:AcDbEllipse', \ + 'did not get expected SubClasses on feature 0.' - if feat.LineType != 'ByLayer': - gdaltest.post_reason('Did not get expected LineType') - return 'fail' + assert feat.LineType == 'ByLayer', 'Did not get expected LineType' - if feat.EntityHandle != '43': - gdaltest.post_reason('did not get expected EntityHandle') - return 'fail' + assert feat.EntityHandle == '43', 'did not get expected EntityHandle' if feat.GetStyleString() != 'PEN(c:#000000)': print('%s' % feat.GetStyleString()) - gdaltest.post_reason('did not get expected style string on feat 0.') - return 'fail' + pytest.fail('did not get expected style string on feat 0.') geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbLineString25D: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString25D, \ + 'did not get expected geometry type.' envelope = geom.GetEnvelope() area = (envelope[1] - envelope[0]) * (envelope[3] - envelope[2]) exp_area = 1596.12 - if area < exp_area - 0.5 or area > exp_area + 0.5: - gdaltest.post_reason('envelope area not as expected, got %g.' % area) - return 'fail' + assert area >= exp_area - 0.5 and area <= exp_area + 0.5, \ + ('envelope area not as expected, got %g.' % area) - if abs(geom.GetX(0) - 73.25) > 0.001 or abs(geom.GetY(0) - 139.75) > 0.001: - gdaltest.post_reason('first point (%g,%g) not expected location.' + assert abs(geom.GetX(0) - 73.25) <= 0.001 and abs(geom.GetY(0) - 139.75) <= 0.001, \ + ('first point (%g,%g) not expected location.' % (geom.GetX(0), geom.GetY(0))) - return 'fail' return 'success' @@ -160,14 +138,12 @@ def test_ogr_dxf_3(): area = (envelope[1] - envelope[0]) * (envelope[3] - envelope[2]) exp_area = 311.864 - if area < exp_area - 0.5 or area > exp_area + 0.5: - gdaltest.post_reason('envelope area not as expected, got %g.' % area) - return 'fail' + assert area >= exp_area - 0.5 and area <= exp_area + 0.5, \ + ('envelope area not as expected, got %g.' % area) - if abs(geom.GetX(0) - 61.133) > 0.01 or abs(geom.GetY(0) - 103.592) > 0.01: - gdaltest.post_reason('first point (%g,%g) not expected location.' + assert abs(geom.GetX(0) - 61.133) <= 0.01 and abs(geom.GetY(0) - 103.592) <= 0.01, \ + ('first point (%g,%g) not expected location.' % (geom.GetX(0), geom.GetY(0))) - return 'fail' return 'success' @@ -179,8 +155,7 @@ def test_ogr_dxf_4(): feat = gdaltest.dxf_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (83.5 160.0 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (83.5 160.0 0)') return 'success' @@ -192,12 +167,10 @@ def test_ogr_dxf_5(): feat = gdaltest.dxf_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (97.0 159.5 0,108.5 132.25 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (97.0 159.5 0,108.5 132.25 0)') - if feat.GetGeometryRef().GetGeometryType() == ogr.wkbLineString: - gdaltest.post_reason('not keeping 3D linestring as 3D') - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() != ogr.wkbLineString, \ + 'not keeping 3D linestring as 3D' return 'success' @@ -209,17 +182,13 @@ def test_ogr_dxf_6(): feat = gdaltest.dxf_layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (84 126)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (84 126)') - if feat.GetGeometryRef().GetGeometryType() == ogr.wkbPoint25D: - gdaltest.post_reason('not keeping 2D text as 2D') - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() != ogr.wkbPoint25D, \ + 'not keeping 2D text as 2D' - if feat.GetStyleString() != 'LABEL(f:"Arial",t:"Test",a:30,s:5g,p:7,c:#000000)': - print(feat.GetStyleString()) - gdaltest.post_reason('got wrong style string') - return 'fail' + assert feat.GetStyleString() == 'LABEL(f:"Arial",t:"Test",a:30,s:5g,p:7,c:#000000)', \ + 'got wrong style string' return 'success' @@ -239,13 +208,11 @@ def test_ogr_dxf_7(): if area < exp_area - 0.5 or area > exp_area + 0.5: print(envelope) - gdaltest.post_reason('envelope area not as expected, got %g.' % area) - return 'fail' + pytest.fail('envelope area not as expected, got %g.' % area) - if abs(geom.GetX(0) - 115.258) > 0.01 or abs(geom.GetY(0) - 107.791) > 0.01: - gdaltest.post_reason('first point (%g,%g) not expected location.' + assert abs(geom.GetX(0) - 115.258) <= 0.01 and abs(geom.GetY(0) - 107.791) <= 0.01, \ + ('first point (%g,%g) not expected location.' % (geom.GetX(0), geom.GetY(0))) - return 'fail' return 'success' @@ -258,53 +225,43 @@ def test_ogr_dxf_8(): # Check that this line is in PaperSpace feat = gdaltest.dxf_layer.GetNextFeature() - if feat.GetField('PaperSpace') != 1: - gdaltest.post_reason( 'did not get expected PaperSpace' ) - return 'fail' + assert feat.GetField('PaperSpace') == 1, 'did not get expected PaperSpace' # Dimension lines feat = gdaltest.dxf_layer.GetNextFeature() geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbMultiLineString: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbMultiLineString, \ + 'did not get expected geometry type.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((63.8628719444825 149.209935992088,24.3419606685507 111.934531038653),(72.3255686642474 140.237438265109,63.0051995752285 150.119275371538),(32.8046573883157 102.962033311673,23.4842882992968 112.843870418103))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((63.8628719444825 149.209935992088,24.3419606685507 111.934531038653),(72.3255686642474 140.237438265109,63.0051995752285 150.119275371538),(32.8046573883157 102.962033311673,23.4842882992968 112.843870418103))') # Dimension arrowheads feat = gdaltest.dxf_layer.GetNextFeature() geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbPolygon25D: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbPolygon25D, \ + 'did not get expected geometry type.' - if ogrtest.check_feature_geometry(feat, 'POLYGON Z ((61.7583023958313 147.797704380064 0,63.8628719444825 149.209935992088 0,62.3300839753339 147.191478127097 0,61.7583023958313 147.797704380064 0))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON Z ((61.7583023958313 147.797704380064 0,63.8628719444825 149.209935992088 0,62.3300839753339 147.191478127097 0,61.7583023958313 147.797704380064 0))') feat = gdaltest.dxf_layer.GetNextFeature() geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbPolygon25D: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbPolygon25D, \ + 'did not get expected geometry type.' - if ogrtest.check_feature_geometry(feat, 'POLYGON Z ((26.4465302172018 113.346762650677 0,24.3419606685507 111.934531038653 0,25.8747486376992 113.952988903644 0,26.4465302172018 113.346762650677 0))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON Z ((26.4465302172018 113.346762650677 0,24.3419606685507 111.934531038653 0,25.8747486376992 113.952988903644 0,26.4465302172018 113.346762650677 0))') # Dimension text feat = gdaltest.dxf_layer.GetNextFeature() geom = feat.GetGeometryRef() - if ogrtest.check_feature_geometry(feat, 'POINT (42.815907752635709 131.936242584545397)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (42.815907752635709 131.936242584545397)') expected_style = 'LABEL(f:"Arial",t:"54.33",p:5,a:43.3,s:2.5g,c:#000000)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string:\n%s\ninstead of:\n%s' % (feat.GetStyleString(), expected_style)) - return 'fail' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string:\n%s\ninstead of:\n%s' % (feat.GetStyleString(), expected_style)) return 'success' @@ -322,39 +279,30 @@ def test_ogr_dxf_9(): feat = gdaltest.dxf_layer.GetNextFeature() geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbMultiLineString25D: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbMultiLineString25D, \ + 'did not get expected geometry type.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((79.069506278985116 121.003652476272777 0,79.716898725419625 118.892590150942851 0),(79.716898725419625 118.892590150942851 0,78.140638855839953 120.440702522851453 0),(78.140638855839953 120.440702522851453 0,80.139111190485622 120.328112532167196 0),(80.139111190485622 120.328112532167196 0,78.619146316248077 118.920737648613908 0),(78.619146316248077 118.920737648613908 0,79.041358781314059 120.975504978601705 0))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((79.069506278985116 121.003652476272777 0,79.716898725419625 118.892590150942851 0),(79.716898725419625 118.892590150942851 0,78.140638855839953 120.440702522851453 0),(78.140638855839953 120.440702522851453 0,80.139111190485622 120.328112532167196 0),(80.139111190485622 120.328112532167196 0,78.619146316248077 118.920737648613908 0),(78.619146316248077 118.920737648613908 0,79.041358781314059 120.975504978601705 0))') # First of two MTEXTs feat = gdaltest.dxf_layer.GetNextFeature() - if feat.GetField('Text') != gdaltest.sample_text: - gdaltest.post_reason('Did not get expected first mtext.') - return 'fail' + assert feat.GetField('Text') == gdaltest.sample_text, \ + 'Did not get expected first mtext.' expected_style = 'LABEL(f:"Arial",t:"' + gdaltest.sample_style + '",a:45,s:0.5g,p:5,c:#000000)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - if ogrtest.check_feature_geometry(feat, 'POINT (77.602201427662891 120.775897075866169 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (77.602201427662891 120.775897075866169 0)') # Second of two MTEXTs feat = gdaltest.dxf_layer.GetNextFeature() - if feat.GetField('Text') != 'Second': - gdaltest.post_reason('Did not get expected second mtext.') - return 'fail' + assert feat.GetField('Text') == 'Second', 'Did not get expected second mtext.' - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbMText': - gdaltest.post_reason('Did not get expected subclasses.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbMText', \ + 'Did not get expected subclasses.' - if ogrtest.check_feature_geometry(feat, 'POINT (79.977331629005178 119.698291706738644 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (79.977331629005178 119.698291706738644 0)') return 'success' @@ -374,20 +322,16 @@ def test_ogr_dxf_10(): feat = ocs_lyr.GetNextFeature() geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbLineString25D: - print(geom.GetGeometryType()) - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString25D, \ + 'did not get expected geometry type.' - if ogrtest.check_feature_geometry(feat, 'LINESTRING (600325.567999998573214 3153021.253000000491738 562.760000000052969,600255.215999998385087 3151973.98600000096485 536.950000000069849,597873.927999997511506 3152247.628000000491738 602.705000000089058)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (600325.567999998573214 3153021.253000000491738 562.760000000052969,600255.215999998385087 3151973.98600000096485 536.950000000069849,597873.927999997511506 3152247.628000000491738 602.705000000089058)') # LWPOLYLINE in OCS with bulge feat = ocs_lyr.GetFeature(12) - if ogrtest.check_feature_geometry(feat, 'LINESTRING Z (611415.459819656 3139300.00002682 1807.37309215522,611245.079665823 3139720.59876424 1807.37309215522,611245.079665823 3139720.59876424 1807.37309215522,611244.054791235 3139723.12875936 1807.27984293229,611243.034695086 3139725.64695847 1807.00053001486,611242.024133533 3139728.14162057 1806.53645568869,611241.027818282 3139730.6011144 1805.88978368251,611240.050394615 3139733.01397265 1805.06352907972,611239.096419732 3139735.36894547 1804.06154426071,611238.170341503 3139737.65505289 1802.88850094122,611237.276477734 3139739.86163602 1801.54986839073,611236.418996029 3139741.97840675 1800.0518879321,611235.601894365 3139743.99549572 1798.40154384175,611234.828982446 3139745.90349832 1796.60653078564,611234.103863944 3139747.69351857 1794.67521794327,611233.429919697 3139749.35721058 1792.61660998662,611232.810291944 3139750.88681743 1790.44030509629,611232.247869676 3139752.27520739 1788.15645021029,611231.745275164 3139753.51590716 1785.77569371438,611231.304851737 3139754.60313201 1783.30913579435,611230.928652852 3139755.5318128 1780.76827668182,611230.618432521 3139756.29761959 1778.16496303489,611230.375637135 3139756.89698184 1775.51133270351,611230.201398719 3139757.32710505 1772.81975813727,611230.096529651 3139757.58598378 1770.10278869926,611230.06151888 3139757.67241101 1767.37309215522,611230.06151892 3139757.67241089 1661.18408370228,611230.06151892 3139757.67241089 1661.18408370228,611230.026508154 3139757.75883812 1658.45438717061,611229.921639091 3139758.01771683 1655.73741774404,611229.74740068 3139758.44784002 1653.04584318824,611229.5046053 3139759.04720226 1650.39221286628,611229.194384975 3139759.81300904 1647.78889922769,611228.818186096 3139760.74168982 1645.24804012238,611228.377762675 3139761.82891465 1642.78148220841,611227.87516817 3139763.0696144 1640.40072571739,611227.312745909 3139764.45800435 1638.11687083509,611226.693118163 3139765.98761118 1635.94056594722,611226.019173923 3139767.65130317 1633.88195799181,611225.294055428 3139769.4413234 1631.95064514943,611224.521143516 3139771.34932599 1630.15563209209,611223.704041858 3139773.36641494 1628.50528799927,611222.84656016 3139775.48318565 1627.00730753696,611221.952696397 3139777.68976876 1625.66867498157,611221.026618175 3139779.97587617 1624.49563165602,611220.072643298 3139782.33084897 1623.49364682979,611219.095219637 3139784.74370721 1622.66739221866,611218.098904392 3139787.20320102 1622.02072020306,611217.088342845 3139789.69786311 1621.55664586644,' + - '611216.0682467 3139792.21606221 1621.27733293758,611215.043372117 3139794.74605732 1621.18408370228,610905.973331759 3140557.71325641 1621.18408370228,610905.973331759 3140557.71325641 1621.18408370228,610904.948457176 3140560.24325151 1621.2773329396,610903.928361033 3140562.76145061 1621.55664587034,610902.917799487 3140565.2561127 1622.02072020868,610901.921484243 3140567.71560651 1622.66739222582,610900.944060583 3140570.12846474 1623.49364683831,610899.990085707 3140572.48343755 1624.49563166573,610899.064007486 3140574.76954495 1625.66867499227,610898.170143725 3140576.97612806 1627.00730754846,610897.312662028 3140579.09289877 1628.50528801138,610896.495560372 3140581.10998771 1630.1556321046,610895.722648461 3140583.0179903 1631.95064516215,610894.997529967 3140584.80801053 1633.88195800453,610894.323585729 3140586.47170251 1635.94056595974,610893.703957984 3140588.00130935 1638.1168708472,610893.141535724 3140589.38969929 1640.4007257289,610892.63894122 3140590.63039904 1642.78148221912,610892.198517801 3140591.71762387 1645.2480401321,610891.822318923 3140592.64630464 1647.78889923622,610891.5120986 3140593.41211142 1650.39221287345,610891.269303221 3140594.01147366 1653.04584319386,610891.095064811 3140594.44159685 1655.73741774794,610890.99019575 3140594.70047556 1658.45438717264,610890.955184986 3140594.78690278 1661.18408370228,610890.955185021 3140594.78690272 1752.31638281001,610890.955185021 3140594.78690271 1752.31638281001,610890.920174252 3140594.87332995 1755.04607934987,610890.815305187 3140595.13220867 1757.76304878401,610890.641066773 3140595.56233187 1760.45462334672,610890.398271389 3140596.16169412 1763.10825367492,610890.088051061 3140596.92750091 1765.71156731903,610889.711852178 3140597.85618169 1768.25242642912,610889.271428753 3140598.94340654 1770.71898434711,610888.768834244 3140600.1841063 1773.09974084137,610888.206411978 3140601.57249626 1775.38359572612,610887.586784228 3140603.1021031 1777.55990061562,610886.912839984 3140604.7657951 1779.61850857185,610886.187721485 3140606.55581535 1781.54982141423,610885.414809569 3140608.46381795 1783.34483447076,610884.597707907 3140610.48090691 1784.99517856195,610883.740226205 3140612.59767763 1786.49315902182,610882.846362438 3140614.80426075 1787.83179157397,610881.920284211 3140617.09036817 1789.0048348955,610880.96630933 3140619.44534098 1790.00681971696,610879.988885665 3140621.85819923 1790.83307432256,610878.992570417 3140624.31769305 1791.47974633192,610877.982008866 3140626.81235515 1791.94382066162,610876.961912718 3140629.33055426 1792.22313358291,610875.937038132 3140631.86054938 1792.31638281001,610699.99993399 3141066.17711854 1792.31638281001)'): - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, 'LINESTRING Z (611415.459819656 3139300.00002682 1807.37309215522,611245.079665823 3139720.59876424 1807.37309215522,611245.079665823 3139720.59876424 1807.37309215522,611244.054791235 3139723.12875936 1807.27984293229,611243.034695086 3139725.64695847 1807.00053001486,611242.024133533 3139728.14162057 1806.53645568869,611241.027818282 3139730.6011144 1805.88978368251,611240.050394615 3139733.01397265 1805.06352907972,611239.096419732 3139735.36894547 1804.06154426071,611238.170341503 3139737.65505289 1802.88850094122,611237.276477734 3139739.86163602 1801.54986839073,611236.418996029 3139741.97840675 1800.0518879321,611235.601894365 3139743.99549572 1798.40154384175,611234.828982446 3139745.90349832 1796.60653078564,611234.103863944 3139747.69351857 1794.67521794327,611233.429919697 3139749.35721058 1792.61660998662,611232.810291944 3139750.88681743 1790.44030509629,611232.247869676 3139752.27520739 1788.15645021029,611231.745275164 3139753.51590716 1785.77569371438,611231.304851737 3139754.60313201 1783.30913579435,611230.928652852 3139755.5318128 1780.76827668182,611230.618432521 3139756.29761959 1778.16496303489,611230.375637135 3139756.89698184 1775.51133270351,611230.201398719 3139757.32710505 1772.81975813727,611230.096529651 3139757.58598378 1770.10278869926,611230.06151888 3139757.67241101 1767.37309215522,611230.06151892 3139757.67241089 1661.18408370228,611230.06151892 3139757.67241089 1661.18408370228,611230.026508154 3139757.75883812 1658.45438717061,611229.921639091 3139758.01771683 1655.73741774404,611229.74740068 3139758.44784002 1653.04584318824,611229.5046053 3139759.04720226 1650.39221286628,611229.194384975 3139759.81300904 1647.78889922769,611228.818186096 3139760.74168982 1645.24804012238,611228.377762675 3139761.82891465 1642.78148220841,611227.87516817 3139763.0696144 1640.40072571739,611227.312745909 3139764.45800435 1638.11687083509,611226.693118163 3139765.98761118 1635.94056594722,611226.019173923 3139767.65130317 1633.88195799181,611225.294055428 3139769.4413234 1631.95064514943,611224.521143516 3139771.34932599 1630.15563209209,611223.704041858 3139773.36641494 1628.50528799927,611222.84656016 3139775.48318565 1627.00730753696,611221.952696397 3139777.68976876 1625.66867498157,611221.026618175 3139779.97587617 1624.49563165602,611220.072643298 3139782.33084897 1623.49364682979,611219.095219637 3139784.74370721 1622.66739221866,611218.098904392 3139787.20320102 1622.02072020306,611217.088342845 3139789.69786311 1621.55664586644,' + + '611216.0682467 3139792.21606221 1621.27733293758,611215.043372117 3139794.74605732 1621.18408370228,610905.973331759 3140557.71325641 1621.18408370228,610905.973331759 3140557.71325641 1621.18408370228,610904.948457176 3140560.24325151 1621.2773329396,610903.928361033 3140562.76145061 1621.55664587034,610902.917799487 3140565.2561127 1622.02072020868,610901.921484243 3140567.71560651 1622.66739222582,610900.944060583 3140570.12846474 1623.49364683831,610899.990085707 3140572.48343755 1624.49563166573,610899.064007486 3140574.76954495 1625.66867499227,610898.170143725 3140576.97612806 1627.00730754846,610897.312662028 3140579.09289877 1628.50528801138,610896.495560372 3140581.10998771 1630.1556321046,610895.722648461 3140583.0179903 1631.95064516215,610894.997529967 3140584.80801053 1633.88195800453,610894.323585729 3140586.47170251 1635.94056595974,610893.703957984 3140588.00130935 1638.1168708472,610893.141535724 3140589.38969929 1640.4007257289,610892.63894122 3140590.63039904 1642.78148221912,610892.198517801 3140591.71762387 1645.2480401321,610891.822318923 3140592.64630464 1647.78889923622,610891.5120986 3140593.41211142 1650.39221287345,610891.269303221 3140594.01147366 1653.04584319386,610891.095064811 3140594.44159685 1655.73741774794,610890.99019575 3140594.70047556 1658.45438717264,610890.955184986 3140594.78690278 1661.18408370228,610890.955185021 3140594.78690272 1752.31638281001,610890.955185021 3140594.78690271 1752.31638281001,610890.920174252 3140594.87332995 1755.04607934987,610890.815305187 3140595.13220867 1757.76304878401,610890.641066773 3140595.56233187 1760.45462334672,610890.398271389 3140596.16169412 1763.10825367492,610890.088051061 3140596.92750091 1765.71156731903,610889.711852178 3140597.85618169 1768.25242642912,610889.271428753 3140598.94340654 1770.71898434711,610888.768834244 3140600.1841063 1773.09974084137,610888.206411978 3140601.57249626 1775.38359572612,610887.586784228 3140603.1021031 1777.55990061562,610886.912839984 3140604.7657951 1779.61850857185,610886.187721485 3140606.55581535 1781.54982141423,610885.414809569 3140608.46381795 1783.34483447076,610884.597707907 3140610.48090691 1784.99517856195,610883.740226205 3140612.59767763 1786.49315902182,610882.846362438 3140614.80426075 1787.83179157397,610881.920284211 3140617.09036817 1789.0048348955,610880.96630933 3140619.44534098 1790.00681971696,610879.988885665 3140621.85819923 1790.83307432256,610878.992570417 3140624.31769305 1791.47974633192,610877.982008866 3140626.81235515 1791.94382066162,610876.961912718 3140629.33055426 1792.22313358291,610875.937038132 3140631.86054938 1792.31638281001,610699.99993399 3141066.17711854 1792.31638281001)')) ocs_lyr = None ocs_ds = None @@ -406,16 +350,14 @@ def test_ogr_dxf_11(): # Check first point. feat = eo_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'POINT (672500.0 242000.0 539.986)'): - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'POINT (672500.0 242000.0 539.986)')) # Check second point. feat = eo_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'POINT (672750.0 242000.0 558.974)'): - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'POINT (672750.0 242000.0 558.974)')) eo_lyr = None eo_ds = None @@ -464,45 +406,39 @@ def test_ogr_dxf_12(): # Check first feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'LINESTRING(10 12, 60 65)'): - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'LINESTRING(10 12, 60 65)')), \ + feat.GetGeometryRef().ExportToWkt() - if feat.GetGeometryRef().GetGeometryType() != ogr.wkbLineString: - gdaltest.post_reason('not linestring 2D') - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() == ogr.wkbLineString, \ + 'not linestring 2D' feat = None # Check second feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'POLYGON((0 0,100 0,100 100,0 0))'): - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'POLYGON((0 0,100 0,100 100,0 0))')), \ + feat.GetGeometryRef().ExportToWkt() - if feat.GetGeometryRef().GetGeometryType() != ogr.wkbPolygon: - gdaltest.post_reason('not keeping polygon 2D') - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() == ogr.wkbPolygon, \ + 'not keeping polygon 2D' feat = None # Check third feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'LINESTRING(1 2 10,3 4 10)'): - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'LINESTRING(1 2 10,3 4 10)')), \ + feat.GetGeometryRef().ExportToWkt() feat = None # Check fourth feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'LINESTRING(1 2 -10,3 4 10)'): - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'LINESTRING(1 2 -10,3 4 10)')), \ + feat.GetGeometryRef().ExportToWkt() feat = None lyr = None @@ -525,22 +461,18 @@ def test_ogr_dxf_13(): feat = layer.GetNextFeature() - if feat.Layer != '1': - gdaltest.post_reason('did not get expected layer for feature 0') - return 'fail' + assert feat.Layer == '1', 'did not get expected layer for feature 0' geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbLineString25D: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString25D, \ + 'did not get expected geometry type.' envelope = geom.GetEnvelope() area = (envelope[1] - envelope[0]) * (envelope[3] - envelope[2]) exp_area = 1350.43 - if area < exp_area - 0.5 or area > exp_area + 0.5: - gdaltest.post_reason('envelope area not as expected, got %g.' % area) - return 'fail' + assert area >= exp_area - 0.5 and area <= exp_area + 0.5, \ + ('envelope area not as expected, got %g.' % area) # Check for specific number of points from tessellated arc(s). # Note that this number depends on the tessellation algorithm and @@ -551,15 +483,12 @@ def test_ogr_dxf_13(): # only that more points are returned than in the original polyline, and # that the points lie along (or reasonably close to) said path. - if geom.GetPointCount() != 146: - gdaltest.post_reason('did not get expected number of points, got %d' % geom.GetPointCount()) - return 'fail' + assert geom.GetPointCount() == 146, \ + ('did not get expected number of points, got %d' % geom.GetPointCount()) - if abs(geom.GetX(0) - 251297.8179) > 0.001 \ - or abs(geom.GetY(0) - 412226.8286) > 0.001: - gdaltest.post_reason('first point (%g,%g) not expected location.' + assert abs(geom.GetX(0) - 251297.8179) <= 0.001 and abs(geom.GetY(0) - 412226.8286) <= 0.001, \ + ('first point (%g,%g) not expected location.' % (geom.GetX(0), geom.GetY(0))) - return 'fail' # Other possible tests: # Polylines with no explicit Z coordinates (e.g., no attribute 38 for @@ -589,32 +518,25 @@ def test_ogr_dxf_14(): feat = layer.GetNextFeature() - if feat.Layer != '1': - gdaltest.post_reason('did not get expected layer for feature 0') - return 'fail' + assert feat.Layer == '1', 'did not get expected layer for feature 0' geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbLineString: - gdaltest.post_reason('did not get expected geometry type.') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString, \ + 'did not get expected geometry type.' envelope = geom.GetEnvelope() area = (envelope[1] - envelope[0]) * (envelope[3] - envelope[2]) exp_area = 1350.43 - if area < exp_area - 0.5 or area > exp_area + 0.5: - gdaltest.post_reason('envelope area not as expected, got %g.' % area) - return 'fail' + assert area >= exp_area - 0.5 and area <= exp_area + 0.5, \ + ('envelope area not as expected, got %g.' % area) - if geom.GetPointCount() != 146: - gdaltest.post_reason('did not get expected number of points, got %d' % geom.GetPointCount()) - return 'fail' + assert geom.GetPointCount() == 146, \ + ('did not get expected number of points, got %d' % geom.GetPointCount()) - if abs(geom.GetX(0) - 251297.8179) > 0.001 \ - or abs(geom.GetY(0) - 412226.8286) > 0.001: - gdaltest.post_reason('first point (%g,%g) not expected location.' + assert abs(geom.GetX(0) - 251297.8179) <= 0.001 and abs(geom.GetY(0) - 412226.8286) <= 0.001, \ + ('first point (%g,%g) not expected location.' % (geom.GetX(0), geom.GetY(0))) - return 'fail' ds = None @@ -652,35 +574,26 @@ def test_ogr_dxf_15(): # Check first feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'LINESTRING(10 12, 60 65)'): - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'LINESTRING(10 12, 60 65)')), \ + feat.GetGeometryRef().ExportToWkt() - if feat.GetGeometryRef().GetGeometryType() == ogr.wkbLineString25D: - gdaltest.post_reason('not linestring 2D') - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() != ogr.wkbLineString25D, \ + 'not linestring 2D' - if feat.GetField('Layer') != 'abc': - gdaltest.post_reason('Did not get expected layer, abc.') - return 'fail' + assert feat.GetField('Layer') == 'abc', 'Did not get expected layer, abc.' # Check second point. feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, - 'POLYGON((0 0,100 0,100 100,0 0))'): - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(feat, + 'POLYGON((0 0,100 0,100 100,0 0))')), \ + feat.GetGeometryRef().ExportToWkt() - if feat.GetGeometryRef().GetGeometryType() == ogr.wkbPolygon25D: - gdaltest.post_reason('not keeping polygon 2D') - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() != ogr.wkbPolygon25D, \ + 'not keeping polygon 2D' - if feat.GetField('Layer') != '0': - print(feat.GetField('Layer')) - gdaltest.post_reason('Did not get expected layer, 0.') - return 'fail' + assert feat.GetField('Layer') == '0', 'Did not get expected layer, 0.' lyr = None ds = None @@ -699,18 +612,13 @@ def test_ogr_dxf_15(): abc_off = txt_2.find('abc\n') - if txt_2[16:abc_off] + '0' + txt_2[abc_off + 3:] != txt_1[16:]: - print(txt_2[abc_off] + '0' + txt_2[abc_off + 3:]) - print(txt_1) - gdaltest.post_reason('Layer abc does not seem to match layer 0.') - return 'fail' + assert txt_2[16:abc_off] + '0' + txt_2[abc_off + 3:] == txt_1[16:], \ + 'Layer abc does not seem to match layer 0.' # Check that $HANDSEED was set as expected. start_seed = outdxf.find('$HANDSEED') handseed = outdxf[start_seed + 10 + 4:start_seed + 10 + 4 + 8] - if handseed != '00000053': - gdaltest.post_reason('Did not get expected HANDSEED, got %s.' % handseed) - return 'fail' + assert handseed == '00000053', ('Did not get expected HANDSEED, got %s.' % handseed) os.unlink('tmp/dxf_14.dxf') @@ -726,18 +634,13 @@ def test_ogr_dxf_16(): dxf_ds = ogr.Open('data/assorted.dxf') - if dxf_ds is None: - return 'fail' + assert dxf_ds is not None - if dxf_ds.GetLayerCount() != 2: - gdaltest.post_reason('expected exactly two layers!') - return 'fail' + assert dxf_ds.GetLayerCount() == 2, 'expected exactly two layers!' dxf_layer = dxf_ds.GetLayer(1) - if dxf_layer.GetName() != 'entities': - gdaltest.post_reason('did not get expected layer name.') - return 'fail' + assert dxf_layer.GetName() == 'entities', 'did not get expected layer name.' # read through till we encounter the block reference. feat = dxf_layer.GetNextFeature() @@ -745,21 +648,14 @@ def test_ogr_dxf_16(): feat = dxf_layer.GetNextFeature() # check contents. - if feat.GetField('BlockName') != 'STAR': - gdaltest.post_reason('Did not get blockname!') - return 'fail' + assert feat.GetField('BlockName') == 'STAR', 'Did not get blockname!' - if feat.GetField('BlockAngle') != 0.0: - gdaltest.post_reason('Did not get expected angle.') - return 'fail' + assert feat.GetField('BlockAngle') == 0.0, 'Did not get expected angle.' - if feat.GetField('BlockScale') != [1.0, 1.0, 1.0]: - print(feat.GetField('BlockScale')) - gdaltest.post_reason('Did not get expected BlockScale') - return 'fail' + assert feat.GetField('BlockScale') == [1.0, 1.0, 1.0], \ + 'Did not get expected BlockScale' - if ogrtest.check_feature_geometry(feat, 'POINT (79.097653776656188 119.962195062443342 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (79.097653776656188 119.962195062443342 0)') feat = None @@ -767,46 +663,34 @@ def test_ogr_dxf_16(): dxf_layer = dxf_ds.GetLayer(0) - if dxf_layer.GetName() != 'blocks': - gdaltest.post_reason('did not get expected layer name.') - return 'fail' + assert dxf_layer.GetName() == 'blocks', 'did not get expected layer name.' # STAR geometry feat = dxf_layer.GetNextFeature() - if feat.GetField('Block') != 'STAR': - gdaltest.post_reason('Did not get expected block name.') - return 'fail' + assert feat.GetField('Block') == 'STAR', 'Did not get expected block name.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((-0.028147497671066 1.041457413829428 0,0.619244948763444 -1.069604911500494 0),(0.619244948763444 -1.069604911500494 0,-0.957014920816232 0.478507460408116 0),(-0.957014920816232 0.478507460408116 0,1.041457413829428 0.365917469723853 0),(1.041457413829428 0.365917469723853 0,-0.478507460408116 -1.041457413829428 0),(-0.478507460408116 -1.041457413829428 0,-0.056294995342131 1.013309916158363 0))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((-0.028147497671066 1.041457413829428 0,0.619244948763444 -1.069604911500494 0),(0.619244948763444 -1.069604911500494 0,-0.957014920816232 0.478507460408116 0),(-0.957014920816232 0.478507460408116 0,1.041457413829428 0.365917469723853 0),(1.041457413829428 0.365917469723853 0,-0.478507460408116 -1.041457413829428 0),(-0.478507460408116 -1.041457413829428 0,-0.056294995342131 1.013309916158363 0))') # First MTEXT feat = dxf_layer.GetNextFeature() - if feat.GetField('Text') != gdaltest.sample_text: - gdaltest.post_reason('Did not get expected first mtext.') - return 'fail' + assert feat.GetField('Text') == gdaltest.sample_text, \ + 'Did not get expected first mtext.' expected_style = 'LABEL(f:"Arial",t:"' + gdaltest.sample_style + '",a:45,s:0.5g,p:5,c:#000000)' - if feat.GetStyleString() != expected_style: - gdaltest.post_reason('Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - return 'fail' + assert feat.GetStyleString() == expected_style, \ + ('Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(), expected_style)) - if ogrtest.check_feature_geometry(feat, 'POINT (-1.495452348993292 0.813702013422821 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (-1.495452348993292 0.813702013422821 0)') # Second MTEXT feat = dxf_layer.GetNextFeature() - if feat.GetField('Text') != 'Second': - gdaltest.post_reason('Did not get expected second mtext.') - return 'fail' + assert feat.GetField('Text') == 'Second', 'Did not get expected second mtext.' - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbMText': - gdaltest.post_reason('Did not get expected subclasses.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbMText', \ + 'Did not get expected subclasses.' - if ogrtest.check_feature_geometry(feat, 'POINT (0.879677852348995 -0.263903355704699 0)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (0.879677852348995 -0.263903355704699 0)') feat = None @@ -902,55 +786,44 @@ def test_ogr_dxf_17(): # Check first feature. feat = lyr.GetNextFeature() - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbBlockReference': - gdaltest.post_reason('Got wrong subclasses for feature 1.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbBlockReference', \ + 'Got wrong subclasses for feature 1.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((200 100,201 101),(201 100,200 101))'): - print('Feature 1') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((200 100,201 101),(201 100,200 101))'), \ + 'Feature 1' # Check 2nd feature. feat = lyr.GetNextFeature() - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbPoint': - gdaltest.post_reason('Got wrong subclasses for feature 2.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbPoint', \ + 'Got wrong subclasses for feature 2.' - if ogrtest.check_feature_geometry(feat, 'POINT (300 50)'): - print('Feature 2') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (300 50)'), 'Feature 2' # Check 3rd feature. feat = lyr.GetNextFeature() - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbBlockReference': - gdaltest.post_reason('Got wrong subclasses for feature 3.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbBlockReference', \ + 'Got wrong subclasses for feature 3.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((249.971852502328943 201.04145741382942 0,250.619244948763452 198.930395088499495 0),(250.619244948763452 198.930395088499495 0,249.042985079183779 200.47850746040811 0),(249.042985079183779 200.47850746040811 0,251.04145741382942 200.365917469723854 0),(251.04145741382942 200.365917469723854 0,249.52149253959189 198.95854258617058 0),(249.52149253959189 198.95854258617058 0,249.943705004657858 201.013309916158363 0))'): - print('Feature 3') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((249.971852502328943 201.04145741382942 0,250.619244948763452 198.930395088499495 0),(250.619244948763452 198.930395088499495 0,249.042985079183779 200.47850746040811 0),(249.042985079183779 200.47850746040811 0,251.04145741382942 200.365917469723854 0),(251.04145741382942 200.365917469723854 0,249.52149253959189 198.95854258617058 0),(249.52149253959189 198.95854258617058 0,249.943705004657858 201.013309916158363 0))'), \ + 'Feature 3' # Check 4th feature (scaled and rotated) feat = lyr.GetNextFeature() - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbBlockReference': - gdaltest.post_reason('Got wrong subclasses for feature 4.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbBlockReference', \ + 'Got wrong subclasses for feature 4.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((300 100,300.964101615137736 106.330127018922198), (303.464101615137736 102.0,297.5 104.330127018922198))'): - print('Feature 4') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((300 100,300.964101615137736 106.330127018922198), (303.464101615137736 102.0,297.5 104.330127018922198))'), \ + 'Feature 4' # Check 5th feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((360 110,360 120,370 120,370 110,360 110)),((360 90,360 80,370 80,370 90,360 90)))'): - print('Feature 5') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((360 110,360 120,370 120,370 110,360 110)),((360 90,360 80,370 80,370 90,360 90)))'), \ + 'Feature 5' # Check 6th feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'GEOMETRYCOLLECTION (POINT (401 102),LINESTRING (400 100,401 101))'): - print('Feature 5') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'GEOMETRYCOLLECTION (POINT (401 102),LINESTRING (400 100,401 101))'), \ + 'Feature 5' # Cleanup @@ -1015,68 +888,45 @@ def test_ogr_dxf_18(): # Check first feature. feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'DASHED': - gdaltest.post_reason('Got wrong linetype. (1)') - return 'fail' + assert feat.GetField('Linetype') == 'DASHED', 'Got wrong linetype. (1)' - if feat.GetStyleString() != 'PEN(c:#ffff00,w:2g,p:"12.7g 6.1234567892g")': - print(feat.GetStyleString()) - gdaltest.post_reason("got wrong style string (1)") - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#ffff00,w:2g,p:"12.7g 6.1234567892g")', \ + "got wrong style string (1)" - if ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,25 25)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,25 25)') # Check second feature. feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'DOTTED': - gdaltest.post_reason('Got wrong linetype. (2)') - return 'fail' + assert feat.GetField('Linetype') == 'DOTTED', 'Got wrong linetype. (2)' - if feat.GetStyleString() != 'PEN(c:#ffff00,w:2g,p:"0g 4g")': - print(feat.GetStyleString()) - gdaltest.post_reason("got wrong style string (2)") - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#ffff00,w:2g,p:"0g 4g")', \ + "got wrong style string (2)" - if ogrtest.check_feature_geometry(feat, 'LINESTRING (5 5,30 30)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (5 5,30 30)') # Check third feature. feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'AutoLineType-1': - gdaltest.post_reason('Got wrong linetype. (3)') - return 'fail' + assert feat.GetField('Linetype') == 'AutoLineType-1', 'Got wrong linetype. (3)' - if feat.GetStyleString() != 'PEN(c:#ffff00,w:2g,p:"3g 4g")': - print(feat.GetStyleString()) - gdaltest.post_reason("got wrong style string (3)") - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#ffff00,w:2g,p:"3g 4g")', \ + "got wrong style string (3)" - if ogrtest.check_feature_geometry(feat, 'LINESTRING (5 5,40 30)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (5 5,40 30)') # Check fourth feature. feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'DASHED': - gdaltest.post_reason('Got wrong linetype. (4)') - return 'fail' + assert feat.GetField('Linetype') == 'DASHED', 'Got wrong linetype. (4)' # TODO why did the lineweight go AWOL here? - if feat.GetStyleString() != 'PEN(c:#ffff00,p:"6.35g 3.0617283946g")': - print(feat.GetStyleString()) - gdaltest.post_reason("got wrong style string (4)") - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#ffff00,p:"6.35g 3.0617283946g")', \ + "got wrong style string (4)" # Check fifth feature. feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'AutoLineType-1': - gdaltest.post_reason('Got wrong linetype. (5)') - return 'fail' + assert feat.GetField('Linetype') == 'AutoLineType-1', 'Got wrong linetype. (5)' - if feat.GetStyleString() != 'PEN(c:#ffff00,w:0.01g,p:"6g 8g")': - print(feat.GetStyleString()) - gdaltest.post_reason("got wrong style string (5)") - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#ffff00,w:0.01g,p:"6g 8g")', \ + "got wrong style string (5)" # Cleanup @@ -1116,12 +966,10 @@ def test_ogr_dxf_19(): # Check first feature. feat = lyr.GetNextFeature() - if feat.GetField('SubClasses') != 'AcDbEntity:AcDbBlockReference': - gdaltest.post_reason('Got wrong subclasses for feature 1.') - return 'fail' + assert feat.GetField('SubClasses') == 'AcDbEntity:AcDbBlockReference', \ + 'Got wrong subclasses for feature 1.' - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((249.971852502328943 201.04145741382942 0,250.619244948763452 198.930395088499495 0),(250.619244948763452 198.930395088499495 0,249.042985079183779 200.47850746040811 0),(249.042985079183779 200.47850746040811 0,251.04145741382942 200.365917469723854 0),(251.04145741382942 200.365917469723854 0,249.52149253959189 198.95854258617058 0),(249.52149253959189 198.95854258617058 0,249.943705004657858 201.013309916158363 0))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((249.971852502328943 201.04145741382942 0,250.619244948763452 198.930395088499495 0),(250.619244948763452 198.930395088499495 0,249.042985079183779 200.47850746040811 0),(249.042985079183779 200.47850746040811 0,251.04145741382942 200.365917469723854 0),(251.04145741382942 200.365917469723854 0,249.52149253959189 198.95854258617058 0),(249.52149253959189 198.95854258617058 0,249.943705004657858 201.013309916158363 0))') # Cleanup @@ -1143,8 +991,7 @@ def test_ogr_dxf_20(): feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (10.75 62.75,20.637752769146068 63.434832501489716,29.283239084385464 63.396838394381845,36.766943814562865 62.711565975596599,43.169351828522906 61.454563542054103,48.570947995110252 59.70137939067456,53.05221718316956 57.527561818378146,56.693644261545501 55.008659122085049,59.575714099082703 52.220219598715438,61.778911564625851 49.237791545189509,63.383721527019588 46.136923258427423,64.470628855108572 42.993163035349369,65.120118417737459 39.882059172875508,65.412419131869868 36.878358785215056,65.417809785093752 34.025663008687722,65.193643595004147 31.327113252708507,64.796409941597645 28.783146935042897,64.282598204870823 26.394201473456341,63.708697764820236 24.16071428571431,63.131198001442392 22.083122789582241,62.606588294733939 20.161864402825621,62.191358024691354 18.397376543209894,61.941996571311265 16.790096628500525,61.914993314590184 15.340462076462975,62.166837634524704 14.0489103048627,62.754018911111373 12.915878731465167,63.723652286703427 11.940700981548817,65.053571428571416 11.114552964042769,66.690557841792398 10.424954275262921,68.581246558980226 9.859407264767562,70.672272612748785 9.405414282114966,72.910271035711943 9.050477676863418,75.241876860483572 8.782099798571203,77.613725119677511 8.587782996796603,79.97245084590763 8.4550296210979,82.264689071787842 8.371342021033378,84.437074829931987 8.324222546161321,86.436243152953921 8.301173546040012,88.208926721776336 8.289771106365336,89.722559658784164 8.293223374005688,90.990763736417563 8.349615688917151,92.033410218878885 8.501752503862612,92.870370370370395 8.792438271604945,93.521515455094473 9.264477444907039,94.006716737253413 9.960674476531764,94.345845481049565 10.923833819242011,94.558772950685281 12.196759925800654,94.665370410362868 13.82225724897058,94.685509124284636 15.843130241514663,94.639060356652948 18.302183356195791,94.545895371670113 21.242221045776841,94.421471763308503 24.702030018356666,94.215205541358216 28.660279617432039,93.825673773330607 33.049360720184715,93.15014577259474 37.800473760933045,92.085890852519697 42.844819173995376,90.530178326474584 48.113597393690064,88.380277507828495 53.538008854335445,85.533457709950525 59.049253990249873,81.886988246209697 64.578533235751706,77.338138429975174 70.057047025159264,71.784177574615995 75.415995792790937,65.122374993501282 80.586579972965055,57.25 85.5)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (10.75 62.75,20.637752769146068 63.434832501489716,29.283239084385464 63.396838394381845,36.766943814562865 62.711565975596599,43.169351828522906 61.454563542054103,48.570947995110252 59.70137939067456,53.05221718316956 57.527561818378146,56.693644261545501 55.008659122085049,59.575714099082703 52.220219598715438,61.778911564625851 49.237791545189509,63.383721527019588 46.136923258427423,64.470628855108572 42.993163035349369,65.120118417737459 39.882059172875508,65.412419131869868 36.878358785215056,65.417809785093752 34.025663008687722,65.193643595004147 31.327113252708507,64.796409941597645 28.783146935042897,64.282598204870823 26.394201473456341,63.708697764820236 24.16071428571431,63.131198001442392 22.083122789582241,62.606588294733939 20.161864402825621,62.191358024691354 18.397376543209894,61.941996571311265 16.790096628500525,61.914993314590184 15.340462076462975,62.166837634524704 14.0489103048627,62.754018911111373 12.915878731465167,63.723652286703427 11.940700981548817,65.053571428571416 11.114552964042769,66.690557841792398 10.424954275262921,68.581246558980226 9.859407264767562,70.672272612748785 9.405414282114966,72.910271035711943 9.050477676863418,75.241876860483572 8.782099798571203,77.613725119677511 8.587782996796603,79.97245084590763 8.4550296210979,82.264689071787842 8.371342021033378,84.437074829931987 8.324222546161321,86.436243152953921 8.301173546040012,88.208926721776336 8.289771106365336,89.722559658784164 8.293223374005688,90.990763736417563 8.349615688917151,92.033410218878885 8.501752503862612,92.870370370370395 8.792438271604945,93.521515455094473 9.264477444907039,94.006716737253413 9.960674476531764,94.345845481049565 10.923833819242011,94.558772950685281 12.196759925800654,94.665370410362868 13.82225724897058,94.685509124284636 15.843130241514663,94.639060356652948 18.302183356195791,94.545895371670113 21.242221045776841,94.421471763308503 24.702030018356666,94.215205541358216 28.660279617432039,93.825673773330607 33.049360720184715,93.15014577259474 37.800473760933045,92.085890852519697 42.844819173995376,90.530178326474584 48.113597393690064,88.380277507828495 53.538008854335445,85.533457709950525 59.049253990249873,81.886988246209697 64.578533235751706,77.338138429975174 70.057047025159264,71.784177574615995 75.415995792790937,65.122374993501282 80.586579972965055,57.25 85.5)') ds = None return 'success' @@ -1160,8 +1007,7 @@ def test_ogr_dxf_21(): feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (5 2 3,4.990256201039297 1.720974105023499 3,4.961072274966281 1.443307596159738 3,4.912590402935223 1.168353236728963 3,4.845046783753276 0.897450576732003 3,4.758770483143634 0.631919426697325 3,4.654181830570403 0.373053427696799 3,4.531790371435708 0.122113748856437 3,4.392192384625703 -0.11967705693282 3,4.23606797749979 -0.351141009169893 3,4.064177772475912 -0.571150438746157 3,3.877359201354605 -0.778633481835989 3,3.676522425435433 -0.972579301909577 3,3.462645901302633 -1.152043014426888 3,3.236771613882987 -1.316150290220167 3,3.0 -1.464101615137754 3,2.75348458715631 -1.595176185196668 3,2.498426373663648 -1.70873541826715 3,2.23606797749979 -1.804226065180614 3,1.967687582398672 -1.881182905103986 3,1.694592710667722 -1.939231012048832 3,1.418113853070614 -1.978087581473093 3,1.139597986810004 -1.997563308076383 3,0.860402013189997 -1.997563308076383 3,0.581886146929387 -1.978087581473094 3,0.305407289332279 -1.939231012048832 3,0.032312417601329 -1.881182905103986 3,-0.236067977499789 -1.804226065180615 3,-0.498426373663648 -1.70873541826715 3,-0.75348458715631 -1.595176185196668 3,-1.0 -1.464101615137755 3,-1.236771613882987 -1.316150290220167 3,-1.462645901302633 -1.152043014426888 3,-1.676522425435433 -0.972579301909577 3,-1.877359201354605 -0.778633481835989 3,-2.064177772475912 -0.571150438746158 3,-2.236067977499789 -0.351141009169893 3,-2.392192384625704 -0.11967705693282 3,-2.531790371435707 0.122113748856436 3,-2.654181830570403 0.373053427696798 3,-2.758770483143633 0.631919426697324 3,-2.845046783753275 0.897450576732001 3,-2.912590402935223 1.168353236728963 3,-2.961072274966281 1.443307596159737 3,-2.990256201039297 1.720974105023498 3,-3.0 2.0 3,-2.990256201039297 2.279025894976499 3,-2.961072274966281 2.556692403840262 3,-2.912590402935223 2.831646763271036 3,-2.845046783753276 3.102549423267996 3,-2.758770483143634 3.368080573302675 3,-2.654181830570404 3.626946572303199 3,-2.531790371435708 3.877886251143563 3,-2.392192384625704 4.119677056932819 3,-2.23606797749979 4.351141009169892 3,-2.064177772475912 4.571150438746157 3,-1.877359201354604 4.778633481835989 3,-1.676522425435434 4.972579301909576 3,-1.462645901302632 5.152043014426889 3,-1.236771613882989 5.316150290220166 3,-1.0 5.464101615137753 3,-0.753484587156311 5.595176185196667 3,-0.498426373663649 5.70873541826715 3,-0.23606797749979 5.804226065180615 3,0.032312417601329 5.881182905103985 3,0.305407289332279 5.939231012048833 3,0.581886146929387 5.978087581473094 3,0.860402013189993 5.997563308076383 3,1.139597986810005 5.997563308076383 3,1.418113853070612 5.978087581473094 3,1.69459271066772 5.939231012048833 3,1.96768758239867 5.881182905103986 3,2.236067977499789 5.804226065180615 3,2.498426373663648 5.70873541826715 3,2.75348458715631 5.595176185196668 3,3.0 5.464101615137754 3,3.236771613882985 5.316150290220168 3,3.462645901302634 5.152043014426887 3,3.676522425435431 4.972579301909578 3,3.877359201354603 4.778633481835991 3,4.064177772475912 4.571150438746159 3,4.23606797749979 4.351141009169893 3,4.392192384625702 4.119677056932823 3,4.531790371435708 3.877886251143563 3,4.654181830570404 3.626946572303201 3,4.758770483143634 3.368080573302675 3,4.845046783753275 3.102549423267999 3,4.912590402935223 2.831646763271039 3,4.961072274966281 2.556692403840263 3,4.990256201039298 2.279025894976499 3,5.0 2.0 3)'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'LINESTRING (5 2 3,4.990256201039297 1.720974105023499 3,4.961072274966281 1.443307596159738 3,4.912590402935223 1.168353236728963 3,4.845046783753276 0.897450576732003 3,4.758770483143634 0.631919426697325 3,4.654181830570403 0.373053427696799 3,4.531790371435708 0.122113748856437 3,4.392192384625703 -0.11967705693282 3,4.23606797749979 -0.351141009169893 3,4.064177772475912 -0.571150438746157 3,3.877359201354605 -0.778633481835989 3,3.676522425435433 -0.972579301909577 3,3.462645901302633 -1.152043014426888 3,3.236771613882987 -1.316150290220167 3,3.0 -1.464101615137754 3,2.75348458715631 -1.595176185196668 3,2.498426373663648 -1.70873541826715 3,2.23606797749979 -1.804226065180614 3,1.967687582398672 -1.881182905103986 3,1.694592710667722 -1.939231012048832 3,1.418113853070614 -1.978087581473093 3,1.139597986810004 -1.997563308076383 3,0.860402013189997 -1.997563308076383 3,0.581886146929387 -1.978087581473094 3,0.305407289332279 -1.939231012048832 3,0.032312417601329 -1.881182905103986 3,-0.236067977499789 -1.804226065180615 3,-0.498426373663648 -1.70873541826715 3,-0.75348458715631 -1.595176185196668 3,-1.0 -1.464101615137755 3,-1.236771613882987 -1.316150290220167 3,-1.462645901302633 -1.152043014426888 3,-1.676522425435433 -0.972579301909577 3,-1.877359201354605 -0.778633481835989 3,-2.064177772475912 -0.571150438746158 3,-2.236067977499789 -0.351141009169893 3,-2.392192384625704 -0.11967705693282 3,-2.531790371435707 0.122113748856436 3,-2.654181830570403 0.373053427696798 3,-2.758770483143633 0.631919426697324 3,-2.845046783753275 0.897450576732001 3,-2.912590402935223 1.168353236728963 3,-2.961072274966281 1.443307596159737 3,-2.990256201039297 1.720974105023498 3,-3.0 2.0 3,-2.990256201039297 2.279025894976499 3,-2.961072274966281 2.556692403840262 3,-2.912590402935223 2.831646763271036 3,-2.845046783753276 3.102549423267996 3,-2.758770483143634 3.368080573302675 3,-2.654181830570404 3.626946572303199 3,-2.531790371435708 3.877886251143563 3,-2.392192384625704 4.119677056932819 3,-2.23606797749979 4.351141009169892 3,-2.064177772475912 4.571150438746157 3,-1.877359201354604 4.778633481835989 3,-1.676522425435434 4.972579301909576 3,-1.462645901302632 5.152043014426889 3,-1.236771613882989 5.316150290220166 3,-1.0 5.464101615137753 3,-0.753484587156311 5.595176185196667 3,-0.498426373663649 5.70873541826715 3,-0.23606797749979 5.804226065180615 3,0.032312417601329 5.881182905103985 3,0.305407289332279 5.939231012048833 3,0.581886146929387 5.978087581473094 3,0.860402013189993 5.997563308076383 3,1.139597986810005 5.997563308076383 3,1.418113853070612 5.978087581473094 3,1.69459271066772 5.939231012048833 3,1.96768758239867 5.881182905103986 3,2.236067977499789 5.804226065180615 3,2.498426373663648 5.70873541826715 3,2.75348458715631 5.595176185196668 3,3.0 5.464101615137754 3,3.236771613882985 5.316150290220168 3,3.462645901302634 5.152043014426887 3,3.676522425435431 4.972579301909578 3,3.877359201354603 4.778633481835991 3,4.064177772475912 4.571150438746159 3,4.23606797749979 4.351141009169893 3,4.392192384625702 4.119677056932823 3,4.531790371435708 3.877886251143563 3,4.654181830570404 3.626946572303201 3,4.758770483143634 3.368080573302675 3,4.845046783753275 3.102549423267999 3,4.912590402935223 2.831646763271039 3,4.961072274966281 2.556692403840263 3,4.990256201039298 2.279025894976499 3,5.0 2.0 3)') ds = None return 'success' @@ -1277,13 +1123,8 @@ def test_ogr_dxf_23(): feat = lyr.GetNextFeature() style = feat.GetStyleString() - if style != 'BRUSH(fc:#ff0000)': - gdaltest.post_reason('bad style') - print(style) - return 'fail' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('bad geometry') - return 'fail' + assert style == 'BRUSH(fc:#ff0000)', 'bad style' + assert not ogrtest.check_feature_geometry(feat, wkt), 'bad geometry' ds = None @@ -1303,18 +1144,15 @@ def test_ogr_dxf_24(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') feat = lyr.GetNextFeature() gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(feat, 'POLYGON ((2 1,1.646446609406726 0.853553390593274,1.5 0.5,1.646446609406726 0.146446609406726,2 0,2.0 0.0,2.146446609406726 -0.353553390593274,2.5 -0.5,2.853553390593274 -0.353553390593274,3.0 -0.0,3 0,3.353553390593274 0.146446609406726,3.5 0.5,3.353553390593274 0.853553390593273,3 1,2.853553390593274 1.353553390593274,2.5 1.5,2.146446609406726 1.353553390593274,2 1))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON ((2 1,1.646446609406726 0.853553390593274,1.5 0.5,1.646446609406726 0.146446609406726,2 0,2.0 0.0,2.146446609406726 -0.353553390593274,2.5 -0.5,2.853553390593274 -0.353553390593274,3.0 -0.0,3 0,3.353553390593274 0.146446609406726,3.5 0.5,3.353553390593274 0.853553390593273,3 1,2.853553390593274 1.353553390593274,2.5 1.5,2.146446609406726 1.353553390593274,2 1))') gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') feat = lyr.GetNextFeature() gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(feat, 'POLYGON ((0.0 0.0 0,-0.353553390593274 0.146446609406726 0,-0.5 0.5 0,-0.353553390593274 0.853553390593274 0,-0.0 1.0 0,0.0 1.0 0,0.146446609406726 1.353553390593274 0,0.5 1.5 0,0.853553390593274 1.353553390593274 0,1.0 1.0 0,1.0 1.0 0,1.353553390593274 0.853553390593274 0,1.5 0.5 0,1.353553390593274 0.146446609406727 0,1.0 0.0 0,1 0 0,0.853553390593274 -0.353553390593274 0,0.5 -0.5 0,0.146446609406726 -0.353553390593274 0,0.0 -0.0 0,0.0 0.0 0))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON ((0.0 0.0 0,-0.353553390593274 0.146446609406726 0,-0.5 0.5 0,-0.353553390593274 0.853553390593274 0,-0.0 1.0 0,0.0 1.0 0,0.146446609406726 1.353553390593274 0,0.5 1.5 0,0.853553390593274 1.353553390593274 0,1.0 1.0 0,1.0 1.0 0,1.353553390593274 0.853553390593274 0,1.5 0.5 0,1.353553390593274 0.146446609406727 0,1.0 0.0 0,1 0 0,0.853553390593274 -0.353553390593274 0,0.5 -0.5 0,0.146446609406726 -0.353553390593274 0,0.0 -0.0 0,0.0 0.0 0))') feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POLYGON ((-1 -1,-1 0,0 0,-1 -1))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POLYGON ((-1 -1,-1 0,0 0,-1 -1))') ds = None return 'success' @@ -1369,8 +1207,7 @@ def test_ogr_dxf_27(): gdal.FileFromMemBuffer('/vsimem/a_dxf_without_extension', open('data/solid.dxf').read()) ds = ogr.Open('/vsimem/a_dxf_without_extension') - if ds is None: - return 'fail' + assert ds is not None gdal.Unlink('/vsimem/a_dxf_without_extension') @@ -2482,13 +2319,11 @@ def test_ogr_dxf_33(): # Polyface mesh (POLYLINE) feat = layer.GetNextFeature() - if feat.Layer != '0': - return 'fail' + assert feat.Layer == '0' geom = feat.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbPolyhedralSurfaceZ: - gdaltest.post_reason('did not get expected geometry type; got %s instead of wkbPolyhedralSurface' % geom.GetGeometryType()) - return 'fail' + assert geom.GetGeometryType() == ogr.wkbPolyhedralSurfaceZ, \ + ('did not get expected geometry type; got %s instead of wkbPolyhedralSurface' % geom.GetGeometryType()) wkt_string = geom.ExportToIsoWkt() wkt_string_expected = 'POLYHEDRALSURFACE Z (((0 0 0,1 0 0,1 1 0,0 1 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((1 0 0,1 1 0,1 1 1,1 0 1,1 0 0)),((1 1 0,1 1 1,0 1 1,0 1 0,1 1 0)),((0 0 0,0 1 0,0 1 1,0 0 1,0 0 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))' @@ -2498,22 +2333,20 @@ def test_ogr_dxf_33(): return 'fail' faces = geom.GetGeometryCount() - if faces != 6: - gdaltest.post_reason('did not get expected number of faces, got %d instead of %d' % (faces, 6)) - return 'fail' + assert faces == 6, \ + ('did not get expected number of faces, got %d instead of %d' % (faces, 6)) # Cylinder (CIRCLE with thickness) feat = layer.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POLYHEDRALSURFACE Z (((2.8 -0.0 1e-31,2.79902562010393 -0.0 -0.0279025894976501,2.79610722749663 -0.0 -0.0556692403840262,2.79125904029352 -0.0 -0.0831646763271037,2.78450467837533 -0.0 -0.1102549423268,2.77587704831436 -0.0 -0.136808057330267,2.76541818305704 -0.0 -0.16269465723032,2.75317903714357 -0.0 -0.187788625114356,2.73921923846257 -0.0 -0.211967705693282,2.72360679774998 0.0 -0.235114100916989,2.70641777724759 0.0 -0.257115043874616,2.68773592013546 0.0 -0.277863348183599,2.66765224254354 0.0 -0.297257930190958,2.64626459013026 0.0 -0.315204301442689,2.6236771613883 0.0 -0.331615029022017,2.6 0.0 -0.346410161513775,2.57534845871563 0.0 -0.359517618519667,2.54984263736636 0.0 -0.370873541826715,2.52360679774998 0.0 -0.380422606518061,2.49676875823987 0.0 -0.388118290510399,2.46945927106677 0.0 -0.393923101204883,2.44181138530706 0.0 -0.397808758147309,2.413959798681 0.0 -0.399756330807638,2.386040201319 0.0 -0.399756330807638,2.35818861469294 0.0 -0.397808758147309,2.33054072893323 0.0 -0.393923101204883,2.30323124176013 0.0 -0.388118290510399,2.27639320225002 0.0 -0.380422606518061,2.25015736263363 0.0 -0.370873541826715,2.22465154128437 0.0 -0.359517618519667,2.2 0.0 -0.346410161513776,2.1763228386117 0.0 -0.331615029022017,2.15373540986974 0.0 -0.315204301442689,2.13234775745646 0.0 -0.297257930190958,2.11226407986454 0.0 -0.277863348183599,2.09358222275241 0.0 -0.257115043874616,2.07639320225002 0.0 -0.235114100916989,2.06078076153743 0.0 -0.211967705693282,2.04682096285643 0.0 -0.187788625114356,2.03458181694296 0.0 -0.16269465723032,2.02412295168564 0.0 -0.136808057330268,2.01549532162467 0.0 -0.1102549423268,2.00874095970648 0.0 -0.0831646763271037,2.00389277250337 0.0 -0.0556692403840263,2.00097437989607 0.0 -0.0279025894976502,' + + assert (not ogrtest.check_feature_geometry(feat, 'POLYHEDRALSURFACE Z (((2.8 -0.0 1e-31,2.79902562010393 -0.0 -0.0279025894976501,2.79610722749663 -0.0 -0.0556692403840262,2.79125904029352 -0.0 -0.0831646763271037,2.78450467837533 -0.0 -0.1102549423268,2.77587704831436 -0.0 -0.136808057330267,2.76541818305704 -0.0 -0.16269465723032,2.75317903714357 -0.0 -0.187788625114356,2.73921923846257 -0.0 -0.211967705693282,2.72360679774998 0.0 -0.235114100916989,2.70641777724759 0.0 -0.257115043874616,2.68773592013546 0.0 -0.277863348183599,2.66765224254354 0.0 -0.297257930190958,2.64626459013026 0.0 -0.315204301442689,2.6236771613883 0.0 -0.331615029022017,2.6 0.0 -0.346410161513775,2.57534845871563 0.0 -0.359517618519667,2.54984263736636 0.0 -0.370873541826715,2.52360679774998 0.0 -0.380422606518061,2.49676875823987 0.0 -0.388118290510399,2.46945927106677 0.0 -0.393923101204883,2.44181138530706 0.0 -0.397808758147309,2.413959798681 0.0 -0.399756330807638,2.386040201319 0.0 -0.399756330807638,2.35818861469294 0.0 -0.397808758147309,2.33054072893323 0.0 -0.393923101204883,2.30323124176013 0.0 -0.388118290510399,2.27639320225002 0.0 -0.380422606518061,2.25015736263363 0.0 -0.370873541826715,2.22465154128437 0.0 -0.359517618519667,2.2 0.0 -0.346410161513776,2.1763228386117 0.0 -0.331615029022017,2.15373540986974 0.0 -0.315204301442689,2.13234775745646 0.0 -0.297257930190958,2.11226407986454 0.0 -0.277863348183599,2.09358222275241 0.0 -0.257115043874616,2.07639320225002 0.0 -0.235114100916989,2.06078076153743 0.0 -0.211967705693282,2.04682096285643 0.0 -0.187788625114356,2.03458181694296 0.0 -0.16269465723032,2.02412295168564 0.0 -0.136808057330268,2.01549532162467 0.0 -0.1102549423268,2.00874095970648 0.0 -0.0831646763271037,2.00389277250337 0.0 -0.0556692403840263,2.00097437989607 0.0 -0.0279025894976502,' + '2.0 0.0 -4.8985871965894e-17,2.00097437989607 0.0 0.0279025894976499,2.00389277250337 0.0 0.0556692403840262,2.00874095970648 0.0 0.0831646763271036,2.01549532162467 0.0 0.1102549423268,2.02412295168564 0.0 0.136808057330267,2.03458181694296 0.0 0.16269465723032,2.04682096285643 0.0 0.187788625114356,2.06078076153743 0.0 0.211967705693282,2.07639320225002 0.0 0.235114100916989,2.09358222275241 0.0 0.257115043874616,2.11226407986454 0.0 0.277863348183599,2.13234775745646 0.0 0.297257930190958,2.15373540986974 0.0 0.315204301442689,2.1763228386117 -0.0 0.331615029022017,2.2 -0.0 0.346410161513775,2.22465154128437 -0.0 0.359517618519667,2.25015736263363 -0.0 0.370873541826715,2.27639320225002 -0.0 0.380422606518061,2.30323124176013 -0.0 0.388118290510399,2.33054072893323 -0.0 0.393923101204883,2.35818861469294 -0.0 0.397808758147309,2.386040201319 -0.0 0.399756330807638,2.413959798681 -0.0 0.399756330807638,2.44181138530706 -0.0 0.397808758147309,2.46945927106677 -0.0 0.393923101204883,2.49676875823987 -0.0 0.388118290510399,2.52360679774998 -0.0 0.380422606518061,2.54984263736636 -0.0 0.370873541826715,2.57534845871563 -0.0 0.359517618519667,2.6 -0.0 0.346410161513775,2.6236771613883 -0.0 0.331615029022017,2.64626459013026 -0.0 0.315204301442689,2.66765224254354 -0.0 0.297257930190958,2.68773592013546 -0.0 0.277863348183599,2.70641777724759 -0.0 0.257115043874616,2.72360679774998 -0.0 0.235114100916989,2.73921923846257 -0.0 0.211967705693282,2.75317903714357 -0.0 0.187788625114356,2.76541818305704 -0.0 0.16269465723032,2.77587704831436 -0.0 0.136808057330267,2.78450467837533 -0.0 0.1102549423268,2.79125904029352 -0.0 0.0831646763271039,2.79610722749663 -0.0 0.0556692403840264,2.79902562010393 -0.0 0.0279025894976499,2.8 -0.0 1e-31)),' + '((2.8 1.8 3.6e-16,2.79902562010393 1.8 -0.0279025894976498,2.79610722749663 1.8 -0.0556692403840258,2.79125904029352 1.8 -0.0831646763271034,2.78450467837533 1.8 -0.110254942326799,2.77587704831436 1.8 -0.136808057330267,2.76541818305704 1.8 -0.16269465723032,2.75317903714357 1.8 -0.187788625114356,2.73921923846257 1.8 -0.211967705693282,2.72360679774998 1.8 -0.235114100916989,2.70641777724759 1.8 -0.257115043874615,2.68773592013546 1.8 -0.277863348183599,2.66765224254354 1.8 -0.297257930190957,2.64626459013026 1.8 -0.315204301442689,2.6236771613883 1.8 -0.331615029022016,2.6 1.8 -0.346410161513775,2.57534845871563 1.8 -0.359517618519667,2.54984263736636 1.8 -0.370873541826715,2.52360679774998 1.8 -0.380422606518061,2.49676875823987 1.8 -0.388118290510398,2.46945927106677 1.8 -0.393923101204883,2.44181138530706 1.8 -0.397808758147309,2.413959798681 1.8 -0.399756330807638,2.386040201319 1.8 -0.399756330807638,2.35818861469294 1.8 -0.397808758147309,2.33054072893323 1.8 -0.393923101204883,2.30323124176013 1.8 -0.388118290510398,2.27639320225002 1.8 -0.380422606518061,2.25015736263363 1.8 -0.370873541826715,2.22465154128437 1.8 -0.359517618519666,2.2 1.8 -0.346410161513775,2.1763228386117 1.8 -0.331615029022016,2.15373540986974 1.8 -0.315204301442689,2.13234775745646 1.8 -0.297257930190957,2.11226407986454 1.8 -0.277863348183599,2.09358222275241 1.8 -0.257115043874615,2.07639320225002 1.8 -0.235114100916989,2.06078076153743 1.8 -0.211967705693282,2.04682096285643 1.8 -0.187788625114356,2.03458181694296 1.8 -0.16269465723032,2.02412295168564 1.8 -0.136808057330267,2.01549532162467 1.8 -0.1102549423268,2.00874095970648 1.8 -0.0831646763271034,2.00389277250337 1.8 -0.0556692403840259,2.00097437989607 1.8 -0.0279025894976499,2.0 1.8 3.11014128034106e-16,' + '2.00097437989607 1.8 0.0279025894976503,2.00389277250337 1.8 0.0556692403840266,2.00874095970648 1.8 0.083164676327104,2.01549532162467 1.8 0.1102549423268,2.02412295168564 1.8 0.136808057330268,2.03458181694296 1.8 0.16269465723032,2.04682096285643 1.8 0.187788625114357,2.06078076153743 1.8 0.211967705693282,2.07639320225002 1.8 0.23511410091699,2.09358222275241 1.8 0.257115043874616,2.11226407986454 1.8 0.277863348183599,2.13234775745646 1.8 0.297257930190958,2.15373540986974 1.8 0.315204301442689,2.1763228386117 1.8 0.331615029022017,2.2 1.8 0.346410161513776,2.22465154128437 1.8 0.359517618519667,2.25015736263363 1.8 0.370873541826715,2.27639320225002 1.8 0.380422606518062,2.30323124176013 1.8 0.388118290510399,2.33054072893323 1.8 0.393923101204884,2.35818861469294 1.8 0.39780875814731,2.386040201319 1.8 0.399756330807639,2.413959798681 1.8 0.399756330807639,2.44181138530706 1.8 0.39780875814731,2.46945927106677 1.8 0.393923101204884,2.49676875823987 1.8 0.388118290510399,2.52360679774998 1.8 0.380422606518062,2.54984263736636 1.8 0.370873541826715,2.57534845871563 1.8 0.359517618519667,2.6 1.8 0.346410161513776,2.6236771613883 1.8 0.331615029022017,2.64626459013026 1.8 0.315204301442689,2.66765224254354 1.8 0.297257930190958,2.68773592013546 1.8 0.277863348183599,2.70641777724759 1.8 0.257115043874616,2.72360679774998 1.8 0.23511410091699,2.73921923846257 1.8 0.211967705693283,2.75317903714357 1.8 0.187788625114357,2.76541818305704 1.8 0.16269465723032,2.77587704831436 1.8 0.136808057330268,2.78450467837533 1.8 0.1102549423268,2.79125904029352 1.8 0.0831646763271043,2.79610722749663 1.8 0.0556692403840267,2.79902562010393 1.8 0.0279025894976503,2.8 1.8 3.6e-16)),' + '((2.0 0.0 -4.8985871965894e-17,2.00097437989607 0.0 -0.0279025894976502,2.00389277250337 0.0 -0.0556692403840263,2.00874095970648 0.0 -0.0831646763271037,2.01549532162467 0.0 -0.1102549423268,2.02412295168564 0.0 -0.136808057330268,2.03458181694296 0.0 -0.16269465723032,2.04682096285643 0.0 -0.187788625114356,2.06078076153743 0.0 -0.211967705693282,2.07639320225002 0.0 -0.235114100916989,2.09358222275241 0.0 -0.257115043874616,2.11226407986454 0.0 -0.277863348183599,2.13234775745646 0.0 -0.297257930190958,2.15373540986974 0.0 -0.315204301442689,2.1763228386117 0.0 -0.331615029022017,2.2 0.0 -0.346410161513776,2.22465154128437 0.0 -0.359517618519667,2.25015736263363 0.0 -0.370873541826715,2.27639320225002 0.0 -0.380422606518061,2.30323124176013 0.0 -0.388118290510399,2.33054072893323 0.0 -0.393923101204883,2.35818861469294 0.0 -0.397808758147309,2.386040201319 0.0 -0.399756330807638,2.413959798681 0.0 -0.399756330807638,2.44181138530706 0.0 -0.397808758147309,2.46945927106677 0.0 -0.393923101204883,2.49676875823987 0.0 -0.388118290510399,2.52360679774998 0.0 -0.380422606518061,2.54984263736636 0.0 -0.370873541826715,2.57534845871563 0.0 -0.359517618519667,2.6 0.0 -0.346410161513775,2.6236771613883 0.0 -0.331615029022017,2.64626459013026 0.0 -0.315204301442689,2.66765224254354 0.0 -0.297257930190958,2.68773592013546 0.0 -0.277863348183599,2.70641777724759 0.0 -0.257115043874616,2.72360679774998 0.0 -0.235114100916989,2.73921923846257 -0.0 -0.211967705693282,2.75317903714357 -0.0 -0.187788625114356,2.76541818305704 -0.0 -0.16269465723032,2.77587704831436 -0.0 -0.136808057330267,2.78450467837533 -0.0 -0.1102549423268,2.79125904029352 -0.0 -0.0831646763271037,2.79610722749663 -0.0 -0.0556692403840262,2.79902562010393 -0.0 -0.0279025894976501,' + '2.8 -0.0 1e-31,2.8 1.8 3.6e-16,2.79902562010393 1.8 -0.0279025894976498,2.79610722749663 1.8 -0.0556692403840258,2.79125904029352 1.8 -0.0831646763271034,2.78450467837533 1.8 -0.110254942326799,2.77587704831436 1.8 -0.136808057330267,2.76541818305704 1.8 -0.16269465723032,2.75317903714357 1.8 -0.187788625114356,2.73921923846257 1.8 -0.211967705693282,2.72360679774998 1.8 -0.235114100916989,2.70641777724759 1.8 -0.257115043874615,2.68773592013546 1.8 -0.277863348183599,2.66765224254354 1.8 -0.297257930190957,2.64626459013026 1.8 -0.315204301442689,2.6236771613883 1.8 -0.331615029022016,2.6 1.8 -0.346410161513775,2.57534845871563 1.8 -0.359517618519667,2.54984263736636 1.8 -0.370873541826715,2.52360679774998 1.8 -0.380422606518061,2.49676875823987 1.8 -0.388118290510398,2.46945927106677 1.8 -0.393923101204883,2.44181138530706 1.8 -0.397808758147309,2.413959798681 1.8 -0.399756330807638,2.386040201319 1.8 -0.399756330807638,2.35818861469294 1.8 -0.397808758147309,2.33054072893323 1.8 -0.393923101204883,2.30323124176013 1.8 -0.388118290510398,2.27639320225002 1.8 -0.380422606518061,2.25015736263363 1.8 -0.370873541826715,2.22465154128437 1.8 -0.359517618519666,2.2 1.8 -0.346410161513775,2.1763228386117 1.8 -0.331615029022016,2.15373540986974 1.8 -0.315204301442689,2.13234775745646 1.8 -0.297257930190957,2.11226407986454 1.8 -0.277863348183599,2.09358222275241 1.8 -0.257115043874615,2.07639320225002 1.8 -0.235114100916989,2.06078076153743 1.8 -0.211967705693282,2.04682096285643 1.8 -0.187788625114356,2.03458181694296 1.8 -0.16269465723032,2.02412295168564 1.8 -0.136808057330267,2.01549532162467 1.8 -0.1102549423268,2.00874095970648 1.8 -0.0831646763271034,2.00389277250337 1.8 -0.0556692403840259,2.00097437989607 1.8 -0.0279025894976499,2.0 1.8 3.11014128034106e-16,2.0 0.0 -4.8985871965894e-17)),' + '((2.8 -0.0 1e-31,2.79902562010393 -0.0 0.0279025894976499,2.79610722749663 -0.0 0.0556692403840264,2.79125904029352 -0.0 0.0831646763271039,2.78450467837533 -0.0 0.1102549423268,2.77587704831436 -0.0 0.136808057330267,2.76541818305704 -0.0 0.16269465723032,2.75317903714357 -0.0 0.187788625114356,2.73921923846257 -0.0 0.211967705693282,2.72360679774998 -0.0 0.235114100916989,2.70641777724759 -0.0 0.257115043874616,2.68773592013546 -0.0 0.277863348183599,2.66765224254354 -0.0 0.297257930190958,2.64626459013026 -0.0 0.315204301442689,2.6236771613883 -0.0 0.331615029022017,2.6 -0.0 0.346410161513775,2.57534845871563 -0.0 0.359517618519667,2.54984263736636 -0.0 0.370873541826715,2.52360679774998 -0.0 0.380422606518061,2.49676875823987 -0.0 0.388118290510399,2.46945927106677 -0.0 0.393923101204883,2.44181138530706 -0.0 0.397808758147309,2.413959798681 -0.0 0.399756330807638,2.386040201319 -0.0 0.399756330807638,2.35818861469294 -0.0 0.397808758147309,2.33054072893323 -0.0 0.393923101204883,2.30323124176013 -0.0 0.388118290510399,2.27639320225002 -0.0 0.380422606518061,2.25015736263363 -0.0 0.370873541826715,2.22465154128437 -0.0 0.359517618519667,2.2 -0.0 0.346410161513775,2.1763228386117 -0.0 0.331615029022017,2.15373540986974 0.0 0.315204301442689,2.13234775745646 0.0 0.297257930190958,2.11226407986454 0.0 0.277863348183599,2.09358222275241 0.0 0.257115043874616,2.07639320225002 0.0 0.235114100916989,2.06078076153743 0.0 0.211967705693282,2.04682096285643 0.0 0.187788625114356,2.03458181694296 0.0 0.16269465723032,2.02412295168564 0.0 0.136808057330267,2.01549532162467 0.0 0.1102549423268,2.00874095970648 0.0 0.0831646763271036,2.00389277250337 0.0 0.0556692403840262,2.00097437989607 0.0 0.0279025894976499,' + - '2.0 0.0 -4.8985871965894e-17,2.0 1.8 3.11014128034106e-16,2.00097437989607 1.8 0.0279025894976503,2.00389277250337 1.8 0.0556692403840266,2.00874095970648 1.8 0.083164676327104,2.01549532162467 1.8 0.1102549423268,2.02412295168564 1.8 0.136808057330268,2.03458181694296 1.8 0.16269465723032,2.04682096285643 1.8 0.187788625114357,2.06078076153743 1.8 0.211967705693282,2.07639320225002 1.8 0.23511410091699,2.09358222275241 1.8 0.257115043874616,2.11226407986454 1.8 0.277863348183599,2.13234775745646 1.8 0.297257930190958,2.15373540986974 1.8 0.315204301442689,2.1763228386117 1.8 0.331615029022017,2.2 1.8 0.346410161513776,2.22465154128437 1.8 0.359517618519667,2.25015736263363 1.8 0.370873541826715,2.27639320225002 1.8 0.380422606518062,2.30323124176013 1.8 0.388118290510399,2.33054072893323 1.8 0.393923101204884,2.35818861469294 1.8 0.39780875814731,2.386040201319 1.8 0.399756330807639,2.413959798681 1.8 0.399756330807639,2.44181138530706 1.8 0.39780875814731,2.46945927106677 1.8 0.393923101204884,2.49676875823987 1.8 0.388118290510399,2.52360679774998 1.8 0.380422606518062,2.54984263736636 1.8 0.370873541826715,2.57534845871563 1.8 0.359517618519667,2.6 1.8 0.346410161513776,2.6236771613883 1.8 0.331615029022017,2.64626459013026 1.8 0.315204301442689,2.66765224254354 1.8 0.297257930190958,2.68773592013546 1.8 0.277863348183599,2.70641777724759 1.8 0.257115043874616,2.72360679774998 1.8 0.23511410091699,2.73921923846257 1.8 0.211967705693283,2.75317903714357 1.8 0.187788625114357,2.76541818305704 1.8 0.16269465723032,2.77587704831436 1.8 0.136808057330268,2.78450467837533 1.8 0.1102549423268,2.79125904029352 1.8 0.0831646763271043,2.79610722749663 1.8 0.0556692403840267,2.79902562010393 1.8 0.0279025894976503,2.8 1.8 3.6e-16,2.8 -0.0 1e-31)))'): - gdaltest.post_reason('wrong geometry for cylinder') - return 'fail' + '2.0 0.0 -4.8985871965894e-17,2.0 1.8 3.11014128034106e-16,2.00097437989607 1.8 0.0279025894976503,2.00389277250337 1.8 0.0556692403840266,2.00874095970648 1.8 0.083164676327104,2.01549532162467 1.8 0.1102549423268,2.02412295168564 1.8 0.136808057330268,2.03458181694296 1.8 0.16269465723032,2.04682096285643 1.8 0.187788625114357,2.06078076153743 1.8 0.211967705693282,2.07639320225002 1.8 0.23511410091699,2.09358222275241 1.8 0.257115043874616,2.11226407986454 1.8 0.277863348183599,2.13234775745646 1.8 0.297257930190958,2.15373540986974 1.8 0.315204301442689,2.1763228386117 1.8 0.331615029022017,2.2 1.8 0.346410161513776,2.22465154128437 1.8 0.359517618519667,2.25015736263363 1.8 0.370873541826715,2.27639320225002 1.8 0.380422606518062,2.30323124176013 1.8 0.388118290510399,2.33054072893323 1.8 0.393923101204884,2.35818861469294 1.8 0.39780875814731,2.386040201319 1.8 0.399756330807639,2.413959798681 1.8 0.399756330807639,2.44181138530706 1.8 0.39780875814731,2.46945927106677 1.8 0.393923101204884,2.49676875823987 1.8 0.388118290510399,2.52360679774998 1.8 0.380422606518062,2.54984263736636 1.8 0.370873541826715,2.57534845871563 1.8 0.359517618519667,2.6 1.8 0.346410161513776,2.6236771613883 1.8 0.331615029022017,2.64626459013026 1.8 0.315204301442689,2.66765224254354 1.8 0.297257930190958,2.68773592013546 1.8 0.277863348183599,2.70641777724759 1.8 0.257115043874616,2.72360679774998 1.8 0.23511410091699,2.73921923846257 1.8 0.211967705693283,2.75317903714357 1.8 0.187788625114357,2.76541818305704 1.8 0.16269465723032,2.77587704831436 1.8 0.136808057330268,2.78450467837533 1.8 0.1102549423268,2.79125904029352 1.8 0.0831646763271043,2.79610722749663 1.8 0.0556692403840267,2.79902562010393 1.8 0.0279025894976503,2.8 1.8 3.6e-16,2.8 -0.0 1e-31)))')), \ + 'wrong geometry for cylinder' # 3DSOLID, plain feat = layer.GetNextFeature() @@ -2589,9 +2422,8 @@ def test_ogr_dxf_34(): expected_wkt = 'POLYGON ((0 0,0 1,1 0,0 0))' received_wkt = geom.ExportToWkt() - if expected_wkt != received_wkt: - gdaltest.post_reason('did not get expected geometry back: got %s' % received_wkt) - return 'fail' + assert expected_wkt == received_wkt, \ + ('did not get expected geometry back: got %s' % received_wkt) ds = None gdal.Unlink('tmp/triangle_test.dxf') @@ -2701,8 +2533,7 @@ def test_ogr_dxf_35(): "13.3027626235603 8.26630944469236 0," + \ "10.0 5.0 0," + \ "10.0 5.0 0))""" - if ogrtest.check_feature_geometry(feat, expected_wkt) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, expected_wkt) == 0 return 'success' @@ -2716,8 +2547,7 @@ def test_ogr_dxf_36(): ds = ogr.Open('data/insert_only.dxf') gdal.SetConfigOption('DXF_MERGE_BLOCK_GEOMETRIES', None) lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 5: - return 'fail' + assert lyr.GetFeatureCount() == 5 return 'success' @@ -2747,8 +2577,7 @@ def test_ogr_dxf_37(): # Check first feature feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None ds = None gdal.Unlink('/vsimem/ogr_dxf_37.dxf') @@ -2918,9 +2747,8 @@ def test_ogr_dxf_42(): # Inlining, merging ds = ogr.Open('data/block-insert-order.dxf') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('Defaults: Expected 2 features, found %d' % lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 2, \ + ('Defaults: Expected 2 features, found %d' % lyr.GetFeatureCount()) # No inlining, merging gdal.SetConfigOption('DXF_INLINE_BLOCKS', 'FALSE') @@ -2928,9 +2756,8 @@ def test_ogr_dxf_42(): gdal.SetConfigOption('DXF_INLINE_BLOCKS', None) lyr = ds.GetLayerByName('entities') - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('No inlining: Expected 2 features on entities, found %d' % lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 2, \ + ('No inlining: Expected 2 features on entities, found %d' % lyr.GetFeatureCount()) f = lyr.GetNextFeature() if ogrtest.check_feature_geometry(f, 'POINT Z (8.0 2.5 6)') != 0: @@ -2945,9 +2772,8 @@ def test_ogr_dxf_42(): return 'fail' lyr = ds.GetLayerByName('blocks') - if lyr.GetFeatureCount() != 6: - gdaltest.post_reason('No inlining: Expected 6 feature on blocks, found %d' % lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 6, \ + ('No inlining: Expected 6 feature on blocks, found %d' % lyr.GetFeatureCount()) f = lyr.GetFeature(3) if ogrtest.check_feature_geometry(f, 'POINT Z (5 5 0)') != 0: @@ -2961,24 +2787,13 @@ def test_ogr_dxf_42(): f.DumpReadable() return 'fail' - if f.GetField('BlockName') != 'BLOCK4': - gdaltest.post_reason('Wrong BlockName') - return 'fail' - if f.GetField('BlockScale') != [0.4, 1.0, 1.5]: - gdaltest.post_reason('Wrong BlockScale') - return 'fail' - if f.GetField('BlockAngle') != 40: - gdaltest.post_reason('Wrong BlockAngle') - return 'fail' - if f.GetField('BlockOCSNormal') != [0.6, 0.565685424949238, 0.565685424949238]: - gdaltest.post_reason('Wrong BlockOCSNormal') - return 'fail' - if f.GetField('BlockOCSCoords') != [5, 5, 0]: - gdaltest.post_reason('Wrong BlockOCSCoords') - return 'fail' - if f.GetField('Block') != 'BLOCK3': - gdaltest.post_reason('Wrong Block') - return 'fail' + assert f.GetField('BlockName') == 'BLOCK4', 'Wrong BlockName' + assert f.GetField('BlockScale') == [0.4, 1.0, 1.5], 'Wrong BlockScale' + assert f.GetField('BlockAngle') == 40, 'Wrong BlockAngle' + assert f.GetField('BlockOCSNormal') == [0.6, 0.565685424949238, 0.565685424949238], \ + 'Wrong BlockOCSNormal' + assert f.GetField('BlockOCSCoords') == [5, 5, 0], 'Wrong BlockOCSCoords' + assert f.GetField('Block') == 'BLOCK3', 'Wrong Block' # Inlining, no merging gdal.SetConfigOption('DXF_MERGE_BLOCK_GEOMETRIES', 'FALSE') @@ -2986,9 +2801,8 @@ def test_ogr_dxf_42(): gdal.SetConfigOption('DXF_MERGE_BLOCK_GEOMETRIES', None) lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 4: - gdaltest.post_reason('Merging: Expected 4 features, found %d' % lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 4, \ + ('Merging: Expected 4 features, found %d' % lyr.GetFeatureCount()) return 'success' @@ -3000,8 +2814,7 @@ def test_ogr_dxf_43(): ds = ogr.Open('data/insert-recursive-pair.dxf') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 return 'success' @@ -3016,8 +2829,7 @@ def test_ogr_dxf_44(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): lyr.GetFeatureCount() - if gdal.GetLastErrorMsg().find('DXF_MAX_BSPLINE_CONTROL_POINTS') < 0: - return 'fail' + assert gdal.GetLastErrorMsg().find('DXF_MAX_BSPLINE_CONTROL_POINTS') >= 0 ds = ogr.Open('data/leader-mleader.dxf') lyr = ds.GetLayer(0) @@ -3072,9 +2884,8 @@ def test_ogr_dxf_44(): # Check that the very long text string in the MTEXT entity associated # to this LEADER is captured correctly f = lyr.GetNextFeature() - if len(f.GetField('Text')) != 319: - gdaltest.post_reason('Wrong text length: got %d' % len(f.GetField('Text'))) - return 'fail' + assert len(f.GetField('Text')) == 319, \ + ('Wrong text length: got %d' % len(f.GetField('Text'))) # MULTILEADER with custom arrowhead f = lyr.GetNextFeature() @@ -3110,22 +2921,19 @@ def test_ogr_dxf_44(): for x in range(3): f = lyr.GetNextFeature() geom = f.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbLineString25D: - gdaltest.post_reason('Unexpected LEADER geometry, expected wkbLineString25D on iteration %d' % x) - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString25D, \ + ('Unexpected LEADER geometry, expected wkbLineString25D on iteration %d' % x) for x in range(2): f = lyr.GetNextFeature() geom = f.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbMultiLineString: - gdaltest.post_reason('Unexpected MULTILEADER geometry, expected wkbMultiLineString on iteration %d' % x) - return 'fail' + assert geom.GetGeometryType() == ogr.wkbMultiLineString, \ + ('Unexpected MULTILEADER geometry, expected wkbMultiLineString on iteration %d' % x) f = lyr.GetNextFeature() geom = f.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbPoint: - gdaltest.post_reason('Unexpected MULTILEADER geometry, expected wkbPoint on iteration %d' % x) - return 'fail' + assert geom.GetGeometryType() == ogr.wkbPoint, \ + ('Unexpected MULTILEADER geometry, expected wkbPoint on iteration %d' % x) # MULTILEADER with multiple leader lines and formatted text f = lyr.GetNextFeature() @@ -3243,44 +3051,28 @@ def test_ogr_dxf_45(): lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'DASHED2': - gdaltest.post_reason('Got wrong linetype (1)') - return 'fail' + assert feat.GetField('Linetype') == 'DASHED2', 'Got wrong linetype (1)' - if feat.GetStyleString() != 'PEN(c:#000000,p:"12.5g 6.25g")': - print(feat.GetStyleString()) - gdaltest.post_reason('Got wrong style string (1)') - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#000000,p:"12.5g 6.25g")', \ + 'Got wrong style string (1)' feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'DASHED2': - gdaltest.post_reason('Got wrong linetype (2)') - return 'fail' + assert feat.GetField('Linetype') == 'DASHED2', 'Got wrong linetype (2)' - if feat.GetStyleString() != 'PEN(c:#000000,p:"0.625g 0.3125g")': - print(feat.GetStyleString()) - gdaltest.post_reason('Got wrong style string (2)') - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#000000,p:"0.625g 0.3125g")', \ + 'Got wrong style string (2)' feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'DASHED2_FLIPPED': - gdaltest.post_reason('Got wrong linetype (3)') - return 'fail' + assert feat.GetField('Linetype') == 'DASHED2_FLIPPED', 'Got wrong linetype (3)' - if feat.GetStyleString() != 'PEN(c:#000000,p:"0.625g 0.3125g")': - print(feat.GetStyleString()) - gdaltest.post_reason('Got wrong style string (3)') - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#000000,p:"0.625g 0.3125g")', \ + 'Got wrong style string (3)' feat = lyr.GetNextFeature() - if feat.GetField('Linetype') != 'Drain_Pipe_Inv_100': - gdaltest.post_reason('Got wrong linetype (4)') - return 'fail' + assert feat.GetField('Linetype') == 'Drain_Pipe_Inv_100', 'Got wrong linetype (4)' - if feat.GetStyleString() != 'PEN(c:#000000,p:"35g 22.5g")': - print(feat.GetStyleString()) - gdaltest.post_reason('Got wrong style string (4)') - return 'fail' + assert feat.GetStyleString() == 'PEN(c:#000000,p:"35g 22.5g")', \ + 'Got wrong style string (4)' return 'success' @@ -3542,9 +3334,8 @@ def test_ogr_dxf_49(): # Inline blocks mode ds = ogr.Open('data/attrib.dxf') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 6: - gdaltest.post_reason('Wrong feature count, got %d' % lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 6, \ + ('Wrong feature count, got %d' % lyr.GetFeatureCount()) f = lyr.GetFeature(1) if f.GetField('Text') != 'super test': @@ -3558,9 +3349,7 @@ def test_ogr_dxf_49(): f = lyr.GetFeature(4) geom = f.GetGeometryRef() - if geom.GetGeometryType() != ogr.wkbLineString25D: - gdaltest.post_reason('Expected LINESTRING Z') - return 'fail' + assert geom.GetGeometryType() == ogr.wkbLineString25D, 'Expected LINESTRING Z' f = lyr.GetFeature(5) if f.GetField('Text') != '': @@ -3848,8 +3637,7 @@ def test_ogr_dxf_write_geometry_collection_of_unsupported_type(): f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(TIN EMPTY)')) with gdaltest.error_handler(): ret = lyr.CreateFeature(f) - if ret == 0: - return 'fail' + assert ret != 0 ds = None gdal.Unlink(tmpfile) diff --git a/autotest/ogr/ogr_edigeo.py b/autotest/ogr/ogr_edigeo.py index 5718f73f1df5..753b008a26ef 100755 --- a/autotest/ogr/ogr_edigeo.py +++ b/autotest/ogr/ogr_edigeo.py @@ -66,9 +66,7 @@ def test_ogr_edigeo_1(): return 'skip' ds = ogr.Open('tmp/cache/E000AB01.THF') - if ds.GetLayerCount() != 24: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 24 layers = [('BATIMENT_id', ogr.wkbPolygon, 107), ('BORNE_id', ogr.wkbPoint, 5), @@ -91,15 +89,10 @@ def test_ogr_edigeo_1(): for l in layers: lyr = ds.GetLayerByName(l[0]) - if lyr.GetLayerDefn().GetGeomType() != l[1]: - return 'fail' - if lyr.GetFeatureCount() != l[2]: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetLayerDefn().GetGeomType() == l[1] + assert lyr.GetFeatureCount() == l[2] if l[1] != ogr.wkbNone: - if lyr.GetSpatialRef().ExportToWkt().find('Lambert_Conformal_Conic_1SP') == -1: - print(lyr.GetSpatialRef().ExportToWkt()) - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('Lambert_Conformal_Conic_1SP') != -1 lyr = ds.GetLayerByName('BORNE_id') feat = lyr.GetNextFeature() diff --git a/autotest/ogr/ogr_eeda.py b/autotest/ogr/ogr_eeda.py index ef82017e317a..1bcd9f40db10 100644 --- a/autotest/ogr/ogr_eeda.py +++ b/autotest/ogr/ogr_eeda.py @@ -86,23 +86,15 @@ def test_eeda_2(): lyr = ds.GetLayer(0) - if lyr.TestCapability(ogr.OLCStringsAsUTF8) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCStringsAsUTF8) == 1 - if lyr.TestCapability('foo') != 0: - return 'fail' + assert lyr.TestCapability('foo') == 0 - if lyr.GetLayerDefn().GetFieldCount() != 8 + 7 + 4: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 8 + 7 + 4 - if lyr.GetExtent() != (-180.0, 180.0, -90.0, 90.0): - print(lyr.GetExtent()) - return 'fail' + assert lyr.GetExtent() == (-180.0, 180.0, -90.0, 90.0) - if lyr.GetFeatureCount() != -1: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == -1 gdal.FileFromMemBuffer('/vsimem/ee/projects/earthengine-public/assets/collection:listImages', json.dumps({ 'assets': [ @@ -197,8 +189,7 @@ def test_eeda_2(): return 'fail' f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None lyr.ResetReading() @@ -218,8 +209,7 @@ def test_eeda_2(): })) f = lyr.GetNextFeature() - if f.GetField('name') != 'projects/earthengine-public/assets/collection/raw_filter': - return 'fail' + assert f.GetField('name') == 'projects/earthengine-public/assets/collection/raw_filter' lyr.SetAttributeFilter(None) lyr.SetAttributeFilter("time >= '1980-01-01T00:00:00Z' AND " + @@ -262,8 +252,7 @@ def test_eeda_2(): f = lyr.GetNextFeature() gdal.Unlink(ogrtest.eeda_drv_tmpfile) - if f.GetField('name') != 'projects/earthengine-public/assets/collection/filtered_feature': - return 'fail' + assert f.GetField('name') == 'projects/earthengine-public/assets/collection/filtered_feature' lyr.SetSpatialFilter(None) @@ -286,8 +275,7 @@ def test_eeda_2(): f = lyr.GetNextFeature() gdal.Unlink(ogrtest.eeda_drv_tmpfile) - if f.GetField('name') != 'projects/earthengine-public/assets/collection/filtered_feature': - return 'fail' + assert f.GetField('name') == 'projects/earthengine-public/assets/collection/filtered_feature' # Test time equality with day granularity lyr.SetAttributeFilter("time = '1980-01-01'") @@ -308,8 +296,7 @@ def test_eeda_2(): f = lyr.GetNextFeature() gdal.Unlink(ogrtest.eeda_drv_tmpfile) - if f.GetField('name') != 'projects/earthengine-public/assets/collection/filtered_feature': - return 'fail' + assert f.GetField('name') == 'projects/earthengine-public/assets/collection/filtered_feature' ds = None @@ -333,9 +320,7 @@ def test_eeda_3(): lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 8 + 7 + 4: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 8 + 7 + 4 ds = None gdal.SetConfigOption('EEDA_BEARER', None) @@ -363,8 +348,7 @@ def test_eeda_4(): } ] })) - if not ogr.Open('EEDA:users/foo').GetLayer(0): - return 'fail' + assert ogr.Open('EEDA:users/foo').GetLayer(0) gdal.Unlink(ogrtest.eeda_drv_tmpfile) # Project asset ID ("projects/**"). @@ -377,8 +361,7 @@ def test_eeda_4(): ] })) ds = ogr.Open('EEDA:projects/foo') - if not ds.GetLayer(0): - return 'fail' + assert ds.GetLayer(0) gdal.Unlink(ogrtest.eeda_drv_tmpfile) ds = None @@ -392,8 +375,7 @@ def test_eeda_4(): ] })) ds = ogr.Open('EEDA:projects/foo/bar/baz') - if not ds.GetLayer(0): - return 'fail' + assert ds.GetLayer(0) gdal.Unlink(ogrtest.eeda_drv_tmpfile) ds = None @@ -407,8 +389,7 @@ def test_eeda_4(): ] })) ds = ogr.Open('EEDA:foo') - if not ds.GetLayer(0): - return 'fail' + assert ds.GetLayer(0) gdal.Unlink(ogrtest.eeda_drv_tmpfile) ds = None @@ -422,8 +403,7 @@ def test_eeda_4(): ] })) ds = ogr.Open('EEDA:projects/foo/assets/bar') - if not ds.GetLayer(0): - return 'fail' + assert ds.GetLayer(0) gdal.Unlink(ogrtest.eeda_drv_tmpfile) ds = None diff --git a/autotest/ogr/ogr_elasticsearch.py b/autotest/ogr/ogr_elasticsearch.py index 888a9168d6e6..4027d7d68920 100755 --- a/autotest/ogr/ogr_elasticsearch.py +++ b/autotest/ogr/ogr_elasticsearch.py @@ -67,54 +67,36 @@ def test_ogr_elasticsearch_nonexistent_server(): with gdaltest.error_handler(): ds = ogrtest.elasticsearch_drv.CreateDataSource( '/vsimem/nonexistent_host') - if ds is not None: - gdaltest.post_reason( - 'managed to open nonexistent ElasticSearch datastore.') - return 'fail' + assert ds is None, 'managed to open nonexistent ElasticSearch datastore.' with gdaltest.error_handler(): ds = ogrtest.elasticsearch_drv.Open('ES:/vsimem/nonexistent_host') - if ds is not None: - gdaltest.post_reason( - 'managed to open nonexistent ElasticSearch datastore.') - return 'fail' + assert ds is None, 'managed to open nonexistent ElasticSearch datastore.' gdal.FileFromMemBuffer("/vsimem/fakeelasticsearch", """{}""") with gdaltest.error_handler(): ds = ogrtest.elasticsearch_drv.Open('ES:/vsimem/fakeelasticsearch') - if ds is not None: - gdaltest.post_reason( - 'managed to open invalid ElasticSearch datastore.') - return 'fail' + assert ds is None, 'managed to open invalid ElasticSearch datastore.' gdal.FileFromMemBuffer("/vsimem/fakeelasticsearch", """{"version":null}""") with gdaltest.error_handler(): ds = ogrtest.elasticsearch_drv.Open('ES:/vsimem/fakeelasticsearch') - if ds is not None: - gdaltest.post_reason( - 'managed to open invalid ElasticSearch datastore.') - return 'fail' + assert ds is None, 'managed to open invalid ElasticSearch datastore.' gdal.FileFromMemBuffer("/vsimem/fakeelasticsearch", """{"version":{}}""") with gdaltest.error_handler(): ds = ogrtest.elasticsearch_drv.Open('ES:/vsimem/fakeelasticsearch') - if ds is not None: - gdaltest.post_reason( - 'managed to open invalid ElasticSearch datastore.') - return 'fail' + assert ds is None, 'managed to open invalid ElasticSearch datastore.' gdal.FileFromMemBuffer("/vsimem/fakeelasticsearch", """{"version":{"number":null}}""") with gdaltest.error_handler(): ds = ogrtest.elasticsearch_drv.Open('ES:/vsimem/fakeelasticsearch') - if ds is not None: - gdaltest.post_reason( - 'managed to open invalid ElasticSearch datastore.') - return 'fail' + assert ds is None, 'managed to open invalid ElasticSearch datastore.' return 'success' @@ -131,34 +113,25 @@ def test_ogr_elasticsearch_1(): ds = ogrtest.elasticsearch_drv.CreateDataSource( "/vsimem/fakeelasticsearch") - if ds is None: - gdaltest.post_reason('did not managed to open ElasticSearch datastore') - return 'fail' + assert ds is not None, 'did not managed to open ElasticSearch datastore' - if ds.TestCapability(ogr.ODsCCreateLayer) == 0: - return 'fail' - if ds.TestCapability(ogr.ODsCDeleteLayer) == 0: - return 'fail' - if ds.TestCapability(ogr.ODsCCreateGeomFieldAfterCreateLayer) == 0: - return 'fail' + assert ds.TestCapability(ogr.ODsCCreateLayer) != 0 + assert ds.TestCapability(ogr.ODsCDeleteLayer) != 0 + assert ds.TestCapability(ogr.ODsCCreateGeomFieldAfterCreateLayer) != 0 # Failed index creation with gdaltest.error_handler(): lyr = ds.CreateLayer('foo', srs=ogrtest.srs_wgs84, options=['FID=']) - if lyr is not None: - return 'fail' - if gdal.GetLastErrorType() != gdal.CE_Failure: - return 'fail' + assert lyr is None + assert gdal.GetLastErrorType() == gdal.CE_Failure gdal.ErrorReset() # Successful index creation gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo&CUSTOMREQUEST=PUT', '{}') lyr = ds.CreateLayer('foo', srs=ogrtest.srs_wgs84, options=['FID=']) - if lyr is None: - return 'fail' - if gdal.GetLastErrorType() != gdal.CE_None: - return 'fail' + assert lyr is not None + assert gdal.GetLastErrorType() == gdal.CE_None gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo/FeatureCollection/_mapping&POSTFIELDS' @@ -168,8 +141,7 @@ def test_ogr_elasticsearch_1(): # OVERWRITE an nonexistent layer. lyr = ds.CreateLayer('foo', geom_type=ogr.wkbNone, options=['OVERWRITE=TRUE', 'FID=']) - if gdal.GetLastErrorType() != gdal.CE_None: - return 'fail' + assert gdal.GetLastErrorType() == gdal.CE_None # Simulate failed overwrite gdal.FileFromMemBuffer('/vsimem/fakeelasticsearch/foo', @@ -177,8 +149,7 @@ def test_ogr_elasticsearch_1(): with gdaltest.error_handler(): lyr = ds.CreateLayer('foo', geom_type=ogr.wkbNone, options=['OVERWRITE=TRUE']) - if gdal.GetLastErrorType() != gdal.CE_Failure: - return 'fail' + assert gdal.GetLastErrorType() == gdal.CE_Failure gdal.ErrorReset() # Successful overwrite @@ -188,37 +159,28 @@ def test_ogr_elasticsearch_1(): '/vsimem/fakeelasticsearch/foo/FeatureCollection/&POSTFIELDS={ }', '{}') lyr = ds.CreateLayer('foo', geom_type=ogr.wkbNone, options=[ 'OVERWRITE=TRUE', 'BULK_INSERT=NO', 'FID=']) - if gdal.GetLastErrorType() != gdal.CE_None: - return 'fail' + assert gdal.GetLastErrorType() == gdal.CE_None - if lyr.TestCapability(ogr.OLCFastFeatureCount) == 0: - return 'fail' - if lyr.TestCapability(ogr.OLCStringsAsUTF8) == 0: - return 'fail' - if lyr.TestCapability(ogr.OLCSequentialWrite) == 0: - return 'fail' - if lyr.TestCapability(ogr.OLCCreateField) == 0: - return 'fail' - if lyr.TestCapability(ogr.OLCCreateGeomField) == 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastFeatureCount) != 0 + assert lyr.TestCapability(ogr.OLCStringsAsUTF8) != 0 + assert lyr.TestCapability(ogr.OLCSequentialWrite) != 0 + assert lyr.TestCapability(ogr.OLCCreateField) != 0 + assert lyr.TestCapability(ogr.OLCCreateGeomField) != 0 feat = ogr.Feature(lyr.GetLayerDefn()) gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo/FeatureCollection/&POSTFIELDS={ "properties": { } }', '{}') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None gdal.FileFromMemBuffer('/vsimem/fakeelasticsearch/foo&CUSTOMREQUEST=PUT', '{"error":"IndexAlreadyExistsException[[foo] already exists]","status":400}') with gdaltest.error_handler(): lyr = ds.CreateLayer('foo', srs=ogrtest.srs_wgs84) - if gdal.GetLastErrorType() != gdal.CE_Failure: - return 'fail' - if lyr is not None: - return 'fail' + assert gdal.GetLastErrorType() == gdal.CE_Failure + assert lyr is None gdal.FileFromMemBuffer( """/vsimem/fakeelasticsearch/foo/FeatureCollection/_mapping&POSTFIELDS={ "FeatureCollection": { "properties": { "type": { "type": "string" }, "properties": { "properties": { } }, "geometry": { "type": "geo_shape" } } } }""", "") @@ -229,8 +191,7 @@ def test_ogr_elasticsearch_1(): ds.DeleteLayer(-1) ds.DeleteLayer(10) ret = ds.DeleteLayer(0) - if ret != 0: - return 'fail' + assert ret == 0 gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo2&CUSTOMREQUEST=PUT', '{}') @@ -255,8 +216,7 @@ def test_ogr_elasticsearch_1(): lyr.CreateField(ogr.FieldDefn('binary_field', ogr.OFTBinary)) ret = lyr.SyncToDisk() - if ret != 0: - return 'fail' + assert ret == 0 feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetField('str_field', 'a') @@ -277,17 +237,14 @@ def test_ogr_elasticsearch_1(): # Simulate server error with gdaltest.error_handler(): ret = lyr.CreateFeature(feat) - if ret == 0: - return 'fail' + assert ret != 0 # Success gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo2/FeatureCollection/&POSTFIELDS={ "geometry": { "type": "POINT", "coordinates": [ 0.0, 1.0 ] }, "type": "Feature", "properties": { "str_field": "a", "int_field": 1, "int64_field": 123456789012, "real_field": 2.34, "boolean_field": true, "strlist_field": [ "a", "b" ], "intlist_field": [ 1, 2 ], "int64list_field": [ 123456789012, 2 ], "reallist_field": [ 1.23, 4.56 ], "date_field": "2015\/08\/12", "datetime_field": "2015\/08\/12 12:34:56.789", "time_field": "12:34:56.789", "binary_field": "ASNGV4mrze8=" } }', '{ "_id": "my_id" }') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' - if feat['_id'] != 'my_id': - return 'fail' + assert ret == 0 + assert feat['_id'] == 'my_id' # DateTime with TZ gdal.FileFromMemBuffer( @@ -295,8 +252,7 @@ def test_ogr_elasticsearch_1(): feat = ogr.Feature(lyr.GetLayerDefn()) feat['datetime_field'] = '2015/08/12 12:34:56.789+0300' ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 # CreateFeature() with _id set gdal.FileFromMemBuffer( @@ -304,28 +260,24 @@ def test_ogr_elasticsearch_1(): feat = ogr.Feature(lyr.GetLayerDefn()) feat['_id'] = 'my_id2' ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 # Failed SetFeature because of missing _id feat = ogr.Feature(lyr.GetLayerDefn()) with gdaltest.error_handler(): ret = lyr.SetFeature(feat) - if ret == 0: - return 'fail' + assert ret != 0 # Simulate server error feat['_id'] = 'my_id' with gdaltest.error_handler(): ret = lyr.SetFeature(feat) - if ret == 0: - return 'fail' + assert ret != 0 gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo2/FeatureCollection/my_id&POSTFIELDS={ "properties": { } }', '{}') ret = lyr.SetFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 # With explicit GEOM_MAPPING_TYPE=GEO_POINT gdal.FileFromMemBuffer( @@ -340,8 +292,7 @@ def test_ogr_elasticsearch_1(): feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None # Test explicit MAPPING first with error case @@ -350,16 +301,14 @@ def test_ogr_elasticsearch_1(): with gdaltest.error_handler(): lyr = ds.CreateLayer('foo4', srs=ogrtest.srs_wgs84, options=[ 'MAPPING={ "FeatureCollection": { "properties": {} }}']) - if lyr is not None: - return 'fail' + assert lyr is None # Test successful explicit MAPPING with inline JSon mapping gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo4/FeatureCollection/_mapping&POSTFIELDS={ "FeatureCollection": { "properties": {} }}', '{}') lyr = ds.CreateLayer('foo4', srs=ogrtest.srs_wgs84, options=[ 'MAPPING={ "FeatureCollection": { "properties": {} }}']) - if lyr is None: - return 'fail' + assert lyr is not None # Test successful explicit MAPPING with reference to file with mapping gdal.FileFromMemBuffer( @@ -369,8 +318,7 @@ def test_ogr_elasticsearch_1(): lyr = ds.CreateLayer('foo4', srs=ogrtest.srs_wgs84, options=['MAPPING=/vsimem/map.txt']) gdal.Unlink('/vsimem/map.txt') - if lyr is None: - return 'fail' + assert lyr is not None # Test successful explicit INDEX_DEFINITION with inline JSon mapping gdal.FileFromMemBuffer( @@ -379,8 +327,7 @@ def test_ogr_elasticsearch_1(): '/vsimem/fakeelasticsearch/foo4/FeatureCollection/_mapping&POSTFIELDS={}', '{}') lyr = ds.CreateLayer('foo4', srs=ogrtest.srs_wgs84, options=[ 'INDEX_DEFINITION={}', 'MAPPING={}']) - if lyr is None: - return 'fail' + assert lyr is not None # Test successful explicit INDEX_DEFINITION with reference to file gdal.FileFromMemBuffer('/vsimem/map.txt', '{"foo":"bar"}') @@ -389,8 +336,7 @@ def test_ogr_elasticsearch_1(): lyr = ds.CreateLayer('foo4', srs=ogrtest.srs_wgs84, options=['INDEX_DEFINITION=/vsimem/map.txt', 'MAPPING={}']) gdal.Unlink('/vsimem/map.txt') - if lyr is None: - return 'fail' + assert lyr is not None return 'success' @@ -404,9 +350,7 @@ def test_ogr_elasticsearch_2(): ds = ogrtest.elasticsearch_drv.CreateDataSource( "/vsimem/fakeelasticsearch") - if ds is None: - gdaltest.post_reason('did not managed to open ElasticSearch datastore') - return 'fail' + assert ds is not None, 'did not managed to open ElasticSearch datastore' gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/foo&CUSTOMREQUEST=PUT', '{}') @@ -422,8 +366,7 @@ def test_ogr_elasticsearch_2(): gdal.FileFromMemBuffer('/vsimem/fakeelasticsearch/foo/FeatureCollection/&POSTFIELDS={ "geometry": { "type": "geometrycollection", "geometries": [ { "type": "point", "coordinates": [ 0.0, 1.0 ] }, { "type": "linestring", "coordinates": [ [ 0.0, 1.0 ], [ 2.0, 3.0 ] ] }, { "type": "polygon", "coordinates": [ [ [ 0.0, 0.0 ], [ 0.0, 10.0 ], [ 10.0, 10.0 ], [ 0.0, 0.0 ] ], [ [ 1.0, 1.0 ], [ 1.0, 9.0 ], [ 9.0, 9.0 ], [ 1.0, 1.0 ] ] ] }, { "type": "multipoint", "coordinates": [ [ 0.0, 1.0 ], [ 2.0, 3.0 ] ] }, { "type": "multilinestring", "coordinates": [ [ [ 0.0, 1.0 ], [ 2.0, 3.0 ] ], [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ] ] }, { "type": "multipolygon", "coordinates": [ [ [ [ 0.0, 0.0 ], [ 0.0, 10.0 ], [ 10.0, 10.0 ], [ 0.0, 0.0 ] ], [ [ 1.0, 1.0 ], [ 1.0, 9.0 ], [ 9.0, 9.0 ], [ 1.0, 1.0 ] ] ], [ [ [ -1.0, -1.0 ], [ -1.0, -9.0 ], [ -9.0, -9.0 ], [ -1.0, -1.0 ] ] ] ] } ] }, "type": "Feature", "properties": { } }', '{}') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None # Same but with explicit GEOM_MAPPING_TYPE=GEO_SHAPE @@ -437,8 +380,7 @@ def test_ogr_elasticsearch_2(): '/vsimem/fakeelasticsearch/foo/FeatureCollection/_mapping&POSTFIELDS={ "FeatureCollection": { "properties": { "type": { "type": "string" }, "properties": { "properties": { } }, "geometry": { "type": "geo_shape", "precision": "1m" } } } }', '{}') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None return 'success' @@ -453,9 +395,7 @@ def test_ogr_elasticsearch_3(): ds = ogrtest.elasticsearch_drv.CreateDataSource( "/vsimem/fakeelasticsearch") - if ds is None: - gdaltest.post_reason('did not managed to open ElasticSearch datastore') - return 'fail' + assert ds is not None, 'did not managed to open ElasticSearch datastore' gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/name_laundering&CUSTOMREQUEST=PUT', '{}') @@ -466,19 +406,16 @@ def test_ogr_elasticsearch_3(): 'NAME/laundering', srs=ogrtest.srs_wgs84, options=['FID=']) feat = ogr.Feature(lyr.GetLayerDefn()) ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None with gdaltest.error_handler(): ret = lyr.SyncToDisk() - if ret == 0: - return 'fail' + assert ret != 0 feat = ogr.Feature(lyr.GetLayerDefn()) ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/_bulk&POSTFIELDS={"index" :{"_index":"name_laundering", "_type":"FeatureCollection"}} @@ -486,8 +423,7 @@ def test_ogr_elasticsearch_3(): """, '{}') ret = lyr.SyncToDisk() - if ret != 0: - return 'fail' + assert ret == 0 ds = None @@ -503,18 +439,14 @@ def test_ogr_elasticsearch_4(): with gdaltest.error_handler(): ds = ogr.Open('ES:/vsimem/fakeelasticsearch') - if ds is None: - return 'fail' + assert ds is not None # Test case where there's no index gdal.FileFromMemBuffer( """/vsimem/fakeelasticsearch/_cat/indices?h=i""", '\n') ds = ogr.Open('ES:/vsimem/fakeelasticsearch') - if ds is None: - return 'fail' - if ds.GetLayerCount() != 0: - print(ds.GetLayerCount()) - return 'fail' + assert ds is not None + assert ds.GetLayerCount() == 0 # Test opening a layer by name gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/_mapping?pretty""", """ @@ -583,42 +515,33 @@ def test_ogr_elasticsearch_4(): """) ds = ogr.Open('ES:/vsimem/fakeelasticsearch') - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('a_layer') - if lyr is None: - return 'fail' + assert lyr is not None lyr = ds.GetLayerByName('a_layer') - if lyr is None: - return 'fail' + assert lyr is not None with gdaltest.error_handler(): lyr = ds.GetLayerByName('not_a_layer') - if lyr is not None: - return 'fail' + assert lyr is None ds = None # Test LAYER open option ds = gdal.OpenEx('ES:/vsimem/fakeelasticsearch', open_options=['LAYER=a_layer']) - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1 ds = None with gdaltest.error_handler(): ds = gdal.OpenEx('ES:/vsimem/fakeelasticsearch', open_options=['LAYER=not_a_layer']) - if ds is not None: - return 'fail' + assert ds is None ds = None # Test GetLayerByName() and GetLayerCount() ds = ogr.Open('ES:/vsimem/fakeelasticsearch') lyr = ds.GetLayerByName('a_layer') lyr = ds.GetLayerByName('a_layer') - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1 ds = None # Test GetLayerCount() @@ -626,23 +549,17 @@ def test_ogr_elasticsearch_4(): """/vsimem/fakeelasticsearch/_cat/indices?h=i""", 'a_layer \n') ds = ogr.Open('ES:/vsimem/fakeelasticsearch') - if ds is None: - return 'fail' - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds is not None + assert ds.GetLayerCount() == 1 lyr = ds.GetLayer(0) with gdaltest.error_handler(): lyr_defn = lyr.GetLayerDefn() idx = lyr_defn.GetFieldIndex("strlist_field") - if lyr_defn.GetFieldDefn(idx).GetType() != ogr.OFTStringList: - return 'fail' + assert lyr_defn.GetFieldDefn(idx).GetType() == ogr.OFTStringList idx = lyr_defn.GetGeomFieldIndex("a_geoshape") - if lyr_defn.GetGeomFieldDefn(idx).GetType() != ogr.wkbLineString: - return 'fail' - if lyr.GetFIDColumn() != 'my_fid': - return 'fail' + assert lyr_defn.GetGeomFieldDefn(idx).GetType() == ogr.wkbLineString + assert lyr.GetFIDColumn() == 'my_fid' gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_count?pretty""", """{ }""") @@ -668,21 +585,18 @@ def test_ogr_elasticsearch_4(): } }""") fc = lyr.GetFeatureCount() - if fc != 3: - return 'fail' + assert fc == 3 with gdaltest.error_handler(): f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100""", """{ }""") lyr.ResetReading() f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100""", """{ "hits": null @@ -748,9 +662,7 @@ def test_ogr_elasticsearch_4(): ds = ogr.Open('ES:/vsimem/fakeelasticsearch') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 15: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 15 gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100""", """{ "_scroll_id": "my_scrollid", @@ -802,8 +714,7 @@ def test_ogr_elasticsearch_4(): lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None if f.GetFID() != 5 or f['_id'] != 'my_id' or f['str_field'] != 'foo' or f['int_field'] != 1 or f['int64_field'] != 123456789012 or \ f['double_field'] != 1.23 or f['float_field'] != 3.45 or f['boolean_field'] != 1 or \ f['binary_field'] != '0123465789ABCDEF' or f['dt_field'] != '2015/08/12 12:34:56.789' or \ @@ -820,8 +731,7 @@ def test_ogr_elasticsearch_4(): lyr.ResetReading() lyr.GetNextFeature() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/_search/scroll?scroll=1m&scroll_id=my_scrollid""", """{ "hits": @@ -839,8 +749,7 @@ def test_ogr_elasticsearch_4(): } }""") f = lyr.GetNextFeature() - if f['int_field'] != 2: - return 'fail' + assert f['int_field'] == 2 gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/_search/scroll?scroll=1m&scroll_id=my_scrollid""", """{ "hits": @@ -849,11 +758,9 @@ def test_ogr_elasticsearch_4(): } }""") f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None lyr.SetSpatialFilterRect(1, 48, 3, 50) lyr.ResetReading() @@ -877,8 +784,7 @@ def test_ogr_elasticsearch_4(): } }""") f = lyr.GetNextFeature() - if f['int_field'] != 3: - return 'fail' + assert f['int_field'] == 3 lyr.SetSpatialFilterRect(1, 1, 48, 3, 50) lyr.ResetReading() @@ -902,8 +808,7 @@ def test_ogr_elasticsearch_4(): } }""") f = lyr.GetNextFeature() - if f['int_field'] != 4: - return 'fail' + assert f['int_field'] == 4 gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?pretty&POSTFIELDS={ "size": 0, "query": { "constant_score" : { "filter": { "geo_bounding_box": { "a_geopoint.coordinates": { "top_left": { "lat": 50.0, "lon": 1.0 }, "bottom_right": { "lat": 48.0, "lon": 3.0 } } } } } } }""", """{ "hits": @@ -912,8 +817,7 @@ def test_ogr_elasticsearch_4(): } }""") fc = lyr.GetFeatureCount() - if fc != 10: - return 'fail' + assert fc == 10 lyr.SetSpatialFilter(None) lyr.SetSpatialFilterRect(-180, -90, 180, 90) @@ -943,8 +847,7 @@ def test_ogr_elasticsearch_4(): } }""") f = lyr.GetNextFeature() - if f['int_field'] != 5: - return 'fail' + assert f['int_field'] == 5 lyr.SetAttributeFilter(None) sql_lyr = ds.ExecuteSQL("{ 'FOO' : 'BAR' }", dialect='ES') @@ -1039,41 +942,33 @@ def test_ogr_elasticsearch_4(): } }""") bbox = lyr.GetExtent(geom_field=1) - if bbox != (1.0, 2.0, 9.0, 10.0): - print(bbox) - return 'fail' + assert bbox == (1.0, 2.0, 9.0, 10.0) # Operations not available in read-only mode with gdaltest.error_handler(): ret = lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.CreateGeomField(ogr.GeomFieldDefn('shape', ogr.wkbPoint)) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.CreateFeature(ogr.Feature(lyr.GetLayerDefn())) - if ret == 0: - return 'fail' + assert ret != 0 lyr.ResetReading() with gdaltest.error_handler(): ret = lyr.SetFeature(lyr.GetNextFeature()) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): lyr = ds.CreateLayer('will_not_work') - if lyr is not None: - return 'fail' + assert lyr is None with gdaltest.error_handler(): ret = ds.DeleteLayer(0) - if ret == 0: - return 'fail' + assert ret != 0 return 'success' @@ -1105,8 +1000,7 @@ def test_ogr_elasticsearch_5(): gdal.FileFromMemBuffer( '/vsimem/fakeelasticsearch/non_geojson/my_mapping/&POSTFIELDS={ "ogc_fid": 5, "str": "foo" }', '{}') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = None ds = None @@ -1215,8 +1109,7 @@ def test_ogr_elasticsearch_5(): } }""") index = lyr.GetLayerDefn().GetFieldIndex('another_field') - if index < 0: - return 'fail' + assert index >= 0 f = lyr.GetNextFeature() if f['str_field'] != 'foo' or \ f['superobject.subfield'] != '5' or \ @@ -1234,8 +1127,7 @@ def test_ogr_elasticsearch_5(): gdal.FileFromMemBuffer( """/vsimem/fakeelasticsearch/non_geojson/my_mapping/my_id&POSTFIELDS={ "a_geoshape": { "type": "linestring", "coordinates": [ [ 2.0, 49.0 ], [ 3.0, 50.0 ] ] }, "a_geopoint": { "type": "POINT", "coordinates": [ 2.0, 49.0 ] }, "another_geopoint": [ 2.5, 49.5 ], "superobject": { "another_geoshape": { "type": "point", "coordinates": [ 3.0, 50.0 ] }, "another_geoshape2": { "type": "point", "coordinates": [ 2.0, 50.0 ] }, "subfield": "5", "subobject": { "subfield": "foo", "another_subfield": 6 } }, "str_field": "foo" }""", "{}") ret = lyr.SetFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f = lyr.GetNextFeature() if f['another_geopoint'].ExportToWkt() != 'POINT (2.1 49.1)': @@ -1285,8 +1177,7 @@ def test_ogr_elasticsearch_5(): 'FEATURE_COUNT_TO_ESTABLISH_FEATURE_DEFN=0', 'FLATTEN_NESTED_ATTRIBUTES=FALSE']) lyr = ds.GetLayer(0) index = lyr.GetLayerDefn().GetFieldIndex('another_field') - if index >= 0: - return 'fail' + assert index < 0 f = lyr.GetNextFeature() if f['str_field'] != 'foo' or \ f['superobject'] != '{ "subfield": 5, "subobject": { "subfield": "foo", "another_subfield": 6 }, "another_geoshape": { "type": "point", "coordinates": [ 3, 50 ] }, "another_geoshape2": { "type": "point", "coordinates": [ 2, 50 ] } }' or \ @@ -1313,8 +1204,7 @@ def test_ogr_elasticsearch_5(): gdal.FileFromMemBuffer( """/vsimem/fakeelasticsearch/non_geojson/my_mapping/my_id&POSTFIELDS={ "foo": "bar" }""", "{}") ret = lyr.SetFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 return 'success' @@ -1438,16 +1328,13 @@ def test_ogr_elasticsearch_7(): ds = None f = gdal.VSIFOpenL('/vsimem/map.txt', 'rb') - if f is None: - return 'fail' + assert f is not None data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/map.txt') - if data != '{ "FeatureCollection": { "properties": { "type": { "type": "string" }, "properties": { "properties": { } }, "geometry": { "type": "geo_shape" } } } }': - print(data) - return 'fail' + assert data == '{ "FeatureCollection": { "properties": { "type": { "type": "string" }, "properties": { "properties": { } }, "geometry": { "type": "geo_shape" } } } }' return 'success' @@ -1472,9 +1359,7 @@ def test_ogr_elasticsearch_8(): gdal.ErrorReset() with gdaltest.error_handler(): lyr = ds.CreateLayer('no_srs') - if gdal.GetLastErrorType() != gdal.CE_Warning: - gdaltest.post_reason('warning expected') - return 'fail' + assert gdal.GetLastErrorType() == gdal.CE_Warning, 'warning expected' f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT (-100 -200)')) gdal.FileFromMemBuffer( @@ -1487,11 +1372,8 @@ def test_ogr_elasticsearch_8(): gdal.ErrorReset() with gdaltest.error_handler(): ret = lyr.CreateFeature(f) - if gdal.GetLastErrorType() != gdal.CE_Warning: - gdaltest.post_reason('warning expected') - return 'fail' - if ret != 0: - return 'fail' + assert gdal.GetLastErrorType() == gdal.CE_Warning, 'warning expected' + assert ret == 0 # Non EPSG-4326 SRS other_srs = osr.SpatialReference() @@ -1508,8 +1390,7 @@ def test_ogr_elasticsearch_8(): """, "{}") ret = lyr.CreateFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 return 'success' @@ -1593,8 +1474,7 @@ def test_ogr_elasticsearch_9(): }""") count = lyr.GetFeatureCount() - if count != 2: - return 'fail' + assert count == 2 gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "geo_shape": { "a_geoshape": { "shape": { "type": "envelope", "coordinates": [ [ 2.0, 50.0 ], [ 3.0, 49.0 ] ] } } } } } } }""", """{ @@ -1618,8 +1498,7 @@ def test_ogr_elasticsearch_9(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None return 'success' @@ -1703,8 +1582,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("text_field = 'foo'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "match": { "properties.text_field": "foo" } } } } }""", @@ -1725,8 +1603,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("text_field_with_raw = 'foo'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "term": { "properties.text_field_with_raw.raw": "foo" } } } } }""", @@ -1747,8 +1624,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("\"_id\" = 'my_id2'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "ids": { "values": [ "my_id2" ] } } } } }""", @@ -1768,8 +1644,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field != 'foo'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "bool": { "must_not": { "term": { "properties.keyword_field": "foo" } } } } } } }""", @@ -1790,8 +1665,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field IS NULL") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "bool": { "must_not": { "exists": { "field": "properties.keyword_field" } } } } } } }""", @@ -1811,8 +1685,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field BETWEEN 'bar' AND 'foo'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "range": { "properties.keyword_field": { "gte": "bar", "lte": "foo" } } } } } }""", @@ -1833,8 +1706,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field IN ('foo', 'bar')") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "terms": { "properties.keyword_field": [ "foo", "bar" ] } } } } }""", @@ -1855,8 +1727,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("text_field IN ('foo', 'bar')") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "bool": { "should": [ { "match": { "properties.text_field": "foo" } }, { "match": { "properties.text_field": "bar" } } ] } } } } }""", @@ -1877,8 +1748,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("text_field_with_raw IN ('foo', 'bar')") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "terms": { "properties.text_field_with_raw.raw": [ "foo", "bar" ] } } } } }""", @@ -1899,8 +1769,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("\"_id\" IN ('my_id', 'bar')") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "ids": { "values": [ "my_id", "bar" ] } } } } }""", @@ -1921,8 +1790,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter( "int_field >= 2 OR long_field >= 9876543210 OR double_field <= 3.123456") @@ -1946,8 +1814,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("dt_field > '2016/01/01 12:34:56.123'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "range": { "properties.dt_field": { "gt": "2016\/01\/01 12:34:56.123" } } } } } }""", @@ -1968,8 +1835,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("NOT dt_field < '2016/01/01 12:34:56.123'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "bool": { "must_not": { "range": { "properties.dt_field": { "lt": "2016\/01\/01 12:34:56.123" } } } } } } } }""", @@ -1990,8 +1856,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field LIKE '_o%'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "wildcard": { "properties.keyword_field": "?o*" } } } } }""", @@ -2012,8 +1877,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None # Evaluated client-side since the pattern uses ? or * lyr.SetAttributeFilter("text_field LIKE '?*'") @@ -2035,8 +1899,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None # Evaluated client-side since the field is analyzed lyr.SetAttributeFilter("text_field LIKE '_Z%'") @@ -2058,8 +1921,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("text_field_with_raw LIKE '_xo%' ESCAPE 'x'") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "wildcard": { "properties.text_field_with_raw.raw": "?o*" } } } } }""", @@ -2080,8 +1942,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field = 'foo' AND 1 = 1") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100&POSTFIELDS={ "query": { "constant_score" : { "filter": { "term": { "properties.keyword_field": "foo" } } } } }""", @@ -2102,13 +1963,11 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("1 = 1 AND keyword_field = 'foo'") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field = 'bar' OR 1 = 0") gdal.FileFromMemBuffer("""/vsimem/fakeelasticsearch/a_layer/FeatureCollection/_search?scroll=1m&size=100""", @@ -2129,8 +1988,7 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None lyr.SetAttributeFilter("keyword_field = 'foo2'") lyr.SetSpatialFilterRect(2, 49, 2, 49) @@ -2156,15 +2014,13 @@ def test_ogr_elasticsearch_10(): } }""") f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None # SQL with WHERE sql_lyr = ds.ExecuteSQL( "SELECT * FROM a_layer WHERE keyword_field = 'foo'") f = sql_lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None ds.ReleaseResultSet(sql_lyr) # SQL with WHERE and ORDER BY @@ -2188,8 +2044,7 @@ def test_ogr_elasticsearch_10(): } }""") f = sql_lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None ds.ReleaseResultSet(sql_lyr) # SQL with ORDER BY only @@ -2212,8 +2067,7 @@ def test_ogr_elasticsearch_10(): } }""") f = sql_lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None ds.ReleaseResultSet(sql_lyr) # SQL with ORDER BY on a text field with a raw sub-field @@ -2236,8 +2090,7 @@ def test_ogr_elasticsearch_10(): } }""") f = sql_lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None ds.ReleaseResultSet(sql_lyr) return 'success' @@ -2362,17 +2215,14 @@ def test_ogr_elasticsearch_11(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetFieldNull('str_field') ret = lyr.CreateFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f = None f = ogr.Feature(lyr.GetLayerDefn()) ret = lyr.CreateFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f = None - if lyr.SyncToDisk() != 0: - return 'fail' + assert lyr.SyncToDisk() == 0 return 'success' @@ -2418,8 +2268,7 @@ def test_ogr_elasticsearch_authentication(): ds = gdal.OpenEx('ES:/vsimem/fakeelasticsearch', open_options=['USERPWD=user:pwd']) - if ds is None: - return 'fail' + assert ds is not None return 'success' diff --git a/autotest/ogr/ogr_factory.py b/autotest/ogr/ogr_factory.py index 7ccdd3ed4d61..7f6252738c68 100755 --- a/autotest/ogr/ogr_factory.py +++ b/autotest/ogr/ogr_factory.py @@ -37,6 +37,7 @@ import gdaltest from osgeo import gdal from osgeo import ogr +import pytest def save_as_csv(geom, filename): @@ -53,8 +54,7 @@ def test_ogr_factory_1(): expected_geom = 'LINESTRING (21.75 33.031088913245533 40,22.374083449152831 32.648634669593925 40,22.972155943227843 32.237161430239802 40,23.537664874825239 31.801177382099848 40,24.064414409750082 31.345459257641004 40,24.546633369868303 30.875 40,24.979038463342047 30.394954059253475 40,25.356892169480634 29.910580919184319 40,25.676054644008637 29.427187473276717 40,25.933029076066084 28.95006988128063 40,26.125 28.484455543377237 40,26.249864142195264 28.035445827688662 40,26.306253464980482 27.607960178621322 40,26.293550155134998 27.206682218403525 40,26.211893392779814 26.836008432340218 40,26.062177826491073 26.5 40)' - if ogrtest.check_feature_geometry(geom, expected_geom): - return 'fail' + assert not ogrtest.check_feature_geometry(geom, expected_geom) return 'success' ############################################################################### @@ -69,9 +69,7 @@ def test_ogr_factory_2(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTISURFACE (((0 0,100 0,100 100,0 0)))' exp_wkt = 'POLYGON((0 0,100 0,100 100,0 0))' @@ -79,9 +77,7 @@ def test_ogr_factory_2(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'CURVEPOLYGON ((0 0,100 0,100 100,0 0))' exp_wkt = 'POLYGON((0 0,100 0,100 100,0 0))' @@ -89,9 +85,7 @@ def test_ogr_factory_2(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'CURVEPOLYGON (CIRCULARSTRING(0 0,0 1,0 2,1 2,2 2,2 1,2 0,1 0,0 0))' exp_wkt = 'POLYGON ((0 0,0 1,0 2,1 2,2 2,2 1,2 0,1 0,0 0))' @@ -99,9 +93,7 @@ def test_ogr_factory_2(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() return 'success' @@ -117,9 +109,7 @@ def test_ogr_factory_3(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'GEOMETRYCOLLECTION(POLYGON((0 0,100 0,100 100,0 0)))' exp_wkt = 'MULTIPOLYGON (((0 0,100 0,100 100,0 0)))' @@ -127,9 +117,7 @@ def test_ogr_factory_3(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'CURVEPOLYGON ((0 0,100 0,100 100,0 0))' exp_wkt = 'MULTIPOLYGON (((0 0,100 0,100 100,0 0)))' @@ -137,9 +125,7 @@ def test_ogr_factory_3(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTISURFACE (((0 0,100 0,100 100,0 0)))' exp_wkt = 'MULTIPOLYGON (((0 0,100 0,100 100,0 0)))' @@ -147,9 +133,7 @@ def test_ogr_factory_3(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiPolygon(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() return 'success' @@ -165,9 +149,7 @@ def test_ogr_factory_4(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiPoint(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'GEOMETRYCOLLECTION(POINT(2 5 3),POINT(4 5 5))' exp_wkt = 'MULTIPOINT(2 5 3,4 5 5)' @@ -175,9 +157,7 @@ def test_ogr_factory_4(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiPoint(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() return 'success' @@ -193,9 +173,7 @@ def test_ogr_factory_5(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'GEOMETRYCOLLECTION(LINESTRING(2 5,10 20),LINESTRING(0 0,10 10))' exp_wkt = 'MULTILINESTRING((2 5,10 20),(0 0,10 10))' @@ -203,9 +181,7 @@ def test_ogr_factory_5(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'POLYGON((2 5,10 20),(0 0,10 10))' exp_wkt = 'MULTILINESTRING((2 5,10 20),(0 0,10 10))' @@ -213,9 +189,7 @@ def test_ogr_factory_5(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTIPOLYGON(((2 5,10 20),(0 0,10 10)),((2 5,10 20)))' exp_wkt = 'MULTILINESTRING((2 5,10 20),(0 0,10 10),(2 5,10 20))' @@ -223,9 +197,7 @@ def test_ogr_factory_5(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToMultiLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() return 'success' @@ -307,9 +279,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTILINESTRING((2 5,10 20))' exp_wkt = 'LINESTRING(2 5,10 20)' @@ -317,9 +287,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTICURVE((2 5,10 20))' exp_wkt = 'LINESTRING(2 5,10 20)' @@ -327,9 +295,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTICURVE(COMPOUNDCURVE((2 5,10 20)))' exp_wkt = 'LINESTRING(2 5,10 20)' @@ -337,9 +303,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTILINESTRING((2 5,10 20),(3 4,30 40))' exp_wkt = 'MULTILINESTRING((2 5,10 20),(3 4,30 40))' @@ -347,9 +311,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTILINESTRING((2 5,10 20),(10 20,30 40))' exp_wkt = 'LINESTRING (2 5,10 20,30 40)' @@ -357,9 +319,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'GEOMETRYCOLLECTION(LINESTRING(2 5,10 20),LINESTRING(10 20,30 40))' exp_wkt = 'LINESTRING (2 5,10 20,30 40)' @@ -367,9 +327,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTILINESTRING((2 5,10 20),(10 20))' exp_wkt = 'MULTILINESTRING((2 5,10 20),(10 20))' @@ -377,9 +335,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'MULTILINESTRING((2 5,10 20),(10 20,30 40),(30 40,50 60))' exp_wkt = 'LINESTRING (2 5,10 20,30 40,50 60)' @@ -387,9 +343,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'POLYGON ((0 0,0 1,1 1,1 0,0 0))' exp_wkt = 'LINESTRING (0 0,0 1,1 1,1 0,0 0)' @@ -397,9 +351,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'CURVEPOLYGON ((0 0,0 1,1 1,1 0,0 0))' exp_wkt = 'LINESTRING (0 0,0 1,1 1,1 0,0 0)' @@ -407,9 +359,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() src_wkt = 'CURVEPOLYGON (COMPOUNDCURVE((0 0,0 1,1 1,1 0,0 0)))' exp_wkt = 'LINESTRING (0 0,0 1,1 1,1 0,0 0)' @@ -417,9 +367,7 @@ def test_ogr_factory_7(): src_geom = ogr.CreateGeometryFromWkt(src_wkt) dst_geom = ogr.ForceToLineString(src_geom) - if ogrtest.check_feature_geometry(dst_geom, exp_wkt): - print(dst_geom.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(dst_geom, exp_wkt), dst_geom.ExportToWkt() return 'success' @@ -592,8 +540,7 @@ def test_ogr_factory_8(): if ogrtest.check_feature_geometry(dst_geom, exp_wkt): print(src_wkt) print(target_type) - print(dst_geom.ExportToWkt()) - return 'fail' + pytest.fail(dst_geom.ExportToWkt()) return 'success' diff --git a/autotest/ogr/ogr_feature.py b/autotest/ogr/ogr_feature.py index bff89a400941..fe00eeeb3211 100755 --- a/autotest/ogr/ogr_feature.py +++ b/autotest/ogr/ogr_feature.py @@ -147,49 +147,35 @@ def test_ogr_feature_cp_integer(): dst_feature.SetFrom(src_feature) gdal.PopErrorHandler() - if not check(dst_feature, 'field_integer', 17): - return 'fail' + assert check(dst_feature, 'field_integer', 17) - if not check(dst_feature, 'field_integer64', 2147483647): - return 'fail' + assert check(dst_feature, 'field_integer64', 2147483647) - if not check(dst_feature, 'field_real', 18): - return 'fail' + assert check(dst_feature, 'field_real', 18) - if not check(dst_feature, 'field_string', 0): - return 'fail' + assert check(dst_feature, 'field_string', 0) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', 15): - return 'fail' + assert check(dst_feature, 'field_integerlist', 15) - if not check(dst_feature, 'field_integer64list', 2147483647): - return 'fail' + assert check(dst_feature, 'field_integer64list', 2147483647) - if not check(dst_feature, 'field_reallist', 17): - return 'fail' + assert check(dst_feature, 'field_reallist', 17) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) vals = [] for val in dst_feature: vals.append(val) - if vals != [17, 2147483647, 18, 0, None, None, None, None, 15, - 2147483647, 17, None]: - print(vals) - return 'fail' + assert (vals == [17, 2147483647, 18, 0, None, None, None, None, 15, + 2147483647, 17, None]) return 'success' @@ -205,47 +191,34 @@ def test_ogr_feature_cp_integer64(): dst_feature = mk_dst_feature(src_feature, ogr.OFTInteger64) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', 17): - return 'fail' + assert check(dst_feature, 'field_integer', 17) - if not check(dst_feature, 'field_integer64', 9876543210): - return 'fail' + assert check(dst_feature, 'field_integer64', 9876543210) gdal.PushErrorHandler() int32_ovflw = dst_feature.GetFieldAsInteger('field_integer64') gdal.PopErrorHandler() - if int32_ovflw != 2147483647: - return 'fail' + assert int32_ovflw == 2147483647 - if not check(dst_feature, 'field_real', 18): - return 'fail' + assert check(dst_feature, 'field_real', 18) - if not check(dst_feature, 'field_string', 0): - return 'fail' + assert check(dst_feature, 'field_string', 0) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', 15): - return 'fail' + assert check(dst_feature, 'field_integerlist', 15) - if not check(dst_feature, 'field_integer64list', 9876543210): - return 'fail' + assert check(dst_feature, 'field_integer64list', 9876543210) - if not check(dst_feature, 'field_reallist', 17): - return 'fail' + assert check(dst_feature, 'field_reallist', 17) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -262,35 +235,25 @@ def test_ogr_feature_cp_real(): with gdaltest.error_handler(): dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', 17.0): - return 'fail' + assert check(dst_feature, 'field_integer', 17.0) - if not check(dst_feature, 'field_real', 18.4): - return 'fail' + assert check(dst_feature, 'field_real', 18.4) - if not check(dst_feature, 'field_string', 0): - return 'fail' + assert check(dst_feature, 'field_string', 0) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', 15.0): - return 'fail' + assert check(dst_feature, 'field_integerlist', 15.0) - if not check(dst_feature, 'field_reallist', 17.5): - return 'fail' + assert check(dst_feature, 'field_reallist', 17.5) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -304,41 +267,29 @@ def test_ogr_feature_cp_string(): dst_feature = mk_dst_feature(src_feature, ogr.OFTString) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', '17'): - return 'fail' + assert check(dst_feature, 'field_integer', '17') - if not check(dst_feature, 'field_integer64', '9876543210'): - return 'fail' + assert check(dst_feature, 'field_integer64', '9876543210') - if not check(dst_feature, 'field_real', '18.4'): - return 'fail' + assert check(dst_feature, 'field_real', '18.4') - if not check(dst_feature, 'field_string', 'abc def'): - return 'fail' + assert check(dst_feature, 'field_string', 'abc def') - if not check(dst_feature, 'field_binary', '0123465789ABCDEF'): - return 'fail' + assert check(dst_feature, 'field_binary', '0123465789ABCDEF') - if not check(dst_feature, 'field_date', '2011/11/11'): - return 'fail' + assert check(dst_feature, 'field_date', '2011/11/11') - if not check(dst_feature, 'field_time', '14:10:35'): - return 'fail' + assert check(dst_feature, 'field_time', '14:10:35') - if not check(dst_feature, 'field_datetime', '2011/11/11 14:10:35.123'): - return 'fail' + assert check(dst_feature, 'field_datetime', '2011/11/11 14:10:35.123') - if not check(dst_feature, 'field_integerlist', '(3:10,20,30)'): - return 'fail' + assert check(dst_feature, 'field_integerlist', '(3:10,20,30)') - if not check(dst_feature, 'field_integer64list', '(1:9876543210)'): - return 'fail' + assert check(dst_feature, 'field_integer64list', '(1:9876543210)') - if not check(dst_feature, 'field_reallist', '(2:123.5,567)'): - return 'fail' + assert check(dst_feature, 'field_reallist', '(2:123.5,567)') - if not check(dst_feature, 'field_stringlist', '(2:abc,def)'): - return 'fail' + assert check(dst_feature, 'field_stringlist', '(2:abc,def)') return 'success' @@ -352,49 +303,35 @@ def test_ogr_feature_cp_binary(): dst_feature = mk_dst_feature(src_feature, ogr.OFTBinary) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', None): - return 'fail' + assert check(dst_feature, 'field_integer', None) - if not check(dst_feature, 'field_integer64', None): - return 'fail' + assert check(dst_feature, 'field_integer64', None) - if not check(dst_feature, 'field_real', None): - return 'fail' + assert check(dst_feature, 'field_real', None) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', '0123465789ABCDEF'): - return 'fail' + assert check(dst_feature, 'field_binary', '0123465789ABCDEF') expected = '\x01\x23\x46\x57\x89\xAB\xCD\xEF' if sys.version_info >= (3, 0, 0): expected = expected.encode('LATIN1') - if dst_feature.GetFieldAsBinary('field_binary') != expected: - return 'fail' - if dst_feature.GetFieldAsBinary(dst_feature.GetDefnRef().GetFieldIndex('field_binary')) != expected: - return 'fail' + assert dst_feature.GetFieldAsBinary('field_binary') == expected + assert dst_feature.GetFieldAsBinary(dst_feature.GetDefnRef().GetFieldIndex('field_binary')) == expected - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', None): - return 'fail' + assert check(dst_feature, 'field_integerlist', None) - if not check(dst_feature, 'field_integer64list', None): - return 'fail' + assert check(dst_feature, 'field_integer64list', None) - if not check(dst_feature, 'field_reallist', None): - return 'fail' + assert check(dst_feature, 'field_reallist', None) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -408,41 +345,29 @@ def test_ogr_feature_cp_date(): dst_feature = mk_dst_feature(src_feature, ogr.OFTDate) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', None): - return 'fail' + assert check(dst_feature, 'field_integer', None) - if not check(dst_feature, 'field_integer64', None): - return 'fail' + assert check(dst_feature, 'field_integer64', None) - if not check(dst_feature, 'field_real', None): - return 'fail' + assert check(dst_feature, 'field_real', None) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', '2011/11/11'): - return 'fail' + assert check(dst_feature, 'field_date', '2011/11/11') - if not check(dst_feature, 'field_time', '0000/00/00'): - return 'fail' + assert check(dst_feature, 'field_time', '0000/00/00') - if not check(dst_feature, 'field_datetime', '2011/11/11'): - return 'fail' + assert check(dst_feature, 'field_datetime', '2011/11/11') - if not check(dst_feature, 'field_integerlist', None): - return 'fail' + assert check(dst_feature, 'field_integerlist', None) - if not check(dst_feature, 'field_integer64list', None): - return 'fail' + assert check(dst_feature, 'field_integer64list', None) - if not check(dst_feature, 'field_reallist', None): - return 'fail' + assert check(dst_feature, 'field_reallist', None) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -456,41 +381,29 @@ def test_ogr_feature_cp_time(): dst_feature = mk_dst_feature(src_feature, ogr.OFTTime) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', None): - return 'fail' + assert check(dst_feature, 'field_integer', None) - if not check(dst_feature, 'field_integer64', None): - return 'fail' + assert check(dst_feature, 'field_integer64', None) - if not check(dst_feature, 'field_real', None): - return 'fail' + assert check(dst_feature, 'field_real', None) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', '00:00:00'): - return 'fail' + assert check(dst_feature, 'field_date', '00:00:00') - if not check(dst_feature, 'field_time', '14:10:35'): - return 'fail' + assert check(dst_feature, 'field_time', '14:10:35') - if not check(dst_feature, 'field_datetime', '14:10:35.123'): - return 'fail' + assert check(dst_feature, 'field_datetime', '14:10:35.123') - if not check(dst_feature, 'field_integerlist', None): - return 'fail' + assert check(dst_feature, 'field_integerlist', None) - if not check(dst_feature, 'field_integer64list', None): - return 'fail' + assert check(dst_feature, 'field_integer64list', None) - if not check(dst_feature, 'field_reallist', None): - return 'fail' + assert check(dst_feature, 'field_reallist', None) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -504,41 +417,29 @@ def test_ogr_feature_cp_datetime(): dst_feature = mk_dst_feature(src_feature, ogr.OFTDateTime) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', None): - return 'fail' + assert check(dst_feature, 'field_integer', None) - if not check(dst_feature, 'field_integer64', None): - return 'fail' + assert check(dst_feature, 'field_integer64', None) - if not check(dst_feature, 'field_real', None): - return 'fail' + assert check(dst_feature, 'field_real', None) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', '2011/11/11 00:00:00'): - return 'fail' + assert check(dst_feature, 'field_date', '2011/11/11 00:00:00') - if not check(dst_feature, 'field_time', '0000/00/00 14:10:35'): - return 'fail' + assert check(dst_feature, 'field_time', '0000/00/00 14:10:35') - if not check(dst_feature, 'field_datetime', '2011/11/11 14:10:35.123'): - return 'fail' + assert check(dst_feature, 'field_datetime', '2011/11/11 14:10:35.123') - if not check(dst_feature, 'field_integerlist', None): - return 'fail' + assert check(dst_feature, 'field_integerlist', None) - if not check(dst_feature, 'field_integer64list', None): - return 'fail' + assert check(dst_feature, 'field_integer64list', None) - if not check(dst_feature, 'field_reallist', None): - return 'fail' + assert check(dst_feature, 'field_reallist', None) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -554,41 +455,29 @@ def test_ogr_feature_cp_integerlist(): dst_feature.SetFrom(src_feature) gdal.PopErrorHandler() - if not check(dst_feature, 'field_integer', [17]): - return 'fail' + assert check(dst_feature, 'field_integer', [17]) - if not check(dst_feature, 'field_integer64', [2147483647]): - return 'fail' + assert check(dst_feature, 'field_integer64', [2147483647]) - if not check(dst_feature, 'field_real', [18]): - return 'fail' + assert check(dst_feature, 'field_real', [18]) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', [10, 20, 30]): - return 'fail' + assert check(dst_feature, 'field_integerlist', [10, 20, 30]) - if not check(dst_feature, 'field_integer64list', [2147483647]): - return 'fail' + assert check(dst_feature, 'field_integer64list', [2147483647]) - if not check(dst_feature, 'field_reallist', [123, 567]): - return 'fail' + assert check(dst_feature, 'field_reallist', [123, 567]) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -602,41 +491,29 @@ def test_ogr_feature_cp_integer64list(): dst_feature = mk_dst_feature(src_feature, ogr.OFTInteger64List) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', [17]): - return 'fail' + assert check(dst_feature, 'field_integer', [17]) - if not check(dst_feature, 'field_integer64', [9876543210]): - return 'fail' + assert check(dst_feature, 'field_integer64', [9876543210]) - if not check(dst_feature, 'field_real', [18]): - return 'fail' + assert check(dst_feature, 'field_real', [18]) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', [10, 20, 30]): - return 'fail' + assert check(dst_feature, 'field_integerlist', [10, 20, 30]) - if not check(dst_feature, 'field_integer64list', [9876543210]): - return 'fail' + assert check(dst_feature, 'field_integer64list', [9876543210]) - if not check(dst_feature, 'field_reallist', [123, 567]): - return 'fail' + assert check(dst_feature, 'field_reallist', [123, 567]) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -650,41 +527,29 @@ def test_ogr_feature_cp_reallist(): dst_feature = mk_dst_feature(src_feature, ogr.OFTRealList) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', [17.0]): - return 'fail' + assert check(dst_feature, 'field_integer', [17.0]) - if not check(dst_feature, 'field_integer64', [9876543210.0]): - return 'fail' + assert check(dst_feature, 'field_integer64', [9876543210.0]) - if not check(dst_feature, 'field_real', [18.4]): - return 'fail' + assert check(dst_feature, 'field_real', [18.4]) - if not check(dst_feature, 'field_string', None): - return 'fail' + assert check(dst_feature, 'field_string', None) - if not check(dst_feature, 'field_binary', None): - return 'fail' + assert check(dst_feature, 'field_binary', None) - if not check(dst_feature, 'field_date', None): - return 'fail' + assert check(dst_feature, 'field_date', None) - if not check(dst_feature, 'field_time', None): - return 'fail' + assert check(dst_feature, 'field_time', None) - if not check(dst_feature, 'field_datetime', None): - return 'fail' + assert check(dst_feature, 'field_datetime', None) - if not check(dst_feature, 'field_integerlist', [10.0, 20.0, 30.0]): - return 'fail' + assert check(dst_feature, 'field_integerlist', [10.0, 20.0, 30.0]) - if not check(dst_feature, 'field_integer64list', [9876543210.0]): - return 'fail' + assert check(dst_feature, 'field_integer64list', [9876543210.0]) - if not check(dst_feature, 'field_reallist', [123.5, 567.0]): - return 'fail' + assert check(dst_feature, 'field_reallist', [123.5, 567.0]) - if not check(dst_feature, 'field_stringlist', None): - return 'fail' + assert check(dst_feature, 'field_stringlist', None) return 'success' @@ -698,41 +563,29 @@ def test_ogr_feature_cp_stringlist(): dst_feature = mk_dst_feature(src_feature, ogr.OFTStringList) dst_feature.SetFrom(src_feature) - if not check(dst_feature, 'field_integer', ["17"]): - return 'fail' + assert check(dst_feature, 'field_integer', ["17"]) - if not check(dst_feature, 'field_integer64', ["9876543210"]): - return 'fail' + assert check(dst_feature, 'field_integer64', ["9876543210"]) - if not check(dst_feature, 'field_real', ["18.4"]): - return 'fail' + assert check(dst_feature, 'field_real', ["18.4"]) - if not check(dst_feature, 'field_string', ['abc def']): - return 'fail' + assert check(dst_feature, 'field_string', ['abc def']) - if not check(dst_feature, 'field_binary', ['0123465789ABCDEF']): - return 'fail' + assert check(dst_feature, 'field_binary', ['0123465789ABCDEF']) - if not check(dst_feature, 'field_date', ['2011/11/11']): - return 'fail' + assert check(dst_feature, 'field_date', ['2011/11/11']) - if not check(dst_feature, 'field_time', ['14:10:35']): - return 'fail' + assert check(dst_feature, 'field_time', ['14:10:35']) - if not check(dst_feature, 'field_datetime', ['2011/11/11 14:10:35.123']): - return 'fail' + assert check(dst_feature, 'field_datetime', ['2011/11/11 14:10:35.123']) - if not check(dst_feature, 'field_integerlist', ['10', '20', '30']): - return 'fail' + assert check(dst_feature, 'field_integerlist', ['10', '20', '30']) - if not check(dst_feature, 'field_integer64list', ['9876543210']): - return 'fail' + assert check(dst_feature, 'field_integer64list', ['9876543210']) - if not check(dst_feature, 'field_reallist', ['123.5', '567']): - return 'fail' + assert check(dst_feature, 'field_reallist', ['123.5', '567']) - if not check(dst_feature, 'field_stringlist', ['abc', 'def']): - return 'fail' + assert check(dst_feature, 'field_stringlist', ['abc', 'def']) return 'success' @@ -754,20 +607,16 @@ def test_ogr_feature_unicode(): src_feature = ogr.Feature(feat_def) src_feature.SetField('field_string', 'abc def'.decode('utf-8')) - if src_feature.GetField('field_string') != 'abc def': - return 'fail' - if src_feature.GetField('field_string'.decode('utf-8')) != 'abc def': - return 'fail' + assert src_feature.GetField('field_string') == 'abc def' + assert src_feature.GetField('field_string'.decode('utf-8')) == 'abc def' src_feature = ogr.Feature(feat_def) src_feature.SetField('field_string'.decode('utf-8'), 'abc def'.decode('utf-8')) - if src_feature.GetField('field_string') != 'abc def': - return 'fail' + assert src_feature.GetField('field_string') == 'abc def' src_feature = ogr.Feature(feat_def) src_feature.SetField('field_integer64'.decode('utf-8'), 1) - if src_feature.GetField('field_integer64') != 1: - return 'fail' + assert src_feature.GetField('field_integer64') == 1 return 'success' @@ -780,8 +629,7 @@ def test_ogr_feature_64bit_fid(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) f.SetFID(123456789012345) - if f.GetFID() != 123456789012345: - return 'fail' + assert f.GetFID() == 123456789012345 return 'success' ############################################################################### @@ -815,34 +663,28 @@ def test_ogr_feature_nullable_validate(): # No fields feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) - if f.Validate() != 1: - return 'fail' + assert f.Validate() == 1 # Field with default parameter and empty feature feat_def = ogr.FeatureDefn('test') field_def = ogr.FieldDefn('field_string', ogr.OFTString) - if field_def.IsNullable() != 1: - return 'fail' - if feat_def.GetGeomFieldDefn(0).IsNullable() != 1: - return 'fail' + assert field_def.IsNullable() == 1 + assert feat_def.GetGeomFieldDefn(0).IsNullable() == 1 feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) - if f.Validate() != 1: - return 'fail' + assert f.Validate() == 1 # Field with not NULL constraint and empty feature feat_def = ogr.FeatureDefn('test') field_def = ogr.FieldDefn('field_string', ogr.OFTString) field_def.SetNullable(0) - if field_def.IsNullable() != 0: - return 'fail' + assert field_def.IsNullable() == 0 feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) gdal.PushErrorHandler() ret = f.Validate() gdal.PopErrorHandler() - if ret != 0: - return 'fail' + assert ret == 0 # Field with not NULL constraint and non-empty feature feat_def = ogr.FeatureDefn('test') @@ -851,8 +693,7 @@ def test_ogr_feature_nullable_validate(): feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) f.SetField(0, 'foo') - if f.Validate() != 1: - return 'fail' + assert f.Validate() == 1 # Field with width constraint that is met feat_def = ogr.FeatureDefn('test') @@ -861,8 +702,7 @@ def test_ogr_feature_nullable_validate(): feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) f.SetField(0, 'foo') - if f.Validate() != 1: - return 'fail' + assert f.Validate() == 1 # Field with width constraint that is not met feat_def = ogr.FeatureDefn('test') @@ -874,21 +714,18 @@ def test_ogr_feature_nullable_validate(): gdal.PushErrorHandler() ret = f.Validate() gdal.PopErrorHandler() - if ret != 0: - return 'fail' + assert ret == 0 # Geometry field with not-null geometry constraint that is met feat_def = ogr.FeatureDefn('test') feat_def.SetGeomType(ogr.wkbNone) gfield_def = ogr.GeomFieldDefn('test', ogr.wkbUnknown) gfield_def.SetNullable(0) - if gfield_def.IsNullable() != 0: - return 'fail' + assert gfield_def.IsNullable() == 0 feat_def.AddGeomFieldDefn(gfield_def) f = ogr.Feature(feat_def) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(0 1)')) - if f.Validate() != 1: - return 'fail' + assert f.Validate() == 1 # Geometry field with not-null geometry constraint that is not met feat_def = ogr.FeatureDefn('test') @@ -900,16 +737,14 @@ def test_ogr_feature_nullable_validate(): gdal.PushErrorHandler() ret = f.Validate() gdal.PopErrorHandler() - if ret != 0: - return 'fail' + assert ret == 0 # Geometry field with Point geometry type that is met feat_def = ogr.FeatureDefn('test') feat_def.SetGeomType(ogr.wkbPoint) f = ogr.Feature(feat_def) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(0 1)')) - if f.Validate() != 1: - return 'fail' + assert f.Validate() == 1 # Geometry field with LineString geometry type that is not met feat_def = ogr.FeatureDefn('test') @@ -919,8 +754,7 @@ def test_ogr_feature_nullable_validate(): gdal.PushErrorHandler() ret = f.Validate() gdal.PopErrorHandler() - if ret != 0: - return 'fail' + assert ret == 0 return 'success' @@ -933,38 +767,29 @@ def test_ogr_feature_default(): feat_def = ogr.FeatureDefn('test') field_def = ogr.FieldDefn('field_string', ogr.OFTString) - if field_def.GetDefault() is not None: - return 'fail' - if field_def.IsDefaultDriverSpecific(): - return 'fail' + assert field_def.GetDefault() is None + assert not field_def.IsDefaultDriverSpecific() field_def.SetDefault("(some_expr)") - if field_def.GetDefault() != "(some_expr)": - return 'fail' - if not field_def.IsDefaultDriverSpecific(): - return 'fail' + assert field_def.GetDefault() == "(some_expr)" + assert field_def.IsDefaultDriverSpecific() field_def.SetDefault("'a") - if field_def.GetDefault() != "'a": - return 'fail' + assert field_def.GetDefault() == "'a" gdal.PushErrorHandler() field_def.SetDefault("'a''") gdal.PopErrorHandler() - if field_def.GetDefault() is not None: - return 'fail' + assert field_def.GetDefault() is None gdal.PushErrorHandler() field_def.SetDefault("'a'b'") gdal.PopErrorHandler() - if field_def.GetDefault() is not None: - return 'fail' + assert field_def.GetDefault() is None field_def.SetDefault("'a''b'''") - if field_def.GetDefault() != "'a''b'''": - return 'fail' - if field_def.IsDefaultDriverSpecific(): - return 'fail' + assert field_def.GetDefault() == "'a''b'''" + assert not field_def.IsDefaultDriverSpecific() feat_def.AddFieldDefn(field_def) field_def = ogr.FieldDefn('field_datetime', ogr.OFTDateTime) @@ -1009,37 +834,26 @@ def test_ogr_feature_native_data(): feat_def = ogr.FeatureDefn('test') f = ogr.Feature(feat_def) - if f.GetNativeData() is not None: - return 'fail' - if f.GetNativeMediaType() is not None: - return 'fail' + assert f.GetNativeData() is None + assert f.GetNativeMediaType() is None f.SetNativeData('native_data') - if f.GetNativeData() != 'native_data': - return 'fail' + assert f.GetNativeData() == 'native_data' f.SetNativeMediaType('native_media_type') - if f.GetNativeMediaType() != 'native_media_type': - print(f.GetNativeMediaType()) - return 'fail' + assert f.GetNativeMediaType() == 'native_media_type' f2 = ogr.Feature(feat_def) f2.SetFrom(f) - if f2.GetNativeData() != 'native_data': - return 'fail' - if f2.GetNativeMediaType() != 'native_media_type': - return 'fail' + assert f2.GetNativeData() == 'native_data' + assert f2.GetNativeMediaType() == 'native_media_type' f_clone = f.Clone() - if f_clone.GetNativeData() != 'native_data': - return 'fail' - if f_clone.GetNativeMediaType() != 'native_media_type': - return 'fail' + assert f_clone.GetNativeData() == 'native_data' + assert f_clone.GetNativeMediaType() == 'native_media_type' f_clone.SetNativeData(None) f_clone.SetNativeMediaType(None) - if f_clone.GetNativeData() is not None: - return 'fail' - if f_clone.GetNativeMediaType() is not None: - return 'fail' + assert f_clone.GetNativeData() is None + assert f_clone.GetNativeMediaType() is None ds = ogr.GetDriverByName('Memory').CreateDataSource('') lyr = ds.CreateLayer('test') @@ -1057,24 +871,12 @@ def test_ogr_feature_native_data(): for dialect in dialects: sql_lyr = ds.ExecuteSQL('SELECT * FROM %s' % lyr.GetName(), dialect=dialect) native_data = sql_lyr.GetMetadataItem('NATIVE_DATA', 'NATIVE_DATA') - if native_data != 'native_data': - print(dialect) - print(native_data) - return 'fail' + assert native_data == 'native_data', dialect native_media_type = sql_lyr.GetMetadataItem('NATIVE_MEDIA_TYPE', 'NATIVE_DATA') - if native_media_type != 'native_media_type': - print(dialect) - print(native_media_type) - return 'fail' + assert native_media_type == 'native_media_type', dialect f = sql_lyr.GetNextFeature() - if f.GetNativeData() != 'native_data': - print(dialect) - print(f.GetNativeData()) - return 'fail' - if f.GetNativeMediaType() != 'native_media_type': - print(dialect) - print(f.GetNativeMediaType()) - return 'fail' + assert f.GetNativeData() == 'native_data', dialect + assert f.GetNativeMediaType() == 'native_media_type', dialect ds.ReleaseResultSet(sql_lyr) return 'success' @@ -1092,8 +894,7 @@ def test_ogr_feature_set_geometry_self(): f.SetGeometryDirectly(f.GetGeometryRef()) f.SetGeometry(f.GetGeometryRef()) f.SetGeometry(f.GetGeometryRef()) - if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (2 49)' return 'success' @@ -1107,19 +908,14 @@ def test_ogr_feature_null_field(): field_def = ogr.FieldDefn('field_string', ogr.OFTString) feat_def.AddFieldDefn(field_def) f = ogr.Feature(feat_def) - if f.IsFieldNull(feat_def.GetFieldIndex("field_string")): - return 'fail' - if f.IsFieldNull("field_string"): - return 'fail' + assert not f.IsFieldNull(feat_def.GetFieldIndex("field_string")) + assert not f.IsFieldNull("field_string") f.SetFieldNull(feat_def.GetFieldIndex("field_string")) - if f.IsFieldNull(feat_def.GetFieldIndex("field_string")) == 0: - return 'fail' + assert f.IsFieldNull(feat_def.GetFieldIndex("field_string")) != 0 f.SetField("field_string", "foo") - if f.IsFieldNull("field_string"): - return 'fail' + assert not f.IsFieldNull("field_string") f.SetFieldNull("field_string") - if f.IsFieldNull(feat_def.GetFieldIndex("field_string")) == 0: - return 'fail' + assert f.IsFieldNull(feat_def.GetFieldIndex("field_string")) != 0 f = None field_def = ogr.FieldDefn('field_binary', ogr.OFTBinary) @@ -1143,37 +939,25 @@ def test_ogr_feature_null_field(): f.field_integer64list = [9876543210] f.field_reallist = [123.5, 567.0] f.field_stringlist = ['abc', 'def'] - if f.IsFieldNull('field_binary') != 0: - return 'fail' - if f.IsFieldNull('field_integerlist') != 0: - return 'fail' - if f.IsFieldNull('field_integer64list') != 0: - return 'fail' - if f.IsFieldNull('field_reallist') != 0: - return 'fail' - if f.IsFieldNull('field_stringlist') != 0: - return 'fail' + assert f.IsFieldNull('field_binary') == 0 + assert f.IsFieldNull('field_integerlist') == 0 + assert f.IsFieldNull('field_integer64list') == 0 + assert f.IsFieldNull('field_reallist') == 0 + assert f.IsFieldNull('field_stringlist') == 0 f.SetField('field_binary', None) f.SetFieldNull('field_integerlist') f.SetFieldNull('field_integer64list') f.SetFieldNull('field_reallist') f.SetFieldNull('field_stringlist') - if f.IsFieldNull('field_binary') == 0: - return 'fail' - if f.IsFieldNull('field_integerlist') == 0: - return 'fail' - if f.IsFieldNull('field_integer64list') == 0: - return 'fail' - if f.IsFieldNull('field_reallist') == 0: - return 'fail' - if f.IsFieldNull('field_stringlist') == 0: - return 'fail' + assert f.IsFieldNull('field_binary') != 0 + assert f.IsFieldNull('field_integerlist') != 0 + assert f.IsFieldNull('field_integer64list') != 0 + assert f.IsFieldNull('field_reallist') != 0 + assert f.IsFieldNull('field_stringlist') != 0 f_clone = f.Clone() - if f_clone.IsFieldNull('field_binary') == 0: - return 'fail' - if not f.Equal(f_clone): - return 'fail' + assert f_clone.IsFieldNull('field_binary') != 0 + assert f.Equal(f_clone) f = None diff --git a/autotest/ogr/ogr_fgdb.py b/autotest/ogr/ogr_fgdb.py index 7e2032033f88..b5576900ab65 100755 --- a/autotest/ogr/ogr_fgdb.py +++ b/autotest/ogr/ogr_fgdb.py @@ -39,6 +39,7 @@ from osgeo import gdal from osgeo import ogr from osgeo import osr +import pytest ############################################################################### # Test if driver is available @@ -174,9 +175,7 @@ def test_ogr_fgdb_1(): for data in datalist: lyr = ds.GetLayerByName(data[0]) if data[1] != ogr.wkbNone: - if lyr.GetSpatialRef().IsSame(srs) != 1: - print(lyr.GetSpatialRef()) - return 'fail' + assert lyr.GetSpatialRef().IsSame(srs) == 1 feat = lyr.GetNextFeature() if data[1] != ogr.wkbNone: try: @@ -208,33 +207,26 @@ def test_ogr_fgdb_1(): return 'fail' sql_lyr = ds.ExecuteSQL("GetLayerDefinition %s" % lyr.GetName()) - if sql_lyr is None: - return 'fail' + assert sql_lyr is not None feat = sql_lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None feat = sql_lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None lyr.ResetReading() lyr.TestCapability("foo") ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("GetLayerMetadata %s" % lyr.GetName()) - if sql_lyr is None: - return 'fail' + assert sql_lyr is not None feat = sql_lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("GetLayerDefinition foo") - if sql_lyr is not None: - return 'fail' + assert sql_lyr is None sql_lyr = ds.ExecuteSQL("GetLayerMetadata foo") - if sql_lyr is not None: - return 'fail' + assert sql_lyr is None ds = None @@ -251,21 +243,14 @@ def test_ogr_fgdb_DeleteField(): ds = ogr.Open("tmp/test.gdb", update=1) lyr = ds.GetLayerByIndex(0) - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint')).GetSubType() != ogr.OFSTInt16: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint2')).GetSubType() != ogr.OFSTInt16: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetSubType() != ogr.OFSTFloat32: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float2')).GetSubType() != ogr.OFSTFloat32: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint')).GetSubType() == ogr.OFSTInt16 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint2')).GetSubType() == ogr.OFSTInt16 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetSubType() == ogr.OFSTFloat32 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float2')).GetSubType() == ogr.OFSTFloat32 - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint')).GetWidth() != 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str')).GetWidth() != 0: - return 'fail' - if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('str')) != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('smallint')).GetWidth() == 0 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str')).GetWidth() == 0 + assert lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('str')) == 0 # Needed since FileGDB v1.4, otherwise crash/error ... if True: # pylint: disable=using-constant-test @@ -281,27 +266,22 @@ def test_ogr_fgdb_DeleteField(): # Test updating non-existing feature feat.SetFID(-10) - if lyr.SetFeature(feat) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('Expected failure of SetFeature().') - return 'fail' + assert lyr.SetFeature(feat) == ogr.OGRERR_NON_EXISTING_FEATURE, \ + 'Expected failure of SetFeature().' # Test deleting non-existing feature - if lyr.DeleteFeature(-10) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('Expected failure of DeleteFeature().') - return 'fail' + assert lyr.DeleteFeature(-10) == ogr.OGRERR_NON_EXISTING_FEATURE, \ + 'Expected failure of DeleteFeature().' feat = None ds = None ds = ogr.Open("tmp/test.gdb") lyr = ds.GetLayerByIndex(0) - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str2')).GetWidth() != 80: - return 'fail' - if lyr.GetLayerDefn().GetFieldIndex('str') != -1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('str2')).GetWidth() == 80 + assert lyr.GetLayerDefn().GetFieldIndex('str') == -1 feat = lyr.GetNextFeature() - if feat.GetFieldAsString("str2") != "foo2_\xc3\xa9": - return 'fail' + assert feat.GetFieldAsString("str2") == "foo2_\xc3\xa9" ds = None return 'success' @@ -320,9 +300,7 @@ def test_ogr_fgdb_2(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro tmp/test.gdb --config OGR_SKIP OpenFileGDB') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -346,9 +324,7 @@ def test_ogr_fgdb_3(): gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f filegdb tmp/poly.gdb data/poly.shp -nlt MULTIPOLYGON -a_srs None') ds = ogr.Open('tmp/poly.gdb') - if ds is None or ds.GetLayerCount() == 0: - gdaltest.post_reason('ogr2ogr failed') - return 'fail' + assert not (ds is None or ds.GetLayerCount() == 0), 'ogr2ogr failed' ds = None if test_cli_utilities.get_test_ogrsf_path() is None: @@ -357,9 +333,7 @@ def test_ogr_fgdb_3(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/poly.gdb') # print ret - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -381,11 +355,9 @@ def test_ogr_fgdb_sql(): sql_lyr = ds.ExecuteSQL("SELECT * FROM POLY WHERE EAS_ID = 170", dialect='FileGDB') feat = sql_lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None feat = sql_lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None feat = None ds.ReleaseResultSet(sql_lyr) ds = None @@ -428,9 +400,7 @@ def test_ogr_fgdb_4(): lyr = ds.GetLayerByName('layer_to_remove') ds = None - if lyr is not None: - gdaltest.post_reason('failed at iteration %d' % j) - return 'fail' + assert lyr is None, ('failed at iteration %d' % j) return 'success' @@ -442,9 +412,8 @@ def test_ogr_fgdb_5(): if ogrtest.fgdb_drv is None: return 'skip' - if ogrtest.fgdb_drv.DeleteDataSource("tmp/test.gdb") != 0: - gdaltest.post_reason('DeleteDataSource() failed') - return 'fail' + assert ogrtest.fgdb_drv.DeleteDataSource("tmp/test.gdb") == 0, \ + 'DeleteDataSource() failed' try: os.stat("tmp/test.gdb") @@ -472,8 +441,7 @@ def test_ogr_fgdb_6(): ds = None ds = ogr.Open('tmp/test.gdb') - if ds.GetLayerCount() != 2: - return 'fail' + assert ds.GetLayerCount() == 2 ds = None return 'success' @@ -508,8 +476,7 @@ def test_ogr_fgdb_7(): lyr.ResetReading() feat = lyr.GetNextFeature() - if feat.GetField(0) != 0: - return 'fail' + assert feat.GetField(0) == 0 ds = None gdal.SetConfigOption('FGDB_BULK_LOAD', None) @@ -549,9 +516,8 @@ def test_ogr_fgdb_8(): 'A1234567890123456789012345678901234567890123456789012345678901_1', 'A1234567890123456789012345678901234567890123456789012345678901_2'] for i in range(5): - if lyr_defn.GetFieldIndex(expected_names[i]) != i: - gdaltest.post_reason('did not find %s' % expected_names[i]) - return 'fail' + assert lyr_defn.GetFieldIndex(expected_names[i]) == i, \ + ('did not find %s' % expected_names[i]) return 'success' @@ -597,9 +563,7 @@ def test_ogr_fgdb_9(): _160char[0:158] + '_1', _160char[0:158] + '_2'] for i, exp_name in enumerate(expected_names): - if ds.GetLayerByIndex(i).GetName() != exp_name: - gdaltest.post_reason('did not find %s' % exp_name) - return 'fail' + assert ds.GetLayerByIndex(i).GetName() == exp_name, ('did not find %s' % exp_name) return 'success' @@ -683,20 +647,15 @@ def test_ogr_fgdb_10(): ds = ogr.Open('tmp/test.gdb') lyr = ds.GetLayerByName("srs_exact_4326") - if lyr.GetSpatialRef().ExportToWkt().find('4326') == -1: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('4326') != -1 lyr = ds.GetLayerByName("srs_approx_4326") - if lyr.GetSpatialRef().ExportToWkt().find('4326') == -1: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('4326') != -1 lyr = ds.GetLayerByName("srs_exact_2193") - if lyr.GetSpatialRef().ExportToWkt().find('2193') == -1: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('2193') != -1 lyr = ds.GetLayerByName("srs_approx_2193") - if lyr.GetSpatialRef().ExportToWkt().find('2193') == -1: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('2193') != -1 lyr = ds.GetLayerByName("srs_approx_4230") - if lyr.GetSpatialRef().ExportToWkt().find('4230') == -1: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('4230') != -1 ds = None return 'success' @@ -783,8 +742,7 @@ def test_ogr_fgdb_12(): return 'skip' ds = ogr.Open('tmp/non_existing.gdb') - if ds is not None: - return 'fail' + assert ds is None gdal.Unlink('tmp/dummy.gdb') try: @@ -796,8 +754,7 @@ def test_ogr_fgdb_12(): f.close() ds = ogr.Open('tmp/dummy.gdb') - if ds is not None: - return 'fail' + assert ds is None os.unlink('tmp/dummy.gdb') @@ -806,8 +763,7 @@ def test_ogr_fgdb_12(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogr.Open('tmp/dummy.gdb') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None shutil.rmtree('tmp/dummy.gdb') @@ -824,8 +780,7 @@ def test_ogr_fgdb_13(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogrtest.fgdb_drv.CreateDataSource('tmp/foo') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None f = open('tmp/dummy.gdb', 'wb') f.close() @@ -833,8 +788,7 @@ def test_ogr_fgdb_13(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogrtest.fgdb_drv.CreateDataSource('tmp/dummy.gdb') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None os.unlink('tmp/dummy.gdb') @@ -848,14 +802,12 @@ def test_ogr_fgdb_13(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogrtest.fgdb_drv.CreateDataSource(name) gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None gdal.PushErrorHandler('CPLQuietErrorHandler') ret = ogrtest.fgdb_drv.DeleteDataSource(name) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 return 'success' @@ -869,11 +821,9 @@ def test_ogr_fgdb_14(): for _ in range(3): ds1 = ogr.Open("tmp/test.gdb") - if ds1 is None: - return 'fail' + assert ds1 is not None ds2 = ogr.Open("tmp/test.gdb") - if ds2 is None: - return 'fail' + assert ds2 is not None ds2 = None ds1 = None @@ -898,10 +848,7 @@ def test_ogr_fgdb_15(): sr = osr.SpatialReference() sr.ImportFromEPSG(3005) expected_wkt = sr.ExportToWkt() - if got_wkt != expected_wkt: - print(got_wkt) - print(expected_wkt) - return 'fail' + assert got_wkt == expected_wkt ds = None return 'success' @@ -960,8 +907,7 @@ def test_ogr_fgdb_17(): sr = osr.SpatialReference() sr.ImportFromEPSG(4326) lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, srs=sr, options=['GEOMETRY_NULLABLE=NO']) - if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() == 0 field_defn = ogr.FieldDefn('field_not_nullable', ogr.OFTString) field_defn.SetNullable(0) lyr.CreateField(field_defn) @@ -972,8 +918,7 @@ def test_ogr_fgdb_17(): f.SetField('field_not_nullable', 'not_null') f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)')) ret = lyr.CreateFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f = None # Error case: missing geometry @@ -982,8 +927,7 @@ def test_ogr_fgdb_17(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None # Error case: missing non-nullable field @@ -992,20 +936,16 @@ def test_ogr_fgdb_17(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None ds = None ds = ogr.Open('tmp/test.gdb', update=1) lyr = ds.GetLayerByName('test') - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() == 0 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() == 1 + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() == 0 ds = None @@ -1070,16 +1010,11 @@ def ogr_fgdb_18_test_results(): ds = ogr.Open('tmp/test.gdb', update=1) lyr = ds.GetLayerByName('test') - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() != "'a''b'": - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() == "'a''b'" if ogrtest.openfilegdb_drv is not None: - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_int')).GetDefault() != '123': - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault() != '1.23': - print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault()) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nodefault')).GetDefault() is not None: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_int')).GetDefault() == '123' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault() == '1.23' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nodefault')).GetDefault() is None # if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime')).GetDefault() != 'CURRENT_TIMESTAMP': # gdaltest.post_reason('fail') # return 'fail' @@ -1151,52 +1086,45 @@ def test_ogr_fgdb_19(): gdal.PushErrorHandler() ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds = None (bPerLayerCopyingForTransaction, ds) = ogr_fgdb_19_open_update('tmp/test.gdb') - if ds.TestCapability(ogr.ODsCEmulatedTransactions) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCEmulatedTransactions) == 1 # Error case: try in non-forced mode gdal.PushErrorHandler() ret = ds.StartTransaction(force=False) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 # Error case: try StartTransaction() with a ExecuteSQL layer still active sql_lyr = ds.ExecuteSQL('SELECT * FROM test') gdal.PushErrorHandler() ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds.ReleaseResultSet(sql_lyr) # Error case: call CommitTransaction() while there is no transaction gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 # Error case: call RollbackTransaction() while there is no transaction gdal.PushErrorHandler() ret = ds.RollbackTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 # Error case: try StartTransaction() with another active connection ds2 = ogr.Open('tmp/test.gdb', update=1) gdal.PushErrorHandler() ret = ds2.StartTransaction(force=True) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds2 = None # Successful StartTransaction() finally! @@ -1207,8 +1135,7 @@ def test_ogr_fgdb_19(): layer_created_before_transaction = ds.CreateLayer('layer_created_before_transaction', geom_type=ogr.wkbNone) layer_created_before_transaction_defn = layer_created_before_transaction.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 try: os.stat('tmp/test.gdb.ogredited') @@ -1221,47 +1148,38 @@ def test_ogr_fgdb_19(): pass ret = lyr.CreateField(ogr.FieldDefn('foobar', ogr.OFTString)) - if ret != 0: - return 'fail' + assert ret == 0 ret = lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('foobar')) - if ret != 0: - return 'fail' + assert ret == 0 gdal.PushErrorHandler() ret = lyr.CreateGeomField(ogr.GeomFieldDefn('foobar', ogr.wkbPoint)) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.PushErrorHandler() ret = lyr.ReorderFields([i for i in range(lyr.GetLayerDefn().GetFieldCount())]) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.PushErrorHandler() ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('foo', ogr.OFTString), 0) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = ogr.Feature(lyr_defn) f.SetField('field_string', 'foo') lyr.CreateFeature(f) lyr.SetFeature(f) fid = f.GetFID() - if fid <= 0: - print(fid) - return 'fail' + assert fid > 0 lyr.ResetReading() for i in range(fid): f = lyr.GetNextFeature() - if f.GetFID() != fid or f.GetField('field_string') != 'foo': - return 'fail' + assert f.GetFID() == fid and f.GetField('field_string') == 'foo' f = lyr.GetFeature(fid) - if f.GetFID() != fid or f.GetField('field_string') != 'foo': - return 'fail' + assert f.GetFID() == fid and f.GetField('field_string') == 'foo' f = ogr.Feature(layer_created_before_transaction_defn) layer_created_before_transaction.CreateFeature(f) @@ -1270,16 +1188,14 @@ def test_ogr_fgdb_19(): gdal.PushErrorHandler() ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 # Error case: try CommitTransaction() with a ExecuteSQL layer still active sql_lyr = ds.ExecuteSQL('SELECT * FROM test') gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds.ReleaseResultSet(sql_lyr) # Error case: try RollbackTransaction() with a ExecuteSQL layer still active @@ -1287,13 +1203,11 @@ def test_ogr_fgdb_19(): gdal.PushErrorHandler() ret = ds.RollbackTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds.ReleaseResultSet(sql_lyr) # Test that CommitTransaction() works - if ds.CommitTransaction() != 0: - return 'fail' + assert ds.CommitTransaction() == 0 try: os.stat('tmp/test.gdb.ogredited') @@ -1309,19 +1223,15 @@ def test_ogr_fgdb_19(): lst = gdal.ReadDir('tmp/test.gdb') for filename in lst: - if filename.find('.tmp') >= 0: - print(lst) - return 'fail' + assert filename.find('.tmp') < 0, lst lyr_tmp = ds.GetLayer(0) lyr_tmp = ds.GetLayer(0) new_count = lyr_tmp.GetFeatureCount() - if new_count != old_count + 1: - return 'fail' + assert new_count == old_count + 1 old_count = new_count - if layer_created_before_transaction.GetFeatureCount() != 1: - return 'fail' + assert layer_created_before_transaction.GetFeatureCount() == 1 for i in range(ds.GetLayerCount()): if ds.GetLayer(i).GetName() == layer_created_before_transaction.GetName(): @@ -1333,20 +1243,16 @@ def test_ogr_fgdb_19(): lyr_count = ds.GetLayerCount() ds.CreateLayer('layer_tmp', geom_type=ogr.wkbNone) ret = ds.StartTransaction(force=True) - if ret != 0: - return 'fail' + assert ret == 0 ds.DeleteLayer(ds.GetLayerCount() - 1) - if ds.CommitTransaction() != 0: - return 'fail' + assert ds.CommitTransaction() == 0 new_lyr_count = ds.GetLayerCount() - if new_lyr_count != lyr_count: - return 'fail' + assert new_lyr_count == lyr_count # Test that RollbackTransaction() works ret = ds.StartTransaction(force=True) - if ret != 0: - return 'fail' + assert ret == 0 f = ogr.Feature(lyr_defn) lyr.CreateFeature(f) @@ -1354,8 +1260,7 @@ def test_ogr_fgdb_19(): layer_created_during_transaction = ds.CreateLayer('layer_created_during_transaction', geom_type=ogr.wkbNone) layer_created_during_transaction.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) - if ds.RollbackTransaction() != 0: - return 'fail' + assert ds.RollbackTransaction() == 0 try: os.stat('tmp/test.gdb.ogredited') @@ -1369,17 +1274,12 @@ def test_ogr_fgdb_19(): except OSError: pass - if lyr.GetFeatureCount() != old_count: - print(lyr.GetFeatureCount()) - print(old_count) - return 'fail' + assert lyr.GetFeatureCount() == old_count # Cannot retrieve the layer any more from fresh - if ds.GetLayerByName('layer_created_during_transaction') is not None: - return 'fail' + assert ds.GetLayerByName('layer_created_during_transaction') is None # Pointer is in ghost state - if layer_created_during_transaction.GetLayerDefn().GetFieldCount() != 0: - return 'fail' + assert layer_created_during_transaction.GetLayerDefn().GetFieldCount() == 0 # Simulate an error case where StartTransaction() cannot copy backup files lyr_count = ds.GetLayerCount() @@ -1388,13 +1288,9 @@ def test_ogr_fgdb_19(): ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 - if ds.GetLayerCount() != lyr_count: - print(lyr_count) - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == lyr_count # Simulate an error case where StartTransaction() cannot reopen database gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE2') @@ -1402,11 +1298,9 @@ def test_ogr_fgdb_19(): ret = ds.StartTransaction(force=True) gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 - if ds.GetLayerCount() != 0: - return 'fail' + assert ds.GetLayerCount() == 0 shutil.rmtree('tmp/test.gdb.ogredited') # Test method on ghost datasource and layer @@ -1478,8 +1372,7 @@ def test_ogr_fgdb_19(): layer_tmp = ds.CreateLayer('layer_tmp', geom_type=ogr.wkbNone) layer_tmp.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 ds.DeleteLayer(ds.GetLayerCount() - 1) @@ -1488,8 +1381,7 @@ def test_ogr_fgdb_19(): ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 ds = None @@ -1497,9 +1389,7 @@ def test_ogr_fgdb_19(): lst = gdal.ReadDir('tmp/test.gdb') for filename in lst: - if filename.find('.tmp') >= 0: - print(lst) - return 'fail' + assert filename.find('.tmp') < 0, lst # Test an error case where we simulate a failure in renaming # a file in original directory @@ -1510,8 +1400,7 @@ def test_ogr_fgdb_19(): ds.DeleteLayer(i) break - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 lyr = ds.GetLayer(0) f = lyr.GetNextFeature() @@ -1523,8 +1412,7 @@ def test_ogr_fgdb_19(): ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 ds = None @@ -1532,16 +1420,13 @@ def test_ogr_fgdb_19(): lst = gdal.ReadDir('tmp/test.gdb') for filename in lst: - if filename.find('.tmp') >= 0: - print(lst) - return 'fail' + assert filename.find('.tmp') < 0, lst # Test an error case where we simulate a failure in moving # a file into original directory (bPerLayerCopyingForTransaction, ds) = ogr_fgdb_19_open_update('tmp/test.gdb') - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 lyr = ds.GetLayer(0) f = lyr.GetNextFeature() @@ -1553,8 +1438,7 @@ def test_ogr_fgdb_19(): ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 ds = None @@ -1570,8 +1454,7 @@ def test_ogr_fgdb_19(): for case in ('CASE4', 'CASE5'): (bPerLayerCopyingForTransaction, ds) = ogr_fgdb_19_open_update('tmp/test.gdb') - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 lyr = ds.GetLayer(0) f = lyr.GetNextFeature() @@ -1583,9 +1466,7 @@ def test_ogr_fgdb_19(): ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret != 0: - print(case) - return 'fail' + assert ret == 0, case ds = None @@ -1611,16 +1492,14 @@ def test_ogr_fgdb_19(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE1') gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 ds = None @@ -1629,16 +1508,14 @@ def test_ogr_fgdb_19(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE2') gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 ds = None os.rename('tmp/test.gdb.ogrtmp', 'tmp/test.gdb') @@ -1648,16 +1525,14 @@ def test_ogr_fgdb_19(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE3') gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret != 0: - return 'fail' + assert ret == 0 ds = None shutil.rmtree('tmp/test.gdb.ogrtmp') @@ -1667,19 +1542,16 @@ def test_ogr_fgdb_19(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE_REOPEN') gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 - if ds.GetLayerCount() != 0: - return 'fail' + assert ds.GetLayerCount() == 0 ds = None @@ -1688,16 +1560,14 @@ def test_ogr_fgdb_19(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE1') gdal.PushErrorHandler() ret = ds.RollbackTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 ds = None shutil.rmtree('tmp/test.gdb.ogredited') @@ -1707,19 +1577,16 @@ def test_ogr_fgdb_19(): lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if ds.StartTransaction(force=True) != 0: - return 'fail' + assert ds.StartTransaction(force=True) == 0 gdal.SetConfigOption('FGDB_SIMUL_FAIL', 'CASE2') gdal.PushErrorHandler() ret = ds.RollbackTransaction() gdal.PopErrorHandler() gdal.SetConfigOption('FGDB_SIMUL_FAIL', None) - if ret == 0: - return 'fail' + assert ret != 0 - if ds.GetLayerCount() != 0: - return 'fail' + assert ds.GetLayerCount() == 0 ds = None @@ -1787,15 +1654,13 @@ def test_ogr_fgdb_20(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('id', 1) ret = lyr.CreateFeature(f) - if ret != 0 or f.GetFID() != 1 or lyr.GetMetadataItem('1', 'MAP_OGR_FID_TO_FGDB_FID') is not None: - return 'fail' + assert ret == 0 and f.GetFID() == 1 and lyr.GetMetadataItem('1', 'MAP_OGR_FID_TO_FGDB_FID') is None # Existing FID gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 for invalid_fid in [-2, 0, 9876543210]: f = ogr.Feature(lyr.GetLayerDefn()) @@ -1803,9 +1668,7 @@ def test_ogr_fgdb_20(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - print(invalid_fid) - return 'fail' + assert ret != 0, invalid_fid f = ogr.Feature(lyr.GetLayerDefn()) f.SetFID(2) @@ -1825,8 +1688,7 @@ def test_ogr_fgdb_20(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds2 = None ret = lyr.CreateFeature(f) @@ -1839,28 +1701,23 @@ def test_ogr_fgdb_20(): gdal.PushErrorHandler() ds2 = ogr.Open('tmp/test.gdb', update=1) gdal.PopErrorHandler() - if ds2 is not None: - return 'fail' + assert ds2 is None ds2 = None # Existing FID, but only in OGR space gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 # This FID exists as a FGDB ID, but should not be user visible. f.SetFID(3) ret = lyr.SetFeature(f) - if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert ret == ogr.OGRERR_NON_EXISTING_FEATURE ret = lyr.DeleteFeature(3) - if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert ret == ogr.OGRERR_NON_EXISTING_FEATURE ret = lyr.GetFeature(3) - if ret is not None: - return 'fail' + assert ret is None # Trying to set OGR FID = 3 --> FileGDB FID = 4 f = ogr.Feature(lyr.GetLayerDefn()) @@ -1880,16 +1737,14 @@ def test_ogr_fgdb_20(): f = lyr.GetNextFeature() else: f = lyr.GetFeature(fid) - if f is None: - return 'fail' + assert f is not None if f.GetFID() != fid or f.GetField('id') != fid: f.DumpReadable() print(fid) return 'fail' got_fgdb_fid = lyr.GetMetadataItem(str(f.GetFID()), 'MAP_OGR_FID_TO_FGDB_FID') if got_fgdb_fid is None: - if fgdb_fid is not None: - return 'fail' + assert fgdb_fid is None elif int(got_fgdb_fid) != fgdb_fid: print(got_fgdb_fid) print(fgdb_fid) @@ -1905,29 +1760,23 @@ def test_ogr_fgdb_20(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetFID(invalid_fid) ret = lyr.SetFeature(f) - if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert ret == ogr.OGRERR_NON_EXISTING_FEATURE ret = lyr.DeleteFeature(invalid_fid) - if ret != ogr.OGRERR_NON_EXISTING_FEATURE: - return 'fail' + assert ret == ogr.OGRERR_NON_EXISTING_FEATURE f = lyr.GetFeature(3) f.SetField('str', '3') ret = lyr.SetFeature(f) - if ret != 0: - return 'fail' + assert ret == 0 f = lyr.GetFeature(3) - if f.GetField('str') != '3': - return 'fail' + assert f.GetField('str') == '3' ret = lyr.DeleteFeature(1) - if ret != 0: - return 'fail' + assert ret == 0 ret = lyr.DeleteFeature(3) - if ret != 0: - return 'fail' + assert ret == 0 for (fid, fgdb_fid) in [(3, 5), (2049, 6), (10, 7), (7, 8), (9, None), (8, 10), (12, 11)]: f = ogr.Feature(lyr.GetLayerDefn()) @@ -1953,8 +1802,7 @@ def test_ogr_fgdb_20(): expected = [(2, None), (4, 3), (3, 5), (2049, 6), (10, 7), (7, 8), (9, None), (8, 10)] for (fid, fgdb_fid) in expected: f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None if f.GetFID() != fid or f.GetField('id') != fid or str(lyr.GetMetadataItem(str(fid), 'MAP_OGR_FID_TO_FGDB_FID')) != str(fgdb_fid): f.DumpReadable() print(fid) @@ -1999,8 +1847,7 @@ def test_ogr_fgdb_20(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds.ReleaseResultSet(sql_lyr) @@ -2038,18 +1885,13 @@ def test_ogr_fgdb_20(): for update in [0, 1]: ds = ogr.Open('tmp/test.gdb', update=update) lyr = ds.GetLayerByName('ogr_fgdb_20') - if lyr.GetFeatureCount() != 10: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 10 lyr.ResetReading() expected = [2, 3, 4, 7, 8, 9, 10, 12, 13, 2049] for fid in expected: f = lyr.GetNextFeature() - if gdal.GetLastErrorType() != 0: - return 'fail' - if f is None: - print(fid) - return 'fail' + assert gdal.GetLastErrorType() == 0 + assert f is not None, fid if f.GetFID() != fid or f.GetField('id') != fid: f.DumpReadable() print(fid) @@ -2066,11 +1908,9 @@ def test_ogr_fgdb_20(): lyr = ds.GetLayerByName('ogr_fgdb_20_simple') f = lyr.GetNextFeature() - if f.GetFID() != 2: - return 'fail' + assert f.GetFID() == 2 f = lyr.GetNextFeature() - if f.GetFID() != 3: - return 'fail' + assert f.GetFID() == 3 # Check attribute index lyr = ds.GetLayerByName('ogr_fgdb_20_indexes') @@ -2079,10 +1919,7 @@ def test_ogr_fgdb_20(): lyr.SetAttributeFilter('id = %d' % fid) lyr.ResetReading() f = lyr.GetNextFeature() - if f.GetFID() != fid: - print(f.GetFID()) - print(fid) - return 'fail' + assert f.GetFID() == fid # Check spatial index lyr.SetAttributeFilter(None) @@ -2092,10 +1929,7 @@ def test_ogr_fgdb_20(): lyr.SetSpatialFilterRect(i - 0.01, -0.01, i + 0.01, 0.01) lyr.ResetReading() f = lyr.GetNextFeature() - if f.GetFID() != fid: - print(f.GetFID()) - print(fid) - return 'fail' + assert f.GetFID() == fid # Insert new features ds = ogr.Open('tmp/test.gdb', update=1) @@ -2132,18 +1966,13 @@ def test_ogr_fgdb_20(): for update in [0, 1]: ds = ogr.Open('tmp/test.gdb', update=update) lyr = ds.GetLayerByName('ogr_fgdb_20') - if lyr.GetFeatureCount() != 16: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 16 lyr.ResetReading() expected = [2, 3, 4, 7, 8, 9, 10, 12, 13, 2049, 8191, 16384, 1000000, 1000001, 10000000, 10000001] for fid in expected: f = lyr.GetNextFeature() - if gdal.GetLastErrorType() != 0: - return 'fail' - if f is None: - print(fid) - return 'fail' + assert gdal.GetLastErrorType() == 0 + assert f is not None, fid if f.GetFID() != fid or f.GetField('id') != fid: f.DumpReadable() print(fid) @@ -2172,36 +2001,23 @@ def test_ogr_fgdb_20(): gdal.SetConfigOption('FGDB_SIMUL_FAIL_REOPEN', None) gdal.PopErrorHandler() if case == 'CASE3': - if sql_lyr is None: - print(case) - return 'fail' + assert sql_lyr is not None, case ds.ReleaseResultSet(sql_lyr) else: - if sql_lyr is not None: - print(case) - return 'fail' + assert sql_lyr is None, case # Everything will fail, but hopefully without crashing lyr.ResetReading() - if lyr.GetNextFeature() is not None: - return 'fail' - if lyr.GetFeature(1) is not None: - return 'fail' - if lyr.DeleteFeature(1) == 0: - return 'fail' - if lyr.CreateFeature(f) == 0: - return 'fail' - if lyr.SetFeature(f) == 0: - return 'fail' + assert lyr.GetNextFeature() is None + assert lyr.GetFeature(1) is None + assert lyr.DeleteFeature(1) != 0 + assert lyr.CreateFeature(f) != 0 + assert lyr.SetFeature(f) != 0 if case != 'CASE3': - if ds.CreateLayer('bar', geom_type=ogr.wkbNone) is not None: - return 'fail' - if ds.DeleteLayer(0) == 0: - return 'fail' + assert ds.CreateLayer('bar', geom_type=ogr.wkbNone) is None + assert ds.DeleteLayer(0) != 0 sql_lyr = ds.ExecuteSQL('SELECT * FROM foo') - if case != 'CASE3' and sql_lyr is not None: - print(case) - return 'fail' + assert case == 'CASE3' or sql_lyr is None ds.ReleaseResultSet(sql_lyr) ds = None @@ -2275,10 +2091,7 @@ def test_ogr_fgdb_21(): elif expected_geom_type == ogr.wkbPolygonZM: expected_geom_type = ogr.wkbMultiPolygonZM - if lyr.GetGeomType() != expected_geom_type: - print(data) - print(lyr.GetGeomType()) - return 'fail' + assert lyr.GetGeomType() == expected_geom_type, data feat = lyr.GetNextFeature() try: expected_wkt = data[3] @@ -2313,8 +2126,7 @@ def test_ogr_fgdb_22(): f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: print(f.GetGeometryRef().ExportToWkt()) - print(f_ref.GetGeometryRef().ExportToWkt()) - return 'fail' + pytest.fail(f_ref.GetGeometryRef().ExportToWkt()) lyr = ds.GetLayerByName('polygon') ds_ref = ogr.Open('data/curves_polygon.csv') @@ -2323,8 +2135,7 @@ def test_ogr_fgdb_22(): f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: print(f.GetGeometryRef().ExportToWkt()) - print(f_ref.GetGeometryRef().ExportToWkt()) - return 'fail' + pytest.fail(f_ref.GetGeometryRef().ExportToWkt()) ds = ogr.Open('data/curve_circle_by_center.gdb') lyr = ds.GetLayer(0) @@ -2334,8 +2145,7 @@ def test_ogr_fgdb_22(): f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: print(f.GetGeometryRef().ExportToWkt()) - print(f_ref.GetGeometryRef().ExportToWkt()) - return 'fail' + pytest.fail(f_ref.GetGeometryRef().ExportToWkt()) return 'success' @@ -2351,8 +2161,7 @@ def test_ogr_fgdb_23(): os.chdir('data/curves.gdb') ds = ogr.Open('.') os.chdir('../..') - if ds is None: - return 'fail' + assert ds is not None return 'success' @@ -2371,8 +2180,7 @@ def test_ogr_fgdb_24(): f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: print(f.GetGeometryRef().ExportToIsoWkt()) - print(f_ref.GetGeometryRef().ExportToIsoWkt()) - return 'fail' + pytest.fail(f_ref.GetGeometryRef().ExportToIsoWkt()) ds = ogr.Open('data/filegdb_polygonzm_nan_m_with_curves.gdb') lyr = ds.GetLayer(0) @@ -2382,8 +2190,7 @@ def test_ogr_fgdb_24(): f_ref = lyr_ref.GetNextFeature() if ogrtest.check_feature_geometry(f, f_ref.GetGeometryRef()) != 0: print(f.GetGeometryRef().ExportToIsoWkt()) - print(f_ref.GetGeometryRef().ExportToIsoWkt()) - return 'fail' + pytest.fail(f_ref.GetGeometryRef().ExportToIsoWkt()) return 'success' @@ -2395,15 +2202,13 @@ def test_ogr_fgdb_25(): ds = ogr.Open('data/curves.gdb') sql_lyr = ds.ExecuteSQL('SELECT OBJECTID FROM polygon WHERE OBJECTID = 2') - if sql_lyr is None: - return 'fail' + assert sql_lyr is not None f = sql_lyr.GetNextFeature() if f.GetFID() != 2: f.DumpReadable() return 'fail' f = sql_lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None ds.ReleaseResultSet(sql_lyr) lyr = ds.GetLayerByName('polygon') diff --git a/autotest/ogr/ogr_fgdb_stress_test.py b/autotest/ogr/ogr_fgdb_stress_test.py index 8155297b91a9..25a75d6a2acf 100755 --- a/autotest/ogr/ogr_fgdb_stress_test.py +++ b/autotest/ogr/ogr_fgdb_stress_test.py @@ -125,9 +125,7 @@ def ogr_fgdb_stress_test_1(): # So to ensure lyr_ref will use the same FID as the tested layer fid = f.GetFID() # print("created %d" % fid) - if ret[0] != ret[1]: - print(ret) - return 'fail' + assert ret[0] == ret[1] if ret[0] == 0: nfeatures_created += 1 # For some odd reason, the .spx file is no longer updated when doing @@ -146,9 +144,7 @@ def ogr_fgdb_stress_test_1(): # gdal.PushErrorHandler() ret.append(lyr.SetFeature(f)) # gdal.PopErrorHandler() - if ret[0] != ret[1]: - print(ret) - return 'fail' + assert ret[0] == ret[1] # Same for DeleteFeature() elif nfeatures_created >= 2: ret = [] @@ -159,9 +155,7 @@ def ogr_fgdb_stress_test_1(): # gdal.PushErrorHandler() ret.append(lyr.DeleteFeature(fid)) # gdal.PopErrorHandler() - if ret[0] != ret[1]: - print(ret) - return 'fail' + assert ret[0] == ret[1] if in_transaction: ds_test.CommitTransaction() @@ -185,8 +179,7 @@ def ogr_fgdb_stress_test_2(): while True: f_test = lyr_test.GetNextFeature() f_ref = lyr_ref.GetNextFeature() - if (f_test is None and f_ref is not None) or (f_test is not None and f_ref is None): - return 'fail' + assert not (f_test is None and f_ref is not None) or (f_test is not None and f_ref is None) if f_test is None: break if f_test.GetFID() != f_ref.GetFID() or \ @@ -199,11 +192,7 @@ def ogr_fgdb_stress_test_2(): for val in range(1000): lyr_test.SetAttributeFilter("str = '%d'" % val) lyr_ref.SetAttributeFilter("str = '%d'" % val) - if lyr_test.GetFeatureCount() != lyr_ref.GetFeatureCount(): - print(val) - print(lyr_test.GetFeatureCount()) - print(lyr_ref.GetFeatureCount()) - return 'fail' + assert lyr_test.GetFeatureCount() == lyr_ref.GetFeatureCount(), val # sys.exit(0) diff --git a/autotest/ogr/ogr_geoconcept.py b/autotest/ogr/ogr_geoconcept.py index c1602c7bb7a4..7321d81a12aa 100755 --- a/autotest/ogr/ogr_geoconcept.py +++ b/autotest/ogr/ogr_geoconcept.py @@ -46,21 +46,14 @@ def test_ogr_gxt_1(): gdaltest.gxt_ds = ogr.Open('data/expected_000_GRD.gxt') - if gdaltest.gxt_ds is None: - return 'fail' + assert gdaltest.gxt_ds is not None - if gdaltest.gxt_ds.GetLayerCount() != 1: - gdaltest.post_reason('Got wrong layer count.') - return 'fail' + assert gdaltest.gxt_ds.GetLayerCount() == 1, 'Got wrong layer count.' lyr = gdaltest.gxt_ds.GetLayer(0) - if lyr.GetName() != '000_GRD.000_GRD': - gdaltest.post_reason('got unexpected layer name.') - return 'fail' + assert lyr.GetName() == '000_GRD.000_GRD', 'got unexpected layer name.' - if lyr.GetFeatureCount() != 10: - gdaltest.post_reason('got wrong feature count.') - return 'fail' + assert lyr.GetFeatureCount() == 10, 'got wrong feature count.' expect = ['000-2007-0050-7130-LAMB93', '000-2007-0595-7130-LAMB93', @@ -74,24 +67,20 @@ def test_ogr_gxt_1(): '000-2007-0050-6585-LAMB93'] tr = ogrtest.check_features_against_list(lyr, 'idSel', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, + assert (ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((50000 7130000,600000 7130000,600000 6580000,50000 6580000,50000 7130000)))', - max_error=0.000000001) != 0: - return 'fail' + max_error=0.000000001) == 0) srs = osr.SpatialReference() srs.SetFromUserInput('PROJCS["Lambert 93",GEOGCS["unnamed",DATUM["ITRS-89",SPHEROID["GRS 80",6378137,298.257222099657],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",44],PARAMETER["standard_parallel_2",49],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000]]') - if not lyr.GetSpatialRef().IsSame(srs): - gdaltest.post_reason('SRS is not the one expected.') - return 'fail' + assert lyr.GetSpatialRef().IsSame(srs), 'SRS is not the one expected.' return 'success' @@ -103,21 +92,14 @@ def test_ogr_gxt_2(): gdaltest.gxt_ds = ogr.Open('data/expected_000_GRD_TAB.txt') - if gdaltest.gxt_ds is None: - return 'fail' + assert gdaltest.gxt_ds is not None - if gdaltest.gxt_ds.GetLayerCount() != 1: - gdaltest.post_reason('Got wrong layer count.') - return 'fail' + assert gdaltest.gxt_ds.GetLayerCount() == 1, 'Got wrong layer count.' lyr = gdaltest.gxt_ds.GetLayer(0) - if lyr.GetName() != '000_GRD.000_GRD': - gdaltest.post_reason('got unexpected layer name.') - return 'fail' + assert lyr.GetName() == '000_GRD.000_GRD', 'got unexpected layer name.' - if lyr.GetFeatureCount() != 5: - gdaltest.post_reason('got wrong feature count.') - return 'fail' + assert lyr.GetFeatureCount() == 5, 'got wrong feature count.' expect = ['000-2007-0050-7130-LAMB93', '000-2007-0595-7130-LAMB93', @@ -126,17 +108,15 @@ def test_ogr_gxt_2(): '000-2007-0050-6585-LAMB93'] tr = ogrtest.check_features_against_list(lyr, 'idSel', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, + assert (ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON (((50000 7130000,600000 7130000,600000 6580000,50000 6580000,50000 7130000)))', - max_error=0.000000001) != 0: - return 'fail' + max_error=0.000000001) == 0) return 'success' @@ -176,9 +156,7 @@ def test_ogr_gxt_3(): feat = src_lyr.GetNextFeature() while feat is not None: dst_feat.SetFrom(feat) - if gxt_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert gxt_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = src_lyr.GetNextFeature() @@ -188,45 +166,38 @@ def test_ogr_gxt_3(): gdaltest.gxt_ds = ogr.Open('tmp/tmp.gxt') gxt_lyr = gdaltest.gxt_ds.GetLayerByName('points.points') - if not gxt_lyr.GetSpatialRef().IsSame(srs): - gdaltest.post_reason('Output SRS is not the one expected.') - return 'fail' + assert gxt_lyr.GetSpatialRef().IsSame(srs), 'Output SRS is not the one expected.' expect = ['PID1', 'PID2'] tr = ogrtest.check_features_against_list(gxt_lyr, 'Primary_ID', expect) - if not tr: - return 'fail' + assert tr gxt_lyr.ResetReading() expect = ['SID1', 'SID2'] tr = ogrtest.check_features_against_list(gxt_lyr, 'Secondary_ID', expect) - if not tr: - return 'fail' + assert tr gxt_lyr.ResetReading() expect = ['TID1', None] tr = ogrtest.check_features_against_list(gxt_lyr, 'Third_ID', expect) - if not tr: - return 'fail' + assert tr gxt_lyr.ResetReading() feat = gxt_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT(0 1)', - max_error=0.000000001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'POINT(0 1)', + max_error=0.000000001) == 0) feat = gxt_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT(2 3)', - max_error=0.000000001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'POINT(2 3)', + max_error=0.000000001) == 0) return 'success' diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index d3505a4f6f02..49e3aaacb02f 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -40,6 +40,7 @@ import gdaltest import ogrtest +import pytest ############################################################################### # Test utilities @@ -221,24 +222,17 @@ def test_ogr_geojson_2(): return 'skip' ds = ogr.Open('data/point.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('point') - if lyr is None: - gdaltest.post_reason('Missing layer called point') - return 'fail' + assert lyr is not None, 'Missing layer called point' extent = (100.0, 100.0, 0.0, 0.0) rc = validate_layer(lyr, 'point', 1, ogr.wkbPoint, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -254,24 +248,17 @@ def test_ogr_geojson_3(): return 'skip' ds = ogr.Open('data/linestring.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('linestring') - if lyr is None: - gdaltest.post_reason('Missing layer called linestring') - return 'fail' + assert lyr is not None, 'Missing layer called linestring' extent = (100.0, 101.0, 0.0, 1.0) rc = validate_layer(lyr, 'linestring', 1, ogr.wkbLineString, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -287,24 +274,17 @@ def test_ogr_geojson_4(): return 'skip' ds = ogr.Open('data/polygon.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('polygon') - if lyr is None: - gdaltest.post_reason('Missing layer called polygon') - return 'fail' + assert lyr is not None, 'Missing layer called polygon' extent = (100.0, 101.0, 0.0, 1.0) rc = validate_layer(lyr, 'polygon', 1, ogr.wkbPolygon, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -320,24 +300,17 @@ def test_ogr_geojson_5(): return 'skip' ds = ogr.Open('data/geometrycollection.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('geometrycollection') - if lyr is None: - gdaltest.post_reason('Missing layer called geometrycollection') - return 'fail' + assert lyr is not None, 'Missing layer called geometrycollection' extent = (100.0, 102.0, 0.0, 1.0) rc = validate_layer(lyr, 'geometrycollection', 1, ogr.wkbGeometryCollection, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -353,24 +326,17 @@ def test_ogr_geojson_6(): return 'skip' ds = ogr.Open('data/multipoint.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('multipoint') - if lyr is None: - gdaltest.post_reason('Missing layer called multipoint') - return 'fail' + assert lyr is not None, 'Missing layer called multipoint' extent = (100.0, 101.0, 0.0, 1.0) rc = validate_layer(lyr, 'multipoint', 1, ogr.wkbMultiPoint, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -386,24 +352,17 @@ def test_ogr_geojson_7(): return 'skip' ds = ogr.Open('data/multilinestring.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('multilinestring') - if lyr is None: - gdaltest.post_reason('Missing layer called multilinestring') - return 'fail' + assert lyr is not None, 'Missing layer called multilinestring' extent = (100.0, 103.0, 0.0, 3.0) rc = validate_layer(lyr, 'multilinestring', 1, ogr.wkbMultiLineString, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -419,24 +378,17 @@ def test_ogr_geojson_8(): return 'skip' ds = ogr.Open('data/multipolygon.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('multipolygon') - if lyr is None: - gdaltest.post_reason('Missing layer called multipolygon') - return 'fail' + assert lyr is not None, 'Missing layer called multipolygon' extent = (100.0, 103.0, 0.0, 3.0) rc = validate_layer(lyr, 'multipolygon', 1, ogr.wkbMultiPolygon, 0, extent) - if not rc: - return 'fail' + assert rc lyr = None @@ -464,14 +416,10 @@ def test_ogr_geojson_9(): test = gdaltest.tests[i] rc = copy_shape_to_geojson(test[0]) - if not rc: - gdaltest.post_reason('Failed making copy of ' + test[0] + '.shp') - return 'fail' + assert rc, ('Failed making copy of ' + test[0] + '.shp') rc = verify_geojson_copy(test[0], test[1], test[2]) - if not rc: - gdaltest.post_reason('Verification of copy of ' + test[0] + '.shp failed') - return 'fail' + assert rc, ('Verification of copy of ' + test[0] + '.shp failed') return 'success' @@ -497,14 +445,10 @@ def test_ogr_geojson_10(): test = gdaltest.tests[i] rc = copy_shape_to_geojson(test[0], '/vsigzip/') - if not rc: - gdaltest.post_reason('Failed making copy of ' + test[0] + '.shp') - return 'fail' + assert rc, ('Failed making copy of ' + test[0] + '.shp') rc = verify_geojson_copy(test[0], test[1], test[2]) - if not rc: - gdaltest.post_reason('Verification of copy of ' + test[0] + '.shp failed') - return 'fail' + assert rc, ('Verification of copy of ' + test[0] + '.shp failed') return 'success' @@ -517,39 +461,28 @@ def test_ogr_geojson_11(): return 'skip' ds = ogr.Open('data/srs_name.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('srs_name') - if lyr is None: - gdaltest.post_reason('Missing layer called srs_name') - return 'fail' + assert lyr is not None, 'Missing layer called srs_name' extent = (100.0, 102.0, 0.0, 1.0) rc = validate_layer(lyr, 'srs_name', 1, ogr.wkbGeometryCollection, 0, extent) - if not rc: - return 'fail' + assert rc ref = lyr.GetSpatialRef() pcs = int(ref.GetAuthorityCode('PROJCS')) - if pcs != 26915: - gdaltest.post_reason('Spatial reference was not valid') - return 'fail' + assert pcs == 26915, 'Spatial reference was not valid' feature = lyr.GetNextFeature() geometry = feature.GetGeometryRef().GetGeometryRef(0) srs = geometry.GetSpatialReference() pcs = int(srs.GetAuthorityCode('PROJCS')) - if pcs != 26916: - gdaltest.post_reason('Spatial reference for individual geometry was not valid') - return 'fail' + assert pcs == 26916, 'Spatial reference for individual geometry was not valid' lyr = None @@ -573,9 +506,7 @@ def test_ogr_geojson_12(): return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_ogrinfo_path() + ' -ro -al \'{"type": "Point","coordinates": [100.0, 0.0]}\'') - if ret.find(' POINT (100 0)') == -1: - print(ret) - return 'fail' + assert ret.find(' POINT (100 0)') != -1 return 'success' @@ -591,9 +522,7 @@ def test_ogr_geojson_13(): test = ['gjpoint', [1], ['Point 1']] rc = copy_shape_to_geojson(test[0], '/vsistdout/') - if not rc: - gdaltest.post_reason('Failed making copy of ' + test[0] + '.shp') - return 'fail' + assert rc, ('Failed making copy of ' + test[0] + '.shp') return 'success' @@ -659,16 +588,12 @@ def test_ogr_geojson_15(): if out != expected_out: out_json = json.loads(out) expected_out_json = json.loads(expected_out) - if out_json != expected_out_json: - print(out) - return 'fail' + assert out_json == expected_out_json, out out = feature.ExportToJson(as_object=True) expected_out = {'geometry': {'type': 'Point', 'coordinates': [1.0, 2.0]}, 'type': 'Feature', 'properties': {'foo': 'bar', "boolfield": True}, 'id': 0} - if out != expected_out: - print(out) - return 'fail' + assert out == expected_out return 'success' @@ -682,31 +607,22 @@ def test_ogr_geojson_16(): return 'skip' ds = ogr.Open('data/esripoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('esripoint') - if lyr is None: - gdaltest.post_reason('Missing layer called esripoint') - return 'fail' + assert lyr is not None, 'Missing layer called esripoint' extent = (2, 2, 49, 49) rc = validate_layer(lyr, 'esripoint', 1, ogr.wkbPoint, 4, extent) - if not rc: - return 'fail' + assert rc ref = lyr.GetSpatialRef() gcs = int(ref.GetAuthorityCode('GEOGCS')) - if gcs != 4326: - gdaltest.post_reason("Spatial reference was not valid") - return 'fail' + assert gcs == 4326, "Spatial reference was not valid" feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('POINT(2 49)') @@ -745,21 +661,16 @@ def test_ogr_geojson_17(): return 'skip' ds = ogr.Open('data/esrilinestring.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) extent = (2, 3, 49, 50) rc = validate_layer(lyr, None, 1, ogr.wkbLineString, 0, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('LINESTRING (2 49,3 50)') @@ -804,21 +715,16 @@ def test_ogr_geojson_18(): return 'skip' ds = ogr.Open('data/esripolygon.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) extent = (-3, 3, 49, 50) rc = validate_layer(lyr, None, 1, ogr.wkbPolygon, 0, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('MULTIPOLYGON (((2 49,2 50,3 50,3 49,2 49),(2.1 49.1,2.1 49.9,2.9 49.9,2.9 49.1,2.1 49.1)),((-2 49,-2 50,-3 50,-3 49,-2 49)))') @@ -830,9 +736,7 @@ def test_ogr_geojson_18(): ds = None ds = ogr.Open('data/esripolygonempty.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayer(0) feature = lyr.GetNextFeature() if feature.GetGeometryRef().ExportToWkt() != 'POLYGON EMPTY': @@ -854,21 +758,16 @@ def test_ogr_geojson_19(): return 'skip' ds = ogr.Open('data/esrimultipoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) extent = (2, 3, 49, 50) rc = validate_layer(lyr, None, 1, ogr.wkbMultiPoint, 4, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('MULTIPOINT (2 49,3 50)') @@ -909,8 +808,7 @@ def test_ogr_geojson_20(): if ds is None: print(gj) print(data.decode('LATIN1')) - gdaltest.post_reason('Failed to open datasource') - return 'fail' + pytest.fail('Failed to open datasource') ds = None gdal.Unlink('/vsimem/testgj') @@ -931,9 +829,7 @@ def test_ogr_geojson_21(): "geometry": {"type":"Point","coordinates":[1,2]}, "properties": {"_id":"aid", "_rev":"arev", "type":"Feature", "properties":{"intvalue" : 2, "floatvalue" : 3.2, "strvalue" : "foo", "properties": { "foo": "bar"}}}}]}""") - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('OGRGeoJSON') @@ -969,9 +865,7 @@ def test_ogr_geojson_22(): "geometry": {"type":"Point","coordinates":[3,4]}, "properties": {"_id":"aid2", "_rev":"arev2", "type":"Feature", "properties":{"intvalue" : 3.5, "str2value" : "bar"}}}]}""") - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('OGRGeoJSON') @@ -1026,10 +920,7 @@ def test_ogr_geojson_23(): sr_got = lyr.GetSpatialRef() ds = None - if sr_got.ExportToWkt() != sr.ExportToWkt(): - gdaltest.post_reason('did not get expected SRS') - print(sr_got) - return 'fail' + assert sr_got.ExportToWkt() == sr.ExportToWkt(), 'did not get expected SRS' fp = gdal.VSIFOpenL('/vsimem/ogr_geojson_23.json', 'rb') data = gdal.VSIFReadL(1, 10000, fp).decode('ascii') @@ -1037,15 +928,10 @@ def test_ogr_geojson_23(): gdal.Unlink('/vsimem/ogr_geojson_23.json') - if data.find('"bbox": [ 1, 10, 2, 20 ]') == -1: - gdaltest.post_reason('did not find global bbox') - print(data) - return 'fail' + assert data.find('"bbox": [ 1, 10, 2, 20 ]') != -1, 'did not find global bbox' - if data.find('"bbox": [ 1.0, 10.0, 1.0, 10.0 ]') == -1: - gdaltest.post_reason('did not find first feature bbox') - print(data) - return 'fail' + assert data.find('"bbox": [ 1.0, 10.0, 1.0, 10.0 ]') != -1, \ + 'did not find first feature bbox' return 'success' @@ -1081,14 +967,10 @@ def test_ogr_geojson_24(): ds = ogr.Open('/vsimem/ogr_geojson_24.js') gdal.Unlink('/vsimem/ogr_geojson_24.js') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('layerFoo') - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('POINT (2 49)') @@ -1098,9 +980,7 @@ def test_ogr_geojson_24(): return 'fail' lyr = ds.GetLayerByName('layerBar') - if lyr is None: - gdaltest.post_reason('cannot find layer') - return 'fail' + assert lyr is not None, 'cannot find layer' feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('POINT (2 49)') @@ -1124,14 +1004,11 @@ def test_ogr_geojson_25(): ds = ogr.Open('data/topojson1.topojson') lyr = ds.GetLayer(0) - if lyr.GetName() != 'a_layer': - return 'fail' + assert lyr.GetName() == 'a_layer' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') == 0 lyr = ds.GetLayer(1) - if lyr.GetName() != 'TopoJSON': - return 'fail' + assert lyr.GetName() == 'TopoJSON' expected_results = [ (None, None, 'POINT EMPTY'), (None, None, 'POINT EMPTY'), @@ -1169,8 +1046,7 @@ def test_ogr_geojson_25(): (None, None, 'MULTILINESTRING ((100 1000,110 1000,110 1100,100 1100,100 1000))'), (None, None, 'MULTILINESTRING ((100 1000,110 1000,110 1100,100 1100,100 1000),(101 1010,101 1090,109 1090,109 1010,101 1010))'), ] - if lyr.GetFeatureCount() != len(expected_results): - return 'fail' + assert lyr.GetFeatureCount() == len(expected_results) for i, exp_result in enumerate(expected_results): feat = lyr.GetNextFeature() if feat.GetField('id') != exp_result[0] or \ @@ -1185,32 +1061,24 @@ def test_ogr_geojson_25(): ds = ogr.Open('data/topojson2.topojson') lyr = ds.GetLayer(0) - if lyr.GetName() != 'a_layer': - return 'fail' + assert lyr.GetName() == 'a_layer' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') == 0 lyr = ds.GetLayer(1) - if lyr.GetName() != 'TopoJSON': - return 'fail' + assert lyr.GetName() == 'TopoJSON' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (100 1000,110 1000,110 1100)') == 0 ds = None ds = ogr.Open('data/topojson3.topojson') lyr = ds.GetLayer(0) - if lyr.GetName() != 'a_layer': - return 'fail' + assert lyr.GetName() == 'a_layer' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,10 0,0 10,10 0,0 0)') != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,10 0,0 10,10 0,0 0)') == 0 lyr = ds.GetLayer(1) - if lyr.GetName() != 'TopoJSON': - return 'fail' + assert lyr.GetName() == 'TopoJSON' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,10 0,0 10,10 0,0 0)') != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (0 0,10 0,0 10,10 0,0 0)') == 0 ds = None return 'success' @@ -1232,13 +1100,10 @@ def test_ogr_geojson_26(): "geometry": {"type":"Point","coordinates":[3,4]}, "properties": { "intvalue" : 1234567890123, "intlist" : [1, 1234567890123] }}, ]}""") - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('OGRGeoJSON') - if lyr.GetMetadataItem(ogr.OLMD_FID64) is None: - return 'fail' + assert lyr.GetMetadataItem(ogr.OLMD_FID64) is not None feature = lyr.GetNextFeature() if feature.GetFID() != 1: @@ -1283,9 +1148,7 @@ def test_ogr_geojson_26(): gdal.Unlink('/vsimem/ogr_geojson_26.json') - if data.find('{ "type": "Feature", "id": 1234567890123, "properties": { "int64": 1234567890123, "int64list": [ 1234567890123 ] }, "geometry": null }') < 0: - print(data) - return 'fail' + assert data.find('{ "type": "Feature", "id": 1234567890123, "properties": { "int64": 1234567890123, "int64list": [ 1234567890123 ] }, "geometry": null }') >= 0 return 'success' @@ -1310,9 +1173,7 @@ def test_ogr_geojson_27(): "properties": { "intvalue" : 12345678901231234567890123 }}, ]}""") gdal.PopErrorHandler() - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('OGRGeoJSON') @@ -1341,13 +1202,9 @@ def test_ogr_geojson_28(): return 'skip' ds = ogr.Open('data/esrizpoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) @@ -1355,15 +1212,12 @@ def test_ogr_geojson_28(): extent = (2, 2, 49, 49, 1, 1) rc = validate_layer(lyr, None, 1, ogr.wkbPoint, 4, extent) - if not rc: - return 'fail' + assert rc ref = lyr.GetSpatialRef() gcs = int(ref.GetAuthorityCode('GEOGCS')) - if gcs != 4326: - gdaltest.post_reason("Spatial reference was not valid") - return 'fail' + assert gcs == 4326, "Spatial reference was not valid" feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('POINT(2 49 1)') @@ -1402,13 +1256,9 @@ def test_ogr_geojson_29(): return 'skip' ds = ogr.Open('data/esrizlinestring.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) @@ -1416,8 +1266,7 @@ def test_ogr_geojson_29(): extent = (2, 3, 49, 50, 1, 2) rc = validate_layer(lyr, None, 1, ogr.wkbLineString, 0, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('LINESTRING (2 49 1,3 50 2)') @@ -1440,13 +1289,9 @@ def test_ogr_geojson_30(): return 'skip' ds = ogr.Open('data/esrizmultipoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) @@ -1454,8 +1299,7 @@ def test_ogr_geojson_30(): extent = (2, 3, 49, 50, 1, 2) rc = validate_layer(lyr, None, 1, ogr.wkbMultiPoint, 4, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('MULTIPOINT (2 49 1,3 50 2)') @@ -1478,13 +1322,9 @@ def test_ogr_geojson_31(): return 'skip' ds = ogr.Open('data/esrizpolygon.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) @@ -1492,8 +1332,7 @@ def test_ogr_geojson_31(): extent = (2, 3, 49, 50, 1, 4) rc = validate_layer(lyr, None, 1, ogr.wkbPolygon, 0, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('POLYGON ((2 49 1,2 50 2,3 50 3,3 49 4,2 49 1))') @@ -1516,21 +1355,16 @@ def test_ogr_geojson_32(): return 'skip' ds = ogr.Open('data/esrihasmnozmultipoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) extent = (2, 3, 49, 50) rc = validate_layer(lyr, None, 1, ogr.wkbMultiPoint, 4, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('MULTIPOINT M ((2 49 1),(3 50 2))') @@ -1553,21 +1387,16 @@ def test_ogr_geojson_33(): return 'skip' ds = ogr.Open('data/esriinvalidhaszmultipoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) extent = (2, 3, 49, 50) rc = validate_layer(lyr, None, 1, ogr.wkbMultiPoint, 4, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('MULTIPOINT (2 49,3 50)') @@ -1590,21 +1419,16 @@ def test_ogr_geojson_34(): return 'skip' ds = ogr.Open('data/esrizmmultipoint.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayer(0) extent = (2, 3, 49, 50) rc = validate_layer(lyr, None, 1, ogr.wkbMultiPoint, 4, extent) - if not rc: - return 'fail' + assert rc feature = lyr.GetNextFeature() ref_geom = ogr.CreateGeometryFromWkt('MULTIPOINT ZM ((2 49 1 100),(3 50 2 100))') @@ -1709,13 +1533,9 @@ def test_ogr_geojson_35(): gdal.Unlink('/vsimem/ogr_geojson_35.json') - if data.find('-1.79') == -1 and data.find('e+308') == -1: - print(data) - return 'fail' + assert not (data.find('-1.79') == -1 and data.find('e+308') == -1) for ident in range(2, 8): - if data.find('{ "type": "Feature", "id": %d, "properties": { }, "geometry": null }' % ident) == -1: - print(data) - return 'fail' + assert data.find('{ "type": "Feature", "id": %d, "properties": { }, "geometry": null }' % ident) != -1 return 'success' @@ -1729,9 +1549,7 @@ def test_ogr_geojson_36(): return 'skip' ds = ogr.Open('data/point_with_utf8bom.json') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' ds = None return 'success' @@ -1752,16 +1570,12 @@ def test_ogr_geojson_37(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool')).GetType() != ogr.OFTInteger or \ - feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool')).GetSubType() != ogr.OFSTBoolean: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('not_bool')).GetSubType() != ogr.OFSTNone: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool_list')).GetType() != ogr.OFTIntegerList or \ - feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool_list')).GetSubType() != ogr.OFSTBoolean: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('notbool_list')).GetSubType() != ogr.OFSTNone: - return 'fail' + assert (feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool')).GetType() == ogr.OFTInteger and \ + feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool')).GetSubType() == ogr.OFSTBoolean) + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('not_bool')).GetSubType() == ogr.OFSTNone + assert (feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool_list')).GetType() == ogr.OFTIntegerList and \ + feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('bool_list')).GetSubType() == ogr.OFSTBoolean) + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('notbool_list')).GetSubType() == ogr.OFSTNone f = lyr.GetNextFeature() if f.GetField('bool') != 0 or f.GetField('bool_list') != [0, 1]: f.DumpReadable() @@ -1782,9 +1596,7 @@ def test_ogr_geojson_37(): gdal.Unlink('/vsimem/ogr_geojson_37.json') - if data.find('"bool": false, "not_bool": 0, "bool_list": [ false, true ], "notbool_list": [ 0, 3 ]') < 0: - print(data) - return 'fail' + assert data.find('"bool": false, "not_bool": 0, "bool_list": [ false, true ], "notbool_list": [ 0, 3 ]') >= 0 return 'success' @@ -1804,18 +1616,12 @@ def test_ogr_geojson_38(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('dt')).GetType() != ogr.OFTDateTime: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('dt2')).GetType() != ogr.OFTDateTime: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('date')).GetType() != ogr.OFTDate: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('time')).GetType() != ogr.OFTTime: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('no_dt')).GetType() != ogr.OFTString: - return 'fail' - if feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('no_dt2')).GetType() != ogr.OFTString: - return 'fail' + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('dt')).GetType() == ogr.OFTDateTime + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('dt2')).GetType() == ogr.OFTDateTime + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('date')).GetType() == ogr.OFTDate + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('time')).GetType() == ogr.OFTTime + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('no_dt')).GetType() == ogr.OFTString + assert feat_defn.GetFieldDefn(feat_defn.GetFieldIndex('no_dt2')).GetType() == ogr.OFTString f = lyr.GetNextFeature() if f.GetField('dt') != '2014/11/20 12:34:56+01' or f.GetField('dt2') != '2014/11/20 00:00:00' or \ f.GetField('date') != '2014/11/20' or f.GetField('time') != '12:34:56': @@ -1843,8 +1649,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTString feat = lyr.GetNextFeature() if feat.GetField('id') != 'foo' or feat.GetField('bar') != 'baz': feat.DumpReadable() @@ -1856,8 +1661,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger feat = lyr.GetNextFeature() if feat.GetField('id') != 6: feat.DumpReadable() @@ -1870,8 +1674,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger feat = lyr.GetNextFeature() if feat.GetField('id') != 6: feat.DumpReadable() @@ -1883,8 +1686,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTString feat = lyr.GetNextFeature() if feat.GetField('id') != 'baz': feat.DumpReadable() @@ -1896,8 +1698,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'ID' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'ID' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger feat = lyr.GetNextFeature() if feat.GetFID() != 1 or feat.GetField('ID') != 2: feat.DumpReadable() @@ -1911,9 +1712,7 @@ def test_ogr_geojson_39(): { "type": "Feature", "id" : 1, "properties": { "foo": "baz" }, "geometry": null }, { "type": "Feature", "id" : 2, "properties": { "foo": "baw" }, "geometry": null } ] }""") - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('expected warning') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'expected warning' lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() feat = lyr.GetNextFeature() @@ -1935,8 +1734,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger feat = lyr.GetNextFeature() if feat.GetField('id') != -1: feat.DumpReadable() @@ -1949,8 +1747,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger64: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger64 feat = lyr.GetNextFeature() if feat.GetField('id') != -1234567890123: feat.DumpReadable() @@ -1963,8 +1760,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger64: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger64 feat = lyr.GetNextFeature() if feat.GetField('id') != -2: feat.DumpReadable() @@ -1977,8 +1773,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(1).GetName() != 'id' or feat_defn.GetFieldDefn(1).GetType() != ogr.OFTInteger: - return 'fail' + assert feat_defn.GetFieldDefn(1).GetName() == 'id' and feat_defn.GetFieldDefn(1).GetType() == ogr.OFTInteger feat = lyr.GetNextFeature() if feat.GetField('id') != 1: feat.DumpReadable() @@ -1992,8 +1787,7 @@ def test_ogr_geojson_39(): ] }""") lyr = ds.GetLayer(0) feat_defn = lyr.GetLayerDefn() - if feat_defn.GetFieldDefn(0).GetName() != 'id' or feat_defn.GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' + assert feat_defn.GetFieldDefn(0).GetName() == 'id' and feat_defn.GetFieldDefn(0).GetType() == ogr.OFTString feat = lyr.GetNextFeature() if feat.GetField('id') != '-2': feat.DumpReadable() @@ -2065,25 +1859,21 @@ def test_ogr_geojson_41(): # Check that by default we return a WGS 84 SRS g = ogr.CreateGeometryFromJson("{ 'type': 'Point', 'coordinates' : [ 2, 49] }") - if g.ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert g.ExportToWkt() == 'POINT (2 49)' srs = g.GetSpatialReference() g = None - if srs.ExportToWkt().find('WGS 84') < 0: - return 'fail' + assert srs.ExportToWkt().find('WGS 84') >= 0 # But if a crs object is set (allowed originally, but not recommended!), we use it g = ogr.CreateGeometryFromJson('{ "type": "Point", "coordinates" : [ 2, 49], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4322" } } }') srs = g.GetSpatialReference() - if srs.ExportToWkt().find('4322') < 0: - return 'fail' + assert srs.ExportToWkt().find('4322') >= 0 # But if a crs object is set to null, set no crs g = ogr.CreateGeometryFromJson('{ "type": "Point", "coordinates" : [ 2, 49], "crs": null }') srs = g.GetSpatialReference() - if srs: - return 'fail' + assert not srs return 'success' @@ -2121,11 +1911,9 @@ def test_ogr_geojson_42(): ds = ogr.Open('/vsimem/geojson/test.json?resultRecordCount=1') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None or f.GetFID() != 1: - return 'fail' + assert f is not None and f.GetFID() == 1 f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None ds = None gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=1') @@ -2135,11 +1923,9 @@ def test_ogr_geojson_42(): gdal.PopErrorHandler() lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None or f.GetFID() != 1: - return 'fail' + assert f is not None and f.GetFID() == 1 f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None ds = None gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=10') @@ -2149,15 +1935,12 @@ def test_ogr_geojson_42(): ds = ogr.Open('/vsimem/geojson/test.json?') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None or f.GetFID() != 1: - return 'fail' + assert f is not None and f.GetFID() == 1 f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None lyr.ResetReading() f = lyr.GetNextFeature() - if f is None or f.GetFID() != 1: - return 'fail' + assert f is not None and f.GetFID() == 1 resultOffset1 = """ { "type":"FeatureCollection", @@ -2176,46 +1959,35 @@ def test_ogr_geojson_42(): } ] }""" gdal.FileFromMemBuffer('/vsimem/geojson/test.json?resultRecordCount=1&resultOffset=1', resultOffset1) f = lyr.GetNextFeature() - if f is None or f.GetFID() != 2: - return 'fail' + assert f is not None and f.GetFID() == 2 f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None gdal.PushErrorHandler() fc = lyr.GetFeatureCount() gdal.PopErrorHandler() - if fc != 2: - return 'fail' + assert fc == 2 gdal.FileFromMemBuffer('/vsimem/geojson/test.json?resultRecordCount=1&returnCountOnly=true', """{ "count": 123456}""") fc = lyr.GetFeatureCount() - if fc != 123456: - return 'fail' + assert fc == 123456 gdal.PushErrorHandler() extent = lyr.GetExtent() gdal.PopErrorHandler() - if extent != (2, 2, 49, 49): - print(extent) - return 'fail' + assert extent == (2, 2, 49, 49) gdal.FileFromMemBuffer('/vsimem/geojson/test.json?resultRecordCount=1&returnExtentOnly=true&f=geojson', """{"type":"FeatureCollection","bbox":[1, 2, 3, 4],"features":[]}""") extent = lyr.GetExtent() - if extent != (1.0, 3.0, 2.0, 4.0): - print(extent) - return 'fail' + assert extent == (1.0, 3.0, 2.0, 4.0) - if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 1 - if lyr.TestCapability(ogr.OLCFastGetExtent) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastGetExtent) == 0 - if lyr.TestCapability('foo') != 0: - return 'fail' + assert lyr.TestCapability('foo') == 0 # Test scrolling with ESRI json resultOffset0 = """ @@ -2274,11 +2046,9 @@ def test_ogr_geojson_42(): ds = ogr.Open('/vsimem/geojson/test.json?resultRecordCount=1') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None or f.GetFID() != 1: - return 'fail' + assert f is not None and f.GetFID() == 1 f = lyr.GetNextFeature() - if f is None or f.GetFID() != 20: - return 'fail' + assert f is not None and f.GetFID() == 20 ds = None gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=1') gdal.Unlink('/vsimem/geojson/test.json?resultRecordCount=1&resultOffset=1') @@ -2295,9 +2065,7 @@ def test_ogr_geojson_43(): ds = ogr.Open("""{"type": "FeatureCollection", "features":[ {"type": "Feature", "properties": {"foo": "bar"}}]}""") - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('OGRGeoJSON') @@ -2343,13 +2111,9 @@ def test_ogr_geojson_45(): ds = gdal.OpenEx('/vsimem/ogr_geojson_45.json', gdal.OF_VECTOR, open_options=['NATIVE_DATA=YES']) lyr = ds.GetLayer(0) native_data = lyr.GetMetadataItem("NATIVE_DATA", "NATIVE_DATA") - if native_data != '{ "foo": "bar", "bar": "baz" }': - print(native_data) - return 'fail' + assert native_data == '{ "foo": "bar", "bar": "baz" }' native_media_type = lyr.GetMetadataItem("NATIVE_MEDIA_TYPE", "NATIVE_DATA") - if native_media_type != 'application/vnd.geo+json': - print(native_media_type) - return 'fail' + assert native_media_type == 'application/vnd.geo+json' f = lyr.GetNextFeature() native_data = f.GetNativeData() if i == 0: @@ -2358,13 +2122,9 @@ def test_ogr_geojson_45(): '{ "type": "Feature", "foo": [ "bar", "baz", 1.0, true, false, [ ], { } ], "properties": { "myprop": "myvalue" }, "geometry": null }'] else: expected = ['{"type":"Feature","foo":["bar","baz",1.0,true,false,[],{}],"properties":{"myprop":"myvalue"},"geometry":null}'] - if native_data not in expected: - print(native_data) - return 'fail' + assert native_data in expected native_media_type = f.GetNativeMediaType() - if native_media_type != 'application/vnd.geo+json': - print(native_media_type) - return 'fail' + assert native_media_type == 'application/vnd.geo+json' ds = None if i == 1: gdal.Unlink('/vsimem/ogr_geojson_45.json') @@ -2394,18 +2154,16 @@ def test_ogr_geojson_45(): gdal.Unlink('/vsimem/ogr_geojson_45.json') - if data.find('"bbox": [ 0, 1, 2, 0, 1, 2 ],') < 0 or \ - data.find('"foo": "bar"') < 0 or data.find('"bar": "baz"') < 0 or \ - data.find('"foo_feature": "bar_feature"') < 0 or \ - data.find('"foo_gc": "bar_gc"') < 0 or \ - data.find('"foo_point": "bar_point"') < 0 or data.find('3') < 0 or \ - data.find('"foo_linestring": "bar_linestring"') < 0 or data.find('4') < 0 or \ - data.find('"foo_multipoint": "bar_multipoint"') < 0 or data.find('5') < 0 or \ - data.find('"foo_multilinestring": "bar_multilinestring"') < 0 or data.find('6') < 0 or \ - data.find('"foo_polygon": "bar_polygon"') < 0 or data.find('7') < 0 or \ - data.find('"foo_multipolygon": "bar_multipolygon"') < 0 or data.find('8') < 0: - print(data) - return 'fail' + assert (data.find('"bbox": [ 0, 1, 2, 0, 1, 2 ],') >= 0 and \ + data.find('"foo": "bar"') >= 0 and data.find('"bar": "baz"') >= 0 and \ + data.find('"foo_feature": "bar_feature"') >= 0 and \ + data.find('"foo_gc": "bar_gc"') >= 0 and \ + data.find('"foo_point": "bar_point"') >= 0 and data.find('3') >= 0 and \ + data.find('"foo_linestring": "bar_linestring"') >= 0 and data.find('4') >= 0 and \ + data.find('"foo_multipoint": "bar_multipoint"') >= 0 and data.find('5') >= 0 and \ + data.find('"foo_multilinestring": "bar_multilinestring"') >= 0 and data.find('6') >= 0 and \ + data.find('"foo_polygon": "bar_polygon"') >= 0 and data.find('7') >= 0 and \ + data.find('"foo_multipolygon": "bar_multipolygon"') >= 0 and data.find('8') >= 0) # Test native support with string id src_ds = gdal.OpenEx("""{ @@ -2430,9 +2188,7 @@ def test_ogr_geojson_45(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Test native support with numeric id src_ds = gdal.OpenEx("""{ @@ -2457,9 +2213,7 @@ def test_ogr_geojson_45(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) return 'success' @@ -2485,9 +2239,7 @@ def test_ogr_geojson_46(): gdal.Unlink('/vsimem/ogr_geojson_46.json') - if data.find('{ "myprop": { "a": "b" } }') < 0: - print(data) - return 'fail' + assert data.find('{ "myprop": { "a": "b" } }') >= 0 return 'success' @@ -2502,8 +2254,7 @@ def test_ogr_geojson_47(): # ERROR 6: Update from inline definition not supported with gdaltest.error_handler(): ds = ogr.Open('{"type": "FeatureCollection", "features":[]}', update=1) - if ds is not None: - return 'fail' + assert ds is None gdal.FileFromMemBuffer('/vsimem/ogr_geojson_47.json', """{"type": "FeatureCollection", "foo": "bar", @@ -2525,11 +2276,9 @@ def test_ogr_geojson_47(): data = None # we don't want crs if there's no in the source - if data.find('"foo": "bar"') < 0 or data.find('"bar": "baz"') < 0 or \ - data.find('crs') >= 0 or \ - data.find('"myprop": "another_value"') < 0: - print(data) - return 'fail' + assert (data.find('"foo": "bar"') >= 0 and data.find('"bar": "baz"') >= 0 and \ + data.find('crs') < 0 and \ + data.find('"myprop": "another_value"') >= 0) # Test append support ds = ogr.Open('/vsimem/ogr_geojson_47.json', update=1) @@ -2561,8 +2310,7 @@ def test_ogr_geojson_47(): ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 4: - return 'fail' + assert lyr.GetFeatureCount() == 4 ds = None fp = gdal.VSIFOpenL('/vsimem/ogr_geojson_47.json', 'rb') @@ -2573,13 +2321,11 @@ def test_ogr_geojson_47(): data = None # we don't want crs if there's no in the source - if data.find('"foo": "bar"') < 0 or data.find('"bar": "baz"') < 0 or \ - data.find('crs') >= 0 or \ - data.find('"myprop": "another_value"') < 0 or \ - data.find('"myprop": "value_of_point_4_5"') < 0 or \ - data.find('id') >= 0: - print(data) - return 'fail' + assert (data.find('"foo": "bar"') >= 0 and data.find('"bar": "baz"') >= 0 and \ + data.find('crs') < 0 and \ + data.find('"myprop": "another_value"') >= 0 and \ + data.find('"myprop": "value_of_point_4_5"') >= 0 and \ + data.find('id') < 0) gdal.Unlink('/vsimem/ogr_geojson_47.json') @@ -2592,8 +2338,7 @@ def test_ogr_geojson_47(): ds = None ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 ds = None # Test appending to array ending with non feature @@ -2605,8 +2350,7 @@ def test_ogr_geojson_47(): ds = None ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 ds = None # Test appending to feature collection not ending with "features" @@ -2618,8 +2362,7 @@ def test_ogr_geojson_47(): ds = None ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 ds = None fp = gdal.VSIFOpenL('/vsimem/ogr_geojson_47.json', 'rb') @@ -2629,9 +2372,7 @@ def test_ogr_geojson_47(): else: data = None - if data.find('something') < 0: - print(data) - return 'fail' + assert data.find('something') >= 0 # Test appending to feature collection with "bbox" gdal.FileFromMemBuffer('/vsimem/ogr_geojson_47.json', """{ "type": "FeatureCollection", "bbox": [0,0,0,0], "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [0,0]} } ]}""") @@ -2642,8 +2383,7 @@ def test_ogr_geojson_47(): ds = None ds = ogr.Open('/vsimem/ogr_geojson_47.json') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 ds = None fp = gdal.VSIFOpenL('/vsimem/ogr_geojson_47.json', 'rb') @@ -2653,9 +2393,7 @@ def test_ogr_geojson_47(): else: data = None - if data.find('bbox') < 0: - print(data) - return 'fail' + assert data.find('bbox') >= 0 gdal.Unlink('/vsimem/ogr_geojson_47.json') @@ -2691,13 +2429,11 @@ def test_ogr_geojson_48(): gdal.Unlink('/vsimem/ogr_geojson_48.json') # we don't want crs if there's no in the source - if data.find('"bar": "baz"') < 0 or \ - data.find('"bbox": [ 3.0, 50.0, 3.0, 50.0 ]') < 0 or \ - data.find('crs') >= 0 or \ - data.find('FeatureCollection') >= 0 or \ - data.find('"myprop": "another_value"') < 0: - print(data) - return 'fail' + assert (data.find('"bar": "baz"') >= 0 and \ + data.find('"bbox": [ 3.0, 50.0, 3.0, 50.0 ]') >= 0 and \ + data.find('crs') < 0 and \ + data.find('FeatureCollection') < 0 and \ + data.find('"myprop": "another_value"') >= 0) return 'success' @@ -2715,8 +2451,7 @@ def test_ogr_geojson_49(): # Test read support ds = gdal.OpenEx('/vsimem/ogr_geojson_49.json', open_options=['ARRAY_AS_STRING=YES']) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetType() == ogr.OFTString f = lyr.GetNextFeature() if f['foo'] != '[ "bar" ]': f.DumpReadable() @@ -2754,9 +2489,7 @@ def test_ogr_geojson_50(): gdal.Unlink('/vsimem/ogr_geojson_50.json') - if data.find('1.23456789012456') < 0 and data.find('5268.813 ') < 0: - print(data) - return 'fail' + assert data.find('1.23456789012456') >= 0 or data.find('5268.813 ') >= 0 # If SIGNIFICANT_FIGURES is explicitly specified, and COORDINATE_PRECISION not, # then it also applies to coordinates @@ -2775,9 +2508,7 @@ def test_ogr_geojson_50(): gdal.Unlink('/vsimem/ogr_geojson_50.json') - if data.find('1.23456789012456') < 0 and data.find('-5') < 0: - print(data) - return 'fail' + assert data.find('1.23456789012456') >= 0 or data.find('-5') >= 0 # If SIGNIFICANT_FIGURES is explicitly specified, and COORDINATE_PRECISION too, # then SIGNIFICANT_FIGURES only applies to non-coordinates floating point values. @@ -2797,9 +2528,7 @@ def test_ogr_geojson_50(): gdal.Unlink('/vsimem/ogr_geojson_50.json') - if data.find('0.00001234') < 0 or data.find('1.23456789012456') < 0: - print(data) - return 'fail' + assert data.find('0.00001234') >= 0 and data.find('1.23456789012456') >= 0 return 'success' @@ -2851,33 +2580,19 @@ def test_ogr_geojson_51(): gdal.Unlink('/vsimem/ogr_geojson_51.json') - if data.find('{ "id": 1 }, "geometry": null') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 1 }, "geometry": null') >= 0 - if data.find('{ "id": 2 }, "geometry": { "type": "LineString", "coordinates": [ ] } }') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 2 }, "geometry": { "type": "LineString", "coordinates": [ ] } }') >= 0 - if data.find('{ "id": 3 }, "geometry": { "type": "Polygon", "coordinates": [ ] } }') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 3 }, "geometry": { "type": "Polygon", "coordinates": [ ] } }') >= 0 - if data.find('{ "id": 4 }, "geometry": { "type": "MultiPoint", "coordinates": [ ] } }') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 4 }, "geometry": { "type": "MultiPoint", "coordinates": [ ] } }') >= 0 - if data.find('{ "id": 5 }, "geometry": { "type": "MultiLineString", "coordinates": [ ] } }') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 5 }, "geometry": { "type": "MultiLineString", "coordinates": [ ] } }') >= 0 - if data.find('{ "id": 6 }, "geometry": { "type": "MultiPolygon", "coordinates": [ ] } }') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 6 }, "geometry": { "type": "MultiPolygon", "coordinates": [ ] } }') >= 0 - if data.find('{ "id": 7 }, "geometry": { "type": "GeometryCollection", "geometries": [ ] } }') < 0: - print(data) - return 'fail' + assert data.find('{ "id": 7 }, "geometry": { "type": "GeometryCollection", "geometries": [ ] } }') >= 0 return 'success' @@ -2890,34 +2605,22 @@ def test_ogr_geojson_52(): return 'skip' ds = ogr.Open('data/nullvalues.geojson') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' - if ds.GetLayerCount() is not 1: - gdaltest.post_reason('Wrong number of layers') - return 'fail' + assert ds.GetLayerCount() is 1, 'Wrong number of layers' lyr = ds.GetLayerByName('nullvalues') - if lyr is None: - gdaltest.post_reason('Missing layer called nullvalues') - return 'fail' + assert lyr is not None, 'Missing layer called nullvalues' fld = lyr.GetLayerDefn().GetFieldDefn(0) - if fld.GetNameRef() != 'int': - return 'fail' - if fld.GetType() != ogr.OFTInteger: - return 'fail' + assert fld.GetNameRef() == 'int' + assert fld.GetType() == ogr.OFTInteger fld = lyr.GetLayerDefn().GetFieldDefn(1) - if fld.GetNameRef() != 'string': - return 'fail' - if fld.GetType() != ogr.OFTString: - return 'fail' + assert fld.GetNameRef() == 'string' + assert fld.GetType() == ogr.OFTString fld = lyr.GetLayerDefn().GetFieldDefn(2) - if fld.GetNameRef() != 'double': - return 'fail' - if fld.GetType() != ogr.OFTReal: - return 'fail' + assert fld.GetNameRef() == 'double' + assert fld.GetType() == ogr.OFTReal return 'success' @@ -2942,9 +2645,7 @@ def test_ogr_geojson_53(): gdal.Unlink('/vsimem/ogr_geojson_53.json') - if data.find('{ "type": "Point", "coordinates": [ 1.0, 2.0, 3.0 ] }') < 0: - print(data) - return 'fail' + assert data.find('{ "type": "Point", "coordinates": [ 1.0, 2.0, 3.0 ] }') >= 0 return 'success' @@ -2968,27 +2669,19 @@ def test_ogr_geojson_54(): lyr = ds.GetLayer(0) fld = lyr.GetLayerDefn().GetFieldDefn(0) - if fld.GetType() != ogr.OFTInteger: - return 'fail' + assert fld.GetType() == ogr.OFTInteger fld = lyr.GetLayerDefn().GetFieldDefn(1) - if fld.GetType() != ogr.OFTString: - return 'fail' + assert fld.GetType() == ogr.OFTString fld = lyr.GetLayerDefn().GetFieldDefn(2) - if fld.GetType() != ogr.OFTReal: - return 'fail' + assert fld.GetType() == ogr.OFTReal fld = lyr.GetLayerDefn().GetFieldDefn(3) - if fld.GetType() != ogr.OFTDateTime: - return 'fail' + assert fld.GetType() == ogr.OFTDateTime fld = lyr.GetLayerDefn().GetFieldDefn(4) - if fld.GetType() != ogr.OFTInteger: - return 'fail' - if fld.GetSubType() != ogr.OFSTBoolean: - return 'fail' - if fld.GetWidth() != 1: - return 'fail' + assert fld.GetType() == ogr.OFTInteger + assert fld.GetSubType() == ogr.OFSTBoolean + assert fld.GetWidth() == 1 fld = lyr.GetLayerDefn().GetFieldDefn(5) - if fld.GetType() != ogr.OFTString: - return 'fail' + assert fld.GetType() == ogr.OFTString return 'success' ############################################################################### @@ -3028,9 +2721,7 @@ def test_ogr_geojson_55(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Test polygon winding order gdal.VectorTranslate('/vsimem/out.json', """{ @@ -3053,9 +2744,7 @@ def test_ogr_geojson_55(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Test foreign member src_ds = gdal.OpenEx("""{ @@ -3104,9 +2793,7 @@ def test_ogr_geojson_55(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) return 'success' @@ -3148,9 +2835,7 @@ def test_ogr_geojson_56(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Test geometries across the antimeridian gdal.VectorTranslate('/vsimem/out.json', """{ @@ -3178,9 +2863,7 @@ def test_ogr_geojson_56(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) return 'success' @@ -3215,9 +2898,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Polar case: EPSG:3995: WGS 84 / Arctic Polar Stereographic src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3244,9 +2925,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Polar case: slice of spherical cap (not intersecting antimeridian, west hemisphere) src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3269,9 +2948,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Polar case: slice of spherical cap (not intersecting antimeridian, east hemisphere) src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3294,9 +2971,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Polar case: slice of spherical cap crossing the antimeridian src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3319,9 +2994,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Polar case: EPSG:3031: WGS 84 / Antarctic Polar Stereographic src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3344,9 +3017,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) # Antimeridian case: EPSG:32660: WGS 84 / UTM zone 60N with polygon and line crossing src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3390,9 +3061,7 @@ def test_ogr_geojson_57(): } """ - if json.loads(got) != json.loads(expected) and json.loads(got) != json.loads(expected2): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) or json.loads(got) == json.loads(expected2) # Antimeridian case: EPSG:32660: WGS 84 / UTM zone 60N wit polygon on west of antimeridian src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0) @@ -3415,9 +3084,7 @@ def test_ogr_geojson_57(): ] } """ - if json.loads(got) != json.loads(expected): - print(got) - return 'fail' + assert json.loads(got) == json.loads(expected) return 'success' @@ -3430,23 +3097,17 @@ def test_ogr_geojson_58(): return 'skip' ds = ogr.Open('{ "type": "FeatureCollection", "name": "layer_name", "features": []}') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayerByName('layer_name') - if lyr is None: - gdaltest.post_reason('Missing layer called layer_name') - return 'fail' + assert lyr is not None, 'Missing layer called layer_name' ds = None ds = ogr.GetDriverByName('GeoJSON').CreateDataSource('/vsimem/ogr_geojson_58.json') lyr = ds.CreateLayer('foo') ds = None ds = ogr.Open('/vsimem/ogr_geojson_58.json') - if ds.GetLayerByName('foo') is None: - gdaltest.post_reason('Missing layer called foo') - return 'fail' + assert ds.GetLayerByName('foo') is not None, 'Missing layer called foo' ds = None gdal.Unlink('/vsimem/ogr_geojson_58.json') @@ -3461,14 +3122,11 @@ def test_ogr_geojson_59(): return 'skip' ds = ogr.Open('{ "type": "FeatureCollection", "description": "my_description", "features": []}') - if ds is None: - gdaltest.post_reason('Failed to open datasource') - return 'fail' + assert ds is not None, 'Failed to open datasource' lyr = ds.GetLayer(0) - if lyr.GetMetadataItem('DESCRIPTION') != 'my_description': - gdaltest.post_reason('Did not get DESCRIPTION') - return 'fail' + assert lyr.GetMetadataItem('DESCRIPTION') == 'my_description', \ + 'Did not get DESCRIPTION' ds = None ds = ogr.GetDriverByName('GeoJSON').CreateDataSource('/vsimem/ogr_geojson_59.json') @@ -3476,9 +3134,7 @@ def test_ogr_geojson_59(): ds = None ds = ogr.Open('/vsimem/ogr_geojson_59.json') lyr = ds.GetLayerByName('foo') - if lyr.GetMetadataItem('DESCRIPTION') != 'my desc': - gdaltest.post_reason('Did not get DESCRIPTION') - return 'fail' + assert lyr.GetMetadataItem('DESCRIPTION') == 'my desc', 'Did not get DESCRIPTION' ds = None gdal.Unlink('/vsimem/ogr_geojson_59.json') @@ -3518,11 +3174,9 @@ def test_ogr_geojson_60(): gdal.VSIFCloseL(fp) gdal.Unlink('/vsimem/ogr_geojson_60.json') - if data.find('"properties": { "foo": "bar" }') < 0 or \ - data.find('"properties": { "foo": null }') < 0 or \ - data.find('"properties": { }') < 0: - print(data) - return 'fail' + assert (data.find('"properties": { "foo": "bar" }') >= 0 and \ + data.find('"properties": { "foo": null }') >= 0 and \ + data.find('"properties": { }') >= 0) return 'success' @@ -3537,15 +3191,13 @@ def test_ogr_geojson_61(): """{ "type": "FeatureCollection", "features": [""") with gdaltest.error_handler(): ds = gdal.OpenEx('/vsimem/ogr_geojson_61.json') - if ds is not None: - return 'fail' + assert ds is None gdal.Unlink('/vsimem/ogr_geojson_61.json') # Invalid single geometry with gdaltest.error_handler(): ds = gdal.OpenEx("""{ "type": "Point", "x" : { "coordinates" : null } } """) - if ds is not None: - return 'fail' + assert ds is None # Empty property name gdal.FileFromMemBuffer('/vsimem/ogr_geojson_61.json', @@ -3553,8 +3205,7 @@ def test_ogr_geojson_61(): ds = gdal.OpenEx('/vsimem/ogr_geojson_61.json') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f.GetField("") != 1: - return 'fail' + assert f.GetField("") == 1 ds = None gdal.Unlink('/vsimem/ogr_geojson_61.json') @@ -3582,8 +3233,7 @@ def test_ogr_geojson_62(): ds = gdal.OpenEx("""{ "type": "FeatureCollection", "crs": { "type":"name", "properties":{"name": "urn:ogc:def:crs:EPSG::32631"} }, "features":[] }""") lyr = ds.GetLayer(0) srs = lyr.GetSpatialRef() - if srs.ExportToWkt().find('32631') < 0: - return 'fail' + assert srs.ExportToWkt().find('32631') >= 0 # crs type=EPSG (not even documented in GJ2008 spec!) tests. Just for coverage completeness gdal.OpenEx("""{ "type": "FeatureCollection", "crs": { "type":"EPSG" }, "features":[] }""") @@ -3603,8 +3253,7 @@ def test_ogr_geojson_62(): ds = gdal.OpenEx("""{ "type": "FeatureCollection", "crs": { "type":"EPSG", "properties":{"code": 32631} }, "features":[] }""") lyr = ds.GetLayer(0) srs = lyr.GetSpatialRef() - if srs.ExportToWkt().find('32631') < 0: - return 'fail' + assert srs.ExportToWkt().find('32631') >= 0 # crs type=link tests gdal.OpenEx("""{ "type": "FeatureCollection", "crs": { "type":"link" }, "features":[] }""") @@ -3639,8 +3288,7 @@ def test_ogr_geojson_62(): ds = gdal.OpenEx("""{ "type": "FeatureCollection", "crs": { "type":"OGC", "properties":{"urn": "urn:ogc:def:crs:EPSG::32631"} }, "features":[] }""") lyr = ds.GetLayer(0) srs = lyr.GetSpatialRef() - if srs.ExportToWkt().find('32631') < 0: - return 'fail' + assert srs.ExportToWkt().find('32631') >= 0 return 'success' @@ -3663,24 +3311,20 @@ def test_ogr_geojson_63(): def test_ogr_geojson_64(): g = ogr.CreateGeometryFromWkt('POINT ZM(1 2 3 4)') - if ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), - ogr.CreateGeometryFromWkt('POINT Z(1 2 3)')) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), + ogr.CreateGeometryFromWkt('POINT Z(1 2 3)')) == 0) g = ogr.CreateGeometryFromWkt('POINT M(1 2 3)') - if ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), - ogr.CreateGeometryFromWkt('POINT (1 2)')) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), + ogr.CreateGeometryFromWkt('POINT (1 2)')) == 0) g = ogr.CreateGeometryFromWkt('LINESTRING ZM(1 2 3 4,5 6 7 8)') - if ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), - ogr.CreateGeometryFromWkt('LINESTRING Z(1 2 3,5 6 7)')) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), + ogr.CreateGeometryFromWkt('LINESTRING Z(1 2 3,5 6 7)')) == 0) g = ogr.CreateGeometryFromWkt('LINESTRING M(1 2 3,4 5 6)') - if ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), - ogr.CreateGeometryFromWkt('LINESTRING (1 2,4 5)')) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(ogr.CreateGeometryFromJson(g.ExportToJson()), + ogr.CreateGeometryFromWkt('LINESTRING (1 2,4 5)')) == 0) return 'success' @@ -3705,9 +3349,7 @@ def test_ogr_geojson_65(): f = lyr.GetNextFeature() srs = f.GetGeometryRef().GetSpatialReference() pcs = int(srs.GetAuthorityCode('PROJCS')) - if pcs != 32631: - gdaltest.post_reason('Spatial reference for individual geometry was not valid') - return 'fail' + assert pcs == 32631, 'Spatial reference for individual geometry was not valid' return 'success' @@ -3732,8 +3374,7 @@ def test_ogr_geojson_66(): } ]}""") lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 0 return 'success' @@ -3744,13 +3385,10 @@ def test_ogr_geojson_66(): def test_ogr_geojson_67(): ds = ogr.Open('data/grenada.geojson') - if ds is None: - return 'fail' - if ds.GetDriver().GetName() != 'GeoJSON': - return 'fail' + assert ds is not None + assert ds.GetDriver().GetName() == 'GeoJSON' lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 return 'success' @@ -3760,13 +3398,10 @@ def test_ogr_geojson_67(): def test_ogr_geojson_68(): ds = ogr.Open('data/esrijsonstartingwithfeaturesgeometry.json') - if ds is None: - return 'fail' - if ds.GetDriver().GetName() != 'ESRIJSON': - return 'fail' + assert ds is not None + assert ds.GetDriver().GetName() == 'ESRIJSON' lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 return 'success' ############################################################################### @@ -3776,99 +3411,75 @@ def test_ogr_geojson_id_field_and_id_type(): gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', options='-f GeoJSON -lco ID_TYPE=String -preserve_fid -limit 1 -fid 2') got = read_file('/vsimem/out.json') - if got.find('"id": "2", "properties": { "AREA": 261752.781, "EAS_ID": 171, "PRFEDEA": "35043414" }') < 0: - print(got) - return 'fail' + assert got.find('"id": "2", "properties": { "AREA": 261752.781, "EAS_ID": 171, "PRFEDEA": "35043414" }') >= 0 gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', options='-f GeoJSON -lco ID_TYPE=Integer -preserve_fid -limit 1 -fid 2') got = read_file('/vsimem/out.json') - if got.find('"id": 2, "properties": { "AREA": 261752.781, "EAS_ID": 171, "PRFEDEA": "35043414" }') < 0: - print(got) - return 'fail' + assert got.find('"id": 2, "properties": { "AREA": 261752.781, "EAS_ID": 171, "PRFEDEA": "35043414" }') >= 0 gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', format='GeoJSON', layerCreationOptions=['ID_FIELD=EAS_ID'], limit=1) got = read_file('/vsimem/out.json') - if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 src_ds = gdal.OpenEx('/vsimem/out.json', open_options=['NATIVE_DATA=YES']) gdal.VectorTranslate('/vsimem/out2.json', src_ds, format='GeoJSON') src_ds = None got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') - if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 src_ds = gdal.OpenEx('/vsimem/out.json', open_options=['NATIVE_DATA=YES']) gdal.VectorTranslate('/vsimem/out2.json', src_ds, format='GeoJSON', layerCreationOptions=['ID_TYPE=String']) src_ds = None got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') - if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 src_ds = gdal.OpenEx('/vsimem/out.json', open_options=['NATIVE_DATA=YES']) gdal.VectorTranslate('/vsimem/out2.json', src_ds, format='GeoJSON', layerCreationOptions=['ID_TYPE=Integer']) src_ds = None got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') - if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 gdal.Unlink('/vsimem/out.json') gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', format='GeoJSON', layerCreationOptions=['ID_FIELD=EAS_ID', 'ID_TYPE=String'], limit=1) got = read_file('/vsimem/out.json') - if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 src_ds = gdal.OpenEx('/vsimem/out.json', open_options=['NATIVE_DATA=YES']) gdal.VectorTranslate('/vsimem/out2.json', src_ds, format='GeoJSON') src_ds = None got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') - if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 src_ds = gdal.OpenEx('/vsimem/out.json', open_options=['NATIVE_DATA=YES']) gdal.VectorTranslate('/vsimem/out2.json', src_ds, format='GeoJSON', layerCreationOptions=['ID_TYPE=String']) src_ds = None got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') - if got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": "168", "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 src_ds = gdal.OpenEx('/vsimem/out.json', open_options=['NATIVE_DATA=YES']) gdal.VectorTranslate('/vsimem/out2.json', src_ds, format='GeoJSON', layerCreationOptions=['ID_TYPE=Integer']) src_ds = None got = read_file('/vsimem/out2.json') gdal.Unlink('/vsimem/out2.json') - if got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') < 0: - print(got) - return 'fail' + assert got.find('"id": 168, "properties": { "AREA": 215229.266, "PRFEDEA": "35043411" }') >= 0 gdal.Unlink('/vsimem/out.json') gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', format='GeoJSON', layerCreationOptions=['ID_FIELD=PRFEDEA'], limit=1) got = read_file('/vsimem/out.json') gdal.Unlink('/vsimem/out.json') - if got.find('"id": "35043411", "properties": { "AREA": 215229.266, "EAS_ID": 168 }') < 0: - print(got) - return 'fail' + assert got.find('"id": "35043411", "properties": { "AREA": 215229.266, "EAS_ID": 168 }') >= 0 gdal.VectorTranslate('/vsimem/out.json', 'data/poly.shp', format='GeoJSON', layerCreationOptions=['ID_FIELD=PRFEDEA', 'ID_TYPE=Integer'], limit=1) got = read_file('/vsimem/out.json') gdal.Unlink('/vsimem/out.json') - if got.find('"id": 35043411, "properties": { "AREA": 215229.266, "EAS_ID": 168 }') < 0: - print(got) - return 'fail' + assert got.find('"id": 35043411, "properties": { "AREA": 215229.266, "EAS_ID": 168 }') >= 0 return 'success' @@ -3879,23 +3490,17 @@ def test_ogr_geojson_geom_export_failure(): g = ogr.CreateGeometryFromWkt('POINT EMPTY') geojson = g.ExportToJson() - if geojson is not None: - print(geojson) - return 'fail' + assert geojson is None g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(TIN EMPTY)') geojson = json.loads(g.ExportToJson()) - if geojson != {"type": "GeometryCollection", "geometries": None}: - print(geojson) - return 'fail' + assert geojson == {"type": "GeometryCollection", "geometries": None} g = ogr.Geometry(ogr.wkbLineString) g.AddPoint_2D(float('nan'), 0) with gdaltest.error_handler(): geojson = g.ExportToJson() - if geojson is not None: - print(geojson) - return 'fail' + assert geojson is None g = ogr.Geometry(ogr.wkbPolygon) lr = ogr.Geometry(ogr.wkbLinearRing) @@ -3912,9 +3517,7 @@ def test_ogr_geojson_geom_export_failure(): g.AddGeometry(lr) with gdaltest.error_handler(): geojson = g.ExportToJson() - if geojson is not None: - print(geojson) - return 'fail' + assert geojson is None return 'success' @@ -3933,8 +3536,7 @@ def test_ogr_geojson_starting_with_crs(): "coordinates": [500000,4500000]}, "properties": { }}]}""") - if ds is None: - return 'fail' + assert ds is not None return 'success' @@ -3964,8 +3566,7 @@ def test_ogr_geojson_append_flush(): lyr = ds2.GetLayer(0) lyr.GetNextFeature() f = lyr.GetNextFeature() - if f is None or f['x'] != 10: - return 'fail' + assert f is not None and f['x'] == 10 ds = None ds2 = None @@ -3980,9 +3581,7 @@ def test_ogr_geojson_append_flush(): def test_ogr_geojson_empty_geometrycollection(): g = ogr.CreateGeometryFromJson('{"type": "GeometryCollection", "geometries": []}') - if g.ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION EMPTY' return 'success' @@ -4011,8 +3610,7 @@ def test_ogr_esrijson_without_geometryType(): """) lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f.GetGeometryRef() is None: - return 'fail' + assert f.GetGeometryRef() is not None return 'success' @@ -4101,9 +3699,7 @@ def test_ogr_geojson_non_finite(): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() for i in range(3): - if lyr.GetLayerDefn().GetFieldDefn(i).GetType() != ogr.OFTReal: - print(i) - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(i).GetType() == ogr.OFTReal if f['inf_prop'] != float('inf'): f.DumpReadable() @@ -4123,15 +3719,13 @@ def test_ogr_geojson_non_finite(): gdal.VectorTranslate(tmpfilename, json_content, options='-f GeoJSON') ds = ogr.Open(tmpfilename) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 0 ds = None gdal.VectorTranslate(tmpfilename, json_content, options='-f GeoJSON -lco WRITE_NON_FINITE_VALUES=YES') ds = ogr.Open(tmpfilename) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 3: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 3 f = lyr.GetNextFeature() if f['inf_prop'] != float('inf'): f.DumpReadable() diff --git a/autotest/ogr/ogr_geojsonseq.py b/autotest/ogr/ogr_geojsonseq.py index 2b41c676eeb5..d44f340c28b7 100755 --- a/autotest/ogr/ogr_geojsonseq.py +++ b/autotest/ogr/ogr_geojsonseq.py @@ -56,12 +56,10 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(3 4)')) lyr.CreateFeature(f) - if ds.TestCapability(ogr.ODsCCreateLayer): - return 'fail' + assert not ds.TestCapability(ogr.ODsCCreateLayer) with gdaltest.error_handler(): - if ds.CreateLayer('foo') is not None: - return 'fail' + assert ds.CreateLayer('foo') is None ds = None @@ -69,11 +67,9 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): first = gdal.VSIFReadL(1, 1, f).decode('ascii') gdal.VSIFCloseL(f) if expect_rs: - if first != '\x1e': - return 'fail' + assert first == '\x1e' else: - if first != '{': - return 'fail' + assert first == '{' ds = ogr.Open(filename) lyr = ds.GetLayer(0) @@ -86,8 +82,7 @@ def _ogr_geojsonseq_create(filename, lco, expect_rs): if f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 4)': f.DumpReadable() return 'fail' - if lyr.GetNextFeature() is not None: - return 'fail' + assert lyr.GetNextFeature() is None ds = None ogr.GetDriverByName('GeoJSONSeq').DeleteDataSource(filename) @@ -112,9 +107,7 @@ def test_ogr_geojsonseq_inline(): ds = ogr.Open("""{"type":"Feature","properties":{},"geometry":null} {"type":"Feature","properties":{},"geometry":null}""") lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 2 return 'success' @@ -122,9 +115,7 @@ def test_ogr_geojsonseq_prefix(): ds = ogr.Open("""GeoJSONSeq:data/test.geojsonl""") lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 2 return 'success' @@ -134,9 +125,7 @@ def test_ogr_geojsonseq_seq_geometries(): ds = ogr.Open("""{"type":"Point","coordinates":[2,49]} {"type":"Point","coordinates":[3,50]}""") lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 2 f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': f.DumpReadable() @@ -185,8 +174,7 @@ def test_ogr_geojsonseq_read_rs_json_pretty(): if f['foo'] != 'baz' or f.GetGeometryRef().ExportToWkt() != 'POINT (3 4)': f.DumpReadable() return 'fail' - if lyr.GetNextFeature() is not None: - return 'fail' + assert lyr.GetNextFeature() is None return 'success' @@ -199,9 +187,7 @@ def test_ogr_geojsonseq_test_ogrsf(): ret = gdaltest.runexternal( test_cli_utilities.get_test_ogrsf_path() + ' -ro data/test.geojsonl') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' diff --git a/autotest/ogr/ogr_geom.py b/autotest/ogr/ogr_geom.py index 3c53c137b30e..2db39eded9d0 100755 --- a/autotest/ogr/ogr_geom.py +++ b/autotest/ogr/ogr_geom.py @@ -38,6 +38,7 @@ from osgeo import ogr from osgeo import osr from osgeo import gdal +import pytest ############################################################################### # Test Area calculation for a MultiPolygon (which exercises lower level @@ -50,15 +51,11 @@ def test_ogr_geom_area(): geom = ogr.CreateGeometryFromWkt(geom_wkt) area = geom.GetArea() - if abs(area - 99.5) > 0.00000000001: - gdaltest.post_reason('GetArea() result wrong, got %g.' % area) - return 'fail' + assert abs(area - 99.5) <= 0.00000000001, ('GetArea() result wrong, got %g.' % area) # OGR >= 1.8.0 area = geom.Area() - if abs(area - 99.5) > 0.00000000001: - gdaltest.post_reason('Area() result wrong, got %g.' % area) - return 'fail' + assert abs(area - 99.5) <= 0.00000000001, ('Area() result wrong, got %g.' % area) return 'success' @@ -77,9 +74,7 @@ def test_ogr_geom_area_linearring(): geom.AddPoint_2D(0, 0) area = geom.GetArea() - if abs(area - 100.0) > 0.00000000001: - gdaltest.post_reason('Area result wrong, got %g.' % area) - return 'fail' + assert abs(area - 100.0) <= 0.00000000001, ('Area result wrong, got %g.' % area) return 'success' @@ -94,9 +89,7 @@ def test_ogr_geom_area_geometrycollection(): geom = ogr.CreateGeometryFromWkt(geom_wkt) area = geom.Area() - if abs(area - 1) > 0.00000000001: - gdaltest.post_reason('Area() result wrong, got %g.' % area) - return 'fail' + assert abs(area - 1) <= 0.00000000001, ('Area() result wrong, got %g.' % area) return 'success' @@ -116,9 +109,7 @@ def test_ogr_geom_area_linearring_big_offset(): geom.AddPoint_2D(BIGOFFSET + 0, BIGOFFSET + 0) area = geom.GetArea() - if abs(area - 100.0) > 0.00000000001: - gdaltest.post_reason('Area result wrong, got %g.' % area) - return 'fail' + assert abs(area - 100.0) <= 0.00000000001, ('Area result wrong, got %g.' % area) return 'success' @@ -132,15 +123,12 @@ def test_ogr_geom_area_triangle(): geom = ogr.CreateGeometryFromWkt(geom_wkt) area = geom.GetArea() - if abs(area - 4999.5) < 0.00000000001: - gdaltest.post_reason('GetArea() result wrong, got %g.' % area) - return 'fail' + assert abs(area - 4999.5) >= 0.00000000001, \ + ('GetArea() result wrong, got %g.' % area) # OGR >= 1.8.0 area = geom.Area() - if abs(area - 4999.5) < 0.00000000001: - gdaltest.post_reason('Area() result wrong, got %g.' % area) - return 'fail' + assert abs(area - 4999.5) >= 0.00000000001, ('Area() result wrong, got %g.' % area) return 'success' @@ -150,19 +138,13 @@ def test_ogr_geom_is_empty(): geom_wkt = 'LINESTRING EMPTY' geom = ogr.CreateGeometryFromWkt(geom_wkt) - if not geom.IsEmpty(): - gdaltest.post_reason("IsEmpty returning false for an empty geometry") - return 'fail' + assert geom.IsEmpty(), "IsEmpty returning false for an empty geometry" geom_wkt = 'POINT( 1 2 )' geom = ogr.CreateGeometryFromWkt(geom_wkt) - if not geom: - gdaltest.post_reason("A geometry could not be created from wkt: %s" % geom_wkt) - return 'fail' + assert geom, ("A geometry could not be created from wkt: %s" % geom_wkt) - if geom.IsEmpty(): - gdaltest.post_reason("IsEmpty returning true for a non-empty geometry") - return 'fail' + assert not geom.IsEmpty(), "IsEmpty returning true for a non-empty geometry" return 'success' ############################################################################### @@ -174,26 +156,18 @@ def test_ogr_geom_is_empty_triangle(): geom_wkt = 'TRIANGLE EMPTY' geom = ogr.CreateGeometryFromWkt(geom_wkt) - if not geom.IsEmpty(): - gdaltest.post_reason("IsEmpty returning false for an empty geometry") - return 'fail' + assert geom.IsEmpty(), "IsEmpty returning false for an empty geometry" geom = ogr.CreateGeometryFromWkb(geom.ExportToWkb()) - if not geom.IsEmpty(): - gdaltest.post_reason("IsEmpty returning false for an empty geometry") - return 'fail' + assert geom.IsEmpty(), "IsEmpty returning false for an empty geometry" geom_wkt = 'TRIANGLE((0 0,100 0,0 100,0 0))' geom = ogr.CreateGeometryFromWkt(geom_wkt) - if not geom: - gdaltest.post_reason("A geometry could not be created from wkt: %s" % geom_wkt) - return 'fail' + assert geom, ("A geometry could not be created from wkt: %s" % geom_wkt) - if geom.IsEmpty(): - gdaltest.post_reason("IsEmpty returning true for a non-empty geometry") - return 'fail' + assert not geom.IsEmpty(), "IsEmpty returning true for a non-empty geometry" return 'success' @@ -204,9 +178,7 @@ def test_ogr_geom_pickle(): with gdaltest.error_handler(): g = pickle.loads(p) - if not geom.Equal(g): - gdaltest.post_reason("pickled geometries were not equal") - return 'fail' + assert geom.Equal(g), "pickled geometries were not equal" return 'success' @@ -227,35 +199,23 @@ def test_ogr_geom_polyhedral_surface(): wkb_string = ps.ExportToWkb(ogr.wkbXDR) geom = ogr.CreateGeometryFromWkb(wkb_string) wkt_string = geom.ExportToWkt() - if wkt_string != wkt_original: - gdaltest.post_reason("Failure in Wkb methods of PolyhedralSurface") - return 'fail' + assert wkt_string == wkt_original, "Failure in Wkb methods of PolyhedralSurface" wkt_string = geom.Clone().ExportToWkt() - if wkt_string != wkt_original: - gdaltest.post_reason("Failure in Clone()") - return 'fail' + assert wkt_string == wkt_original, "Failure in Clone()" polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbPolygon).ExportToWkt() - if polygon_wkt != wkt_original: - print(polygon_wkt) - return 'fail' + assert polygon_wkt == wkt_original polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbMultiPolygon).ExportToWkt() - if polygon_wkt != 'MULTIPOLYGON (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))': - print(polygon_wkt) - return 'fail' + assert polygon_wkt == 'MULTIPOLYGON (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))' if ogrtest.have_sfcgal(): area = ps.Area() - if area != 6.0: - gdaltest.post_reason("Wrong area of PolyhedralSurface") - return 'fail' + assert area == 6.0, "Wrong area of PolyhedralSurface" size = ps.WkbSize() - if size != 807: - gdaltest.post_reason("Wrong WkbSize() of PolyhedralSurface") - return 'fail' + assert size == 807, "Wrong WkbSize() of PolyhedralSurface" # if ogrtest.have_sfcgal(): # geom = ps.DelaunayTriangulation(0.0,True) @@ -268,23 +228,17 @@ def test_ogr_geom_polyhedral_surface(): if ogrtest.have_geos() or ogrtest.have_sfcgal(): geom = ogr.CreateGeometryFromWkb(wkb_string) - if not ps.Contains(geom): - gdaltest.post_reason("Failure in Contains() of PolyhedralSurface") - return 'fail' + assert ps.Contains(geom), "Failure in Contains() of PolyhedralSurface" - if ps.IsEmpty(): - gdaltest.post_reason("Failure in IsEmpty() of PolyhedralSurface") - return 'fail' + assert not ps.IsEmpty(), "Failure in IsEmpty() of PolyhedralSurface" ps.Empty() wkt_string = ps.ExportToWkt() - if wkt_string != 'POLYHEDRALSURFACE Z EMPTY': - gdaltest.post_reason("Failure in Empty() of PolyhedralSurface") - return 'fail' + assert wkt_string == 'POLYHEDRALSURFACE Z EMPTY', \ + "Failure in Empty() of PolyhedralSurface" g = ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)))') - if g.Equals(g) == 0: - return 'fail' + assert g.Equals(g) != 0 for wkt in ['MULTIPOLYGON (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)))', 'POLYHEDRALSURFACE (((0 0 0,0 0 1,0 1 1,0 0 0)))', @@ -292,26 +246,21 @@ def test_ogr_geom_polyhedral_surface(): 'POLYHEDRALSURFACE EMPTY']: g2 = ogr.CreateGeometryFromWkt(wkt) if g.Equals(g2): - gdaltest.post_reason("Unexpected true Equals() return") print(wkt) - return 'fail' + pytest.fail("Unexpected true Equals() return") # Error - if g.AddGeometry(ogr.CreateGeometryFromWkt('POINT (0 0)')) == 0: - return 'fail' + assert g.AddGeometry(ogr.CreateGeometryFromWkt('POINT (0 0)')) != 0 # Error - if g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('POINT (0 0)')) == 0: - return 'fail' + assert g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('POINT (0 0)')) != 0 # Test dimension promotion g = ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE EMPTY') g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('POLYGON ZM ((0 0 1 2,0 1 1 2,1 1 1 2,0 0 1 2))')) g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('POLYGON ((10 10,10 11,11 11,10 10))')) wkt = g.ExportToIsoWkt() - if wkt != 'POLYHEDRALSURFACE ZM (((0 0 1 2,0 1 1 2,1 1 1 2,0 0 1 2)),((10 10 0 0,10 11 0 0,11 11 0 0,10 10 0 0)))': - print(wkt) - return 'fail' + assert wkt == 'POLYHEDRALSURFACE ZM (((0 0 1 2,0 1 1 2,1 1 1 2,0 0 1 2)),((10 10 0 0,10 11 0 0,11 11 0 0,10 10 0 0)))' return 'success' @@ -329,9 +278,7 @@ def test_ogr_geom_tin(): for i in range(0, tin.GetGeometryCount()): geom = tin.GetGeometryRef(i) wkt_geom = geom.ExportToWkt() - if polygon_wkt[i] != wkt_geom: - gdaltest.post_reason("Failure in getting geometries of TIN") - return 'fail' + assert polygon_wkt[i] == wkt_geom, "Failure in getting geometries of TIN" wkt_original = 'TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,0 0 0)))' tin = ogr.CreateGeometryFromWkt(wkt_original) @@ -339,25 +286,17 @@ def test_ogr_geom_tin(): wkb_string = tin.ExportToWkb(ogr.wkbXDR) geom = ogr.CreateGeometryFromWkb(wkb_string) wkt_string = geom.ExportToWkt() - if wkt_string != wkt_original: - gdaltest.post_reason("Failure in Wkb methods of TIN") - return 'fail' + assert wkt_string == wkt_original, "Failure in Wkb methods of TIN" wkt_string = geom.Clone().ExportToWkt() - if wkt_string != wkt_original: - gdaltest.post_reason("Failure in Clone()") - return 'fail' + assert wkt_string == wkt_original, "Failure in Clone()" if ogrtest.have_sfcgal(): area = 12.3 * tin.Area() - if area != 12.3: - gdaltest.post_reason("Wrong area of TIN") - return 'fail' + assert area == 12.3, "Wrong area of TIN" size = tin.WkbSize() - if size != 227: - gdaltest.post_reason("Wrong WkbSize() of TIN") - return 'fail' + assert size == 227, "Wrong WkbSize() of TIN" # geom = tin.DelaunayTriangulation(0.0,True) # wkt_geom_dt = 'MULTILINESTRING ((0 1 0,1 1 0),(0 0 0,0 1 0),(0 0 0,1 1 0))' @@ -372,33 +311,26 @@ def test_ogr_geom_tin(): # gdaltest.post_reason ("Failure in Contains() of TIN") # return 'fail' - if tin.IsEmpty(): - gdaltest.post_reason("Failure in IsEmpty() of TIN") - return 'fail' + assert not tin.IsEmpty(), "Failure in IsEmpty() of TIN" tin.Empty() wkt_string = tin.ExportToWkt() - if wkt_string != 'TIN Z EMPTY': - gdaltest.post_reason("Failure in Empty() of TIN") - return 'fail' + assert wkt_string == 'TIN Z EMPTY', "Failure in Empty() of TIN" wrong_polygon = ogr.CreateGeometryFromWkt('POLYGON ((0 0 0,0 1 0,1 1 0,0 0 1))') geom_count = tin.GetGeometryCount() gdal.PushErrorHandler('CPLQuietErrorHandler') x = tin.AddGeometry(wrong_polygon) gdal.PopErrorHandler() - if tin.GetGeometryCount() != geom_count: - gdaltest.post_reason("Added wrong geometry in TIN, error has code " + str(x)) - return 'fail' + assert tin.GetGeometryCount() == geom_count, \ + ("Added wrong geometry in TIN, error has code " + str(x)) if ogrtest.have_geos() or ogrtest.have_sfcgal(): point = tin.PointOnSurface() point_wkt = point.ExportToWkt() point_correct_wkt = 'POINT EMPTY' - if point_wkt != point_correct_wkt: - gdaltest.post_reason("Wrong Point Obtained for PointOnSurface() in TIN") - print(point_wkt) - return 'fail' + assert point_wkt == point_correct_wkt, \ + "Wrong Point Obtained for PointOnSurface() in TIN" tin = ogr.CreateGeometryFromWkt(wkt_original) # point = tin.PointOnSurface() @@ -410,36 +342,29 @@ def test_ogr_geom_tin(): # return 'fail' tin.FlattenTo2D() - if tin.IsValid(): - gdaltest.post_reason("Problem with IsValid() in TIN") - return 'fail' + assert not tin.IsValid(), "Problem with IsValid() in TIN" # 4 points invalid_wkt = 'TIN (((0 0,0 1,1 1,1 0,0 0)))' with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt(invalid_wkt) - if g is not None: - return 'fail' + assert g is None # hole invalid_wkt = 'TIN(((0 0,0 1,1 1,0 0),(0.1 0.1,0.1 0.2,0.2 0.2,0.1 0.1)))' with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt(invalid_wkt) - if g is not None: - return 'fail' + assert g is None invalid_wkt = 'TIN (POLYGON((0 0,0 1,1 1,0 0)))' with gdaltest.error_handler(): g = ogr.CreateGeometryFromWkt(invalid_wkt) - if g is not None: - return 'fail' + assert g is None # Add a POLYGON that can be cast as a TRIANGLE g = ogr.Geometry(ogr.wkbTIN) - if g.AddGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,0 0))')) != 0: - return 'fail' - if g.ExportToIsoWkt() != 'TIN (((0 0,0 1,1 1,0 0)))': - return 'fail' + assert g.AddGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,0 0))')) == 0 + assert g.ExportToIsoWkt() == 'TIN (((0 0,0 1,1 1,0 0)))' return 'success' @@ -456,14 +381,12 @@ def test_ogr_geom_boundary_point(): geom = ogr.CreateGeometryFromWkt(geom_wkt) bnd = geom.GetBoundary() - if bnd.GetGeometryType() != ogr.wkbGeometryCollection: - gdaltest.post_reason('GetBoundary not reported as GEOMETRYCOLLECTION EMPTY') - return 'fail' + assert bnd.GetGeometryType() == ogr.wkbGeometryCollection, \ + 'GetBoundary not reported as GEOMETRYCOLLECTION EMPTY' bnd = geom.Boundary() - if bnd.GetGeometryType() != ogr.wkbGeometryCollection: - gdaltest.post_reason('Boundary not reported as GEOMETRYCOLLECTION EMPTY') - return 'fail' + assert bnd.GetGeometryType() == ogr.wkbGeometryCollection, \ + 'Boundary not reported as GEOMETRYCOLLECTION EMPTY' return 'success' @@ -480,9 +403,8 @@ def test_ogr_geom_boundary_multipoint(): geom = ogr.CreateGeometryFromWkt(geom_wkt) bnd = geom.GetBoundary() - if bnd.GetGeometryType() != ogr.wkbGeometryCollection: - gdaltest.post_reason('Boundary not reported as GEOMETRYCOLLECTION EMPTY') - return 'fail' + assert bnd.GetGeometryType() == ogr.wkbGeometryCollection, \ + 'Boundary not reported as GEOMETRYCOLLECTION EMPTY' return 'success' @@ -499,26 +421,20 @@ def test_ogr_geom_boundary_linestring(): geom = ogr.CreateGeometryFromWkt(geom_wkt) bnd = geom.GetBoundary() - if bnd.GetGeometryType() != ogr.wkbMultiPoint: - gdaltest.post_reason('Boundary not reported as MULTIPOINT') - print(bnd) - return 'fail' + assert bnd.GetGeometryType() == ogr.wkbMultiPoint, \ + 'Boundary not reported as MULTIPOINT' - if bnd.GetGeometryCount() != 2: - gdaltest.post_reason('Boundary not reported as MULTIPOINT consisting of 2 points') - return 'fail' + assert bnd.GetGeometryCount() == 2, \ + 'Boundary not reported as MULTIPOINT consisting of 2 points' geom_wkt = 'LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)' geom = ogr.CreateGeometryFromWkt(geom_wkt) bnd = geom.GetBoundary() - if bnd.GetGeometryType() != ogr.wkbMultiPoint: - gdaltest.post_reason('Boundary not reported as MULTIPOINT') - return 'fail' + assert bnd.GetGeometryType() == ogr.wkbMultiPoint, \ + 'Boundary not reported as MULTIPOINT' - if bnd.GetGeometryCount() != 0: - gdaltest.post_reason('Boundary not reported as MULTIPOINT EMPTY') - return 'fail' + assert bnd.GetGeometryCount() == 0, 'Boundary not reported as MULTIPOINT EMPTY' return 'success' @@ -535,10 +451,8 @@ def test_ogr_geom_boundary_polygon(): geom = ogr.CreateGeometryFromWkt(geom_wkt) bnd = geom.GetBoundary() - if bnd.GetGeometryType() != ogr.wkbLineString: - gdaltest.post_reason('Boundary not reported as non-empty LINESTRING') - print(bnd) - return 'fail' + assert bnd.GetGeometryType() == ogr.wkbLineString, \ + 'Boundary not reported as non-empty LINESTRING' return 'success' @@ -568,8 +482,7 @@ def test_ogr_geom_build_from_edges_1(): try: poly = ogr.BuildPolygonFromEdges(link_coll) - if poly is None: - return 'fail' + assert poly is not None except: return 'fail' @@ -600,8 +513,7 @@ def test_ogr_geom_build_from_edges_2(): try: poly = ogr.BuildPolygonFromEdges(link_coll) - if poly is None: - return 'fail' + assert poly is not None except: return 'fail' @@ -621,8 +533,7 @@ def test_ogr_geom_build_from_edges_3(): gdal.PushErrorHandler('CPLQuietErrorHandler') poly = ogr.BuildPolygonFromEdges(src_geom) gdal.PopErrorHandler() - if poly is not None: - return 'fail' + assert poly is None except: pass @@ -631,8 +542,7 @@ def test_ogr_geom_build_from_edges_3(): gdal.PushErrorHandler('CPLQuietErrorHandler') poly = ogr.BuildPolygonFromEdges(src_geom) gdal.PopErrorHandler() - if poly is not None: - return 'fail' + assert poly is None except: pass @@ -673,12 +583,9 @@ def test_ogr_geom_build_from_edges_4(): try: poly = ogr.BuildPolygonFromEdges(link_coll) - if poly is None: - return 'fail' + assert poly is not None wkt = poly.ExportToWkt() - if wkt != 'POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1))': - print(wkt) - return 'fail' + assert wkt == 'POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1))' except: return 'fail' @@ -693,8 +600,7 @@ def test_ogr_geom_area_empty_linearring(): geom = ogr.Geometry(type=ogr.wkbLinearRing) area = geom.GetArea() - if area != 0: - return 'fail' + assert area == 0 return 'success' @@ -717,17 +623,15 @@ def test_ogr_geom_transform_to(): sr2.ImportFromEPSG(32631) ret = geom.TransformTo(sr2) - if ret != 0 or abs(geom.GetX() - 426857) > 1 or abs(geom.GetY() - 5427937) > 1: - print(geom.ExportToWkt()) - return 'fail' + assert ret == 0 and abs(geom.GetX() - 426857) <= 1 and abs(geom.GetY() - 5427937) <= 1, \ + geom.ExportToWkt() # Geometry without SRS geom = ogr.CreateGeometryFromWkt('POINT(2 49)') gdal.ErrorReset() with gdaltest.error_handler(): ret = geom.TransformTo(sr2) - if ret == 0 or gdal.GetLastErrorMsg() == '': - return 'fail' + assert not (ret == 0 or gdal.GetLastErrorMsg() == '') return 'success' @@ -752,9 +656,8 @@ def test_ogr_geom_transform(): geom.Transform(ct) - if abs(geom.GetX() - 426857) > 1 or abs(geom.GetY() - 5427937) > 1: - print(geom.ExportToWkt()) - return 'fail' + assert abs(geom.GetX() - 426857) <= 1 and abs(geom.GetY() - 5427937) <= 1, \ + geom.ExportToWkt() return 'success' @@ -767,14 +670,10 @@ def test_ogr_geom_closerings(): geom = ogr.CreateGeometryFromWkt('POLYGON((0 0,0 1,1 1,1 0))') geom.CloseRings() - if geom.ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,0 1,1 1,1 0,0 0))' geom.CloseRings() - if geom.ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,0 1,1 1,1 0,0 0))' return 'success' @@ -787,16 +686,12 @@ def test_ogr_geom_segmentize(): geom = ogr.CreateGeometryFromWkt('LINESTRING(0 0,0 10)') geom.Segmentize(1.00001) - if geom.ExportToWkt() != 'LINESTRING (0 0,0 1,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10)': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (0 0,0 1,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10)' geom = ogr.CreateGeometryFromWkt('LINESTRING(0 0 1,0 10 1)') geom.Segmentize(1.00001) - if geom.ExportToWkt() != 'LINESTRING (0 0 1,0 1 1,0 2 1,0 3 1,0 4 1,0 5 1,0 6 1,0 7 1,0 8 1,0 9 1,0 10 1)': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (0 0 1,0 1 1,0 2 1,0 3 1,0 4 1,0 5 1,0 6 1,0 7 1,0 8 1,0 9 1,0 10 1)' # Check segmentize symmetry : do exact binary comparison. in_wkt = 'LINESTRING (0 0,1.2 1,2 0)' @@ -807,12 +702,8 @@ def test_ogr_geom_segmentize(): g2.Segmentize(0.25) for i in range(g1.GetPointCount()): if g1.GetPoint(i) != g2.GetPoint(g1.GetPointCount() - 1 - i): - print(i) print('%.18g' % (g1.GetPoint(i)[0] - g2.GetPoint(g1.GetPointCount() - 1 - i)[0])) - print('%.18g' % (g1.GetPoint(i)[1] - g2.GetPoint(g1.GetPointCount() - 1 - i)[1])) - print(g1) - print(g2) - return 'fail' + pytest.fail('%.18g' % (g1.GetPoint(i)[1] - g2.GetPoint(g1.GetPointCount() - 1 - i)[1])) return 'success' @@ -826,33 +717,23 @@ def test_ogr_geom_value(): p = geom.Value(-1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (2 3)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = geom.Value(geom.Length() / 4) expected_p = ogr.CreateGeometryFromWkt('POINT (3.5 3)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = geom.Value(geom.Length() / 2) expected_p = ogr.CreateGeometryFromWkt('POINT (5 3)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = geom.Value(3 * geom.Length() / 4) expected_p = ogr.CreateGeometryFromWkt('POINT (5 1.5)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = geom.Value(geom.Length() + 1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (5 0)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 return 'success' @@ -865,22 +746,14 @@ def test_ogr_geom_flattenTo2D(): geom = ogr.CreateGeometryFromWkt('POINT (1 2 3)') # Point is 0 dimension, LineString 1, ... - if geom.GetDimension() != 0: - print(geom.GetDimension()) - return 'fail' + assert geom.GetDimension() == 0 - if geom.GetCoordinateDimension() != 3: - print(geom.GetCoordinateDimension()) - return 'fail' + assert geom.GetCoordinateDimension() == 3 geom.FlattenTo2D() - if geom.GetCoordinateDimension() != 2: - print(geom.GetCoordinateDimension()) - return 'fail' + assert geom.GetCoordinateDimension() == 2 - if geom.ExportToWkt() != 'POINT (1 2)': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POINT (1 2)' return 'success' @@ -893,22 +766,14 @@ def test_ogr_geom_flattenTo2D_triangle(): geom = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0 0,100 0 100,0 100 100,0 0 0))') # Point is 0 dimension, LineString 1, ... - if geom.GetDimension() != 2: - print(geom.GetDimension()) - return 'fail' + assert geom.GetDimension() == 2 - if geom.GetCoordinateDimension() != 3: - print(geom.GetCoordinateDimension()) - return 'fail' + assert geom.GetCoordinateDimension() == 3 geom.FlattenTo2D() - if geom.GetCoordinateDimension() != 2: - print(geom.GetCoordinateDimension()) - return 'fail' + assert geom.GetCoordinateDimension() == 2 - if geom.ExportToWkt() != 'TRIANGLE ((0 0,100 0,0 100,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'TRIANGLE ((0 0,100 0,0 100,0 0))' return 'success' @@ -918,72 +783,61 @@ def test_ogr_geom_flattenTo2D_triangle(): def test_ogr_geom_linestring_limits(): geom = ogr.CreateGeometryFromWkt('LINESTRING EMPTY') - if geom.Length() != 0: - return 'fail' + assert geom.Length() == 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.GetPoint(-1) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.GetPoint(0) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.GetPoint_2D(-1) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.GetPoint_2D(0) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.SetPoint(-1, 5, 6, 7) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.SetPoint_2D(-1, 5, 6) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 if False: # pylint: disable=using-constant-test gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.SetPoint(2147000000, 5, 6, 7) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 gdal.ErrorReset() gdal.PushErrorHandler('CPLQuietErrorHandler') geom.SetPoint_2D(2147000000, 5, 6) gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 geom = ogr.CreateGeometryFromWkt('LINESTRING(0 0)') - if geom.Length() != 0: - return 'fail' + assert geom.Length() == 0 geom = ogr.CreateGeometryFromWkt('LINESTRING(0 0, 1 0)') - if geom.Length() != 1: - return 'fail' + assert geom.Length() == 1 return 'success' @@ -994,10 +848,7 @@ def test_ogr_geom_coord_round(): geom = ogr.CreateGeometryFromWkt('POINT(370441.860 5591000.590)') wkt = geom.ExportToWkt() - if wkt != 'POINT (370441.86 5591000.59)': - gdaltest.post_reason('did not get expected WKT') - print(wkt) - return 'fail' + assert wkt == 'POINT (370441.86 5591000.59)', 'did not get expected WKT' return 'success' @@ -1008,10 +859,7 @@ def test_ogr_geom_coord_round_2(): geom = ogr.CreateGeometryFromWkt('POINT(1.0 169.600374)') wkt = geom.ExportToWkt() - if wkt != 'POINT (1.0 169.600374)': - gdaltest.post_reason('did not get expected WKT') - print(wkt) - return 'fail' + assert wkt == 'POINT (1.0 169.600374)', 'did not get expected WKT' return 'success' @@ -1026,9 +874,7 @@ def test_ogr_geom_area_point(): with gdaltest.error_handler(): area = geom.Area() - if area != 0: - gdaltest.post_reason('Area() result wrong, got %g.' % area) - return 'fail' + assert area == 0, ('Area() result wrong, got %g.' % area) return 'success' @@ -1044,9 +890,7 @@ def test_ogr_geom_length_point(): with gdaltest.error_handler(): length = geom.Length() - if length != 0: - gdaltest.post_reason('Length() result wrong, got %g.' % length) - return 'fail' + assert length == 0, ('Length() result wrong, got %g.' % length) return 'success' @@ -1061,9 +905,7 @@ def test_ogr_geom_length_multilinestring(): geom = ogr.CreateGeometryFromWkt(geom_wkt) length = geom.Length() - if abs(length - 2) > 0.00000000001: - gdaltest.post_reason('Length() result wrong, got %g.' % length) - return 'fail' + assert abs(length - 2) <= 0.00000000001, ('Length() result wrong, got %g.' % length) return 'success' @@ -1078,9 +920,7 @@ def test_ogr_geom_length_geometrycollection(): geom = ogr.CreateGeometryFromWkt(geom_wkt) length = geom.Length() - if abs(length - 4) > 0.00000000001: - gdaltest.post_reason('Length() result wrong, got %g.' % length) - return 'fail' + assert abs(length - 4) <= 0.00000000001, ('Length() result wrong, got %g.' % length) return 'success' @@ -1092,51 +932,29 @@ def test_ogr_geom_getpoints(): geom = ogr.CreateGeometryFromWkt('LINESTRING(0 1,2 3)') points = geom.GetPoints() - if points != [(0.0, 1.0), (2.0, 3.0)]: - gdaltest.post_reason('did not get expected points (1)') - print(points) - return 'fail' + assert points == [(0.0, 1.0), (2.0, 3.0)], 'did not get expected points (1)' points = geom.GetPoints(nCoordDimension=3) - if points != [(0.0, 1.0, 0.0), (2.0, 3.0, 0.0)]: - gdaltest.post_reason('did not get expected points (2)') - print(points) - return 'fail' + assert points == [(0.0, 1.0, 0.0), (2.0, 3.0, 0.0)], \ + 'did not get expected points (2)' geom = ogr.CreateGeometryFromWkt('LINESTRING(0 1 2,3 4 5)') points = geom.GetPoints() - if points != [(0.0, 1.0, 2.0), (3.0, 4.0, 5.0)]: - gdaltest.post_reason('did not get expected points (3)') - print(points) - return 'fail' + assert points == [(0.0, 1.0, 2.0), (3.0, 4.0, 5.0)], \ + 'did not get expected points (3)' points = geom.GetPoints(nCoordDimension=2) - if points != [(0.0, 1.0), (3.0, 4.0)]: - gdaltest.post_reason('did not get expected points (4)') - print(points) - return 'fail' + assert points == [(0.0, 1.0), (3.0, 4.0)], 'did not get expected points (4)' geom = ogr.CreateGeometryFromWkt('POINT(0 1)') points = geom.GetPoints() - if points != [(0.0, 1.0)]: - gdaltest.post_reason('did not get expected points (5)') - print(points) - return 'fail' + assert points == [(0.0, 1.0)], 'did not get expected points (5)' points = geom.GetPoints(nCoordDimension=3) - if points != [(0.0, 1.0, 0.0)]: - gdaltest.post_reason('did not get expected points (6)') - print(points) - return 'fail' + assert points == [(0.0, 1.0, 0.0)], 'did not get expected points (6)' geom = ogr.CreateGeometryFromWkt('POINT(0 1 2)') points = geom.GetPoints() - if points != [(0.0, 1.0, 2.0)]: - gdaltest.post_reason('did not get expected points (7)') - print(points) - return 'fail' + assert points == [(0.0, 1.0, 2.0)], 'did not get expected points (7)' points = geom.GetPoints(nCoordDimension=2) - if points != [(0.0, 1.0)]: - gdaltest.post_reason('did not get expected points (8)') - print(points) - return 'fail' + assert points == [(0.0, 1.0)], 'did not get expected points (8)' return 'success' @@ -1150,8 +968,7 @@ def test_ogr_geom_empty(): g1.Empty() wkt = g1.ExportToWkt() - if wkt != 'POLYGON EMPTY': - return 'fail' + assert wkt == 'POLYGON EMPTY' return 'success' @@ -1165,8 +982,7 @@ def test_ogr_geom_empty_triangle(): g1.Empty() wkt = g1.ExportToWkt() - if wkt != 'TRIANGLE EMPTY': - return 'fail' + assert wkt == 'TRIANGLE EMPTY' return 'success' @@ -1181,18 +997,16 @@ def test_ogr_geom_mixed_coordinate_dimension(): expected_wkt = 'MULTIPOLYGON (((1 2 -4,1 3 -3,2 3 -3,2 2 -3,1 2 -6)),((-1 -2 0,-1 -3 0,-2 -3 0,-2 -2 0,-1 -2 0,50 60 0)))' g = ogr.CreateGeometryFromWkt(wkt) got_wkt = g.ExportToWkt() - if got_wkt != expected_wkt: - gdaltest.post_reason('for %s: got %s, expected %s' % (wkt, got_wkt, expected_wkt)) - return 'fail' + assert got_wkt == expected_wkt, \ + ('for %s: got %s, expected %s' % (wkt, got_wkt, expected_wkt)) # first part is 3D, second part is 2D of same length, except the last point which is 3D wkt = 'MULTIPOLYGON (((1 2 -4,1 3 -3,2 3 -3,2 2 -3,1 2 -6)),((-1 -2,-1 -3,-2 -3,-2 -2,-1 -2,50 60 7)))' expected_wkt = 'MULTIPOLYGON (((1 2 -4,1 3 -3,2 3 -3,2 2 -3,1 2 -6)),((-1 -2 0,-1 -3 0,-2 -3 0,-2 -2 0,-1 -2 0,50 60 7)))' g = ogr.CreateGeometryFromWkt(wkt) got_wkt = g.ExportToWkt() - if got_wkt != expected_wkt: - gdaltest.post_reason('for %s: got %s, expected %s' % (wkt, got_wkt, expected_wkt)) - return 'fail' + assert got_wkt == expected_wkt, \ + ('for %s: got %s, expected %s' % (wkt, got_wkt, expected_wkt)) return 'success' @@ -1205,74 +1019,42 @@ def test_ogr_geom_getenvelope3d(): g = ogr.CreateGeometryFromWkt('POINT EMPTY') envelope = g.GetEnvelope3D() expected_envelope = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (1)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (1)' g = ogr.CreateGeometryFromWkt('POINT(1 2)') envelope = g.GetEnvelope3D() expected_envelope = (1.0, 1.0, 2.0, 2.0, 0.0, 0.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (2)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (2)' g = ogr.CreateGeometryFromWkt('POINT(1 2 3)') envelope = g.GetEnvelope3D() expected_envelope = (1.0, 1.0, 2.0, 2.0, 3.0, 3.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (3)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (3)' g = ogr.CreateGeometryFromWkt('POLYGON EMPTY') envelope = g.GetEnvelope3D() expected_envelope = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (4)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (4)' g = ogr.CreateGeometryFromWkt('LINESTRING(1 2,3 4)') envelope = g.GetEnvelope3D() expected_envelope = (1, 3, 2, 4, 0, 0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (5)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (5)' g = ogr.CreateGeometryFromWkt('MULTIPOLYGON(((1 2 3,-1 2 3,-1 -2 3,-1 2 3,1 2 3),(0.1 0.2 0.3,-0.1 0.2 0.3,-0.1 -0.2 0.3,-0.1 0.2 0.3,0.1 0.2 0.3)),((10 20 -30,-10 20 -30,-10 -20 -30,-10 20 -30,10 20 -30)))') envelope = g.GetEnvelope3D() expected_envelope = (-10, 10, -20, 20, -30, 3.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (6)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (6)' g = ogr.CreateGeometryFromWkt('MULTIPOLYGON EMPTY') envelope = g.GetEnvelope3D() expected_envelope = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (7)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (7)' g = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0 0,100 0 100,0 100 100,0 0 0))') envelope = g.GetEnvelope3D() expected_envelope = (0.0, 100.0, 0.0, 100.0, 0.0, 100.0) - if envelope != expected_envelope: - gdaltest.post_reason('did not get expected envelope (8)') - print(envelope) - print(expected_envelope) - return 'fail' + assert envelope == expected_envelope, 'did not get expected envelope (8)' return 'success' @@ -1288,15 +1070,11 @@ def test_ogr_geom_z_empty(): in_wkt = geom + ' Z EMPTY' g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToIsoWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToIsoWkb()) out_wkt = g2.ExportToIsoWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt return 'success' @@ -1320,25 +1098,16 @@ def test_ogr_geom_getlineargeometry(): in_wkt = geom_in + ' EMPTY' g = ogr.CreateGeometryFromWkt(in_wkt) g2 = g.GetLinearGeometry() - if geom_in != geom_out and not g.HasCurveGeometry(): - print(g) - return 'fail' - if g2.ExportToWkt() != geom_out + ' EMPTY': - print(g) - print(g2) - return 'fail' + assert geom_in == geom_out or g.HasCurveGeometry() + assert g2.ExportToWkt() == geom_out + ' EMPTY', g g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT (0 1))') - if g.HasCurveGeometry(): - return 'fail' - if g.HasCurveGeometry(True): - return 'fail' + assert not g.HasCurveGeometry() + assert not g.HasCurveGeometry(True) g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(CIRCULARSTRING (0 0,0 1,0 0))') - if not g.HasCurveGeometry(): - return 'fail' - if not g.HasCurveGeometry(True): - return 'fail' + assert g.HasCurveGeometry() + assert g.HasCurveGeometry(True) return 'success' @@ -1363,18 +1132,13 @@ def test_ogr_geom_getdimension(): ('POLYHEDRALSURFACE EMPTY', 2), ('TIN EMPTY', 2)]: g = ogr.CreateGeometryFromWkt(geom) - if g.GetDimension() != dim: - print(g) - print(dim) - return 'fail' + assert g.GetDimension() == dim g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(LINESTRING EMPTY, POINT (0 1))') - if g.GetDimension() != 1: - return 'fail' + assert g.GetDimension() == 1 g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT (0 1), LINESTRING EMPTY, POLYGON EMPTY)') - if g.GetDimension() != 2: - return 'fail' + assert g.GetDimension() == 2 return 'success' @@ -1390,24 +1154,16 @@ def test_ogr_geom_triangle(): wkb_string = geom.ExportToWkb(ogr.wkbXDR) geom = ogr.CreateGeometryFromWkb(wkb_string) wkt_string = geom.ExportToWkt() - if wkt_string != wkt_original: - gdaltest.post_reason("Failure in Wkb methods of Triangle") - return 'fail' + assert wkt_string == wkt_original, "Failure in Wkb methods of Triangle" wkt_string = geom.Clone().ExportToWkt() - if wkt_string != wkt_original: - gdaltest.post_reason("Failure in Clone()") - return 'fail' + assert wkt_string == wkt_original, "Failure in Clone()" polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbPolygon).ExportToWkt() - if polygon_wkt != 'POLYGON ((0 0,0 1,1 1,0 0))': - print(polygon_wkt) - return 'fail' + assert polygon_wkt == 'POLYGON ((0 0,0 1,1 1,0 0))' polygon_wkt = ogr.ForceTo(geom.Clone(), ogr.wkbMultiPolygon).ExportToWkt() - if polygon_wkt != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': - print(polygon_wkt) - return 'fail' + assert polygon_wkt == 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))' return 'success' @@ -1420,36 +1176,27 @@ def test_ogr_geom_triangle_invalid_wkt(): geom_wkt = 'TRIANGLE (0 0)' with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) - if geom is not None: - return 'fail' + assert geom is None geom_wkt = 'TRIANGLE ((0 0))' with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) - if geom is not None: - print(geom) - return 'fail' + assert geom is None geom_wkt = 'TRIANGLE ((0 0,0 1,1 1,1 0))' with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) - if geom is not None: - print(geom) - return 'fail' + assert geom is None geom_wkt = 'TRIANGLE ((0 0,0 1,1 1,1 0,0 0))' with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) - if geom is not None: - print(geom) - return 'fail' + assert geom is None geom_wkt = 'TRIANGLE ((0 0,0 1,1 1,0 0),(0 0,0 1,1 1,0 0))' with gdaltest.error_handler(): geom = ogr.CreateGeometryFromWkt(geom_wkt) - if geom is not None: - print(geom) - return 'fail' + assert geom is None return 'success' @@ -1464,15 +1211,13 @@ def test_ogr_geom_triangle_sfcgal(): g1 = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,100 0 100,0 100 100,0 0))') g2 = ogr.CreateGeometryFromWkt('TRIANGLE ((-1 -1,100 0 100,0 100 100,-1 -1))') - if not g2.Intersects(g1): - return 'fail' + assert g2.Intersects(g1) g1 = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,1 0,0 1,0 0))') g2 = ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,1 0,1 1,0 0))') g3 = g1.Intersection(g2) g4 = ogr.CreateGeometryFromWkt('TRIANGLE ((0.5 0.5 0,0 0 0,1 0 0,0.5 0.5 0))') - if not g4.Equals(g3): - return 'fail' + assert g4.Equals(g3) return 'success' @@ -1486,44 +1231,32 @@ def test_ogr_geom_circularstring(): # Test export/import Wkt g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCircularString: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCircularString out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt if ogrtest.have_geos(): - if not g1.IsValid(): - return 'fail' + assert g1.IsValid() # Test GetEnvelope() env = g1.GetEnvelope() expected_env = (0.0, 2.0, -1.0, 1.0) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # Test Length() length = g1.Length() expected_length = 1.5 * math.pi - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Test Value() p = g1.Value(-1) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(0) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(length / 6.0) expected_p = ogr.CreateGeometryFromWkt('POINT (0.292893218813453 0.707106781186548)') @@ -1532,60 +1265,42 @@ def test_ogr_geom_circularstring(): p = g1.Value(length / 3.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1 1)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(length / 2.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1.707106781186547 0.707106781186547)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(2 * length / 3.0) expected_p = ogr.CreateGeometryFromWkt('POINT (2 0)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(length) expected_p = ogr.CreateGeometryFromWkt('POINT (1 -1)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(length + 1) expected_p = ogr.CreateGeometryFromWkt('POINT (1 -1)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 # Test export/import Wkb g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # With Z in_wkt = 'CIRCULARSTRING Z (0 0 10,1 1 20,2 0 30)' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCircularStringZ: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCircularStringZ out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt wkb = g1.ExportToWkb() isowkb = g1.ExportToIsoWkb() - if wkb != isowkb: - return 'fail' + assert wkb == isowkb g2 = ogr.CreateGeometryFromWkb(wkb) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Test stroking gdal.SetConfigOption('OGR_STROKE_CURVE', 'TRUE') @@ -1596,9 +1311,7 @@ def test_ogr_geom_circularstring(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1)') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 in_wkt = 'CIRCULARSTRING (0 0,1 1,1 -1)' g1 = ogr.CreateGeometryFromWkt(in_wkt) @@ -1610,44 +1323,33 @@ def test_ogr_geom_circularstring(): gdal.SetConfigOption('OGR_STROKE_CURVE', 'FALSE') gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test HasCurveGeometry - if not g1.HasCurveGeometry(): - return 'fail' - if not g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert g1.HasCurveGeometry(True) # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test ForceToLineString gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test ForceToMultiLineString gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') expected_g2 = ogr.CreateGeometryFromWkt('MULTILINESTRING ((0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1))') g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g2) == 0 # Test GEOS operations if ogrtest.have_geos(): g2 = g1.Intersection(g1) - if g2 is None: - return 'fail' + assert g2 is not None # Test CIRCULARSTRING wrapped in a GEOMETRYCOLLECTION in_wkt = 'GEOMETRYCOLLECTION(CIRCULARSTRING (0 0,1 1,1 -1))' @@ -1656,24 +1358,19 @@ def test_ogr_geom_circularstring(): # Test GEOS operations if ogrtest.have_geos(): g2 = g1.Intersection(g1) - if g2 is None: - return 'fail' + assert g2 is not None # Test ForceToLineString gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test ForceToMultiLineString gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g2) == 0 # Test stroking of full circle with 3 points. ISO draft # mentions that this should define a full circle, but there's an @@ -1684,44 +1381,32 @@ def test_ogr_geom_circularstring(): g1 = ogr.CreateGeometryFromWkt(in_wkt) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0)') g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 length = g1.Length() expected_length = 2 * math.pi * 0.5 - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Test stroking of full circle (well defined) in_wkt = 'CIRCULARSTRING (0 0,0.5 0.5,1.0 0.0,0.5 -0.5,0.0 0.0)' g1 = ogr.CreateGeometryFromWkt(in_wkt) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.049515566048791 0.216941869558781,0.188255099070638 0.390915741234018,0.388739533021848 0.48746395609092,0.611260466978166 0.48746395609092,0.811744900929369 0.390915741234018,0.950484433951232 0.216941869558781,1 0,0.950484433951232 -0.216941869558781,0.811744900929369 -0.390915741234018,0.611260466978166 -0.48746395609092,0.388739533021848 -0.48746395609092,0.188255099070638 -0.390915741234018,0.049515566048791 -0.216941869558781,0 0)') g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 length = g1.Length() expected_length = 2 * math.pi * 0.5 - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Check segmentize g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.146446609406726 0.353553390593274,0.5 0.5,0.853553390593274 0.353553390593274,1 0,0.853553390593274 -0.353553390593274,0.5 -0.5,0.146446609406726 -0.353553390593274,0 0)') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 # Sanity check: the length must remain the same length = g1.Length() expected_length = 2 * math.pi * 0.5 - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Check segmentize symmetry : do exact binary comparison in_wkt = 'CIRCULARSTRING (0 0,1.2 1,2 0)' @@ -1732,112 +1417,80 @@ def test_ogr_geom_circularstring(): g2.Segmentize(0.25) for i in range(g1.GetPointCount()): if g1.GetPoint(i) != g2.GetPoint(g1.GetPointCount() - 1 - i): - print(i) print('%.18g' % (g1.GetPoint(i)[0] - g2.GetPoint(g1.GetPointCount() - 1 - i)[0])) - print('%.18g' % (g1.GetPoint(i)[1] - g2.GetPoint(g1.GetPointCount() - 1 - i)[1])) - print(g1) - print(g2) - return 'fail' + pytest.fail('%.18g' % (g1.GetPoint(i)[1] - g2.GetPoint(g1.GetPointCount() - 1 - i)[1])) # Test stroking of full circle with Z in_wkt = 'CIRCULARSTRING (0 0 1,1 0 2,0 0 1)' g1 = ogr.CreateGeometryFromWkt(in_wkt) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0 1,0.116977778440514 -0.321393804843282 1,0.413175911166547 -0.49240387650611 1,0.75 -0.433012701892224 1,0.969846310392967 -0.171010071662835 1,0.969846310392967 0.171010071662835 1,0.75 0.433012701892224 1,0.413175911166547 0.49240387650611 1,0.116977778440514 0.321393804843282 1,0 0 1)') g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Check segmentize g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING Z (0 0 1,0.146446609406726 -0.353553390593274 1.25,0.5 -0.5 1.5,0.853553390593274 -0.353553390593274 1.75,1 0 2,0.853553390593274 0.353553390593274 1.75,0.5 0.5 1.5,0.146446609406727 0.353553390593274 1.25,0 0 1)') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 # Same as above but reverse order in_wkt = 'CIRCULARSTRING (0 0,0.5 -0.5,1.0 0.0,0.5 0.5,0.0 0.0)' g1 = ogr.CreateGeometryFromWkt(in_wkt) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.049515566048791 -0.216941869558781,0.188255099070638 -0.390915741234018,0.388739533021848 -0.48746395609092,0.611260466978166 -0.48746395609092,0.811744900929369 -0.390915741234018,0.950484433951232 -0.216941869558781,1 0,0.950484433951232 0.216941869558781,0.811744900929369 0.390915741234018,0.611260466978166 0.48746395609092,0.388739533021848 0.48746395609092,0.188255099070638 0.390915741234018,0.049515566048791 0.216941869558781,0 0)') g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 length = g1.Length() expected_length = 2 * math.pi * 0.5 - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Test stroking of a circular string with 3 colinear points in_wkt = 'CIRCULARSTRING (0 0,1 1,2 2)' g1 = ogr.CreateGeometryFromWkt(in_wkt) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,1 1,2 2)') g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 length = g1.Length() expected_length = 2 * math.sqrt(2) - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Test Value() p = g1.Value(length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (0.5 0.5)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(3.0 * length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1.5 1.5)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 # Check segmentize g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.166666666666667 0.166666666666667,0.333333333333333 0.333333333333333,0.5 0.5,0.666666666666667 0.666666666666667,0.833333333333333 0.833333333333333,1 1,1.166666666666667 1.166666666666667,1.333333333333333 1.333333333333333,1.5 1.5,1.666666666666667 1.666666666666667,1.833333333333333 1.833333333333333,2 2)') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 # Sanity check: the length must remain the same length = g1.Length() expected_length = 2 * math.sqrt(2) - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 # Same with Z in_wkt = 'CIRCULARSTRING (0 0 1,1 1 2,2 2 1)' g1 = ogr.CreateGeometryFromWkt(in_wkt) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0 1,1 1 2,2 2 1)') g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Check segmentize g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('CIRCULARSTRING Z (0 0 1,0.166666666666667 0.166666666666667 1.166666666666667,0.333333333333333 0.333333333333333 1.333333333333333,0.5 0.5 1.5,0.666666666666667 0.666666666666667 1.666666666666667,0.833333333333333 0.833333333333333 1.833333333333333,1 1 2,1.166666666666667 1.166666666666667 1.833333333333333,1.333333333333333 1.333333333333333 1.666666666666667,1.5 1.5 1.5,1.666666666666667 1.666666666666667 1.333333333333333,1.833333333333333 1.833333333333333 1.166666666666667,2 2 1)') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 # Test Value() p = g1.Value(length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (0.5 0.5 1.5)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(3.0 * length / 4.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1.5 1.5 1.5)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 in_wkt = 'CIRCULARSTRING (0 0,1 1,1 -1)' # Test GetEnvelope() in various cases @@ -1857,9 +1510,7 @@ def test_ogr_geom_circularstring(): env = g1.GetEnvelope() expected_env = (cx + r * math.cos(a0), cx + r * math.cos(a2), cy + r * math.sin(a2), cy + r * math.sin(a0)) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # From quadrant 0 to quadrant -1 a0 = math.pi / 3 @@ -1873,9 +1524,7 @@ def test_ogr_geom_circularstring(): env = g1.GetEnvelope() expected_env = (cx + r * math.cos(a0), cx + r, cy + r * math.sin(a2), cy + r * math.sin(a0)) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # From quadrant 0 to quadrant 3 a0 = math.pi / 3 @@ -1889,9 +1538,7 @@ def test_ogr_geom_circularstring(): env = g1.GetEnvelope() expected_env = (cx - r, cx + r * math.cos(a2), cy - r, cy + r) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # From quadrant 0 to quadrant 4 a0 = math.pi / 3 @@ -1905,9 +1552,7 @@ def test_ogr_geom_circularstring(): env = g1.GetEnvelope() expected_env = (cx - r, cx + r, cy - r, cy + r) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # Full circle a0 = math.pi / 3 @@ -1921,36 +1566,25 @@ def test_ogr_geom_circularstring(): env = g1.GetEnvelope() expected_env = (cx - r, cx + r, cy - r, cy + r) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # Error case : not enough points in_wkt = 'CIRCULARSTRING (0 0)' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # EMPTY for in_wkt in ['CIRCULARSTRING EMPTY', 'CIRCULARSTRING Z EMPTY']: g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(in_wkt) - print(out_wkt) - return 'fail' - if g1.Length() != 0.0: - print(in_wkt) - return 'fail' + assert in_wkt == out_wkt + assert g1.Length() == 0.0, in_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(in_wkt) - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt return 'success' @@ -1962,152 +1596,105 @@ def test_ogr_geom_compoundcurve(): in_wkt = 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCompoundCurve: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCompoundCurve out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt - if g1.GetGeometryCount() != 1: - return 'fail' - if g1.GetGeometryRef(0).ExportToWkt() != 'CIRCULARSTRING (0 0,1 1,1 -1)': - return 'fail' + assert g1.GetGeometryCount() == 1 + assert g1.GetGeometryRef(0).ExportToWkt() == 'CIRCULARSTRING (0 0,1 1,1 -1)' env = g1.GetEnvelope() expected_env = (0.0, 2.0, -1.0, 1.0) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 length = g1.Length() expected_length = 1.5 * math.pi - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt g1 = ogr.CreateGeometryFromWkt(in_wkt) - if not g1.HasCurveGeometry(): - return 'fail' - if not g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert g1.HasCurveGeometry(True) # CreateGeometryFromWkt of LINESTRING in_wkt = 'COMPOUNDCURVE ((0 0,0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if not g1.HasCurveGeometry(): - return 'fail' - if g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert not g1.HasCurveGeometry(True) # With Z in_wkt = 'COMPOUNDCURVE Z (CIRCULARSTRING Z (0 0 10,1 1 20,2 0 30),(2 0 30,0 0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCompoundCurveZ: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCompoundCurveZ out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt env = g1.GetEnvelope() expected_env = (0.0, 2.0, 0.0, 1.0) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 env = g1.GetEnvelope3D() expected_env = (0.0, 2.0, 0.0, 1.0, 10, 30) for i in range(6): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 # Test Value() p = g1.Value(-1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0 10)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(math.pi / 2.0) expected_p = ogr.CreateGeometryFromWkt('POINT (1 1 20)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(math.pi) expected_p = ogr.CreateGeometryFromWkt('POINT (2 0 30)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(math.pi + 1) expected_p = ogr.CreateGeometryFromWkt('POINT (1 0 20)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 p = g1.Value(math.pi + 2 + 1e-3) expected_p = ogr.CreateGeometryFromWkt('POINT (0 0 10)') - if ogrtest.check_feature_geometry(p, expected_p) != 0: - print(p) - return 'fail' + assert ogrtest.check_feature_geometry(p, expected_p) == 0 wkb = g1.ExportToWkb() isowkb = g1.ExportToIsoWkb() - if wkb != isowkb: - return 'fail' + assert wkb == isowkb g2 = ogr.CreateGeometryFromWkb(wkb) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Several parts in_wkt = 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCompoundCurve: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCompoundCurve out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt - if not g1.Equals(g1): - return 'fail' + assert g1.Equals(g1) - if not g1.Equals(g1.Clone()): - return 'fail' + assert g1.Equals(g1.Clone()) - if g1.Equals(ogr.CreateGeometryFromWkt('POINT(0 0)')): - return 'fail' + assert not g1.Equals(ogr.CreateGeometryFromWkt('POINT(0 0)')) - if g1.Equals(ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))')): - return 'fail' + assert not g1.Equals(ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))')) - if g1.Equals(ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,0 1))')): - return 'fail' + assert not g1.Equals(ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,0 1))')) length = g1.Length() expected_length = 1.5 * math.pi + math.sqrt(2) - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Test stroking gdal.SetConfigOption('OGR_STROKE_CURVE', 'TRUE') @@ -2118,9 +1705,7 @@ def test_ogr_geom_compoundcurve(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1)') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 in_wkt = 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1))' g1 = ogr.CreateGeometryFromWkt(in_wkt) @@ -2133,117 +1718,93 @@ def test_ogr_geom_compoundcurve(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1)') - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 - if not g1.HasCurveGeometry(): - return 'fail' + assert g1.HasCurveGeometry() - if not g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry(True) g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') expected_g = ogr.CreateGeometryFromWkt('MULTILINESTRING ((0 0,0.218168517531969 0.623489801858729,0.777479066043687 0.974927912181831,1.433883739117561 0.900968867902435,1.900968867902463 0.433883739117562,1.974927912181821 -0.222520933956316,1.623489801858719 -0.78183148246804,1 -1))') g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Check segmentize g1.Segmentize(0.5) expected_g = ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,0.076120467488713 0.38268343236509,0.292893218813453 0.707106781186548,0.61731656763491 0.923879532511287,1 1,1.38268343236509 0.923879532511287,1.707106781186547 0.707106781186547,1.923879532511287 0.38268343236509,2 0,1.923879532511287 -0.38268343236509,1.707106781186547 -0.707106781186547,1.38268343236509 -0.923879532511287,1 -1))') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 # Error case : not enough points in_wkt = 'COMPOUNDCURVE ((0 0))' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Error case : invalid curve in_wkt = 'COMPOUNDCURVE (COMPOUNDCURVE EMPTY)' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Error case : non contiguous curves in_wkt = 'COMPOUNDCURVE ((0 0,1 1),(2 2,3 3))' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Error case : non contiguous curves in_wkt = 'COMPOUNDCURVE (EMPTY,(2 2,3 3))' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Error case : non contiguous curves in_wkt = 'COMPOUNDCURVE ((2 2,3 3), EMPTY)' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None g = ogr.Geometry(ogr.wkbCompoundCurve) g.AddGeometry(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) - if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1))': - return 'fail' + assert g.ExportToWkt() == 'COMPOUNDCURVE ((0 0,1 1))' gdal.PushErrorHandler('CPLQuietErrorHandler') g.AddGeometry(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) gdal.PopErrorHandler() - if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1),(1 1,0 0))': - return 'fail' + assert g.ExportToWkt() == 'COMPOUNDCURVE ((0 0,1 1),(1 1,0 0))' g = ogr.Geometry(ogr.wkbCompoundCurve) g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) - if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1))': - return 'fail' + assert g.ExportToWkt() == 'COMPOUNDCURVE ((0 0,1 1))' gdal.PushErrorHandler('CPLQuietErrorHandler') g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('LINESTRING(0 0,1 1)')) gdal.PopErrorHandler() - if g.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1),(1 1,0 0))': - return 'fail' + assert g.ExportToWkt() == 'COMPOUNDCURVE ((0 0,1 1),(1 1,0 0))' # Cannot add compoundcurve in compoundcurve g = ogr.Geometry(ogr.wkbCompoundCurve) gdal.PushErrorHandler('CPLQuietErrorHandler') g.AddGeometryDirectly(ogr.CreateGeometryFromWkt('COMPOUNDCURVE((1 1,2 2))')) gdal.PopErrorHandler() - if g.ExportToWkt() != 'COMPOUNDCURVE EMPTY': - return 'fail' + assert g.ExportToWkt() == 'COMPOUNDCURVE EMPTY' # Check that discretization is not sensitive to winding order g1 = ogr.CreateGeometryFromWkt('COMPOUNDCURVE((-1 0,0 1),CIRCULARSTRING (0 1,0.25 0,0.1 -0.5),(0.1 -0.5,-1 0))') @@ -2256,12 +1817,8 @@ def test_ogr_geom_compoundcurve(): # The curves must be exactly the same, despite our stealth mode if g2.GetX(i) != g3.GetX(p_count - 1 - i) or \ g2.GetY(i) != g3.GetY(p_count - 1 - i): - print(g2) - print(g3) - print(i) print(abs(g2.GetX(i) - g3.GetX(p_count - 1 - i))) - print(abs(g2.GetY(i) - g3.GetY(p_count - 1 - i))) - return 'fail' + pytest.fail(abs(g2.GetY(i) - g3.GetY(p_count - 1 - i))) # Test Transform sr = osr.SpatialReference() @@ -2282,28 +1839,18 @@ def test_ogr_geom_compoundcurve(): gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkb(wkb) gdal.PopErrorHandler() - if g is not None: - print(wkb) - return 'fail' + assert g is None, wkb # EMPTY for in_wkt in ['COMPOUNDCURVE EMPTY', 'COMPOUNDCURVE Z EMPTY']: g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(in_wkt) - print(out_wkt) - return 'fail' - if g1.Length() != 0.0: - print(in_wkt) - return 'fail' + assert in_wkt == out_wkt + assert g1.Length() == 0.0, in_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(in_wkt) - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt return 'success' @@ -2315,66 +1862,46 @@ def test_ogr_geom_curvepolygon(): in_wkt = 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCurvePolygon: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCurvePolygon out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt if ogrtest.have_geos(): p1 = g1.PointOnSurface() - if (p1.GetX() - 0.5) * (p1.GetX() - 0.5) + p1.GetY() * p1.GetY() > 0.5 * 0.5: - print(p1) - return 'fail' + assert (p1.GetX() - 0.5) * (p1.GetX() - 0.5) + p1.GetY() * p1.GetY() <= 0.5 * 0.5 env = g1.GetEnvelope() expected_env = (0.0, 1.0, -0.5, 0.5) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 area = g1.Area() expected_area = math.pi * 0.5 * 0.5 - if abs(area - expected_area) > 1e-8: - print(area) - print(expected_area) - return 'fail' + assert abs(area - expected_area) <= 1e-8 g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # CURVEPOLYGON of LINESTRING in_wkt = 'CURVEPOLYGON ((0 0,0 10,10 10,10 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if not g1.HasCurveGeometry(): - return 'fail' - if g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert not g1.HasCurveGeometry(True) # With Z in_wkt = 'CURVEPOLYGON Z (CIRCULARSTRING Z (0 0 10,1 0 10,0 0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbCurvePolygonZ: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbCurvePolygonZ out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt wkb = g1.ExportToWkb() isowkb = g1.ExportToIsoWkb() - if wkb != isowkb: - return 'fail' + assert wkb == isowkb g2 = ogr.CreateGeometryFromWkb(wkb) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Test stroking gdal.SetConfigOption('OGR_STROKE_CURVE', 'TRUE') @@ -2385,9 +1912,7 @@ def test_ogr_geom_curvepolygon(): gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = ogr.CreateGeometryFromWkt('POLYGON ((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0))') - if ogrtest.check_feature_geometry(g1, expected_g) != 0: - print(g1) - return 'fail' + assert ogrtest.check_feature_geometry(g1, expected_g) == 0 in_wkt = 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) @@ -2399,146 +1924,113 @@ def test_ogr_geom_curvepolygon(): gdal.SetConfigOption('OGR_STROKE_CURVE', 'FALSE') gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test HasCurveGeometry - if not g1.HasCurveGeometry(): - return 'fail' - if not g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert g1.HasCurveGeometry(True) # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test ForceToPolygon gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test ForceToMultiPolygon gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') expected_g2 = ogr.CreateGeometryFromWkt('MULTIPOLYGON (((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0)))') g2 = ogr.ForceToMultiPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g2) == 0 # Test ForceToMultiLineString gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g3 = ogr.CreateGeometryFromWkt('MULTILINESTRING ((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0))') - if ogrtest.check_feature_geometry(g2, expected_g3) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g3) == 0 # Test GEOS operations if ogrtest.have_geos(): g2 = g1.Intersection(g1) - if g2 is None: - return 'fail' + assert g2 is not None # Test CURVEPOLYGON and COMPOUNDCURVE, CIRCULARSTRING, LINESTRING in_wkt = 'CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0),(2 0,0 0)),(0.1 0.1,0.1 0.2,0.2 0.2,0.2 0.1,0.1 0.1),CIRCULARSTRING (0.25 0.25,0.75 0.25,0.25 0.25))' g1 = ogr.CreateGeometryFromWkt(in_wkt) g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) - if g2.ExportToWkt() != in_wkt: - print(g2) - return 'fail' + assert g2.ExportToWkt() == in_wkt # Test CURVEPOLYGON wrapped in a GEOMETRYCOLLECTION in_wkt = 'GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING (0 0,1 0,0 0)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) - if not g1.Equals(g2): - print(g2) - return 'fail' + assert g1.Equals(g2) # Test GEOS operations if ogrtest.have_geos(): g2 = g1.Intersection(g1) - if g2 is None: - return 'fail' + assert g2 is not None # Test ForceToPolygon gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test ForceToMultiPolygon gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToMultiPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if ogrtest.check_feature_geometry(g2, expected_g2) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g2) == 0 # Error case : not enough points in_wkt = 'CURVEPOLYGON ((0 0,0 1,0 0))' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Error case : wrong sub-geometry type in_wkt = 'CURVEPOLYGON (POINT EMPTY)' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Error case: non closed ring in_wkt = 'CURVEPOLYGON ((0 0,0 1,1 1,1 0))' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None # Area g = ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0))') - if g.Area() != 0.5: - return 'fail' + assert g.Area() == 0.5 g = ogr.CreateGeometryFromWkt('CURVEPOLYGON (COMPOUNDCURVE((0 0,1 1,1 0,0 0)))') - if g.Area() != 0.5: - return 'fail' + assert g.Area() == 0.5 g = ogr.CreateGeometryFromWkt('CURVEPOLYGON (COMPOUNDCURVE((0 0,1 1),(1 1,1 0,0 0)))') - if g.Area() != 0.5: - return 'fail' + assert g.Area() == 0.5 g = ogr.CreateGeometryFromWkt('CURVEPOLYGON ((100000000 100000000,100000001 100000001,100000001 100000000,100000000 100000000))') - if g.Area() != 0.5: - return 'fail' + assert g.Area() == 0.5 # Equals g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0),CIRCULARSTRING(0.75 0.5,0.85 0.5,0.75 0.5))') - if not g1.Equals(g1): - return 'fail' + assert g1.Equals(g1) - if not g1.Equals(g1.Clone()): - return 'fail' + assert g1.Equals(g1.Clone()) - if g1.Equals(ogr.CreateGeometryFromWkt('POINT(0 0)')): - return 'fail' + assert not g1.Equals(ogr.CreateGeometryFromWkt('POINT(0 0)')) - if g1.Equals(ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0))')): - return 'fail' + assert not g1.Equals(ogr.CreateGeometryFromWkt('CURVEPOLYGON ((0 0,1 1,1 0,0 0))')) # Intersects optimizations on a circle g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,2 0,0 0))') @@ -2551,97 +2043,68 @@ def test_ogr_geom_curvepolygon(): res = res & g1.Contains(p1) res = res & p1.Within(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) - if not res: - return 'fail' + assert res # Test point slightly outside circle p2 = ogr.CreateGeometryFromWkt('POINT (%.16g %.16g)' % (1 + math.cos(math.pi / 6) + 1e-4, math.sin(math.pi / 6))) - if p2.Within(g1): - return 'fail' + assert not p2.Within(g1) # Full circle defined by 2 arcs g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0))') - if not p1.Within(g1): - return 'fail' + assert p1.Within(g1) # Same but in reverse order g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 -1,2 0,1 1,0 0))') - if not p1.Within(g1): - return 'fail' + assert p1.Within(g1) # This is not a circle p2 = ogr.CreateGeometryFromWkt('POINT (%.16g %.16g)' % (1 + math.cos(math.pi / 6) - 1e-2, math.sin(math.pi / 6))) g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,1 1,0 0))') - if p2.Within(g1): - return 'fail' + assert not p2.Within(g1) # Test area on circle in 2 pieces g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0))') area = g1.Area() expected_area = math.pi - if abs(area - expected_area) > 1e-10: - print(area) - print(expected_area) - return 'fail' + assert abs(area - expected_area) <= 1e-10 # Test area on hippodrome g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,2 -1,2 -2,1 -3,0 -2,0 -1,0 0))') area = g1.Area() expected_area = math.pi + 2 * 2 - if abs(area - expected_area) > 1e-10: - print(area) - print(expected_area) - return 'fail' + assert abs(area - expected_area) <= 1e-10 # Same hippodrome but with different WKT g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (COMPOUNDCURVE(CIRCULARSTRING (0 0,1 1,2 0),(2 0,2 -2),CIRCULARSTRING(2 -2,1 -3,0 -2),(0 -2,0 0)))') area = g1.Area() expected_area = math.pi + 2 * 2 - if abs(area - expected_area) > 1e-10: - print(area) - print(expected_area) - return 'fail' + assert abs(area - expected_area) <= 1e-10 # Similar, but with concave part (does not trigger optimization) g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON (COMPOUNDCURVE(CIRCULARSTRING (0 0,1 1,2 0),(2 0,2 -2),CIRCULARSTRING(2 -2,1 -1,0 -2),(0 -2,0 0)))') area = g1.Area() expected_area = 2 * 2 - if abs(area - expected_area) > 1e-10: - print(area) - print(expected_area) - return 'fail' + assert abs(area - expected_area) <= 1e-10 # EMPTY for in_wkt in ['CURVEPOLYGON EMPTY', 'CURVEPOLYGON Z EMPTY']: g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(in_wkt) - print(out_wkt) - return 'fail' - if g1.Area() != 0.0: - print(in_wkt) - return 'fail' + assert in_wkt == out_wkt + assert g1.Area() == 0.0, in_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(in_wkt) - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Empty CircularString g = ogr.Geometry(ogr.wkbCurvePolygon) g.AddGeometry(ogr.Geometry(ogr.wkbCircularString)) - if g.Area() != 0: - print(g.Area()) - return 'fail' + assert g.Area() == 0 # Non-convex CircularString g = ogr.CreateGeometryFromWkt('CURVEPOLYGON( COMPOUNDCURVE( CIRCULARSTRING(0 0,0.5 -0.5,1 0,1.5 0.5,2 0), (2 0,2 1,0 1,0 0) ) )') - if abs(g.Area() - 2.0) > 1e-10: - print(g.Area()) - return 'fail' + assert abs(g.Area() - 2.0) <= 1e-10 return 'success' @@ -2654,101 +2117,72 @@ def test_ogr_geom_multicurve(): # Simple test in_wkt = 'MULTICURVE (CIRCULARSTRING (0 0,1 0,0 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbMultiCurve: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbMultiCurve out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt - if g1.GetDimension() != 1: - print(g1.GetDimension()) - return 'fail' + assert g1.GetDimension() == 1 env = g1.GetEnvelope() expected_env = (0.0, 1.0, -0.5, 0.5) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 length = g1.Length() expected_length = 2 * math.pi * 0.5 - if abs(length - expected_length) > 1e-8: - print(length) - return 'fail' + assert abs(length - expected_length) <= 1e-8 g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt - if not g1.HasCurveGeometry(): - return 'fail' - if not g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert g1.HasCurveGeometry(True) # MULTICURVE of LINESTRING in_wkt = 'MULTICURVE ((0 0,1 0))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if not g1.HasCurveGeometry(): - return 'fail' - if g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert not g1.HasCurveGeometry(True) # Z in_wkt = 'MULTICURVE Z (CIRCULARSTRING Z (0 0 10,1 0 10,0 0 10))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbMultiCurveZ: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbMultiCurveZ out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # WKT with all possible sub geometries in_wkt = 'MULTICURVE (CIRCULARSTRING (0 0,1 0,0 0),(0 0,1 1),COMPOUNDCURVE ((0 0,1 1),CIRCULARSTRING (1 1,2 2,3 3)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Test ForceToMultiLineString gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToMultiLineString(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = 'MULTILINESTRING ((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0),(0 0,1 1),(0 0,1 1,2 2,3 3))' - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Error case : wrong sub-geometry type in_wkt = 'MULTILINESTRING (POINT EMPTY)' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None return 'success' @@ -2761,115 +2195,82 @@ def test_ogr_geom_multisurface(): # Simple test in_wkt = 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbMultiSurface: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbMultiSurface out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt - if g1.GetDimension() != 2: - print(g1.GetDimension()) - return 'fail' + assert g1.GetDimension() == 2 env = g1.GetEnvelope() expected_env = (0.0, 1.0, -0.5, 0.5) for i in range(4): - if abs(env[i] - expected_env[i]) > 1e-8: - print(env) - return 'fail' + assert abs(env[i] - expected_env[i]) <= 1e-8 area = g1.Area() expected_area = math.pi * 0.5 * 0.5 - if abs(area - expected_area) > 1e-8: - print(area) - return 'fail' + assert abs(area - expected_area) <= 1e-8 g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt - if not g1.HasCurveGeometry(): - return 'fail' - if not g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert g1.HasCurveGeometry(True) # Z in_wkt = 'MULTISURFACE Z (CURVEPOLYGON Z (CIRCULARSTRING Z (0 0 10,1 0 10,0 0 10)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if g1.GetGeometryType() != ogr.wkbMultiSurfaceZ: - return 'fail' + assert g1.GetGeometryType() == ogr.wkbMultiSurfaceZ out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # MULTISURFACE of POLYGON in_wkt = 'MULTISURFACE (((0 0,0 10,10 10,10 0,0 0)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) - if not g1.HasCurveGeometry(): - return 'fail' - if g1.HasCurveGeometry(True): - return 'fail' + assert g1.HasCurveGeometry() + assert not g1.HasCurveGeometry(True) # WKT with all possible sub geometries in_wkt = 'MULTISURFACE (((0 0,0 10,10 10,10 0,0 0)),CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) out_wkt = g1.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt g2 = ogr.CreateGeometryFromWkb(g1.ExportToWkb()) out_wkt = g2.ExportToWkt() - if in_wkt != out_wkt: - print(out_wkt) - return 'fail' + assert in_wkt == out_wkt # Test ForceToMultiPolygon gdal.SetConfigOption('OGR_ARC_STEPSIZE', '45') g2 = ogr.ForceToMultiPolygon(g1) gdal.SetConfigOption('OGR_ARC_STEPSIZE', None) expected_g = 'MULTIPOLYGON (((0 0,0 10,10 10,10 0,0 0)),((0 0,0.116977778440514 -0.321393804843282,0.413175911166547 -0.49240387650611,0.75 -0.433012701892224,0.969846310392967 -0.171010071662835,0.969846310392967 0.171010071662835,0.75 0.433012701892224,0.413175911166547 0.49240387650611,0.116977778440514 0.321393804843282,0 0)))' - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Test GetLinearGeometry g2 = g1.GetLinearGeometry(45) - if ogrtest.check_feature_geometry(g2, expected_g) != 0: - print(g2) - return 'fail' + assert ogrtest.check_feature_geometry(g2, expected_g) == 0 # Check that GetLinearGeometry() is idem-potent on MULTIPOLYGON g3 = g2.GetLinearGeometry(45) - if not g3.Equals(g2): - print(g3) - return 'fail' + assert g3.Equals(g2) # PointOnSurface if ogrtest.have_geos(): in_wkt = 'MULTISURFACE (((0 0,0 10,10 10,10 0,0 0),(1 1,1 9,9 9,9 1,1 1)),((10 0,10 10,20 10,20 0,10 0),(11 1,11 9,19 9,19 1,11 1)))' g1 = ogr.CreateGeometryFromWkt(in_wkt) p1 = g1.PointOnSurface() - if p1.ExportToWkt() != 'POINT (0.5 5.0)': - print(p1) - return 'fail' + assert p1.ExportToWkt() == 'POINT (0.5 5.0)' # Error case : wrong sub-geometry type in_wkt = 'MULTIPOLYGON (POINT EMPTY)' gdal.PushErrorHandler('CPLQuietErrorHandler') g = ogr.CreateGeometryFromWkt(in_wkt) gdal.PopErrorHandler() - if g is not None: - return 'fail' + assert g is None return 'success' @@ -2889,56 +2290,43 @@ def test_ogr_geom_getcurvegeometry(): in_wkt = geom + ' EMPTY' g = ogr.CreateGeometryFromWkt(in_wkt) g2 = g.GetCurveGeometry() - if g2.ExportToWkt() != in_wkt: - print(g) - print(g2) - return 'fail' + assert g2.ExportToWkt() == in_wkt, g g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT (0 1))') g2 = g.GetCurveGeometry() - if not g.Equals(g2): - return 'fail' + assert g.Equals(g2) g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(LINESTRING (0 0,0 1,0 0))') g2 = g.GetCurveGeometry() - if not g.Equals(g2): - return 'fail' + assert g.Equals(g2) g = ogr.CreateGeometryFromWkt('POLYGON((0 0,0 1,1 1,1 0,0 0))') g2 = g.GetCurveGeometry() - if not g.Equals(g2): - return 'fail' + assert g.Equals(g2) g = ogr.CreateGeometryFromWkt('POLYGON Z ((0 0 10,0 1 10,1 1 10,1 0 10,0 0 10))') g2 = g.GetCurveGeometry() - if not g.Equals(g2): - return 'fail' + assert g.Equals(g2) # CircularString with large step g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1 1,2 0)') g2 = g1.GetLinearGeometry(15) g3 = g2.GetCurveGeometry() - if g3.GetGeometryType() != ogr.wkbCircularString or \ - g1.GetPoint(0) != g3.GetPoint(0) or g1.GetPoint(2) != g3.GetPoint(2) or \ - abs((g3.GetX(1) - 1) * (g3.GetX(1) - 1) + g3.GetY(1) * g3.GetY(1) - 1) > 1e-8: - print(g3) - return 'fail' + assert (g3.GetGeometryType() == ogr.wkbCircularString and \ + g1.GetPoint(0) == g3.GetPoint(0) and g1.GetPoint(2) == g3.GetPoint(2) and \ + abs((g3.GetX(1) - 1) * (g3.GetX(1) - 1) + g3.GetY(1) * g3.GetY(1) - 1) <= 1e-8) # CurvePolygon with large step g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON( CIRCULARSTRING (0 0,1 1,0 0))') g2 = g1.GetLinearGeometry(15) g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # This is a straight line g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 2,3 4,5 6)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if g3.ExportToWkt() != 'LINESTRING (1 2,3 4,5 6)': - print(g3) - return 'fail' + assert g3.ExportToWkt() == 'LINESTRING (1 2,3 4,5 6)' # "Random" arcs for wkt in ['CIRCULARSTRING (1 2,3 1,5 6)', @@ -2957,10 +2345,7 @@ def test_ogr_geom_getcurvegeometry(): g1 = ogr.CreateGeometryFromWkt(wkt) g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g1) - print(g3) - return 'fail' + assert g3.Equals(g1) # Really random arcs with coordinates in the [-1000,1000] range for i in range(1000): @@ -3022,24 +2407,18 @@ def test_ogr_geom_getcurvegeometry(): g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.5 -0.5,1 0,0.5 0.5,0 0)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # 3 points full circle g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1 0,0 0)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if g3.GetGeometryType() != ogr.wkbCircularString or \ - g1.GetPoint(0) != g3.GetPoint(0) or \ - g1.GetPoint(1) != g3.GetPoint(2) or \ - g1.GetPoint(2) != g3.GetPoint(4) or \ - abs((g3.GetX(1) - 0.5) * (g3.GetX(1) - 0.5) + g3.GetY(1) * g3.GetY(1) - 0.5 * 0.5) > 1e-12 or \ - abs((g3.GetX(3) - 0.5) * (g3.GetX(3) - 0.5) + g3.GetY(3) * g3.GetY(3) - 0.5 * 0.5) > 1e-12: - print(g3) - # print(abs((g3.GetX(1) - 0.5)*(g3.GetX(1) - 0.5)+g3.GetY(1)*g3.GetY(1) - 0.5*0.5)) - # print(abs((g3.GetX(3) - 0.5)*(g3.GetX(3) - 0.5)+g3.GetY(3)*g3.GetY(3) - 0.5*0.5)) - return 'fail' + assert (g3.GetGeometryType() == ogr.wkbCircularString and \ + g1.GetPoint(0) == g3.GetPoint(0) and \ + g1.GetPoint(1) == g3.GetPoint(2) and \ + g1.GetPoint(2) == g3.GetPoint(4) and \ + abs((g3.GetX(1) - 0.5) * (g3.GetX(1) - 0.5) + g3.GetY(1) * g3.GetY(1) - 0.5 * 0.5) <= 1e-12 and \ + abs((g3.GetX(3) - 0.5) * (g3.GetX(3) - 0.5) + g3.GetY(3) * g3.GetY(3) - 0.5 * 0.5) <= 1e-12) # 3 points full circle in a CurvePolygon for wkt in ['CURVEPOLYGON( CIRCULARSTRING (0 0,1 0,0 0))', @@ -3049,147 +2428,110 @@ def test_ogr_geom_getcurvegeometry(): g1 = ogr.CreateGeometryFromWkt(wkt) g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g1) - print(g3) - return 'fail' + assert g3.Equals(g1) # 2 curves in the CircularString g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1 1,2 0,3 -1,4 0)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # 3 curves in the CircularString g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1 1,2 0,3 -1,4 0,5 1,6 0)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # CircularString, LineString, CircularString g1 = ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0),(2 0,3 0,4 0),CIRCULARSTRING (4 0,5 1,6 0))') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # LineString, CircularString, LineString, CircularString, LineString g1 = ogr.CreateGeometryFromWkt('COMPOUNDCURVE ((-1 0,-0.5 0.5,0 0),CIRCULARSTRING (0 0,1 1,2 0),(2 0,3 0,4 0),CIRCULARSTRING (4 0,5 1,6 0),(6 0,7 0))') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Check with default discretization method g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.000997093138961 0.068920262501281,0.006738548124866 0.137608197923873,0.017197098230267 0.205737600590167,0.032323074784779 0.272984917348872,0.052044643056421 0.339030784160355,0.076268143401735 0.403561542787492,0.104878536064531 0.466270730389102,0.137739947510866 0.526860534941749,0.174696315705653 0.585043209577972,0.215572131266425 0.640542439124111,0.260173270974444 0.693094652347904,0.30828791968472 0.742450273683876,0.359687576256715 0.788374908491942,0.414128138728451 0.830650456220319,0.471351063580441 0.869076146186235,0.531084593583979 0.903469491055406,0.593045048402615 0.933667153492107,0.656938171817632 0.959525721864054,0.722460529179411 0.980922391318168,0.789300948448056 0.99775554699276,0.857141997979641 1.009945246596371,0.925661494039921 1.017433600061489,0.994534030886182 1.020185044470095,1.063432526150724 1.01818651294542,1.132029774186796 1.01144749670781,1.2 1.0,1.267547127648721 0.983752320094182,1.333803428245673 0.962854851656094,1.398449236893265 0.937408418110045,1.461172658788815 0.907535790143504,1.521671074014578 0.873381093378847,1.579652597579492 0.835109113014538,1.634837487668428 0.792904498790658,1.686959495304612 0.746970874114522,1.73576714891352 0.697529853644598,1.781024967590663 0.644819974072535,1.822514597219645 0.589095543261942,1.860035863959079 0.53062541329644,1.89340774001566 0.469691683356621,1.922469217043826 0.406588338684124,1.94708008295817 0.341619832199361,1.967121598410718 0.27509961561613,1.982497069669296 0.207348627140011,1.993132315133044 0.138693743046887,1.998976023234287 0.069466200612231,2 0)') g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Check with alternate discretization method : ROUND_ANGLE_METHOD g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,-0.000199980003999 0.02,0.002236456877416 0.089770423644023,0.009533897446083 0.159200932797352,0.021656789305088 0.227953268998521,0.038546070943884 0.295692477776518,0.060119459480029 0.362088540515299,0.086271851533127 0.426817982271309,0.116875835277923 0.489565447710894,0.151782311181914 0.550025237489786,0.190821218403283 0.607902797589577,0.233802363310224 0.662916154355295,0.280516346085201 0.7147972882427,0.330735580899807 0.763293439582565,0.384215404690045 0.80816834000038,0.440695269130182 0.849203363492117,0.499900009998002 0.886198591548151,0.561541187747236 0.918973787136141,0.62531849275604 0.947369272797732,0.690921208405283 0.971246708581086,0.758029724858684 0.990489766019218,0.826317096169807 1.005004694870594,0.895450633129846 1.014720779860886,0.965093524096011 1.019590685200679,1.034906475903993 1.019590685200679,1.104549366870158 1.014720779860886,1.173682903830197 1.005004694870593,1.2 1.0,1.241970275141317 0.990489766019217,1.309078791594718 0.971246708581085,1.374681507243961 0.947369272797731,1.438458812252765 0.91897378713614,1.500099990002 0.886198591548151,1.559304730869819 0.849203363492116,1.615784595309956 0.808168340000379,1.669264419100194 0.763293439582565,1.7194836539148 0.714797288242699,1.766197636689777 0.662916154355294,1.809178781596718 0.607902797589576,1.848217688818087 0.550025237489785,1.883124164722078 0.489565447710893,1.913728148466874 0.426817982271308,1.939880540519971 0.362088540515298,1.961453929056117 0.295692477776516,1.978343210694912 0.227953268998519,1.990466102553917 0.15920093279735,1.997763543122584 0.089770423644022,2.000199980003999 0.02,2 0)') g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Check with PostgreSQL output of SELECT ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING (0 0,1.2 1.0,2 0)')) g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,0.000223190308279 0.049091765203314,0.002854930521212 0.098113445796116,0.007888880546112 0.146946944256066,0.015312913156447 0.195474616408063,0.025109143207391 0.243579554839372,0.037253970722702 0.291145870539817,0.051718137749134 0.338058972088558,0.068466798841411 0.384205841714863,0.08745960500795 0.429475307567812,0.108650800915124 0.473758311539029,0.131989335115863 0.516948171993215,0.157418983037062 0.558940840773549,0.184878482429505 0.599635153862819,0.214301680953989 0.638933075096389,0.245617695548099 0.676739932339917,0.27875108318972 0.712964645562815,0.31362202264588 0.747519946258017,0.350146506769097 0.780322587679462,0.388236544877951 0.811293545390794,0.427800374734344 0.840358207642151,0.46874268360677 0.867446555116406,0.510964837887032 0.892493329611833,0.554365120707246 0.915438191254836,0.598838976984681 0.936225863863983,0.644279265304116 0.954806268115175,0.690576516030889 0.971134642187118,0.737619195032841 0.985171649596477,0.785293972375802 0.996883473962907,0.833485995345338 1.006241900475673,0.88207916513699 1.013224383865605,0.930956416548473 1.017814102718623,0.98 1.02,1.029091765203309 1.019776809691721,1.078113445796111 1.017145069478788,1.12694694425606 1.012111119453889,1.175474616408058 1.004687086843554,1.223579554839367 0.994890856792611,1.271145870539812 0.9827460292773,1.318058972088553 0.968281862250867,1.364205841714858 0.951533201158591,1.409475307567807 0.932540394992052,1.453758311539024 0.911349199084878,1.49694817199321 0.88801066488414,1.538940840773545 0.862581016962941,1.579635153862814 0.835121517570498,1.618933075096384 0.805698319046015,1.656739932339913 0.774382304451905,1.692964645562811 0.741248916810284,1.727519946258013 0.706377977354124,1.760322587679458 0.669853493230907,1.791293545390791 0.631763455122053,1.820358207642148 0.59219962526566,1.847446555116403 0.551257316393235,1.872493329611831 0.509035162112973,1.895438191254833 0.465634879292759,1.916225863863981 0.421161023015324,1.934806268115173 0.37572073469589,1.951134642187117 0.329423483969116,1.965171649596476 0.282380804967164,1.976883473962906 0.234706027624203,1.986241900475672 0.186514004654668,1.993224383865604 0.137920834863015,1.997814102718623 0.089043583451532,2.0 0.04,2 0)') g3 = g2.GetCurveGeometry() g1_expected = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,0.98 1.02,2 0)') - if not g3.Equals(g1_expected): - print(g3) - return 'fail' + assert g3.Equals(g1_expected) # Test default ( implicit option ADD_INTERMEDIATE_POINT=STEALTH ) g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test with Z g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0 1,1 1 2,2 0 3)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (2 0 3,1 1 2,0 0 1)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test option ADD_INTERMEDIATE_POINT=STEALTH g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = g1.GetLinearGeometry(options=['ADD_INTERMEDIATE_POINT=STEALTH']) g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test option ADD_INTERMEDIATE_POINT=YES g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = g1.GetLinearGeometry(options=['ADD_INTERMEDIATE_POINT=YES']) g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test with big coordinates. The points are (2,49),(3,50),(4,49) reprojected from EPSG:4326 to EPSG:32631 g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (426857.987717275 5427937.52346616,500000.000000001 5538630.70286887,573142.012282726 5427937.52346616)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if ogrtest.check_feature_geometry(g3, g1) != 0: - print(g3) - return 'fail' + assert ogrtest.check_feature_geometry(g3, g1) == 0 # Same with integer coordinates g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (426858 5427938,500000 5538632,573142 5427938)') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test option ADD_INTERMEDIATE_POINT=FALSE g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.2 1.0,2 0)') g2 = g1.GetLinearGeometry(options=['ADD_INTERMEDIATE_POINT=FALSE']) g3 = g2.GetCurveGeometry() g1_expected = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1.0 1.020199980003999,2 0)') - if ogrtest.check_feature_geometry(g3, g1_expected) != 0: - print(g3) - return 'fail' + assert ogrtest.check_feature_geometry(g3, g1_expected) == 0 # Test with unrecognized options gdal.PushErrorHandler('CPLQuietErrorHandler') g2_new = g1.GetLinearGeometry(options=['bla', 'ADD_INTERMEDIATE_POINT=FALSE', 'foo=bar']) gdal.PopErrorHandler() - if not g2_new.Equals(g2): - print(g2_new) - return 'fail' + assert g2_new.Equals(g2) # Add repeated point at end of line g2 = g1.GetLinearGeometry() g2.AddPoint_2D(2 - 1e-9, 0) g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Add repeated point at end of line g2 = g1.GetLinearGeometry() @@ -3198,9 +2540,7 @@ def test_ogr_geom_getcurvegeometry(): for i in range(g2.GetPointCount()): g2_new.AddPoint_2D(g2.GetX(i), g2.GetY(i)) g3 = g2_new.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test various configurations for (wkt, eps) in [('CIRCULARSTRING (0 0,0.5 0.5,0 1,-0.5 0.5,0 0)', 0), @@ -3226,72 +2566,52 @@ def test_ogr_geom_getcurvegeometry(): g1 = ogr.CreateGeometryFromWkt(wkt) g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if (eps == 0 and not g3.Equals(g1)) or (eps > 0 and ogrtest.check_feature_geometry(g3, g1, eps) != 0): - print('') - print(g1) - print(g3) - print(ogrtest.check_feature_geometry(g3, g1, 1e-6)) - return 'fail' + assert not (eps == 0 and not g3.Equals(g1)) or (eps > 0 and ogrtest.check_feature_geometry(g3, g1, eps) != 0), \ + '' # Test with GEOMETRYCOLLECTION container g1 = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(CIRCULARSTRING (0 0,0.5 0.5,0 1,-0.5 0.5,0 0))') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test with MULTICURVE container g1 = ogr.CreateGeometryFromWkt('MULTICURVE(CIRCULARSTRING (0 0,0.5 0.5,0 1,-0.5 0.5,0 0))') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) # Test with MULTISURFACE container g1 = ogr.CreateGeometryFromWkt('MULTISURFACE(CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING (0 0,0.5 0.5,1 0),(1 0,0 0))))') g2 = g1.GetLinearGeometry() g3 = g2.GetCurveGeometry() - if not g3.Equals(g1): - print(g3) - return 'fail' + assert g3.Equals(g1) if ogrtest.have_geos(): g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (0 0,2 0,0 0))') g2 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (1 0,3 1,1 0))') g3 = g1.Intersection(g2) - if g3.GetGeometryType() != ogr.wkbCurvePolygon: - print(g3) - return 'fail' + assert g3.GetGeometryType() == ogr.wkbCurvePolygon g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (0 0,2 0,0 0))') g2 = ogr.CreateGeometryFromWkt('CURVEPOLYGON((1 -1,1 1,3 1,3 -1,1 -1))') g3 = g1.Intersection(g2) - if g3.GetGeometryType() != ogr.wkbCurvePolygon: - print(g3) - return 'fail' + assert g3.GetGeometryType() == ogr.wkbCurvePolygon g1 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (0 0,2 0,0 0))') g2 = ogr.CreateGeometryFromWkt('CURVEPOLYGON(CIRCULARSTRING (3 0,5 0,3 0))') g3 = g1.Union(g2) - if g3.ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,2 0,0 0)),CURVEPOLYGON (CIRCULARSTRING (3 0,5 0,3 0)))': - print(g3) - return 'fail' + assert g3.ExportToWkt() == 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,2 0,0 0)),CURVEPOLYGON (CIRCULARSTRING (3 0,5 0,3 0)))' g1 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,1 1,2 0))') g2 = ogr.CreateGeometryFromWkt('CIRCULARSTRING (2 0,1 -1,0 0))') g3 = g1.Union(g2) - if g3.ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,1 -1,0 0))': - print(g3) - return 'fail' + assert g3.ExportToWkt() == 'MULTICURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,1 -1,0 0))' g1 = ogr.CreateGeometryFromWkt('POINT(1 2)') g1 = g1.Buffer(0.5) g1 = g1.GetCurveGeometry() - if g1.ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (1.5 2.0,0.5 2.0,1.5 2.0))': - print(g1) - return 'fail' + assert g1.ExportToWkt() == 'CURVEPOLYGON (CIRCULARSTRING (1.5 2.0,0.5 2.0,1.5 2.0))' return 'success' @@ -3311,9 +2631,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringM, 0), (ogr.wkbCircularStringZM, 1)] for (gt, res) in tuples: - if ogr.GT_HasZ(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_HasZ(gt) == res # GT_SetZ tuples = [(ogr.wkbPoint, ogr.wkbPoint25D), @@ -3325,9 +2643,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringM, ogr.wkbCircularStringZM), (ogr.wkbCircularStringZM, ogr.wkbCircularStringZM)] for (gt, res) in tuples: - if ogr.GT_SetZ(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_SetZ(gt) == res # GT_HasM tuples = [(ogr.wkbPoint, 0), @@ -3339,9 +2655,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringM, 1), (ogr.wkbCircularStringZM, 1)] for (gt, res) in tuples: - if ogr.GT_HasM(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_HasM(gt) == res # GT_SetM tuples = [(ogr.wkbPoint, ogr.wkbPointM), @@ -3353,9 +2667,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringM, ogr.wkbCircularStringM), (ogr.wkbCircularStringZM, ogr.wkbCircularStringZM)] for (gt, res) in tuples: - if ogr.GT_SetM(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_SetM(gt) == res # OGR_GT_SetModifier tuples = [(ogr.wkbPoint, 0, 0, ogr.wkbPoint), @@ -3377,9 +2689,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularString, 0, 0, ogr.wkbCircularString), (ogr.wkbCircularStringZ, 0, 0, ogr.wkbCircularString)] for (gt, modZ, modM, res) in tuples: - if ogr.GT_SetModifier(gt, modZ, modM) != res: - print(gt) - return 'fail' + assert ogr.GT_SetModifier(gt, modZ, modM) == res # GT_Flatten tuples = [(ogr.wkbPoint, ogr.wkbPoint), @@ -3392,9 +2702,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbCircularStringM, ogr.wkbCircularString), (ogr.wkbCircularStringZM, ogr.wkbCircularString)] for (gt, res) in tuples: - if ogr.GT_Flatten(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_Flatten(gt) == res # GT_IsSubClassOf tuples = [(ogr.wkbPoint, ogr.wkbPoint, 1), @@ -3413,10 +2721,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbPolyhedralSurface, ogr.wkbTIN, 0), ] for (gt, gt2, res) in tuples: - if ogr.GT_IsSubClassOf(gt, gt2) != res: - print(gt) - print(gt2) - return 'fail' + assert ogr.GT_IsSubClassOf(gt, gt2) == res # GT_IsCurve tuples = [(ogr.wkbPoint, 0), @@ -3435,9 +2740,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbPolyhedralSurface, 0), (ogr.wkbTIN, 0)] for (gt, res) in tuples: - if ogr.GT_IsCurve(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_IsCurve(gt) == res # GT_IsSurface tuples = [(ogr.wkbPoint, 0), @@ -3454,9 +2757,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbPolyhedralSurface, 1), (ogr.wkbTIN, 1)] for (gt, res) in tuples: - if ogr.GT_IsSurface(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_IsSurface(gt) == res # GT_GetCollection tuples = [(ogr.wkbPoint, ogr.wkbMultiPoint), @@ -3469,9 +2770,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbLineString, ogr.wkbMultiLineString), (ogr.wkbPolygon, ogr.wkbMultiPolygon)] for (gt, res) in tuples: - if ogr.GT_GetCollection(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_GetCollection(gt) == res # GT_IsNonLinear tuples = [(ogr.wkbPoint, 0), @@ -3490,9 +2789,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbPolygon, 0), (ogr.wkbTriangle, 0)] for (gt, res) in tuples: - if ogr.GT_IsNonLinear(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_IsNonLinear(gt) == res # GT_GetCurve tuples = [(ogr.wkbPoint, ogr.wkbPoint), @@ -3512,9 +2809,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbMultiCurve, ogr.wkbMultiCurve), (ogr.wkbMultiSurface, ogr.wkbMultiSurface)] for (gt, res) in tuples: - if ogr.GT_GetCurve(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_GetCurve(gt) == res # GT_GetLinear tuples = [(ogr.wkbPoint, ogr.wkbPoint), @@ -3534,9 +2829,7 @@ def test_ogr_geom_gt_functions(): (ogr.wkbMultiCurve, ogr.wkbMultiLineString), (ogr.wkbMultiSurface, ogr.wkbMultiPolygon)] for (gt, res) in tuples: - if ogr.GT_GetLinear(gt) != res: - print(gt) - return 'fail' + assert ogr.GT_GetLinear(gt) == res return 'success' @@ -3598,48 +2891,31 @@ def test_ogr_geom_equals(): p_empty = ogr.Geometry(ogr.wkbPoint) p_0 = ogr.CreateGeometryFromWkt('POINT (0 0)') p_1 = ogr.CreateGeometryFromWkt('POINT (1 1)') - if not p_empty.Equals(p_empty): - return 'fail' - if not p_0.Equals(p_0): - return 'fail' - if not p_0.Equals(p_0.Clone()): - return 'fail' - if p_empty.Equals(p_0): - return 'fail' - if p_0.Equals(p_empty): - return 'fail' - if p_0.Equals(p_1): - return 'fail' + assert p_empty.Equals(p_empty) + assert p_0.Equals(p_0) + assert p_0.Equals(p_0.Clone()) + assert not p_empty.Equals(p_0) + assert not p_0.Equals(p_empty) + assert not p_0.Equals(p_1) l_empty = ogr.Geometry(ogr.wkbLineString) l_0_1 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,1 1)') l_0_1_2 = ogr.CreateGeometryFromWkt('LINESTRING (0 0,1 1,2 2)') - if not l_0_1.Equals(l_0_1): - return 'fail' - if not l_0_1.Equals(l_0_1.Clone()): - return 'fail' - if l_empty.Equals(l_0_1): - return 'fail' - if l_0_1.Equals(l_empty): - return 'fail' - if l_0_1.Equals(l_0_1_2): - return 'fail' + assert l_0_1.Equals(l_0_1) + assert l_0_1.Equals(l_0_1.Clone()) + assert not l_empty.Equals(l_0_1) + assert not l_0_1.Equals(l_empty) + assert not l_0_1.Equals(l_0_1_2) gc_empty = ogr.Geometry(ogr.wkbGeometryCollection) gc_p_0 = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (0 0))') gc_p_1 = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 1))') - if not gc_empty.Equals(gc_empty): - return 'fail' - if not gc_p_0.Equals(gc_p_0): - return 'fail' - if not gc_p_0.Equals(gc_p_0.Clone()): - return 'fail' - if gc_empty.Equals(gc_p_0): - return 'fail' - if gc_p_0.Equals(gc_empty): - return 'fail' - if gc_p_0.Equals(gc_p_1): - return 'fail' + assert gc_empty.Equals(gc_empty) + assert gc_p_0.Equals(gc_p_0) + assert gc_p_0.Equals(gc_p_0.Clone()) + assert not gc_empty.Equals(gc_p_0) + assert not gc_p_0.Equals(gc_empty) + assert not gc_p_0.Equals(gc_p_1) return 'success' @@ -3685,59 +2961,37 @@ def test_ogr_geom_measured_geometries_to_2D_or_3D(): geom2 = ogr.CreateGeometryFromWkb(wkb) if not geom.Equals(geom2): print(before) - print(geom2.ExportToIsoWkt()) - return 'fail' + pytest.fail(geom2.ExportToIsoWkt()) geom = ogr.CreateGeometryFromWkt(before) geom.FlattenTo2D() - if geom.ExportToIsoWkt() != after_2D: - print(before) - print(after_2D) - print(geom.ExportToIsoWkt()) - return 'fail' + assert geom.ExportToIsoWkt() == after_2D, before geom = ogr.CreateGeometryFromWkt(before) geom.SetCoordinateDimension(2) - if geom.ExportToIsoWkt() != after_2D: - print(before) - print(after_2D) - print(geom.ExportToIsoWkt()) - return 'fail' + assert geom.ExportToIsoWkt() == after_2D, before geom = ogr.CreateGeometryFromWkt(before) geom.SetCoordinateDimension(3) - if geom.ExportToIsoWkt() != after_3D: - print(before) - print(after_3D) - print(geom.ExportToIsoWkt()) - return 'fail' + assert geom.ExportToIsoWkt() == after_3D, before # Test no-op geom = ogr.CreateGeometryFromWkt(before) geom.Set3D(geom.Is3D()) geom.SetMeasured(geom.IsMeasured()) - if geom.ExportToIsoWkt() != before: - print(before) - print(geom.ExportToIsoWkt()) - return 'fail' + assert geom.ExportToIsoWkt() == before - if ogr.CreateGeometryFromWkt('POINT (1 2)').CoordinateDimension() != 2: - return 'fail' + assert ogr.CreateGeometryFromWkt('POINT (1 2)').CoordinateDimension() == 2 - if ogr.CreateGeometryFromWkt('POINT M (1 2 3)').CoordinateDimension() != 3: - return 'fail' + assert ogr.CreateGeometryFromWkt('POINT M (1 2 3)').CoordinateDimension() == 3 - if ogr.CreateGeometryFromWkt('POINT Z (1 2 3)').CoordinateDimension() != 3: - return 'fail' + assert ogr.CreateGeometryFromWkt('POINT Z (1 2 3)').CoordinateDimension() == 3 - if ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)').CoordinateDimension() != 4: - return 'fail' + assert ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)').CoordinateDimension() == 4 # Unrelated test. Test old-style unqualified non-bracketted ZM import g = ogr.CreateGeometryFromWkt('MULTIPOINT (1 2 3 4)') - if g.ExportToIsoWkt() != 'MULTIPOINT ZM ((1 2 3 4))': - print(g.ExportToIsoWkt()) - return 'fail' + assert g.ExportToIsoWkt() == 'MULTIPOINT ZM ((1 2 3 4))' return 'success' @@ -3752,11 +3006,7 @@ def test_ogr_geom_postgis_ewkt_xym(): ] for (before, after) in list_wkt: geom = ogr.CreateGeometryFromWkt(before) - if geom.ExportToIsoWkt() != after: - print(before) - print(after) - print(geom.ExportToIsoWkt()) - return 'fail' + assert geom.ExportToIsoWkt() == after, before return 'success' @@ -3776,11 +3026,7 @@ def test_ogr_geom_curve_surface(): [ogr.wkbSurfaceZM, "3D Measured Surface"]] for (wkb_type, name) in tests: - if ogr.GeometryTypeToName(wkb_type) != name: - print(wkb_type) - print(name) - print(ogr.GeometryTypeToName(wkb_type)) - return 'fail' + assert ogr.GeometryTypeToName(wkb_type) == name return 'success' @@ -3829,9 +3075,7 @@ def test_ogr_geom_import_corrupted_wkb(): g = ogr.CreateGeometryFromWkb(str(wkb)) if g: g2 = ogr.CreateGeometryFromWkb(g.ExportToIsoWkb()) - if not g.Equals(g2): - print(wkt, i, method) - return 'fail' + assert g.Equals(g2), (wkt, i, method) wkb[i] = init_val # Test truncation of the WKB @@ -3841,9 +3085,7 @@ def test_ogr_geom_import_corrupted_wkb(): g = ogr.CreateGeometryFromWkb(bytes(wkb[0:i])) else: g = ogr.CreateGeometryFromWkb(str(wkb[0:i])) - if g is not None: - print(wkt, i) - return 'fail' + assert g is None, (wkt, i) return 'success' @@ -3873,49 +3115,31 @@ def test_ogr_geom_triangle_ps_tin_conversion(): wkt_expected = wkt_target if (g.GetGeometryType() == ogr.wkbTIN or g.GetGeometryType() == ogr.wkbPolyhedralSurface) and g2.GetGeometryType() == ogr.wkbCurvePolygon: wkt_expected = wkt - if got_wkt != wkt_expected: - print(wkt, wkt_target, got_wkt, wkt_expected) - return 'fail' + assert got_wkt == wkt_expected, (wkt, wkt_target, got_wkt, wkt_expected) g = ogr.ForceTo(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,1 0,0 0))'), ogr.wkbTriangle) - if g.GetGeometryType() != ogr.wkbPolygon: - print(g.ExportToWkt()) - return 'fail' + assert g.GetGeometryType() == ogr.wkbPolygon, g.ExportToWkt() g = ogr.ForceTo(ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE (((0 0,0 1,1 1,1 0,0 0)))'), ogr.wkbTIN) - if g.GetGeometryType() != ogr.wkbPolyhedralSurface: - print(g.ExportToWkt()) - return 'fail' + assert g.GetGeometryType() == ogr.wkbPolyhedralSurface, g.ExportToWkt() g = ogr.ForceTo(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POLYHEDRALSURFACE (((0 0,0 1,1 1,1 0,0 0))))'), ogr.wkbMultiPolygon) - if g.ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)))': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)))' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (TRIANGLE ((0 0,0 1,1 1,0 0)))'), ogr.wkbMultiPolygon) - if g.ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('MULTIPOLYGON (((0 0,0 1,1 1,0 0)))'), ogr.wkbGeometryCollection) - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('TRIANGLE ((0 0,0 1,1 1,0 0))'), ogr.wkbGeometryCollection) - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (TRIANGLE ((0 0,0 1,1 1,0 0)))': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (TRIANGLE ((0 0,0 1,1 1,0 0)))' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('TIN (((0 0,0 1,1 1,0 0)))'), ogr.wkbGeometryCollection) - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))' g = ogr.ForceTo(ogr.CreateGeometryFromWkt('POLYHEDRALSURFACE (((0 0,0 1,1 1,0 0)))'), ogr.wkbGeometryCollection) - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - print(g.ExportToWkt()) - return 'fail' + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))' return 'success' @@ -3926,15 +3150,11 @@ def test_ogr_geom_multipoint_envelope_bug(): g = ogr.CreateGeometryFromWkt('MULTIPOINT(0 0,1 1)') minx, maxx, miny, maxy = g.GetEnvelope() - if (minx, maxx, miny, maxy) != (0, 1, 0, 1): - print(minx, maxx, miny, maxy) - return 'fail' + assert (minx, maxx, miny, maxy) == (0, 1, 0, 1) g = ogr.CreateGeometryFromWkt('MULTIPOINT(0 0 0,1 1 1)') minx, maxx, miny, maxy, minz, maxz = g.GetEnvelope3D() - if (minx, maxx, miny, maxy, minz, maxz) != (0, 1, 0, 1, 0, 1): - print(minx, maxx, miny, maxy, minz, maxz) - return 'fail' + assert (minx, maxx, miny, maxy, minz, maxz) == (0, 1, 0, 1, 0, 1) return 'success' @@ -3946,8 +3166,7 @@ def test_ogr_geom_polygon_empty_ring(): g = ogr.Geometry(ogr.wkbPolygon) g2 = ogr.Geometry(ogr.wkbLinearRing) g.AddGeometryDirectly(g2) - if not g.IsEmpty(): - return 'fail' + assert g.IsEmpty() return 'success' @@ -3962,10 +3181,8 @@ def test_ogr_geom_polygon_intersects_point(): poly = ogr.CreateGeometryFromWkt('POLYGON((0 0,5 5,10 0,0 0))') point = ogr.Geometry(ogr.wkbPoint) point.AddPoint(10, 0) - if poly.Intersects(point) != 1: - return 'fail' - if poly.Contains(point) != 0: - return 'fail' + assert poly.Intersects(point) == 1 + assert poly.Contains(point) == 0 return 'success' @@ -3992,9 +3209,7 @@ def test_ogr_geom_geometrycollection(): 'GEOMETRYCOLLECTION (TIN EMPTY)'] for wkt in wkt_list: g = ogr.CreateGeometryFromWkt(wkt) - if g.ExportToWkt() != wkt: - print(g.ExportToWkt(), wkt) - return 'fail' + assert g.ExportToWkt() == wkt return 'success' @@ -4008,18 +3223,12 @@ def test_ogr_geom_assignspatialref(): sr = osr.SpatialReference() sr.ImportFromEPSG(4326) g.AssignSpatialReference(sr) - if g.GetGeometryRef(0).GetSpatialReference().ExportToWkt() != sr.ExportToWkt(): - return 'fail' - if g.GetGeometryRef(0).GetGeometryRef(0).GetSpatialReference().ExportToWkt() != sr.ExportToWkt(): - return 'fail' - if g.GetGeometryRef(1).GetSpatialReference().ExportToWkt() != sr.ExportToWkt(): - return 'fail' - if g.GetGeometryRef(1).GetGeometryRef(0).GetSpatialReference().ExportToWkt() != sr.ExportToWkt(): - return 'fail' - if g.GetGeometryRef(2).GetSpatialReference().ExportToWkt() != sr.ExportToWkt(): - return 'fail' - if g.GetGeometryRef(2).GetGeometryRef(0).GetSpatialReference().ExportToWkt() != sr.ExportToWkt(): - return 'fail' + assert g.GetGeometryRef(0).GetSpatialReference().ExportToWkt() == sr.ExportToWkt() + assert g.GetGeometryRef(0).GetGeometryRef(0).GetSpatialReference().ExportToWkt() == sr.ExportToWkt() + assert g.GetGeometryRef(1).GetSpatialReference().ExportToWkt() == sr.ExportToWkt() + assert g.GetGeometryRef(1).GetGeometryRef(0).GetSpatialReference().ExportToWkt() == sr.ExportToWkt() + assert g.GetGeometryRef(2).GetSpatialReference().ExportToWkt() == sr.ExportToWkt() + assert g.GetGeometryRef(2).GetGeometryRef(0).GetSpatialReference().ExportToWkt() == sr.ExportToWkt() return 'success' @@ -4030,9 +3239,7 @@ def test_ogr_geom_swapxy(): g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(1 2,2 3),POLYGON((0 0,0 1,1 1,0 0)),COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,2 0)),POLYHEDRALSURFACE(((0 0,0 1,1 1,0 0))))') g.SwapXY() - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (2 1),LINESTRING (2 1,3 2),POLYGON ((0 0,1 0,1 1,0 0)),COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,0 2)),POLYHEDRALSURFACE (((0 0,1 0,1 1,0 0))))': - print(g) - return 'fail' + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (POINT (2 1),LINESTRING (2 1,3 2),POLYGON ((0 0,1 0,1 1,0 0)),COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,0 2)),POLYHEDRALSURFACE (((0 0,1 0,1 1,0 0))))' return 'success' @@ -4043,86 +3250,52 @@ def test_ogr_geom_remove_geometry(): # With GEOMETRYCOLLECTION g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 2),LINESTRING (1 2,2 3),POINT (3 4))') - if g.RemoveGeometry(3) == 0 or g.RemoveGeometry(-2) == 0: - return 'fail' + assert not (g.RemoveGeometry(3) == 0 or g.RemoveGeometry(-2) == 0) - if g.RemoveGeometry(1) != 0: - return 'fail' - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (1 2),POINT (3 4))': - print(g) - return 'fail' + assert g.RemoveGeometry(1) == 0 + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (POINT (1 2),POINT (3 4))' - if g.RemoveGeometry(1) != 0: - return 'fail' - if g.ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (1 2))': - print(g) - return 'fail' + assert g.RemoveGeometry(1) == 0 + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION (POINT (1 2))' - if g.RemoveGeometry(0) != 0: - return 'fail' - if g.ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': - print(g) - return 'fail' + assert g.RemoveGeometry(0) == 0 + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION EMPTY' g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (1 2),LINESTRING (1 2,2 3),POINT (3 4))') - if g.RemoveGeometry(-1) != 0: - return 'fail' - if g.ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': - print(g) - return 'fail' + assert g.RemoveGeometry(-1) == 0 + assert g.ExportToWkt() == 'GEOMETRYCOLLECTION EMPTY' # With POLYHEDRALSURFACE/TIN g = ogr.CreateGeometryFromWkt('TIN (((0 0,0 1,1 1,0 0)),((0 0,1 0,1 1,0 0)))') - if g.RemoveGeometry(2) == 0 or g.RemoveGeometry(-2) == 0: - return 'fail' + assert not (g.RemoveGeometry(2) == 0 or g.RemoveGeometry(-2) == 0) - if g.RemoveGeometry(1) != 0: - return 'fail' - if g.ExportToWkt() != 'TIN (((0 0,0 1,1 1,0 0)))': - print(g) - return 'fail' + assert g.RemoveGeometry(1) == 0 + assert g.ExportToWkt() == 'TIN (((0 0,0 1,1 1,0 0)))' - if g.RemoveGeometry(0) != 0: - return 'fail' - if g.ExportToWkt() != 'TIN EMPTY': - print(g) - return 'fail' + assert g.RemoveGeometry(0) == 0 + assert g.ExportToWkt() == 'TIN EMPTY' g = ogr.CreateGeometryFromWkt('TIN (((0 0,0 1,1 1,0 0)),((0 0,1 0,1 1,0 0)))') - if g.RemoveGeometry(-1) != 0: - return 'fail' - if g.ExportToWkt() != 'TIN EMPTY': - print(g) - return 'fail' + assert g.RemoveGeometry(-1) == 0 + assert g.ExportToWkt() == 'TIN EMPTY' # With POLYGON g = ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,1 9,9 9,1 1))') - if g.RemoveGeometry(2) == 0 or g.RemoveGeometry(-2) == 0: - return 'fail' + assert not (g.RemoveGeometry(2) == 0 or g.RemoveGeometry(-2) == 0) - if g.RemoveGeometry(1) != 0: - return 'fail' - if g.ExportToWkt() != 'POLYGON ((0 0,0 10,10 10,10 0,0 0))': - print(g) - return 'fail' + assert g.RemoveGeometry(1) == 0 + assert g.ExportToWkt() == 'POLYGON ((0 0,0 10,10 10,10 0,0 0))' - if g.RemoveGeometry(0) != 0: - return 'fail' - if g.ExportToWkt() != 'POLYGON EMPTY': - print(g) - return 'fail' + assert g.RemoveGeometry(0) == 0 + assert g.ExportToWkt() == 'POLYGON EMPTY' g = ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,1 9,9 9,1 1))') - if g.RemoveGeometry(-1) != 0: - return 'fail' - if g.ExportToWkt() != 'POLYGON EMPTY': - print(g) - return 'fail' + assert g.RemoveGeometry(-1) == 0 + assert g.ExportToWkt() == 'POLYGON EMPTY' # Unsupported type g = ogr.CreateGeometryFromWkt('POINT (0 0)') - if g.RemoveGeometry(0) == 0: - return 'fail' + assert g.RemoveGeometry(0) != 0 return 'success' @@ -4154,8 +3327,7 @@ def test_ogr_geom_sfcgal(): def test_ogr_geom_cannot_add_triangle_to_multisurface(): g = ogr.Geometry(ogr.wkbMultiSurface) - if g.AddGeometry(ogr.Geometry(ogr.wkbTriangle)) == 0: - return 'fail' + assert g.AddGeometry(ogr.Geometry(ogr.wkbTriangle)) != 0 return 'success' ############################################################################### @@ -4164,9 +3336,7 @@ def test_ogr_geom_cannot_add_triangle_to_multisurface(): def test_ogr_geom_force_polygonzm_to_linestring(): g = ogr.CreateGeometryFromWkt('POLYGON ZM ((0 0 10 20,0 1 30 40,1 1 50 60,0 0 10 70))') wkt = ogr.ForceToLineString(g).ExportToIsoWkt() - if wkt != 'LINESTRING ZM (0 0 10 20,0 1 30 40,1 1 50 60,0 0 10 70)': - print(wkt) - return 'fail' + assert wkt == 'LINESTRING ZM (0 0 10 20,0 1 30 40,1 1 50 60,0 0 10 70)' return 'success' ############################################################################### diff --git a/autotest/ogr/ogr_georss.py b/autotest/ogr/ogr_georss.py index 9d377624f90b..456170bd9243 100755 --- a/autotest/ogr/ogr_georss.py +++ b/autotest/ogr/ogr_georss.py @@ -37,6 +37,7 @@ from osgeo import ogr from osgeo import osr from osgeo import gdal +import pytest def test_ogr_georss_init(): @@ -91,20 +92,16 @@ def ogr_georss_test_atom(filename): ds = ogr.Open(filename) lyr = ds.GetLayerByName('georss') - if lyr.GetSpatialRef() is not None: - gdaltest.post_reason('No spatial ref expected') - return 'fail' + assert lyr.GetSpatialRef() is None, 'No spatial ref expected' feat = lyr.GetNextFeature() for field_value in gdaltest.atom_field_values: - if feat.GetFieldAsString(field_value[0]) != field_value[1]: - gdaltest.post_reason('For field "%s", got "%s" instead of "%s"' % (field_value[0], feat.GetFieldAsString(field_value[0]), field_value[1])) - return 'fail' + assert feat.GetFieldAsString(field_value[0]) == field_value[1], \ + ('For field "%s", got "%s" instead of "%s"' % (field_value[0], feat.GetFieldAsString(field_value[0]), field_value[1])) - if feat.GetFieldAsString('content').find('
      ') == -1: - gdaltest.post_reason('For field "%s", got "%s"' % ('content', feat.GetFieldAsString('content'))) - return 'fail' + assert feat.GetFieldAsString('content').find('
      ') != -1, \ + ('For field "%s", got "%s"' % ('content', feat.GetFieldAsString('content'))) return 'success' @@ -147,9 +144,7 @@ def test_ogr_georss_1bis(): dst_feat.SetField(field_value[0], field_value[1]) dst_feat.SetField('content', '

      [Update: The Atom draft is finished.]

      ') - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None @@ -173,17 +168,15 @@ def ogr_georss_test_rss(filename, only_first_feature): return 'skip' ds = ogr.Open(filename) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) srs = osr.SpatialReference() srs.SetWellKnownGeogCS('WGS84') - if lyr.GetSpatialRef() is None or not lyr.GetSpatialRef().IsSame(srs): - gdaltest.post_reason('SRS is not the one expected.') - return 'fail' + assert lyr.GetSpatialRef() is not None and lyr.GetSpatialRef().IsSame(srs), \ + 'SRS is not the one expected.' if lyr.GetSpatialRef().ExportToWkt().find('AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') != -1: lyr.GetSpatialRef().ExportToWkt() @@ -192,49 +185,34 @@ def ogr_georss_test_rss(filename, only_first_feature): feat = lyr.GetNextFeature() expected_wkt = 'POINT (2 49)' - if feat.GetGeometryRef().ExportToWkt() != expected_wkt: - print(('%s' % feat.GetGeometryRef().ExportToWkt())) - return 'fail' - if feat.GetFieldAsString('title') != 'A point': - return 'fail' - if feat.GetFieldAsString('author') != 'Author': - return 'fail' - if feat.GetFieldAsString('link') != 'http://gdal.org': - return 'fail' - if feat.GetFieldAsString('pubDate') != '2008/12/07 20:13:00+02': - return 'fail' - if feat.GetFieldAsString('category') != 'First category': - return 'fail' - if feat.GetFieldAsString('category_domain') != 'first_domain': - return 'fail' - if feat.GetFieldAsString('category2') != 'Second category': - return 'fail' - if feat.GetFieldAsString('category2_domain') != 'second_domain': - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == expected_wkt, \ + ('%s' % feat.GetGeometryRef().ExportToWkt()) + assert feat.GetFieldAsString('title') == 'A point' + assert feat.GetFieldAsString('author') == 'Author' + assert feat.GetFieldAsString('link') == 'http://gdal.org' + assert feat.GetFieldAsString('pubDate') == '2008/12/07 20:13:00+02' + assert feat.GetFieldAsString('category') == 'First category' + assert feat.GetFieldAsString('category_domain') == 'first_domain' + assert feat.GetFieldAsString('category2') == 'Second category' + assert feat.GetFieldAsString('category2_domain') == 'second_domain' feat = lyr.GetNextFeature() expected_wkt = 'LINESTRING (2 48,2.1 48.1,2.2 48.0)' - if only_first_feature is False and feat.GetGeometryRef().ExportToWkt() != expected_wkt: - print(('%s' % feat.GetGeometryRef().ExportToWkt())) - return 'fail' - if feat.GetFieldAsString('title') != 'A line': - return 'fail' + assert only_first_feature is not False or feat.GetGeometryRef().ExportToWkt() == expected_wkt, \ + ('%s' % feat.GetGeometryRef().ExportToWkt()) + assert feat.GetFieldAsString('title') == 'A line' feat = lyr.GetNextFeature() expected_wkt = 'POLYGON ((2 50,2.1 50.1,2.2 48.1,2.1 46.1,2 50))' - if only_first_feature is False and feat.GetGeometryRef().ExportToWkt() != expected_wkt: - print(('%s' % feat.GetGeometryRef().ExportToWkt())) - return 'fail' - if feat.GetFieldAsString('title') != 'A polygon': - return 'fail' + assert only_first_feature is not False or feat.GetGeometryRef().ExportToWkt() == expected_wkt, \ + ('%s' % feat.GetGeometryRef().ExportToWkt()) + assert feat.GetFieldAsString('title') == 'A polygon' feat = lyr.GetNextFeature() expected_wkt = 'POLYGON ((2 49,2.0 49.5,2.2 49.5,2.2 49.0,2 49))' - if only_first_feature is False and feat.GetGeometryRef().ExportToWkt() != expected_wkt: - print(('%s' % feat.GetGeometryRef().ExportToWkt())) - return 'fail' - if feat.GetFieldAsString('title') != 'A box': - return 'fail' + assert only_first_feature is not False or feat.GetGeometryRef().ExportToWkt() == expected_wkt, \ + ('%s' % feat.GetGeometryRef().ExportToWkt()) + assert feat.GetFieldAsString('title') == 'A box' return 'success' @@ -291,9 +269,7 @@ def ogr_georss_create(filename, options): dst_feat.SetField('category2_domain', 'second_domain') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn()) dst_feat.SetField('title', 'A line') @@ -302,9 +278,7 @@ def ogr_georss_create(filename, options): dst_feat.SetField('pubDate', '2008/12/07 20:13:00+02') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('LINESTRING (2 48,2.1 48.1,2.2 48.0)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn()) dst_feat.SetField('title', 'A polygon') @@ -313,9 +287,7 @@ def ogr_georss_create(filename, options): dst_feat.SetField('pubDate', '2008/12/07 20:13:00+02') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((2 50,2.1 50.1,2.2 48.1,2.1 46.1,2 50))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn()) dst_feat.SetField('title', 'A box') @@ -324,9 +296,7 @@ def ogr_georss_create(filename, options): dst_feat.SetField('pubDate', '2008/12/07 20:13:00+02') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((2 49,2.0 49.5,2.2 49.5,2.2 49.0,2 49))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None @@ -341,9 +311,7 @@ def test_ogr_georss_4(): ogr_georss_create('tmp/test_rss2.xml', []) content = open('tmp/test_rss2.xml').read() - if content.find('49 2') == -1: - print(('%s' % content)) - return 'fail' + assert content.find('49 2') != -1, ('%s' % content) return 'success' @@ -364,9 +332,8 @@ def test_ogr_georss_6(): ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=GML']) content = open('tmp/test_rss2.xml').read() - if content.find('49 2') == -1: - print(('%s' % content)) - return 'fail' + assert content.find('49 2') != -1, \ + ('%s' % content) return 'success' @@ -389,9 +356,8 @@ def test_ogr_georss_8(): ogr_georss_create('tmp/test_rss2.xml', ['GEOM_DIALECT=W3C_GEO']) content = open('tmp/test_rss2.xml').read() - if content.find('49') == -1 or content.find('2') == -1: - print(('%s' % content)) - return 'fail' + assert not (content.find('49') == -1 or content.find('2') == -1), \ + ('%s' % content) return 'success' @@ -423,9 +389,7 @@ def test_ogr_georss_10(): except: lyr = None gdal.PopErrorHandler() - if lyr is not None: - gdaltest.post_reason('should not have accepted EPSG:32631 with GEOM_DIALECT != GML') - return 'fail' + assert lyr is None, 'should not have accepted EPSG:32631 with GEOM_DIALECT != GML' ds = None @@ -440,16 +404,13 @@ def test_ogr_georss_10(): dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (500000 4000000)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None content = open('tmp/test32631.rss').read() - if content.find('500000 4000000') == -1: - print(('%s' % content)) - return 'fail' + assert content.find('500000 4000000') != -1, \ + ('%s' % content) return 'success' @@ -470,20 +431,17 @@ def test_ogr_georss_11(): srs = osr.SpatialReference() srs.ImportFromEPSG(32631) - if lyr.GetSpatialRef() is None or not lyr.GetSpatialRef().IsSame(srs): - gdaltest.post_reason('SRS is not the one expected.') - return 'fail' + assert lyr.GetSpatialRef() is not None and lyr.GetSpatialRef().IsSame(srs), \ + 'SRS is not the one expected.' if lyr.GetSpatialRef().ExportToWkt().find('AXIS["Easting",EAST],AXIS["Northing",NORTH]') == -1: print(('%s' % lyr.GetSpatialRef().ExportToWkt())) - gdaltest.post_reason('AXIS definition expected is AXIS["Easting",EAST],AXIS["Northing",NORTH]!') - return 'fail' + pytest.fail('AXIS definition expected is AXIS["Easting",EAST],AXIS["Northing",NORTH]!') feat = lyr.GetNextFeature() expected_wkt = 'POINT (500000 4000000)' - if feat.GetGeometryRef().ExportToWkt() != expected_wkt: - print(('%s' % feat.GetGeometryRef().ExportToWkt())) - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == expected_wkt, \ + ('%s' % feat.GetGeometryRef().ExportToWkt()) return 'success' @@ -500,24 +458,21 @@ def test_ogr_georss_12(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogr.Open('tmp/broken.rss') gdal.PopErrorHandler() - if ds is not None: - return 'fail' + assert ds is None open('tmp/broken.rss', 'wt').write('49 2 49.5') ds = ogr.Open('tmp/broken.rss') gdal.PushErrorHandler('CPLQuietErrorHandler') feat = ds.GetLayer(0).GetNextFeature() gdal.PopErrorHandler() - if feat.GetGeometryRef() is not None: - return 'fail' + assert feat.GetGeometryRef() is None open('tmp/broken.rss', 'wt').write('48 2 48.1 2.1 48') ds = ogr.Open('tmp/broken.rss') gdal.PushErrorHandler('CPLQuietErrorHandler') feat = ds.GetLayer(0).GetNextFeature() gdal.PopErrorHandler() - if feat.GetGeometryRef() is not None: - return 'fail' + assert feat.GetGeometryRef() is None return 'success' @@ -542,22 +497,14 @@ def test_ogr_georss_13(): dst_feat.SetField('field2', 'val2') dst_feat.SetField('ogr_field3', 'val3') - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None content = open('tmp/nonstandard.rss').read() - if content.find('val') == -1: - print(('%s' % content)) - return 'fail' - if content.find('val2') == -1: - print(('%s' % content)) - return 'fail' - if content.find('val3') == -1: - print(('%s' % content)) - return 'fail' + assert content.find('val') != -1, ('%s' % content) + assert content.find('val2') != -1, ('%s' % content) + assert content.find('val3') != -1, ('%s' % content) return 'success' @@ -575,15 +522,12 @@ def test_ogr_georss_14(): feat = lyr.GetNextFeature() - if feat.GetFieldAsString('myns_field') != 'val': - print(('Expected %s. Got %s' % ('val', feat.GetFieldAsString('myns_field')))) - return 'fail' - if feat.GetFieldAsString('ogr_field2') != 'val2': - print(('Expected %s. Got %s' % ('val2', feat.GetFieldAsString('ogr_field2')))) - return 'fail' - if feat.GetFieldAsString('ogr_field3') != 'val3': - print(('Expected %s. Got %s' % ('val3', feat.GetFieldAsString('ogr_field3')))) - return 'fail' + assert feat.GetFieldAsString('myns_field') == 'val', \ + ('Expected %s. Got %s' % ('val', feat.GetFieldAsString('myns_field'))) + assert feat.GetFieldAsString('ogr_field2') == 'val2', \ + ('Expected %s. Got %s' % ('val2', feat.GetFieldAsString('ogr_field2'))) + assert feat.GetFieldAsString('ogr_field3') == 'val3', \ + ('Expected %s. Got %s' % ('val3', feat.GetFieldAsString('ogr_field3'))) return 'success' @@ -623,9 +567,8 @@ def test_ogr_georss_15(): feat = lyr.GetNextFeature() - if feat.GetFieldAsString('title') != 'item title': - print(('Expected %s. Got %s' % ('item title', feat.GetFieldAsString('title')))) - return 'fail' + assert feat.GetFieldAsString('title') == 'item title', \ + ('Expected %s. Got %s' % ('item title', feat.GetFieldAsString('title'))) # Release memory associated to the in-memory file gdal.Unlink('/vsimem/georssinmem') diff --git a/autotest/ogr/ogr_geos.py b/autotest/ogr/ogr_geos.py index eba53c158d18..cfe3ec335b0a 100755 --- a/autotest/ogr/ogr_geos.py +++ b/autotest/ogr/ogr_geos.py @@ -49,8 +49,7 @@ def test_ogr_geos_union(): result = pnt1.Union(pnt2) - if ogrtest.check_feature_geometry(result, 'MULTIPOINT (10 20,30 20)'): - return 'fail' + assert not ogrtest.check_feature_geometry(result, 'MULTIPOINT (10 20,30 20)') return 'success' @@ -68,9 +67,8 @@ def test_ogr_geos_intersection(): result = g1.Intersection(g2) - if ogrtest.check_feature_geometry(result, 'POLYGON ((0 0,5 5,10 0,0 0))'): - gdaltest.post_reason('Got: %s' % result.ExportToWkt()) - return 'fail' + assert not ogrtest.check_feature_geometry(result, 'POLYGON ((0 0,5 5,10 0,0 0))'), \ + ('Got: %s' % result.ExportToWkt()) return 'success' @@ -88,10 +86,9 @@ def test_ogr_geos_difference(): result = g1.Difference(g2) - if ogrtest.check_feature_geometry(result, - 'POLYGON ((5 5,10 10,10 0,5 5))'): - gdaltest.post_reason('Got: %s' % result.ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(result, + 'POLYGON ((5 5,10 10,10 0,5 5))')), \ + ('Got: %s' % result.ExportToWkt()) return 'success' @@ -109,10 +106,9 @@ def test_ogr_geos_symmetric_difference(): result = g1.SymmetricDifference(g2) - if ogrtest.check_feature_geometry(result, - 'MULTIPOLYGON (((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))'): - gdaltest.post_reason('Got: %s' % result.ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(result, + 'MULTIPOLYGON (((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))')), \ + ('Got: %s' % result.ExportToWkt()) return 'success' @@ -130,10 +126,9 @@ def test_ogr_geos_sym_difference(): result = g1.SymDifference(g2) - if ogrtest.check_feature_geometry(result, - 'MULTIPOLYGON (((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))'): - gdaltest.post_reason('Got: %s' % result.ExportToWkt()) - return 'fail' + assert (not ogrtest.check_feature_geometry(result, + 'MULTIPOLYGON (((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))')), \ + ('Got: %s' % result.ExportToWkt()) return 'success' @@ -151,18 +146,14 @@ def test_ogr_geos_intersect(): result = g1.Intersect(g2) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' g1 = ogr.CreateGeometryFromWkt('LINESTRING(0 0, 10 10)') g2 = ogr.CreateGeometryFromWkt('POLYGON((20 20, 20 30, 30 20, 20 20))') result = g1.Intersect(g2) - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' return 'success' @@ -180,18 +171,14 @@ def test_ogr_geos_disjoint(): result = g1.Disjoint(g2) - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' g1 = ogr.CreateGeometryFromWkt('LINESTRING(0 0, 10 10)') g2 = ogr.CreateGeometryFromWkt('POLYGON((20 20, 20 30, 30 20, 20 20))') result = g1.Disjoint(g2) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' return 'success' @@ -209,18 +196,14 @@ def test_ogr_geos_touches(): result = g1.Touches(g2) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' g1 = ogr.CreateGeometryFromWkt('LINESTRING(0 0, 10 10)') g2 = ogr.CreateGeometryFromWkt('POLYGON((20 20, 20 30, 30 20, 20 20))') result = g1.Touches(g2) - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' return 'success' @@ -238,18 +221,14 @@ def test_ogr_geos_crosses(): result = g1.Crosses(g2) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' g1 = ogr.CreateGeometryFromWkt('LINESTRING(0 0, 10 10)') g2 = ogr.CreateGeometryFromWkt('LINESTRING(0 0, 0 10)') result = g1.Crosses(g2) - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' return 'success' @@ -266,15 +245,11 @@ def test_ogr_geos_within(): result = g1.Within(g2) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' result = g2.Within(g1) - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' return 'success' @@ -291,15 +266,11 @@ def test_ogr_geos_contains(): result = g2.Contains(g1) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' result = g1.Contains(g2) - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' return 'success' @@ -317,18 +288,14 @@ def test_ogr_geos_overlaps(): result = g2.Overlaps(g1) # g1 and g2 intersect, but their intersection is equal to g1 - if result != 0: - gdaltest.post_reason('wrong result (got true)') - return 'fail' + assert result == 0, 'wrong result (got true)' g1 = ogr.CreateGeometryFromWkt('POLYGON((0 0, 10 10, 10 0, 0 0))') g2 = ogr.CreateGeometryFromWkt('POLYGON((0 -5,10 5,10 -5,0 -5))') result = g2.Overlaps(g1) - if result == 0: - gdaltest.post_reason('wrong result (got false)') - return 'fail' + assert result != 0, 'wrong result (got false)' return 'success' @@ -344,10 +311,9 @@ def test_ogr_geos_buffer(): result = g1.Buffer(1.0, 3) - if ogrtest.check_feature_geometry(result, - 'POLYGON ((0 -1,-0.555570233019607 -0.831469612302542,-0.923879532511288 -0.382683432365087,-0.98078528040323 0.19509032201613,-0.707106781186547 0.707106781186547,9.292893218813452 10.707106781186548,9.690983005625053 10.951056516295154,10.156434465040231 10.987688340595138,10.587785252292473 10.809016994374947,10.891006524188368 10.453990499739547,11 10,11 0,10.866025403784439 -0.5,10.5 -0.866025403784439,10 -1,0 -1))') != 0: - gdaltest.post_reason('Got: %s' % result.ExportToWkt()) - return 'fail' + assert (ogrtest.check_feature_geometry(result, + 'POLYGON ((0 -1,-0.555570233019607 -0.831469612302542,-0.923879532511288 -0.382683432365087,-0.98078528040323 0.19509032201613,-0.707106781186547 0.707106781186547,9.292893218813452 10.707106781186548,9.690983005625053 10.951056516295154,10.156434465040231 10.987688340595138,10.587785252292473 10.809016994374947,10.891006524188368 10.453990499739547,11 10,11 0,10.866025403784439 -0.5,10.5 -0.866025403784439,10 -1,0 -1))') == 0), \ + ('Got: %s' % result.ExportToWkt()) return 'success' @@ -363,19 +329,17 @@ def test_ogr_geos_centroid(): centroid = g1.Centroid() - if ogrtest.check_feature_geometry(centroid, - 'POINT(6.666666667 3.333333333)') != 0: - gdaltest.post_reason('Got: %s' % centroid.ExportToWkt()) - return 'fail' + assert (ogrtest.check_feature_geometry(centroid, + 'POINT(6.666666667 3.333333333)') == 0), \ + ('Got: %s' % centroid.ExportToWkt()) # Test with a self intersecting polygon too. # This particular polygon has two triangles. The right triangle is larger. g2 = ogr.CreateGeometryFromWkt('POLYGON((0 0, 0 2, 2 -0.1, 2 2.1, 0 0))') centroid2 = g2.Centroid() - if ogrtest.check_feature_geometry(centroid2, 'POINT (8.0 1.0)') != 0: - gdaltest.post_reason('Got: %s' % centroid2.ExportToWkt()) - return 'fail' + assert ogrtest.check_feature_geometry(centroid2, 'POINT (8.0 1.0)') == 0, \ + ('Got: %s' % centroid2.ExportToWkt()) return 'success' @@ -391,10 +355,9 @@ def test_ogr_geos_centroid_multipolygon(): centroid = g1.Centroid() - if ogrtest.check_feature_geometry(centroid, - 'POINT (1.5 0.5)') != 0: - gdaltest.post_reason('Got: %s' % centroid.ExportToWkt()) - return 'fail' + assert (ogrtest.check_feature_geometry(centroid, + 'POINT (1.5 0.5)') == 0), \ + ('Got: %s' % centroid.ExportToWkt()) return 'success' @@ -410,9 +373,7 @@ def test_ogr_geos_centroid_point_empty(): centroid = g1.Centroid() - if centroid.ExportToWkt() != 'POINT EMPTY': - gdaltest.post_reason('Got: %s' % centroid.ExportToWkt()) - return 'fail' + assert centroid.ExportToWkt() == 'POINT EMPTY', ('Got: %s' % centroid.ExportToWkt()) return 'success' @@ -429,9 +390,8 @@ def test_ogr_geos_simplify_linestring(): gdal.ErrorReset() simplify = g1.Simplify(5) - if simplify.ExportToWkt() != 'LINESTRING (0 0,10 0)': - gdaltest.post_reason('Got: %s' % simplify.ExportToWkt()) - return 'fail' + assert simplify.ExportToWkt() == 'LINESTRING (0 0,10 0)', \ + ('Got: %s' % simplify.ExportToWkt()) return 'success' @@ -448,9 +408,8 @@ def test_ogr_geos_simplifypreservetopology_linestring(): gdal.ErrorReset() simplify = g1.SimplifyPreserveTopology(5) - if simplify.ExportToWkt() != 'LINESTRING (0 0,10 0)': - gdaltest.post_reason('Got: %s' % simplify.ExportToWkt()) - return 'fail' + assert simplify.ExportToWkt() == 'LINESTRING (0 0,10 0)', \ + ('Got: %s' % simplify.ExportToWkt()) return 'success' @@ -467,9 +426,8 @@ def test_ogr_geos_unioncascaded(): gdal.ErrorReset() cascadedunion = g1.UnionCascaded() - if cascadedunion.ExportToWkt() != 'POLYGON ((0 0,0 1,0.5 1.0,0.5 1.5,1.5 1.5,1.5 0.5,1.0 0.5,1 0,0 0))': - gdaltest.post_reason('Got: %s' % cascadedunion.ExportToWkt()) - return 'fail' + assert cascadedunion.ExportToWkt() == 'POLYGON ((0 0,0 1,0.5 1.0,0.5 1.5,1.5 1.5,1.5 0.5,1.0 0.5,1 0,0 0))', \ + ('Got: %s' % cascadedunion.ExportToWkt()) return 'success' @@ -485,9 +443,8 @@ def test_ogr_geos_convexhull(): convexhull = g1.ConvexHull() - if convexhull.ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': - gdaltest.post_reason('Got: %s' % convexhull.ExportToWkt()) - return 'fail' + assert convexhull.ExportToWkt() == 'POLYGON ((0 0,0 1,1 1,1 0,0 0))', \ + ('Got: %s' % convexhull.ExportToWkt()) return 'success' @@ -504,9 +461,8 @@ def test_ogr_geos_distance(): distance = g1.Distance(g2) - if abs(distance - 1) > 0.00000000001: - gdaltest.post_reason('Distance() result wrong, got %g.' % distance) - return 'fail' + assert abs(distance - 1) <= 0.00000000001, \ + ('Distance() result wrong, got %g.' % distance) return 'success' @@ -522,8 +478,7 @@ def test_ogr_geos_isring(): isring = g1.IsRing() - if isring != 1: - return 'fail' + assert isring == 1 return 'success' @@ -539,8 +494,7 @@ def test_ogr_geos_issimple_true(): isring = g1.IsSimple() - if isring != 1: - return 'fail' + assert isring == 1 return 'success' @@ -556,8 +510,7 @@ def test_ogr_geos_issimple_false(): isring = g1.IsSimple() - if isring != 0: - return 'fail' + assert isring == 0 return 'success' @@ -573,8 +526,7 @@ def test_ogr_geos_isvalid_true(): isring = g1.IsValid() - if isring != 1: - return 'fail' + assert isring == 1 return 'success' @@ -590,8 +542,7 @@ def test_ogr_geos_isvalid_true_linestringM(): isring = g1.IsValid() - if isring != 1: - return 'fail' + assert isring == 1 return 'success' @@ -607,8 +558,7 @@ def test_ogr_geos_isvalid_true_circularStringM(): isring = g1.IsValid() - if isring != 1: - return 'fail' + assert isring == 1 return 'success' @@ -624,8 +574,7 @@ def test_ogr_geos_isvalid_true_triangle(): isring = g1.IsValid() - if isring != 1: - return 'fail' + assert isring == 1 return 'success' @@ -642,8 +591,7 @@ def test_ogr_geos_isvalid_false(): with gdaltest.error_handler(): isring = g1.IsValid() - if isring != 0: - return 'fail' + assert isring == 0 return 'success' @@ -659,8 +607,7 @@ def test_ogr_geos_pointonsurface(): pointonsurface = g1.PointOnSurface() - if pointonsurface.Within(g1) != 1: - return 'fail' + assert pointonsurface.Within(g1) == 1 return 'success' @@ -677,13 +624,11 @@ def test_ogr_geos_DelaunayTriangulation(): gdal.ErrorReset() triangulation = g1.DelaunayTriangulation() if triangulation is None: - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' return 'skip' - if triangulation.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 1,0 0,1 0,0 1)),POLYGON ((0 1,1 0,1 1,0 1)))': - gdaltest.post_reason('Got: %s' % triangulation.ExportToWkt()) - return 'fail' + assert triangulation.ExportToWkt() == 'GEOMETRYCOLLECTION (POLYGON ((0 1,0 0,1 0,0 1)),POLYGON ((0 1,1 0,1 1,0 1)))', \ + ('Got: %s' % triangulation.ExportToWkt()) return 'success' @@ -697,21 +642,16 @@ def test_ogr_geos_polygonize(): g = ogr.CreateGeometryFromWkt('MULTILINESTRING((0 0,0 1,1 1),(1 1,0 0))') got = g.Polygonize() - if got.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason('Got: %s' % got.ExportToWkt()) - return 'fail' + assert got.ExportToWkt() == 'GEOMETRYCOLLECTION (POLYGON ((0 0,0 1,1 1,0 0)))', \ + ('Got: %s' % got.ExportToWkt()) g = ogr.CreateGeometryFromWkt('POINT EMPTY') got = g.Polygonize() - if got is not None: - gdaltest.post_reason('Got: %s' % got.ExportToWkt()) - return 'fail' + assert got is None, ('Got: %s' % got.ExportToWkt()) g = ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION(POINT EMPTY)') got = g.Polygonize() - if got is not None: - gdaltest.post_reason('Got: %s' % got.ExportToWkt()) - return 'fail' + assert got is None, ('Got: %s' % got.ExportToWkt()) return 'success' diff --git a/autotest/ogr/ogr_gft.py b/autotest/ogr/ogr_gft.py index f998a4580f4d..ee879e42cb92 100755 --- a/autotest/ogr/ogr_gft.py +++ b/autotest/ogr/ogr_gft.py @@ -80,12 +80,10 @@ def test_ogr_gft_read(): gdal.SetConfigOption('GFT_AUTH', old_auth) gdal.SetConfigOption('GFT_ACCESS_TOKEN', old_access) gdal.SetConfigOption('GFT_REFRESH_TOKEN', old_refresh) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr is None: - return 'fail' + assert lyr is not None lyr.SetSpatialFilterRect(67, 31.5, 67.5, 32) lyr.SetAttributeFilter("'Attack on' = 'ENEMY'") @@ -100,15 +98,12 @@ def test_ogr_gft_read(): return 'fail' sql_lyr = ds.ExecuteSQL("SELECT Latitude, Longitude FROM " + table_id + " WHERE ST_INTERSECTS('Latitude', RECTANGLE(LATLNG(31.5,67.0), LATLNG(32.0,67.5))) AND 'Attack on' = 'ENEMY'") - if sql_lyr is None: - gdaltest.post_reason('SQL request failed') - return 'fail' + assert sql_lyr is not None, 'SQL request failed' sql_lyr_count = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if sql_lyr_count != count: - gdaltest.post_reason('did not get expected feature count. Got %d, expected %d' % (sql_lyr_count, count)) - return 'fail' + assert sql_lyr_count == count, \ + ('did not get expected feature count. Got %d, expected %d' % (sql_lyr_count, count)) return 'success' @@ -145,15 +140,11 @@ def test_ogr_gft_write(): expected_wkt = "POLYGON ((0 0,0 1,1 1,1 0),(0.25 0.25,0.25 0.75,0.75 0.75,0.75 0.25))" geom = ogr.CreateGeometryFromWkt(expected_wkt) feat.SetGeometry(geom) - if lyr.CreateFeature(feat) != 0: - gdaltest.post_reason('CreateFeature() failed') - return 'fail' + assert lyr.CreateFeature(feat) == 0, 'CreateFeature() failed' fid = feat.GetFID() feat.SetField('strcol', 'bar') - if lyr.SetFeature(feat) != 0: - gdaltest.post_reason('SetFeature() failed') - return 'fail' + assert lyr.SetFeature(feat) == 0, 'SetFeature() failed' lyr.ResetReading() feat = lyr.GetNextFeature() @@ -168,18 +159,12 @@ def test_ogr_gft_write(): feat.DumpReadable() return 'fail' got_wkt = feat.GetGeometryRef().ExportToWkt() - if got_wkt != expected_wkt: - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == expected_wkt, 'did not get expected geometry' - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('GetFeatureCount() did not returned expected value') - return 'fail' + assert lyr.GetFeatureCount() == 1, \ + 'GetFeatureCount() did not returned expected value' - if lyr.DeleteFeature(feat.GetFID()) != 0: - gdaltest.post_reason('DeleteFeature() failed') - return 'fail' + assert lyr.DeleteFeature(feat.GetFID()) == 0, 'DeleteFeature() failed' ds.ExecuteSQL('DELLAYER:%s' % table_name) diff --git a/autotest/ogr/ogr_gml_fgd_read.py b/autotest/ogr/ogr_gml_fgd_read.py index b1f0b1b6992a..265039d56e36 100755 --- a/autotest/ogr/ogr_gml_fgd_read.py +++ b/autotest/ogr/ogr_gml_fgd_read.py @@ -66,28 +66,21 @@ def test_ogr_gml_fgd_1(): gdaltest.have_gml_fgd_reader = 1 # check number of layers - if ds.GetLayerCount() != 1: - gdaltest.post_reason('Wrong layer count') - return 'fail' + assert ds.GetLayerCount() == 1, 'Wrong layer count' lyr = ds.GetLayer(0) # check the SRS sr = osr.SpatialReference() sr.ImportFromEPSG(6668) # JGD2011 - if not sr.IsSame(lyr.GetSpatialRef()): - gdaltest.post_reason('Wrong SRS') - return 'fail' + assert sr.IsSame(lyr.GetSpatialRef()), 'Wrong SRS' # check the first feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (133.123456789 34.123456789)'): - gdaltest.post_reason('Wrong geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'POINT (133.123456789 34.123456789)'), \ + 'Wrong geometry' - if feat.GetField('devDate') != '2015-01-07': - gdaltest.post_reason('Wrong attribute value') - return 'fail' + assert feat.GetField('devDate') == '2015-01-07', 'Wrong attribute value' return 'success' @@ -103,30 +96,22 @@ def test_ogr_gml_fgd_2(): ds = ogr.Open(_fgd_dir + 'BldA.xml') # check number of layers - if ds.GetLayerCount() != 1: - gdaltest.post_reason('Wrong layer count') - return 'fail' + assert ds.GetLayerCount() == 1, 'Wrong layer count' lyr = ds.GetLayer(0) # check the SRS sr = osr.SpatialReference() sr.ImportFromEPSG(6668) # JGD2011 - if not sr.IsSame(lyr.GetSpatialRef()): - gdaltest.post_reason('Wrong SRS') - return 'fail' + assert sr.IsSame(lyr.GetSpatialRef()), 'Wrong SRS' wkt = 'POLYGON ((139.718509733734 35.6952171397133,139.718444177734 35.6953121947133,139.718496754142 35.6953498949667,139.718550483734 35.6952359447133,139.718509733734 35.6952171397133))' # check the first feature feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Wrong geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Wrong geometry' - if feat.GetField('devDate') != '2017-03-07': - gdaltest.post_reason('Wrong attribute value') - return 'fail' + assert feat.GetField('devDate') == '2017-03-07', 'Wrong attribute value' return 'success' diff --git a/autotest/ogr/ogr_gml_geom.py b/autotest/ogr/ogr_gml_geom.py index d21a10e89231..f88e5a707dbe 100755 --- a/autotest/ogr/ogr_gml_geom.py +++ b/autotest/ogr/ogr_gml_geom.py @@ -58,9 +58,7 @@ def test_gml_geom(unit): gml = geom_wkt.ExportToGML() - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' ###################################################################### # Create geometry from GML. @@ -83,10 +81,8 @@ def test_gml_geom(unit): def test_gml_space_test(): gml = '189999.99995605,624999.99998375 200000.00005735,624999.99998375 200000.00005735,612499.99997125 195791.3593843,612499.99997125 193327.3749823,612499.99997125 189999.99995605,612499.99997125 189999.99995605,619462.31247125 189999.99995605,624999.99998375 \n' geom = ogr.CreateGeometryFromGML(gml) - if geom is None or geom.GetGeometryType() is not ogr.wkbLineString \ - or geom.GetPointCount() != 8: - gdaltest.post_reason('GML not correctly parsed') - return 'fail' + assert geom is not None and geom.GetGeometryType() is ogr.wkbLineString and geom.GetPointCount() == 8, \ + 'GML not correctly parsed' return 'success' @@ -100,9 +96,7 @@ def test_gml_pos_point(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POINT (31 29 16)': - gdaltest.post_reason(' not correctly parsed') - return 'fail' + assert geom.ExportToWkt() == 'POINT (31 29 16)', ' not correctly parsed' return 'success' @@ -135,9 +129,8 @@ def test_gml_pos_polygon(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1))': - gdaltest.post_reason(' not correctly parsed') - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1))', \ + ' not correctly parsed' return 'success' @@ -151,9 +144,8 @@ def test_gml_posList_line(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'LINESTRING (31 42,53 64,55 76)': - gdaltest.post_reason(' not correctly parsed') - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (31 42,53 64,55 76)', \ + ' not correctly parsed' return 'success' @@ -167,9 +159,8 @@ def test_gml_posList_line3d(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'LINESTRING (31 42 1,53 64 2,55 76 3)': - gdaltest.post_reason(' not correctly parsed') - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (31 42 1,53 64 2,55 76 3)', \ + ' not correctly parsed' return 'success' @@ -184,9 +175,8 @@ def test_gml_posList_line3d_2(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'LINESTRING (31 42 1,53 64 2,55 76 3)': - gdaltest.post_reason(' not correctly parsed') - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (31 42 1,53 64 2,55 76 3)', \ + ' not correctly parsed' return 'success' @@ -199,9 +189,8 @@ def test_gml_polygon(): gml = '0 0 4 0 4 4 0 4 0 01 1 2 1 2 2 1 2 1 1' geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1))': - gdaltest.post_reason(' not correctly parsed') - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1))', \ + ' not correctly parsed' return 'success' @@ -239,13 +228,10 @@ def test_gml_out_point_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:31] != '': - gdaltest.post_reason('No srsName attribute in GML output') - return 'fail' + assert gml[0:31] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -259,13 +245,10 @@ def test_gml_out_point3d_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:31] != '': - gdaltest.post_reason('No srsName attribute in GML output') - return 'fail' + assert gml[0:31] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -279,13 +262,10 @@ def test_gml_out_linestring_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:36] != '': - gdaltest.post_reason('No srsName attribute in GML output') - return 'fail' + assert gml[0:36] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -299,13 +279,10 @@ def test_gml_out_polygon_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:33] != '': - gdaltest.post_reason('No srsName attribute in GML output') - return 'fail' + assert gml[0:33] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -319,13 +296,10 @@ def test_gml_out_multipoint_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:36] != '': - gdaltest.post_reason('No srsName attribute in GML output') - return 'fail' + assert gml[0:36] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -339,13 +313,10 @@ def test_gml_out_multilinestring_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:41] != '': - gdaltest.post_reason('No srsName attribute in GML output') - return 'fail' + assert gml[0:41] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -359,20 +330,14 @@ def test_gml_out_multipolygon_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:38] != '': - gdaltest.post_reason('No srsName attribute in GML output') - print(gml) - return 'fail' + assert gml[0:38] == '', \ + 'No srsName attribute in GML output' # Verify we have no other srsName's on subelements. - if gml[39:].find('srsName') != -1: - gdaltest.post_reason('Got extra srsName attributes on subelements.') - print(gml) - return 'fail' + assert gml[39:].find('srsName') == -1, \ + 'Got extra srsName attributes on subelements.' return 'success' @@ -386,14 +351,10 @@ def test_gml_out_geometrycollection_srs(): gml = _CreateGMLWithSRSFromWkt(wkt, 4326) - if gml is None or not gml: - gdaltest.post_reason('Conversion to GML failed.') - return 'fail' + assert gml is not None and gml, 'Conversion to GML failed.' - if gml[0:39] != '': - gdaltest.post_reason('No srsName attribute in GML output') - print(gml) - return 'fail' + assert gml[0:39] == '', \ + 'No srsName attribute in GML output' return 'success' @@ -416,10 +377,8 @@ def test_gml_Box(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((1 2 0,3 2 0,3 4 0,1 4 0,1 2 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((1 2 0,3 2 0,3 4 0,1 4 0,1 2 0))', \ + ' not correctly parsed' return 'success' @@ -436,10 +395,8 @@ def test_gml_Envelope(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((1 2,3 2,3 4,1 4,1 2))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((1 2,3 2,3 4,1 4,1 2))', \ + ' not correctly parsed' return 'success' @@ -459,10 +416,8 @@ def test_gml_Curve(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'LINESTRING (1 2,3 4)': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (1 2,3 4)', \ + ' not correctly parsed' return 'success' @@ -487,10 +442,8 @@ def test_gml_Curve_with_pointProperty(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'LINESTRING (1 2,3 4)': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (1 2,3 4)', \ + ' not correctly parsed' return 'success' @@ -515,10 +468,8 @@ def test_gml_MultiCurve(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTILINESTRING ((1 2,2 3),(3 4,4 5))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTILINESTRING ((1 2,2 3),(3 4,4 5))', \ + ' not correctly parsed' return 'success' @@ -598,10 +549,8 @@ def test_gml_MultiSurface(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTIPOLYGON (((1 2,3 4,5 6,1 2),(2 3,4 5,6 7,2 3),(3 4,5 6,7 8,3 4)),((4 5,6 7,8 9,4 5)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTIPOLYGON (((1 2,3 4,5 6,1 2),(2 3,4 5,6 7,2 3),(3 4,5 6,7 8,3 4)),((4 5,6 7,8 9,4 5)))', \ + ' not correctly parsed' return 'success' @@ -652,10 +601,8 @@ def test_gml_MultiSurface_surfaceMembers(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTIPOLYGON (((1 2,3 4,5 6,1 2),(2 3,4 5,6 7,2 3)),((3 4,5 6,7 8,3 4)),((30 40,50 60,70 80,30 40)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTIPOLYGON (((1 2,3 4,5 6,1 2),(2 3,4 5,6 7,2 3)),((3 4,5 6,7 8,3 4)),((30 40,50 60,70 80,30 40)))', \ + ' not correctly parsed' return 'success' @@ -675,10 +622,8 @@ def test_gml_MultiCurve_curveMembers(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTILINESTRING ((0 0,1 1))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTILINESTRING ((0 0,1 1))', \ + ' not correctly parsed' return 'success' @@ -697,10 +642,8 @@ def test_gml_MultiGeometry_geometryMembers(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'GEOMETRYCOLLECTION (LINESTRING (0 0,1 1))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'GEOMETRYCOLLECTION (LINESTRING (0 0,1 1))', \ + ' not correctly parsed' return 'success' @@ -723,10 +666,8 @@ def test_gml_CompositeCurve_curveMembers(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'LINESTRING (0 0,1 1,2 2)': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (0 0,1 1,2 2)', \ + ' not correctly parsed' return 'success' @@ -749,10 +690,8 @@ def test_gml_MultiCurve_pointMembers(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTIPOINT (0 0,1 1)': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTIPOINT (0 0,1 1)', \ + ' not correctly parsed' return 'success' ############################################################################### @@ -779,10 +718,8 @@ def test_gml_Solid(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYHEDRALSURFACE Z (((1 2 0,3 4 0,5 6 0,1 2 0)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYHEDRALSURFACE Z (((1 2 0,3 4 0,5 6 0,1 2 0)))', \ + ' not correctly parsed' return 'success' @@ -808,10 +745,8 @@ def test_gml_OrientableSurface(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((-213.475 24.989 0,-213.475 24.989 8,-215.704 25.077 8,-215.704 25.077 0,-213.475 24.989 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((-213.475 24.989 0,-213.475 24.989 8,-215.704 25.077 8,-215.704 25.077 0,-213.475 24.989 0))', \ + ' not correctly parsed' return 'success' @@ -831,10 +766,8 @@ def test_gml_Triangle(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'TRIANGLE ((0 0,0 1,1 1,0 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'TRIANGLE ((0 0,0 1,1 1,0 0))', \ + ' not correctly parsed' # check the conversion of Triangle from OGR -> GML wkt_original = 'TRIANGLE ((0 0,0 1,0 1,0 0))' @@ -843,9 +776,8 @@ def test_gml_Triangle(): gml_string = triangle.ExportToGML(opts) if gml_string != '0 0 0 1 0 1 0 0': - gdaltest.post_reason('incorrect conversion from OGR -> GML for OGRTriangle') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('incorrect conversion from OGR -> GML for OGRTriangle') return 'success' @@ -865,10 +797,8 @@ def test_gml_Rectangle(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,0 1,1 1,1 0,0 0))', \ + ' not correctly parsed' return 'success' @@ -908,10 +838,8 @@ def test_gml_PolyhedralSurface(): # NOTE - this is actually an invalid PolyhedralSurface # need to assert geom.IsValid() == True to determine the validity of the geometry - if geom.ExportToWkt() != 'POLYHEDRALSURFACE Z (((1 2 3,4 5 6,7 8 9,1 2 3)),((10 11 12,13 14 15,16 17 18,10 11 12),(19 20 21,22 23 24,25 26 27,19 20 21)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYHEDRALSURFACE Z (((1 2 3,4 5 6,7 8 9,1 2 3)),((10 11 12,13 14 15,16 17 18,10 11 12),(19 20 21,22 23 24,25 26 27,19 20 21)))', \ + ' not correctly parsed' # 1 patch and 2 rings gml = """ @@ -936,10 +864,8 @@ def test_gml_PolyhedralSurface(): # NOTE - this is actually an invalid PolyhedralSurface # need to assert geom.IsValid() == True to determine the validity of the geometry - if geom.ExportToWkt() != 'POLYHEDRALSURFACE Z (((1 2 3,4 5 6,7 8 9,1 2 3)),((10 11 12,13 14 15,16 17 18,10 11 12)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYHEDRALSURFACE Z (((1 2 3,4 5 6,7 8 9,1 2 3)),((10 11 12,13 14 15,16 17 18,10 11 12)))', \ + ' not correctly parsed' # Variations of empty PolyhedralSurface gml_strings = ['', @@ -955,10 +881,8 @@ def test_gml_PolyhedralSurface(): for string in gml_strings: geom = ogr.CreateGeometryFromGML(string) - if geom.ExportToWkt() != 'POLYHEDRALSURFACE EMPTY': - gdaltest.post_reason('Empty not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYHEDRALSURFACE EMPTY', \ + 'Empty not correctly parsed' # Conversion from OGR -> GML wkt_original = 'POLYHEDRALSURFACE Z (((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),\ @@ -971,15 +895,13 @@ def test_gml_PolyhedralSurface(): opts = ["FORMAT=GML3"] string = ps.ExportToGML(opts) if string != '0 0 0 0 0 1 0 1 1 0 1 0 0 0 00 0 0 0 1 0 1 1 0 1 0 0 0 0 00 0 0 1 0 0 1 0 1 0 0 1 0 0 01 1 0 1 1 1 1 0 1 1 0 0 1 1 00 1 0 0 1 1 1 1 1 1 1 0 0 1 00 0 1 1 0 1 1 1 1 0 1 1 0 0 1': - gdaltest.post_reason('incorrect parsing of OGR -> GML for PolyhedralSurface') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('incorrect parsing of OGR -> GML for PolyhedralSurface') g2 = ogr.CreateGeometryFromGML(string) if g2.Equals(ps) != 1: - gdaltest.post_reason('incorrect round-tripping') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('incorrect round-tripping') # empty geometry wkt_original = 'POLYHEDRALSURFACE EMPTY' @@ -987,9 +909,8 @@ def test_gml_PolyhedralSurface(): opts = ["FORMAT=GML3"] string = ps.ExportToGML(opts) if string != '': - gdaltest.post_reason('incorrect parsing of OGR -> GML for empty PolyhedralSurface') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('incorrect parsing of OGR -> GML for empty PolyhedralSurface') # several polygon patches (and test that non elements such as comments are parsed OK) gml = """ @@ -1016,10 +937,8 @@ def test_gml_PolyhedralSurface(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'GEOMETRYCOLLECTION (POLYHEDRALSURFACE (((1 2 3,4 5 6,7 8 9,1 2 3))),POLYHEDRALSURFACE (((1 2 3,4 5 6,7 8 9,1 2 3))))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'GEOMETRYCOLLECTION (POLYHEDRALSURFACE (((1 2 3,4 5 6,7 8 9,1 2 3))),POLYHEDRALSURFACE (((1 2 3,4 5 6,7 8 9,1 2 3))))', \ + ' not correctly parsed' # Test PolyhedralSurface with curve section (which we linearize since the SF PolyhedralSurface doesn't support curves) gml = """ @@ -1049,10 +968,8 @@ def test_gml_PolyhedralSurface(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt().find('POLYHEDRALSURFACE (((0 -1,0 1,') < 0: - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt().find('POLYHEDRALSURFACE (((0 -1,0 1,') >= 0, \ + ' not correctly parsed' return 'success' @@ -1078,10 +995,8 @@ def test_gml_Tin(): # NOTE - this is actually an invalid TIN surface, as the triangle is incorrect # need to assert geom.IsValid() == True to determine the validity of the geometry - if geom.ExportToWkt() != 'TIN Z (((0 0 1,0 1 1,1 1 1,1 0 1,0 0 1)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'TIN Z (((0 0 1,0 1 1,1 1 1,1 0 1,0 0 1)))', \ + ' not correctly parsed' # Test for gml:TriangulatedSurface gml = """ @@ -1105,10 +1020,8 @@ def test_gml_Tin(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,0 0 0)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,0 0 0)))', \ + ' not correctly parsed' # substituting gml:trianglePatches for gml:patches gml = """ @@ -1132,10 +1045,8 @@ def test_gml_Tin(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,0 0 0)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,0 0 0)))', \ + ' not correctly parsed' # Part 2 - Create GML File from OGR Geometries wkt_original = 'TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 1 0,0 0 0)))' @@ -1145,9 +1056,8 @@ def test_gml_Tin(): gml_string = tin.ExportToGML(opts) if gml_string != '0 0 0 0 0 1 0 1 0 0 0 00 0 0 0 1 0 1 1 0 0 0 0': - gdaltest.post_reason('OGRGeometry::TriangulatedSurface incorrectly converted') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('OGRGeometry::TriangulatedSurface incorrectly converted') return 'success' @@ -1185,13 +1095,9 @@ def test_gml_ConcatenatedDeduplication(): geom = ogr.CreateGeometryFromGML(gml) expected_wkt = 'CURVEPOLYGON (COMPOUNDCURVE ((0 -1,0 1),CIRCULARSTRING (0 1,1 0,0 -1)))' - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt(expected_wkt)) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt(expected_wkt)) == 0 - if ogrtest.have_geos() and not geom.IsValid(): - gdaltest.post_reason('geometry not valid') - return 'fail' + assert not ogrtest.have_geos() or geom.IsValid(), 'geometry not valid' return 'success' @@ -1204,18 +1110,12 @@ def gml_out_precision(): geom = ogr.CreateGeometryFromWkt('POINT(93538.15 1.23456789)') expected_gml = '93538.15,1.23456789' got_gml = geom.ExportToGML() - if got_gml != expected_gml: - gdaltest.post_reason('did not get expected gml') - print(got_gml) - return 'fail' + assert got_gml == expected_gml, 'did not get expected gml' geom = ogr.CreateGeometryFromWkt('POINT(93538.55 1234567.89)') expected_gml = '93538.55,1234567.89' got_gml = geom.ExportToGML() - if got_gml != expected_gml: - gdaltest.post_reason('did not get expected gml') - print(got_gml) - return 'fail' + assert got_gml == expected_gml, 'did not get expected gml' return 'success' @@ -1381,18 +1281,16 @@ def test_gml_invalid_geoms(): geom = ogr.CreateGeometryFromGML(gml) gdal.PopErrorHandler() if geom is None: - if expected_wkt is not None: - gdaltest.post_reason('did not get expected result for %s. Got None instead of %s' % (gml, expected_wkt)) - return 'fail' + assert expected_wkt is None, \ + ('did not get expected result for %s. Got None instead of %s' % (gml, expected_wkt)) else: wkt = geom.ExportToWkt() if expected_wkt is None: gdaltest.post_reason('did not get expected result for %s. Got %s instead of None' % (gml, wkt)) return 'fail' else: - if wkt != expected_wkt: - gdaltest.post_reason('did not get expected result for %s. Got %s instead of %s' % (gml, wkt, expected_wkt)) - return 'fail' + assert wkt == expected_wkt, \ + ('did not get expected result for %s. Got %s instead of %s' % (gml, wkt, expected_wkt)) return 'success' @@ -1422,9 +1320,7 @@ def test_gml_write_gml3_geometries(): gml_out = geom.ExportToGML(['FORMAT=GML3', 'GML3_LINESTRING_ELEMENT=curve']) else: gml_out = geom.ExportToGML(['FORMAT=GML3']) - if gml_out != gml_in: - gdaltest.post_reason('got %s, instead of %s' % (gml_out, gml_in)) - return 'fail' + assert gml_out == gml_in, ('got %s, instead of %s' % (gml_out, gml_in)) return 'success' @@ -1447,63 +1343,49 @@ def test_gml_write_gml3_srs(): geom.AssignSpatialReference(sr32631) gml3 = geom.ExportToGML(options=['FORMAT=GML3']) expected_gml = '500000 4500000' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) # Should perform the needed coordinate order swapping geom = ogr.CreateGeometryFromWkt('POINT(2 49)') geom.AssignSpatialReference(srlonglat) gml3 = geom.ExportToGML(options=['FORMAT=GML3']) expected_gml = '49 2' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) # Should not change the coordinate order. geom = ogr.CreateGeometryFromWkt('POINT(49 2)') geom.AssignSpatialReference(srlatlong) gml3 = geom.ExportToGML(options=['FORMAT=GML3']) expected_gml = '49 2' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) # Legacy SRS format geom = ogr.CreateGeometryFromWkt('POINT(2 49)') geom.AssignSpatialReference(srlonglat) gml3 = geom.ExportToGML(options=['FORMAT=GML3', 'GML3_LONGSRS=NO']) expected_gml = '2 49' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) # Test SRSNAME_FORMAT=SHORT geom = ogr.CreateGeometryFromWkt('POINT(2 49)') geom.AssignSpatialReference(srlonglat) gml3 = geom.ExportToGML(options=['FORMAT=GML3', 'SRSNAME_FORMAT=SHORT']) expected_gml = '2 49' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) # Test SRSNAME_FORMAT=SRSNAME_FORMAT geom = ogr.CreateGeometryFromWkt('POINT(2 49)') geom.AssignSpatialReference(srlonglat) gml3 = geom.ExportToGML(options=['FORMAT=GML3', 'SRSNAME_FORMAT=OGC_URN']) expected_gml = '49 2' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) # Test SRSNAME_FORMAT=OGC_URL geom = ogr.CreateGeometryFromWkt('POINT(2 49)') geom.AssignSpatialReference(srlonglat) gml3 = geom.ExportToGML(options=['FORMAT=GML3', 'SRSNAME_FORMAT=OGC_URL']) expected_gml = '49 2' - if gml3 != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml3, expected_gml)) - return 'fail' + assert gml3 == expected_gml, ('got %s, instead of %s' % (gml3, expected_gml)) return 'success' @@ -1518,9 +1400,7 @@ def test_gml_nested(): gml += '' * 31 geom = ogr.CreateGeometryFromGML(gml) - if geom is None: - gdaltest.post_reason('expected a geometry') - return 'fail' + assert geom is not None, 'expected a geometry' gml = '' * 32 gml += '' @@ -1529,9 +1409,7 @@ def test_gml_nested(): gdal.PushErrorHandler('CPLQuietErrorHandler') geom = ogr.CreateGeometryFromGML(gml) gdal.PopErrorHandler() - if geom is not None: - gdaltest.post_reason('expected None') - return 'fail' + assert geom is None, 'expected None' return 'success' @@ -1545,10 +1423,8 @@ def test_gml_SimplePolygon(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0,1 0,1 1,0 1,0 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,1 0,1 1,0 1,0 0))', \ + ' not correctly parsed' return 'success' @@ -1562,10 +1438,8 @@ def test_gml_SimpleRectangle(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0,1 0,1 1,0 1,0 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,1 0,1 1,0 1,0 0))', \ + ' not correctly parsed' return 'success' @@ -1579,10 +1453,8 @@ def test_gml_SimpleTriangle(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'TRIANGLE ((0 0,1 0,1 1,0 0))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'TRIANGLE ((0 0,1 0,1 1,0 0))', \ + ' not correctly parsed' return 'success' @@ -1596,10 +1468,8 @@ def test_gml_SimpleMultiPoint(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTIPOINT (0 1,2 3)': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTIPOINT (0 1,2 3)', \ + ' not correctly parsed' return 'success' @@ -1656,9 +1526,7 @@ def test_gml_CompositeCurveInRing(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0,0 1,1 1,0 0))' return 'success' @@ -1695,9 +1563,7 @@ def test_gml_CompositeSurface_in_surfaceMembers(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)),((2 0,2 1,3 1,3 0,2 0)))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)),((2 0,2 1,3 1,3 0,2 0)))' return 'success' @@ -1751,9 +1617,7 @@ def test_gml_MultiSurfaceOfSurfaceOfPolygonPatchWithInteriorRing(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.25 0.75,0.75 0.75,0.75 0.25,0.25 0.25)),((0 0,0 -1,-1 -1,-1 0,0 0)))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.25 0.75,0.75 0.75,0.75 0.25,0.25 0.25)),((0 0,0 -1,-1 -1,-1 0,0 0)))' return 'success' @@ -1787,9 +1651,8 @@ def test_gml_Coordinates_ts_cs_decimal(): gdaltest.post_reason('did not get expected result for %s. Got %s instead of None' % (gml, wkt)) return 'fail' else: - if wkt != expected_wkt: - gdaltest.post_reason('did not get expected result for %s. Got %s instead of %s' % (gml, wkt, expected_wkt)) - return 'fail' + assert wkt == expected_wkt, \ + ('did not get expected result for %s. Got %s instead of %s' % (gml, wkt, expected_wkt)) return 'success' @@ -1831,9 +1694,8 @@ def test_gml_with_xml_header_and_comments(): gdaltest.post_reason('did not get expected result for %s. Got %s instead of None' % (gml, wkt)) return 'fail' else: - if wkt != expected_wkt: - gdaltest.post_reason('did not get expected result for %s. Got %s instead of %s' % (gml, wkt, expected_wkt)) - return 'fail' + assert wkt == expected_wkt, \ + ('did not get expected result for %s. Got %s instead of %s' % (gml, wkt, expected_wkt)) return 'success' @@ -1859,9 +1721,7 @@ def test_gml_srsDimension_topgeometry(): geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'POLYGON ((0 0 10,0 1 10,1 1 10,1 0 10,0 0 10))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'POLYGON ((0 0 10,0 1 10,1 1 10,1 0 10,0 0 10))' return 'success' @@ -1874,20 +1734,14 @@ def test_gml_Arc(): gml = "1 0 0 1 -1 0" geom = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 0,0 1,-1 0)')) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 0,0 1,-1 0)')) == 0 gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '1 0 0 1 -1 0' - if gml2 != expected_gml2: - print(gml2) - return 'fail' + assert gml2 == expected_gml2 geom2 = ogr.CreateGeometryFromGML(gml2) - if not geom.Equals(geom2): - print(geom2) - return 'fail' + assert geom.Equals(geom2) return 'success' @@ -1900,9 +1754,7 @@ def test_gml_ArcByBulge(): gml = "2 0 -2 02-1" geom = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (2 0,0 2,-2 0)')) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (2 0,0 2,-2 0)')) == 0 return 'success' @@ -1915,9 +1767,7 @@ def test_gml_ArcByCenterPoint(): gml = "1 2290270" geom = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 4,-1 2,1 0)')) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (1 4,-1 2,1 0)')) == 0 return 'success' @@ -1977,9 +1827,7 @@ def test_gml_CompoundCurve_of_ArcByCenterPoint(): """ geom = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('POLYGON ((-80.4 33.86,-80.27 33.63,-80.305028054229538 33.622017309598967,-80.335422529369936 33.613343178471617,-80.366464292754429 33.606448070493634,-80.398003921948742 33.601365147653873,-80.429889693662162 33.598118851265042,-80.461968286017793 33.596724788982847,-80.494085487001527 33.597189662699385,-80.52608690656875 33.599511237590342,-80.557818688893789 33.603678352435914,-80.589128223167393 33.609670971175497,-80.619864849221443 33.617460275496377,-80.63 33.62,-80.39 33.85))')) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('POLYGON ((-80.4 33.86,-80.27 33.63,-80.305028054229538 33.622017309598967,-80.335422529369936 33.613343178471617,-80.366464292754429 33.606448070493634,-80.398003921948742 33.601365147653873,-80.429889693662162 33.598118851265042,-80.461968286017793 33.596724788982847,-80.494085487001527 33.597189662699385,-80.52608690656875 33.599511237590342,-80.557818688893789 33.603678352435914,-80.589128223167393 33.609670971175497,-80.619864849221443 33.617460275496377,-80.63 33.62,-80.39 33.85))')) == 0 return 'success' @@ -1992,9 +1840,7 @@ def test_gml_CircleByCenterPoint(): gml = "1 22" geom = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (-1 2,3 2,-1 2)')) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt('CIRCULARSTRING (-1 2,3 2,-1 2)')) == 0 return 'success' @@ -2011,28 +1857,20 @@ def test_gml_Circle(): geom = ogr.CreateGeometryFromGML(gml) expected_wkt = 'CIRCULARSTRING (-1 0,0 1,-0.707106781186547 -0.707106781186548,-0.923879532511287 -0.38268343236509,-1 0)' - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt(expected_wkt)) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt(expected_wkt)) == 0 geom = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0,2 0,0 0)') gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 1 1 2 0' - if gml2 != expected_gml2: - print(gml2) - return 'fail' + assert gml2 == expected_gml2 geom2 = ogr.CreateGeometryFromGML(gml2) - if geom2.ExportToWkt() != 'CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0)': - print(geom2) - return 'fail' + assert geom2.ExportToWkt() == 'CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0)' geom = ogr.CreateGeometryFromWkt('CIRCULARSTRING (0 0 10,2 0 10,0 0 10)') gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 10 1 1 10 2 0 10' - if gml2 != expected_gml2: - print(gml2) - return 'fail' + assert gml2 == expected_gml2 gml = """ @@ -2053,9 +1891,7 @@ def test_gml_Circle(): geom = ogr.CreateGeometryFromGML(gml) expected_wkt = 'CURVEPOLYGON ( CIRCULARSTRING (-1 0,0 1,-0.707106781186547 -0.707106781186548,-0.923879532511287 -0.38268343236509,-1 0))' - if ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt(expected_wkt)) != 0: - print(geom) - return 'fail' + assert ogrtest.check_feature_geometry(geom, ogr.CreateGeometryFromWkt(expected_wkt)) == 0 return 'success' @@ -2067,26 +1903,18 @@ def test_gml_ArcString(): gml = """-2 0 -1 -1 0 0""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'CIRCULARSTRING (-2 0,-1 -1,0 0)': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'CIRCULARSTRING (-2 0,-1 -1,0 0)' gml = """-2 0 -1 -1 0 0 1 -1 2 0 0 2 -2 0""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'CIRCULARSTRING (-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0)': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'CIRCULARSTRING (-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0)' gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '-2 0 -1 -1 0 0 1 -1 2 0 0 2 -2 0' - if gml2 != expected_gml2: - print(gml2) - return 'fail' + assert gml2 == expected_gml2 geom2 = ogr.CreateGeometryFromGML(gml2) - if geom2.ExportToWkt() != 'CIRCULARSTRING (-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0)': - print(geom2) - return 'fail' + assert geom2.ExportToWkt() == 'CIRCULARSTRING (-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0)' return 'success' @@ -2100,30 +1928,21 @@ def test_gml_OGRCompoundCurve(): geom = ogr.CreateGeometryFromWkt(wkt) gml = geom.ExportToGML(['FORMAT=GML3']) expected_gml = '0 0 1 1 2 0' - if gml != expected_gml: - print(gml) - return 'fail' + assert gml == expected_gml # CompositeCurve of LineStringSegment gml = expected_gml geom = ogr.CreateGeometryFromGML(gml) # We simplify it in LINESTRING - if geom.ExportToWkt() != 'LINESTRING (0 0,1 1,2 0)': - # if geom.ExportToWkt() != wkt - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'LINESTRING (0 0,1 1,2 0)' # CompositeCurve of Arc gml = """0 0 1 1 2 0""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0))' gml2 = geom.ExportToGML(['FORMAT=GML3']) - if gml2 != gml: - print(gml2) - return 'fail' + assert gml2 == gml # CompositeCurve of 3 arcs gml = """ @@ -2132,9 +1951,7 @@ def test_gml_OGRCompoundCurve(): 4 0 5 1 6 0 """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,3 1,4 0),CIRCULARSTRING (4 0,5 1,6 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,3 1,4 0),CIRCULARSTRING (4 0,5 1,6 0))' # Alternative syntax : Curve with 3 Arc segments gml = """ @@ -2143,9 +1960,7 @@ def test_gml_OGRCompoundCurve(): 4 0 5 1 6 0 """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,3 1,4 0),CIRCULARSTRING (4 0,5 1,6 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0),CIRCULARSTRING (2 0,3 1,4 0),CIRCULARSTRING (4 0,5 1,6 0))' # Curve with LineStringSegment and Arc segments gml = """ @@ -2153,9 +1968,7 @@ def test_gml_OGRCompoundCurve(): 0 0 -1 0 0 0 """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 0,0 0),(0 0,-1 0,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 0,0 0),(0 0,-1 0,0 0))' # Composite curve of a LineString and a (Composite) Curve with an Arc and a LineString gml = """ @@ -2168,9 +1981,7 @@ def test_gml_OGRCompoundCurve(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 0,0 0),CIRCULARSTRING (0 0,1 0,0 0),(0 0,-1 0,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'COMPOUNDCURVE ((0 0,1 0,0 0),CIRCULARSTRING (0 0,1 0,0 0),(0 0,-1 0,0 0))' return 'success' @@ -2183,44 +1994,33 @@ def test_gml_OGRCurvePolygon(): # Test one CircularString gml = """0 0 1 0 0 0""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0))' gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 0.5 0.5 1 0' - if gml2 != expected_gml2: - print(gml2) - return 'fail' + assert gml2 == expected_gml2 # Test two CircularString gml = """0 0 1 0 0 00.25 0 0.75 0 0.25 0""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0),CIRCULARSTRING (0.25 0.0,0.75 0.0,0.25 0.0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'CURVEPOLYGON (CIRCULARSTRING (0 0,1 0,0 0),CIRCULARSTRING (0.25 0.0,0.75 0.0,0.25 0.0))' # Test a LinearRing followed by a CircularString gml = """-2 -2 -2 2 2 2 2 -2 -2 -20.25 0 0.75 0 0.25 0""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'CURVEPOLYGON ((-2 -2,-2 2,2 2,2 -2,-2 -2),CIRCULARSTRING (0.25 0.0,0.75 0.0,0.25 0.0))': - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'CURVEPOLYGON ((-2 -2,-2 2,2 2,2 -2,-2 -2),CIRCULARSTRING (0.25 0.0,0.75 0.0,0.25 0.0))' # Test a CircularString followed by a LinearRing gml = """-1 0 1 2 3 0-2 -2 -2 2 2 2 2 -2 -2 -2""" geom = ogr.CreateGeometryFromGML(gml) - if ogrtest.check_feature_geometry(geom, 'CURVEPOLYGON (CIRCULARSTRING (-1 0,1 2,3 0,1.0 -2.0,-1 0),(-2 -2,-2 2,2 2,2 -2,-2 -2))') != 0: - print(geom.ExportToWkt()) - return 'fail' + assert ogrtest.check_feature_geometry(geom, 'CURVEPOLYGON (CIRCULARSTRING (-1 0,1 2,3 0,1.0 -2.0,-1 0),(-2 -2,-2 2,2 2,2 -2,-2 -2))') == 0, \ + geom.ExportToWkt() gml2 = geom.ExportToGML(['FORMAT=GML3']) geom2 = ogr.CreateGeometryFromGML(gml) expected_gml2 = '-1 0 1 2 3 0 1 -2 -1 0-2 -2 -2 2 2 2 2 -2 -2 -2' expected_geom2 = ogr.CreateGeometryFromGML(expected_gml2) - if ogrtest.check_feature_geometry(geom2, expected_geom2) != 0: - print(gml2) - return 'fail' + assert ogrtest.check_feature_geometry(geom2, expected_geom2) == 0, gml2 return 'success' @@ -2246,10 +2046,8 @@ def test_gml_OGRMultiSurface(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,1 -1,0.292893218813453 -0.707106781186548,0 0)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,1 -1,0.292893218813453 -0.707106781186548,0 0)))', \ + ' not correctly parsed' # MultiSurface of Polygon and CurvePolygon gml = """ @@ -2270,10 +2068,8 @@ def test_gml_OGRMultiSurface(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTISURFACE (((0 0,0 1,1 1,0 0)),CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,1 -1,0.292893218813453 -0.707106781186548,0 0)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTISURFACE (((0 0,0 1,1 1,0 0)),CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,1 -1,0.292893218813453 -0.707106781186548,0 0)))', \ + ' not correctly parsed' # MultiSurface of CurvePolygon and Polygon gml = """ @@ -2294,17 +2090,13 @@ def test_gml_OGRMultiSurface(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,1 -1,0.292893218813453 -0.707106781186548,0 0)),((0 0,0 1,1 1,0 0)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,1 -1,0.292893218813453 -0.707106781186548,0 0)),((0 0,0 1,1 1,0 0)))', \ + ' not correctly parsed' geom = ogr.CreateGeometryFromWkt('MULTISURFACE (CURVEPOLYGON((0 0,0 1,1 1,1 0,0 0)))') gml2 = geom.ExportToGML(['FORMAT=GML3']) expected_gml2 = '0 0 0 1 1 1 1 0 0 0' - if gml2 != expected_gml2: - print(gml2) - return 'fail' + assert gml2 == expected_gml2 return 'success' @@ -2318,15 +2110,11 @@ def test_gml_OGRMultiCurve(): gml = """0 0 1 1 1 -1""" geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,1 1,1 -1))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTICURVE (CIRCULARSTRING (0 0,1 1,1 -1))', \ + ' not correctly parsed' gml2 = geom.ExportToGML(['FORMAT=GML3']) - if gml2 != gml: - print(gml2) - return 'fail' + assert gml2 == gml # MultiCurve of LineString and Arc gml = """ @@ -2341,10 +2129,8 @@ def test_gml_OGRMultiCurve(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTICURVE ((0 0,1 1,1 -1),CIRCULARSTRING (0 0,1 1,1 -1))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTICURVE ((0 0,1 1,1 -1),CIRCULARSTRING (0 0,1 1,1 -1))', \ + ' not correctly parsed' # MultiCurve of Arc and LineString gml = """ @@ -2359,10 +2145,8 @@ def test_gml_OGRMultiCurve(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,1 1,1 -1),(0 0,1 1,1 -1))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTICURVE (CIRCULARSTRING (0 0,1 1,1 -1),(0 0,1 1,1 -1))', \ + ' not correctly parsed' # MultiCurve of CompositeCurve gml = """ @@ -2381,10 +2165,8 @@ def test_gml_OGRMultiCurve(): """ geom = ogr.CreateGeometryFromGML(gml) - if geom.ExportToWkt() != 'MULTICURVE (COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,1 1,1 -1)))': - gdaltest.post_reason(' not correctly parsed') - print(geom.ExportToWkt()) - return 'fail' + assert geom.ExportToWkt() == 'MULTICURVE (COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 -1),(1 -1,1 1,1 -1)))', \ + ' not correctly parsed' return 'success' @@ -2397,23 +2179,17 @@ def test_gml_write_gml_ns(): geom = ogr.CreateGeometryFromWkt('POINT(500000 4500000)') gml = geom.ExportToGML(options=['NAMESPACE_DECL=YES']) expected_gml = '500000,4500000' - if gml != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml, expected_gml)) - return 'fail' + assert gml == expected_gml, ('got %s, instead of %s' % (gml, expected_gml)) geom = ogr.CreateGeometryFromWkt('POINT(500000 4500000)') gml = geom.ExportToGML(options=['FORMAT=GML3', 'NAMESPACE_DECL=YES']) expected_gml = '500000 4500000' - if gml != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml, expected_gml)) - return 'fail' + assert gml == expected_gml, ('got %s, instead of %s' % (gml, expected_gml)) geom = ogr.CreateGeometryFromWkt('POINT(500000 4500000)') gml = geom.ExportToGML(options=['FORMAT=GML32', 'GMLID=foo', 'NAMESPACE_DECL=YES']) expected_gml = '500000 4500000' - if gml != expected_gml: - gdaltest.post_reason('got %s, instead of %s' % (gml, expected_gml)) - return 'fail' + assert gml == expected_gml, ('got %s, instead of %s' % (gml, expected_gml)) return 'success' diff --git a/autotest/ogr/ogr_gml_read.py b/autotest/ogr/ogr_gml_read.py index cc5833dbf31d..dae301442d3a 100755 --- a/autotest/ogr/ogr_gml_read.py +++ b/autotest/ogr/ogr_gml_read.py @@ -40,6 +40,7 @@ from osgeo import gdal from osgeo import ogr from osgeo import osr +import pytest ############################################################################### # Test reading geometry and attribute from ionic wfs gml file. @@ -59,26 +60,19 @@ def test_ogr_gml_1(): gdaltest.have_gml_reader = 1 - if gml_ds.GetLayerCount() != 1: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert gml_ds.GetLayerCount() == 1, 'wrong number of layers' lyr = gml_ds.GetLayerByName('GEM') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Aartselaar': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Aartselaar', 'Wrong name field value' wkt = 'POLYGON ((44038 511549,44015 511548,43994 511522,43941 511539,43844 511514,43754 511479,43685 511521,43594 511505,43619 511452,43645 511417,4363 511387,437 511346,43749 511298,43808 511229,43819 511205,4379 511185,43728 511167,43617 511175,43604 511151,43655 511125,43746 511143,43886 511154,43885 511178,43928 511186,43977 511217,4404 511223,44008 511229,44099 51131,44095 511335,44106 51135,44127 511379,44124 511435,44137 511455,44105 511467,44098 511484,44086 511499,4407 511506,44067 511535,44038 511549))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('got unexpected feature.') - return 'fail' + assert feat is None, 'got unexpected feature.' return 'success' @@ -95,26 +89,19 @@ def test_ogr_gml_2(): gml_ds = ogr.Open('tmp/ionic_wfs.gml') - if gml_ds.GetLayerCount() != 1: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert gml_ds.GetLayerCount() == 1, 'wrong number of layers' lyr = gml_ds.GetLayerByName('GEM') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Aartselaar': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Aartselaar', 'Wrong name field value' wkt = 'POLYGON ((44038 511549,44015 511548,43994 511522,43941 511539,43844 511514,43754 511479,43685 511521,43594 511505,43619 511452,43645 511417,4363 511387,437 511346,43749 511298,43808 511229,43819 511205,4379 511185,43728 511167,43617 511175,43604 511151,43655 511125,43746 511143,43886 511154,43885 511178,43928 511186,43977 511217,4404 511223,44008 511229,44099 51131,44095 511335,44106 51135,44127 511379,44124 511435,44137 511455,44105 511467,44098 511484,44086 511499,4407 511506,44067 511535,44038 511549))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('got unexpected feature.') - return 'fail' + assert feat is None, 'got unexpected feature.' return 'success' @@ -128,30 +115,21 @@ def test_ogr_gml_3(): gml_ds = ogr.Open('data/rnf_eg.gml') - if gml_ds.GetLayerCount() != 1: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert gml_ds.GetLayerCount() == 1, 'wrong number of layers' lyr = gml_ds.GetLayerByName('RoadSegment') feat = lyr.GetNextFeature() - if feat.GetField('ngd_id') != 817792: - gdaltest.post_reason('Wrong ngd_id field value') - return 'fail' + assert feat.GetField('ngd_id') == 817792, 'Wrong ngd_id field value' - if feat.GetField('type') != 'HWY': - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 'HWY', 'Wrong type field value' wkt = 'LINESTRING (-63.500411040289066 46.240122507771368,-63.501009714909742 46.240344881690326,-63.502170462373471 46.241041855639622,-63.505862621395394 46.24195250605576,-63.506719184531178 46.242002742901576,-63.507197272602212 46.241931577811606,-63.508403092799554 46.241752283460158,-63.509946573455622 46.241745397977233)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('got unexpected feature.') - return 'fail' + assert feat is None, 'got unexpected feature.' return 'success' @@ -166,43 +144,31 @@ def test_ogr_gml_4(): gml_ds = ogr.Open('data/bom.gml') - if gml_ds.GetLayerCount() != 1: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert gml_ds.GetLayerCount() == 1, 'wrong number of layers' lyr = gml_ds.GetLayerByName('CartographicText') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('wrong number of features') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'wrong number of features' # Test 1st feature feat = lyr.GetNextFeature() - if feat.GetField('featureCode') != 10198: - gdaltest.post_reason('Wrong featureCode field value') - return 'fail' + assert feat.GetField('featureCode') == 10198, 'Wrong featureCode field value' - if feat.GetField('anchorPosition') != 8: - gdaltest.post_reason('Wrong anchorPosition field value') - return 'fail' + assert feat.GetField('anchorPosition') == 8, 'Wrong anchorPosition field value' wkt = 'POINT (347243.85 461299.5)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) # Test 2nd feature feat = lyr.GetNextFeature() - if feat.GetField('featureCode') != 10069: - gdaltest.post_reason('Wrong featureCode field value') - return 'fail' + assert feat.GetField('featureCode') == 10069, 'Wrong featureCode field value' wkt = 'POINT (347251.45 461250.85)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -271,24 +237,16 @@ def test_ogr_gml_7(): ldefn = lyr.GetLayerDefn() # Test fix for #2969 - if lyr.GetFeatureCount() != 5: - gdaltest.post_reason('Bad feature count') - return 'fail' + assert lyr.GetFeatureCount() == 5, 'Bad feature count' try: ldefn.GetFieldDefn(0).GetFieldTypeName except: return 'skip' - if ldefn.GetFieldDefn(0).GetFieldTypeName(ldefn.GetFieldDefn(0).GetType())\ - != 'Real': - return 'fail' - if ldefn.GetFieldDefn(1).GetFieldTypeName(ldefn.GetFieldDefn(1).GetType())\ - != 'Integer': - return 'fail' - if ldefn.GetFieldDefn(2).GetFieldTypeName(ldefn.GetFieldDefn(2).GetType())\ - != 'String': - return 'fail' + assert ldefn.GetFieldDefn(0).GetFieldTypeName(ldefn.GetFieldDefn(0).GetType()) == 'Real' + assert ldefn.GetFieldDefn(1).GetFieldTypeName(ldefn.GetFieldDefn(1).GetType()) == 'Integer' + assert ldefn.GetFieldDefn(2).GetFieldTypeName(ldefn.GetFieldDefn(2).GetType()) == 'String' return 'success' @@ -305,13 +263,9 @@ def test_ogr_gml_8(): lyr = gml_ds.GetLayer() feat = lyr.GetNextFeature() if sys.version_info >= (3, 0, 0): - if feat.GetFieldAsString('name') != '\xc4\x80liamanu'.encode('latin1').decode('utf-8'): - print(feat.GetFieldAsString('name')) - return 'fail' + assert feat.GetFieldAsString('name') == '\xc4\x80liamanu'.encode('latin1').decode('utf-8') else: - if feat.GetFieldAsString('name') != '\xc4\x80liamanu': - print(feat.GetFieldAsString('name')) - return 'fail' + assert feat.GetFieldAsString('name') == '\xc4\x80liamanu' return 'success' @@ -337,19 +291,14 @@ def test_ogr_gml_9(): ret = lyr.CreateFeature(dst_feat) gdal.PopErrorHandler() - if ret != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert ret == 0, 'CreateFeature failed.' ds = None ds = ogr.Open('tmp/broken_utf8.gml') lyr = ds.GetLayerByName('test') feat = lyr.GetNextFeature() - if feat.GetField('test') != '?bad': - gdaltest.post_reason('Unexpected content.') - print(feat.GetField('test')) - return 'fail' + assert feat.GetField('test') == '?bad', 'Unexpected content.' ds = None os.remove('tmp/broken_utf8.gml') @@ -392,9 +341,7 @@ def test_ogr_gml_10(): ret = lyr.CreateFeature(dst_feat) - if ret != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert ret == 0, 'CreateFeature failed.' ds = None @@ -402,50 +349,33 @@ def test_ogr_gml_10(): lyr = ds.GetLayerByName('test') feat = lyr.GetNextFeature() - if feat.GetFieldDefnRef(feat.GetFieldIndex('string')).GetType() != ogr.OFTString: - gdaltest.post_reason('String type is reported wrong. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('string')).GetType())) - return 'fail' - if feat.GetFieldDefnRef(feat.GetFieldIndex('date')).GetType() != ogr.OFTString: - gdaltest.post_reason('Date type is not reported as OFTString. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('date')).GetType())) - return 'fail' - if feat.GetFieldDefnRef(feat.GetFieldIndex('real')).GetType() != ogr.OFTReal: - gdaltest.post_reason('Real type is reported wrong. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('real')).GetType())) - return 'fail' - if feat.GetFieldDefnRef(feat.GetFieldIndex('float')).GetType() != ogr.OFTReal: - gdaltest.post_reason('Float type is not reported as OFTReal. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('float')).GetType())) - return 'fail' - if feat.GetFieldDefnRef(feat.GetFieldIndex('integer')).GetType() != ogr.OFTInteger: - gdaltest.post_reason('Integer type is reported wrong. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('integer')).GetType())) - return 'fail' - - if feat.GetField('string') != 'test string of length 24': - gdaltest.post_reason('Unexpected string content.' + feat.GetField('string')) - return 'fail' - if feat.GetField('date') != '2003/04/22': - gdaltest.post_reason('Unexpected string content.' + feat.GetField('date')) - return 'fail' - if feat.GetFieldAsDouble('real') != 12.34: - gdaltest.post_reason('Unexpected real content.') - return 'fail' - if feat.GetField('float') != 1234.5678: - gdaltest.post_reason('Unexpected float content.') - return 'fail' - if feat.GetField('integer') != 1234: - gdaltest.post_reason('Unexpected integer content.') - return 'fail' - - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('string')).GetWidth() != 100: - gdaltest.post_reason('Unexpected width of string field.') - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('real')).GetWidth() != 4: - gdaltest.post_reason('Unexpected width of real field.') - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('real')).GetPrecision() != 2: - gdaltest.post_reason('Unexpected precision of real field.') - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('integer')).GetWidth() != 5: - gdaltest.post_reason('Unexpected width of integer field.') - return 'fail' + assert feat.GetFieldDefnRef(feat.GetFieldIndex('string')).GetType() == ogr.OFTString, \ + ('String type is reported wrong. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('string')).GetType())) + assert feat.GetFieldDefnRef(feat.GetFieldIndex('date')).GetType() == ogr.OFTString, \ + ('Date type is not reported as OFTString. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('date')).GetType())) + assert feat.GetFieldDefnRef(feat.GetFieldIndex('real')).GetType() == ogr.OFTReal, \ + ('Real type is reported wrong. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('real')).GetType())) + assert feat.GetFieldDefnRef(feat.GetFieldIndex('float')).GetType() == ogr.OFTReal, \ + ('Float type is not reported as OFTReal. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('float')).GetType())) + assert feat.GetFieldDefnRef(feat.GetFieldIndex('integer')).GetType() == ogr.OFTInteger, \ + ('Integer type is reported wrong. Got ' + str(feat.GetFieldDefnRef(feat.GetFieldIndex('integer')).GetType())) + + assert feat.GetField('string') == 'test string of length 24', \ + ('Unexpected string content.' + feat.GetField('string')) + assert feat.GetField('date') == '2003/04/22', \ + ('Unexpected string content.' + feat.GetField('date')) + assert feat.GetFieldAsDouble('real') == 12.34, 'Unexpected real content.' + assert feat.GetField('float') == 1234.5678, 'Unexpected float content.' + assert feat.GetField('integer') == 1234, 'Unexpected integer content.' + + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('string')).GetWidth() == 100, \ + 'Unexpected width of string field.' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('real')).GetWidth() == 4, \ + 'Unexpected width of real field.' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('real')).GetPrecision() == 2, \ + 'Unexpected precision of real field.' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('integer')).GetWidth() == 5, \ + 'Unexpected width of integer field.' ds = None os.remove('tmp/fields.gml') @@ -479,21 +409,16 @@ def test_ogr_gml_11(): ds = ogr.Open('data/testgeometryelementpath.gml') lyr = ds.GetLayer(0) - if lyr.GetGeometryColumn() != 'location1container|location1': - gdaltest.post_reason('did not get expected geometry column name') - return 'fail' + assert lyr.GetGeometryColumn() == 'location1container|location1', \ + 'did not get expected geometry column name' feat = lyr.GetNextFeature() - if feat.GetField('attrib1') != 'attrib1_value': - gdaltest.post_reason('did not get expected value for attrib1') - return 'fail' - if feat.GetField('attrib2') != 'attrib2_value': - gdaltest.post_reason('did not get expected value for attrib2') - return 'fail' + assert feat.GetField('attrib1') == 'attrib1_value', \ + 'did not get expected value for attrib1' + assert feat.GetField('attrib2') == 'attrib2_value', \ + 'did not get expected value for attrib2' geom = feat.GetGeometryRef() - if geom.ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('did not get expected geometry') - return 'fail' + assert geom.ExportToWkt() == 'POINT (3 50)', 'did not get expected geometry' ds = None return 'success' @@ -508,21 +433,16 @@ def test_ogr_gml_12(): ds = ogr.Open('/vsizip/data/testgeometryelementpath.zip/testgeometryelementpath.gml') lyr = ds.GetLayer(0) - if lyr.GetGeometryColumn() != 'location1container|location1': - gdaltest.post_reason('did not get expected geometry column name') - return 'fail' + assert lyr.GetGeometryColumn() == 'location1container|location1', \ + 'did not get expected geometry column name' feat = lyr.GetNextFeature() - if feat.GetField('attrib1') != 'attrib1_value': - gdaltest.post_reason('did not get expected value for attrib1') - return 'fail' - if feat.GetField('attrib2') != 'attrib2_value': - gdaltest.post_reason('did not get expected value for attrib2') - return 'fail' + assert feat.GetField('attrib1') == 'attrib1_value', \ + 'did not get expected value for attrib1' + assert feat.GetField('attrib2') == 'attrib2_value', \ + 'did not get expected value for attrib2' geom = feat.GetGeometryRef() - if geom.ExportToWkt() != 'POINT (3 50)': - gdaltest.post_reason('did not get expected geometry') - return 'fail' + assert geom.ExportToWkt() == 'POINT (3 50)', 'did not get expected geometry' ds = None return 'success' @@ -539,18 +459,14 @@ def test_ogr_gml_13(): ds = ogr.Open('data/testlistfields.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat.GetFieldAsStringList(feat.GetFieldIndex('attrib1')) != ['value1', 'value2']: - gdaltest.post_reason('did not get expected value for attrib1') - return 'fail' - if feat.GetField(feat.GetFieldIndex('attrib2')) != 'value3': - gdaltest.post_reason('did not get expected value for attrib2') - return 'fail' - if feat.GetFieldAsIntegerList(feat.GetFieldIndex('attrib3')) != [4, 5]: - gdaltest.post_reason('did not get expected value for attrib3') - return 'fail' - if feat.GetFieldAsDoubleList(feat.GetFieldIndex('attrib4')) != [6.1, 7.1]: - gdaltest.post_reason('did not get expected value for attrib4') - return 'fail' + assert feat.GetFieldAsStringList(feat.GetFieldIndex('attrib1')) == ['value1', 'value2'], \ + 'did not get expected value for attrib1' + assert feat.GetField(feat.GetFieldIndex('attrib2')) == 'value3', \ + 'did not get expected value for attrib2' + assert feat.GetFieldAsIntegerList(feat.GetFieldIndex('attrib3')) == [4, 5], \ + 'did not get expected value for attrib3' + assert feat.GetFieldAsDoubleList(feat.GetFieldIndex('attrib4')) == [6.1, 7.1], \ + 'did not get expected value for attrib4' ds = None gdal.Unlink('data/testlistfields.gfs') @@ -603,9 +519,7 @@ def test_ogr_gml_14(): except (IOError, OSError): return 'fail' - if text != expectedtext: - print('Problem with file 1') - return 'fail' + assert text == expectedtext, 'Problem with file 1' try: fp = open('tmp/cache/xlink2resolved.gml', 'r') @@ -618,9 +532,7 @@ def test_ogr_gml_14(): except (IOError, OSError): return 'fail' - if text != expectedtext: - print('Problem with file 2') - return 'fail' + assert text == expectedtext, 'Problem with file 2' return 'success' @@ -639,9 +551,7 @@ def test_ogr_gml_15(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro data/test_point.gml') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -680,18 +590,12 @@ def test_ogr_gml_17(): lyr = ds.GetLayer(0) sr = lyr.GetSpatialRef() got_wkt = sr.ExportToWkt() - if got_wkt.find('GEOGCS["WGS 84"') == -1: - gdaltest.post_reason('did not get expected SRS') - print(got_wkt) - return 'fail' + assert got_wkt.find('GEOGCS["WGS 84"') != -1, 'did not get expected SRS' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POINT (2.09 34.12)': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POINT (2.09 34.12)', 'did not get expected geometry' return 'success' @@ -708,18 +612,12 @@ def test_ogr_gml_18(): lyr = ds.GetLayer(0) sr = lyr.GetSpatialRef() got_wkt = sr.ExportToWkt() - if got_wkt.find('GEOGCS["WGS 84"') == -1: - gdaltest.post_reason('did not get expected SRS') - print(got_wkt) - return 'fail' + assert got_wkt.find('GEOGCS["WGS 84"') != -1, 'did not get expected SRS' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POINT (2.09 34.12)': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POINT (2.09 34.12)', 'did not get expected geometry' return 'success' @@ -745,19 +643,14 @@ def test_ogr_gml_19(): lyr = ds.GetLayer(0) sr = lyr.GetSpatialRef() got_wkt = sr.ExportToWkt() - if got_wkt.find('GEOGCS["WGS 84"') == -1 or \ - got_wkt.find('AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') == -1: - gdaltest.post_reason('did not get expected SRS') - print(got_wkt) - return 'fail' + assert (not (got_wkt.find('GEOGCS["WGS 84"') == -1 or \ + got_wkt.find('AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') == -1)), \ + 'did not get expected SRS' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POINT (34.12 2.09)': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POINT (34.12 2.09)', 'did not get expected geometry' return 'success' @@ -785,28 +678,21 @@ def test_ogr_gml_20(): return 'skip' idx = ldefn.GetFieldIndex("gml_id") - if idx == -1: - gdaltest.post_reason('did not get expected column "gml_id"') - return 'fail' + assert idx != -1, 'did not get expected column "gml_id"' idx = ldefn.GetFieldIndex("cat") fddefn = ldefn.GetFieldDefn(idx) - if fddefn.GetFieldTypeName(fddefn.GetType()) != 'Integer64': - gdaltest.post_reason('did not get expected column type for col "cat"') - return 'fail' + assert fddefn.GetFieldTypeName(fddefn.GetType()) == 'Integer64', \ + 'did not get expected column type for col "cat"' idx = ldefn.GetFieldIndex("str1") fddefn = ldefn.GetFieldDefn(idx) - if fddefn.GetFieldTypeName(fddefn.GetType()) != 'String': - gdaltest.post_reason('did not get expected column type for col "str1"') - return 'fail' + assert fddefn.GetFieldTypeName(fddefn.GetType()) == 'String', \ + 'did not get expected column type for col "str1"' - if lyr.GetGeometryColumn() != 'the_geom': - gdaltest.post_reason('did not get expected geometry column name') - return 'fail' + assert lyr.GetGeometryColumn() == 'the_geom', \ + 'did not get expected geometry column name' - if ldefn.GetGeomType() != ogr.wkbPoint: - gdaltest.post_reason('did not get expected geometry type') - return 'fail' + assert ldefn.GetGeomType() == ogr.wkbPoint, 'did not get expected geometry type' ds = None @@ -857,9 +743,8 @@ def test_ogr_gml_21(frmt='GML3'): ds = ogr.Open('tmp/gml_21.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - gdaltest.post_reason('did not get expected geometry') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49)', \ + 'did not get expected geometry' ds = None # Test that .gml and .xsd are identical to what is expected @@ -874,9 +759,8 @@ def test_ogr_gml_21(frmt='GML3'): line1 = line1.strip() line2 = line2.strip() if line1 != line2: - gdaltest.post_reason('.gml file not identical to expected') print(open('tmp/gml_21.gml', 'rt').read()) - return 'fail' + pytest.fail('.gml file not identical to expected') line1 = f1.readline() line2 = f2.readline() f1.close() @@ -895,9 +779,8 @@ def test_ogr_gml_21(frmt='GML3'): line1 = line1.strip() line2 = line2.strip() if line1 != line2: - gdaltest.post_reason('.xsd file not identical to expected') print(open('tmp/gml_21.xsd', 'rt').read()) - return 'fail' + pytest.fail('.xsd file not identical to expected') line1 = f1.readline() line2 = f2.readline() f1.close() @@ -924,18 +807,11 @@ def test_ogr_gml_22(): ds = ogr.Open('data/paris_typical_strike_demonstration.xml') lyr = ds.GetLayerByName('RouteGeometry') - if lyr is None: - gdaltest.post_reason('cannot find RouteGeometry') - return 'fail' + assert lyr is not None, 'cannot find RouteGeometry' lyr = ds.GetLayerByName('RouteInstruction') - if lyr is None: - gdaltest.post_reason('cannot find RouteInstruction') - return 'fail' + assert lyr is not None, 'cannot find RouteInstruction' count = lyr.GetFeatureCount() - if count != 9: - gdaltest.post_reason('did not get expected feature count') - print(count) - return 'fail' + assert count == 9, 'did not get expected feature count' ds = None return 'success' @@ -963,25 +839,17 @@ def test_ogr_gml_23(): lyr = ds.GetLayer(0) sr = lyr.GetSpatialRef() got_wkt = sr.ExportToWkt() - if got_wkt.find('GEOGCS["WGS 84"') == -1 or \ - got_wkt.find('AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') != -1: - gdaltest.post_reason('did not get expected SRS') - print(got_wkt) - return 'fail' + assert (got_wkt.find('GEOGCS["WGS 84"') != -1 and \ + got_wkt.find('AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') == -1), \ + 'did not get expected SRS' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POINT (2 49)': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POINT (2 49)', 'did not get expected geometry' extent = lyr.GetExtent() - if extent != (2.0, 3.0, 49.0, 50.0): - gdaltest.post_reason('did not get expected layer extent') - print(extent) - return 'fail' + assert extent == (2.0, 3.0, 49.0, 50.0), 'did not get expected layer extent' return 'success' @@ -1018,16 +886,10 @@ def test_ogr_gml_24(): feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POINT (2 49)': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POINT (2 49)', 'did not get expected geometry' extent = lyr.GetExtent() - if extent != (2.0, 3.0, 49.0, 50.0): - gdaltest.post_reason('did not get expected layer extent') - print(extent) - return 'fail' + assert extent == (2.0, 3.0, 49.0, 50.0), 'did not get expected layer extent' return 'success' @@ -1058,10 +920,8 @@ def test_ogr_gml_25(): feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POLYGON ((14 21,6 21,6 9,14 9,22 9,22 21,14 21))': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POLYGON ((14 21,6 21,6 9,14 9,22 9,22 21,14 21))', \ + 'did not get expected geometry' return 'success' @@ -1083,15 +943,13 @@ def test_ogr_gml_26(): f = open('tmp/ogr_gml_26.gml', 'rt') content = f.read() f.close() - if content.find("478315.531254762880.5158") == -1: - return 'fail' + assert content.find("478315.531254762880.5158") != -1 ds = ogr.Open('tmp/ogr_gml_26.gml') lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbPolygon25D: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon25D ds = None @@ -1115,16 +973,13 @@ def test_ogr_gml_27(): f = open('tmp/ogr_gml_27.gml', 'rt') content = f.read() f.close() - if content.find("478315.53125 4762880.5 158") == -1: - return 'fail' + assert content.find("478315.53125 4762880.5 158") != -1 ds = ogr.Open('tmp/ogr_gml_27.gml') lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbPolygon25D: - print(lyr.GetGeomType()) - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon25D ds = None @@ -1148,23 +1003,20 @@ def test_ogr_gml_28(): # Try with .xsd ds = ogr.Open('tmp/ogr_gml_28.gml') lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbNone: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbNone ds = None os.unlink('tmp/ogr_gml_28.xsd') ds = ogr.Open('tmp/ogr_gml_28.gml') lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbNone: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbNone ds = None # Try with .gfs ds = ogr.Open('tmp/ogr_gml_28.gml') lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbNone: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbNone ds = None return 'success' @@ -1187,17 +1039,14 @@ def test_ogr_gml_29(): for j, expected_result in enumerate(expected_results): lyr = ds.GetLayer(j) - if lyr.GetGeomType() != expected_result[0]: - gdaltest.post_reason('layer %d, did not get expected layer geometry type' % j) - return 'fail' + assert lyr.GetGeomType() == expected_result[0], \ + ('layer %d, did not get expected layer geometry type' % j) for _ in range(2): feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != expected_result[1]: - gdaltest.post_reason('layer %d, did not get expected geometry' % j) - print(got_wkt) - return 'fail' + assert got_wkt == expected_result[1], \ + ('layer %d, did not get expected geometry' % j) ds = None @@ -1241,17 +1090,9 @@ def test_ogr_gml_30(): gdal.Unlink("/vsimem/ogr_gml_30.gml") gdal.Unlink("/vsimem/ogr_gml_30.gfs") - if len(field1) != 2050: - gdaltest.post_reason('did not get expected len(field1)') - print(field1) - print(len(field1)) - return 'fail' + assert len(field1) == 2050, 'did not get expected len(field1)' - if len(geom_wkt) != 2060: - gdaltest.post_reason('did not get expected len(geom_wkt)') - print(geom_wkt) - print(len(geom_wkt)) - return 'fail' + assert len(geom_wkt) == 2060, 'did not get expected len(geom_wkt)' return 'success' @@ -1276,16 +1117,12 @@ def test_ogr_gml_31(): lyr = ds.GetLayer(1) feat = lyr.GetNextFeature() feat = lyr.GetNextFeature() - if feat.GetFID() != 1: - gdaltest.post_reason('did not get feature when reading directly second layer') - return 'fail' + assert feat.GetFID() == 1, 'did not get feature when reading directly second layer' lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() feat = lyr.GetNextFeature() - if feat.GetFID() != 1: - gdaltest.post_reason('did not get feature when reading back first layer') - return 'fail' + assert feat.GetFID() == 1, 'did not get feature when reading back first layer' return 'success' @@ -1312,9 +1149,7 @@ def test_ogr_gml_32(): lyr = ds.GetLayer(1) feat = lyr.GetNextFeature() feat = lyr.GetNextFeature() - if feat.GetFID() != 1: - gdaltest.post_reason('did not get feature when reading directly second layer') - return 'fail' + assert feat.GetFID() == 1, 'did not get feature when reading directly second layer' ds = None @@ -1324,9 +1159,8 @@ def test_ogr_gml_32(): data = str(data) - if data.find("true") == -1: - gdaltest.post_reason('did not find true in .gfs') - return 'fail' + assert data.find("true") != -1, \ + 'did not find true in .gfs' gdal.Unlink("/vsimem/ogr_gml_31.gml") gdal.Unlink("/vsimem/ogr_gml_31.gfs") @@ -1369,9 +1203,7 @@ def test_ogr_gml_33(): else: fid = feat.GetFID() expected_fid = read_seq[1] - if fid != expected_fid: - gdaltest.post_reason('failed at step %d' % i) - return 'fail' + assert fid == expected_fid, ('failed at step %d' % i) return 'success' @@ -1397,9 +1229,7 @@ def test_ogr_gml_34(): ds = ogr.Open('/vsimem/ogr_gml_34.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat.GetFieldAsString('name') != '\xc4\x80liamanu<&': - print(feat.GetFieldAsString('name')) - return 'fail' + assert feat.GetFieldAsString('name') == '\xc4\x80liamanu<&' ds = None gdal.Unlink('/vsimem/ogr_gml_34.gml') @@ -1448,29 +1278,20 @@ def test_ogr_gml_35(): except OSError: pass - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('did not expect error') - return 'fail' - if ds.GetLayerCount() != 3: - # We have an extra layer : ResolvedNodes - gdaltest.post_reason('expected 3 layers, got %d' % ds.GetLayerCount()) - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'did not expect error' + assert ds.GetLayerCount() == 3, ('expected 3 layers, got %d' % ds.GetLayerCount()) lyr = ds.GetLayerByName('Suolo') feat = lyr.GetNextFeature() wkt = 'MULTIPOLYGON (((-0.1 0.6,-0.0 0.7,0.2 0.7,0.3 0.6,0.5 0.6,0.5 0.8,0.7 0.8,0.8 0.6,0.9 0.6,0.9 0.4,0.7 0.3,0.7 0.2,0.9 0.1,0.9 -0.1,0.6 -0.2,0.3 -0.2,0.2 -0.2,-0.1 0.0,-0.1 0.1,-0.1 0.2,0.1 0.3,0.1 0.4,-0.0 0.4,-0.1 0.5,-0.1 0.6)))' - if ogrtest.check_feature_geometry(feat, wkt): - print(feat.GetGeometryRef()) - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), feat.GetGeometryRef() ds = None ds = ogr.Open('tmp/GmlTopo-sample.xml') lyr = ds.GetLayerByName('Suolo') feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, wkt): - print(feat.GetGeometryRef()) - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), feat.GetGeometryRef() ds = None @@ -1505,9 +1326,7 @@ def test_ogr_gml_36(GML_FACE_HOLE_NEGATIVE='NO'): ds = ogr.Open('tmp/GmlTopo-sample.xml') gdal.SetConfigOption('GML_SKIP_RESOLVE_ELEMS', None) gdal.SetConfigOption('GML_FACE_HOLE_NEGATIVE', None) - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('did not expect error') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'did not expect error' lyr = ds.GetLayerByName('Suolo') feat = lyr.GetNextFeature() @@ -1515,9 +1334,7 @@ def test_ogr_gml_36(GML_FACE_HOLE_NEGATIVE='NO'): wkt = 'MULTIPOLYGON (((-0.1 0.6,-0.0 0.7,0.2 0.7,0.3 0.6,0.5 0.6,0.5 0.8,0.7 0.8,0.8 0.6,0.9 0.6,0.9 0.4,0.7 0.3,0.7 0.2,0.9 0.1,0.9 -0.1,0.6 -0.2,0.3 -0.2,0.2 -0.2,-0.1 0.0,-0.1 0.1,-0.1 0.2,0.1 0.3,0.1 0.4,-0.0 0.4,-0.1 0.5,-0.1 0.6)))' else: wkt = 'POLYGON ((-0.1 0.6,-0.0 0.7,0.2 0.7,0.3 0.6,0.5 0.6,0.5 0.8,0.7 0.8,0.8 0.6,0.9 0.6,0.9 0.4,0.7 0.3,0.7 0.2,0.9 0.1,0.9 -0.1,0.6 -0.2,0.3 -0.2,0.2 -0.2,-0.1 0.0,-0.1 0.1,-0.1 0.2,0.1 0.3,0.1 0.4,-0.0 0.4,-0.1 0.5,-0.1 0.6),(0.2 0.2,0.2 0.4,0.4 0.4,0.5 0.2,0.5 0.1,0.5 0.0,0.2 0.0,0.2 0.2),(0.6 0.1,0.8 0.1,0.8 -0.1,0.6 -0.1,0.6 0.1))' - if ogrtest.check_feature_geometry(feat, wkt): - print(feat.GetGeometryRef()) - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), feat.GetGeometryRef() ds = None @@ -1526,9 +1343,7 @@ def test_ogr_gml_36(GML_FACE_HOLE_NEGATIVE='NO'): gdal.SetConfigOption('GML_FACE_HOLE_NEGATIVE', None) lyr = ds.GetLayerByName('Suolo') feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, wkt): - print(feat.GetGeometryRef()) - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), feat.GetGeometryRef() ds = None @@ -1585,16 +1400,12 @@ def test_ogr_gml_38(resolver='HUGE'): except OSError: pass - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('did not expect error') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'did not expect error' lyr = ds.GetLayerByName('Suolo') feat = lyr.GetNextFeature() wkt = 'MULTIPOLYGON (((0.9 0.6,0.9 0.4,0.7 0.3,0.7 0.2,0.9 0.1,0.9 -0.1,0.6 -0.2,0.3 -0.2,0.2 -0.2,-0.1 0.0,-0.1 0.1,-0.1 0.2,0.1 0.3,0.1 0.4,-0.0 0.4,-0.1 0.5,-0.1 0.6,-0.0 0.7,0.2 0.7,0.3 0.6,0.5 0.6,0.5 0.8,0.7 0.8,0.8 0.6,0.9 0.6),(0.6 0.1,0.6 -0.1,0.8 -0.1,0.8 0.1,0.6 0.1),(0.2 0.4,0.2 0.2,0.2 0.0,0.5 0.0,0.5 0.1,0.5 0.2,0.4 0.4,0.2 0.4)))' - if ogrtest.check_feature_geometry(feat, wkt): - print(feat.GetGeometryRef()) - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), feat.GetGeometryRef() ds = None @@ -1619,8 +1430,7 @@ def test_ogr_gml_40(): ds = ogr.Open('data/testLookForSimpleType.xml') lyr = ds.GetLayer(0) fld_defn = lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('CITYNAME')) - if fld_defn.GetWidth() != 26: - return 'fail' + assert fld_defn.GetWidth() == 26 return 'success' @@ -1651,8 +1461,7 @@ def test_ogr_gml_41(): ds.ReleaseResultSet(lyr) if val == 0: - if gdal.GetLastErrorMsg().find('not implemented due to missing libxml2 support') == -1: - return 'fail' + assert gdal.GetLastErrorMsg().find('not implemented due to missing libxml2 support') != -1 return 'skip' gdaltest.have_gml_validation = True @@ -1690,8 +1499,7 @@ def test_ogr_gml_42(): ds.ReleaseResultSet(lyr) - if val == 0: - return 'fail' + assert val != 0 return 'success' @@ -1709,8 +1517,7 @@ def test_ogr_gml_43(): return 'skip' ds = ogr.Open('data/wfs_typefeature.gml') - if ds is None: - return 'fail' + assert ds is not None ds = None try: @@ -1725,9 +1532,7 @@ def test_ogr_gml_43(): else: can_download_schema = gdal.GetDriverByName('HTTP') is not None - if can_download_schema: - gdaltest.post_reason('.gfs found, but schema could be downloaded') - return 'fail' + assert not can_download_schema, '.gfs found, but schema could be downloaded' return 'success' @@ -1777,8 +1582,7 @@ def test_ogr_gml_44(): lyr = ds.GetLayer(0) # fid and dbl - if lyr.GetLayerDefn().GetFieldCount() != 2: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 2 ds = None @@ -1835,8 +1639,7 @@ def test_ogr_gml_45(): gdal.Unlink('/vsimem/ogr_gml_45.gml') gdal.Unlink('/vsimem/ogr_gml_45.xsd') - if val == 0: - return 'fail' + assert val != 0 return 'success' @@ -1945,8 +1748,7 @@ def test_ogr_gml_46(): gdal.Unlink('/vsimem/ogr_gml_46.gml') gdal.Unlink('/vsimem/ogr_gml_46.xsd') - if val == 0: - return 'fail' + assert val != 0 # Only minor schema changes if frmt == 'GML3Deegree': @@ -1982,9 +1784,7 @@ def test_ogr_gml_47(): ds.ReleaseResultSet(lyr) ds = None - if val == 0: - gdaltest.post_reason('validation failed for file=%s' % filename) - return 'fail' + assert val != 0, ('validation failed for file=%s' % filename) return 'success' @@ -2010,11 +1810,9 @@ def test_ogr_gml_48(): ds = ogr.Open('data/schema_with_geom_in_complextype.xml') lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbUnknown: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbUnknown - if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetType() == ogr.OFTString ds = None @@ -2044,16 +1842,14 @@ def test_ogr_gml_49(): ds = ogr.Open('/vsimem/ogr_gml_49.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat.GetGeometryRef().GetGeometryType() != ogr.wkbPolygon: - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() == ogr.wkbPolygon ds = None # Now with .gfs file present (#6247) ds = ogr.Open('/vsimem/ogr_gml_49.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat.GetGeometryRef().GetGeometryType() != ogr.wkbPolygon: - return 'fail' + assert feat.GetGeometryRef().GetGeometryType() == ogr.wkbPolygon ds = None gdal.Unlink('/vsimem/ogr_gml_49.gml') @@ -2125,29 +1921,18 @@ def test_ogr_gml_51(): f = open('tmp/ogr_gml_51.gml', 'rt') content = f.read() f.close() - if content.find("") == -1: - print(content) - return 'fail' - if content.find("""215229.266""") == -1: - print(content) - return 'fail' + assert content.find("") != -1 + assert content.find("""215229.266""") != -1 - if content.find("""479647""") != -1: - print(content) - return 'fail' + assert content.find("""479647""") == -1 ds = ogr.Open('tmp/ogr_gml_51.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None ds = None return 'success' @@ -2171,15 +1956,11 @@ def test_ogr_gml_52(): ds = ogr.Open('data/fake_mtkgml.xml') lyr = ds.GetLayerByName('A') - if lyr.GetGeomType() != ogr.wkbPoint25D: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPoint25D srs = lyr.GetSpatialRef() - if srs is None: - return 'fail' + assert srs is not None wkt = srs.ExportToWkt() - if wkt.find('3067') < 0: - print(wkt) - return 'fail' + assert wkt.find('3067') >= 0 feat = lyr.GetNextFeature() if feat.GetField('gid') != '1' or \ @@ -2192,19 +1973,16 @@ def test_ogr_gml_52(): return 'fail' lyr = ds.GetLayerByName('B') - if lyr.GetGeomType() != ogr.wkbPolygon25D: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon25D srs = lyr.GetSpatialRef() - if srs is None: - return 'fail' + assert srs is not None feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'POLYGON ((280000 7000000 0,281000 7000000 0,281000 7001000 0,280000 7001000 0,280000 7000000 0))') != 0: feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('C') - if lyr.GetGeomType() != ogr.wkbLineString25D: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbLineString25D feat = lyr.GetNextFeature() if ogrtest.check_feature_geometry(feat, 'LINESTRING (280000 7000000 0,281000 7000000 0,281000 7001000 0,280000 7001000 0,280000 7000000 0)') != 0: feat.DumpReadable() @@ -2226,8 +2004,7 @@ def test_ogr_gml_53(): return 'skip' ds = ogr.Open('data/archsites.xsd') - if ds is not None: - return 'fail' + assert ds is None ds = None return 'success' @@ -2244,14 +2021,12 @@ def test_ogr_gml_54(): gdal.Unlink('data/empty.gfs') ds = ogr.Open('data/empty.gml') - if ds is None: - return 'fail' + assert ds is not None ds = None # with .gfs now ds = ogr.Open('data/empty.gml') - if ds is None: - return 'fail' + assert ds is not None ds = None gdal.Unlink('data/empty.gfs') @@ -2270,8 +2045,7 @@ def test_ogr_gml_55(): ds = ogr.Open('data/ogr_gml_55.gml') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTString: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetType() == ogr.OFTString ds = None try: @@ -2298,39 +2072,27 @@ def test_ogr_gml_56(): ds = ogr.Open('data/ogr_gml_56.gml') gdal.SetConfigOption('GML_REGISTRY', None) lyr = ds.GetLayerByName('mainFeature') - if lyr.GetSpatialRef() is None: - return 'fail' + assert lyr.GetSpatialRef() is not None feat = lyr.GetNextFeature() - if feat.GetFieldAsString(feat.GetFieldIndex('subFeatureProperty_href')) != '#subFeature.0': - return 'fail' - if feat.GetFieldAsStringList(feat.GetFieldIndex('subFeatureRepeatedProperty_href')) != ['#subFeatureRepeated.0', '#subFeatureRepeated.1']: - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,1 0,0 0))': - return 'fail' - if feat.GetGeomFieldRef(1).ExportToWkt() != 'POINT (10 10)': - return 'fail' + assert feat.GetFieldAsString(feat.GetFieldIndex('subFeatureProperty_href')) == '#subFeature.0' + assert feat.GetFieldAsStringList(feat.GetFieldIndex('subFeatureRepeatedProperty_href')) == ['#subFeatureRepeated.0', '#subFeatureRepeated.1'] + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'POLYGON ((0 0,0 1,1 1,1 0,0 0))' + assert feat.GetGeomFieldRef(1).ExportToWkt() == 'POINT (10 10)' lyr = ds.GetLayerByName('subFeature') - if lyr.GetLayerDefn().GetGeomFieldCount() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldCount() == 0 feat = lyr.GetNextFeature() - if feat.GetFieldAsStringList(feat.GetFieldIndex('subFeatureRepeatedProperty_href')) != ['#subFeatureRepeated.2']: - return 'fail' - if feat.GetField('foo') != 'bar': - return 'fail' + assert feat.GetFieldAsStringList(feat.GetFieldIndex('subFeatureRepeatedProperty_href')) == ['#subFeatureRepeated.2'] + assert feat.GetField('foo') == 'bar' lyr = ds.GetLayerByName('subFeatureRepeated') feat = lyr.GetNextFeature() - if feat.GetField('gml_id') != 'subFeatureRepeated.2': - return 'fail' - if feat.GetField('bar') != 'baz': - return 'fail' + assert feat.GetField('gml_id') == 'subFeatureRepeated.2' + assert feat.GetField('bar') == 'baz' feat = lyr.GetNextFeature() - if feat.GetField('gml_id') != 'subFeatureRepeated.0': - return 'fail' + assert feat.GetField('gml_id') == 'subFeatureRepeated.0' feat = lyr.GetNextFeature() - if feat.GetField('gml_id') != 'subFeatureRepeated.1': - return 'fail' + assert feat.GetField('gml_id') == 'subFeatureRepeated.1' ds = None try: @@ -2355,11 +2117,9 @@ def test_ogr_gml_57(): if i == 3: options = ['FORMAT=GML3.2'] ds = ogr.GetDriverByName('GML').CreateDataSource('/vsimem/ogr_gml_57.gml', options=options) - if ds.TestCapability(ogr.ODsCCreateGeomFieldAfterCreateLayer) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCCreateGeomFieldAfterCreateLayer) == 1 lyr = ds.CreateLayer('myLayer', geom_type=ogr.wkbNone) - if lyr.TestCapability(ogr.OLCCreateGeomField) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCCreateGeomField) == 1 geomfielddefn = ogr.GeomFieldDefn('first_geometry', ogr.wkbPoint) if i == 1 or i == 2: sr = osr.SpatialReference() @@ -2391,16 +2151,11 @@ def test_ogr_gml_57(): ds = ogr.Open('/vsimem/ogr_gml_57.gml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if i == 1 and feat.GetGeomFieldRef(0).GetSpatialReference().ExportToWkt().find('32630') < 0: - return 'fail' - if i == 1 and feat.GetGeomFieldRef(1).GetSpatialReference().ExportToWkt().find('32630') < 0: - return 'fail' - if i == 2 and feat.GetGeomFieldRef(1).GetSpatialReference().ExportToWkt().find('32631') < 0: - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'POINT (0 1)': - return 'fail' - if feat.GetGeomFieldRef(1).ExportToWkt() != 'LINESTRING (2 3,4 5)': - return 'fail' + assert not (i == 1 and feat.GetGeomFieldRef(0).GetSpatialReference().ExportToWkt().find('32630') < 0) + assert not (i == 1 and feat.GetGeomFieldRef(1).GetSpatialReference().ExportToWkt().find('32630') < 0) + assert not (i == 2 and feat.GetGeomFieldRef(1).GetSpatialReference().ExportToWkt().find('32631') < 0) + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'POINT (0 1)' + assert feat.GetGeomFieldRef(1).ExportToWkt() == 'LINESTRING (2 3,4 5)' ds = None gdal.Unlink('/vsimem/ogr_gml_57.gml') @@ -2422,16 +2177,11 @@ def test_ogr_gml_58(): ds = ogr.Open('data/inspire_cadastralparcel.xml') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetGeomFieldCount() != 2: - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetName() != 'geometry': - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbMultiPolygon: - return 'fail' - if lyr_defn.GetGeomFieldDefn(1).GetName() != 'referencePoint': - return 'fail' - if lyr_defn.GetGeomFieldDefn(1).GetType() != ogr.wkbPoint: - return 'fail' + assert lyr_defn.GetGeomFieldCount() == 2 + assert lyr_defn.GetGeomFieldDefn(0).GetName() == 'geometry' + assert lyr_defn.GetGeomFieldDefn(0).GetType() == ogr.wkbMultiPolygon + assert lyr_defn.GetGeomFieldDefn(1).GetName() == 'referencePoint' + assert lyr_defn.GetGeomFieldDefn(1).GetType() == ogr.wkbPoint feat = lyr.GetNextFeature() expected = [('gml_id', 'CadastralParcel-01'), @@ -2449,15 +2199,9 @@ def test_ogr_gml_58(): ('administrativeUnit_href', '#AU.1'), ('zoning_href', '#CZ.1')] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - return 'fail' - if feat.GetGeomFieldRef(1).ExportToWkt() != 'POINT (2.5 49.5)': - return 'fail' + assert feat.GetField(key) == val + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))' + assert feat.GetGeomFieldRef(1).ExportToWkt() == 'POINT (2.5 49.5)' feat = lyr.GetNextFeature() expected = [('gml_id', 'CadastralParcel-02'), @@ -2475,15 +2219,9 @@ def test_ogr_gml_58(): ('administrativeUnit_href', None), ('zoning_href', None)] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - return 'fail' - if feat.GetGeomFieldRef(1) is not None: - return 'fail' + assert feat.GetField(key) == val + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))' + assert feat.GetGeomFieldRef(1) is None feat = None lyr = None ds = None @@ -2491,8 +2229,7 @@ def test_ogr_gml_58(): ds = ogr.Open('data/inspire_basicpropertyunit.xml') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetGeomFieldCount() != 0: - return 'fail' + assert lyr_defn.GetGeomFieldCount() == 0 feat = lyr.GetNextFeature() expected = [('gml_id', 'BasicPropertyUnit-01'), @@ -2507,11 +2244,7 @@ def test_ogr_gml_58(): ('endLifespanVersion', '2003-01-01T00:00:00.0Z'), ('administrativeUnit_href', '#AU.1')] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' + assert feat.GetField(key) == val feat = lyr.GetNextFeature() expected = [('gml_id', 'BasicPropertyUnit-02'), @@ -2526,11 +2259,7 @@ def test_ogr_gml_58(): ('endLifespanVersion', None), ('administrativeUnit_href', None)] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' + assert feat.GetField(key) == val feat = None lyr = None ds = None @@ -2538,12 +2267,9 @@ def test_ogr_gml_58(): ds = ogr.Open('data/inspire_cadastralboundary.xml') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetGeomFieldCount() != 1: - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetName() != 'geometry': - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbLineString: - return 'fail' + assert lyr_defn.GetGeomFieldCount() == 1 + assert lyr_defn.GetGeomFieldDefn(0).GetName() == 'geometry' + assert lyr_defn.GetGeomFieldDefn(0).GetType() == ogr.wkbLineString feat = lyr.GetNextFeature() expected = [('gml_id', 'CadastralBoundary-01'), @@ -2557,13 +2283,8 @@ def test_ogr_gml_58(): ('validTo', '2003-01-01T00:00:00.0Z'), ('parcel_href', ['#Parcel.1', '#Parcel.2'])] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'LINESTRING (2 49,3 50)': - return 'fail' + assert feat.GetField(key) == val + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'LINESTRING (2 49,3 50)' feat = lyr.GetNextFeature() expected = [('gml_id', 'CadastralBoundary-02'), @@ -2577,13 +2298,8 @@ def test_ogr_gml_58(): ('validTo', None), ('parcel_href', None)] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'LINESTRING (2 49,3 50)': - return 'fail' + assert feat.GetField(key) == val + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'LINESTRING (2 49,3 50)' feat = None lyr = None ds = None @@ -2591,16 +2307,11 @@ def test_ogr_gml_58(): ds = ogr.Open('data/inspire_cadastralzoning.xml') lyr = ds.GetLayer(0) lyr_defn = lyr.GetLayerDefn() - if lyr_defn.GetGeomFieldCount() != 2: - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetName() != 'geometry': - return 'fail' - if lyr_defn.GetGeomFieldDefn(0).GetType() != ogr.wkbMultiPolygon: - return 'fail' - if lyr_defn.GetGeomFieldDefn(1).GetName() != 'referencePoint': - return 'fail' - if lyr_defn.GetGeomFieldDefn(1).GetType() != ogr.wkbPoint: - return 'fail' + assert lyr_defn.GetGeomFieldCount() == 2 + assert lyr_defn.GetGeomFieldDefn(0).GetName() == 'geometry' + assert lyr_defn.GetGeomFieldDefn(0).GetType() == ogr.wkbMultiPolygon + assert lyr_defn.GetGeomFieldDefn(1).GetName() == 'referencePoint' + assert lyr_defn.GetGeomFieldDefn(1).GetType() == ogr.wkbPoint feat = lyr.GetNextFeature() expected = [('gml_id', 'CadastralZoning-01'), @@ -2625,15 +2336,9 @@ def test_ogr_gml_58(): ('validTo', '2003-01-01T00:00:00.0Z'), ('upperLevelUnit_href', '#ulu.1')] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - return 'fail' - if feat.GetGeomFieldRef(1).ExportToWkt() != 'POINT (2.5 49.5)': - return 'fail' + assert feat.GetField(key) == val + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))' + assert feat.GetGeomFieldRef(1).ExportToWkt() == 'POINT (2.5 49.5)' feat = lyr.GetNextFeature() expected = [('gml_id', 'CadastralZoning-02'), @@ -2658,15 +2363,9 @@ def test_ogr_gml_58(): ('validTo', None), ('upperLevelUnit_href', None)] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' - if feat.GetGeomFieldRef(0).ExportToWkt() != 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))': - return 'fail' - if feat.GetGeomFieldRef(1) is not None: - return 'fail' + assert feat.GetField(key) == val + assert feat.GetGeomFieldRef(0).ExportToWkt() == 'MULTIPOLYGON (((2 49,2 50,3 50,3 49)))' + assert feat.GetGeomFieldRef(1) is None feat = None lyr = None ds = None @@ -2705,11 +2404,7 @@ def test_ogr_gml_59(): ('name_others_lang', ['de']), ('name_others', ['Deutsche name'])] for (key, val) in expected: - if feat.GetField(key) != val: - print(key) - print(val) - print(feat.GetField(key)) - return 'fail' + assert feat.GetField(key) == val feat = None lyr = None ds = None @@ -2732,17 +2427,13 @@ def test_ogr_gml_60(): for _ in range(2): ds = ogr.Open('data/wfs_200_multiplelayers.gml') lyr = ds.GetLayerByName('road') - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 feat = lyr.GetNextFeature() - if feat.GetField('gml_id') != 'road.21': - return 'fail' + assert feat.GetField('gml_id') == 'road.21' lyr = ds.GetLayerByName('popplace') - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 feat = lyr.GetNextFeature() - if feat.GetField('gml_id') != 'popplace.BACMK': - return 'fail' + assert feat.GetField('gml_id') == 'popplace.BACMK' ds = None gdal.Unlink('data/wfs_200_multiplelayers.gfs') @@ -2775,9 +2466,7 @@ def test_ogr_gml_61(): ds = ogr.Open('data/gmlsubfeature.gml') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('did not get expected geometry column name') - return 'fail' + assert lyr.GetFeatureCount() == 2, 'did not get expected geometry column name' feat = lyr.GetNextFeature() if feat.GetField('gml_id') != 'Object.1' or feat.GetField('foo') != 'bar': @@ -2816,8 +2505,7 @@ def test_ogr_gml_62(): # Default behaviour ds = ogr.Open('tmp/gmlattributes.gml') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 1 ds = None # Test GML_ATTRIBUTES_TO_OGR_FIELDS=YES @@ -2831,9 +2519,7 @@ def test_ogr_gml_62(): if i == 0: gdal.SetConfigOption('GML_ATTRIBUTES_TO_OGR_FIELDS', None) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 4: - print(i) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 4, i feat = lyr.GetNextFeature() if feat.GetField('element_attr1') != '1' or \ feat.GetField('element2_attr1') != 'a' or \ @@ -2877,17 +2563,14 @@ def test_ogr_gml_63(): # check number of layers nlayers = ds.GetLayerCount() - if nlayers != 14: - return 'fail' + assert nlayers == 14 # check name of first layer lyr = ds.GetLayer(0) - if lyr.GetName() != 'Staty': - return 'fail' + assert lyr.GetName() == 'Staty' # check geometry column name - if lyr.GetGeometryColumn() != 'DefinicniBod': - return 'fail' + assert lyr.GetGeometryColumn() == 'DefinicniBod' ds = None @@ -2896,16 +2579,14 @@ def test_ogr_gml_63(): # check number of layers nlayers = ds.GetLayerCount() - if nlayers != 11: - return 'fail' + assert nlayers == 11 # check number of features nfeatures = 0 for i in range(nlayers): lyr = ds.GetLayer(i) nfeatures += lyr.GetFeatureCount() - if nfeatures != 7: - return 'fail' + assert nfeatures == 7 return 'success' @@ -2925,9 +2606,7 @@ def test_ogr_gml_64(): gdal.SetConfigOption('GML_PARSER', None) lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat is None: - print(parser) - return 'fail' + assert feat is not None, parser return 'success' @@ -2958,8 +2637,7 @@ def test_ogr_gml_65(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find(expected) < 0: - return 'fail' + assert data.find(expected) >= 0 ds = ogr.Open(filename) lyr = ds.GetLayer(0) @@ -3118,8 +2796,7 @@ def test_ogr_gml_66(): ds = ogr.Open(filename) lyr = ds.GetLayerByName('compoundcurve') - if lyr.GetGeomType() != ogr.wkbCompoundCurve: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbCompoundCurve feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,2 0))': feat.DumpReadable() @@ -3134,8 +2811,7 @@ def test_ogr_gml_66(): return 'fail' lyr = ds.GetLayerByName('curvepolygon') - if lyr.GetGeomType() != ogr.wkbCurvePolygon: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbCurvePolygon feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'CURVEPOLYGON (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0))': feat.DumpReadable() @@ -3146,8 +2822,7 @@ def test_ogr_gml_66(): return 'fail' lyr = ds.GetLayerByName('multisurface') - if lyr.GetGeomType() != ogr.wkbMultiSurface: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiSurface feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTISURFACE (CURVEPOLYGON (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0)))': feat.DumpReadable() @@ -3158,8 +2833,7 @@ def test_ogr_gml_66(): return 'fail' lyr = ds.GetLayerByName('multicurve') - if lyr.GetGeomType() != ogr.wkbMultiCurve: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiCurve feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTICURVE (CIRCULARSTRING (0 0,0.5 0.5,1 0,0.5 -0.5,0 0))': feat.DumpReadable() @@ -3170,33 +2844,28 @@ def test_ogr_gml_66(): return 'fail' lyr = ds.GetLayerByName('polygon') - if lyr.GetGeomType() != ogr.wkbPolygon: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('linestring') - if lyr.GetGeomType() != ogr.wkbLineString: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbLineString feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (0 0,0 1,1 1,0 0)': feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multipolygon') - if lyr.GetGeomType() != ogr.wkbMultiPolygon: - print(lyr.GetGeomType()) - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiPolygon feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOLYGON (((0 0,0 1,1 1,0 0)))': feat.DumpReadable() return 'fail' lyr = ds.GetLayerByName('multilinestring') - if lyr.GetGeomType() != ogr.wkbMultiLineString: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiLineString feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTILINESTRING ((0 0,0 1,1 1,0 0))': feat.DumpReadable() @@ -3204,9 +2873,7 @@ def test_ogr_gml_66(): lyr = ds.GetLayerByName('compoundcurve_untyped') if i != 0: - if lyr.GetGeomType() != ogr.wkbCompoundCurve: - print(lyr.GetGeomType()) - return 'fail' + assert lyr.GetGeomType() == ogr.wkbCompoundCurve feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'COMPOUNDCURVE ((0 0,1 1,2 0))': feat.DumpReadable() @@ -3223,8 +2890,7 @@ def test_ogr_gml_66(): lyr = ds.GetLayerByName('curvepolygon_untyped') if i != 0: - if lyr.GetGeomType() != ogr.wkbCurvePolygon: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbCurvePolygon feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'CURVEPOLYGON ((0 0,0 1,1 1,0 0))': feat.DumpReadable() @@ -3241,8 +2907,7 @@ def test_ogr_gml_66(): lyr = ds.GetLayerByName('multisurface_untyped') if i != 0: - if lyr.GetGeomType() != ogr.wkbMultiSurface: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiSurface feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTISURFACE (((0 0,0 1,1 1,0 0)))': feat.DumpReadable() @@ -3259,8 +2924,7 @@ def test_ogr_gml_66(): lyr = ds.GetLayerByName('multicurve_untyped') if i != 0: - if lyr.GetGeomType() != ogr.wkbMultiCurve: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiCurve feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'MULTICURVE ((0 0,0 1,1 1,0 0))': feat.DumpReadable() @@ -3339,30 +3003,24 @@ def test_ogr_gml_67(): ds = ogr.Open(filename) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('b1')).GetType() != ogr.OFTInteger or \ - lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('b1')).GetSubType() != ogr.OFSTBoolean: - print(i) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('bool_list')).GetType() != ogr.OFTIntegerList or \ - lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('bool_list')).GetSubType() != ogr.OFSTBoolean: - print(i) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('b1')).GetType() == ogr.OFTInteger and \ + lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('b1')).GetSubType() == ogr.OFSTBoolean), \ + i + assert (lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('bool_list')).GetType() == ogr.OFTIntegerList and \ + lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('bool_list')).GetSubType() == ogr.OFSTBoolean), \ + i if i == 0: - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('short')).GetType() != ogr.OFTInteger or \ - lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('short')).GetSubType() != ogr.OFSTInt16: - print(i) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('short')).GetType() == ogr.OFTInteger and \ + lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('short')).GetSubType() == ogr.OFSTInt16), \ + i if i == 0: - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetType() != ogr.OFTReal or \ - lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetSubType() != ogr.OFSTFloat32: - print(i) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('int64')).GetType() != ogr.OFTInteger64: - print(i) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('int64list')).GetType() != ogr.OFTInteger64List: - print(i) - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetType() == ogr.OFTReal and \ + lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('float')).GetSubType() == ogr.OFSTFloat32), \ + i + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('int64')).GetType() == ogr.OFTInteger64, \ + i + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('int64list')).GetType() == ogr.OFTInteger64List, \ + i f = lyr.GetNextFeature() if f.GetField('b1') != 1 or f.GetField('b2') != 0 or f.GetFieldAsString('bool_list') != '(2:1,0)' or f.GetField('short') != -32768 or f.GetField('float') != 1.23: print(i) @@ -3397,17 +3055,13 @@ def test_ogr_gml_68(): 'MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)),((10 0,10 1,11 1,11 0,10 0)))'] lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbMultiPolygon: - gdaltest.post_reason(' did not get expected layer geometry type') - return 'fail' + assert lyr.GetGeomType() == ogr.wkbMultiPolygon, \ + ' did not get expected layer geometry type' for i in range(2): feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != expected_results[i]: - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == expected_results[i], 'did not get expected geometry' ds = None @@ -3446,8 +3100,7 @@ def test_ogr_gml_69(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None # Error case: missing non-nullable field @@ -3456,22 +3109,17 @@ def test_ogr_gml_69(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None ds = None ds = gdal.OpenEx('/vsimem/ogr_gml_69.gml', open_options=['EMPTY_AS_NULL=NO']) lyr = ds.GetLayerByName('test') - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() != 0: - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_nullable')).IsNullable() != 1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() == 0 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() == 1 + assert lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() == 0 + assert lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_nullable')).IsNullable() == 1 ds = None gdal.Unlink("/vsimem/ogr_gml_69.gml") @@ -3522,13 +3170,9 @@ def test_ogr_gml_70(): def ogr_gml_71_helper(ds): - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1 lyr = ds.GetLayer(0) - if lyr.GetName() != 'join_table1_table2': - print(lyr.GetName()) - return 'fail' + assert lyr.GetName() == 'join_table1_table2' fields = [('table1.gml_id', ogr.OFTString), ('table1.foo', ogr.OFTInteger), ('table1.bar', ogr.OFTInteger), @@ -3536,28 +3180,14 @@ def ogr_gml_71_helper(ds): ('table2.bar', ogr.OFTInteger), ('table2.baz', ogr.OFTString)] layer_defn = lyr.GetLayerDefn() - if layer_defn.GetFieldCount() != len(fields): - print(layer_defn.GetFieldCount()) - return 'fail' + assert layer_defn.GetFieldCount() == len(fields) for i, field in enumerate(fields): fld_defn = layer_defn.GetFieldDefn(i) - if fld_defn.GetName() != field[0]: - print(i) - print(fld_defn.GetName()) - return 'fail' - if fld_defn.GetType() != field[1]: - print(i) - print(fld_defn.GetType()) - return 'fail' - if layer_defn.GetGeomFieldCount() != 2: - print(layer_defn.GetGeomFieldCount()) - return 'fail' - if layer_defn.GetGeomFieldDefn(0).GetName() != 'table1.geometry': - print(layer_defn.GetGeomFieldDefn(0).GetName()) - return 'fail' - if layer_defn.GetGeomFieldDefn(1).GetName() != 'table2.geometry': - print(layer_defn.GetGeomFieldDefn(1).GetName()) - return 'fail' + assert fld_defn.GetName() == field[0], i + assert fld_defn.GetType() == field[1], i + assert layer_defn.GetGeomFieldCount() == 2 + assert layer_defn.GetGeomFieldDefn(0).GetName() == 'table1.geometry' + assert layer_defn.GetGeomFieldDefn(1).GetName() == 'table2.geometry' f = lyr.GetNextFeature() if f.GetField('table1.gml_id') != 'table1-1' or \ f.GetField('table1.foo') != 1 or \ @@ -3644,9 +3274,7 @@ def test_ogr_gml_72(): ds = None ds = ogr.Open('/vsimem/ogr_gml_72.gml') - if ds.GetMetadata() != {'NAME': 'name', 'DESCRIPTION': 'description'}: - print(ds.GetMetadata()) - return 'fail' + assert ds.GetMetadata() == {'NAME': 'name', 'DESCRIPTION': 'description'} ds = None gdal.Unlink("/vsimem/ogr_gml_72.gml") @@ -3658,9 +3286,7 @@ def test_ogr_gml_72(): ds = None ds = ogr.Open('/vsimem/ogr_gml_72.gml') - if ds.GetMetadata() != {'NAME': 'name', 'DESCRIPTION': 'description'}: - print(ds.GetMetadata()) - return 'fail' + assert ds.GetMetadata() == {'NAME': 'name', 'DESCRIPTION': 'description'} ds = None gdal.Unlink("/vsimem/ogr_gml_72.gml") @@ -3688,18 +3314,13 @@ def test_ogr_gml_73(): lyr = ds.GetLayer(i) sr = lyr.GetSpatialRef() got_wkt = sr.ExportToWkt() - if got_wkt.find('4326') < 0: - gdaltest.post_reason('did not get expected SRS') - print(got_wkt) - return 'fail' + assert got_wkt.find('4326') >= 0, 'did not get expected SRS' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() got_wkt = geom.ExportToWkt() - if got_wkt != 'POLYGON ((-180 -90,-180 90,180 90,180 -90,-180 -90))': - gdaltest.post_reason('did not get expected geometry') - print(got_wkt) - return 'fail' + assert got_wkt == 'POLYGON ((-180 -90,-180 90,180 90,180 -90,-180 -90))', \ + 'did not get expected geometry' ds = None @@ -3722,13 +3343,8 @@ def test_ogr_gml_74(): # With .xsd ds = gdal.OpenEx('data/expected_gml_gml32.gml', open_options=['FORCE_SRS_DETECTION=YES']) lyr = ds.GetLayer(0) - if lyr.GetSpatialRef() is None: - gdaltest.post_reason('did not get expected SRS') - return 'fail' - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('did not get expected feature count') - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetSpatialRef() is not None, 'did not get expected SRS' + assert lyr.GetFeatureCount() == 2, 'did not get expected feature count' shutil.copy('data/expected_gml_gml32.gml', 'tmp/ogr_gml_74.gml') if os.path.exists('tmp/ogr_gml_74.gfs'): @@ -3737,24 +3353,14 @@ def test_ogr_gml_74(): # Without .xsd or .gfs ds = gdal.OpenEx('tmp/ogr_gml_74.gml', open_options=['FORCE_SRS_DETECTION=YES']) lyr = ds.GetLayer(0) - if lyr.GetSpatialRef() is None: - gdaltest.post_reason('did not get expected SRS') - return 'fail' - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('did not get expected feature count') - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetSpatialRef() is not None, 'did not get expected SRS' + assert lyr.GetFeatureCount() == 2, 'did not get expected feature count' # With .gfs ds = gdal.OpenEx('tmp/ogr_gml_74.gml', open_options=['FORCE_SRS_DETECTION=YES']) lyr = ds.GetLayer(0) - if lyr.GetSpatialRef() is None: - gdaltest.post_reason('did not get expected SRS') - return 'fail' - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('did not get expected feature count') - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetSpatialRef() is not None, 'did not get expected SRS' + assert lyr.GetFeatureCount() == 2, 'did not get expected feature count' ds = None os.unlink('tmp/ogr_gml_74.gml') @@ -3799,8 +3405,7 @@ def test_ogr_gml_75(): """) ds = ogr.Open('/vsimem/ogr_gml_75.xml') - if ds is not None: - return 'fail' + assert ds is None gdal.Unlink('/vsimem/ogr_gml_75.xml') return 'success' @@ -3856,25 +3461,21 @@ def test_ogr_gml_77(): ds = ogr.Open('/vsimem/ogr_gml_77.xml') lyr = ds.GetLayer(0) - if lyr.GetSpatialRef().ExportToWkt().find('AXIS') >= 0: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('AXIS') < 0 f = lyr.GetNextFeature() - if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (2 49)' ds = None ds = gdal.OpenEx('/vsimem/ogr_gml_77.xml', open_options=['SWAP_COORDINATES=YES']) lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (2 49)' ds = None ds = gdal.OpenEx('/vsimem/ogr_gml_77.xml', open_options=['SWAP_COORDINATES=NO']) lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f.GetGeometryRef().ExportToWkt() != 'POINT (49 2)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (49 2)' ds = None gdal.Unlink('/vsimem/ogr_gml_77.xml') @@ -3908,25 +3509,21 @@ def test_ogr_gml_78(): ds = ogr.Open('/vsimem/ogr_gml_78.xml') lyr = ds.GetLayer(0) - if lyr.GetSpatialRef().ExportToWkt().find('AXIS') >= 0: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('AXIS') < 0 f = lyr.GetNextFeature() - if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (2 49)' ds = None ds = gdal.OpenEx('/vsimem/ogr_gml_78.xml', open_options=['SWAP_COORDINATES=YES']) lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f.GetGeometryRef().ExportToWkt() != 'POINT (49 2)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (49 2)' ds = None ds = gdal.OpenEx('/vsimem/ogr_gml_78.xml', open_options=['SWAP_COORDINATES=NO']) lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - return 'fail' + assert f.GetGeometryRef().ExportToWkt() == 'POINT (2 49)' ds = None gdal.Unlink('/vsimem/ogr_gml_78.xml') @@ -3963,10 +3560,8 @@ def test_ogr_gml_79(): data = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) - if data.find(expected_srsname) < 0 or data.find(expected_coords) < 0: - print(srsname_format) - print(data) - return 'fail' + assert data.find(expected_srsname) >= 0 and data.find(expected_coords) >= 0, \ + srsname_format gdal.Unlink('/vsimem/ogr_gml_79.xml') gdal.Unlink('/vsimem/ogr_gml_79.xsd') @@ -4061,28 +3656,21 @@ def test_ogr_gml_82(): ds = ogr.Open('/vsimem/ogr_gml_82.gml') lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 10: - return 'fail' + assert lyr.GetFeatureCount() == 10 ds = None f = gdal.VSIFOpenL("/vsimem/ogr_gml_82.gml", "rb") if f is not None: data = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) - if data.find('gml:FeatureCollection') < 0: - print(data) - return 'fail' + assert data.find('gml:FeatureCollection') >= 0 f = gdal.VSIFOpenL("/vsimem/ogr_gml_82.xsd", "rb") if f is not None: data = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) - if data.find('name = "FeatureCollection"') >= 0: - print(data) - return 'fail' - if data.find('gmlsf') >= 0: - print(data) - return 'fail' + assert data.find('name = "FeatureCollection"') < 0 + assert data.find('gmlsf') < 0 gdal.Unlink('/vsimem/ogr_gml_82.gml') gdal.Unlink('/vsimem/ogr_gml_82.xsd') diff --git a/autotest/ogr/ogr_gmlas.py b/autotest/ogr/ogr_gmlas.py index 4e7ff84e1df7..8a7d2aa63914 100755 --- a/autotest/ogr/ogr_gmlas.py +++ b/autotest/ogr/ogr_gmlas.py @@ -98,8 +98,7 @@ def test_ogr_gmlas_basic(): gdal.SetConfigOption('GDAL_XML_VALIDATION', 'NO') ds = ogr.Open('GMLAS:data/gmlas/gmlas_test1.xml') - if ds is None: - return 'fail' + assert ds is not None ds = None # Skip tests when -fsanitize is used @@ -131,9 +130,7 @@ def test_ogr_gmlas_test_ogrsf(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro GMLAS:data/gmlas/gmlas_test1.xml') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -160,8 +157,7 @@ def test_ogr_gmlas_virtual_file(): """) ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_8.xml') - if ds is None: - return 'fail' + assert ds is not None gdal.Unlink('/vsimem/ogr_gmlas_8.xml') gdal.Unlink('/vsimem/ogr_gmlas_8.xsd') @@ -178,8 +174,7 @@ def test_ogr_gmlas_datafile_with_xsd_option(): return 'skip' ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['XSD=data/gmlas/gmlas_test1.xsd']) - if ds is None: - return 'fail' + assert ds is not None return 'success' @@ -193,8 +188,7 @@ def test_ogr_gmlas_no_datafile_with_xsd_option(): return 'skip' ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xsd']) - if ds is None: - return 'fail' + assert ds is not None return 'success' @@ -209,11 +203,8 @@ def test_ogr_gmlas_no_datafile_xsd_which_is_not_xsd(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xml']) - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find("invalid content in 'schema' element") < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find("invalid content in 'schema' element") >= 0 return 'success' @@ -228,11 +219,8 @@ def test_ogr_gmlas_no_datafile_no_xsd(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:') - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('XSD open option must be provided when no XML data file is passed') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('XSD open option must be provided when no XML data file is passed') >= 0 return 'success' @@ -247,11 +235,8 @@ def test_ogr_gmlas_non_existing_gml(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:/vsimem/i_do_not_exist.gml') - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Cannot open /vsimem/i_do_not_exist.gml') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('Cannot open /vsimem/i_do_not_exist.gml') >= 0 return 'success' @@ -266,11 +251,8 @@ def test_ogr_gmlas_non_existing_xsd(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=/vsimem/i_do_not_exist.xsd']) - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('Cannot resolve /vsimem/i_do_not_exist.xsd') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('Cannot resolve /vsimem/i_do_not_exist.xsd') >= 0 return 'success' @@ -288,11 +270,8 @@ def test_ogr_gmlas_gml_without_schema_location(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_gml_without_schema_location.xml') - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('No schema locations found when analyzing data file: XSD open option must be provided') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('No schema locations found when analyzing data file: XSD open option must be provided') >= 0 gdal.Unlink('/vsimem/ogr_gmlas_gml_without_schema_location.xml') @@ -309,11 +288,8 @@ def test_ogr_gmlas_invalid_schema(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_invalid_schema.xml') - if ds is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('invalid content') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None + assert gdal.GetLastErrorMsg().find('invalid content') >= 0 return 'success' @@ -330,11 +306,8 @@ def test_ogr_gmlas_invalid_xml(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): f = lyr.GetNextFeature() - if f is not None: - return 'fail' - if gdal.GetLastErrorMsg().find('input ended before all started tags were ended') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert f is None + assert gdal.GetLastErrorMsg().find('input ended before all started tags were ended') >= 0 return 'success' @@ -348,9 +321,7 @@ def test_ogr_gmlas_gml_Reference(): return 'skip' ds = ogr.Open('GMLAS:data/gmlas/gmlas_test_targetelement.xml') - if ds.GetLayerCount() != 3: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 3 lyr = ds.GetLayerByName('main_elt') with gdaltest.error_handler(): @@ -377,27 +348,20 @@ def test_ogr_gmlas_same_element_in_different_ns(): return 'skip' ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_same_element_in_different_ns.xml') - if ds is None: - return 'fail' + assert ds is not None # for i in range(ds.GetLayerCount()): # print(ds.GetLayer(i).GetName()) - if ds.GetLayerCount() != 5: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 5 lyr = ds.GetLayerByName('elt') f = lyr.GetNextFeature() if f.IsFieldSet('abstractElt_other_ns_realizationOfAbstractElt_pkid') == 0: f.DumpReadable() return 'fail' - if ds.GetLayerByName('myns_realizationOfAbstractElt') is None: - return 'fail' - if ds.GetLayerByName('other_ns_realizationOfAbstractElt') is None: - return 'fail' - if ds.GetLayerByName('elt_elt2_abstractElt_myns_realizationOfAbstractElt') is None: - return 'fail' - if ds.GetLayerByName('elt_elt2_abstractElt_other_ns_realizationOfAbstractElt') is None: - return 'fail' + assert ds.GetLayerByName('myns_realizationOfAbstractElt') is not None + assert ds.GetLayerByName('other_ns_realizationOfAbstractElt') is not None + assert ds.GetLayerByName('elt_elt2_abstractElt_myns_realizationOfAbstractElt') is not None + assert ds.GetLayerByName('elt_elt2_abstractElt_other_ns_realizationOfAbstractElt') is not None return 'success' @@ -411,8 +375,7 @@ def test_ogr_gmlas_corner_case_relative_path(): return 'skip' ds = ogr.Open('GMLAS:../ogr/data/gmlas/gmlas_test1.xml') - if ds is None: - return 'fail' + assert ds is not None return 'success' @@ -432,12 +395,9 @@ def test_ogr_gmlas_unexpected_repeated_element(): if f is None or f['foo'] != 'foo_again': # somewhat arbitrary to keep the latest one! f.DumpReadable() return 'fail' - if gdal.GetLastErrorMsg().find('Unexpected element myns:main_elt/myns:foo') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('Unexpected element myns:main_elt/myns:foo') >= 0 f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None ds = None return 'success' @@ -458,12 +418,9 @@ def test_ogr_gmlas_unexpected_repeated_element_variant(): if f is None or f['foo'] != 'foo_again': # somewhat arbitrary to keep the latest one! f.DumpReadable() return 'fail' - if gdal.GetLastErrorMsg().find('Unexpected element myns:main_elt/myns:foo') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('Unexpected element myns:main_elt/myns:foo') >= 0 f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None ds = None return 'success' @@ -482,9 +439,7 @@ def test_ogr_gmlas_geometryproperty(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): geom_field_count = lyr.GetLayerDefn().GetGeomFieldCount() - if geom_field_count != 15: - print(geom_field_count) - return 'fail' + assert geom_field_count == 15 f = lyr.GetNextFeature() if f['geometryProperty_xml'] != ' 49 2 ': f.DumpReadable() @@ -504,9 +459,7 @@ def test_ogr_gmlas_geometryproperty(): return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryProperty') sr = lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetSpatialRef() - if sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0: - print(sr) - return 'fail' + assert not (sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0) wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() # Axis swapping if wkt != 'POINT (2 49)': @@ -518,29 +471,21 @@ def test_ogr_gmlas_geometryproperty(): return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('pointProperty') sr = lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetSpatialRef() - if sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0: - print(sr) - return 'fail' + assert not (sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0) wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'POINT (3 50)': f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('lineStringProperty') sr = lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetSpatialRef() - if sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0: - print(sr) - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType() != ogr.wkbLineString: - print(lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType()) - return 'fail' + assert not (sr is None or sr.ExportToWkt().find('4326') < 0 or sr.ExportToWkt().find('AXIS') >= 0) + assert lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType() == ogr.wkbLineString wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'LINESTRING (2 49)': f.DumpReadable() return 'fail' geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('pointPropertyRepeated') - if lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType() != ogr.wkbUnknown: - print(lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType()) - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldDefn(geom_idx).GetType() == ogr.wkbUnknown wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() if wkt != 'GEOMETRYCOLLECTION (POINT (0 1),POINT (1 2),POINT (3 4))': f.DumpReadable() @@ -619,9 +564,7 @@ def test_ogr_gmlas_abstractgeometry(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_abstractgeometry_gml32.gml', open_options=[ 'CONFIG_FILE=true']) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetGeomFieldCount() != 2: - print(lyr.GetLayerDefn().GetGeomFieldCount()) - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldCount() == 2 f = lyr.GetNextFeature() if f['AbstractGeometry_xml'] != '0 1': f.DumpReadable() @@ -663,8 +606,7 @@ def test_ogr_gmlas_validate(): # By default check we are silent about validation error ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml') - if ds is None: - return 'fail' + assert ds is not None myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) gdal.SetConfigOption('GMLAS_WARN_UNEXPECTED', None) @@ -672,34 +614,25 @@ def test_ogr_gmlas_validate(): lyr.GetFeatureCount() gdal.SetConfigOption('GMLAS_WARN_UNEXPECTED', 'YES') gdal.PopErrorHandler() - if myhandler.error_list: - print(myhandler.error_list) - return 'fail' + assert not myhandler.error_list ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml') - if ds is None: - return 'fail' + assert ds is not None myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) lyr = ds.GetLayer(0) lyr.GetFeatureCount() gdal.PopErrorHandler() # Unexpected element with xpath=myns:main_elt/myns:bar (subxpath=myns:main_elt/myns:bar) found - if len(myhandler.error_list) < 2: - print(myhandler.error_list) - return 'fail' + assert len(myhandler.error_list) >= 2 # Enable validation on a doc without validation errors myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['VALIDATE=YES']) gdal.PopErrorHandler() - if ds is None: - print(myhandler.error_list) - return 'fail' - if myhandler.error_list: - print(myhandler.error_list) - return 'fail' + assert ds is not None, myhandler.error_list + assert not myhandler.error_list # Enable validation on a doc without validation error, and with explicit XSD gdal.FileFromMemBuffer('/vsimem/gmlas_test1.xml', @@ -710,48 +643,32 @@ def test_ogr_gmlas_validate(): 'XSD=' + os.getcwd() + '/data/gmlas/gmlas_test1.xsd', 'VALIDATE=YES']) gdal.PopErrorHandler() gdal.Unlink('/vsimem/gmlas_test1.xml') - if ds is None: - print(myhandler.error_list) - return 'fail' - if myhandler.error_list: - print(myhandler.error_list) - return 'fail' + assert ds is not None, myhandler.error_list + assert not myhandler.error_list # Validation errors, but do not prevent dataset opening myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml', open_options=['VALIDATE=YES']) gdal.PopErrorHandler() - if ds is None: - return 'fail' - if len(myhandler.error_list) != 5: - print(myhandler.error_list) - print(len(myhandler.error_list)) - return 'fail' + assert ds is not None + assert len(myhandler.error_list) == 5 # Validation errors and do prevent dataset opening myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml', open_options=['VALIDATE=YES', 'FAIL_IF_VALIDATION_ERROR=YES']) gdal.PopErrorHandler() - if ds is not None: - return 'fail' - if len(myhandler.error_list) != 6: - print(myhandler.error_list) - print(len(myhandler.error_list)) - return 'fail' + assert ds is None + assert len(myhandler.error_list) == 6 # Test that validation without doc doesn't crash myhandler = MyHandler() gdal.PushErrorHandler(myhandler.error_handler) ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xsd', 'VALIDATE=YES']) gdal.PopErrorHandler() - if ds is None: - print(myhandler.error_list) - return 'fail' - if myhandler.error_list: - print(myhandler.error_list) - return 'fail' + assert ds is not None, myhandler.error_list + assert not myhandler.error_list return 'success' @@ -805,16 +722,14 @@ def test_ogr_gmlas_conf(): # Non existing file with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['CONFIG_FILE=not_existing']) - if ds is not None: - return 'fail' + assert ds is None # Broken conf file gdal.FileFromMemBuffer('/vsimem/my_conf.xml', "") with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['CONFIG_FILE=/vsimem/my_conf.xml']) gdal.Unlink('/vsimem/my_conf.xml') - if ds is not None: - return 'fail' + assert ds is None # Valid XML, but not validating gdal.FileFromMemBuffer('/vsimem/my_conf.xml', "") @@ -825,17 +740,14 @@ def test_ogr_gmlas_conf(): # Inlined conf file + UseArrays = false ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=[ 'CONFIG_FILE=false']) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('main_elt_string_array') - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 # AlwaysGenerateOGRId = true ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=[ 'CONFIG_FILE=true']) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('main_elt') f = lyr.GetNextFeature() if f['ogr_pkid'].find('main_elt_1') < 0 or \ @@ -846,12 +758,10 @@ def test_ogr_gmlas_conf(): # IncludeGeometryXML = false ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_geometryproperty_gml32.gml', open_options=[ 'CONFIG_FILE=false']) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) with gdaltest.error_handler(): - if lyr.GetLayerDefn().GetFieldIndex('geometryProperty_xml') >= 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('geometryProperty_xml') < 0 f = lyr.GetNextFeature() geom_idx = lyr.GetLayerDefn().GetGeomFieldIndex('geometryProperty') wkt = f.GetGeomFieldRef(geom_idx).ExportToWkt() @@ -862,28 +772,20 @@ def test_ogr_gmlas_conf(): # ExposeMetadataLayers = true ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_abstractgeometry_gml32.gml', open_options=[ 'CONFIG_FILE=true']) - if ds is None: - return 'fail' - if ds.GetLayerCount() != 5: - print(ds.GetLayerCount()) - return 'fail' + assert ds is not None + assert ds.GetLayerCount() == 5 # Test override with open option ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_abstractgeometry_gml32.gml', open_options=[ 'EXPOSE_METADATA_LAYERS=NO', 'CONFIG_FILE=true']) - if ds is None: - return 'fail' - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds is not None + assert ds.GetLayerCount() == 1 # Turn on validation and error on validation with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_validate.xml', open_options=[ 'CONFIG_FILE=true']) - if ds is not None or gdal.GetLastErrorMsg().find('Validation') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None and gdal.GetLastErrorMsg().find('Validation') >= 0 return 'success' @@ -917,10 +819,7 @@ def test_ogr_gmlas_conf_ignored_xpath(): %s """ % xpath]) - if gdal.GetLastErrorMsg().find('XPath syntax') < 0: - print(xpath) - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('XPath syntax') >= 0, xpath # Test duplicating mapping with gdaltest.error_handler(): @@ -934,9 +833,7 @@ def test_ogr_gmlas_conf_ignored_xpath(): """]) - if gdal.GetLastErrorMsg().find('Prefix ns was already mapped') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('Prefix ns was already mapped') >= 0 # Test XPath with implicit namespace, and warning ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=[ @@ -946,16 +843,12 @@ def test_ogr_gmlas_conf_ignored_xpath(): @otherns:id """]) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('main_elt') - if lyr.GetLayerDefn().GetFieldIndex('otherns_id') >= 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('otherns_id') < 0 with gdaltest.error_handler(): lyr.GetNextFeature() - if gdal.GetLastErrorMsg().find('Attribute with xpath=myns:main_elt/@otherns:id found in document but ignored') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('Attribute with xpath=myns:main_elt/@otherns:id found in document but ignored') >= 0 # Test XPath with explicit namespace, and warning suppression ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=[ @@ -967,13 +860,10 @@ def test_ogr_gmlas_conf_ignored_xpath(): @other_ns:id """]) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('main_elt') lyr.GetNextFeature() - if gdal.GetLastErrorMsg() != '': - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg() == '' # Test various XPath syntaxes ds = gdal.OpenEx('GMLAS:', open_options=[ @@ -993,27 +883,19 @@ def test_ogr_gmlas_conf_ignored_xpath(): foo/myns:long """]) - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayerByName('main_elt') # Ignored fields - if lyr.GetLayerDefn().GetFieldIndex('optionalStrAttr') >= 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldIndex('fixedValUnset') >= 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldIndex('base_int') >= 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldIndex('string') >= 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldIndex('string_array') >= 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('optionalStrAttr') < 0 + assert lyr.GetLayerDefn().GetFieldIndex('fixedValUnset') < 0 + assert lyr.GetLayerDefn().GetFieldIndex('base_int') < 0 + assert lyr.GetLayerDefn().GetFieldIndex('string') < 0 + assert lyr.GetLayerDefn().GetFieldIndex('string_array') < 0 # Present fields - if lyr.GetLayerDefn().GetFieldIndex('int_array') < 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldIndex('long') < 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('int_array') >= 0 + assert lyr.GetLayerDefn().GetFieldIndex('long') >= 0 return 'success' @@ -1106,9 +988,7 @@ def test_ogr_gmlas_cache(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=false/vsimem/my/gmlas_cache']) - if ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None and gdal.GetLastErrorMsg().find('Cannot resolve') >= 0 # Test invalid cache directory with gdaltest.error_handler(): @@ -1161,10 +1041,8 @@ def test_ogr_gmlas_cache(): # Now re-open with the webserver turned off ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/vsimem/my/gmlas_cache']) - if ds is None: - return 'fail' - if ds.GetLayerCount() != 1: - return 'fail' + assert ds is not None + assert ds.GetLayerCount() == 1 # Re try but ask for refresh with gdaltest.error_handler(): @@ -1182,9 +1060,7 @@ def test_ogr_gmlas_cache(): with gdaltest.error_handler(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_cache.xml', open_options=[ 'CONFIG_FILE=/vsimem/my/gmlas_cache']) - if ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ds is None and gdal.GetLastErrorMsg().find('Cannot resolve') >= 0 # Cleanup gdal.Unlink('/vsimem/ogr_gmlas_cache.xml') @@ -1262,8 +1138,7 @@ def test_ogr_gmlas_instantiate_only_gml_feature(): ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_instantiate_only_gml_feature.xsd']) - if ds.GetLayerCount() != 1: - return 'fail' + assert ds.GetLayerCount() == 1 ds = None return 'success' @@ -1303,32 +1178,25 @@ def test_ogr_gmlas_dataset_getnextfeature(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml') - if ds.TestCapability(ogr.ODsCRandomLayerRead) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCRandomLayerRead) == 1 count = 0 last_l = None while True: f, lyr = ds.GetNextFeature() if f is None: - if lyr is not None: - return 'fail' + assert lyr is None break count += 1 last_l = lyr base_count = 59 - if count != base_count: - print(count) - return 'fail' + assert count == base_count - if last_l.GetName() != 'main_elt': - print(last_l.GetName()) - return 'fail' + assert last_l.GetName() == 'main_elt' f, lyr = ds.GetNextFeature() - if f is not None or lyr is not None: - return 'fail' + assert f is None and lyr is None ds.ResetReading() last_pct = 0 @@ -1336,12 +1204,9 @@ def test_ogr_gmlas_dataset_getnextfeature(): f, l, pct = ds.GetNextFeature(include_pct=True) last_pct = pct if f is None: - if l is not None: - return 'fail' + assert l is None break - if last_pct != 1.0: - print(last_pct - 1.0) - return 'fail' + assert last_pct == 1.0 ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_test1.xml', open_options=['EXPOSE_METADATA_LAYERS=YES']) fc_map = {} @@ -1357,8 +1222,7 @@ def test_ogr_gmlas_dataset_getnextfeature(): while True: f, lyr = ds.GetNextFeature() if f is None: - if lyr is not None: - return 'fail' + assert lyr is None break count += 1 @@ -1367,13 +1231,10 @@ def test_ogr_gmlas_dataset_getnextfeature(): expected_count += fc_map['_ogr_layers_metadata'] expected_count += fc_map['_ogr_layer_relationships'] expected_count += fc_map['_ogr_other_metadata'] - if count != expected_count: - print(count) - return 'fail' + assert count == expected_count f, lyr = ds.GetNextFeature() - if f is not None or lyr is not None: - return 'fail' + assert f is None and lyr is None ds.ResetReading() @@ -1381,15 +1242,11 @@ def test_ogr_gmlas_dataset_getnextfeature(): while True: f, lyr = ds.GetNextFeature() if f is None: - if lyr is not None: - return 'fail' + assert lyr is None break count += 1 - if count != expected_count: - print(count) - print(expected_count) - return 'fail' + assert count == expected_count for layers in [['_ogr_fields_metadata'], ['_ogr_layers_metadata'], @@ -1409,19 +1266,14 @@ def test_ogr_gmlas_dataset_getnextfeature(): while True: f, lyr = ds.GetNextFeature() if f is None: - if lyr is not None: - return 'fail' + assert lyr is None break count += 1 - if count != expected_count: - print(count) - print(expected_count) - return 'fail' + assert count == expected_count f, lyr = ds.GetNextFeature() - if f is not None or lyr is not None: - return 'fail' + assert f is None and lyr is None # Test iterating over metadata layers on XSD-only based dataset ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_test1.xsd', 'EXPOSE_METADATA_LAYERS=YES']) @@ -1430,15 +1282,12 @@ def test_ogr_gmlas_dataset_getnextfeature(): while True: f, lyr = ds.GetNextFeature() if f is None: - if lyr is not None: - return 'fail' + assert lyr is None break count += 1 last_l = lyr - if count == 0: - print(count) - return 'fail' + assert count != 0 return 'success' @@ -1459,8 +1308,7 @@ def test_ogr_gmlas_inline_identifier(): print(ds.GetLayer(i).GetName()) return 'fail' lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldIndex('identifier_foo') < 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('identifier_foo') >= 0 return 'success' @@ -1474,15 +1322,11 @@ def test_ogr_gmlas_avoid_same_name_inlined_classes(): return 'skip' ds = gdal.OpenEx('GMLAS:', open_options=['XSD=data/gmlas/gmlas_avoid_same_name_inlined_classes.xsd']) - if ds.GetLayerCount() != 3: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 3 lyr = ds.GetLayerByName('myFeature_ns1_dt') - if lyr is None: - return 'fail' + assert lyr is not None lyr = ds.GetLayerByName('myFeature_ns2_dt') - if lyr is None: - return 'fail' + assert lyr is not None return 'success' @@ -1501,9 +1345,7 @@ def test_ogr_gmlas_validate_ignored_fixed_attribute(): open_options=['VALIDATE=YES', 'CONFIG_FILE=@bar']) gdal.PopErrorHandler() - if myhandler.error_list: - print(myhandler.error_list) - return 'fail' + assert not myhandler.error_list return 'success' @@ -1519,16 +1361,14 @@ def test_ogr_gmlas_remove_unused_layers_and_fields(): ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_remove_unused_layers_and_fields.xml', open_options=['REMOVE_UNUSED_LAYERS=YES', 'REMOVE_UNUSED_FIELDS=YES']) - if ds.GetLayerCount() != 1: - return 'fail' + assert ds.GetLayerCount() == 1 lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if lyr.GetLayerDefn().GetFieldCount() != 4: print(lyr.GetLayerDefn().GetFieldCount()) f.DumpReadable() return 'fail' - if f['used1'] != 'foo' or f['used2'] != 'bar' or f['nillable_nilReason'] != 'unknown': - return 'fail' + assert f['used1'] == 'foo' and f['used2'] == 'bar' and f['nillable_nilReason'] == 'unknown' lyr = ds.GetLayerByName('_ogr_layers_metadata') if lyr.GetFeatureCount() != 1: @@ -2105,49 +1945,27 @@ def test_ogr_gmlas_identifier_truncation(): 'XSD=data/gmlas/gmlas_identifier_truncation.xsd', 'CONFIG_FILE=10false']) lyr = ds.GetLayerByName('v_l_i_clas') - if lyr is None: - print(ds.GetLayer(0).GetName()) - return 'fail' + assert lyr is not None, ds.GetLayer(0).GetName() s = lyr.GetLayerDefn().GetFieldDefn(1).GetName() - if s != 'v_l_idTifi': - print(s) - return 'fail' + assert s == 'v_l_idTifi' s = lyr.GetLayerDefn().GetFieldDefn(2).GetName() - if s != 'an_lo_ide1': - print(s) - return 'fail' + assert s == 'an_lo_ide1' s = lyr.GetLayerDefn().GetFieldDefn(3).GetName() - if s != 'an_lo_ide2': - print(s) - return 'fail' + assert s == 'an_lo_ide2' s = lyr.GetLayerDefn().GetFieldDefn(4).GetName() - if s != 'x': - print(s) - return 'fail' + assert s == 'x' s = lyr.GetLayerDefn().GetFieldDefn(5).GetName() - if s != 'noTCAMELCa': - print(s) - return 'fail' + assert s == 'noTCAMELCa' s = lyr.GetLayerDefn().GetFieldDefn(6).GetName() - if s != 'suuuuuuuuu': - print(s) - return 'fail' + assert s == 'suuuuuuuuu' s = lyr.GetLayerDefn().GetFieldDefn(7).GetName() - if s != '_r_l_o_n_g': - print(s) - return 'fail' + assert s == '_r_l_o_n_g' lyr = ds.GetLayerByName('a_l_i_cla1') - if lyr is None: - print(ds.GetLayer(1).GetName()) - return 'fail' + assert lyr is not None, ds.GetLayer(1).GetName() lyr = ds.GetLayerByName('a_l_i_cla2') - if lyr is None: - print(ds.GetLayer(2).GetName()) - return 'fail' + assert lyr is not None, ds.GetLayer(2).GetName() lyr = ds.GetLayerByName('y') - if lyr is None: - print(ds.GetLayer(3).GetName()) - return 'fail' + assert lyr is not None, ds.GetLayer(3).GetName() ds = None return 'success' @@ -2165,21 +1983,13 @@ def test_ogr_gmlas_identifier_case_ambiguity(): 'XSD=data/gmlas/gmlas_identifier_case_ambiguity.xsd', 'CONFIG_FILE=false']) lyr = ds.GetLayerByName('differentcase1') - if lyr is None: - print(ds.GetLayer(0).GetName()) - return 'fail' + assert lyr is not None, ds.GetLayer(0).GetName() s = lyr.GetLayerDefn().GetFieldDefn(1).GetName() - if s != 'differentcase1': - print(s) - return 'fail' + assert s == 'differentcase1' s = lyr.GetLayerDefn().GetFieldDefn(2).GetName() - if s != 'DifferentCASE2': - print(s) - return 'fail' + assert s == 'DifferentCASE2' lyr = ds.GetLayerByName('DifferentCASE2') - if lyr is None: - print(ds.GetLayer(0).GetName()) - return 'fail' + assert lyr is not None, ds.GetLayer(0).GetName() ds = None return 'success' @@ -2205,8 +2015,7 @@ def test_ogr_gmlas_writer(): tmp_ds = None gdal.Unlink('/vsimem/ogr_gmlas_writer.db') - if ret_ds is None: - return 'fail' + assert ret_ds is not None return 'success' @@ -2227,9 +2036,7 @@ def test_ogr_gmlas_writer_check_xml_xsd(): pos = got.find('http://myns ') + len('http://myns ') pos_end = got.find('"', pos) absolute_xsd = got[pos:pos_end] - if not absolute_xsd.endswith('gmlas_test1.xsd') or not os.path.exists(absolute_xsd): - print(absolute_xsd) - return 'fail' + assert absolute_xsd.endswith('gmlas_test1.xsd') and os.path.exists(absolute_xsd) got = got.replace(absolute_xsd, 'gmlas_test1.xsd') expected = open('data/gmlas/gmlas_test1_generated.xml', 'rt').read() @@ -2249,9 +2056,7 @@ def test_ogr_gmlas_writer_check_xml_xsd(): pos = got.find('schemaLocation="') + len('schemaLocation="') pos_end = got.find('"', pos) absolute_xsd = got[pos:pos_end] - if not absolute_xsd.endswith('gmlas_test1.xsd') or not os.path.exists(absolute_xsd): - print(absolute_xsd) - return 'fail' + assert absolute_xsd.endswith('gmlas_test1.xsd') and os.path.exists(absolute_xsd) got = got.replace(absolute_xsd, 'gmlas_test1.xsd') expected = open('data/gmlas/gmlas_test1_generated.xsd', 'rt').read() @@ -2357,37 +2162,25 @@ def test_ogr_gmlas_writer_gml(): 'LAYERS={SPATIAL_LAYERS}']) tmp_ds = None - if ret_ds is None: - return 'fail' + assert ret_ds is not None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_gml.xml', 'rb') - if f is None: - return 'fail' + assert f is not None content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xml') gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xsd') - if content.find('xmlns:gml="http://fake_gml32"') < 0: - print(content) - return 'fail' + assert content.find('xmlns:gml="http://fake_gml32"') >= 0 - if content.find('49 2') < 0: - print(content) - return 'fail' + assert content.find('49 2') >= 0 - if content.find('50 3') < 0: - print(content) - return 'fail' + assert content.find('50 3') >= 0 - if content.find(' 0 1') < 0: - print(content) - return 'fail' + assert content.find(' 0 1') >= 0 - if content.find(' 1 2') < 0: - print(content) - return 'fail' + assert content.find(' 1 2') >= 0 return 'success' @@ -2411,21 +2204,17 @@ def test_ogr_gmlas_writer_gml_assign_srs(): reproject=False) tmp_ds = None - if ret_ds is None: - return 'fail' + assert ret_ds is not None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_gml.xml', 'rb') - if f is None: - return 'fail' + assert f is not None content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xml') gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xsd') - if content.find('http://www.opengis.net/def/crs/EPSG/0/32631') < 0: - print(content) - return 'fail' + assert content.find('http://www.opengis.net/def/crs/EPSG/0/32631') >= 0 # No geometry, but to test that the proxied ExecuteSQL() works @@ -2445,10 +2234,7 @@ def test_ogr_gmlas_writer_gml_assign_srs(): tmp_ds = None gdal.Unlink('/vsimem/ogr_gmlas_writer.db') - if gdal.VSIStatL('/vsimem/gmlas_test1_generated_ref0.xml').size != gdal.VSIStatL('/vsimem/gmlas_test1_generated_asrs.xml').size: - print(gdal.VSIStatL('/vsimem/gmlas_test1_generated_ref0.xml').size) - print(gdal.VSIStatL('/vsimem/gmlas_test1_generated_asrs.xml').size) - return 'fail' + assert gdal.VSIStatL('/vsimem/gmlas_test1_generated_ref0.xml').size == gdal.VSIStatL('/vsimem/gmlas_test1_generated_asrs.xml').size gdal.Unlink('/vsimem/gmlas_test1_generated_ref0.xml') gdal.Unlink('/vsimem/gmlas_test1_generated_ref0.xsd') @@ -2475,35 +2261,26 @@ def test_ogr_gmlas_writer_gml_original_xml(): datasetCreationOptions=['WRAPPING=GMLAS_FEATURECOLLECTION']) tmp_ds = None - if ret_ds is None: - return 'fail' + assert ret_ds is not None ret_ds = None ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_writer_gml.xml', open_options=['VALIDATE=YES']) - if ds is None or gdal.GetLastErrorMsg() != '': - return 'fail' + assert ds is not None and gdal.GetLastErrorMsg() == '' ds = None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_gml.xml', 'rb') - if f is None: - return 'fail' + assert f is not None content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xml') gdal.Unlink('/vsimem/ogr_gmlas_writer_gml.xsd') - if content.find(' 49 2 ') < 0: - print(content) - return 'fail' + assert content.find(' 49 2 ') >= 0 - if content.find(' 0 1') < 0: - print(content) - return 'fail' + assert content.find(' 0 1') >= 0 - if content.find(' 1 2') < 0: - print(content) - return 'fail' + assert content.find(' 1 2') >= 0 return 'success' @@ -2529,41 +2306,30 @@ def test_ogr_gmlas_writer_options(): 'OUTPUT_XSD_FILENAME=/vsimem/my_schema.xsd']) tmp_ds = None - if ret_ds is None: - return 'fail' + assert ret_ds is not None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_options.xml', 'rb') - if f is None: - return 'fail' + assert f is not None content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/ogr_gmlas_writer_options.xml') - if gdal.VSIStatL('/vsimem/my_schema.xsd') is None: - return 'fail' + assert gdal.VSIStatL('/vsimem/my_schema.xsd') is not None gdal.Unlink('/vsimem/my_schema.xsd') # Test indentation size - if content.find('\n ') < 0: - print(content) - return 'fail' + assert content.find('\n ') >= 0 # Test comment - if content.find('\n') < 0: - print(content) - return 'fail' + assert content.find('\n') >= 0 # Test OUTPUT_XSD_FILENAME - if content.find('/vsimem/my_schema.xsd') < 0: - print(content) - return 'fail' + assert content.find('/vsimem/my_schema.xsd') >= 0 # Test SRSNAME_FORMAT=OGC_URN - if content.find('49 2') < 0: - print(content) - return 'fail' + assert content.find('49 2') >= 0 # Test TIMESTAMP option src_ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_geometryproperty_gml32_no_error.gml', @@ -2574,24 +2340,19 @@ def test_ogr_gmlas_writer_options(): datasetCreationOptions=['TIMESTAMP=1970-01-01T12:34:56Z', '@REOPEN_DATASET_WITH_GMLAS=NO']) tmp_ds = None - if ret_ds is None: - return 'fail' + assert ret_ds is not None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_options.xml', 'rb') - if f is None: - return 'fail' + assert f is not None content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/ogr_gmlas_writer_options.xml') - if gdal.VSIStatL('/vsimem/my_schema.xsd') is not None: - return 'fail' + assert gdal.VSIStatL('/vsimem/my_schema.xsd') is None - if content.find('timeStamp="1970-01-01T12:34:56Z"') < 0 or \ - content.find('xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd ') < 0: - print(content) - return 'fail' + assert (content.find('timeStamp="1970-01-01T12:34:56Z"') >= 0 and \ + content.find('xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd ') >= 0) # Test WFS20_SCHEMALOCATION option src_ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_geometryproperty_gml32_no_error.gml', @@ -2602,8 +2363,7 @@ def test_ogr_gmlas_writer_options(): datasetCreationOptions=['WFS20_SCHEMALOCATION=/vsimem/fake_wfs.xsd']) tmp_ds = None - if ret_ds is None: - return 'fail' + assert ret_ds is not None gdal.FileFromMemBuffer('/vsimem/fake_wfs.xsd', """ @@ -2626,24 +2386,19 @@ def test_ogr_gmlas_writer_options(): ds = gdal.OpenEx('GMLAS:/vsimem/ogr_gmlas_writer_options.xml', open_options=['VALIDATE=YES']) gdal.Unlink('/vsimem/fake_wfs.xsd') - if ds is None or gdal.GetLastErrorMsg() != '': - return 'fail' + assert ds is not None and gdal.GetLastErrorMsg() == '' ds = None f = gdal.VSIFOpenL('/vsimem/ogr_gmlas_writer_options.xml', 'rb') - if f is None: - return 'fail' + assert f is not None content = gdal.VSIFReadL(1, 10000, f).decode('utf-8') gdal.VSIFCloseL(f) gdal.Unlink('/vsimem/ogr_gmlas_writer_options.xml') - if gdal.VSIStatL('/vsimem/my_schema.xsd') is not None: - return 'fail' + assert gdal.VSIStatL('/vsimem/my_schema.xsd') is None - if content.find('xsi:schemaLocation="http://www.opengis.net/wfs/2.0 /vsimem/fake_wfs.xsd ') < 0: - print(content) - return 'fail' + assert content.find('xsi:schemaLocation="http://www.opengis.net/wfs/2.0 /vsimem/fake_wfs.xsd ') >= 0 return 'success' @@ -2659,9 +2414,7 @@ def test_ogr_gmlas_writer_errors(): # Source dataset is empty with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', gdal.GetDriverByName('Memory').Create('', 0, 0, 0, 0), format='GMLAS') - if ret_ds is not None or gdal.GetLastErrorMsg().find('Source dataset has no layers') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Source dataset has no layers') >= 0 # Missing input schemas src_ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_geometryproperty_gml32_no_error.gml') @@ -2669,17 +2422,13 @@ def test_ogr_gmlas_writer_errors(): src_ds = None with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS') - if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot establish schema since no INPUT_XSD creation option specified and no _ogr_other_metadata found in source dataset') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Cannot establish schema since no INPUT_XSD creation option specified and no _ogr_other_metadata found in source dataset') >= 0 # Invalid input schema with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['INPUT_XSD=/i_do_not/exist.xsd']) - if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot resolve /i_do_not/exist.xsd') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Cannot resolve /i_do_not/exist.xsd') >= 0 # Invalid output .xml name src_ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_geometryproperty_gml32_no_error.gml', @@ -2689,43 +2438,33 @@ def test_ogr_gmlas_writer_errors(): with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/i_am/not/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['GENERATE_XSD=NO']) - if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot create /i_am/not/valid.xml') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Cannot create /i_am/not/valid.xml') >= 0 # .xsd extension not allowed with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/i_am/not/valid.xsd', tmp_ds, format='GMLAS', datasetCreationOptions=['GENERATE_XSD=NO']) - if ret_ds is not None or gdal.GetLastErrorMsg().find('.xsd extension is not valid') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('.xsd extension is not valid') >= 0 # Invalid output .xsd name with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['WRAPPING=GMLAS_FEATURECOLLECTION', 'OUTPUT_XSD_FILENAME=/i_am/not/valid.xsd']) - if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot create /i_am/not/valid.xsd') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Cannot create /i_am/not/valid.xsd') >= 0 gdal.Unlink('/vsimem/valid.xml') # Invalid CONFIG_FILE with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['CONFIG_FILE=/i/do_not/exist']) - if ret_ds is not None or gdal.GetLastErrorMsg().find('Loading of configuration failed') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Loading of configuration failed') >= 0 # Invalid layer name with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', tmp_ds, format='GMLAS', datasetCreationOptions=['LAYERS=foo']) - if ret_ds is not None or gdal.GetLastErrorMsg().find('Layer foo specified in LAYERS option does not exist') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Layer foo specified in LAYERS option does not exist') >= 0 gdal.Unlink('/vsimem/valid.xml') # _ogr_layers_metadata not found @@ -2733,9 +2472,7 @@ def test_ogr_gmlas_writer_errors(): src_ds.CreateLayer('_ogr_other_metadata') with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') - if ret_ds is not None or gdal.GetLastErrorMsg().find('_ogr_layers_metadata not found') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('_ogr_layers_metadata not found') >= 0 # _ogr_fields_metadata not found src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0, 0) @@ -2743,9 +2480,7 @@ def test_ogr_gmlas_writer_errors(): src_ds.CreateLayer('_ogr_layers_metadata') with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') - if ret_ds is not None or gdal.GetLastErrorMsg().find('_ogr_fields_metadata not found') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('_ogr_fields_metadata not found') >= 0 # _ogr_layer_relationships not found src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0, 0) @@ -2754,9 +2489,7 @@ def test_ogr_gmlas_writer_errors(): src_ds.CreateLayer('_ogr_fields_metadata') with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') - if ret_ds is not None or gdal.GetLastErrorMsg().find('_ogr_layer_relationships not found') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('_ogr_layer_relationships not found') >= 0 # Cannot find field layer_name in _ogr_layers_metadata layer src_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0, 0) @@ -2766,9 +2499,7 @@ def test_ogr_gmlas_writer_errors(): src_ds.CreateLayer('_ogr_layer_relationships') with gdaltest.error_handler(): ret_ds = gdal.VectorTranslate('/vsimem/valid.xml', src_ds, format='GMLAS') - if ret_ds is not None or gdal.GetLastErrorMsg().find('Cannot find field layer_name in _ogr_layers_metadata layer') < 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert ret_ds is None and gdal.GetLastErrorMsg().find('Cannot find field layer_name in _ogr_layers_metadata layer') >= 0 gdal.Unlink('/vsimem/valid.xml') gdal.Unlink('/vsimem/valid.xsd') @@ -2790,14 +2521,11 @@ def test_ogr_gmlas_read_fake_gmljp2(): while True: f, lyr = ds.GetNextFeature() if f is None: - if lyr is not None: - return 'fail' + assert lyr is None break count += 1 - if count != 5: - print(count) - return 'fail' + assert count == 5 return 'success' @@ -2854,8 +2582,7 @@ def test_ogr_gmlas_typing_constraints(): """]) lyr = ds.GetLayer('main_elt_foo_bar') - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 lyr = ds.GetLayer('bar') f = lyr.GetNextFeature() if f.GetField('value') != 'baz': @@ -2984,15 +2711,12 @@ def test_ogr_gmlas_swe_datarecord(): gdal.ErrorReset() ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_swe_datarecord.xml', open_options=['VALIDATE=YES']) - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' ds = None ds = gdal.OpenEx('GMLAS:data/gmlas/gmlas_swe_datarecord.xml') lyr = ds.GetLayerByName('main_elt_foo') - if lyr.GetLayerDefn().GetFieldCount() != 12: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 12 f = lyr.GetNextFeature() if f.GetField('mytime_value') != '2017/09/01 00:00:00' or \ f.GetField('mycategory_value') != 'myvalue' or \ @@ -3028,8 +2752,7 @@ def test_ogr_gmlas_any_field_at_end_of_declaration(): gdal.ErrorReset() with gdaltest.error_handler(): f = lyr.GetNextFeature() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' if f.GetField('foo') != 'bar': f.DumpReadable() return 'fail' diff --git a/autotest/ogr/ogr_gmt.py b/autotest/ogr/ogr_gmt.py index e996a58398ff..a7967264d11e 100755 --- a/autotest/ogr/ogr_gmt.py +++ b/autotest/ogr/ogr_gmt.py @@ -45,8 +45,7 @@ def test_ogr_gmt_1(): gmt_drv = ogr.GetDriverByName('GMT') gdaltest.gmt_ds = gmt_drv.CreateDataSource('tmp/tpoly.gmt') - if gdaltest.gmt_ds is None: - return 'fail' + assert gdaltest.gmt_ds is not None return 'success' @@ -113,14 +112,12 @@ def test_ogr_gmt_3(): orig_feat = gdaltest.poly_feat[i] read_feat = gdaltest.gmt_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(read_feat, orig_feat.GetGeometryRef(), - max_error=0.000000001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(read_feat, orig_feat.GetGeometryRef(), + max_error=0.000000001) == 0) for fld in range(3): - if orig_feat.GetField(fld) != read_feat.GetField(fld): - gdaltest.post_reason('Attribute %d does not match' % fld) - return 'fail' + assert orig_feat.GetField(fld) == read_feat.GetField(fld), \ + ('Attribute %d does not match' % fld) gdaltest.poly_feat = None gdaltest.shp_ds = None @@ -138,33 +135,24 @@ def test_ogr_gmt_4(): ds = ogr.Open('data/test_multi.gmt') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetGeomType() != ogr.wkbMultiLineString: - gdaltest.post_reason('did not get expected multilinestring type.') - return 'fail' + assert lyr.GetLayerDefn().GetGeomType() == ogr.wkbMultiLineString, \ + 'did not get expected multilinestring type.' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((175 -45,176 -45),(180.0 -45.3,179.0 -45.4))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((175 -45,176 -45),(180.0 -45.3,179.0 -45.4))') - if feat.GetField('name') != 'feature 1': - gdaltest.post_reason('got wrong name, feature 1') - return 'fail' + assert feat.GetField('name') == 'feature 1', 'got wrong name, feature 1' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((175.1 -45.0,175.2 -45.1),(180.1 -45.3,180.0 -45.2))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((175.1 -45.0,175.2 -45.1),(180.1 -45.3,180.0 -45.2))') - if feat.GetField('name') != 'feature 2': - gdaltest.post_reason('got wrong name, feature 2') - return 'fail' + assert feat.GetField('name') == 'feature 2', 'got wrong name, feature 2' feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('did not get null feature when expected.') - return 'fail' + assert feat is None, 'did not get null feature when expected.' return 'success' @@ -210,33 +198,24 @@ def test_ogr_gmt_5(): ds = ogr.Open('tmp/mpoly.gmt') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetGeomType() != ogr.wkbMultiPolygon: - gdaltest.post_reason('did not get expected multipolygon type.') - return 'fail' + assert lyr.GetLayerDefn().GetGeomType() == ogr.wkbMultiPolygon, \ + 'did not get expected multipolygon type.' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON(((0 0,0 10,10 10,0 10,0 0),(3 3,4 4, 3 4,3 3)),((12 0,14 0,12 3,12 0)))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON(((0 0,0 10,10 10,0 10,0 0),(3 3,4 4, 3 4,3 3)),((12 0,14 0,12 3,12 0)))') - if feat.GetField('ID') != 15: - gdaltest.post_reason('got wrong id, first feature') - return 'fail' + assert feat.GetField('ID') == 15, 'got wrong id, first feature' feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON(((30 20,40 20,30 30,30 20)))'): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, 'MULTIPOLYGON(((30 20,40 20,30 30,30 20)))') - if feat.GetField('ID') != 16: - gdaltest.post_reason('got wrong ID, second feature') - return 'fail' + assert feat.GetField('ID') == 16, 'got wrong ID, second feature' feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('did not get null feature when expected.') - return 'fail' + assert feat is None, 'did not get null feature when expected.' return 'success' diff --git a/autotest/ogr/ogr_gpkg.py b/autotest/ogr/ogr_gpkg.py index 96872de1a072..ae24e36a856a 100755 --- a/autotest/ogr/ogr_gpkg.py +++ b/autotest/ogr/ogr_gpkg.py @@ -108,14 +108,11 @@ def test_ogr_gpkg_1(): gdaltest.gpkg_ds = gdaltest.gpkg_dr.CreateDataSource('tmp/gpkg_test.gpkg') - if gdaltest.gpkg_ds is None: - return 'fail' + assert gdaltest.gpkg_ds is not None gdaltest.gpkg_ds = None - if not validate('tmp/gpkg_test.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('tmp/gpkg_test.gpkg'), 'validation failed' return 'success' @@ -133,8 +130,7 @@ def test_ogr_gpkg_2(): # Check there a ogr_empty_table sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT COUNT(*) FROM sqlite_master WHERE name = 'ogr_empty_table'") f = sql_lyr.GetNextFeature() - if f.GetField(0) != 1: - return 'fail' + assert f.GetField(0) == 1 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) # Should default to GPKG 1.2 @@ -168,17 +164,14 @@ def test_ogr_gpkg_3(): srs4326.ImportFromEPSG(4326) lyr = gdaltest.gpkg_ds.CreateLayer('first_layer', geom_type=ogr.wkbPoint, srs=srs4326, options=['GEOMETRY_NAME=gpkg_geometry', 'SPATIAL_INDEX=NO']) # gdal.PopErrorHandler() - if lyr is None: - return 'fail' + assert lyr is not None # Test creating a layer with an existing name gdal.PushErrorHandler('CPLQuietErrorHandler') lyr = gdaltest.gpkg_ds.CreateLayer('a_layer', options=['SPATIAL_INDEX=NO']) lyr = gdaltest.gpkg_ds.CreateLayer('a_layer', options=['SPATIAL_INDEX=NO']) gdal.PopErrorHandler() - if lyr is not None: - gdaltest.post_reason('layer creation should have failed') - return 'fail' + assert lyr is None, 'layer creation should have failed' return 'success' @@ -193,42 +186,32 @@ def test_ogr_gpkg_4(): gdaltest.gpkg_ds = None - if not validate('tmp/gpkg_test.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('tmp/gpkg_test.gpkg'), 'validation failed' gdal.PushErrorHandler('CPLQuietErrorHandler') gdaltest.gpkg_ds = gdaltest.gpkg_dr.Open('tmp/gpkg_test.gpkg', update=1) gdal.PopErrorHandler() - if gdaltest.gpkg_ds is None: - return 'fail' + assert gdaltest.gpkg_ds is not None # Check there no ogr_empty_table sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT COUNT(*) FROM sqlite_master WHERE name = 'ogr_empty_table'") f = sql_lyr.GetNextFeature() - if f.GetField(0) != 0: - return 'fail' + assert f.GetField(0) == 0 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) - if gdaltest.gpkg_ds.GetLayerCount() != 2: - gdaltest.post_reason('unexpected number of layers') - return 'fail' + assert gdaltest.gpkg_ds.GetLayerCount() == 2, 'unexpected number of layers' lyr0 = gdaltest.gpkg_ds.GetLayer(0) - if lyr0.GetFIDColumn() != 'fid': - gdaltest.post_reason('unexpected FID name for layer 0') - return 'fail' + assert lyr0.GetFIDColumn() == 'fid', 'unexpected FID name for layer 0' gdaltest.gpkg_ds = None gdaltest.gpkg_ds = gdaltest.gpkg_dr.Open('tmp/gpkg_test.gpkg', update=1) lyr0 = gdaltest.gpkg_ds.GetLayer(0) - if lyr0.GetName() != 'first_layer': - gdaltest.post_reason('unexpected layer name for layer 0') - return 'fail' + assert lyr0.GetName() == 'first_layer', 'unexpected layer name for layer 0' gdaltest.gpkg_ds = None gdaltest.gpkg_ds = gdaltest.gpkg_dr.Open('tmp/gpkg_test.gpkg', update=1) @@ -236,17 +219,13 @@ def test_ogr_gpkg_4(): lyr0 = gdaltest.gpkg_ds.GetLayer(0) lyr1 = gdaltest.gpkg_ds.GetLayer(1) - if lyr0.GetLayerDefn().GetGeomFieldDefn(0).GetName() != 'gpkg_geometry': - gdaltest.post_reason('unexpected geometry field name for layer 0') - return 'fail' + assert lyr0.GetLayerDefn().GetGeomFieldDefn(0).GetName() == 'gpkg_geometry', \ + 'unexpected geometry field name for layer 0' - if lyr1.GetName() != 'a_layer': - gdaltest.post_reason('unexpected layer name for layer 1') - return 'fail' + assert lyr1.GetName() == 'a_layer', 'unexpected layer name for layer 1' sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_extensions'") - if sql_lyr.GetFeatureCount() != 0: - return 'fail' + assert sql_lyr.GetFeatureCount() == 0 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) return 'success' @@ -260,33 +239,21 @@ def test_ogr_gpkg_5(): if gdaltest.gpkg_dr is None or gdaltest.gpkg_ds is None: return 'skip' - if gdaltest.gpkg_ds.GetLayerCount() != 2: - gdaltest.post_reason('unexpected number of layers') - return 'fail' + assert gdaltest.gpkg_ds.GetLayerCount() == 2, 'unexpected number of layers' with gdaltest.error_handler(): ret = gdaltest.gpkg_ds.DeleteLayer(-1) - if ret == 0: - gdaltest.post_reason('expected error') - return 'fail' + assert ret != 0, 'expected error' with gdaltest.error_handler(): ret = gdaltest.gpkg_ds.DeleteLayer(gdaltest.gpkg_ds.GetLayerCount()) - if ret == 0: - gdaltest.post_reason('expected error') - return 'fail' + assert ret != 0, 'expected error' - if gdaltest.gpkg_ds.DeleteLayer(1) != 0: - gdaltest.post_reason('got error code from DeleteLayer(1)') - return 'fail' + assert gdaltest.gpkg_ds.DeleteLayer(1) == 0, 'got error code from DeleteLayer(1)' - if gdaltest.gpkg_ds.DeleteLayer(0) != 0: - gdaltest.post_reason('got error code from DeleteLayer(0)') - return 'fail' + assert gdaltest.gpkg_ds.DeleteLayer(0) == 0, 'got error code from DeleteLayer(0)' - if gdaltest.gpkg_ds.GetLayerCount() != 0: - gdaltest.post_reason('unexpected number of layers (not 0)') - return 'fail' + assert gdaltest.gpkg_ds.GetLayerCount() == 0, 'unexpected number of layers (not 0)' return 'success' @@ -302,44 +269,33 @@ def test_ogr_gpkg_6(): srs4326 = osr.SpatialReference() srs4326.ImportFromEPSG(4326) lyr = gdaltest.gpkg_ds.CreateLayer('field_test_layer', geom_type=ogr.wkbPoint, srs=srs4326) - if lyr is None: - return 'fail' + assert lyr is not None field_defn = ogr.FieldDefn('dummy', ogr.OFTString) lyr.CreateField(field_defn) - if lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTString: - gdaltest.post_reason('wrong field type') - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetType() == ogr.OFTString, \ + 'wrong field type' gdaltest.gpkg_ds = None - if not validate('tmp/gpkg_test.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('tmp/gpkg_test.gpkg'), 'validation failed' gdal.PushErrorHandler('CPLQuietErrorHandler') gdaltest.gpkg_ds = gdaltest.gpkg_dr.Open('tmp/gpkg_test.gpkg', update=1) gdal.PopErrorHandler() - if gdaltest.gpkg_ds is None: - return 'fail' + assert gdaltest.gpkg_ds is not None - if gdaltest.gpkg_ds.GetLayerCount() != 1: - return 'fail' + assert gdaltest.gpkg_ds.GetLayerCount() == 1 lyr = gdaltest.gpkg_ds.GetLayer(0) - if lyr.GetName() != 'field_test_layer': - return 'fail' + assert lyr.GetName() == 'field_test_layer' field_defn_out = lyr.GetLayerDefn().GetFieldDefn(0) - if field_defn_out.GetType() != ogr.OFTString: - gdaltest.post_reason('wrong field type after reopen') - return 'fail' + assert field_defn_out.GetType() == ogr.OFTString, 'wrong field type after reopen' - if field_defn_out.GetName() != 'dummy': - gdaltest.post_reason('wrong field name after reopen') - return 'fail' + assert field_defn_out.GetName() == 'dummy', 'wrong field name after reopen' return 'success' @@ -358,78 +314,60 @@ def test_ogr_gpkg_7(): feat.SetGeometry(geom) feat.SetField('dummy', 'a dummy value') - if lyr.TestCapability(ogr.OLCSequentialWrite) != 1: - gdaltest.post_reason('lyr.TestCapability(ogr.OLCSequentialWrite) != 1') - return 'fail' + assert lyr.TestCapability(ogr.OLCSequentialWrite) == 1, \ + 'lyr.TestCapability(ogr.OLCSequentialWrite) != 1' - if lyr.CreateFeature(feat) != 0: - gdaltest.post_reason('cannot create feature') - return 'fail' + assert lyr.CreateFeature(feat) == 0, 'cannot create feature' # Read back what we just inserted lyr.ResetReading() feat_read = lyr.GetNextFeature() - if feat_read.GetField('dummy') != 'a dummy value': - gdaltest.post_reason('output does not match input') - return 'fail' + assert feat_read.GetField('dummy') == 'a dummy value', 'output does not match input' # Only inserted one thing, so second feature should return NULL feat_read = lyr.GetNextFeature() - if feat_read is not None: - gdaltest.post_reason('last call should return NULL') - return 'fail' + assert feat_read is None, 'last call should return NULL' # Add another feature geom = ogr.CreateGeometryFromWkt('POINT(100 100)') feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(geom) feat.SetField('dummy', 'who you calling a dummy?') - if lyr.CreateFeature(feat) != 0: - gdaltest.post_reason('cannot create feature') - return 'fail' + assert lyr.CreateFeature(feat) == 0, 'cannot create feature' - if lyr.TestCapability(ogr.OLCRandomRead) != 1: - gdaltest.post_reason('lyr.TestCapability(ogr.OLCRandomRead) != 1') - return 'fail' + assert lyr.TestCapability(ogr.OLCRandomRead) == 1, \ + 'lyr.TestCapability(ogr.OLCRandomRead) != 1' # Random read a feature feat_read_random = lyr.GetFeature(feat.GetFID()) - if feat_read_random.GetField('dummy') != 'who you calling a dummy?': - gdaltest.post_reason('random read output does not match input') - return 'fail' + assert feat_read_random.GetField('dummy') == 'who you calling a dummy?', \ + 'random read output does not match input' - if lyr.TestCapability(ogr.OLCRandomWrite) != 1: - gdaltest.post_reason('lyr.TestCapability(ogr.OLCRandomWrite) != 1') - return 'fail' + assert lyr.TestCapability(ogr.OLCRandomWrite) == 1, \ + 'lyr.TestCapability(ogr.OLCRandomWrite) != 1' # Random write a feature feat.SetField('dummy', 'i am no dummy') lyr.SetFeature(feat) feat_read_random = lyr.GetFeature(feat.GetFID()) - if feat_read_random.GetField('dummy') != 'i am no dummy': - gdaltest.post_reason('random read output does not match random write input') - return 'fail' + assert feat_read_random.GetField('dummy') == 'i am no dummy', \ + 'random read output does not match random write input' - if lyr.TestCapability(ogr.OLCDeleteFeature) != 1: - gdaltest.post_reason('lyr.TestCapability(ogr.OLCDeleteFeature) != 1') - return 'fail' + assert lyr.TestCapability(ogr.OLCDeleteFeature) == 1, \ + 'lyr.TestCapability(ogr.OLCDeleteFeature) != 1' # Delete a feature lyr.DeleteFeature(feat.GetFID()) - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('delete feature did not delete') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'delete feature did not delete' # Test updating non-existing feature feat.SetFID(-10) - if lyr.SetFeature(feat) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('Expected failure of SetFeature().') - return 'fail' + assert lyr.SetFeature(feat) == ogr.OGRERR_NON_EXISTING_FEATURE, \ + 'Expected failure of SetFeature().' # Test deleting non-existing feature - if lyr.DeleteFeature(-10) != ogr.OGRERR_NON_EXISTING_FEATURE: - gdaltest.post_reason('Expected failure of DeleteFeature().') - return 'fail' + assert lyr.DeleteFeature(-10) == ogr.OGRERR_NON_EXISTING_FEATURE, \ + 'Expected failure of DeleteFeature().' # Delete the layer if gdaltest.gpkg_ds.DeleteLayer('field_test_layer') != 0: @@ -458,8 +396,7 @@ def test_ogr_gpkg_8(): srs.ImportFromEPSG(32631) lyr = gdaltest.gpkg_ds.CreateLayer('tbl_linestring', geom_type=ogr.wkbLineString, srs=srs) - if lyr is None: - return 'fail' + assert lyr is not None lyr.StartTransaction() lyr.CreateField(ogr.FieldDefn('fld_integer', ogr.OFTInteger)) @@ -496,30 +433,21 @@ def test_ogr_gpkg_8(): feat.SetField('fld_float', 1.23) feat.SetField('fld_integer64', 1000000000000 + i) - if lyr.CreateFeature(feat) != 0: - gdaltest.post_reason('cannot create feature %d' % i) - return 'fail' + assert lyr.CreateFeature(feat) == 0, ('cannot create feature %d' % i) lyr.CommitTransaction() feat = ogr.Feature(lyr.GetLayerDefn()) - if lyr.CreateFeature(feat) != 0: - gdaltest.post_reason('cannot insert empty') - return 'fail' + assert lyr.CreateFeature(feat) == 0, 'cannot insert empty' feat.SetFID(6) - if lyr.SetFeature(feat) != 0: - gdaltest.post_reason('cannot update with empty') - return 'fail' + assert lyr.SetFeature(feat) == 0, 'cannot update with empty' gdaltest.gpkg_ds = None gdaltest.gpkg_ds = gdaltest.gpkg_dr.Open('tmp/gpkg_test.gpkg', update=1) lyr = gdaltest.gpkg_ds.GetLayerByName('tbl_linestring') - if lyr.GetLayerDefn().GetFieldDefn(6).GetSubType() != ogr.OFSTBoolean: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(7).GetSubType() != ogr.OFSTInt16: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(8).GetSubType() != ogr.OFSTFloat32: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(6).GetSubType() == ogr.OFSTBoolean + assert lyr.GetLayerDefn().GetFieldDefn(7).GetSubType() == ogr.OFSTInt16 + assert lyr.GetLayerDefn().GetFieldDefn(8).GetSubType() == ogr.OFSTFloat32 feat = lyr.GetNextFeature() if feat.GetField(0) != 10 or feat.GetField(1) != 'test string 0 test' or \ feat.GetField(2) != 3.14159 or feat.GetField(3) != '2014/05/17' or \ @@ -530,8 +458,7 @@ def test_ogr_gpkg_8(): return 'fail' lyr = gdaltest.gpkg_ds.CreateLayer('tbl_polygon', geom_type=ogr.wkbPolygon, srs=srs) - if lyr is None: - return 'fail' + assert lyr is not None lyr.StartTransaction() lyr.CreateField(ogr.FieldDefn('fld_datetime', ogr.OFTDateTime)) @@ -546,21 +473,17 @@ def test_ogr_gpkg_8(): feat.SetField('fld_string', 'my super string %d' % i) feat.SetField('fld_datetime', '2010-01-01') - if lyr.CreateFeature(feat) != 0: - gdaltest.post_reason('cannot create polygon feature %d' % i) - return 'fail' + assert lyr.CreateFeature(feat) == 0, ('cannot create polygon feature %d' % i) lyr.CommitTransaction() feat = lyr.GetFeature(3) geom_read = feat.GetGeometryRef() - if geom.ExportToWkt() != geom_read.ExportToWkt(): - gdaltest.post_reason('geom output not equal to geom input') - return 'fail' + assert geom.ExportToWkt() == geom_read.ExportToWkt(), \ + 'geom output not equal to geom input' # Test out the 3D support... lyr = gdaltest.gpkg_ds.CreateLayer('tbl_polygon25d', geom_type=ogr.wkbPolygon25D, srs=srs) - if lyr is None: - return 'fail' + assert lyr is not None lyr.CreateField(ogr.FieldDefn('fld_string', ogr.OFTString)) geom = ogr.CreateGeometryFromWkt('POLYGON((5 5 1, 10 5 2, 10 10 3, 5 104 , 5 5 1),(6 6 4, 6 7 5, 7 7 6, 7 6 7, 6 6 4))') @@ -571,9 +494,8 @@ def test_ogr_gpkg_8(): lyr.ResetReading() feat = lyr.GetNextFeature() geom_read = feat.GetGeometryRef() - if geom.ExportToWkt() != geom_read.ExportToWkt(): - gdaltest.post_reason('3d geom output not equal to geom input') - return 'fail' + assert geom.ExportToWkt() == geom_read.ExportToWkt(), \ + '3d geom output not equal to geom input' return 'success' @@ -588,16 +510,10 @@ def test_ogr_gpkg_9(): lyr = gdaltest.gpkg_ds.GetLayerByName('tbl_linestring') extent = lyr.GetExtent() - if extent != (5.0, 10.0, 5.0, 10.0): - gdaltest.post_reason('got bad extent') - print(extent) - return 'fail' + assert extent == (5.0, 10.0, 5.0, 10.0), 'got bad extent' fcount = lyr.GetFeatureCount() - if fcount != 11: - gdaltest.post_reason('got bad featurecount') - print(fcount) - return 'fail' + assert fcount == 11, 'got bad featurecount' return 'success' @@ -619,11 +535,9 @@ def test_ogr_gpkg_11(): gdaltest.gpkg_ds = ogr.Open('tmp/gpkg_test.gpkg', update=1) lyr = gdaltest.gpkg_ds.GetLayerByName('tbl_linestring_renamed') - if lyr is None: - return 'fail' + assert lyr is not None lyr.SetAttributeFilter('fld_integer = 10') - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 return 'success' @@ -637,27 +551,17 @@ def test_ogr_gpkg_12(): return 'skip' sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT * FROM tbl_linestring_renamed') - if sql_lyr.GetFIDColumn() != 'fid': - return 'fail' - if sql_lyr.GetGeomType() != ogr.wkbLineString: - return 'fail' - if sql_lyr.GetGeometryColumn() != 'geom': - return 'fail' - if sql_lyr.GetSpatialRef().ExportToWkt().find('32631') < 0: - return 'fail' + assert sql_lyr.GetFIDColumn() == 'fid' + assert sql_lyr.GetGeomType() == ogr.wkbLineString + assert sql_lyr.GetGeometryColumn() == 'geom' + assert sql_lyr.GetSpatialRef().ExportToWkt().find('32631') >= 0 feat = sql_lyr.GetNextFeature() - if feat.GetFID() != 1: - return 'fail' - if sql_lyr.GetFeatureCount() != 11: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldCount() != 10: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(6).GetSubType() != ogr.OFSTBoolean: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(7).GetSubType() != ogr.OFSTInt16: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(8).GetSubType() != ogr.OFSTFloat32: - return 'fail' + assert feat.GetFID() == 1 + assert sql_lyr.GetFeatureCount() == 11 + assert sql_lyr.GetLayerDefn().GetFieldCount() == 10 + assert sql_lyr.GetLayerDefn().GetFieldDefn(6).GetSubType() == ogr.OFSTBoolean + assert sql_lyr.GetLayerDefn().GetFieldDefn(7).GetSubType() == ogr.OFSTInt16 + assert sql_lyr.GetLayerDefn().GetFieldDefn(8).GetSubType() == ogr.OFSTFloat32 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) sql_lyr = gdaltest.gpkg_ds.ExecuteSQL( @@ -674,41 +578,24 @@ def test_ogr_gpkg_12(): 'CAST(fld_binary as BLOB) as FLD_BINARY, ' 'CAST(fld_integer64 AS INTEGER) AS FLD_INTEGER64 ' 'FROM tbl_linestring_renamed') - if sql_lyr.GetFIDColumn() != 'FID': - print(sql_lyr.GetFIDColumn()) - return 'fail' - if sql_lyr.GetGeometryColumn() != 'GEOM': - print(sql_lyr.GetGeometryColumn()) - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldCount() != 5: - print(sql_lyr.GetLayerDefn().GetFieldCount()) - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(0).GetName() != 'FLD_INTEGER': - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(0).GetType() != ogr.OFTInteger: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(1).GetName() != 'FLD_STRING': - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(1).GetType() != ogr.OFTString: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(2).GetName() != 'FLD_REAL': - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(2).GetType() != ogr.OFTReal: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(3).GetName() != 'FLD_BINARY': - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(3).GetType() != ogr.OFTBinary: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(4).GetName() != 'FLD_INTEGER64': - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldDefn(4).GetType() != ogr.OFTInteger64: - return 'fail' + assert sql_lyr.GetFIDColumn() == 'FID' + assert sql_lyr.GetGeometryColumn() == 'GEOM' + assert sql_lyr.GetLayerDefn().GetFieldCount() == 5 + assert sql_lyr.GetLayerDefn().GetFieldDefn(0).GetName() == 'FLD_INTEGER' + assert sql_lyr.GetLayerDefn().GetFieldDefn(0).GetType() == ogr.OFTInteger + assert sql_lyr.GetLayerDefn().GetFieldDefn(1).GetName() == 'FLD_STRING' + assert sql_lyr.GetLayerDefn().GetFieldDefn(1).GetType() == ogr.OFTString + assert sql_lyr.GetLayerDefn().GetFieldDefn(2).GetName() == 'FLD_REAL' + assert sql_lyr.GetLayerDefn().GetFieldDefn(2).GetType() == ogr.OFTReal + assert sql_lyr.GetLayerDefn().GetFieldDefn(3).GetName() == 'FLD_BINARY' + assert sql_lyr.GetLayerDefn().GetFieldDefn(3).GetType() == ogr.OFTBinary + assert sql_lyr.GetLayerDefn().GetFieldDefn(4).GetName() == 'FLD_INTEGER64' + assert sql_lyr.GetLayerDefn().GetFieldDefn(4).GetType() == ogr.OFTInteger64 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT * FROM tbl_linestring_renamed WHERE 0=1') feat = sql_lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) for sql in ['SELECT * FROM tbl_linestring_renamed LIMIT 1', @@ -716,23 +603,17 @@ def test_ogr_gpkg_12(): 'SELECT * FROM tbl_linestring_renamed UNION ALL SELECT * FROM tbl_linestring_renamed ORDER BY fld_integer LIMIT 1']: sql_lyr = gdaltest.gpkg_ds.ExecuteSQL(sql) feat = sql_lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None feat = sql_lyr.GetNextFeature() - if feat is not None: - return 'fail' - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert feat is None + assert sql_lyr.GetFeatureCount() == 1 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT sqlite_version()') feat = sql_lyr.GetNextFeature() - if feat is None: - return 'fail' - if sql_lyr.GetLayerDefn().GetFieldCount() != 1: - return 'fail' - if sql_lyr.GetLayerDefn().GetGeomFieldCount() != 0: - return 'fail' + assert feat is not None + assert sql_lyr.GetLayerDefn().GetFieldCount() == 1 + assert sql_lyr.GetLayerDefn().GetGeomFieldCount() == 0 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) return 'success' @@ -770,25 +651,19 @@ def test_ogr_gpkg_13(): gdaltest.gpkg_ds = None gdaltest.gpkg_ds = ogr.Open('tmp/gpkg_test.gpkg', update=1) - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail : warning NOT expected') - return 'fail' - if gdaltest.gpkg_ds.GetLayerCount() != 5: - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'fail : warning NOT expected' + assert gdaltest.gpkg_ds.GetLayerCount() == 5 lyr = gdaltest.gpkg_ds.GetLayer('non_spatial') - if lyr.GetGeomType() != ogr.wkbNone: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbNone feat = lyr.GetNextFeature() - if not feat.IsFieldNull('fld_integer'): - return 'fail' + assert feat.IsFieldNull('fld_integer') feat = lyr.GetNextFeature() if feat.GetField('fld_integer') != 1: feat.DumpReadable() return 'fail' sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name IS NULL AND extension_name = 'gdal_aspatial'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) return 'success' @@ -806,8 +681,7 @@ def test_ogr_gpkg_14(): sr.ImportFromEPSG(32631) lyr = gdaltest.gpkg_ds.CreateLayer('point_no_spi-but-with-dashes', geom_type=ogr.wkbPoint, options=['SPATIAL_INDEX=NO'], srs=sr) - if lyr.TestCapability(ogr.OLCFastSpatialFilter) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastSpatialFilter) == 0 feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1000 30000000)')) lyr.CreateFeature(feat) @@ -841,12 +715,10 @@ def test_ogr_gpkg_14(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT * FROM "point_no_spi-but-with-dashes"') res = sql_lyr.TestCapability(ogr.OLCFastSpatialFilter) gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) - if res != 0: - return 'fail' + assert res == 0 lyr = gdaltest.gpkg_ds.CreateLayer('point-with-spi-and-dashes', geom_type=ogr.wkbPoint) - if lyr.TestCapability(ogr.OLCFastSpatialFilter) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastSpatialFilter) == 1 feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1000 30000000)')) lyr.CreateFeature(feat) @@ -870,18 +742,15 @@ def test_ogr_gpkg_14(): sql_lyr = gdaltest.gpkg_ds.ExecuteSQL('SELECT * FROM "point-with-spi-and-dashes"') res = sql_lyr.TestCapability(ogr.OLCFastSpatialFilter) gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) - if res != 1: - return 'fail' + assert res == 1 # Test spatial filer right away lyr.SetSpatialFilterRect(1000, 30000000, 1000, 30000000) lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None return 'success' @@ -927,9 +796,8 @@ def test_ogr_gpkg_15(): feat = sql_lyr.GetNextFeature() got_result = feat.GetField(0) gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) - if got_result != expected_result: - print("expected_type=%s actual_type=%s expected_result=%d got_result=%d" % (expected_type, actual_type, expected_result, got_result)) - return 'fail' + assert got_result == expected_result, \ + ("expected_type=%s actual_type=%s expected_result=%d got_result=%d" % (expected_type, actual_type, expected_result, got_result)) for (sql, expected_result) in [ ("SELECT HasSpatialIndex('point-with-spi-and-dashes', 'geom')", 1), @@ -964,9 +832,7 @@ def test_ogr_gpkg_15(): feat = sql_lyr.GetNextFeature() got_result = feat.GetField(0) gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) - if got_result != expected_result: - print(sql) - return 'fail' + assert got_result == expected_result, sql # NULL argument sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("SELECT SridFromAuthCRS(NULL, 4326)") @@ -1244,12 +1110,8 @@ def test_ogr_gpkg_15(): if has_spatialite_4_3_or_later: sql_lyr = gdaltest.gpkg_ds.ExecuteSQL( "SELECT ST_Buffer(geom, 0) FROM tbl_linestring_renamed") - if sql_lyr.GetGeomType() != ogr.wkbPolygon: - print(sql_lyr.GetGeomType()) - return 'fail' - if sql_lyr.GetSpatialRef().ExportToWkt().find('32631') < 0: - print(sql_lyr.GetSpatialRef()) - return 'fail' + assert sql_lyr.GetGeomType() == ogr.wkbPolygon + assert sql_lyr.GetSpatialRef().ExportToWkt().find('32631') >= 0 gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) gdaltest.gpkg_ds = None @@ -1277,9 +1139,7 @@ def test_ogr_gpkg_16(): lyr = ds.GetLayer(0) lyr.GetLayerDefn() ds = None - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail : warning NOT expected') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'fail : warning NOT expected' # Warning since we open as read-write ds = ogr.Open('/vsimem/ogr_gpk_16.gpkg', update=1) @@ -1287,9 +1147,7 @@ def test_ogr_gpkg_16(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' ds.ExecuteSQL("UPDATE gpkg_extensions SET scope = 'read-write' WHERE extension_name = 'myext'") ds = None @@ -1300,9 +1158,7 @@ def test_ogr_gpkg_16(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' # and also as read-write ds = ogr.Open('/vsimem/ogr_gpk_16.gpkg', update=1) @@ -1310,9 +1166,7 @@ def test_ogr_gpkg_16(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' ds = None gdal.Unlink('/vsimem/ogr_gpk_16.gpkg') @@ -1329,9 +1183,7 @@ def test_ogr_gpkg_16(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn() gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' gdal.Unlink('/vsimem/ogr_gpk_16.gpkg') @@ -1346,17 +1198,13 @@ def test_ogr_gpkg_16(): ds = ogr.Open('/vsimem/ogr_gpk_16.gpkg') lyr = ds.GetLayer(0) lyr.GetLayerDefn() - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail : warning NOT expected') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'fail : warning NOT expected' # Warning since we open as read-write gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogr.Open('/vsimem/ogr_gpk_16.gpkg', update=1) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' ds.ExecuteSQL("UPDATE gpkg_extensions SET scope = 'read-write' WHERE extension_name = 'myext'") ds = None @@ -1365,17 +1213,13 @@ def test_ogr_gpkg_16(): gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogr.Open('/vsimem/ogr_gpk_16.gpkg') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' # and also as read-write gdal.PushErrorHandler('CPLQuietErrorHandler') ds = ogr.Open('/vsimem/ogr_gpk_16.gpkg', update=1) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('fail : warning expected') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'fail : warning expected' ds = None gdal.Unlink('/vsimem/ogr_gpk_16.gpkg') @@ -1394,8 +1238,7 @@ def test_ogr_gpkg_17(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_17.gpkg') sql_lyr = ds.ExecuteSQL("SELECT ogr_version()", dialect='INDIRECT_SQLITE') f = sql_lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None ds.ReleaseResultSet(sql_lyr) ds = None @@ -1419,26 +1262,19 @@ def test_ogr_gpkg_18(): f = None ds = None - if not validate('/vsimem/ogr_gpkg_18.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_18.gpkg'), 'validation failed' ds = ogr.Open('/vsimem/ogr_gpkg_18.gpkg') - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail : warning NOT expected') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'fail : warning NOT expected' lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbCircularString: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbCircularString f = lyr.GetNextFeature() g = f.GetGeometryRef() - if g.GetGeometryType() != ogr.wkbCircularString: - return 'fail' + assert g.GetGeometryType() == ogr.wkbCircularString sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'wkbCircularString' AND extension_name = 'gpkg_geom_CIRCULARSTRING'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 ds.ReleaseResultSet(sql_lyr) ds = None @@ -1453,22 +1289,18 @@ def test_ogr_gpkg_18(): f = None sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'test' AND extension_name = 'gpkg_geom_CIRCULARSTRING'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 ds.ReleaseResultSet(sql_lyr) ds = None ds = ogr.Open('/vsimem/ogr_gpkg_18.gpkg') - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('fail : warning NOT expected') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'fail : warning NOT expected' lyr = ds.GetLayer(0) f = lyr.GetNextFeature() g = f.GetGeometryRef() - if g.GetGeometryType() != ogr.wkbCircularString: - return 'fail' + assert g.GetGeometryType() == ogr.wkbCircularString ds = None @@ -1477,8 +1309,7 @@ def test_ogr_gpkg_18(): f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometry(ogr.CreateGeometryFromWkt('CIRCULARSTRING(0 0,1 0,0 0)')) ret = lyr.CreateFeature(f) - if ret != 0 or gdal.GetLastErrorMsg() != '': - return 'fail' + assert ret == 0 and gdal.GetLastErrorMsg() == '' f = None ds = None @@ -1488,15 +1319,12 @@ def test_ogr_gpkg_18(): # Warning 1: Registering non-standard gpkg_geom_TRIANGLE extension ds.FlushCache() sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'test' AND extension_name = 'gpkg_geom_TRIANGLE'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 ds.ReleaseResultSet(sql_lyr) ds = None ret = validate('/vsimem/ogr_gpkg_18.gpkg', quiet=True) - if ret: - gdaltest.post_reason('validation unexpectedly succeeded') - return 'fail' + assert not ret, 'validation unexpectedly succeeded' # Test non-linear geometry in GeometryCollection ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_18.gpkg') @@ -1506,8 +1334,7 @@ def test_ogr_gpkg_18(): lyr.CreateFeature(f) f = None sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions WHERE table_name = 'test' AND extension_name LIKE 'gpkg_geom_%'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 ds.ReleaseResultSet(sql_lyr) ds = None @@ -1525,11 +1352,9 @@ def test_ogr_gpkg_19(): return 'skip' ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_19.gpkg') - if ds.GetMetadata(): - return 'fail' + assert not ds.GetMetadata() lyr = ds.CreateLayer('test_without_md') - if lyr.GetMetadata(): - return 'fail' + assert not lyr.GetMetadata() ds.SetMetadataItem('foo', 'bar') @@ -1542,19 +1367,13 @@ def test_ogr_gpkg_19(): ds = None ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') - if ds.GetMetadataDomainList() != ['']: - print(ds.GetMetadataDomainList()) - return 'fail' + assert ds.GetMetadataDomainList() == [''] ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') - if len(ds.GetMetadata()) != 1: - print(ds.GetMetadata()) - return 'fail' + assert len(ds.GetMetadata()) == 1 ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') - if ds.GetMetadataItem('foo') != 'bar': - print(ds.GetMetadata()) - return 'fail' + assert ds.GetMetadataItem('foo') == 'bar', ds.GetMetadata() ds = None ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) @@ -1566,18 +1385,12 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg') lyr = ds.GetLayer('test_with_md') - if lyr.GetMetadataItem('IDENTIFIER') != 'ident': - print(lyr.GetMetadataItem('IDENTIFIER')) - return 'fail' - if lyr.GetMetadataItem('DESCRIPTION') != 'desc': - print(lyr.GetMetadataItem('DESCRIPTION')) - return 'fail' + assert lyr.GetMetadataItem('IDENTIFIER') == 'ident' + assert lyr.GetMetadataItem('DESCRIPTION') == 'desc' ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') - if lyr.GetMetadata() != {'IDENTIFIER': 'ident', 'DESCRIPTION': 'desc'}: - print(lyr.GetMetadata()) - return 'fail' + assert lyr.GetMetadata() == {'IDENTIFIER': 'ident', 'DESCRIPTION': 'desc'} lyr.SetMetadataItem('IDENTIFIER', 'another_ident') lyr.SetMetadataItem('DESCRIPTION', 'another_desc') ds = None @@ -1587,45 +1400,31 @@ def test_ogr_gpkg_19(): ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') - if lyr.GetMetadata() != {'IDENTIFIER': 'another_ident', 'DESCRIPTION': 'another_desc'}: - print(lyr.GetMetadata()) - return 'fail' + assert lyr.GetMetadata() == {'IDENTIFIER': 'another_ident', 'DESCRIPTION': 'another_desc'} lyr.SetMetadataItem('foo', 'bar') lyr.SetMetadataItem('bar', 'baz', 'another_domain') ds = None ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') - if lyr.GetMetadataDomainList() != ['', 'another_domain']: - print(lyr.GetMetadataDomainList()) - return 'fail' + assert lyr.GetMetadataDomainList() == ['', 'another_domain'] ds = None ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') - if lyr.GetMetadata() != {'IDENTIFIER': 'another_ident', 'foo': 'bar', 'DESCRIPTION': 'another_desc'}: - print(lyr.GetMetadata()) - return 'fail' - if lyr.GetMetadata('another_domain') != {'bar': 'baz'}: - print(lyr.GetMetadata('another_domain')) - return 'fail' + assert lyr.GetMetadata() == {'IDENTIFIER': 'another_ident', 'foo': 'bar', 'DESCRIPTION': 'another_desc'} + assert lyr.GetMetadata('another_domain') == {'bar': 'baz'} lyr.SetMetadata(None) lyr.SetMetadata(None, 'another_domain') ds = None ds = ogr.Open('/vsimem/ogr_gpkg_19.gpkg', update=1) lyr = ds.GetLayer('test_with_md') - if lyr.GetMetadata() != {'IDENTIFIER': 'another_ident', 'DESCRIPTION': 'another_desc'}: - print(lyr.GetMetadata()) - return 'fail' - if lyr.GetMetadataDomainList() != ['']: - print(lyr.GetMetadataDomainList()) - return 'fail' + assert lyr.GetMetadata() == {'IDENTIFIER': 'another_ident', 'DESCRIPTION': 'another_desc'} + assert lyr.GetMetadataDomainList() == [''] ds = None - if not validate('/vsimem/ogr_gpkg_19.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_19.gpkg'), 'validation failed' gdal.Unlink('/vsimem/ogr_gpkg_19.gpkg') gdal.Unlink('/vsimem/ogr_gpkg_19.gpkg.aux.xml') @@ -1665,30 +1464,20 @@ def test_ogr_gpkg_20(): sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_spatial_ref_sys WHERE srs_name='my geogcs' AND srs_id = 100000 AND organization='MY_ORG' AND organization_coordsys_id=4326 AND description is NULL") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 1: - print(fc) - return 'fail' + assert fc == 1 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_spatial_ref_sys WHERE srs_name='another geogcs' AND srs_id = 100001 AND organization='NONE' AND organization_coordsys_id=100001 AND description is NULL") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 1: - print(fc) - return 'fail' + assert fc == 1 lyr = ds.GetLayer('my_org_4326') - if lyr.GetSpatialRef().ExportToWkt().find('my geogcs') < 0: - print(lyr.GetSpatialRef().ExportToWkt()) - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('my geogcs') >= 0 lyr = ds.GetLayer('without_org') - if lyr.GetSpatialRef().ExportToWkt().find('another geogcs') < 0: - print(lyr.GetSpatialRef().ExportToWkt()) - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('another geogcs') >= 0 ds = None - if not validate('/vsimem/ogr_gpkg_20.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_20.gpkg'), 'validation failed' gdal.Unlink('/vsimem/ogr_gpkg_20.gpkg') @@ -1758,14 +1547,12 @@ def test_ogr_gpkg_21(): ds = ogr.Open('/vsimem/ogr_gpkg_21.gpkg', update=1) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(0).GetWidth() != 2: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetWidth() == 2 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField(0, 'ab') gdal.ErrorReset() lyr.CreateFeature(f) - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' f = ogr.Feature(lyr.GetLayerDefn()) f.SetFieldBinaryFromHexString(0, '41E9') @@ -1773,8 +1560,7 @@ def test_ogr_gpkg_21(): gdal.PushErrorHandler() lyr.CreateFeature(f) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField(0, 'abc') @@ -1782,12 +1568,10 @@ def test_ogr_gpkg_21(): gdal.PushErrorHandler() lyr.CreateFeature(f) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' f = lyr.GetFeature(f.GetFID()) - if f.GetField(0) != 'abc': - return 'fail' + assert f.GetField(0) == 'abc' gdal.Unlink('/vsimem/ogr_gpkg_21.gpkg') @@ -1803,12 +1587,10 @@ def test_ogr_gpkg_21(): gdal.PushErrorHandler() lyr.CreateFeature(f) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' f = lyr.GetFeature(f.GetFID()) - if f.GetField(0) != 'A_': - return 'fail' + assert f.GetField(0) == 'A_' f = ogr.Feature(lyr.GetLayerDefn()) f.SetField(0, 'abc') @@ -1816,8 +1598,7 @@ def test_ogr_gpkg_21(): gdal.PushErrorHandler() lyr.CreateFeature(f) gdal.PopErrorHandler() - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' f = lyr.GetFeature(f.GetFID()) if f.GetField(0) != 'ab': @@ -1849,11 +1630,9 @@ def test_ogr_gpkg_22(): ds = ogr.Open('/vsimem/ogr_gpkg_22.gpkg') lyr = ds.GetLayerByName('test') - if lyr.GetMetadataItem(ogr.OLMD_FID64) is None: - return 'fail' + assert lyr.GetMetadataItem(ogr.OLMD_FID64) is not None f = lyr.GetNextFeature() - if f.GetFID() != 1234567890123: - return 'fail' + assert f.GetFID() == 1234567890123 gdal.Unlink('/vsimem/ogr_gpkg_22.gpkg') @@ -1891,8 +1670,7 @@ def test_ogr_gpkg_23(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None # Error case: missing non-nullable field @@ -1901,8 +1679,7 @@ def test_ogr_gpkg_23(): gdal.PushErrorHandler() ret = lyr.CreateFeature(f) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = None # Nullable geometry field @@ -1912,8 +1689,7 @@ def test_ogr_gpkg_23(): gdal.PushErrorHandler() ret = lyr.CreateGeomField(ogr.GeomFieldDefn('foo', ogr.wkbPoint)) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 f = ogr.Feature(lyr.GetLayerDefn()) lyr.CreateFeature(f) @@ -1936,22 +1712,18 @@ def test_ogr_gpkg_23(): sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE data_type = 'features'") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 2: - return 'fail' + assert fc == 2 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions") fc = sql_lyr.GetFeatureCount() f = sql_lyr.GetNextFeature() ds.ReleaseResultSet(sql_lyr) - if fc != 2: # r-tree and aspatial - print(fc) - return 'fail' + assert fc == 2 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 2: - return 'fail' + assert fc == 2 field_defn = ogr.GeomFieldDefn('geomfield_not_nullable', ogr.wkbPoint) field_defn.SetNullable(0) @@ -1960,22 +1732,18 @@ def test_ogr_gpkg_23(): sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE data_type = 'features'") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 3: - return 'fail' + assert fc == 3 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_extensions") fc = sql_lyr.GetFeatureCount() f = sql_lyr.GetNextFeature() ds.ReleaseResultSet(sql_lyr) - if fc != 1: # r-tree - print(fc) - return 'fail' + assert fc == 1 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 3: - return 'fail' + assert fc == 3 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('field_not_nullable', 'not_null') @@ -1985,8 +1753,7 @@ def test_ogr_gpkg_23(): # Not Nullable geometry field lyr = ds.CreateLayer('test4', geom_type=ogr.wkbPoint, options=['GEOMETRY_NULLABLE=NO']) - if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() == 0 f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)')) lyr.CreateFeature(f) @@ -2001,32 +1768,23 @@ def test_ogr_gpkg_23(): lyr = ds.GetLayerByName('test5') field_defn = ogr.GeomFieldDefn('', ogr.wkbPoint) with gdaltest.error_handler(): - if lyr.CreateGeomField(field_defn) == 0: - return 'fail' + assert lyr.CreateGeomField(field_defn) != 0 lyr = ds.GetLayerByName('test') - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() == 0 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() == 1 + assert lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() == 0 lyr = ds.GetLayerByName('test2') - if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 1: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() == 1 lyr = ds.GetLayerByName('test3') - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() != 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() != 1: - return 'fail' - if lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_not_nullable')).IsNullable() == 0 + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nullable')).IsNullable() == 1 + assert lyr.GetLayerDefn().GetGeomFieldDefn(lyr.GetLayerDefn().GetGeomFieldIndex('geomfield_not_nullable')).IsNullable() == 0 lyr = ds.GetLayerByName('test4') - if lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetGeomFieldDefn(0).IsNullable() == 0 ds = None @@ -2112,28 +1870,16 @@ def test_ogr_gpkg_24(): ds = ogr.Open('/vsimem/ogr_gpkg_24.gpkg', update=1) lyr = ds.GetLayerByName('test') - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() != "'a''b'": - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_int')).GetDefault() != '123': - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault() != '1.23': - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nodefault')).GetDefault() is not None: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_string')).GetDefault() == "'a''b'" + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_int')).GetDefault() == '123' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_real')).GetDefault() == '1.23' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_nodefault')).GetDefault() is None # Translated from "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))" to CURRENT_TIMESTAMP - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime')).GetDefault() != 'CURRENT_TIMESTAMP': - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime2')).GetDefault() != "'2015/06/30 12:34:56'": - print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime2')).GetDefault()) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime3')).GetDefault() != "CURRENT_TIMESTAMP": - print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime3')).GetDefault()) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime4')).GetDefault() != "'2015/06/30 12:34:56.123'": - print(lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime4')).GetDefault()) - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_date')).GetDefault() != "CURRENT_DATE": - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime')).GetDefault() == 'CURRENT_TIMESTAMP' + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime2')).GetDefault() == "'2015/06/30 12:34:56'" + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime3')).GetDefault() == "CURRENT_TIMESTAMP" + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_datetime4')).GetDefault() == "'2015/06/30 12:34:56.123'" + assert lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_date')).GetDefault() == "CURRENT_DATE" # if lyr.GetLayerDefn().GetFieldDefn(lyr.GetLayerDefn().GetFieldIndex('field_time')).GetDefault() != "CURRENT_TIME": # gdaltest.post_reason('fail') # return 'fail' @@ -2173,12 +1919,10 @@ def test_ogr_gpkg_25(): gdal.PushErrorHandler() ret = lyr.CreateField(ogr.FieldDefn('myfid', ogr.OFTString)) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ret = lyr.CreateField(ogr.FieldDefn('myfid', ogr.OFTInteger)) - if ret != 0: - return 'fail' + assert ret == 0 lyr.CreateField(ogr.FieldDefn('str2', ogr.OFTString)) feat = ogr.Feature(lyr.GetLayerDefn()) @@ -2186,16 +1930,13 @@ def test_ogr_gpkg_25(): feat.SetField('myfid', 10) feat.SetField('str2', 'second string') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' - if feat.GetFID() != 10: - return 'fail' + assert ret == 0 + assert feat.GetFID() == 10 feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetField('str2', 'second string') ret = lyr.CreateFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 if feat.GetFID() < 0: feat.DumpReadable() return 'fail' @@ -2205,8 +1946,7 @@ def test_ogr_gpkg_25(): feat.SetField('str', 'foo') ret = lyr.SetFeature(feat) - if ret != 0: - return 'fail' + assert ret == 0 feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetFID(1) @@ -2214,21 +1954,18 @@ def test_ogr_gpkg_25(): gdal.PushErrorHandler() ret = lyr.CreateFeature(feat) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 gdal.PushErrorHandler() ret = lyr.SetFeature(feat) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 feat.UnsetField('myfid') gdal.PushErrorHandler() ret = lyr.SetFeature(feat) gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 lyr.ResetReading() f = lyr.GetNextFeature() @@ -2258,85 +1995,68 @@ def test_ogr_gpkg_26(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_26.gpkg') - if ds.TestCapability(ogr.ODsCTransactions) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCTransactions) == 1 ret = ds.StartTransaction() - if ret != 0: - return 'fail' + assert ret == 0 gdal.PushErrorHandler() ret = ds.StartTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) ret = ds.RollbackTransaction() - if ret != 0: - return 'fail' + assert ret == 0 gdal.PushErrorHandler() ret = ds.RollbackTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds = None ds = ogr.Open('/vsimem/ogr_gpkg_26.gpkg', update=1) - if ds.GetLayerCount() != 0: - return 'fail' + assert ds.GetLayerCount() == 0 ret = ds.StartTransaction() - if ret != 0: - return 'fail' + assert ret == 0 gdal.PushErrorHandler() ret = ds.StartTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) ret = ds.CommitTransaction() - if ret != 0: - return 'fail' + assert ret == 0 gdal.PushErrorHandler() ret = ds.CommitTransaction() gdal.PopErrorHandler() - if ret == 0: - return 'fail' + assert ret != 0 ds = None ds = ogr.Open('/vsimem/ogr_gpkg_26.gpkg', update=1) - if ds.GetLayerCount() != 1: - return 'fail' + assert ds.GetLayerCount() == 1 lyr = ds.GetLayerByName('test') ds.StartTransaction() lyr.CreateFeature(ogr.Feature(lyr.GetLayerDefn())) lyr.ResetReading() f = lyr.GetNextFeature() - if f is None: - return 'fail' - if lyr.GetFeatureCount() != 1: - return 'fail' + assert f is not None + assert lyr.GetFeatureCount() == 1 ds.RollbackTransaction() - if lyr.GetFeatureCount() != 0: - return 'fail' + assert lyr.GetFeatureCount() == 0 ds.StartTransaction() lyr.CreateFeature(ogr.Feature(lyr.GetLayerDefn())) lyr.CreateFeature(ogr.Feature(lyr.GetLayerDefn())) lyr.ResetReading() f = lyr.GetNextFeature() - if f is None or f.GetFID() != 1: - return 'fail' + assert f is not None and f.GetFID() == 1 ds.CommitTransaction() # the cursor is still valid after CommitTransaction(), which isn't the case for other backends such as PG ! f = lyr.GetNextFeature() - if f is None or f.GetFID() != 2: - return 'fail' - if lyr.GetFeatureCount() != 2: - return 'fail' + assert f is not None and f.GetFID() == 2 + assert lyr.GetFeatureCount() == 2 ds.StartTransaction() lyr = ds.CreateLayer('test2', geom_type=ogr.wkbPoint) @@ -2346,16 +2066,14 @@ def test_ogr_gpkg_26(): f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)')) ret = lyr.CreateFeature(f) ds.CommitTransaction() - if ret != 0: - return 'fail' + assert ret == 0 ds.StartTransaction() f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)')) ret = lyr.CreateFeature(f) ds.CommitTransaction() - if ret != 0: - return 'fail' + assert ret == 0 if False: # pylint: disable=using-constant-test ds.StartTransaction() @@ -2379,8 +2097,7 @@ def test_ogr_gpkg_26(): ds.CommitTransaction() # For some reason fails with SQLite 3.6.X with 'failed to execute insert : callback requested query abort' # but not with later versions... - if ret != 0: - return 'fail' + assert ret == 0 ds = None @@ -2435,8 +2152,7 @@ def test_ogr_gpkg_28(): srcDS = gdal.OpenEx('../ogr/data/poly.shp') ds = gdal.VectorTranslate('/vsimem/ogr_gpkg_28.gpkg', srcDS, format='GPKG', dstSRS='EPSG:4326') - if str(ds.GetLayer(0).GetSpatialRef()).find('1984') == -1: - return 'fail' + assert str(ds.GetLayer(0).GetSpatialRef()).find('1984') != -1 ds = None gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_28.gpkg') @@ -2453,30 +2169,24 @@ def test_ogr_gpkg_29(): return 'skip' ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_29.gpkg') - if ds.TestCapability(ogr.ODsCMeasuredGeometries) != 1: - return 'fail' + assert ds.TestCapability(ogr.ODsCMeasuredGeometries) == 1 lyr = ds.CreateLayer('pointm', geom_type=ogr.wkbPointM) - if lyr.TestCapability(ogr.OLCMeasuredGeometries) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCMeasuredGeometries) == 1 f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT M (1 2 3)')) lyr.CreateFeature(f) lyr = ds.CreateLayer('pointzm', geom_type=ogr.wkbPointZM) - if lyr.TestCapability(ogr.OLCMeasuredGeometries) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCMeasuredGeometries) == 1 f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)')) lyr.CreateFeature(f) ds = None - if not validate('/vsimem/ogr_gpkg_29.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_29.gpkg'), 'validation failed' ds = ogr.Open('/vsimem/ogr_gpkg_29.gpkg', update=1) lyr = ds.GetLayerByName('pointm') - if lyr.GetGeomType() != ogr.wkbPointM: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPointM f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT M (1 2 3)': f.DumpReadable() @@ -2486,8 +2196,7 @@ def test_ogr_gpkg_29(): ds.ExecuteSQL("UPDATE pointm SET geom = x'4750000700000000000000000000F03F000000000000F03F000000000000004000000000000000400000000000000840000000000000084001D1070000000000000000F03F00000000000000400000000000000840'") lyr = ds.GetLayerByName('pointzm') - if lyr.GetGeomType() != ogr.wkbPointZM: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPointZM f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT ZM (1 2 3 4)': f.DumpReadable() @@ -2501,15 +2210,13 @@ def test_ogr_gpkg_29(): # Check again ds = ogr.Open('/vsimem/ogr_gpkg_29.gpkg') lyr = ds.GetLayerByName('pointm') - if lyr.GetGeomType() != ogr.wkbPointM: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPointM f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT M (1 2 3)': f.DumpReadable() return 'fail' lyr = ds.GetLayerByName('pointzm') - if lyr.GetGeomType() != ogr.wkbPointZM: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPointZM f = lyr.GetNextFeature() if f.GetGeometryRef().ExportToIsoWkt() != 'POINT ZM (1 2 3 4)': f.DumpReadable() @@ -2531,18 +2238,14 @@ def test_ogr_gpkg_30(): with gdaltest.error_handler(): ds = gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_30.geopkg') - if ds is None: - return 'fail' - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert ds is not None + assert gdal.GetLastErrorMsg() != '' ds = None with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_30.geopkg', update=1) - if ds is None: - return 'fail' - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert ds is not None + assert gdal.GetLastErrorMsg() != '' ds = None with gdaltest.error_handler(): @@ -2578,16 +2281,12 @@ def test_ogr_gpkg_31(): ds = ogr.Open('/vsimem/ogr_gpkg_31.gpkg') lyr = ds.GetLayerByName('curve') - if lyr.GetGeomType() != ogr.wkbCurve: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbCurve lyr = ds.GetLayerByName('surface') - if lyr.GetGeomType() != ogr.wkbSurface: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbSurface ds = None - if not validate('/vsimem/ogr_gpkg_31.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_31.gpkg'), 'validation failed' gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_31.gpkg') @@ -2608,25 +2307,19 @@ def test_ogr_gpkg_32(): ds = None ds = ogr.Open('/vsimem/ogr_gpkg_32.gpkg') - if ds.GetLayerCount() != 1: - return 'fail' + assert ds.GetLayerCount() == 1 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE table_name != 'ogr_empty_table'") - if sql_lyr.GetFeatureCount() != 0: - return 'fail' + assert sql_lyr.GetFeatureCount() == 0 ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns WHERE table_name != 'ogr_empty_table'") - if sql_lyr.GetFeatureCount() != 0: - return 'fail' + assert sql_lyr.GetFeatureCount() == 0 ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_extensions'") - if sql_lyr.GetFeatureCount() != 0: - return 'fail' + assert sql_lyr.GetFeatureCount() == 0 ds.ReleaseResultSet(sql_lyr) ds = None - if not validate('/vsimem/ogr_gpkg_32.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_32.gpkg'), 'validation failed' gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_32.gpkg') @@ -2649,8 +2342,7 @@ def test_ogr_gpkg_33(): ds = ogr.Open('/vsimem/ogr_gpkg_33.gpkg') sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE last_change = '2000-01-01T:00:00:00.000Z' AND table_name != 'ogr_empty_table'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 ds.ReleaseResultSet(sql_lyr) ds = None @@ -2670,9 +2362,7 @@ def test_ogr_gpkg_test_ogrsf(): # Do integrity check first sql_lyr = gdaltest.gpkg_ds.ExecuteSQL("PRAGMA integrity_check") feat = sql_lyr.GetNextFeature() - if feat.GetField(0) != 'ok': - gdaltest.post_reason('integrity check failed') - return 'fail' + assert feat.GetField(0) == 'ok', 'integrity check failed' gdaltest.gpkg_ds.ReleaseResultSet(sql_lyr) import test_cli_utilities @@ -2683,15 +2373,11 @@ def test_ogr_gpkg_test_ogrsf(): # sys.exit(0) ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/gpkg_test.gpkg --config OGR_SQLITE_SYNCHRONOUS OFF') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/gpkg_test.gpkg -sql "select * from tbl_linestring_renamed" --config OGR_SQLITE_SYNCHRONOUS OFF') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -2733,15 +2419,13 @@ def test_ogr_gpkg_34(): content = gdal.VSIFReadL(1, 1000000, f).decode('latin1') gdal.VSIFCloseL(f) - if content.find(layer_name) < 0: - return 'fail' + assert content.find(layer_name) >= 0 ds = ogr.Open(dbname, update=1) new_layer_name = """weird2'layer"name""" with gdaltest.error_handler(): ds.ExecuteSQL('ALTER TABLE "weird\'layer""name" RENAME TO gpkg_contents') - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.ErrorReset() ds.ExecuteSQL('ALTER TABLE "weird\'layer""name" RENAME TO "weird2\'layer""name"') ds.ExecuteSQL('VACUUM') @@ -2752,19 +2436,16 @@ def test_ogr_gpkg_34(): content = gdal.VSIFReadL(1, 1000000, f).decode('latin1') gdal.VSIFCloseL(f) - if content.find(layer_name) >= 0: - return 'fail' + assert content.find(layer_name) < 0 layer_name = new_layer_name ds = ogr.Open(dbname, update=1) with gdaltest.error_handler(): ds.ExecuteSQL('DELLAYER:does_not_exist') - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.ErrorReset() ds.ExecuteSQL('DELLAYER:' + layer_name) - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' ds.ExecuteSQL('VACUUM') ds = None @@ -2773,8 +2454,7 @@ def test_ogr_gpkg_34(): content = gdal.VSIFReadL(1, 1000000, f).decode('latin1') gdal.VSIFCloseL(f) - if content.find(layer_name) >= 0: - return 'fail' + assert content.find(layer_name) < 0 gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -2790,15 +2470,12 @@ def test_ogr_gpkg_34(): ds = ogr.Open(dbname, update=1) ds.ExecuteSQL('DROP TABLE "weird2\'layer""name"') - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' ds.ExecuteSQL('DROP TABLE another_layer_name') - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' with gdaltest.error_handler(): ds.ExecuteSQL('DROP TABLE "foobar"') - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert gdal.GetLastErrorMsg() != '' gdal.ErrorReset() ds.ExecuteSQL('VACUUM') ds = None @@ -2808,11 +2485,9 @@ def test_ogr_gpkg_34(): content = gdal.VSIFReadL(1, 1000000, f).decode('latin1') gdal.VSIFCloseL(f) - if content.find(layer_name) >= 0: - return 'fail' + assert content.find(layer_name) < 0 - if content.find('another_layer_name') >= 0: - return 'fail' + assert content.find('another_layer_name') < 0 gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -2866,23 +2541,18 @@ def test_ogr_gpkg_35(): ds.ExecuteSQL("INSERT INTO gpkg_data_columns VALUES('test', 'bar_i_will_disappear', 'bar_constraints', NULL, NULL, NULL, NULL)") ds.ExecuteSQL("INSERT INTO gpkg_extensions VALUES('test', 'bar_i_will_disappear', 'extension_name', 'definition', 'scope')") - if lyr.TestCapability(ogr.OLCDeleteField) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCDeleteField) == 1 with gdaltest.error_handler(): ret = lyr.DeleteField(-1) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.DeleteField(lyr.GetLayerDefn().GetFieldCount()) - if ret == 0: - return 'fail' + assert ret != 0 - if lyr.DeleteField(1) != 0: - return 'fail' - if lyr.GetLayerDefn().GetFieldCount() != 2: - return 'fail' + assert lyr.DeleteField(1) == 0 + assert lyr.GetLayerDefn().GetFieldCount() == 2 lyr.ResetReading() f = lyr.GetNextFeature() @@ -2894,8 +2564,7 @@ def test_ogr_gpkg_35(): lyr.StartTransaction() ret = lyr_nonspatial.DeleteField(1) lyr.CommitTransaction() - if ret != 0: - return 'fail' + assert ret == 0 lyr_nonspatial.ResetReading() f = lyr_nonspatial.GetNextFeature() if f.GetFID() != 10 or f['foo'] != 'fooval' or f['baz'] != 'bazval': @@ -2911,8 +2580,7 @@ def test_ogr_gpkg_35(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): ret = lyr.DeleteField(0) - if ret == 0: - return 'fail' + assert ret != 0 ds = None # Check that there is no more any reference to the layer @@ -2920,8 +2588,7 @@ def test_ogr_gpkg_35(): content = gdal.VSIFReadL(1, 1000000, f).decode('latin1') gdal.VSIFCloseL(f) - if content.find('bar_i_will_disappear') >= 0: - return 'fail' + assert content.find('bar_i_will_disappear') < 0 gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -2963,38 +2630,31 @@ def test_ogr_gpkg_36(): ds.ExecuteSQL("INSERT INTO gpkg_extensions VALUES('test', 'foo', 'extension_name', 'definition', 'scope')") ds.ExecuteSQL("CREATE INDEX my_idx ON test(foo)") - if lyr.TestCapability(ogr.OLCAlterFieldDefn) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCAlterFieldDefn) == 1 with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(-1, ogr.FieldDefn('foo'), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(1, ogr.FieldDefn('foo'), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn(lyr.GetGeometryColumn()), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn(lyr.GetFIDColumn()), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('baz'), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 new_field_defn = ogr.FieldDefn('bar', ogr.OFTReal) new_field_defn.SetSubType(ogr.OFSTFloat32) - if lyr.AlterFieldDefn(0, new_field_defn, ogr.ALTER_ALL_FLAG) != 0: - return 'fail' + assert lyr.AlterFieldDefn(0, new_field_defn, ogr.ALTER_ALL_FLAG) == 0 lyr.ResetReading() f = lyr.GetNextFeature() @@ -3006,8 +2666,7 @@ def test_ogr_gpkg_36(): lyr.StartTransaction() new_field_defn = ogr.FieldDefn('baw', ogr.OFTString) - if lyr.AlterFieldDefn(0, new_field_defn, ogr.ALTER_ALL_FLAG) != 0: - return 'fail' + assert lyr.AlterFieldDefn(0, new_field_defn, ogr.ALTER_ALL_FLAG) == 0 lyr.CommitTransaction() lyr.ResetReading() @@ -3021,8 +2680,7 @@ def test_ogr_gpkg_36(): # Check that index has been recreated sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'my_idx'") f = sql_lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None f = None ds.ReleaseResultSet(sql_lyr) @@ -3035,8 +2693,7 @@ def test_ogr_gpkg_36(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('foo'), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 ds = None # Check that there is no more any reference to the layer @@ -3044,8 +2701,7 @@ def test_ogr_gpkg_36(): content = gdal.VSIFReadL(1, 1000000, f).decode('latin1') gdal.VSIFCloseL(f) - if content.find('foo') >= 0: - return 'fail' + assert content.find('foo') < 0 gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3058,8 +2714,7 @@ def test_ogr_gpkg_36(): gdal.Unlink(dbname) with gdaltest.error_handler(): ret = lyr.AlterFieldDefn(0, ogr.FieldDefn('bar'), ogr.ALTER_ALL_FLAG) - if ret == 0: - return 'fail' + assert ret != 0 with gdaltest.error_handler(): ds = None @@ -3104,20 +2759,16 @@ def test_ogr_gpkg_37(): ds.ExecuteSQL("CREATE INDEX my_idx_foo ON test(foo)") ds.ExecuteSQL("CREATE INDEX my_idx_bar ON test(bar)") - if lyr.TestCapability(ogr.OLCReorderFields) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCReorderFields) == 1 with gdaltest.error_handler(): ret = lyr.ReorderFields([-1, -1]) - if ret == 0: - return 'fail' + assert ret != 0 - if lyr.ReorderFields([1, 0]) != 0: - return 'fail' + assert lyr.ReorderFields([1, 0]) == 0 lyr.ResetReading() - if lyr.GetLayerDefn().GetFieldIndex('foo') != 1 or lyr.GetLayerDefn().GetFieldIndex('bar') != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('foo') == 1 and lyr.GetLayerDefn().GetFieldIndex('bar') == 0 f = lyr.GetNextFeature() if f.GetFID() != 10 or f['foo'] != 'fooval' or f['bar'] != 'barval' or \ f.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0,0 1,1 1,0 0))': @@ -3126,8 +2777,7 @@ def test_ogr_gpkg_37(): # Check that index has been recreated sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'my_idx_foo' OR name = 'my_idx_bar'") - if sql_lyr.GetFeatureCount() != 2: - return 'fail' + assert sql_lyr.GetFeatureCount() == 2 ds.ReleaseResultSet(sql_lyr) ds = None @@ -3137,8 +2787,7 @@ def test_ogr_gpkg_37(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): ret = lyr.ReorderFields([1, 0]) - if ret == 0: - return 'fail' + assert ret != 0 ds = None gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3170,14 +2819,10 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): ds = ogr.Open(dbname, update=1) lyr = ds.GetLayer(0) extent = lyr.GetExtent(force=0, can_return_null=True) - if extent is not None: - print(extent) - return 'fail' + assert extent is None # Test that we can compute the extent of a layer that has none registered in gpkg_contents extent = lyr.GetExtent(force=1) - if extent != (1, 3, 2, 4): - print(extent) - return 'fail' + assert extent == (1, 3, 2, 4) sql_lyr = ds.ExecuteSQL('SELECT min_x, min_y, max_x, max_y FROM gpkg_contents') f = sql_lyr.GetNextFeature() if f['min_x'] != 1 or f['min_y'] != 2 or f['max_x'] != 3 or f['max_y'] != 4: @@ -3185,9 +2830,7 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): return 'fail' ds.ReleaseResultSet(sql_lyr) extent = lyr.GetExtent(force=0) - if extent != (1, 3, 2, 4): - print(extent) - return 'fail' + assert extent == (1, 3, 2, 4) # Modify feature f = lyr.GetFeature(1) @@ -3196,23 +2839,17 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): # The extent has grown extent = lyr.GetExtent(force=0) - if extent != (-3.0, 3.0, -4.0, 4.0): - print(extent) - return 'fail' + assert extent == (-3.0, 3.0, -4.0, 4.0) ds.ExecuteSQL('RECOMPUTE EXTENT ON test') extent = lyr.GetExtent(force=0) - if extent != (-3.0, -1.0, -4.0, -2.0): - print(extent) - return 'fail' + assert extent == (-3.0, -1.0, -4.0, -2.0) ds = None ds = ogr.Open(dbname) lyr = ds.GetLayer(0) extent = lyr.GetExtent(force=0) - if extent != (-3.0, -1.0, -4.0, -2.0): - print(extent) - return 'fail' + assert extent == (-3.0, -1.0, -4.0, -2.0) ds = None ds = ogr.Open(dbname, update=1) @@ -3223,17 +2860,13 @@ def test_ogr_gpkg_38(options=['SPATIAL_INDEX=YES']): # This should cancel NULLify the extent in gpkg_contents ds.ExecuteSQL('RECOMPUTE EXTENT ON test') extent = lyr.GetExtent(force=0, can_return_null=True) - if extent is not None: - print(extent) - return 'fail' + assert extent is None ds = None ds = ogr.Open(dbname) lyr = ds.GetLayer(0) extent = lyr.GetExtent(force=0, can_return_null=True) - if extent is not None: - print(extent) - return 'fail' + assert extent is None ds = None gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3260,29 +2893,24 @@ def test_ogr_gpkg_39(): ds.CreateLayer('test') lyr = ds.CreateLayer('test_with_explicit_identifier', options=['IDENTIFIER=explicit_identifier']) - if lyr is None: - return 'fail' + assert lyr is not None # Allow overwriting lyr = ds.CreateLayer('test_with_explicit_identifier', options=['IDENTIFIER=explicit_identifier', 'OVERWRITE=YES']) - if lyr is None: - return 'fail' + assert lyr is not None with gdaltest.error_handler(): lyr = ds.CreateLayer('test2', options=['IDENTIFIER=test']) - if lyr is not None: - return 'fail' + assert lyr is None with gdaltest.error_handler(): lyr = ds.CreateLayer('test2', options=['IDENTIFIER=explicit_identifier']) - if lyr is not None: - return 'fail' + assert lyr is None ds.ExecuteSQL("INSERT INTO gpkg_contents ( table_name, identifier, data_type ) VALUES ( 'some_table', 'another_identifier', 'some_data_type' )") with gdaltest.error_handler(): lyr = ds.CreateLayer('test2', options=['IDENTIFIER=another_identifier']) - if lyr is not None: - return 'fail' + assert lyr is None ds = None gdaltest.gpkg_dr.DeleteDataSource(dbname) @@ -3304,25 +2932,19 @@ def test_ogr_gpkg_40(): ds = None ds = ogr.Open('/vsimem/ogr_gpkg_40.gpkg') - if ds.GetLayerCount() != 1: - return 'fail' + assert ds.GetLayerCount() == 1 sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_contents WHERE table_name != 'ogr_empty_table'") - if sql_lyr.GetFeatureCount() != 1: - return 'fail' + assert sql_lyr.GetFeatureCount() == 1 ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM gpkg_geometry_columns WHERE table_name != 'ogr_empty_table'") - if sql_lyr.GetFeatureCount() != 0: - return 'fail' + assert sql_lyr.GetFeatureCount() == 0 ds.ReleaseResultSet(sql_lyr) sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_extensions'") - if sql_lyr.GetFeatureCount() != 0: - return 'fail' + assert sql_lyr.GetFeatureCount() == 0 ds.ReleaseResultSet(sql_lyr) ds = None - if not validate('/vsimem/ogr_gpkg_40.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_40.gpkg'), 'validation failed' gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_40.gpkg') @@ -3404,12 +3026,9 @@ def test_ogr_gpkg_42(): ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg') lyr = ds.GetLayer(0) - if get_feature_count_from_gpkg_contents(ds) != 5: - return 'fail' - if not foo_has_trigger(ds): - return 'fail' - if lyr.TestCapability(ogr.OLCFastFeatureCount) == 0: - return 'fail' + assert get_feature_count_from_gpkg_contents(ds) == 5 + assert foo_has_trigger(ds) + assert lyr.TestCapability(ogr.OLCFastFeatureCount) != 0 ds = None ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) @@ -3419,57 +3038,42 @@ def test_ogr_gpkg_42(): lyr.CreateFeature(f) # Has been invalidated for now - if get_feature_count_from_gpkg_contents(ds) is not None: - return 'fail' + assert get_feature_count_from_gpkg_contents(ds) is None - if foo_has_trigger(ds): - return 'fail' + assert not foo_has_trigger(ds) fc = lyr.GetFeatureCount() - if fc != 6: - print(fc) - return 'fail' + assert fc == 6 ds.ExecuteSQL('DELETE FROM foo WHERE i = 1') - if not foo_has_trigger(ds): - return 'fail' + assert foo_has_trigger(ds) - if get_feature_count_from_gpkg_contents(ds) is not None: - return 'fail' + assert get_feature_count_from_gpkg_contents(ds) is None fc = lyr.GetFeatureCount() - if fc != 5: - print(fc) - return 'fail' + assert fc == 5 - if get_feature_count_from_gpkg_contents(ds) != 5: - return 'fail' + assert get_feature_count_from_gpkg_contents(ds) == 5 ds = None ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) lyr = ds.GetLayer(0) fc = lyr.GetFeatureCount() - if fc != 5: - print(fc) - return 'fail' + assert fc == 5 ds.ExecuteSQL('UPDATE gpkg_ogr_contents SET feature_count = NULL') ds = None ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) lyr = ds.GetLayer(0) - if get_feature_count_from_gpkg_contents(ds) is not None: - return 'fail' + assert get_feature_count_from_gpkg_contents(ds) is None fc = lyr.GetFeatureCount() - if fc != 5: - print(fc) - return 'fail' + assert fc == 5 ds = None ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) - if get_feature_count_from_gpkg_contents(ds) != 5: - return 'fail' + assert get_feature_count_from_gpkg_contents(ds) == 5 # So as to test that we really read from gpkg_ogr_contents ds.ExecuteSQL('UPDATE gpkg_ogr_contents SET feature_count = 5000') @@ -3477,9 +3081,7 @@ def test_ogr_gpkg_42(): ds = ogr.Open('/vsimem/ogr_gpkg_42.gpkg', update=1) lyr = ds.GetLayer(0) fc = lyr.GetFeatureCount() - if fc != 5000: - print(fc) - return 'fail' + assert fc == 5000 # Test renaming ds.ExecuteSQL('ALTER TABLE foo RENAME TO bar') @@ -3490,15 +3092,13 @@ def test_ogr_gpkg_42(): val = f.GetField(0) f = None ds.ReleaseResultSet(sql_lyr) - if val != 5000: - return 'fail' + assert val == 5000 # Test layer deletion ds.DeleteLayer(0) sql_lyr = ds.ExecuteSQL("SELECT feature_count FROM gpkg_ogr_contents WHERE table_name != 'ogr_empty_table'", dialect='DEBUG') f = sql_lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None ds.ReleaseResultSet(sql_lyr) ds = None @@ -3519,32 +3119,23 @@ def test_ogr_gpkg_42(): sql_lyr = ds.ExecuteSQL('PRAGMA table_info(gpkg_contents)') fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 10: - return 'fail' + assert fc == 10 - if foo_has_trigger(ds): - return 'fail' + assert not foo_has_trigger(ds) lyr = ds.GetLayer(0) - if lyr.TestCapability(ogr.OLCFastFeatureCount) != 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 0 fc = lyr.GetFeatureCount() - if fc != 5: - print(fc) - return 'fail' + assert fc == 5 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField(0, 10) lyr.CreateFeature(f) lyr = ds.GetLayer(0) fc = lyr.GetFeatureCount() - if fc != 6: - print(fc) - return 'fail' + assert fc == 6 ds.ExecuteSQL('DELETE FROM foo WHERE i = 1') fc = lyr.GetFeatureCount() - if fc != 5: - print(fc) - return 'fail' + assert fc == 5 ds = None gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_42.gpkg') @@ -3576,17 +3167,13 @@ def test_ogr_gpkg_43(): with gdaltest.error_handler(): ds = gdal.Open('/vsimem/ogr_gpkg_43.gpkg') - if len(ds.GetMetadata_List('SUBDATASETS')) != 2 * 1000: - print(len(ds.GetMetadata_List('SUBDATASETS'))) - return 'fail' + assert len(ds.GetMetadata_List('SUBDATASETS')) == 2 * 1000 ds = None gdal.SetConfigOption('OGR_TABLE_LIMIT', '1000') with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_43.gpkg') gdal.SetConfigOption('OGR_TABLE_LIMIT', None) - if ds.GetLayerCount() != 1000: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1000 ds = None gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_43.gpkg') @@ -3608,24 +3195,17 @@ def test_ogr_gpkg_44(): ds = None gdal.SetConfigOption('CREATE_METADATA_TABLES', None) - if not validate('/vsimem/ogr_gpkg_44.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_44.gpkg'), 'validation failed' ds = ogr.Open('/vsimem/ogr_gpkg_44.gpkg') md = ds.GetMetadata() - if md != {}: - print(md) - return 'fail' + assert md == {} md = ds.GetLayer(0).GetMetadata() - if md != {}: - print(md) - return 'fail' + assert md == {} sql_lyr = ds.ExecuteSQL("SELECT * FROM sqlite_master WHERE name = 'gpkg_metadata'") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 0: - return 'fail' + assert fc == 0 ds = None ds = ogr.Open('/vsimem/ogr_gpkg_44.gpkg', update=1) @@ -3634,9 +3214,7 @@ def test_ogr_gpkg_44(): ds = ogr.Open('/vsimem/ogr_gpkg_44.gpkg') md = ds.GetMetadata() - if md != {'FOO': 'BAR'}: - print(md) - return 'fail' + assert md == {'FOO': 'BAR'} ds = None gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_44.gpkg') @@ -3658,10 +3236,8 @@ def test_ogr_gpkg_45(): ds = None ds = ogr.Open('/vsimem/ogr_gpkg_45.gpkg') lyr = ds.GetLayer(0) - if lyr.GetFIDColumn() != '': - return 'fail' - if lyr.GetLayerDefn().GetFieldCount() != 2: - return 'fail' + assert lyr.GetFIDColumn() == '' + assert lyr.GetLayerDefn().GetFieldCount() == 2 ds = None gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_45.gpkg') @@ -3701,12 +3277,8 @@ def test_ogr_gpkg_46(): ds = ogr.Open('/vsimem/ogr_gpkg_46.gpkg', update=1) lyr = ds.GetLayerByName('my_view') - if lyr.GetLayerDefn().GetFieldCount() != 1: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' - if lyr.GetGeometryColumn() != 'my_geom': - print(lyr.GetGeometryColumn()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 1 + assert lyr.GetGeometryColumn() == 'my_geom' # Operations not valid on a view with gdaltest.error_handler(): @@ -3730,22 +3302,16 @@ def test_ogr_gpkg_46(): # Effectively test spatial index lyr.SetSpatialFilterRect(-0.5, -0.5, 0.5, 0.5) - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr.GetFeatureCount() == 1 f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None f = lyr.GetNextFeature() - if f is not None: - return 'fail' + assert f is None # View with FID lyr = ds.GetLayerByName('my_view2') - if lyr.GetLayerDefn().GetFieldCount() != 1: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' - if lyr.GetFIDColumn() != 'OGC_FID': - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 1 + assert lyr.GetFIDColumn() == 'OGC_FID' f = lyr.GetNextFeature() if f.GetFID() != 1 or f.GetField(0) != 'bla': f.DumpReadable() @@ -3753,9 +3319,7 @@ def test_ogr_gpkg_46(): # View without valid rowid lyr = ds.GetLayerByName('my_view3') - if lyr.GetLayerDefn().GetFieldCount() != 2: - print(lyr.GetLayerDefn().GetFieldCount()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 2 f = lyr.GetNextFeature() if f.GetFID() != 0: f.DumpReadable() @@ -3794,17 +3358,13 @@ def test_ogr_gpkg_47(): with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) - if ds is None: - return 'fail' - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert ds is not None + assert gdal.GetLastErrorMsg() != '' gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', 'NO') ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) - if gdal.GetLastErrorMsg() != '': - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg() == '' gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_47.gpkg', options=['VERSION=1.2']) # Set wrong user_version @@ -3815,17 +3375,14 @@ def test_ogr_gpkg_47(): with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) - if ds is None: - return 'fail' - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert ds is not None + assert gdal.GetLastErrorMsg() != '' ds = None gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', 'NO') ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' # Set GPKG 1.2.1 gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_47.gpkg', options=['VERSION=1.2']) @@ -3836,17 +3393,14 @@ def test_ogr_gpkg_47(): gdal.VSIFCloseL(fp) ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) - if ds is None: - return 'fail' - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert ds is not None + assert gdal.GetLastErrorMsg() == '' ds = None gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', 'NO') ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' # Set GPKG 1.3.0 gdaltest.gpkg_dr.CreateDataSource('/vsimem/ogr_gpkg_47.gpkg', options=['VERSION=1.2']) @@ -3858,16 +3412,13 @@ def test_ogr_gpkg_47(): with gdaltest.error_handler(): ds = ogr.Open('/vsimem/ogr_gpkg_47.gpkg', update=1) - if ds is None: - return 'fail' - if gdal.GetLastErrorMsg() == '': - return 'fail' + assert ds is not None + assert gdal.GetLastErrorMsg() != '' gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', 'NO') ogr.Open('/vsimem/ogr_gpkg_47.gpkg') gdal.SetConfigOption('GPKG_WARN_UNRECOGNIZED_APPLICATION_ID', None) - if gdal.GetLastErrorMsg() != '': - return 'fail' + assert gdal.GetLastErrorMsg() == '' # Just for the sake of coverage testing in DEBUG mode with gdaltest.error_handler(): @@ -3903,8 +3454,7 @@ def test_ogr_gpkg_47(): gdal.VSIFCloseL(fp) gdal.VSIFCloseL(fzip) ds = ogr.Open('/vsizip//vsimem/ogr_gpkg_47.zip') - if ds.GetDriver().GetName() != 'GPKG': - return 'fail' + assert ds.GetDriver().GetName() == 'GPKG' ds = None gdal.Unlink('/vsimem/ogr_gpkg_47.zip') @@ -3949,8 +3499,7 @@ def test_ogr_gpkg_48(): fld_defn.SetDefault('x') lyr.CreateField(fld_defn) f = ogr.Feature(lyr.GetLayerDefn()) - if lyr.CreateFeature(f) != 0: - return 'fail' + assert lyr.CreateFeature(f) == 0 lyr.ResetReading() f = lyr.GetNextFeature() if f.GetField('foo') != 'x': @@ -3958,8 +3507,7 @@ def test_ogr_gpkg_48(): return 'fail' f = ogr.Feature(lyr.GetLayerDefn()) f.SetFID(1) - if lyr.SetFeature(f) != 0: - return 'fail' + assert lyr.SetFeature(f) == 0 lyr.ResetReading() f = lyr.GetNextFeature() if f.GetField('foo') != 'x': @@ -3990,8 +3538,7 @@ def test_ogr_gpkg_49(): f = None field_defn = ogr.GeomFieldDefn('', ogr.wkbPoint) - if lyr.CreateGeomField(field_defn) != 0: - return 'fail' + assert lyr.CreateGeomField(field_defn) == 0 ds = None gdaltest.gpkg_dr.DeleteDataSource('/vsimem/ogr_gpkg_49.gpkg') @@ -4025,21 +3572,16 @@ def test_ogr_gpkg_50(): ds = None - if not validate('/vsimem/ogr_gpkg_50.gpkg'): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate('/vsimem/ogr_gpkg_50.gpkg'), 'validation failed' ds = ogr.Open('/vsimem/ogr_gpkg_50.gpkg') lyr = ds.GetLayer('test') - if not lyr.GetSpatialRef().IsSame(srs32631): - return 'fail' + assert lyr.GetSpatialRef().IsSame(srs32631) lyr = ds.GetLayer('without_org') - if not lyr.GetSpatialRef().IsSame(srs_without_org): - return 'fail' + assert lyr.GetSpatialRef().IsSame(srs_without_org) sql_lyr = ds.ExecuteSQL('SELECT definition_12_063 FROM gpkg_spatial_ref_sys WHERE srs_id = 32631') f = sql_lyr.GetNextFeature() - if f.GetField(0) != 'undefined': - return 'fail' + assert f.GetField(0) == 'undefined' ds.ReleaseResultSet(sql_lyr) ds = None @@ -4062,8 +3604,7 @@ def test_ogr_gpkg_51(): ds = ogr.Open('data/poly.gpkg.sql') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None return 'success' @@ -4080,8 +3621,7 @@ def test_ogr_gpkg_52(): lyr = ds.GetLayer(0) with gdaltest.error_handler(): f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None return 'success' @@ -4098,20 +3638,16 @@ def test_ogr_gpkg_53(): return 'skip' ds = ogr.Open('data/poly_inconsistent_case.gpkg.sql') - if ds.GetLayerCount() != 1: - return 'fail' + assert ds.GetLayerCount() == 1 lyr = ds.GetLayer(0) f = lyr.GetNextFeature() - if f is None: - return 'fail' + assert f is not None import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is not None: ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' data/poly_inconsistent_case.gpkg.sql') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -4199,17 +3735,13 @@ def test_ogr_gpkg_55(): gdal.ErrorReset() with gdaltest.error_handler(): lyr.CreateFeature(f) - if gdal.GetLastErrorMsg() == '': - gdaltest.post_reason('should have warned') - return 'fail' + assert gdal.GetLastErrorMsg() != '', 'should have warned' f = None f = ogr.Feature(lyr.GetLayerDefn()) f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(1 1)')) gdal.ErrorReset() lyr.CreateFeature(f) - if gdal.GetLastErrorMsg() != '': - gdaltest.post_reason('should NOT have warned') - return 'fail' + assert gdal.GetLastErrorMsg() == '', 'should NOT have warned' f = None ds = None @@ -4266,12 +3798,9 @@ def test_ogr_gpkg_57(): with gdaltest.error_handler(): ds = ogr.Open(tmpfile) - if ds.GetLayerCount() != 1: - gdaltest.post_reason('bad layer count') - return 'fail' - if gdal.GetLastErrorMsg().find('Table poly appearing several times') < 0: - gdaltest.post_reason('should NOT have warned') - return 'fail' + assert ds.GetLayerCount() == 1, 'bad layer count' + assert gdal.GetLastErrorMsg().find('Table poly appearing several times') >= 0, \ + 'should NOT have warned' ds = None gdal.Unlink(tmpfile) @@ -4295,8 +3824,7 @@ def test_ogr_gpkg_58(): ds = ogr.Open(out_filename) sql_lyr = ds.ExecuteSQL("SELECT HasSpatialIndex('poly', 'geom')") f = sql_lyr.GetNextFeature() - if f.GetField(0) != 1: - return 'fail' + assert f.GetField(0) == 1 ds.ReleaseResultSet(sql_lyr) ds = None @@ -4320,8 +3848,7 @@ def test_ogr_gpkg_59(): ds = ogr.Open(out_filename, update=1) sql_lyr = ds.ExecuteSQL("SELECT CreateSpatialIndex('poly', 'geom')") f = sql_lyr.GetNextFeature() - if f.GetField(0) != 1: - return 'fail' + assert f.GetField(0) == 1 ds.ReleaseResultSet(sql_lyr) ds = None @@ -4361,9 +3888,7 @@ def test_ogr_gpkg_savepoint(): ds = ogr.Open(filename) lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 2: - print(lyr.GetFeatureCount()) - return 'fail' + assert lyr.GetFeatureCount() == 2 ds = None gdal.Unlink(filename) @@ -4430,16 +3955,14 @@ def test_ogr_gpkg_json(): fld_defn = ogr.FieldDefn('test_json', ogr.OFTString) fld_defn.SetSubType(ogr.OFSTJSON) lyr.CreateField(fld_defn) - if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() == ogr.OFSTJSON ds.ReleaseResultSet(ds.ExecuteSQL('SELECT 1 FROM test')) # will crystalize fld_defn = ogr.FieldDefn('test2_json', ogr.OFTString) fld_defn.SetSubType(ogr.OFSTJSON) lyr.CreateField(fld_defn) - if lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTJSON: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() == ogr.OFSTJSON fld_defn = ogr.FieldDefn('test_string', ogr.OFTString) lyr.CreateField(fld_defn) @@ -4448,46 +3971,36 @@ def test_ogr_gpkg_json(): ds = ogr.Open(filename, update = 1) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() != ogr.OFSTJSON: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() != ogr.OFSTJSON: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetSubType() == ogr.OFSTJSON + assert lyr.GetLayerDefn().GetFieldDefn(1).GetSubType() == ogr.OFSTJSON # Demote field from JSON new_defn = ogr.FieldDefn('test_was_json_now_string', ogr.OFTString) - if lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test2_json'), new_defn, ogr.ALTER_ALL_FLAG) != 0: - return 'fail' + assert lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test2_json'), new_defn, ogr.ALTER_ALL_FLAG) == 0 # Alter field to JSON new_defn = ogr.FieldDefn('test_was_string_now_json', ogr.OFTString) new_defn.SetSubType(ogr.OFSTJSON) - if lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test_string'), new_defn, ogr.ALTER_ALL_FLAG) != 0: - return 'fail' + assert lyr.AlterFieldDefn(lyr.GetLayerDefn().GetFieldIndex('test_string'), new_defn, ogr.ALTER_ALL_FLAG) == 0 # Delete JSON field - if lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('test_json')) != 0: - return 'fail' + assert lyr.DeleteField(lyr.GetLayerDefn().GetFieldIndex('test_json')) == 0 ds = None - if not validate(filename): - gdaltest.post_reason('validation failed') - return 'fail' + assert validate(filename), 'validation failed' ds = ogr.Open(filename) lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldDefn( - lyr.GetLayerDefn().GetFieldIndex('test_was_json_now_string')).GetSubType() != ogr.OFSTNone: - return 'fail' - if lyr.GetLayerDefn().GetFieldDefn( - lyr.GetLayerDefn().GetFieldIndex('test_was_string_now_json')).GetSubType() != ogr.OFSTJSON: - return 'fail' + assert (lyr.GetLayerDefn().GetFieldDefn( + lyr.GetLayerDefn().GetFieldIndex('test_was_json_now_string')).GetSubType() == ogr.OFSTNone) + assert (lyr.GetLayerDefn().GetFieldDefn( + lyr.GetLayerDefn().GetFieldIndex('test_was_string_now_json')).GetSubType() == ogr.OFSTJSON) sql_lyr = ds.ExecuteSQL("SELECT 1 FROM gpkg_data_columns WHERE table_name = 'test'") fc = sql_lyr.GetFeatureCount() ds.ReleaseResultSet(sql_lyr) - if fc != 1: # only test_was_string_now_json remaining - return 'fail' + assert fc == 1 ds = None diff --git a/autotest/ogr/ogr_gpsbabel.py b/autotest/ogr/ogr_gpsbabel.py index fcddac8a5763..475fbd919bd9 100755 --- a/autotest/ogr/ogr_gpsbabel.py +++ b/autotest/ogr/ogr_gpsbabel.py @@ -74,11 +74,9 @@ def test_ogr_gpsbabel_1(): return 'skip' ds = ogr.Open('GPSBabel:nmea:data/nmea.txt') - if ds is None: - return 'fail' + assert ds is not None - if ds.GetLayerCount() != 2: - return 'fail' + assert ds.GetLayerCount() == 2 return 'success' @@ -92,11 +90,9 @@ def test_ogr_gpsbabel_2(): return 'skip' ds = ogr.Open('data/nmea.txt') - if ds is None: - return 'fail' + assert ds is not None - if ds.GetLayerCount() != 2: - return 'fail' + assert ds.GetLayerCount() == 2 return 'success' @@ -137,12 +133,9 @@ def test_ogr_gpsbabel_3(): gdal.Unlink('tmp/nmea.txt') - if res.find('$GPRMC') == -1 or \ + assert (not (res.find('$GPRMC') == -1 or \ res.find('$GPGGA') == -1 or \ - res.find('$GPGSA') == -1: - gdaltest.post_reason('did not get expected result') - print(res) - return 'fail' + res.find('$GPGSA') == -1)), 'did not get expected result' return 'success' diff --git a/autotest/ogr/ogr_gpx.py b/autotest/ogr/ogr_gpx.py index 8f872dfa5e4d..73c946d050ce 100755 --- a/autotest/ogr/ogr_gpx.py +++ b/autotest/ogr/ogr_gpx.py @@ -50,9 +50,7 @@ def test_ogr_gpx_init(): if not gdaltest.have_gpx: return 'skip' - if gdaltest.gpx_ds.GetLayerCount() != 5: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert gdaltest.gpx_ds.GetLayerCount() == 5, 'wrong number of layers' return 'success' @@ -64,8 +62,7 @@ def test_ogr_gpx_1(): if not gdaltest.have_gpx: return 'skip' - if gdaltest.gpx_ds is None: - return 'fail' + assert gdaltest.gpx_ds is not None lyr = gdaltest.gpx_ds.GetLayerByName('waypoints') @@ -73,83 +70,72 @@ def test_ogr_gpx_1(): with gdaltest.error_handler(): tr = ogrtest.check_features_against_list(lyr, 'ele', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['waypoint name', None] tr = ogrtest.check_features_against_list(lyr, 'name', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['href', None] tr = ogrtest.check_features_against_list(lyr, 'link1_href', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['text', None] tr = ogrtest.check_features_against_list(lyr, 'link1_text', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['type', None] tr = ogrtest.check_features_against_list(lyr, 'link1_type', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['href2', None] tr = ogrtest.check_features_against_list(lyr, 'link2_href', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['text2', None] tr = ogrtest.check_features_against_list(lyr, 'link2_text', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['type2', None] tr = ogrtest.check_features_against_list(lyr, 'link2_type', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() expect = ['2007/11/25 17:58:00+01', None] tr = ogrtest.check_features_against_list(lyr, 'time', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (1 0)', - max_error=0.0001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'POINT (1 0)', + max_error=0.0001) == 0) feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (4 3)', - max_error=0.0001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(feat, 'POINT (4 3)', + max_error=0.0001) == 0) return 'success' @@ -161,19 +147,16 @@ def test_ogr_gpx_2(): if not gdaltest.have_gpx: return 'skip' - if gdaltest.gpx_ds is None: - return 'fail' + assert gdaltest.gpx_ds is not None lyr = gdaltest.gpx_ds.GetLayerByName('routes') lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING (6 5,9 8,12 11)', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING (6 5,9 8,12 11)', max_error=0.0001) == 0 feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'LINESTRING EMPTY', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'LINESTRING EMPTY', max_error=0.0001) == 0 return 'success' @@ -185,21 +168,18 @@ def test_ogr_gpx_3(): if not gdaltest.have_gpx: return 'skip' - if gdaltest.gpx_ds is None: - return 'fail' + assert gdaltest.gpx_ds is not None lyr = gdaltest.gpx_ds.GetLayerByName('route_points') expect = ['route point name', None, None] tr = ogrtest.check_features_against_list(lyr, 'name', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (6 5)', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'POINT (6 5)', max_error=0.0001) == 0 return 'success' @@ -211,24 +191,20 @@ def test_ogr_gpx_4(): if not gdaltest.have_gpx: return 'skip' - if gdaltest.gpx_ds is None: - return 'fail' + assert gdaltest.gpx_ds is not None lyr = gdaltest.gpx_ds.GetLayerByName('tracks') lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((15 14,18 17),(21 20,24 23))', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'MULTILINESTRING ((15 14,18 17),(21 20,24 23))', max_error=0.0001) == 0 feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'MULTILINESTRING EMPTY', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'MULTILINESTRING EMPTY', max_error=0.0001) == 0 feat = lyr.GetNextFeature() f_geom = feat.GetGeometryRef() - if f_geom.ExportToWkt() != 'MULTILINESTRING EMPTY': - return 'fail' + assert f_geom.ExportToWkt() == 'MULTILINESTRING EMPTY' return 'success' @@ -240,21 +216,18 @@ def test_ogr_gpx_5(): if not gdaltest.have_gpx: return 'skip' - if gdaltest.gpx_ds is None: - return 'fail' + assert gdaltest.gpx_ds is not None lyr = gdaltest.gpx_ds.GetLayerByName('track_points') expect = ['track point name', None, None, None] tr = ogrtest.check_features_against_list(lyr, 'name', expect) - if not tr: - return 'fail' + assert tr lyr.ResetReading() feat = lyr.GetNextFeature() - if ogrtest.check_feature_geometry(feat, 'POINT (15 14)', max_error=0.0001) != 0: - return 'fail' + assert ogrtest.check_feature_geometry(feat, 'POINT (15 14)', max_error=0.0001) == 0 return 'success' @@ -293,9 +266,7 @@ def test_ogr_gpx_6(): feat = gpx_lyr.GetNextFeature() while feat is not None: dst_feat.SetFrom(feat) - if gpx2_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert gpx2_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = gpx_lyr.GetNextFeature() @@ -311,9 +282,7 @@ def test_ogr_gpx_6(): feat = gpx_lyr.GetNextFeature() while feat is not None: dst_feat.SetFrom(feat) - if gpx2_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert gpx2_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = gpx_lyr.GetNextFeature() @@ -329,9 +298,7 @@ def test_ogr_gpx_6(): feat = gpx_lyr.GetNextFeature() while feat is not None: dst_feat.SetFrom(feat) - if gpx2_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert gpx2_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = gpx_lyr.GetNextFeature() @@ -383,9 +350,7 @@ def test_ogr_gpx_7(): feat = bna_lyr.GetNextFeature() while feat is not None: dst_feat.SetFrom(feat) - if gpx_lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert gpx_lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' feat = bna_lyr.GetNextFeature() @@ -398,24 +363,21 @@ def test_ogr_gpx_7(): expect = ['PID1', 'PID2'] tr = ogrtest.check_features_against_list(gpx_lyr, 'ogr_Primary_ID', expect) - if not tr: - return 'fail' + assert tr gpx_lyr.ResetReading() expect = ['SID1', 'SID2'] tr = ogrtest.check_features_against_list(gpx_lyr, 'ogr_Secondary_ID', expect) - if not tr: - return 'fail' + assert tr gpx_lyr.ResetReading() expect = ['TID1', None] tr = ogrtest.check_features_against_list(gpx_lyr, 'ogr_Third_ID', expect) - if not tr: - return 'fail' + assert tr return 'success' @@ -507,10 +469,7 @@ def test_ogr_gpx_8(): f.close() f_ref.close() - if f_content.find(f_ref_content) == -1: - gdaltest.post_reason('did not get expected result') - print(f_content) - return 'fail' + assert f_content.find(f_ref_content) != -1, 'did not get expected result' return 'success' diff --git a/autotest/ogr/ogr_grass.py b/autotest/ogr/ogr_grass.py index eca1cb77aa34..21a444aba397 100755 --- a/autotest/ogr/ogr_grass.py +++ b/autotest/ogr/ogr_grass.py @@ -56,23 +56,15 @@ def test_ogr_grass_2(): return 'skip' ds = ogr.Open('./data/PERMANENT/vector/point/head') - if ds is None: - gdaltest.post_reason('Cannot open datasource') - return 'fail' + assert ds is not None, 'Cannot open datasource' lyr = ds.GetLayerByName('1') - if lyr is None: - gdaltest.post_reason('Cannot find layer') - return 'fail' + assert lyr is not None, 'Cannot find layer' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'POINT (0 0)': - print(feat.GetGeometryRef().ExportToWkt()) - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'POINT (0 0)' - if feat.GetFieldAsString('name') != 'my point': - print(feat.GetFieldAsString('name')) - return 'fail' + assert feat.GetFieldAsString('name') == 'my point' ds = None diff --git a/autotest/ogr/ogr_gtm.py b/autotest/ogr/ogr_gtm.py index 6ac241e85ed5..0181c85d37f1 100755 --- a/autotest/ogr/ogr_gtm.py +++ b/autotest/ogr/ogr_gtm.py @@ -51,9 +51,7 @@ def test_ogr_gtm_init(): if not gdaltest.have_gtm: return 'skip' - if gdaltest.gtm_ds.GetLayerCount() != 2: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert gdaltest.gtm_ds.GetLayerCount() == 2, 'wrong number of layers' return 'success' @@ -65,86 +63,54 @@ def test_ogr_gtm_read_1(): if not gdaltest.have_gtm: return 'skip' - if gdaltest.gtm_ds is None: - return 'fail' + assert gdaltest.gtm_ds is not None lyr = gdaltest.gtm_ds.GetLayerByName('samplemap_waypoints') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('wrong number of features') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'wrong number of features' # Test 1st feature feat = lyr.GetNextFeature() - if feat.GetField('name') != 'WAY6': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'WAY6', 'Wrong name field value' - if feat.GetField('comment') != 'Santa Cruz Stadium': - gdaltest.post_reason('Wrong comment field value') - return 'fail' + assert feat.GetField('comment') == 'Santa Cruz Stadium', 'Wrong comment field value' - if feat.GetField('icon') != 92: - gdaltest.post_reason('Wrong icon field value') - return 'fail' + assert feat.GetField('icon') == 92, 'Wrong icon field value' - if feat.GetField('time') != '2009/12/18 17:32:41': - gdaltest.post_reason('Wrong time field value') - return 'fail' + assert feat.GetField('time') == '2009/12/18 17:32:41', 'Wrong time field value' wkt = 'POINT (-47.789974212646484 -21.201919555664062)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 2nd feature feat = lyr.GetNextFeature() - if feat.GetField('name') != 'WAY6': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'WAY6', 'Wrong name field value' - if feat.GetField('comment') != 'Joe\'s Goalkeeper Pub': - gdaltest.post_reason('Wrong comment field value') - return 'fail' + assert feat.GetField('comment') == 'Joe\'s Goalkeeper Pub', \ + 'Wrong comment field value' - if feat.GetField('icon') != 4: - gdaltest.post_reason('Wrong icon field value') - return 'fail' + assert feat.GetField('icon') == 4, 'Wrong icon field value' - if feat.GetField('time') != '2009/12/18 17:34:46': - gdaltest.post_reason('Wrong time field value') - return 'fail' + assert feat.GetField('time') == '2009/12/18 17:34:46', 'Wrong time field value' wkt = 'POINT (-47.909481048583984 -21.294229507446289)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 3rd feature feat = lyr.GetNextFeature() - if feat.GetField('name') != '33543400': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == '33543400', 'Wrong name field value' - if feat.GetField('comment') != 'City Hall': - gdaltest.post_reason('Wrong comment field value') - return 'fail' + assert feat.GetField('comment') == 'City Hall', 'Wrong comment field value' - if feat.GetField('icon') != 61: - gdaltest.post_reason('Wrong icon field value') - return 'fail' + assert feat.GetField('icon') == 61, 'Wrong icon field value' - if feat.GetField('time') is not None: - gdaltest.post_reason('Wrong time field value') - return 'fail' + assert feat.GetField('time') is None, 'Wrong time field value' wkt = 'POINT (-47.806097491943362 -21.176849600708007)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' return 'success' @@ -156,29 +122,20 @@ def test_ogr_gtm_read_2(): if not gdaltest.have_gtm: return 'skip' - if gdaltest.gtm_ds is None: - return 'fail' + assert gdaltest.gtm_ds is not None lyr = gdaltest.gtm_ds.GetLayerByName('samplemap_tracks') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('wrong number of features') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'wrong number of features' # Test 1st feature feat = lyr.GetNextFeature() - if feat.GetField('name') != 'San Sebastian Street': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'San Sebastian Street', 'Wrong name field value' - if feat.GetField('type') != 2: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 2, 'Wrong type field value' - if feat.GetField('color') != 0: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 0, 'Wrong color field value' # if feat.GetField('time') is not None: # gdaltest.post_reason( 'Wrong time field value' ) @@ -188,24 +145,16 @@ def test_ogr_gtm_read_2(): '-47.808151245117188 -21.177299499511719,' + \ '-47.809136624130645 -21.176562836150087,' + \ '-47.809931418108405 -21.175971104366582)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 2nd feature feat = lyr.GetNextFeature() - if feat.GetField('name') != 'Barao do Amazonas Street': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'Barao do Amazonas Street', 'Wrong name field value' - if feat.GetField('type') != 1: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 1, 'Wrong type field value' - if feat.GetField('color') != 0: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 0, 'Wrong color field value' # if feat.GetField('time') is not None: # gdaltest.post_reason( 'Wrong time field value' ) @@ -215,23 +164,16 @@ def test_ogr_gtm_read_2(): '-47.808151245117188 -21.177299499511719,' + \ '-47.807561550927701 -21.176617693474089,' + \ '-47.806959118447779 -21.175900153727685)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) # Test 3rd feature feat = lyr.GetNextFeature() - if feat.GetField('name') != 'Curupira Park': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'Curupira Park', 'Wrong name field value' - if feat.GetField('type') != 17: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 17, 'Wrong type field value' - if feat.GetField('color') != 46848: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 46848, 'Wrong color field value' # if feat.GetField('time') is not None: # gdaltest.post_reason( 'Wrong time field value' ) @@ -245,9 +187,7 @@ def test_ogr_gtm_read_2(): '-47.792263031005859 -21.194267272949219,' + \ '-47.7894287109375 -21.194473266601562)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' return 'success' @@ -268,18 +208,14 @@ def test_ogr_gtm_write_1(): dst_feat.SetField('icon', 10) dst_feat.SetField('time', '2009/12/23 14:25:46') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (-21 -47)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetField('name', 'WAY0000001') dst_feat.SetField('comment', 'Waypoint 1') dst_feat.SetField('icon', 31) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (-21.123 -47.231 800)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' lyr = ds.CreateLayer('gtm_tracks', geom_type=ogr.wkbLineString) @@ -288,18 +224,14 @@ def test_ogr_gtm_write_1(): dst_feat.SetField('type', 2) dst_feat.SetField('color', 0x0000FF) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('LINESTRING (-21.1 -47.1, -21.2 -47.2, -21.3 -47.3, -21.4 -47.4)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetField('name', '2nd Street') dst_feat.SetField('type', 1) dst_feat.SetField('color', 0x000000) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('LINESTRING (-21.11 -47.1, -21.21 -47.2, -21.31 -47.3, -21.41 -47.4)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetField('name', '3rd Street') @@ -307,9 +239,7 @@ def test_ogr_gtm_write_1(): dst_feat.SetField('color', 0x000000) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTILINESTRING ((-21.12 -47.1, -21.22 -47.2, -21.32 -47.3, -21.42 -47.4),' + '(-21.12 -47.1, -21.02 -47.0, -20.92 -46.9))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None @@ -325,145 +255,87 @@ def test_ogr_gtm_check_write_1(): ds = ogr.Open('tmp/gtm.gtm') lyr = ds.GetLayerByName('gtm_waypoints') - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('Bad feature count.') - return 'fail' + assert lyr.GetFeatureCount() == 2, 'Bad feature count.' # Test 1st waypoint feat = lyr.GetNextFeature() - if feat.GetField('name') != 'WAY0000000': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'WAY0000000', 'Wrong name field value' - if feat.GetField('comment') != 'Waypoint 0': - gdaltest.post_reason('Wrong comment field value') - return 'fail' + assert feat.GetField('comment') == 'Waypoint 0', 'Wrong comment field value' - if feat.GetField('icon') != 10: - gdaltest.post_reason('Wrong icon field value') - return 'fail' + assert feat.GetField('icon') == 10, 'Wrong icon field value' - if feat.GetField('time') != '2009/12/23 14:25:46': - gdaltest.post_reason('Wrong time field value') - return 'fail' + assert feat.GetField('time') == '2009/12/23 14:25:46', 'Wrong time field value' wkt = 'POINT (-21 -47)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 2nd waypoint feat = lyr.GetNextFeature() - if feat.GetField('name') != 'WAY0000001': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == 'WAY0000001', 'Wrong name field value' - if feat.GetField('comment') != 'Waypoint 1': - gdaltest.post_reason('Wrong comment field value') - return 'fail' + assert feat.GetField('comment') == 'Waypoint 1', 'Wrong comment field value' - if feat.GetField('icon') != 31: - gdaltest.post_reason('Wrong icon field value') - return 'fail' + assert feat.GetField('icon') == 31, 'Wrong icon field value' - if feat.GetField('time') is not None: - gdaltest.post_reason('Wrong time field value') - return 'fail' + assert feat.GetField('time') is None, 'Wrong time field value' wkt = 'POINT (-21.123 -47.231 800)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test tracks lyr = ds.GetLayerByName('gtm_tracks') - if lyr.GetFeatureCount() != 4: # The driver converts multiline - # into one line for each tuple - # element - gdaltest.post_reason('Bad feature count.') - return 'fail' + assert lyr.GetFeatureCount() == 4, 'Bad feature count.' # Test 1st track feat = lyr.GetNextFeature() - if feat.GetField('name') != '1st Street': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == '1st Street', 'Wrong name field value' - if feat.GetField('type') != 2: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 2, 'Wrong type field value' - if feat.GetField('color') != 0x0000FF: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 0x0000FF, 'Wrong color field value' wkt = 'LINESTRING (-21.1 -47.1, -21.2 -47.2, -21.3 -47.3, -21.4 -47.4)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 2nd track feat = lyr.GetNextFeature() - if feat.GetField('name') != '2nd Street': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == '2nd Street', 'Wrong name field value' - if feat.GetField('type') != 1: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 1, 'Wrong type field value' - if feat.GetField('color') != 0x000000: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 0x000000, 'Wrong color field value' wkt = 'LINESTRING (-21.11 -47.1, -21.21 -47.2, -21.31 -47.3, -21.41 -47.4)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 3rd track feat = lyr.GetNextFeature() - if feat.GetField('name') != '3rd Street': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == '3rd Street', 'Wrong name field value' - if feat.GetField('type') != 2: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 2, 'Wrong type field value' - if feat.GetField('color') != 0x000000: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 0x000000, 'Wrong color field value' wkt = 'LINESTRING (-21.12 -47.1, -21.22 -47.2, -21.32 -47.3, -21.42 -47.4)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' # Test 4th track feat = lyr.GetNextFeature() - if feat.GetField('name') != '3rd Street': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('name') == '3rd Street', 'Wrong name field value' - if feat.GetField('type') != 2: - gdaltest.post_reason('Wrong type field value') - return 'fail' + assert feat.GetField('type') == 2, 'Wrong type field value' - if feat.GetField('color') != 0x000000: - gdaltest.post_reason('Wrong color field value') - return 'fail' + assert feat.GetField('color') == 0x000000, 'Wrong color field value' wkt = 'LINESTRING (-21.12 -47.1, -21.02 -47.0, -20.92 -46.9)' - if ogrtest.check_feature_geometry(feat, wkt): - gdaltest.post_reason('Unexpected geometry') - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt), 'Unexpected geometry' return 'success' diff --git a/autotest/ogr/ogr_htf.py b/autotest/ogr/ogr_htf.py index c4531c01bbb4..246626477ce0 100755 --- a/autotest/ogr/ogr_htf.py +++ b/autotest/ogr/ogr_htf.py @@ -34,6 +34,7 @@ import gdaltest import ogrtest from osgeo import ogr +import pytest ############################################################################### # Basic test @@ -42,62 +43,43 @@ def test_ogr_htf_1(): ds = ogr.Open('data/test.htf') - if ds is None: - gdaltest.post_reason('cannot open dataset') - return 'fail' + assert ds is not None, 'cannot open dataset' lyr = ds.GetLayer(0) - if lyr.GetName() != 'polygon': - gdaltest.post_reason('layer 0 is not polygon') - return 'fail' + assert lyr.GetName() == 'polygon', 'layer 0 is not polygon' lyr = ds.GetLayerByName('polygon') - if lyr is None: - gdaltest.post_reason('cannot find layer polygon') - return 'fail' + assert lyr is not None, 'cannot find layer polygon' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() if ogrtest.check_feature_geometry(feat, 'POLYGON ((320830 7678810,350840 7658030,308130 7595560,278310 7616820,320830 7678810))', max_error=0.0000001) != 0: - gdaltest.post_reason('did not get expected first geom') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('did not get expected first geom') feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() if ogrtest.check_feature_geometry(feat, 'POLYGON ((320830 7678810,350840 7658030,308130 7595560,278310 7616820,320830 7678810),(0 0,0 1,1 1,0 0))', max_error=0.0000001) != 0: - gdaltest.post_reason('did not get expected first geom') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('did not get expected first geom') - if feat.GetField('IDENTIFIER') != 2: - gdaltest.post_reason('did not get expected identifier') - print(feat.GetField('IDENTIFIER')) - return 'fail' + assert feat.GetField('IDENTIFIER') == 2, 'did not get expected identifier' lyr = ds.GetLayerByName('sounding') - if lyr is None: - gdaltest.post_reason('cannot find layer sounding') - return 'fail' + assert lyr is not None, 'cannot find layer sounding' - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('did not get expected feature count') - return 'fail' + assert lyr.GetFeatureCount() == 2, 'did not get expected feature count' feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() if ogrtest.check_feature_geometry(feat, 'POINT (278670 7616330)', max_error=0.0000001) != 0: - gdaltest.post_reason('did not get expected first geom') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('did not get expected first geom') - if feat.GetField('other3') != 'other3': - gdaltest.post_reason('did not get expected other3 val') - print(feat.GetField('other3')) - return 'fail' + assert feat.GetField('other3') == 'other3', 'did not get expected other3 val' return 'success' @@ -113,15 +95,11 @@ def test_ogr_htf_2(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro data/test.htf') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro data/test.htf metadata') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' diff --git a/autotest/ogr/ogr_idrisi.py b/autotest/ogr/ogr_idrisi.py index 31f9303ece09..719453f58596 100755 --- a/autotest/ogr/ogr_idrisi.py +++ b/autotest/ogr/ogr_idrisi.py @@ -42,36 +42,25 @@ def test_ogr_idrisi_1(): ds = ogr.Open('data/points.vct') - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbPoint: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPoint - if lyr.GetLayerDefn().GetFieldDefn(1).GetName() != 'IntegerField': - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(1).GetName() == 'IntegerField' - if lyr.GetLayerDefn().GetFieldDefn(1).GetType() != ogr.OFTInteger: - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(1).GetType() == ogr.OFTInteger sr = lyr.GetSpatialRef() - if sr.ExportToWkt().find('PROJCS["UTM Zone 31, Northern Hemisphere"') != 0: - print(sr.ExportToWkt()) - return 'fail' + assert sr.ExportToWkt().find('PROJCS["UTM Zone 31, Northern Hemisphere"') == 0 - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 - if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 1 - if lyr.TestCapability(ogr.OLCFastGetExtent) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastGetExtent) == 1 - if lyr.GetExtent() != (400000.0, 600000.0, 4000000.0, 5000000.0): - print(lyr.GetExtent()) - return 'fail' + assert lyr.GetExtent() == (400000.0, 600000.0, 4000000.0, 5000000.0) feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 1.0: @@ -113,8 +102,7 @@ def test_ogr_idrisi_1(): lyr.SetSpatialFilterRect(0, 0, 1, 1) lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None ds = None @@ -127,25 +115,18 @@ def test_ogr_idrisi_1(): def test_ogr_idrisi_2(): ds = ogr.Open('data/lines.vct') - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbLineString: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbLineString - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 - if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 1 - if lyr.TestCapability(ogr.OLCFastGetExtent) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastGetExtent) == 1 - if lyr.GetExtent() != (400000.0, 600000.0, 4000000.0, 5000000.0): - print(lyr.GetExtent()) - return 'fail' + assert lyr.GetExtent() == (400000.0, 600000.0, 4000000.0, 5000000.0) feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 10.0: @@ -168,8 +149,7 @@ def test_ogr_idrisi_2(): lyr.SetSpatialFilterRect(0, 0, 1, 1) lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None ds = None @@ -182,25 +162,18 @@ def test_ogr_idrisi_2(): def test_ogr_idrisi_3(): ds = ogr.Open('data/polygons.vct') - if ds is None: - return 'fail' + assert ds is not None lyr = ds.GetLayer(0) - if lyr.GetGeomType() != ogr.wkbPolygon: - return 'fail' + assert lyr.GetGeomType() == ogr.wkbPolygon - if lyr.GetFeatureCount() != 2: - return 'fail' + assert lyr.GetFeatureCount() == 2 - if lyr.TestCapability(ogr.OLCFastFeatureCount) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastFeatureCount) == 1 - if lyr.TestCapability(ogr.OLCFastGetExtent) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCFastGetExtent) == 1 - if lyr.GetExtent() != (400000.0, 600000.0, 4000000.0, 5000000.0): - print(lyr.GetExtent()) - return 'fail' + assert lyr.GetExtent() == (400000.0, 600000.0, 4000000.0, 5000000.0) feat = lyr.GetNextFeature() if feat.GetFieldAsDouble(0) != 1.0: @@ -223,8 +196,7 @@ def test_ogr_idrisi_3(): lyr.SetSpatialFilterRect(0, 0, 1, 1) lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None ds = None diff --git a/autotest/ogr/ogr_ili.py b/autotest/ogr/ogr_ili.py index b31cac532d04..30347f6d45a5 100755 --- a/autotest/ogr/ogr_ili.py +++ b/autotest/ogr/ogr_ili.py @@ -33,6 +33,7 @@ import ogrtest from osgeo import gdal from osgeo import ogr +import pytest def cpl_debug_on(): @@ -75,20 +76,14 @@ def test_ogr_interlis1_2(): 'Bodenbedeckung__BoFlaechen_Form', 'Bodenbedeckung__Strasse', 'Bodenbedeckung__Gebaeude'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('Bodenbedeckung__BoFlaechen') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'feature count wrong.' # Get 2nd feature feat = lyr.GetNextFeature() @@ -96,9 +91,7 @@ def test_ogr_interlis1_2(): field_values = [20, 1, 168.27, 170.85] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -108,18 +101,12 @@ def test_ogr_interlis1_2(): return 'fail' geom = feat.GetGeomFieldRef(0) - if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('dimension wrong.') - return 'fail' + assert geom.GetCoordinateDimension() == 2, 'dimension wrong.' geom = feat.GetGeomFieldRef(1) - if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('dimension wrong.') - return 'fail' + assert geom.GetCoordinateDimension() == 2, 'dimension wrong.' geom = feat.GetGeometryRef() - if geom.GetGeometryName() != 'POLYGON': - gdaltest.post_reason('Geometry of wrong type.') - return 'fail' + assert geom.GetGeometryName() == 'POLYGON', 'Geometry of wrong type.' return 'success' @@ -135,28 +122,20 @@ def test_ogr_interlis1_3(): ds = ogr.Open('data/ili/format-default.itf,data/ili/format-default.imd') layers = ['FormatTests__FormatTable'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('FormatTests__FormatTable') - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() field_values = [0, 'aa bb', 'cc^dd', '', 1] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -179,28 +158,20 @@ def test_ogr_interlis1_4(): ds = ogr.Open('data/ili/format-test.itf,data/ili/format-test.imd') layers = ['FormatTests__FormatTable'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('FormatTests__FormatTable') - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() field_values = [0, 'aa_bb', 'cc dd', '', 1] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -254,9 +225,7 @@ def test_ogr_interlis1_5(): ETOP EMOD ENDE""" - if expected not in itf: - gdaltest.post_reason("Interlis output doesn't match.") - return 'fail' + assert expected in itf, "Interlis output doesn't match." return 'success' @@ -299,10 +268,7 @@ def test_ogr_interlis1_6(): ETOP EMOD ENDE""" - if expected not in itf: - gdaltest.post_reason("Interlis output doesn't match.") - print(itf) - return 'fail' + assert expected in itf, "Interlis output doesn't match." return 'success' @@ -318,20 +284,14 @@ def test_ogr_interlis1_7(): ds = ogr.Open('data/ili/encoding-test.itf,data/ili/format-default.imd') layers = ['FormatTests__FormatTable'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('FormatTests__FormatTable') - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -339,9 +299,7 @@ def test_ogr_interlis1_7(): # Python source code is UTF-8 encoded field_values = [0, 'äöü', 'ÄÖÜ', '', 1] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -385,10 +343,7 @@ def test_ogr_interlis1_7(): expected = expected.decode('utf8').encode('iso-8859-1') except: pass - if expected not in itf: - gdaltest.post_reason("Interlis output doesn't match.") - print(itf) - return 'fail' + assert expected in itf, "Interlis output doesn't match." return 'success' @@ -403,32 +358,23 @@ def test_ogr_interlis1_9(): ds = ogr.Open('data/ili/Beispiel-rename.vrt') layers = ['BoGebaeude'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('BoGebaeude') - if lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef() != 'AssekuranzNr': - gdaltest.post_reason('Wrong field name: ' + lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef()) - return 'fail' + assert lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef() == 'AssekuranzNr', \ + ('Wrong field name: ' + lyr.GetLayerDefn().GetFieldDefn(0).GetNameRef()) - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() field_values = ['958', 10, 'POINT (148.41 175.96)'] - if feat.GetFieldCount() != len(field_values) - 1: - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values) - 1, 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -455,17 +401,12 @@ def test_ogr_interlis1_10(): lyr = ds.GetLayerByName('Bodenbedeckung__BoFlaechen') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'feature count wrong.' feat = lyr.GetNextFeature() geom_field_values = ['POLYGON ((146.92 174.98,138.68 187.51,147.04 193.0,149.79 188.82,158.15 194.31,163.64 185.96,146.92 174.98))', 'POINT (148.2 183.48)'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -487,20 +428,14 @@ def test_ogr_interlis1_11(): ds = ogr.Open('data/ili/multigeom.itf,data/ili/multigeom.imd') layers = ['MultigeomTests__MultigeomTable'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('MultigeomTests__MultigeomTable') - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -512,23 +447,15 @@ def test_ogr_interlis1_11(): # GeomPoint_0 (Real) = 148.41 # GeomPoint_1 (Real) = 175.96 - if feat.GetFieldCount() != 5: - gdaltest.post_reason('field count wrong.') - print(feat.GetFieldCount()) - return 'fail' + assert feat.GetFieldCount() == 5, 'field count wrong.' geom_columns = ['GeomLine', 'GeomPoint'] - if feat.GetGeomFieldCount() != len(geom_columns): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_columns), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): defn = lyr.GetLayerDefn().GetGeomFieldDefn(i) - if defn.GetName() != str(geom_columns[i]): - print("Geom field: " + defn.GetName()) - return 'fail' + assert defn.GetName() == str(geom_columns[i]), ("Geom field: " + defn.GetName()) return 'success' @@ -544,20 +471,14 @@ def test_ogr_interlis1_12(): ds = ogr.Open('data/ili/multicoord.itf,data/ili/multicoord.imd') layers = ['MulticoordTests__MulticoordTable'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('MulticoordTests__MulticoordTable') - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -568,16 +489,11 @@ def test_ogr_interlis1_12(): geom_columns = ['coordPoint1', 'coordPoint2'] - if feat.GetGeomFieldCount() != len(geom_columns): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_columns), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): defn = lyr.GetLayerDefn().GetGeomFieldDefn(i) - if defn.GetName() != str(geom_columns[i]): - print("Geom field: " + defn.GetName()) - return 'fail' + assert defn.GetName() == str(geom_columns[i]), ("Geom field: " + defn.GetName()) return 'success' @@ -601,34 +517,24 @@ def test_ogr_interlis1_13(): 'SURFC_TOP__Flaechenelement_Geometrie' ] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('SURFC_TOP__SURFC_TBL_SHAPE') - if lyr.GetFeatureCount() != 5: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 5, 'feature count wrong.' lyr = ds.GetLayerByName('SURFC_TOP__SURFC_TBL') - if lyr.GetFeatureCount() != 4: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 4, 'feature count wrong.' feat = lyr.GetNextFeature() field_values = ['103', 1, 3, 1, 23, 25000, 20060111] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -639,10 +545,7 @@ def test_ogr_interlis1_13(): geom_field_values = ['CURVEPOLYGON (COMPOUNDCURVE ((598600.961 249487.174,598608.899 249538.768,598624.774 249594.331,598648.586 249630.05,598684.305 249661.8,598763.68 249685.612,598850.993 249685.612,598854.962 249618.143,598843.055 249550.675,598819.243 249514.956,598763.68 249479.237,598692.243 249447.487,598612.868 249427.643,598600.961 249487.174)))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -655,10 +558,7 @@ def test_ogr_interlis1_13(): feat = lyr.GetNextFeature() geom_field_values = ['CURVEPOLYGON (COMPOUNDCURVE ((598131.445 249100.621,598170.131 249095.094,598200.448 249085.393),CIRCULARSTRING (598200.448 249085.393,598239.253 249062.352,598246.529 249044.162),(598246.529 249044.162,598245.316 249025.972,598229.552 249017.483,598165.28 249035.673,598134.963 249049.013,598130.273 249052.095,598131.445 249100.621)))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -672,9 +572,7 @@ def test_ogr_interlis1_13(): feat = lyr.GetNextFeature() field_values = ['106', 3, 3, 1, 23, 25000, 20060111] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -686,10 +584,7 @@ def test_ogr_interlis1_13(): # FIXME: note this is an invalid curve polygon. The two rings are completely disjoint, so this should be a multisurface instead. geom_field_values = ['CURVEPOLYGON (COMPOUNDCURVE ((747951.24 265833.326,747955.101 265828.716,747954.975 265827.862,747951.166 265828.348,747951.24 265833.326)),COMPOUNDCURVE ((747925.762 265857.606,747927.618 265861.533,747928.237 265860.794,747930.956 265857.547,747925.762 265857.606)))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -773,9 +668,7 @@ def test_ogr_interlis1_13(): # return 'fail' lyr = ds.GetLayerByName('SURFC_TOP__Flaechenelement_Geometrie') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -798,9 +691,7 @@ def test_ogr_interlis1_13(): return 'fail' lyr = ds.GetLayerByName('SURFC_TOP__Flaechenelement') - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 2, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -859,34 +750,24 @@ def test_ogr_interlis1_13_linear(): 'SURFC_TOP__Flaechenelement_Geometrie' ] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('SURFC_TOP__SURFC_TBL_SHAPE') - if lyr.GetFeatureCount() != 5: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 5, 'feature count wrong.' lyr = ds.GetLayerByName('SURFC_TOP__SURFC_TBL') - if lyr.GetFeatureCount() != 4: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 4, 'feature count wrong.' feat = lyr.GetNextFeature() field_values = ['103', 1, 3, 1, 23, 25000, 20060111] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -897,10 +778,7 @@ def test_ogr_interlis1_13_linear(): geom_field_values = ['POLYGON ((598600.961 249487.174,598608.899 249538.768,598624.774 249594.331,598648.586 249630.05,598684.305 249661.8,598763.68 249685.612,598850.993 249685.612,598854.962 249618.143,598843.055 249550.675,598819.243 249514.956,598763.68 249479.237,598692.243 249447.487,598612.868 249427.643,598600.961 249487.174))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -912,10 +790,7 @@ def test_ogr_interlis1_13_linear(): geom_field_values = ['POLYGON ((598600.961 249487.174,598608.899 249538.768,598624.774 249594.331,598648.586 249630.05,598684.305 249661.8,598763.68 249685.612,598850.993 249685.612,598854.962 249618.143,598843.055 249550.675,598819.243 249514.956,598763.68 249479.237,598692.243 249447.487,598612.868 249427.643,598600.961 249487.174))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -930,9 +805,7 @@ def test_ogr_interlis1_13_linear(): # field_values = ['106', 3, 3, 1, 23, 25000, 20060111] field_values = ['105', 3, 3, 1, 23, 25000, 20060111] - if feat.GetFieldCount() != len(field_values): - gdaltest.post_reason('field count wrong.') - return 'fail' + assert feat.GetFieldCount() == len(field_values), 'field count wrong.' for i in range(feat.GetFieldCount()): if feat.GetFieldAsString(i) != str(field_values[i]): @@ -943,10 +816,7 @@ def test_ogr_interlis1_13_linear(): geom_field_values = ['POLYGON ((598330.204 249028.397,598344.756 249057.501,598390.838 249074.479,598422.367 249081.755,598459.96 249093.882,598493.915 249101.158,598523.019 249106.008,598563.038 249084.18,598589.716 249042.949,598603.056 249011.42,598607.907 248966.551,598577.59 248960.487,598493.915 248983.528,598424.793 248996.868,598359.308 249010.207,598330.204 249028.397))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -955,9 +825,7 @@ def test_ogr_interlis1_13_linear(): return 'fail' lyr = ds.GetLayerByName('SURFC_TOP__Flaechenelement_Geometrie') - if lyr.GetFeatureCount() != 3: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 3, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -980,9 +848,7 @@ def test_ogr_interlis1_13_linear(): return 'fail' lyr = ds.GetLayerByName('SURFC_TOP__Flaechenelement') - if lyr.GetFeatureCount() != 2: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 2, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -1053,10 +919,7 @@ def test_ogr_interlis1_14(): EMOD ENDE """ - if expected not in itf: - gdaltest.post_reason("Interlis output doesn't match.") - print(itf) - return 'fail' + assert expected in itf, "Interlis output doesn't match." return 'success' @@ -1070,8 +933,7 @@ def test_ogr_interlis2_1(): return 'skip' ds = ogr.Open('data/ili/RoadsExdm2ien.xml') - if ds is None: - return 'fail' + assert ds is not None layers = ['RoadsExdm2ben.Roads.LandCover', 'RoadsExdm2ben.Roads.Street', @@ -1079,14 +941,10 @@ def test_ogr_interlis2_1(): 'RoadsExdm2ben.Roads.StreetNamePosition', 'RoadsExdm2ien.RoadsExtended.RoadSign'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' return 'success' @@ -1100,8 +958,7 @@ def test_ogr_interlis2_2(): return 'skip' ds = ogr.Open('data/ili/RoadsExdm2ien.xml,data/ili/RoadsExdm2ien.imd') - if ds is None: - return 'fail' + assert ds is not None layers = ['RoadsExdm2ben.Roads.LAttrs', 'RoadsExdm2ben.Roads.LandCover', @@ -1110,19 +967,13 @@ def test_ogr_interlis2_2(): 'RoadsExdm2ien.RoadsExtended.StreetAxis', 'RoadsExdm2ien.RoadsExtended.RoadSign'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('RoadsExdm2ien.RoadsExtended.RoadSign') - if lyr.GetFeatureCount() != 4: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 4, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -1141,16 +992,11 @@ def test_ogr_interlis2_2(): return 'fail' geom = feat.GetGeometryRef() - if geom.GetCoordinateDimension() != 2: - gdaltest.post_reason('dimension wrong.') - return 'fail' + assert geom.GetCoordinateDimension() == 2, 'dimension wrong.' geom_field_values = ['POINT (69.389 92.056)'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -1159,18 +1005,13 @@ def test_ogr_interlis2_2(): return 'fail' lyr = ds.GetLayerByName('RoadsExdm2ien.RoadsExtended.StreetAxis') - if lyr.GetFeatureCount() != 7: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 7, 'feature count wrong.' feat = lyr.GetNextFeature() geom_field_values = ['LINESTRING (55.6 37.649,15.573 25.785)'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -1179,18 +1020,13 @@ def test_ogr_interlis2_2(): return 'fail' lyr = ds.GetLayerByName('RoadsExdm2ben.Roads.LandCover') - if lyr.GetFeatureCount() != 12: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 12, 'feature count wrong.' feat = lyr.GetNextFeature() geom_field_values = ['POLYGON ((39.038 60.315,41.2 59.302,43.362 60.315,44.713 66.268,45.794 67.662,48.766 67.408,53.36 64.115,56.197 62.595,57.818 63.862,58.899 68.928,55.927 72.348,47.955 75.515,42.281 75.388,39.308 73.235,36.741 69.688,35.525 66.268,35.661 63.735,37.957 61.455,39.038 60.315))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -1240,9 +1076,7 @@ def test_ogr_interlis2_3(): expected = """ @@ -1291,10 +1125,7 @@ def test_ogr_interlis2_3(): """ expected = expected.replace('.11499999999999', '.115') xtf = xtf.replace('.11499999999999', '.115') - if expected not in xtf: - gdaltest.post_reason("Interlis output doesn't match.") - print(xtf) - return 'fail' + assert expected in xtf, "Interlis output doesn't match." return 'success' ############################################################################### @@ -1307,8 +1138,7 @@ def test_ogr_interlis2_4(): return 'skip' ds = ogr.Open('data/ili/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf,data/ili/ch.bazl.sicherheitszonenplan.oereb_20131118.imd') - if ds is None: - return 'fail' + assert ds is not None layers = ['chGeoId10.BFSNr_', 'chGeoId10.Kanton_', @@ -1338,19 +1168,13 @@ def test_ogr_interlis2_4(): 'OeREBKRM09trsfr.Transferstruktur.HinweisVorschrift', 'OeREBKRM09vs.Vorschriften.Dokument'] - if ds.GetLayerCount() != len(layers): - gdaltest.post_reason('layer count wrong.') - return 'fail' + assert ds.GetLayerCount() == len(layers), 'layer count wrong.' for i in range(ds.GetLayerCount()): - if not ds.GetLayer(i).GetName() in layers: - gdaltest.post_reason('Did not get right layers') - return 'fail' + assert ds.GetLayer(i).GetName() in layers, 'Did not get right layers' lyr = ds.GetLayerByName('OeREBKRM09trsfr.Transferstruktur.Geometrie') - if lyr.GetFeatureCount() != 36: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 36, 'feature count wrong.' feat = lyr.GetNextFeature() @@ -1371,10 +1195,7 @@ def test_ogr_interlis2_4(): return 'fail' geom_field_values = [None, None, 'CURVEPOLYGON (COMPOUNDCURVE ((658593.928 254957.714,658511.628 254948.614,658418.028 254938.516,658106.426 254913.918,658192.222 254445.914,658771.228 254619.412,659667.232 254699.606,660369.238 254827.202,661016.442 255010.1,661279.644 255090.198,661866.648 255138.094,661784.45 255601.798,661211.146 255432.8,660320.54 255352.806,659523.436 255206.71,658703.528 254966.814,658624.228 254961.014,658593.928 254957.714)))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) @@ -1384,9 +1205,8 @@ def test_ogr_interlis2_4(): else: ok = ogrtest.check_feature_geometry(geom, val) == 0 if not ok: - gdaltest.post_reason('geom check failed.') print(geom) - return 'fail' + pytest.fail('geom check failed.') return 'success' @@ -1409,9 +1229,7 @@ def test_ogr_interlis_arc1(): # Read Area lines lyr = ds.GetLayerByName('Bodenbedeckung__BoFlaechen_Form') - if lyr.GetFeatureCount() != 4: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 4, 'feature count wrong.' # Get 3rd feature feat = lyr.GetNextFeature() @@ -1420,36 +1238,28 @@ def test_ogr_interlis_arc1(): geom = feat.GetGeometryRef() length = geom.Length() - if abs(length - length_0_1_deg) > 0.001: - gdaltest.post_reason('Length() result wrong, got %g.' % length) - return 'fail' + assert abs(length - length_0_1_deg) <= 0.001, \ + ('Length() result wrong, got %g.' % length) if ogrtest.check_feature_geometry(geom, 'MULTILINESTRING ((186.38 206.82,186.456637039593772 206.352374385077951,186.525513501820711 205.883542875348297,186.586610467027612 205.413634254015022,186.639911152487883 204.942777600139351,186.685400917071064 204.471102253228281,186.72306726518579 203.998737777656032,186.752899850289367 203.525813927088137,186.774890477674461 203.05246060886563,186.789033106731921 202.578807848280093,186.795323852631526 202.104985752892361,186.793760987376999 201.631124476756639,186.784344940257114 201.157354184717377,186.76707829777294 200.683805016597006,186.741965802895692 200.210607051507367,186.709014353764331 199.737890272066551,186.668233001808375 199.265784528717603,186.619632949244959 198.79441950407633,186.563227546008392 198.323924677271833,186.499032286083064 197.854429288403452,186.427064803254297 197.386062303034095,186.347344866240718 196.918952376778151,186.259894373302785 196.453227819933062,186.164737346189185 195.989016562249134,186.06189992355209 195.52644611780849,185.951410353787622 195.065643549954956,185.83329898723602 194.606735436434946,185.70759826788705 194.149847834589281,185.574342724430579 193.695106246756012,185.433568960797828 193.242635585782381,185.285315646106 192.792560140718678,185.129623504006275 192.345003542672174,184.966535301544326 191.900088730850229,184.796095837373258 191.457937918770739,184.618351929457248 191.018672560741805,184.433352402229474 190.582413318443258,184.241148073160701 190.149280027813774,184.04179173881127 189.71939166611989,183.835338160315558 189.292866319286958,183.621844048349857 188.869821149441094,183.401368047569093 188.450372362771276,183.173970720454207 188.03463517752968,182.939714530730242 187.622723792475853,182.698663826158707 187.214751355422749,182.450884820893378 186.810829932226596,182.196445577297681 186.411070475951391,181.935415987201822 186.015582796419011,181.667867752774299 185.624475530035824,181.3938743667604 185.237856109953981,181.113511092327798 184.855830736560137,180.826854942395556 184.478504348306132,180.53398465846837 184.105980592874374,180.234980689005141 183.73836179872157,179.929925167336449 183.375748946964421,179.618901889065427 183.018241643621849,179.301996289112111 182.665938092286495,178.979295418190276 182.318935067130923,178.650887918905909 181.977327886313986,178.316864001440962 181.64121038583832,177.97731541873506 181.310674893720687,177.632335441296135 180.985812204678922,177.282018831589056 180.666711555153569,176.9264618179877 180.353460598817009,176.565762068363227 180.046145382490039,176.200018663221243 179.744850322516839,175.829332068533375 179.449658181561944,175.453804108095909 179.160650045865594,175.073537935597386 178.877905303001143,174.688638006242371 178.601501620054449,174.299210048091453 178.331514922276227,173.905361033015623 178.068019372236421,173.507199147294131 177.811087349466078,173.104833761914023 177.560789430557605,172.698375402513165 177.317194369767066,172.28793571903222 177.080369080176723,171.873627455046488 176.850378615250492,171.455564416777605 176.627286151007837,171.033861441848018 176.411152968667096,170.60863436775486 176.202038437793476,170.18 176.0,140.69 156.63))') != 0: - gdaltest.post_reason('Ili curve not correctly read') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('Ili curve not correctly read') line = geom.GetGeometryRef(0) points = line.GetPoints() - if len(points) != 81: - gdaltest.post_reason('line point count wrong.') - return 'fail' + assert len(points) == 81, 'line point count wrong.' # Get 4th feature feat = lyr.GetNextFeature() geom = feat.GetGeometryRef() length = geom.Length() - if abs(length - 98.0243498288) > 0.001: - gdaltest.post_reason('Length() result wrong, got %g.' % length) - return 'fail' + assert abs(length - 98.0243498288) <= 0.001, \ + ('Length() result wrong, got %g.' % length) if ogrtest.check_feature_geometry(geom, 'MULTILINESTRING ((186.38 206.82,194.26 208.19,194.360118941290381 207.583863387608318,194.450034548441351 206.976129417129414,194.52972141151983 206.366969832830335,194.599157011165488 205.756556781867374,194.658321725044487 205.145062765608571,194.707198833340925 204.532660590913991,194.745774523486006 203.919523321273999,194.774037894087058 203.305824227936654,194.791980957968889 202.691736740889581,194.799598644465704 202.077434399900056,194.796888800832647 201.463090805460496,194.783852192864259 200.848879569690297,194.760492504683469 200.234974267339538,194.72681633767931 199.621548386683543,194.682833208673372 199.00877528050475,194.628555547191326 198.396828117140075,194.56399869197773 197.785879831499159,194.489180886659568 197.176103076206317,194.40412327458759 196.567670172822517,194.308849892848201 195.960753063147394,194.203387665489544 195.355523260601302,194.087766395903571 194.752151801789267,193.962018758407766 194.150809198152245,193.826180289004668 193.55166538777118,193.680289375348337 192.954889687360236,193.524387245874067 192.360650744412823,193.358517958193232 191.769116489536799,193.182728386585921 191.180454089007952,192.997068208809623 190.594829897498101,192.80158989201297 190.012409411123343,192.596348677929171 189.433357220623265,192.381402567276353 188.857836964845745,192.156812303357555 188.28601128455918,191.922641354867636 187.718041776424769,191.678955898001703 187.15408894736899,191.425824797734066 186.594312169210724,191.163319588355051 186.038869633623079,190.891514453251119 185.48791830744446,190.610486203950103 184.941613888295223,190.320314258417028 184.400110760594515,190.021080618593231 183.863561951926357,189.71286984725154 183.332119089784072,189.395769044065645 182.805932358758554,189.069867821024644 182.285150458053948,188.735258277090878 181.769920559469,188.392034972181108 181.260388265836781,188.040294900434645 180.756697569857323,187.680137462819374 180.258990813403187,187.311664439032 179.767408647305245,186.934979958736193 179.282089991582296,186.550190472116782 178.803171996223654,186.157404719844607 178.330790002393741,185.756733702299215 177.865077504182381,185.348290648216761 177.406166110929888,184.932190982704896 176.954185509959615,184.508552294610098 176.50926343000171,184.077494303273824 176.071525605046162,183.639138824742957 175.641095738836128,183.193609737303603 175.218095469892404,182.741032946476452 174.802644337149076,182.281536349473726 174.394859746185801,181.815249799001293 173.994856936020341,181.34230506662422 173.60274894655592,180.86283580545566 173.21864658665433,180.376977512460115 172.84265840277655,179.884867490109144 172.47489064835824,179.38664480760778 172.115447253752762,178.882450261575258 171.764429796865414,178.372426336281904 171.421937474442501,177.856717163354887 171.08806707407345,177.335468481061952 170.762912946782279,176.808827593129507 170.446566980404867,176.276943327102316 170.13911857360651,175.739965992295737 169.840654610641622,175.198047337304331 169.551259436742839,174.651340507162928 169.271014834364934,174.1 169.0,145.08 149.94,140.69 156.63))') != 0: - gdaltest.post_reason('Ili curve not correctly read') print(geom.ExportToWkt()) - return 'fail' + pytest.fail('Ili curve not correctly read') line = geom.GetGeometryRef(0) points = line.GetPoints() - if len(points) != 81: - gdaltest.post_reason('line point count wrong.') - return 'fail' + assert len(points) == 81, 'line point count wrong.' return 'success' @@ -1465,17 +1275,12 @@ def test_ogr_interlis_arc2(): ds = ogr.Open('data/ili/Beispiel.itf,data/ili/Beispiel.imd') lyr = ds.GetLayerByName('Bodenbedeckung__Strasse') - if lyr.GetFeatureCount() != 1: - gdaltest.post_reason('feature count wrong.') - return 'fail' + assert lyr.GetFeatureCount() == 1, 'feature count wrong.' feat = lyr.GetNextFeature() geom_field_values = ['MULTICURVE (COMPOUNDCURVE (CIRCULARSTRING (190.26 208.0,187 186,173.1 171.0),(173.1 171.0,141.08 152.94)))'] - if feat.GetGeomFieldCount() != len(geom_field_values): - gdaltest.post_reason('geom field count wrong.') - print(feat.GetGeomFieldCount()) - return 'fail' + assert feat.GetGeomFieldCount() == len(geom_field_values), 'geom field count wrong.' for i in range(feat.GetGeomFieldCount()): geom = feat.GetGeomFieldRef(i) diff --git a/autotest/ogr/ogr_index_test.py b/autotest/ogr/ogr_index_test.py index 3d6e96d22afb..49c45b257fed 100755 --- a/autotest/ogr/ogr_index_test.py +++ b/autotest/ogr/ogr_index_test.py @@ -98,9 +98,7 @@ def test_ogr_index_2(): for i in range(20): ogrtest.quick_create_feature(gdaltest.s_lyr, [i, 'Value ' + str(i)], None) - if gdaltest.s_lyr.GetFeatureCount() != 20: - gdaltest.post_reason('FeatureCount wrong') - return 'fail' + assert gdaltest.s_lyr.GetFeatureCount() == 20, 'FeatureCount wrong' gdaltest.s_ds.Release() gdaltest.s_lyr = None @@ -223,8 +221,7 @@ def test_ogr_index_9(): expect = ['Value 5'] tr = ogrtest.check_features_against_list(gdaltest.s_lyr, 'VALUE', expect) - if not tr: - return 'fail' + assert tr gdaltest.s_ds.Release() @@ -253,10 +250,7 @@ def test_ogr_index_9(): f = open('join_t.idm', 'rt') xml = f.read() f.close() - if xml.find('VALUE') == -1: - gdaltest.post_reason('VALUE column is not indexed (1)') - print(xml) - return 'fail' + assert xml.find('VALUE') != -1, 'VALUE column is not indexed (1)' # Close the dataset and re-open gdaltest.s_ds = ogr.OpenShared('join_t.dbf', update=1) @@ -269,14 +263,8 @@ def test_ogr_index_9(): f = open('join_t.idm', 'rt') xml = f.read() f.close() - if xml.find('VALUE') == -1: - gdaltest.post_reason('VALUE column is not indexed (2)') - print(xml) - return 'fail' - if xml.find('SKEY') == -1: - gdaltest.post_reason('SKEY column is not indexed (2)') - print(xml) - return 'fail' + assert xml.find('VALUE') != -1, 'VALUE column is not indexed (2)' + assert xml.find('SKEY') != -1, 'SKEY column is not indexed (2)' return 'success' @@ -303,104 +291,87 @@ def test_ogr_index_10(): lyr.SetAttributeFilter('intfield IN (1)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('intfield = 1') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('intfield IN (2)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None lyr.SetAttributeFilter('intfield IN (1.0)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('intfield = 1.0') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('intfield IN (1.1)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None lyr.SetAttributeFilter("intfield IN ('1')") lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('realfield IN (1.0)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('realfield = 1.0') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('realfield IN (1.1)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None lyr.SetAttributeFilter('realfield IN (1)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('realfield = 1') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter('realfield IN (2)') lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None lyr.SetAttributeFilter("realfield IN ('1')") lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter("strfield IN ('foo')") lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter("strfield = 'foo'") lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None lyr.SetAttributeFilter("strfield IN ('bar')") lyr.ResetReading() feat = lyr.GetNextFeature() - if feat is not None: - return 'fail' + assert feat is None ds = None @@ -415,10 +386,8 @@ def ogr_index_11_check(lyr, expected_fids): lyr.ResetReading() for expected_fid in expected_fids: feat = lyr.GetNextFeature() - if feat is None: - return 'fail' - if feat.GetFID() != expected_fid: - return 'fail' + assert feat is not None + assert feat.GetFID() == expected_fid return 'success' diff --git a/autotest/ogr/ogr_ingres.py b/autotest/ogr/ogr_ingres.py index f3cd42e71198..51f68d676f5c 100755 --- a/autotest/ogr/ogr_ingres.py +++ b/autotest/ogr/ogr_ingres.py @@ -117,14 +117,12 @@ def test_ogr_ingres_3(): orig_feat = gdaltest.poly_feat[i] read_feat = gdaltest.ingres_lyr.GetNextFeature() - if ogrtest.check_feature_geometry(read_feat, orig_feat.GetGeometryRef(), - max_error=0.000000001) != 0: - return 'fail' + assert (ogrtest.check_feature_geometry(read_feat, orig_feat.GetGeometryRef(), + max_error=0.000000001) == 0) for fld in range(3): - if orig_feat.GetField(fld) != read_feat.GetField(fld): - gdaltest.post_reason('Attribute %d does not match' % fld) - return 'fail' + assert orig_feat.GetField(fld) == read_feat.GetField(fld), \ + ('Attribute %d does not match' % fld) gdaltest.poly_feat = None gdaltest.shp_ds.Destroy() @@ -224,18 +222,14 @@ def test_ogr_ingres_7(): result = gdaltest.ingres_lyr.CreateField(field_defn) field_defn.Destroy() - if result is not 0: - gdaltest.post_reason('CreateField failed!') - return 'fail' + assert result is 0, 'CreateField failed!' #################################################################### # Apply a value to this field in one feature. gdaltest.ingres_lyr.SetAttributeFilter("prfedea = '35043423'") feat_read = gdaltest.ingres_lyr.GetNextFeature() - if feat_read is None: - gdaltest.post_reason('failed to read target feature!') - return 'fail' + assert feat_read is not None, 'failed to read target feature!' gdaltest.ingres_fid = feat_read.GetFID() @@ -265,9 +259,8 @@ def test_ogr_ingres_8(): if gdaltest.ingres_ds is None: return 'skip' - if not gdaltest.ingres_lyr.TestCapability('DeleteFeature'): - gdaltest.post_reason('DeleteFeature capability test failed.') - return 'fail' + assert gdaltest.ingres_lyr.TestCapability('DeleteFeature'), \ + 'DeleteFeature capability test failed.' old_count = gdaltest.ingres_lyr.GetFeatureCount() @@ -275,9 +268,8 @@ def test_ogr_ingres_8(): # Delete target feature. target_fid = gdaltest.ingres_fid - if gdaltest.ingres_lyr.DeleteFeature(target_fid) != 0: - gdaltest.post_reason('DeleteFeature returned error code.') - return 'fail' + assert gdaltest.ingres_lyr.DeleteFeature(target_fid) == 0, \ + 'DeleteFeature returned error code.' #################################################################### # Verify that count has dropped by one, and that the feature in question @@ -287,9 +279,7 @@ def test_ogr_ingres_8(): gdaltest.post_reason('got feature count of %d, not expected %d.' % (new_count, old_count - 1)) - if gdaltest.ingres_lyr.GetFeature(target_fid) is not None: - gdaltest.post_reason('Got deleted feature!') - return 'fail' + assert gdaltest.ingres_lyr.GetFeature(target_fid) is None, 'Got deleted feature!' return 'success' diff --git a/autotest/ogr/ogr_jml.py b/autotest/ogr/ogr_jml.py index 916dbed55147..0628e1eb44e0 100755 --- a/autotest/ogr/ogr_jml.py +++ b/autotest/ogr/ogr_jml.py @@ -60,14 +60,10 @@ def test_ogr_jml_1(): return 'skip' ds = ogr.Open('data/test.jml') - if ds.GetLayerCount() != 1: - return 'fail' - if ds.GetLayer(1) is not None: - return 'fail' - if ds.TestCapability(ogr.ODsCCreateLayer) != 0: - return 'fail' - if ds.TestCapability(ogr.ODsCDeleteLayer) != 0: - return 'fail' + assert ds.GetLayerCount() == 1 + assert ds.GetLayer(1) is None + assert ds.TestCapability(ogr.ODsCCreateLayer) == 0 + assert ds.TestCapability(ogr.ODsCDeleteLayer) == 0 lyr = ds.GetLayer(0) fields = [('first_property', ogr.OFTString), ('another_property', ogr.OFTString), @@ -80,13 +76,10 @@ def test_ogr_jml_1(): ('datetime', ogr.OFTDateTime), ('R_G_B', ogr.OFTString), ('not_ignored', ogr.OFTString)] - if lyr.GetLayerDefn().GetFieldCount() != len(fields): - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == len(fields) for i, field in enumerate(fields): field_defn = lyr.GetLayerDefn().GetFieldDefn(i) - if field_defn.GetName() != field[0] or field_defn.GetType() != field[1]: - print(i) - return 'fail' + assert field_defn.GetName() == field[0] and field_defn.GetType() == field[1], i feat = lyr.GetNextFeature() if feat.GetField('first_property') != 'even' or \ feat.GetField('another_property') != 'rouault' or \ @@ -142,7 +135,7 @@ def test_ogr_jml_2(): data = gdal.VSIFReadL(1, 1000, f).decode('ascii') gdal.VSIFCloseL(f) - if data != """ + assert data == """ featureCollection @@ -160,9 +153,7 @@ def test_ogr_jml_2(): -""": - print(data) - return 'fail' +""" gdal.Unlink('/vsimem/ogr_jml.jml') @@ -181,23 +172,17 @@ def test_ogr_jml_2(): with gdaltest.error_handler(): lyr.CreateField(ogr.FieldDefn('time_as_str', ogr.OFTTime)) - if lyr.TestCapability(ogr.OLCCreateField) != 1: - return 'fail' - if lyr.TestCapability(ogr.OLCSequentialWrite) != 1: - return 'fail' - if lyr.TestCapability(ogr.OLCRandomWrite) != 0: - return 'fail' - if lyr.TestCapability(ogr.OLCStringsAsUTF8) != 1: - return 'fail' + assert lyr.TestCapability(ogr.OLCCreateField) == 1 + assert lyr.TestCapability(ogr.OLCSequentialWrite) == 1 + assert lyr.TestCapability(ogr.OLCRandomWrite) == 0 + assert lyr.TestCapability(ogr.OLCStringsAsUTF8) == 1 # empty feature f = ogr.Feature(lyr.GetLayerDefn()) lyr.CreateFeature(f) - if lyr.TestCapability(ogr.OLCCreateField) != 0: - return 'fail' - if lyr.CreateField(ogr.FieldDefn('that_wont_work')) == 0: - return 'fail' + assert lyr.TestCapability(ogr.OLCCreateField) == 0 + assert lyr.CreateField(ogr.FieldDefn('that_wont_work')) != 0 f = ogr.Feature(lyr.GetLayerDefn()) f.SetField('str', 'fo + assert data == """ featureCollection @@ -327,9 +312,7 @@ def test_ogr_jml_2(): -""": - print(data) - return 'fail' +""" gdal.Unlink('/vsimem/ogr_jml.jml') @@ -354,9 +337,7 @@ def test_ogr_jml_2(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('112233') < 0 or data.find('445566') < 0: - print(data) - return 'fail' + assert data.find('112233') >= 0 and data.find('445566') >= 0 gdal.Unlink('/vsimem/ogr_jml.jml') @@ -372,9 +353,7 @@ def test_ogr_jml_2(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('R_G_B') >= 0: - print(data) - return 'fail' + assert data.find('R_G_B') < 0 gdal.Unlink('/vsimem/ogr_jml.jml') @@ -391,9 +370,7 @@ def test_ogr_jml_2(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('OGR_STYLE') < 0 or data.find('PEN(c:#445566)') < 0: - print(data) - return 'fail' + assert data.find('OGR_STYLE') >= 0 and data.find('PEN(c:#445566)') >= 0 gdal.Unlink('/vsimem/ogr_jml.jml') @@ -412,9 +389,7 @@ def test_ogr_jml_2(): data = gdal.VSIFReadL(1, 10000, f).decode('ascii') gdal.VSIFCloseL(f) - if data.find('OGR_STYLE') < 0 or data.find('PEN(c:#445566)') < 0 or data.find('112233') < 0: - print(data) - return 'fail' + assert data.find('OGR_STYLE') >= 0 and data.find('PEN(c:#445566)') >= 0 and data.find('112233') >= 0 gdal.Unlink('/vsimem/ogr_jml.jml') @@ -435,9 +410,7 @@ def test_ogr_jml_3(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' -ro data/test.jml') - if ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert ret.find('INFO') != -1 and ret.find('ERROR') == -1 return 'success' @@ -469,8 +442,7 @@ def test_ogr_jml_4(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn() gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 ds = None # XML malformed in JCSGMLInputTemplate @@ -492,8 +464,7 @@ def test_ogr_jml_4(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn() gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 ds = None # XML malformed in featureCollection @@ -521,8 +492,7 @@ def test_ogr_jml_4(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn().GetFieldCount() gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 ds = None # XML malformed in featureCollection @@ -551,8 +521,7 @@ def test_ogr_jml_4(): gdal.PushErrorHandler('CPLQuietErrorHandler') lyr.GetLayerDefn().GetFieldCount() gdal.PopErrorHandler() - if gdal.GetLastErrorType() == 0: - return 'fail' + assert gdal.GetLastErrorType() != 0 del ds # Invalid column definitions @@ -620,8 +589,7 @@ def test_ogr_jml_4(): ds = ogr.Open('/vsimem/ogr_jml.jml') lyr = ds.GetLayer(0) - if lyr.GetLayerDefn().GetFieldCount() != 0: - return 'fail' + assert lyr.GetLayerDefn().GetFieldCount() == 0 lyr.GetNextFeature() ds = None @@ -638,11 +606,9 @@ def test_ogr_jml_read_srs(): ds = ogr.Open('data/one_point_srid_4326.jml') lyr = ds.GetLayer(0) - if lyr.GetSpatialRef().ExportToWkt().find('4326') < 0: - return 'fail' + assert lyr.GetSpatialRef().ExportToWkt().find('4326') >= 0 f = lyr.GetNextFeature() - if f.GetGeometryRef() is None: - return 'fail' + assert f.GetGeometryRef() is not None return 'success' diff --git a/autotest/ogr/ogr_join_test.py b/autotest/ogr/ogr_join_test.py index 7dceca704427..4c4564c54c08 100755 --- a/autotest/ogr/ogr_join_test.py +++ b/autotest/ogr/ogr_join_test.py @@ -46,9 +46,8 @@ def test_ogr_join_1(): 'SELECT * FROM poly LEFT JOIN idlink ON poly.eas_id = idlink.eas_id') count = sql_lyr.GetFeatureCount() - if count != 10: - gdaltest.post_reason('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) - return 'fail' + assert count == 10, \ + ('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) gdaltest.ds.ReleaseResultSet(sql_lyr) @@ -253,9 +252,8 @@ def test_ogr_join_12(): "SELECT * FROM poly LEFT JOIN 'data/idlink.dbf'.idlink ON poly.eas_id = idlink.eas_id") count = sql_lyr.GetFeatureCount() - if count != 10: - gdaltest.post_reason('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) - return 'fail' + assert count == 10, \ + ('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) ds.ReleaseResultSet(sql_lyr) @@ -329,13 +327,9 @@ def test_ogr_join_15(): gdal.Unlink('/vsimem/ogr_join_14/third.csv') gdal.Unlink('/vsimem/ogr_join_14') - if val1 != 'c2': - print(val1) - return 'fail' + assert val1 == 'c2' - if val2 != 'c2': - print(val2) - return 'fail' + assert val2 == 'c2' return 'success' @@ -353,8 +347,7 @@ def test_ogr_join_16(): 'WHERE idlink.name = \'_165\'') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('Cannot use field') != 0: - return 'fail' + assert gdal.GetLastErrorMsg().find('Cannot use field') == 0 if sql_lyr is None: return 'success' @@ -374,9 +367,7 @@ def test_ogr_join_17(): 'ORDER BY name') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('Cannot use field') != 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('Cannot use field') == 0 if sql_lyr is None: return 'success' @@ -392,9 +383,8 @@ def test_ogr_join_18(): 'SELECT * FROM poly LEFT JOIN idlink ON idlink.eas_id = poly.eas_id') count = sql_lyr.GetFeatureCount() - if count != 10: - gdaltest.post_reason('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) - return 'fail' + assert count == 10, \ + ('Got wrong count with GetFeatureCount() - %d, expecting 10' % count) gdaltest.ds.ReleaseResultSet(sql_lyr) @@ -412,9 +402,7 @@ def test_ogr_join_19(): 'SELECT * FROM poly LEFT JOIN idlink ON poly.foo = idlink.eas_id') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('"poly"."foo" not recognised as an available field') != 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('"poly"."foo" not recognised as an available field') == 0 if sql_lyr is None: return 'success' @@ -432,9 +420,7 @@ def test_ogr_join_20(): 'SELECT * FROM poly LEFT JOIN idlink ON poly.eas_id = idlink.foo') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('"idlink"."foo" not recognised as an available field') != 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('"idlink"."foo" not recognised as an available field') == 0 if sql_lyr is None: return 'success' @@ -454,9 +440,7 @@ def test_ogr_join_21(): 'LEFT JOIN idlink il2 ON p.eas_id = il2.eas_id') gdal.PopErrorHandler() - if gdal.GetLastErrorMsg().find('Field il2.eas_id in JOIN clause does not correspond to the primary table nor the joint (secondary) table') != 0: - print(gdal.GetLastErrorMsg()) - return 'fail' + assert gdal.GetLastErrorMsg().find('Field il2.eas_id in JOIN clause does not correspond to the primary table nor the joint (secondary) table') == 0 if sql_lyr is None: return 'success' @@ -486,9 +470,7 @@ def test_ogr_join_22(): ds = None - if val != '2': - print(val) - return 'fail' + assert val == '2' return 'success' diff --git a/autotest/ogr/ogr_kml.py b/autotest/ogr/ogr_kml.py index 67c2694e4547..d2947f3c1e4c 100755 --- a/autotest/ogr/ogr_kml.py +++ b/autotest/ogr/ogr_kml.py @@ -39,6 +39,7 @@ from osgeo import ogr from osgeo import osr from osgeo import gdal +import pytest ############################################################################### # Test basic open operation for KML datastore. @@ -70,9 +71,7 @@ def test_ogr_kml_datastore(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds.GetLayerCount() != 6: - gdaltest.post_reason('wrong number of layers') - return 'fail' + assert ogrtest.kml_ds.GetLayerCount() == 6, 'wrong number of layers' return 'success' @@ -86,49 +85,34 @@ def test_ogr_kml_attributes_1(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Placemarks') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Simple placemark': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Simple placemark', 'Wrong name field value' if feat.GetField('description')[:23] != 'Attached to the ground.': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')[:23]) - return 'fail' + pytest.fail('Wrong description field value') feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' - if feat.GetField('Name') != 'Floating placemark': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Floating placemark', 'Wrong name field value' if feat.GetField('description')[:25] != 'Floats a defined distance': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')[:25]) - return 'fail' + pytest.fail('Wrong description field value') feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' - if feat.GetField('Name') != 'Extruded placemark': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Extruded placemark', 'Wrong name field value' if feat.GetField('description') != 'Tethered to the ground by a customizable \"tail\"': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')) - return 'fail' + pytest.fail('Wrong description field value') return 'success' @@ -142,25 +126,17 @@ def test_ogr_kml_attributes_2(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Highlighted Icon') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Roll over this icon': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Roll over this icon', 'Wrong name field value' - if feat.GetField('description') != '': - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') == '', 'Wrong description field value' feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('unexpected feature found.') - return 'fail' + assert feat is None, 'unexpected feature found.' return 'success' @@ -174,38 +150,26 @@ def test_ogr_kml_attributes_3(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Paths') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Tessellated': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Tessellated', 'Wrong name field value' - if feat.GetField('description') != 'If the tag has a value of 1, the line will contour to the underlying terrain': - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') == 'If the tag has a value of 1, the line will contour to the underlying terrain', \ + 'Wrong description field value' feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' - if feat.GetField('Name') != 'Untessellated': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Untessellated', 'Wrong name field value' - if feat.GetField('description') != 'If the tag has a value of 0, the line follow a simple straight-line path from point to point': - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') == 'If the tag has a value of 0, the line follow a simple straight-line path from point to point', \ + 'Wrong description field value' feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' return 'success' @@ -219,9 +183,7 @@ def test_ogr_kml_attributes_4(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Google Campus') feat = lyr.GetNextFeature() @@ -230,13 +192,10 @@ def test_ogr_kml_attributes_4(): while feat is not None: name = 'Building %d' % i if feat.GetField('Name') != name: - gdaltest.post_reason('Wrong name field value') print('Got: "%s"' % feat.GetField('name')) - return 'fail' + pytest.fail('Wrong name field value') - if feat.GetField('description') != '': - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') == '', 'Wrong description field value' i = i + 1 feat = lyr.GetNextFeature() @@ -253,9 +212,7 @@ def test_ogr_kml_point_read(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Placemarks') lyr.ResetReading() @@ -263,28 +220,21 @@ def test_ogr_kml_point_read(): wkt = 'POINT(-122.0822035425683 37.42228990140251)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POINT(-122.084075 37.4220033612141 50)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POINT(-122.0857667006183 37.42156927867553 50)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -298,35 +248,26 @@ def test_ogr_kml_linestring_read(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Paths') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'LINESTRING (-112.081423783034495 36.106778704771372 0, -112.087026775269294 36.0905099328766 0)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'LINESTRING (-112.080622229594994 36.106734600079953 0,-112.085242575314993 36.090495986124218 0)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'LINESTRING (-112.265654928602004 36.094476726025462 2357,-112.266038452823807 36.093426088386707 2357,-112.266813901345301 36.092510587768807 2357,-112.267782683444494 36.091898273579957 2357,-112.268855751095202 36.091313794118697 2357,-112.269481071721899 36.090367720752099 2357,-112.269526855561097 36.089321714872852 2357,-112.269014456727604 36.088509160604723 2357,-112.268152881533894 36.087538135979557 2357,-112.2670588176031 36.086826852625677 2357,-112.265737458732104 36.086463123013033 2357)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -340,44 +281,32 @@ def test_ogr_kml_polygon_read(): if not ogrtest.have_read_kml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('kml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'kml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Google Campus') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'POLYGON ((-122.084893845961204 37.422571240447859 17,-122.084958097919795 37.422119226268563 17,-122.084746957304702 37.42207183952619 17,-122.084572538096197 37.422090067296757 17,-122.084595488672306 37.422159327008949 17,-122.0838521118269 37.422272785643713 17,-122.083792243334997 37.422035391120843 17,-122.0835076656616 37.422090069571063 17,-122.083470946415204 37.422009873951609 17,-122.083122108574798 37.422104649494599 17,-122.082924737457205 37.422265039903863 17,-122.082933916938501 37.422312428430942 17,-122.083383735973698 37.422250460876178 17,-122.083360785424802 37.422341592287452 17,-122.083420455164202 37.42237075460644 17,-122.083659133885007 37.422512920110009 17,-122.083975843895203 37.422658730937812 17,-122.084237474333094 37.422651439725207 17,-122.0845036949503 37.422651438643499 17,-122.0848020460801 37.422611339163147 17,-122.084788275051494 37.422563950551208 17,-122.084893845961204 37.422571240447859 17))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POLYGON ((-122.085741277148301 37.422270331552568 17,-122.085816976848093 37.422314088323461 17,-122.085852582875006 37.422303374697442 17,-122.085879994563896 37.422256861387893 17,-122.085886010140896 37.422231107613797 17,-122.085806915728796 37.422202501738553 17,-122.085837954265301 37.42214027058678 17,-122.085673264051906 37.422086902144081 17,-122.085602292640701 37.42214885429042 17,-122.085590277843593 37.422128290487002 17,-122.085584167223701 37.422081719672462 17,-122.085485206574106 37.42210455874995 17,-122.085506726435199 37.422142679498243 17,-122.085443071291493 37.422127838461719 17,-122.085099071490404 37.42251282407603 17,-122.085676981863202 37.422818153236513 17,-122.086016227378295 37.422449188587223 17,-122.085726032700407 37.422292396042529 17,-122.085741277148301 37.422270331552568 17))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POLYGON ((-122.085786228724203 37.421362088869692 25,-122.085731299060299 37.421369359894811 25,-122.085731299291794 37.421409349109027 25,-122.085607707367899 37.421383901665649 25,-122.085580242651602 37.42137299550869 25,-122.085218622197104 37.421372995043157 25,-122.085227776563897 37.421616565082651 25,-122.085259818934702 37.421605658944031 25,-122.085259818549901 37.421682001560001 25,-122.085236931147804 37.421700178603459 25,-122.085264395782801 37.421761979825753 25,-122.085323903274599 37.421761980139067 25,-122.085355945432397 37.421852864451999 25,-122.085410875246296 37.421889218237339 25,-122.085479537935697 37.42189285337048 25,-122.085543622981902 37.421889217975462 25,-122.085626017804202 37.421860134999257 25,-122.085937287963006 37.421860134536047 25,-122.085942871866607 37.42160898590042 25,-122.085965546986102 37.421579927591438 25,-122.085864046234093 37.421471150029568 25,-122.0858548911215 37.421405713261841 25,-122.085809116276806 37.4214057134039 25,-122.085786228724203 37.421362088869692 25))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POLYGON ((-122.084437112828397 37.421772530030907 19,-122.084511885574599 37.421911115428962 19,-122.0850470999805 37.421787551215353 19,-122.085071991339106 37.421436630231611 19,-122.084916406231997 37.421372378221157 19,-122.084219386816699 37.421372378016258 19,-122.084219386589993 37.421476171614962 19,-122.083808641999099 37.4214613409357 19,-122.083789972856394 37.421313064107963 19,-122.083279653469802 37.421293288405927 19,-122.083260981920702 37.421392139442979 19,-122.082937362173695 37.421372363998763 19,-122.082906242566693 37.421515697788713 19,-122.082850226966499 37.421762825764652 19,-122.082943578863507 37.421767769696352 19,-122.083217411188002 37.421792485526858 19,-122.0835970430103 37.421748007445601 19,-122.083945555677104 37.421693642376027 19,-122.084007789463698 37.421762838158529 19,-122.084113587521003 37.421748011043917 19,-122.084076247378405 37.421713412923751 19,-122.084144704773905 37.421678815345693 19,-122.084144704222993 37.421817206601972 19,-122.084250333307395 37.421817070044597 19,-122.084437112828397 37.421772530030907 19))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -397,13 +326,9 @@ def test_ogr_kml_write_1(): dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' - if dst_feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - print(dst_feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('CreateFeature changed the geometry.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' + assert dst_feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49)', \ + 'CreateFeature changed the geometry.' lyr = ds.CreateLayer('test_wgs84') @@ -411,51 +336,35 @@ def test_ogr_kml_write_1(): dst_feat.SetField('name', 'my_name') dst_feat.SetField('description', 'my_description') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49 1)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('LINESTRING (0 1,2 3)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTIPOINT (2 49,2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTILINESTRING ((0 1,2 3),(0 1,2 3))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTIPOLYGON (((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1)),((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1)))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1 0,2 3 0))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None @@ -471,71 +380,44 @@ def test_ogr_kml_check_write_1(): return 'skip' content = open('tmp/kml.kml').read() - if content.find('Schema') >= 0: - gdaltest.post_reason('Did not expect Schema tags.') - return 'fail' + assert content.find('Schema') < 0, 'Did not expect Schema tags.' ds = ogr.Open('tmp/kml.kml') lyr = ds.GetLayerByName('test_wgs84') - if lyr.GetFeatureCount() != 8: - gdaltest.post_reason('Bad feature count.') - return 'fail' + assert lyr.GetFeatureCount() == 8, 'Bad feature count.' feat = lyr.GetNextFeature() - if feat.GetField('name') != 'my_name': - print(feat.GetField('name')) - gdaltest.post_reason('Unexpected name.') - return 'fail' - if feat.GetField('description') != 'my_description': - print(feat.GetField('description')) - gdaltest.post_reason('Unexpected description.') - return 'fail' - if feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetField('name') == 'my_name', 'Unexpected name.' + assert feat.GetField('description') == 'my_description', 'Unexpected description.' + assert feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49)', 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49 1)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49 1)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (0 1,2 3)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'LINESTRING (0 1,2 3)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'POLYGON ((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1))', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOINT (2 49,2 49)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'MULTIPOINT (2 49,2 49)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'MULTILINESTRING ((0 1,2 3),(0 1,2 3))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'MULTILINESTRING ((0 1,2 3),(0 1,2 3))', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOLYGON (((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1)),((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1)))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'MULTIPOLYGON (((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1)),((0 1,2 3,4 5,0 1),(0 1,2 3,4 5,0 1)))', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1 0,2 3 0))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1 0,2 3 0))', \ + 'Unexpected geometry.' return 'success' @@ -554,9 +436,8 @@ def test_ogr_kml_xml_attributes(): feat = lyr.GetNextFeature() if feat.GetField('description') != 'Description

      Interesting

      ': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')) - return 'fail' + pytest.fail('Wrong description field value') return 'success' @@ -593,9 +474,7 @@ def test_ogr_kml_test_ogrsf(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' --config OGR_SKIP LIBKML -ro data/samples.kml') - if ret.find("using driver `KML'") == -1 or ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert not (ret.find("using driver `KML'") == -1 or ret.find('INFO') == -1 or ret.find('ERROR') != -1) return 'success' @@ -616,8 +495,7 @@ def test_ogr_kml_interleaved_writing(): gdal.Unlink('/vsimem/ogr_kml_interleaved_writing.kml') # CreateFeature() should fail - if ret == 0: - return 'fail' + assert ret != 0 return 'success' @@ -633,8 +511,7 @@ def test_ogr_kml_read_placemark(): ds = ogr.Open('data/placemark.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None return 'success' @@ -648,9 +525,7 @@ def test_ogr_kml_read_empty(): return 'skip' ds = ogr.Open('data/empty.kml') - if ds.GetLayerCount() != 0: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 0 return 'success' @@ -664,17 +539,11 @@ def test_ogr_kml_read_emptylayers(): return 'skip' ds = ogr.Open('data/emptylayers.kml') - if ds.GetLayerCount() != 2: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 2 - if ds.GetLayer(0).GetFeatureCount() != 0: - print(ds.GetLayer(0).GetFeatureCount()) - return 'fail' + assert ds.GetLayer(0).GetFeatureCount() == 0 - if ds.GetLayer(1).GetFeatureCount() != 0: - print(ds.GetLayer(1).GetFeatureCount()) - return 'fail' + assert ds.GetLayer(1).GetFeatureCount() == 0 return 'success' @@ -685,13 +554,9 @@ def compare_output(content, expected_content): content_lines = content.strip().split('\n') expected_lines = expected_content.strip().split('\n') - if len(content_lines) != len(expected_lines): - print(content) - return 'fail' + assert len(content_lines) == len(expected_lines), content for i, content_line in enumerate(content_lines): - if content_line.strip() != expected_lines[i].strip(): - print(content) - return 'fail' + assert content_line.strip() == expected_lines[i].strip(), content return 'success' @@ -837,13 +702,9 @@ def test_ogr_kml_read_folder_with_subfolder_placemark(): return 'skip' ds = ogr.Open('data/folder_with_subfolder_placemark.kml') - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1 - if ds.GetLayer(0).GetFeatureCount() != 0: - print(ds.GetLayer(0).GetFeatureCount()) - return 'fail' + assert ds.GetLayer(0).GetFeatureCount() == 0 return 'success' @@ -858,8 +719,7 @@ def test_ogr_kml_read_truncated(): with gdaltest.error_handler(): ds = ogr.Open('data/truncated.kml') - if ds is not None: - return 'fail' + assert ds is None return 'success' @@ -873,13 +733,9 @@ def test_ogr_kml_read_weird_empty_folders(): return 'skip' ds = ogr.Open('data/weird_empty_folders.kml') - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1 - if ds.GetLayer(0).GetFeatureCount() != 0: - print(ds.GetLayer(0).GetFeatureCount()) - return 'fail' + assert ds.GetLayer(0).GetFeatureCount() == 0 return 'success' @@ -894,8 +750,7 @@ def test_ogr_kml_read_junk_content_after_valid_doc(): with gdaltest.error_handler(): ds = ogr.Open('data/junk_content_after_valid_doc.kml') - if ds is not None: - return 'fail' + assert ds is None return 'success' @@ -911,8 +766,7 @@ def test_ogr_kml_read_placemark_with_kml_prefix(): ds = ogr.Open('data/placemark_with_kml_prefix.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None return 'success' @@ -927,13 +781,9 @@ def test_ogr_kml_read_duplicate_folder_name(): ds = ogr.Open('data/duplicate_folder_name.kml') lyr = ds.GetLayer(0) - if lyr.GetName() != 'layer': - print(lyr.GetName()) - return 'fail' + assert lyr.GetName() == 'layer' lyr = ds.GetLayer(1) - if lyr.GetName() != 'layer (#2)': - print(lyr.GetName()) - return 'fail' + assert lyr.GetName() == 'layer (#2)' return 'success' @@ -948,16 +798,12 @@ def test_ogr_kml_read_placemark_in_root_and_subfolder(): ds = ogr.Open('data/placemark_in_root_and_subfolder.kml') lyr = ds.GetLayerByName('TopLevel') - if lyr is None: - return 'fail' - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr is not None + assert lyr.GetFeatureCount() == 1 lyr = ds.GetLayerByName('SubFolder1') - if lyr is None: - return 'fail' - if lyr.GetFeatureCount() != 1: - return 'fail' + assert lyr is not None + assert lyr.GetFeatureCount() == 1 return 'success' diff --git a/autotest/ogr/ogr_layer_algebra.py b/autotest/ogr/ogr_layer_algebra.py index c87130b7a22b..cfee839b1680 100755 --- a/autotest/ogr/ogr_layer_algebra.py +++ b/autotest/ogr/ogr_layer_algebra.py @@ -169,22 +169,15 @@ def test_algebra_intersection(): err = A.Intersection(B, C) - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Intersection') - return 'fail' + assert err == 0, \ + ('got non-zero result code ' + str(err) + ' from Layer.Intersection') C_defn = C.GetLayerDefn() - if C_defn.GetFieldCount() != 2 \ - or C_defn.GetFieldDefn(0).GetName() != 'A' \ - or C_defn.GetFieldDefn(0).GetType() != ogr.OFTInteger \ - or C_defn.GetFieldDefn(1).GetName() != 'B' \ - or C_defn.GetFieldDefn(1).GetType() != ogr.OFTString: - gdaltest.post_reason('Did not get expected output schema.') - return 'fail' + assert C_defn.GetFieldCount() == 2 and C_defn.GetFieldDefn(0).GetName() == 'A' and C_defn.GetFieldDefn(0).GetType() == ogr.OFTInteger and C_defn.GetFieldDefn(1).GetName() == 'B' and C_defn.GetFieldDefn(1).GetType() == ogr.OFTString, \ + 'Did not get expected output schema.' - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Intersection returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Intersection returned ' + str(C.GetFeatureCount()) + ' features') f1 = (ogr.Geometry(wkt='POLYGON ((2 3,3 3,3 2,2 2,2 3))'), 1, 'first') f2 = (ogr.Geometry(wkt='POLYGON ((5 2,5 3,6 3,6 2,5 2))'), 2, 'first') @@ -197,13 +190,11 @@ def test_algebra_intersection(): g = feat.GetGeometryRef() if g.Equals(f1[0]): - if feat.GetField('A') != f1[1] or feat.GetField('B') != f1[2]: - gdaltest.post_reason('Did not get expected field values.') - return 'fail' + assert feat.GetField('A') == f1[1] and feat.GetField('B') == f1[2], \ + 'Did not get expected field values.' elif g.Equals(f2[0]): - if feat.GetField('A') != f2[1] or feat.GetField('B') != f2[2]: - gdaltest.post_reason('Did not get expected field values.') - return 'fail' + assert feat.GetField('A') == f2[1] and feat.GetField('B') == f2[2], \ + 'Did not get expected field values.' else: gdaltest.post_reason('Layer.Intersection returned wrong geometry: ' + g.ExportToWkt()) return 'fail' @@ -215,13 +206,11 @@ def test_algebra_intersection(): err = A.Intersection(B, C, options=['PROMOTE_TO_MULTI=YES']) - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Intersection') - return 'fail' + assert err == 0, \ + ('got non-zero result code ' + str(err) + ' from Layer.Intersection') - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Intersection returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Intersection returned ' + str(C.GetFeatureCount()) + ' features') f1 = (ogr.Geometry(wkt='MULTIPOLYGON (((2 3,3 3,3 2,2 2,2 3)))'), 1, 'first') f2 = (ogr.Geometry(wkt='MULTIPOLYGON (((5 2,5 3,6 3,6 2,5 2)))'), 2, 'first') @@ -234,18 +223,11 @@ def test_algebra_intersection(): g = feat.GetGeometryRef() if g.Equals(f1[0]): - if feat.GetField('A') != f1[1] or feat.GetField('B') != f1[2]: - gdaltest.post_reason('Did not get expected field values. (1)') - print(feat.GetField('A')) - print(feat.GetField('B')) - return 'fail' + assert feat.GetField('A') == f1[1] and feat.GetField('B') == f1[2], \ + 'Did not get expected field values. (1)' elif g.Equals(f2[0]): - if feat.GetField('A') != f2[1] or feat.GetField('B') != f2[2]: - gdaltest.post_reason('Did not get expected field values. (2)') - print(feat.GetField('A')) - print(feat.GetField('B')) - print(feat.GetField('B')) - return 'fail' + assert feat.GetField('A') == f2[1] and feat.GetField('B') == f2[2], \ + 'Did not get expected field values. (2)' else: gdaltest.post_reason('Layer.Intersection returned wrong geometry: ' + g.ExportToWkt()) return 'fail' @@ -256,13 +238,10 @@ def test_algebra_intersection(): err = D1.Intersection(D2, C, ['KEEP_LOWER_DIMENSION_GEOMETRIES=NO']) - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Intersection') - return 'fail' + assert err == 0, \ + ('got non-zero result code ' + str(err) + ' from Layer.Intersection') - if not is_same(D1, C): - gdaltest.post_reason('D1 != C') - return 'fail' + assert is_same(D1, C), 'D1 != C' return 'success' @@ -302,39 +281,32 @@ def test_algebra_KEEP_LOWER_DIMENSION_GEOMETRIES(): layer3 = ds.CreateLayer('layer3a') layer1.Intersection(layer2, layer3, ['KEEP_LOWER_DIMENSION_GEOMETRIES=NO']) - if layer3.GetFeatureCount() != 0: - gdaltest.post_reason('Lower dimension geometries not removed in intersection') - return 'fail' + assert layer3.GetFeatureCount() == 0, \ + 'Lower dimension geometries not removed in intersection' layer3 = ds.CreateLayer('layer3b') layer1.Intersection(layer2, layer3, ['KEEP_LOWER_DIMENSION_GEOMETRIES=YES']) - if layer3.GetFeatureCount() != 2: - gdaltest.post_reason('Lower dimension geometries not kept in intersection') - return 'fail' + assert layer3.GetFeatureCount() == 2, \ + 'Lower dimension geometries not kept in intersection' layer3 = ds.CreateLayer('layer3c') layer1.Union(layer2, layer3, ['KEEP_LOWER_DIMENSION_GEOMETRIES=NO']) - if layer3.GetFeatureCount() != 4: - gdaltest.post_reason('Lower dimension geometries not removed in union') - return 'fail' + assert layer3.GetFeatureCount() == 4, \ + 'Lower dimension geometries not removed in union' layer3 = ds.CreateLayer('layer3d') layer1.Union(layer2, layer3, ['KEEP_LOWER_DIMENSION_GEOMETRIES=YES']) - if layer3.GetFeatureCount() != 6: - gdaltest.post_reason('Lower dimension geometries not kept in union') - return 'fail' + assert layer3.GetFeatureCount() == 6, 'Lower dimension geometries not kept in union' layer3 = ds.CreateLayer('layer3e') layer1.Identity(layer2, layer3, ['KEEP_LOWER_DIMENSION_GEOMETRIES=NO']) - if layer3.GetFeatureCount() != 2: - gdaltest.post_reason('Lower dimension geometries not removed in identity') - return 'fail' + assert layer3.GetFeatureCount() == 2, \ + 'Lower dimension geometries not removed in identity' layer3 = ds.CreateLayer('layer3f') layer1.Identity(layer2, layer3, ['KEEP_LOWER_DIMENSION_GEOMETRIES=YES']) - if layer3.GetFeatureCount() != 4: - gdaltest.post_reason('Lower dimension geometries not kept in identity') - return 'fail' + assert layer3.GetFeatureCount() == 4, \ + 'Lower dimension geometries not kept in identity' return 'success' @@ -350,26 +322,20 @@ def test_algebra_union(): err = A.Union(B, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Union') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Union') - if C.GetFeatureCount() != 5: - gdaltest.post_reason('Layer.Union returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 5, \ + ('Layer.Union returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() err = A.Union(B, C, options=['PROMOTE_TO_MULTI=YES']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Union') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Union') - if C.GetFeatureCount() != 5: - gdaltest.post_reason('Layer.Union returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 5, \ + ('Layer.Union returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -378,13 +344,9 @@ def test_algebra_union(): err = D1.Union(D2, C, ['KEEP_LOWER_DIMENSION_GEOMETRIES=NO']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Union') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Union') - if not is_same(D1, C): - gdaltest.post_reason('D1 != C') - return 'fail' + assert is_same(D1, C), 'D1 != C' recreate_layer_C() @@ -393,13 +355,10 @@ def test_algebra_union(): err = B.Union(pointInB, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Union') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Union') - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Union returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Union returned ' + str(C.GetFeatureCount()) + ' features') return 'success' @@ -415,26 +374,20 @@ def test_algebra_symdifference(): err = A.SymDifference(B, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.SymDifference') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.SymDifference') - if C.GetFeatureCount() != 3: - gdaltest.post_reason('Layer.SymDifference returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 3, \ + ('Layer.SymDifference returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() err = A.SymDifference(B, C, options=['PROMOTE_TO_MULTI=YES']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.SymDifference') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.SymDifference') - if C.GetFeatureCount() != 3: - gdaltest.post_reason('Layer.SymDifference returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 3, \ + ('Layer.SymDifference returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -443,13 +396,10 @@ def test_algebra_symdifference(): err = D1.SymDifference(D2, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.SymDifference') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.SymDifference') - if C.GetFeatureCount() != 0: - gdaltest.post_reason('Layer.SymDifference returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 0, \ + ('Layer.SymDifference returned ' + str(C.GetFeatureCount()) + ' features') return 'success' @@ -465,26 +415,20 @@ def test_algebra_identify(): err = A.Identity(B, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Identity') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Identity') - if C.GetFeatureCount() != 4: - gdaltest.post_reason('Layer.Identity returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 4, \ + ('Layer.Identity returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() err = A.Identity(B, C, options=['PROMOTE_TO_MULTI=YES']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Identity') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Identity') - if C.GetFeatureCount() != 4: - gdaltest.post_reason('Layer.Identity returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 4, \ + ('Layer.Identity returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -493,13 +437,9 @@ def test_algebra_identify(): err = D1.Identity(D2, C, ['KEEP_LOWER_DIMENSION_GEOMETRIES=NO']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Identity') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Identity') - if not is_same(D1, C): - gdaltest.post_reason('D1 != C') - return 'fail' + assert is_same(D1, C), 'D1 != C' return 'success' @@ -515,26 +455,20 @@ def test_algebra_update(): err = A.Update(B, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Update') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Update') - if C.GetFeatureCount() != 3: - gdaltest.post_reason('Layer.Update returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 3, \ + ('Layer.Update returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() err = A.Update(B, C, options=['PROMOTE_TO_MULTI=YES']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Update') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Update') - if C.GetFeatureCount() != 3: - gdaltest.post_reason('Layer.Update returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 3, \ + ('Layer.Update returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -543,13 +477,9 @@ def test_algebra_update(): err = D1.Update(D2, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Update') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Update') - if not is_same(D1, C): - gdaltest.post_reason('D1 != C') - return 'fail' + assert is_same(D1, C), 'D1 != C' return 'success' @@ -565,26 +495,20 @@ def test_algebra_clip(): err = A.Clip(B, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Clip') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Clip') - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Clip returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Clip returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() err = A.Clip(B, C, options=['PROMOTE_TO_MULTI=YES']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Clip') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Clip') - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Clip returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Clip returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -593,13 +517,9 @@ def test_algebra_clip(): err = D1.Update(D2, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Clip') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Clip') - if not is_same(D1, C): - gdaltest.post_reason('D1 != C') - return 'fail' + assert is_same(D1, C), 'D1 != C' return 'success' @@ -615,26 +535,20 @@ def test_algebra_erase(): err = A.Erase(B, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Erase') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Erase') - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() err = A.Erase(B, C, options=['PROMOTE_TO_MULTI=YES']) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Erase') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Erase') - if C.GetFeatureCount() != 2: - gdaltest.post_reason('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 2, \ + ('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -643,13 +557,10 @@ def test_algebra_erase(): err = D1.Erase(D2, C) if ogrtest.have_geos(): - if err != 0: - gdaltest.post_reason('got non-zero result code ' + str(err) + ' from Layer.Erase') - return 'fail' + assert err == 0, ('got non-zero result code ' + str(err) + ' from Layer.Erase') - if C.GetFeatureCount() != 0: - gdaltest.post_reason('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == 0, \ + ('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() @@ -657,9 +568,8 @@ def test_algebra_erase(): A.Erase(empty, C) - if C.GetFeatureCount() != A.GetFeatureCount(): - gdaltest.post_reason('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == A.GetFeatureCount(), \ + ('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') A.ResetReading() feat_a = A.GetNextFeature() @@ -674,9 +584,8 @@ def test_algebra_erase(): A.Erase(empty, C, options=['PROMOTE_TO_MULTI=YES']) - if C.GetFeatureCount() != A.GetFeatureCount(): - gdaltest.post_reason('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') - return 'fail' + assert C.GetFeatureCount() == A.GetFeatureCount(), \ + ('Layer.Erase returned ' + str(C.GetFeatureCount()) + ' features') recreate_layer_C() diff --git a/autotest/ogr/ogr_libkml.py b/autotest/ogr/ogr_libkml.py index 000db62e2cfd..66df2752177f 100755 --- a/autotest/ogr/ogr_libkml.py +++ b/autotest/ogr/ogr_libkml.py @@ -37,6 +37,7 @@ from osgeo import ogr from osgeo import osr from osgeo import gdal +import pytest ############################################################################### # Test basic open operation for KML datastore. @@ -68,10 +69,7 @@ def test_ogr_libkml_datastore(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds.GetLayerCount() != 10: - gdaltest.post_reason('wrong number of layers') - print(ogrtest.kml_ds.GetLayerCount()) - return 'fail' + assert ogrtest.kml_ds.GetLayerCount() == 10, 'wrong number of layers' return 'success' @@ -85,49 +83,34 @@ def test_ogr_libkml_attributes_1(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Placemarks') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Simple placemark': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Simple placemark', 'Wrong name field value' if feat.GetField('description')[:23] != 'Attached to the ground.': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')[:23]) - return 'fail' + pytest.fail('Wrong description field value') feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' - if feat.GetField('Name') != 'Floating placemark': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Floating placemark', 'Wrong name field value' if feat.GetField('description')[:25] != 'Floats a defined distance': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')[:25]) - return 'fail' + pytest.fail('Wrong description field value') feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' - if feat.GetField('Name') != 'Extruded placemark': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Extruded placemark', 'Wrong name field value' if feat.GetField('description') != 'Tethered to the ground by a customizable\n \"tail\"': - gdaltest.post_reason('Wrong description field value') print('got: ', feat.GetField('description')) - return 'fail' + pytest.fail('Wrong description field value') return 'success' @@ -141,26 +124,19 @@ def test_ogr_libkml_attributes_2(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Highlighted Icon') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Roll over this icon': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Roll over this icon', 'Wrong name field value' if feat.GetField('description') is not None: - gdaltest.post_reason('Wrong description field value') print("'%s'" % feat.GetField('description')) - return 'fail' + pytest.fail('Wrong description field value') feat = lyr.GetNextFeature() - if feat is not None: - gdaltest.post_reason('unexpected feature found.') - return 'fail' + assert feat is None, 'unexpected feature found.' return 'success' @@ -174,38 +150,26 @@ def test_ogr_libkml_attributes_3(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Paths') feat = lyr.GetNextFeature() - if feat.GetField('Name') != 'Tessellated': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Tessellated', 'Wrong name field value' - if feat.GetField('description') != 'If the tag has a value of 1, the line will contour to the underlying terrain': - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') == 'If the tag has a value of 1, the line will contour to the underlying terrain', \ + 'Wrong description field value' feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' - if feat.GetField('Name') != 'Untessellated': - gdaltest.post_reason('Wrong name field value') - return 'fail' + assert feat.GetField('Name') == 'Untessellated', 'Wrong name field value' - if feat.GetField('description') != 'If the tag has a value of 0, the line follow a simple straight-line path from point to point': - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') == 'If the tag has a value of 0, the line follow a simple straight-line path from point to point', \ + 'Wrong description field value' feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' return 'success' @@ -219,9 +183,7 @@ def test_ogr_libkml_attributes_4(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Google Campus') feat = lyr.GetNextFeature() @@ -230,13 +192,10 @@ def test_ogr_libkml_attributes_4(): while feat is not None: name = 'Building %d' % i if feat.GetField('Name') != name: - gdaltest.post_reason('Wrong name field value') print('Got: "%s"' % feat.GetField('name')) - return 'fail' + pytest.fail('Wrong name field value') - if feat.GetField('description') is not None: - gdaltest.post_reason('Wrong description field value') - return 'fail' + assert feat.GetField('description') is None, 'Wrong description field value' i = i + 1 feat = lyr.GetNextFeature() @@ -253,9 +212,7 @@ def test_ogr_libkml_point_read(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Placemarks') lyr.ResetReading() @@ -263,28 +220,21 @@ def test_ogr_libkml_point_read(): wkt = 'POINT(-122.0822035425683 37.42228990140251)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POINT(-122.084075 37.4220033612141 50)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POINT(-122.0857667006183 37.42156927867553 50)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -298,35 +248,26 @@ def test_ogr_libkml_linestring_read(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Paths') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'LINESTRING (-112.081423783034495 36.106778704771372 0, -112.087026775269294 36.0905099328766 0)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'LINESTRING (-112.080622229594994 36.106734600079953 0,-112.085242575314993 36.090495986124218 0)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'LINESTRING (-112.265654928602004 36.094476726025462 2357,-112.266038452823807 36.093426088386707 2357,-112.266813901345301 36.092510587768807 2357,-112.267782683444494 36.091898273579957 2357,-112.268855751095202 36.091313794118697 2357,-112.269481071721899 36.090367720752099 2357,-112.269526855561097 36.089321714872852 2357,-112.269014456727604 36.088509160604723 2357,-112.268152881533894 36.087538135979557 2357,-112.2670588176031 36.086826852625677 2357,-112.265737458732104 36.086463123013033 2357)' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -340,44 +281,32 @@ def test_ogr_libkml_polygon_read(): if not ogrtest.have_read_libkml: return 'skip' - if ogrtest.kml_ds is None: - gdaltest.post_reason('libkml_ds is none') - return 'fail' + assert ogrtest.kml_ds is not None, 'libkml_ds is none' lyr = ogrtest.kml_ds.GetLayerByName('Google Campus') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'POLYGON ((-122.084893845961204 37.422571240447859 17,-122.084958097919795 37.422119226268563 17,-122.084746957304702 37.42207183952619 17,-122.084572538096197 37.422090067296757 17,-122.084595488672306 37.422159327008949 17,-122.0838521118269 37.422272785643713 17,-122.083792243334997 37.422035391120843 17,-122.0835076656616 37.422090069571063 17,-122.083470946415204 37.422009873951609 17,-122.083122108574798 37.422104649494599 17,-122.082924737457205 37.422265039903863 17,-122.082933916938501 37.422312428430942 17,-122.083383735973698 37.422250460876178 17,-122.083360785424802 37.422341592287452 17,-122.083420455164202 37.42237075460644 17,-122.083659133885007 37.422512920110009 17,-122.083975843895203 37.422658730937812 17,-122.084237474333094 37.422651439725207 17,-122.0845036949503 37.422651438643499 17,-122.0848020460801 37.422611339163147 17,-122.084788275051494 37.422563950551208 17,-122.084893845961204 37.422571240447859 17))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POLYGON ((-122.085741277148301 37.422270331552568 17,-122.085816976848093 37.422314088323461 17,-122.085852582875006 37.422303374697442 17,-122.085879994563896 37.422256861387893 17,-122.085886010140896 37.422231107613797 17,-122.085806915728796 37.422202501738553 17,-122.085837954265301 37.42214027058678 17,-122.085673264051906 37.422086902144081 17,-122.085602292640701 37.42214885429042 17,-122.085590277843593 37.422128290487002 17,-122.085584167223701 37.422081719672462 17,-122.085485206574106 37.42210455874995 17,-122.085506726435199 37.422142679498243 17,-122.085443071291493 37.422127838461719 17,-122.085099071490404 37.42251282407603 17,-122.085676981863202 37.422818153236513 17,-122.086016227378295 37.422449188587223 17,-122.085726032700407 37.422292396042529 17,-122.085741277148301 37.422270331552568 17))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POLYGON ((-122.085786228724203 37.421362088869692 25,-122.085731299060299 37.421369359894811 25,-122.085731299291794 37.421409349109027 25,-122.085607707367899 37.421383901665649 25,-122.085580242651602 37.42137299550869 25,-122.085218622197104 37.421372995043157 25,-122.085227776563897 37.421616565082651 25,-122.085259818934702 37.421605658944031 25,-122.085259818549901 37.421682001560001 25,-122.085236931147804 37.421700178603459 25,-122.085264395782801 37.421761979825753 25,-122.085323903274599 37.421761980139067 25,-122.085355945432397 37.421852864451999 25,-122.085410875246296 37.421889218237339 25,-122.085479537935697 37.42189285337048 25,-122.085543622981902 37.421889217975462 25,-122.085626017804202 37.421860134999257 25,-122.085937287963006 37.421860134536047 25,-122.085942871866607 37.42160898590042 25,-122.085965546986102 37.421579927591438 25,-122.085864046234093 37.421471150029568 25,-122.0858548911215 37.421405713261841 25,-122.085809116276806 37.4214057134039 25,-122.085786228724203 37.421362088869692 25))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() - if feat is None: - gdaltest.post_reason('expected feature not found.') - return 'fail' + assert feat is not None, 'expected feature not found.' wkt = 'POLYGON ((-122.084437112828397 37.421772530030907 19,-122.084511885574599 37.421911115428962 19,-122.0850470999805 37.421787551215353 19,-122.085071991339106 37.421436630231611 19,-122.084916406231997 37.421372378221157 19,-122.084219386816699 37.421372378016258 19,-122.084219386589993 37.421476171614962 19,-122.083808641999099 37.4214613409357 19,-122.083789972856394 37.421313064107963 19,-122.083279653469802 37.421293288405927 19,-122.083260981920702 37.421392139442979 19,-122.082937362173695 37.421372363998763 19,-122.082906242566693 37.421515697788713 19,-122.082850226966499 37.421762825764652 19,-122.082943578863507 37.421767769696352 19,-122.083217411188002 37.421792485526858 19,-122.0835970430103 37.421748007445601 19,-122.083945555677104 37.421693642376027 19,-122.084007789463698 37.421762838158529 19,-122.084113587521003 37.421748011043917 19,-122.084076247378405 37.421713412923751 19,-122.084144704773905 37.421678815345693 19,-122.084144704222993 37.421817206601972 19,-122.084250333307395 37.421817070044597 19,-122.084437112828397 37.421772530030907 19))' - if ogrtest.check_feature_geometry(feat, wkt): - return 'fail' + assert not ogrtest.check_feature_geometry(feat, wkt) return 'success' @@ -399,13 +328,9 @@ def ogr_libkml_write(filename): dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' - if dst_feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49)': - print(dst_feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('CreateFeature changed the geometry.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' + assert dst_feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49)', \ + 'CreateFeature changed the geometry.' lyr = ds.CreateLayer('test_wgs84') @@ -421,51 +346,35 @@ def ogr_libkml_write(filename): dst_feat.SetField('description', 'my_description') dst_feat.SetField('foo', 'bar') dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49 1)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('LINESTRING (0 1,2 3)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0),(0.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTIPOINT (2 49,2 49)')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTILINESTRING ((0 1,2 3),(0 1,2 3))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('MULTIPOLYGON (((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0),(0.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0)),((-0.25 0.25 0,-0.25 0.75 0,-0.75 0.75 0,-0.75 0.25 0,-0.25 0.25 0)))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1,2 3))')) - if lyr.CreateFeature(dst_feat) != 0: - gdaltest.post_reason('CreateFeature failed.') - return 'fail' + assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' ds = None @@ -485,69 +394,42 @@ def ogr_libkml_check_write(filename): lyr = ds.GetLayerByName('test_wgs84') else: lyr = ds.GetLayer(0) - if lyr.GetFeatureCount() != 8: - gdaltest.post_reason('Bad feature count.') - return 'fail' + assert lyr.GetFeatureCount() == 8, 'Bad feature count.' feat = lyr.GetNextFeature() - if feat.GetField('name') != 'my_name': - print(feat.GetField('name')) - gdaltest.post_reason('Unexpected name.') - return 'fail' - if feat.GetField('description') != 'my_description': - print(feat.GetField('description')) - gdaltest.post_reason('Unexpected description.') - return 'fail' - if feat.GetField('foo') != 'bar': - print(feat.GetField('foo')) - gdaltest.post_reason('Unexpected foo.') - return 'fail' - if feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49 0)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetField('name') == 'my_name', 'Unexpected name.' + assert feat.GetField('description') == 'my_description', 'Unexpected description.' + assert feat.GetField('foo') == 'bar', 'Unexpected foo.' + assert feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49 0)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'POINT (2 49 1)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'POINT (2 49 1)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'LINESTRING (0 1 0,2 3 0)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'LINESTRING (0 1 0,2 3 0)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'POLYGON ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0),(0.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'POLYGON ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0),(0.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0))', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOINT (2 49 0,2 49 0)': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'MULTIPOINT (2 49 0,2 49 0)', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'MULTILINESTRING ((0 1 0,2 3 0),(0 1 0,2 3 0))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'MULTILINESTRING ((0 1 0,2 3 0),(0 1 0,2 3 0))', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'MULTIPOLYGON (((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0),(0.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0)),((-0.25 0.25 0,-0.25 0.75 0,-0.75 0.75 0,-0.75 0.25 0,-0.25 0.25 0)))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'MULTIPOLYGON (((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0),(0.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0)),((-0.25 0.25 0,-0.25 0.75 0,-0.75 0.75 0,-0.75 0.25 0,-0.25 0.25 0)))', \ + 'Unexpected geometry.' feat = lyr.GetNextFeature() - if feat.GetGeometryRef().ExportToWkt() != 'GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1 0,2 3 0))': - print(feat.GetGeometryRef().ExportToWkt()) - gdaltest.post_reason('Unexpected geometry.') - return 'fail' + assert feat.GetGeometryRef().ExportToWkt() == 'GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1 0,2 3 0))', \ + 'Unexpected geometry.' ds = None @@ -614,9 +496,8 @@ def test_ogr_libkml_xml_attributes(): feat = lyr.GetNextFeature() if feat.GetField('description').find('Description

      Interesting

      ') != 0: - gdaltest.post_reason('Wrong description field value') print('got: %s ' % feat.GetField('description')) - return 'fail' + pytest.fail('Wrong description field value') ds = None @@ -658,9 +539,7 @@ def test_ogr_libkml_test_ogrsf(): ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' --config OGR_SKIP KML -ro data/samples.kml') - if ret.find("using driver `LIBKML'") == -1 or ret.find('INFO') == -1 or ret.find('ERROR') != -1: - print(ret) - return 'fail' + assert not (ret.find("using driver `LIBKML'") == -1 or ret.find('INFO') == -1 or ret.find('ERROR') != -1) return 'success' @@ -676,8 +555,7 @@ def test_ogr_libkml_read_placemark(): ds = ogr.Open('data/placemark.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() - if feat is None: - return 'fail' + assert feat is not None ds = None @@ -693,9 +571,7 @@ def test_ogr_libkml_read_empty(): return 'skip' ds = ogr.Open('data/empty.kml') - if ds.GetLayerCount() != 0: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 0 ds = None @@ -711,18 +587,12 @@ def test_ogr_libkml_read_emptylayers(): return 'skip' ds = ogr.Open('data/emptylayers.kml') - if ds.GetLayerCount() != 2: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 2 # --> One difference with the old KML driver - if ds.GetLayer(0).GetFeatureCount() != 1: - print(ds.GetLayer(0).GetFeatureCount()) - return 'fail' + assert ds.GetLayer(0).GetFeatureCount() == 1 - if ds.GetLayer(1).GetFeatureCount() != 0: - print(ds.GetLayer(1).GetFeatureCount()) - return 'fail' + assert ds.GetLayer(1).GetFeatureCount() == 0 ds = None @@ -741,14 +611,11 @@ def test_ogr_libkml_read_emptylayers_without_folder(): return 'skip' ds = ogr.Open('data/emptylayers_without_folder.kml') - if ds.GetLayerCount() != 1: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 1 # --> One difference with the old KML driver - if ds.GetLayer(0).GetName() != 'Test': - print("Layer name must be '" + ds.GetLayer(0).GetName() + "'.") - return 'fail' + assert ds.GetLayer(0).GetName() == 'Test', \ + ("Layer name must be '" + ds.GetLayer(0).GetName() + "'.") ds = None @@ -764,9 +631,7 @@ def test_ogr_libkml_read_schema(): return 'skip' ds = ogr.Open('data/test_schema.kml') - if ds.GetLayerCount() != 4: - print(ds.GetLayerCount()) - return 'fail' + assert ds.GetLayerCount() == 4 lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() @@ -781,12 +646,10 @@ def test_ogr_libkml_read_schema(): return 'fail' lyr = ds.GetLayer(2) - if lyr.GetLayerDefn().GetFieldIndex('foo') != -1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('foo') == -1 lyr = ds.GetLayer(3) - if lyr.GetLayerDefn().GetFieldIndex('foo') != -1: - return 'fail' + assert lyr.GetLayerDefn().GetFieldIndex('foo') == -1 ds = None @@ -904,15 +767,13 @@ def test_ogr_libkml_camera(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('') == -1 or \ + assert (not (data.find('') == -1 or \ data.find('2') == -1 or \ data.find('49') == -1 or \ data.find('70') == -1 or \ data.find('75') == -1 or \ data.find('10') == -1 or \ - data.find('relativeToGround') == -1: - print(data) - return 'fail' + data.find('relativeToGround') == -1)) ds = ogr.Open('/vsimem/ogr_libkml_camera.kml') lyr = ds.GetLayer(0) @@ -959,23 +820,19 @@ def test_ogr_libkml_write_layer_lookat(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('') == -1 or \ + assert (not (data.find('') == -1 or \ data.find('2') == -1 or \ data.find('49') == -1 or \ - data.find('150') == -1: - print(data) - return 'fail' + data.find('150') == -1)) - if data.find('') == -1 or \ + assert (not (data.find('') == -1 or \ data.find('3') == -1 or \ data.find('50') == -1 or \ data.find('100') == -1 or \ data.find('70') == -1 or \ data.find('50') == -1 or \ data.find('150') == -1 or \ - data.find('relativeToGround') == -1: - print(data) - return 'fail' + data.find('relativeToGround') == -1)) return 'success' @@ -999,16 +856,14 @@ def test_ogr_libkml_write_layer_camera(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('') == -1 or \ + assert (not (data.find('') == -1 or \ data.find('3') == -1 or \ data.find('50') == -1 or \ data.find('100') == -1 or \ data.find('70') == -1 or \ data.find('50') == -1 or \ data.find('10') == -1 or \ - data.find('relativeToGround') == -1: - print(data) - return 'fail' + data.find('relativeToGround') == -1)) return 'success' @@ -1071,9 +926,7 @@ def test_ogr_libkml_write_snippet(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('test_snippet') == -1: - print(data) - return 'fail' + assert data.find('test_snippet') != -1 ds = ogr.Open("/vsimem/ogr_libkml_write_snippet.kml") lyr = ds.GetLayer(0) @@ -1099,9 +952,7 @@ def test_ogr_libkml_write_atom_author(): filepath = '/vsimem/ogr_libkml_write_atom_author.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['author_name=name', 'author_uri=http://foo', 'author_email=foo@bar.com']) - if ds is None: - gdaltest.post_reason('Unable to create %s.' % filepath) - return 'fail' + assert ds is not None, ('Unable to create %s.' % filepath) ds = None f = gdal.VSIFOpenL(filepath, 'rb') @@ -1109,13 +960,11 @@ def test_ogr_libkml_write_atom_author(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('') == -1 or \ + assert (not (data.find('') == -1 or \ data.find('name') == -1 or \ data.find('http://foo') == -1 or \ - data.find('foo@bar.com') == -1: - print(data) - gdaltest.post_reason('failure to find an atom string') - return 'fail' + data.find('foo@bar.com') == -1)), \ + 'failure to find an atom string' return 'success' @@ -1131,9 +980,7 @@ def test_ogr_libkml_write_atom_link(): filepath = '/vsimem/ogr_libkml_write_atom_link.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['link=http://foo']) - if ds is None: - gdaltest.post_reason('Unable to create %s.' % filepath) - return 'fail' + assert ds is not None, ('Unable to create %s.' % filepath) ds = None f = gdal.VSIFOpenL(filepath, 'rb') @@ -1141,10 +988,8 @@ def test_ogr_libkml_write_atom_link(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('') == -1 or \ - data.find('') == -1: - print(data) - return 'fail' + assert (not (data.find('') == -1 or \ + data.find('') == -1)) return 'success' @@ -1160,9 +1005,7 @@ def test_ogr_libkml_write_phonenumber(): filepath = '/vsimem/ogr_libkml_write_phonenumber.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['phonenumber=tel:911']) - if ds is None: - gdaltest.post_reason('Unable to create %s.' % filepath) - return 'fail' + assert ds is not None, ('Unable to create %s.' % filepath) ds = None f = gdal.VSIFOpenL(filepath, 'rb') @@ -1170,9 +1013,7 @@ def test_ogr_libkml_write_phonenumber(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('tel:911') == -1: - print(data) - return 'fail' + assert data.find('tel:911') != -1 return 'success' @@ -1201,25 +1042,21 @@ def test_ogr_libkml_write_region(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('49') == -1 or \ + assert (not (data.find('49') == -1 or \ data.find('48') == -1 or \ data.find('3') == -1 or \ data.find('2') == -1 or \ data.find('256') == -1 or \ - data.find('-1') == -1: - print(data) - return 'fail' + data.find('-1') == -1)) - if data.find('90') == -1 or \ + assert (not (data.find('90') == -1 or \ data.find('-90') == -1 or \ data.find('180') == -1 or \ data.find('-180') == -1 or \ data.find('128') == -1 or \ data.find('10000000') == -1 or \ data.find('1') == -1 or \ - data.find('2') == -1: - print(data) - return 'fail' + data.find('2') == -1)) return 'success' @@ -1256,18 +1093,14 @@ def test_ogr_libkml_write_screenoverlay(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('http://foo') == -1 or \ - data.find('') == -1: - print(data) - return 'fail' + assert (not (data.find('http://foo') == -1 or \ + data.find('') == -1)) - if data.find('') == -1 or \ + assert (not (data.find('') == -1 or \ data.find('') == -1 or \ data.find('') == -1 or \ data.find('name') == -1 or \ - data.find('description') == -1: - print(data) - return 'fail' + data.find('description') == -1)) return 'success' @@ -1315,7 +1148,7 @@ def test_ogr_libkml_write_model(): data = data.decode('ascii') gdal.VSIFCloseL(f) - if data.find('2') == -1 or \ + assert (not (data.find('2') == -1 or \ data.find('49') == -1 or \ data.find('10') == -1 or \ data.find('relativeToGround') == -1 or \ @@ -1329,18 +1162,15 @@ def test_ogr_libkml_write_model(): data.find('1') == -1 or \ data.find('1') == -1 or \ data.find('http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.dae') == -1 or \ - data.find('http://foo') == -1: - print(data) - return 'fail' + data.find('http://foo') == -1)) # This can only appear if HTTP resource is available and GDAL is built with curl/http support if gdal.GetDriverByName('HTTP') is not None and \ (data.find('http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.gif') == -1 or data.find('cube.gif') == -1): - if gdaltest.gdalurlopen('http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.dae') is not None: - print(data) - return 'fail' + assert gdaltest.gdalurlopen('http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.dae') is None, \ + data return 'success' @@ -1446,15 +1276,13 @@ def test_ogr_libkml_read_write_style(): lines_ref = [l.strip() for l in styles.split('\n')] if lines_got != lines_ref: print(data) - print(styles) - return 'fail' + pytest.fail(styles) lines_got = lines[lines.index('