Skip to content
Permalink
Browse files

Fix tests where locale-dependent formatting of numbers is used

  • Loading branch information
wonder-sk committed Feb 23, 2016
1 parent b34105d commit 98713a94d4caddf7b11649b73485d19f071fce2f
@@ -17,7 +17,6 @@
#include <sqlite3.h>
#include <QDir>
#include <QString>
#include <QLocale>
#include <QObject>

#include "qgis.h"
@@ -1094,7 +1093,7 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
break;
}

return QLocale::system().toString( value, 'f', decimals ) + unitLabel;
return QString( "%L1%2" ).arg( value, 0, 'f', decimals ).arg( unitLabel );
}

QString QgsDistanceArea::formatArea( double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit )
@@ -1229,7 +1228,7 @@ QString QgsDistanceArea::formatArea( double area, int decimals, QgsUnitTypes::Ar
}
}

return QLocale::system().toString( area, 'f', decimals ) + unitLabel;
return QString( "%L1%2" ).arg( area, 0, 'f', decimals ).arg( unitLabel );
}

void QgsDistanceArea::convertMeasurement( double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea ) const
@@ -16,7 +16,6 @@

#include "qgsunittypes.h"
#include <QCoreApplication>
#include <QLocale>

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
@@ -938,7 +937,7 @@ QString QgsUnitTypes::formatAngle( double angle, int decimals, QgsUnitTypes::Ang
break;
}

return QLocale::system().toString( angle, 'f', decimals ) + unitLabel;
return QString( "%L1%2" ).arg( angle, 0, 'f', decimals ).arg( unitLabel );
}

// enable for QGIS 3.0
@@ -55,6 +55,10 @@ void TestQgsMapToolIdentifyAction::initTestCase()
QCoreApplication::setApplicationName( "QGIS-TEST" );

QgsApplication::showSettings();

// enforce C locale because the tests expect it
// (decimal separators / thousand separators)
QLocale::setDefault( QLocale::c() );
}

void TestQgsMapToolIdentifyAction::cleanupTestCase()
@@ -69,6 +69,10 @@ void TestQgsMeasureTool::initTestCase()

mQgisApp = new QgisApp();
mCanvas = new QgsMapCanvas();

// enforce C locale because the tests expect it
// (decimal separators / thousand separators)
QLocale::setDefault( QLocale::c() );
}

//runs after all tests
@@ -20,6 +20,11 @@
QGis,
QgsSymbolV2
)
from PyQt4.QtCore import QLocale

# enforce C locale because the tests expect it
# (decimal separators / thousand separators)
QLocale.setDefault(QLocale.c())


class TestQgsUnitTypes(unittest.TestCase):

0 comments on commit 98713a9

Please sign in to comment.
You can’t perform that action at this time.