mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Merge pull request #5244 from nyalldawson/proc_misc
[processing] Misc test related fixes
This commit is contained in:
commit
8902d5f48f
@ -299,7 +299,7 @@ class ProcessingToolbox(BASE, WIDGET):
|
||||
context = dataobjects.createContext(feedback)
|
||||
parameters = {}
|
||||
ret, results = execute(alg, parameters, context, feedback)
|
||||
handleAlgorithmResults(alg, parameters, context, feedback)
|
||||
handleAlgorithmResults(alg, context, feedback)
|
||||
feedback.close()
|
||||
if isinstance(item, TreeActionItem):
|
||||
action = item.action
|
||||
|
@ -44,6 +44,7 @@ from qgis.core import (QgsApplication,
|
||||
QgsProcessingParameterBoolean,
|
||||
QgsProcessingParameterNumber,
|
||||
QgsProcessingParameterFile,
|
||||
QgsProcessingParameterBand,
|
||||
QgsProcessingParameterString,
|
||||
QgsProcessingParameterVectorLayer,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
@ -234,6 +235,8 @@ def createTest(text):
|
||||
params[param.name()] = [int(t) for t in token]
|
||||
else:
|
||||
params[param.name()] = int(token)
|
||||
elif isinstance(param, QgsProcessingParameterBand):
|
||||
params[param.name()] = int(token)
|
||||
elif token:
|
||||
if token[0] == '"':
|
||||
token = token[1:]
|
||||
|
@ -30,7 +30,7 @@ QGIS utilities module
|
||||
|
||||
from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread
|
||||
from qgis.PyQt.QtWidgets import QPushButton, QApplication
|
||||
from qgis.core import Qgis, QgsExpression, QgsMessageLog, qgsfunction, QgsMessageOutput, QgsWkbTypes, QgsApplication
|
||||
from qgis.core import Qgis, QgsExpression, QgsMessageLog, qgsfunction, QgsMessageOutput, QgsWkbTypes
|
||||
from qgis.gui import QgsMessageBar
|
||||
|
||||
import sys
|
||||
@ -133,7 +133,7 @@ def show_message_log(pop_error=True):
|
||||
|
||||
|
||||
def open_stack_dialog(type, value, tb, msg, pop_error=True):
|
||||
if pop_error:
|
||||
if pop_error and iface is not None:
|
||||
iface.messageBar().popWidget()
|
||||
|
||||
if msg is None:
|
||||
@ -189,7 +189,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
|
||||
|
||||
def qgis_excepthook(type, value, tb):
|
||||
# detect if running in the main thread
|
||||
in_main_thread = QThread.currentThread() == QgsApplication.instance().thread()
|
||||
in_main_thread = QCoreApplication.instance() is None or QThread.currentThread() == QCoreApplication.instance().thread()
|
||||
|
||||
# only use messagebar if running in main thread - otherwise it will crash!
|
||||
showException(type, value, tb, None, messagebar=in_main_thread)
|
||||
|
@ -2993,11 +2993,11 @@ QString QgsProcessingParameterRasterDestination::valueAsPythonString( const QVar
|
||||
QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
|
||||
if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
|
||||
{
|
||||
return QStringLiteral( "QgsProcessingOutputLayerDefinition('%1')" ).arg( fromVar.sink.staticValue().toString() );
|
||||
return QStringLiteral( "'%1'" ).arg( fromVar.sink.staticValue().toString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('%1'))" ).arg( fromVar.sink.asExpression() );
|
||||
return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -3071,11 +3071,11 @@ QString QgsProcessingParameterFileDestination::valueAsPythonString( const QVaria
|
||||
QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
|
||||
if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
|
||||
{
|
||||
return QStringLiteral( "QgsProcessingOutputLayerDefinition('%1')" ).arg( fromVar.sink.staticValue().toString() );
|
||||
return QStringLiteral( "'%1'" ).arg( fromVar.sink.staticValue().toString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('%1'))" ).arg( fromVar.sink.asExpression() );
|
||||
return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -3260,11 +3260,11 @@ QString QgsProcessingParameterVectorDestination::valueAsPythonString( const QVar
|
||||
QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
|
||||
if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
|
||||
{
|
||||
return QStringLiteral( "QgsProcessingOutputLayerDefinition('%1')" ).arg( fromVar.sink.staticValue().toString() );
|
||||
return QStringLiteral( "'%1'" ).arg( fromVar.sink.staticValue().toString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('%1'))" ).arg( fromVar.sink.asExpression() );
|
||||
return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3719,9 +3719,9 @@ void TestQgsProcessing::parameterVectorOut()
|
||||
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp", &context ) );
|
||||
|
||||
QCOMPARE( def->valueAsPythonString( QStringLiteral( "abc" ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromValue( "abc" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('\"abc\" || \"def\"'))" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromValue( "abc" ) ) ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"abc\" || \"def\"')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
|
||||
|
||||
QCOMPARE( def->defaultFileExtension(), QStringLiteral( "shp" ) );
|
||||
@ -3830,9 +3830,9 @@ void TestQgsProcessing::parameterRasterOut()
|
||||
QCOMPARE( QgsProcessingParameters::parameterAsOutputLayer( def.get(), params, context ), QStringLiteral( "test.tif" ) );
|
||||
|
||||
QCOMPARE( def->valueAsPythonString( QStringLiteral( "abc" ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromValue( "abc" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('\"abc\" || \"def\"'))" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromValue( "abc" ) ) ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"abc\" || \"def\"')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
|
||||
|
||||
QVariantMap map = def->toVariantMap();
|
||||
@ -3948,9 +3948,9 @@ void TestQgsProcessing::parameterFileOut()
|
||||
QCOMPARE( QgsProcessingParameters::parameterAsFileOutput( def.get(), params, context ), QStringLiteral( "test.txt" ) );
|
||||
|
||||
QCOMPARE( def->valueAsPythonString( QStringLiteral( "abc" ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromValue( "abc" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('\"abc\" || \"def\"'))" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromValue( "abc" ) ) ), context ), QStringLiteral( "'abc'" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"abc\" || \"def\"')" ) );
|
||||
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
|
||||
|
||||
QVariantMap map = def->toVariantMap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user