17
17
from PyQt4 import QtCore
18
18
import sys
19
19
import os
20
+ import glob
21
+ import re
20
22
import time
21
23
# import locale
22
24
import shutil
@@ -35,6 +37,8 @@ class TestPyQgsAppStartup(unittest.TestCase):
35
37
@classmethod
36
38
def setUpClass (cls ):
37
39
cls .TMP_DIR = tempfile .mkdtemp ()
40
+ # print 'TMP_DIR: ' + cls.TMP_DIR
41
+ # subprocess.call(['open', cls.TMP_DIR])
38
42
39
43
@classmethod
40
44
def tearDownClass (cls ):
@@ -93,29 +97,32 @@ def testOptionsPath(self):
93
97
if sys .platform [:3 ] == 'dar' : # Mac
94
98
subdir = 'qgis.org'
95
99
ini = os .path .join (subdir , 'QGIS2.ini' )
96
- for p in ['test_opts' , 'test opts' , 'test_optsé€' ]:
100
+ for p in ['test_opts' , 'test opts' , u 'test_optsé€' ]:
97
101
assert self .doTestStartup (option = "--optionspath" ,
98
102
testDir = os .path .join (self .TMP_DIR , p ),
99
103
testFile = ini ,
100
104
timeOut = 5 ), "options path %s" % p
101
105
102
106
def testConfigPath (self ):
103
- for p in ['test_config' , 'test config' , 'test_configé€' ]:
107
+ for p in ['test_config' , 'test config' , u 'test_configé€' ]:
104
108
assert self .doTestStartup (option = "--configpath" ,
105
109
testDir = os .path .join (self .TMP_DIR , p ),
106
110
testFile = "qgis.db" ,
107
111
timeOut = 30 ), "config path %s" % p
108
112
109
113
def testPluginPath (self ):
110
- for t in ['test_plugins' , 'test plugins' , 'test_pluginsé€' ]:
114
+ for t in ['test_plugins' , 'test plugins' , u 'test_pluginsé€' ]:
111
115
112
116
# get a unicode test dir
113
- testDir = ( os .path .join (self .TMP_DIR , t )). decode ( 'utf-8' )
117
+ testDir = os .path .join (self .TMP_DIR , t )
114
118
115
119
# copy from testdata
116
- shutil .rmtree (testDir , ignore_errors = True )
117
- shutil .copytree (os .path .join (TEST_DATA_DIR , 'test_plugin_path' ),
118
- testDir )
120
+ if not os .path .exists (testDir ):
121
+ os .mkdir (testDir )
122
+ test_plug_dir = os .path .join (TEST_DATA_DIR , 'test_plugin_path' )
123
+ for item in os .listdir (test_plug_dir ):
124
+ shutil .copytree (os .path .join (test_plug_dir , item ),
125
+ os .path .join (testDir , item ))
119
126
120
127
# we use here a minimal plugin that writes to 'plugin_started.txt'
121
128
# when it is started. if QGIS_PLUGINPATH is correctly parsed, this
@@ -164,13 +171,19 @@ def testPyQgisStartupEnvVar(self):
164
171
if os .path .exists (b ):
165
172
QGIS_BIN = b
166
173
break
167
- b = os .path .abspath (os .path .join (d , 'QGIS.app/Contents/MacOS/QGIS' ))
168
- if os .path .exists (b ):
169
- QGIS_BIN = b
170
- break
174
+ if sys .platform [:3 ] == 'dar' : # Mac
175
+ # QGIS.app may be QGIS_x.x-dev.app for nightlies
176
+ # internal binary will match, minus the '.app'
177
+ found = False
178
+ for app_path in glob .glob (d + '/QGIS*.app' ):
179
+ m = re .search ('/(QGIS(_\d\.\d-dev)?)\.app' , app_path )
180
+ if m :
181
+ QGIS_BIN = app_path + '/Contents/MacOS/' + m .group (1 )
182
+ found = True
183
+ break
184
+ if found :
185
+ break
171
186
172
- print ''
173
- print 'QGIS_BIN: ' , QGIS_BIN
174
- assert 'qgis' in QGIS_BIN .lower () and os .path .exists (QGIS_BIN ), \
175
- 'QGIS binary not found, skipping test suite'
187
+ print '\n QGIS_BIN: ' , QGIS_BIN
188
+ assert QGIS_BIN , 'QGIS binary not found, skipping test suite'
176
189
unittest .main ()
0 commit comments