Merge lp:~coreygoldberg/selenium-simple-test/modernize-me into lp:selenium-simple-test

Proposed by Corey Goldberg
Status: Merged
Approved by: Corey Goldberg
Approved revision: 445
Merged at revision: 435
Proposed branch: lp:~coreygoldberg/selenium-simple-test/modernize-me
Merge into: lp:selenium-simple-test
Diff against target: 322 lines (+32/-30)
14 files modified
src/sst/actions.py (+2/-3)
src/sst/cases.py (+8/-6)
src/sst/command.py (+6/-4)
src/sst/concurrency.py (+0/-2)
src/sst/config.py (+0/-1)
src/sst/context.py (+1/-2)
src/sst/filters.py (+1/-0)
src/sst/loaders.py (+1/-0)
src/sst/results.py (+1/-0)
src/sst/scripts/test.py (+7/-6)
src/sst/tests/test_django_devserver.py (+2/-2)
src/sst/xvfbdisplay.py (+0/-1)
src/testproject/manage.py (+2/-2)
tox.ini (+1/-1)
To merge this branch: bzr merge lp:~coreygoldberg/selenium-simple-test/modernize-me
Reviewer Review Type Date Requested Status
Leo Arias (community) code review Approve
Review via email: mp+185642@code.launchpad.net

Commit message

modernize python files for easier porting.

Description of the change

modernize python files for easier porting to py3.

ran `python-modernize` with `--no-six` and `--compat-unicode` options.

To post a comment you must log in.
438. By Corey Goldberg

fixed imports

439. By Corey Goldberg

single quotes

440. By Corey Goldberg

remove extra paren

441. By Corey Goldberg

pep8 fix

442. By Corey Goldberg

tuple fix

443. By Corey Goldberg

fix parens

444. By Corey Goldberg

changed prints to logger.debug() when reading csv data

445. By Corey Goldberg

whitespace fixes

Revision history for this message
Leo Arias (elopio) wrote :

