Skip to content

Commit 6648a95

Browse files
committed
Fix test
1 parent 69f45e3 commit 6648a95

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/core/expression/qgsexpressioncontextutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::processingModelAlgorithmSc
767767
modelPath = context.project()->projectStorage() ? context.project()->fileName() : context.project()->absoluteFilePath();
768768
}
769769

770-
const QString modelFolder = QFileInfo( modelPath ).path();
770+
const QString modelFolder = !modelPath.isEmpty() ? QFileInfo( modelPath ).path() : QString();
771771
modelScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "model_path" ), QDir::toNativeSeparators( modelPath ), true ) );
772772
modelScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "model_folder" ), QDir::toNativeSeparators( modelFolder ), true, true ) );
773773
modelScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "model_name" ), model->displayName(), true ) );

tests/src/analysis/testqgsprocessing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,8 +6014,8 @@ void TestQgsProcessing::modelScope()
60146014
QCOMPARE( scope->variable( QStringLiteral( "model_group" ) ).toString(), QStringLiteral( "testGroup" ) );
60156015
QVERIFY( scope->hasVariable( QStringLiteral( "model_path" ) ) );
60166016
QVERIFY( scope->hasVariable( QStringLiteral( "model_folder" ) ) );
6017-
QVERIFY( scope->variable( QStringLiteral( "model_path" ) ).toString().isEmpty() );
6018-
QVERIFY( scope->variable( QStringLiteral( "model_folder" ) ).toString().isEmpty() );
6017+
QCOMPARE( scope->variable( QStringLiteral( "model_path" ) ).toString(), QString() );
6018+
QCOMPARE( scope->variable( QStringLiteral( "model_folder" ) ).toString(), QString() );
60196019

60206020
QgsProject p;
60216021
pc.setProject( &p );

0 commit comments

Comments
 (0)