Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix locale problems in PyQgsAppStartup test
  • Loading branch information
m-kuhn committed Mar 29, 2016
1 parent 0cc7ae0 commit fbc2a4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/python/qgspythonutilsimpl.cpp
Expand Up @@ -82,7 +82,7 @@ bool QgsPythonUtilsImpl::checkSystemImports()
// locally installed plugins have priority over the system plugins
// use os.path.expanduser to support usernames with special characters (see #2512)
QStringList pluginpaths;
Q_FOREACH ( QString p, extraPluginsPaths() )
Q_FOREACH ( const QString& p, extraPluginsPaths() )
{
if ( !QDir( p ).exists() )
{
Expand All @@ -97,7 +97,11 @@ bool QgsPythonUtilsImpl::checkSystemImports()
// we store here paths in unicode strings
// the str constant will contain utf8 code (through runString)
// so we call '...'.decode('utf-8') to make a unicode string
#if (PY_VERSION_HEX < 0x03000000)
pluginpaths << '"' + p + "\".decode('utf-8')";
#else
pluginpaths << '"' + p + '"';
#endif
}
pluginpaths << homePluginsPath();
pluginpaths << '"' + pluginsPath() + '"';
Expand Down
5 changes: 4 additions & 1 deletion tests/src/python/test_qgsappstartup.py
Expand Up @@ -23,6 +23,7 @@
import subprocess
import tempfile
import errno
import locale

from qgis.testing import unittest
from utilities import unitTestDataPath
Expand Down Expand Up @@ -118,6 +119,8 @@ def testPluginPath(self):
for t in ['test_plugins', 'test plugins', u'test_pluginsé€']:

# get a unicode test dir
if sys.version_info.major == 2:
t = t.encode(locale.getpreferredencoding())
testDir = os.path.join(self.TMP_DIR, t)

# copy from testdata
Expand All @@ -137,7 +140,7 @@ def testPluginPath(self):
testFile="plugin_started.txt",
timeOut=270,
loadPlugins=True,
env={'QGIS_PLUGINPATH': testDir.encode('ascii', 'ignore')})
env={'QGIS_PLUGINPATH': testDir})

def testPyQgisStartupEnvVar(self):
# verify PYQGIS_STARTUP env variable file is run by embedded interpreter
Expand Down

0 comments on commit fbc2a4e

Please sign in to comment.