Looks nice. Thank you!

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sst/actions.py'
2--- src/sst/actions.py 2013-07-05 16:05:28 +0000
3+++ src/sst/actions.py 2013-09-15 16:25:48 +0000
4@@ -39,7 +39,6 @@
5
6 """
7
8-
9 import codecs
10 import errno
11 import logging
12@@ -100,7 +99,7 @@
13 logger = logging.getLogger('SST')
14
15
16-class EndTest(StandardError):
17+class EndTest(Exception):
18 pass
19
20
21@@ -271,7 +270,7 @@
22 "results_directory should be set")
23 try:
24 os.makedirs(config.results_directory)
25- except OSError, e:
26+ except OSError as e:
27 if e.errno != errno.EEXIST:
28 raise
29
30
31=== modified file 'src/sst/cases.py'
32--- src/sst/cases.py 2013-08-14 13:57:48 +0000
33+++ src/sst/cases.py 2013-09-15 16:25:48 +0000
34@@ -17,12 +17,15 @@
35 # limitations under the License.
36 #
37
38+from __future__ import print_function
39+
40 import ast
41 import logging
42 import os
43 import pdb
44 import testtools
45 import testtools.content
46+import traceback
47
48 from selenium.common import exceptions
49 from sst import (
50@@ -32,7 +35,6 @@
51 context,
52 xvfbdisplay,
53 )
54-import traceback
55
56
57 logger = logging.getLogger('SST')
58@@ -97,13 +99,13 @@
59 max_attempts = 5
60 for nb_attempts in range(1, max_attempts):
61 try:
62- logger.debug('Starting browser (attempt: %d)' % (nb_attempts,))
63+ logger.debug('Starting browser (attempt: %d)' % nb_attempts)
64 self._start_browser()
65 break
66 except exceptions.WebDriverException:
67 if nb_attempts >= max_attempts:
68 raise
69- logger.debug('Browser started: %s' % (self.browser.name))
70+ logger.debug('Browser started: %s' % self.browser.name)
71
72 def stop_browser(self):
73 logger.debug('Stopping browser')
74@@ -201,7 +203,7 @@
75 def run_test_script(self, result=None):
76 # Run the test catching exceptions sstnam style
77 try:
78- exec self.code in self.context
79+ exec(self.code, self.context)
80 except actions.EndTest:
81 pass
82
83@@ -214,7 +216,7 @@
84 with data values.
85 """
86 rows = []
87- print ' Reading data from %r...' % os.path.split(csv_path)[-1],
88+ logger.debug('Reading data from %r' % os.path.split(csv_path)[-1])
89 row_num = 0
90 with open(csv_path) as f:
91 headers = f.readline().rstrip().split('^')
92@@ -236,5 +238,5 @@
93 value = True
94 row[header] = value
95 rows.append(row)
96- print 'found %s rows' % len(rows)
97+ logger.debug('found %s rows' % len(rows))
98 return rows
99
100=== modified file 'src/sst/command.py'
101--- src/sst/command.py 2013-08-14 13:26:05 +0000
102+++ src/sst/command.py 2013-09-15 16:25:48 +0000
103@@ -17,6 +17,8 @@
104 # limitations under the License.
105 #
106
107+from __future__ import print_function
108+
109 import errno
110 import logging
111 import optparse
112@@ -48,7 +50,7 @@
113 def reset_directory(path):
114 try:
115 shutil.rmtree(path)
116- except OSError, e:
117+ except OSError as e:
118 if e.errno != errno.ENOENT:
119 raise
120 os.makedirs(path)
121@@ -150,12 +152,12 @@
122 (cmd_opts, args) = parser.parse_args(args)
123
124 if cmd_opts.print_version:
125- print 'SST version: %s' % sst.__version__
126+ print('SST version: %s' % sst.__version__)
127 sys.exit()
128
129 if cmd_opts.browser_type not in browsers.browser_factories:
130- print ("Error: %s should be one of %s"
131- % (cmd_opts.browser_type, browsers.browser_factories.keys()))
132+ print('Error: %s should be one of %s' %
133+ cmd_opts.browser_type, browsers.browser_factories.keys())
134 sys.exit(1)
135
136 logging.basicConfig(format=' %(levelname)s:%(name)s:%(message)s')
137
138=== modified file 'src/sst/concurrency.py'
139--- src/sst/concurrency.py 2013-07-05 09:45:58 +0000
140+++ src/sst/concurrency.py 2013-09-15 16:25:48 +0000
141@@ -17,7 +17,6 @@
142 # limitations under the License.
143 #
144
145-
146 """Python testtools extension for running unittest suites concurrently.
147
148 The `testtools` project provides a ConcurrentTestSuite class, but does
149@@ -32,7 +31,6 @@
150 Unix only.
151 """
152
153-
154 import os
155 import sys
156 import traceback
157
158=== modified file 'src/sst/config.py'
159--- src/sst/config.py 2013-08-14 13:26:05 +0000
160+++ src/sst/config.py 2013-09-15 16:25:48 +0000
161@@ -17,7 +17,6 @@
162 # limitations under the License.
163 #
164
165-
166 """
167 The `sst.config` module has the following information::
168
169
170=== modified file 'src/sst/context.py'
171--- src/sst/context.py 2013-08-14 13:26:05 +0000
172+++ src/sst/context.py 2013-09-15 16:25:48 +0000
173@@ -17,7 +17,6 @@
174 # limitations under the License.
175 #
176
177-
178 import os
179
180 from sst import actions, config
181@@ -92,6 +91,6 @@
182 populate_context(context, location, config.browser_type, kwargs)
183
184 with open(location) as h:
185- exec h.read() in context
186+ exec(h.read(), context)
187
188 return context.get('RESULT')
189
190=== modified file 'src/sst/filters.py'
191--- src/sst/filters.py 2013-06-03 14:07:47 +0000
192+++ src/sst/filters.py 2013-09-15 16:25:48 +0000
193@@ -16,6 +16,7 @@
194 # See the License for the specific language governing permissions and
195 # limitations under the License.
196 #
197+
198 import re
199 import unittest
200
201
202=== modified file 'src/sst/loaders.py'
203--- src/sst/loaders.py 2013-07-05 08:30:22 +0000
204+++ src/sst/loaders.py 2013-09-15 16:25:48 +0000
205@@ -16,6 +16,7 @@
206 # See the License for the specific language governing permissions and
207 # limitations under the License.
208 #
209+
210 import contextlib
211 import fnmatch
212 import functools
213
214=== modified file 'src/sst/results.py'
215--- src/sst/results.py 2013-07-08 07:36:57 +0000
216+++ src/sst/results.py 2013-09-15 16:25:48 +0000
217@@ -16,6 +16,7 @@
218 # See the License for the specific language governing permissions and
219 # limitations under the License.
220 #
221+
222 from testtools import testresult
223
224
225
226=== modified file 'src/sst/scripts/test.py'
227--- src/sst/scripts/test.py 2013-08-14 13:34:54 +0000
228+++ src/sst/scripts/test.py 2013-09-15 16:25:48 +0000
229@@ -85,8 +85,8 @@
230 def run_django(port):
231 """Start django server for running local self-tests."""
232 if tests.check_devserver_port_used(port):
233- raise RuntimeError('Error: port %s is in use.\n'
234- 'Can not launch devserver for internal tests.'
235+ raise RuntimeError('Port %s is in use.\n'
236+ 'Can not launch Django server for internal tests.'
237 % (port,))
238 manage_file = os.path.abspath(
239 os.path.join(package_dir, '../testproject/manage.py'))
240@@ -94,9 +94,9 @@
241
242 if not os.path.isfile(manage_file):
243 raise RuntimeError(
244- 'Error: can not find the django testproject.\n'
245+ 'Can not find the django testproject.\n'
246 '%r does not exist\n'
247- 'you must run self-tests from the dev branch or package source.'
248+ 'you must run tests from the dev branch or package source.'
249 % (manage_file,))
250
251 proc = subprocess.Popen([manage_file, 'runserver', str(port)],
252@@ -104,7 +104,7 @@
253 stdout=open(os.devnull, 'w')
254 )
255 attempts = 30
256- for count in xrange(attempts):
257+ for count in range(attempts):
258 try:
259 resp = urllib.urlopen(url)
260 if resp.code == 200:
261@@ -112,7 +112,8 @@
262 except IOError:
263 time.sleep(0.2)
264 if count >= attempts - 1: # timeout
265- raise
266+ raise RuntimeError('Django server for acceptance '
267+ 'tests is not running.')
268 return proc
269
270
271
272=== modified file 'src/sst/tests/test_django_devserver.py'
273--- src/sst/tests/test_django_devserver.py 2013-07-05 17:13:50 +0000
274+++ src/sst/tests/test_django_devserver.py 2013-09-15 16:25:48 +0000
275@@ -58,7 +58,7 @@
276 self.assertTrue(used)
277 e = self.assertRaises(RuntimeError,
278 script_test.run_django, port)
279- self.assertEqual('Error: port %s is in use.\n'
280- 'Can not launch devserver for internal tests.'
281+ self.assertEqual('Port %s is in use.\n'
282+ 'Can not launch Django server for internal tests.'
283 % (port,),
284 e.args[0])
285
286=== modified file 'src/sst/xvfbdisplay.py'
287--- src/sst/xvfbdisplay.py 2013-07-05 16:40:19 +0000
288+++ src/sst/xvfbdisplay.py 2013-09-15 16:25:48 +0000
289@@ -22,7 +22,6 @@
290 # inspired by PyVirtualDisplay: http://pypi.python.org/pypi/PyVirtualDisplay
291 #
292
293-
294 import os
295 import fnmatch
296 import random
297
298=== modified file 'src/testproject/manage.py'
299--- src/testproject/manage.py 2012-12-16 15:25:23 +0000
300+++ src/testproject/manage.py 2013-09-15 16:25:48 +0000
301@@ -1,9 +1,9 @@
302 #!/usr/bin/env python
303+
304 from django.core.management import execute_manager
305
306-
307 import settings # assumed to be in the same directory.
308
309
310-if __name__ == "__main__":
311+if __name__ == '__main__':
312 execute_manager(settings)
313
314=== modified file 'tox.ini'
315--- tox.ini 2013-09-06 15:45:38 +0000
316+++ tox.ini 2013-09-15 16:25:48 +0000
317@@ -17,4 +17,4 @@
318 # print version and exit
319 sst-run -V
320 # run sst unit tests
321- {envpython} sst-test -q -s -x --extended-tracebacks ^sst.tests
322+ {envpython} sst-test -s -x --extended-tracebacks ^sst.tests

Subscribers

People subscribed via source and target branches