Merge lp:~dobey/ubuntuone-dev-tools/default-reactor into lp:ubuntuone-dev-tools

Proposed by dobey on 2012-06-05
Status: Merged
Approved by: dobey on 2012-06-06
Approved revision: 82
Merged at revision: 75
Proposed branch: lp:~dobey/ubuntuone-dev-tools/default-reactor
Merge into: lp:ubuntuone-dev-tools
Diff against target: 141 lines (+23/-21)
6 files modified
bin/u1lint (+0/-4)
bin/u1trial (+10/-6)
run-tests (+6/-5)
run-tests.bat (+4/-5)
setup.py (+1/-1)
ubuntuone/devtools/services/squid.py (+2/-0)
To merge this branch: bzr merge lp:~dobey/ubuntuone-dev-tools/default-reactor
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve on 2012-06-06
Mike McCracken (community) 2012-06-05 Approve on 2012-06-05
Review via email: mp+108823@code.launchpad.net

Commit Message

Define a method to get the platform-dependent default reactor and use it

To post a comment you must log in.
Mike McCracken (mikemc) wrote :

works for me on Windows.
on macos: runs same tests twice, since default is now twisted reactor
this is not a big deal to me, so I approve this merge

review: Approve
Manuel de la Peña (mandel) wrote :

Everything looks good. I would have simply done the following for the default reactor:

["reactor", "r", "gi" if sys.platform == "linux2" else "twisted"]

rather than using a function but I suppose the only reason I have to prefer that is that I'm lazy :)

review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (21.7 KiB)

The attempt to merge lp:~dobey/ubuntuone-dev-tools/default-reactor into lp:ubuntuone-dev-tools failed. Below is the output from the failed tests.

Starting squid version...
Waiting for squid to start....
Waiting for squid to start.....
Waiting for squid to start......
Waiting for squid to start.......
ubuntuone.devtools.testing.tests.test_txwebserver
  MultipleWebServersTestCase
    test_multiple_requests ... [OK]
    test_single_request ... [OK]
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntuone.devtools.testing.tests.test_txwebserver
  WebServerTestCase
    test_get_iri ... [OK]
    test_get_port ... [OK]
    test_multiple_requests ... [OK]
    test_single_request ... [OK]
ubuntuone.devtools.testcases
  BaseTestCase
    runTest ... [OK]
ubuntuone.devtools.services.tests.test_squid
  EnvironTestCase
    test_delete_proxy_settings_present ... [OK]
    test_retrieve_proxy_settings ... [OK]
    test_store_settings ... [OK]
  PathsTestCase
    test_get_auth_temp_path ... [OK]
    test_get_basedir_missing ... [OK]
    test_get_basedir_present ... [OK]
    test_get_spool_temp_path_missing ... [OK]
    test_get_spool_temp_path_present ... [OK]
    test_get_squid_temp_path_missing ... [OK]
    test_get_squid_temp_path_present ... [OK]
  SquidRunnerInitTestCase
    test_htpasswd_missing ... [OK]
    test_squid_missing ... [OK]
  SquidRunnerTestCase
    test_generate_auth_file ... [OK]
    test_generate_config_file ... [OK]
    test_generate_swap ... [OK]
    test_start_error ... [OK]
ubuntuone.devtools.testcases.dbus
  DBusTestCase
    runTest ... [OK]
ubuntuone.devtools.services.tests.test_dbus
  TestWithDBus
    test_config_file_path ... [OK]
    test_dbus_session_is_running ... [OK]
ubuntuone.devtools.services.tests.test_squid_linux
  SquidLinuxTestCase
    test_format_config_path ... [OK]
    test_get_auth_process ... [OK]
    test_get_auth_process_3 ... ...

82. By dobey on 2012-06-06

Can't use "$PYTHON pep8" as it doesn't auto-expand from $PATH

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1lint'
2--- bin/u1lint 2012-03-30 17:44:03 +0000
3+++ bin/u1lint 2012-06-06 13:30:25 +0000
4@@ -1,8 +1,4 @@
5 #!/usr/bin/python
6-
7-# u1lint: Wrapper script for pylint or pyflakes
8-#
9-# Author: Rodney Dawes <rodney.dawes@canonical.com>
10 #
11 # Copyright 2009-2012 Canonical Ltd.
12 #
13
14=== modified file 'bin/u1trial'
15--- bin/u1trial 2012-04-25 20:11:12 +0000
16+++ bin/u1trial 2012-06-06 13:30:25 +0000
17@@ -1,8 +1,4 @@
18-#!/usr/bin/env python
19-
20-# u1trial: Test runner for Python unit tests needing DBus
21-#
22-# Author: Rodney Dawes <rodney.dawes@canonical.com>
23+#!/usr/bin/python
24 #
25 # Copyright 2009-2012 Canonical Ltd.
26 #
27@@ -224,6 +220,14 @@
28 return result
29
30
31+def _get_default_reactor():
32+ """Return the platform-dependent default reactor to use."""
33+ default_reactor = 'gi'
34+ if sys.platform in ['darwin', 'win32']:
35+ default_reactor = 'twisted'
36+ return default_reactor
37+
38+
39 class Options(trial.Options):
40 """Class for options handling."""
41
42@@ -236,7 +240,7 @@
43 ["loop", None, 1],
44 ["ignore-modules", "i", ""],
45 ["ignore-paths", "p", ""],
46- ["reactor", "r", "gi"],
47+ ["reactor", "r", _get_default_reactor()],
48 ]
49
50 def __init__(self):
51
52=== modified file 'run-tests'
53--- run-tests 2012-04-24 16:37:39 +0000
54+++ run-tests 2012-06-06 13:30:25 +0000
55@@ -1,7 +1,6 @@
56 #!/bin/bash
57-# Author: Natalia Bidart <natalia.bidart@canonical.com>
58 #
59-# Copyright 2010-2011 Canonical Ltd.
60+# Copyright 2010-2012 Canonical Ltd.
61 #
62 # This program is free software: you can redistribute it and/or modify it
63 # under the terms of the GNU General Public License version 3, as published
64@@ -16,10 +15,12 @@
65 # with this program. If not, see <http://www.gnu.org/licenses/>.
66 set -e
67
68-bin/u1trial -i "test_squid_windows.py" -c ubuntuone
69-bin/u1trial --reactor=twisted -i "test_squid_windows.py" ubuntuone
70+PYTHON="python"
71+
72+$PYTHON bin/u1trial -i "test_squid_windows.py" -c ubuntuone
73+$PYTHON bin/u1trial --reactor=twisted -i "test_squid_windows.py" ubuntuone
74 echo "Running style checks..."
75-bin/u1lint
76+$PYTHON bin/u1lint
77 pep8 --repeat . bin/* --exclude=*.bat
78 rm -rf _trial_temp
79 rm -rf .coverage
80
81=== modified file 'run-tests.bat'
82--- run-tests.bat 2012-04-30 11:03:04 +0000
83+++ run-tests.bat 2012-06-06 13:30:25 +0000
84@@ -29,12 +29,11 @@
85 @ECHO off
86
87 SET IGNORED="test_squid_linux.py"
88+SET LINTIGNORED="ubuntuone\devtools\services\dbus.py,ubuntuone\devtools\services\tests\test_squid_linux.py"
89
90 ECHO Checking for Python on the path
91 :: Look for Python from buildout
92 FOR %%A in (python.exe) do (SET PYTHONEXEPATH=%%~$PATH:A)
93-FOR %%B in (u1trial) do (SET TRIALPATH=%%~$PATH:B)
94-FOR %%C in (u1lint) do (SET LINTPATH=%%~$PATH:C)
95 FOR %%D in (pep8.exe) do (SET PEP8PATH=%%~$PATH:D)
96
97 IF NOT "%PYTHONEXEPATH%" == "" GOTO :PYTHONPRESENT
98@@ -69,16 +68,16 @@
99
100 ECHO Python found at %PYTHONEXEPATH%, executing the tests...
101 :: execute the tests with a number of ignored linux only modules
102-"%PYTHONEXEPATH%" bin/u1trial --reactor=twisted -i %IGNORED% -c %PARAMS% ubuntuone
103+"%PYTHONEXEPATH%" bin/u1trial -i %IGNORED% -c %PARAMS% ubuntuone
104
105 IF %SKIPLINT% == 1 (
106 ECHO Skipping style checks
107 GOTO :CLEAN)
108
109-"%PYTHONEXEPATH%" "%LINTPATH%"
110+"%PYTHONEXEPATH%" bin/u1lint -i %LINTIGNORED%
111 :: test for style if we can, if pep8 is not present, move to the end
112 IF NOT EXIST "%PEP8PATH%" GOTO :NOPEP8
113-START "Pep8" /B "%PEP8PATH%" --repeat
114+START "Pep8" /B "%PEP8PATH%" --repeat .
115 :NOPEP8
116 ECHO Style checks were not done
117 :CLEAN
118
119=== modified file 'setup.py'
120--- setup.py 2012-05-24 19:07:16 +0000
121+++ setup.py 2012-06-06 13:30:25 +0000
122@@ -1,4 +1,4 @@
123-#!/usr/bin/env python
124+#!/usr/bin/python
125 #
126 # Copyright 2010-2012 Canonical Ltd.
127 #
128
129=== modified file 'ubuntuone/devtools/services/squid.py'
130--- ubuntuone/devtools/services/squid.py 2012-04-26 14:52:43 +0000
131+++ ubuntuone/devtools/services/squid.py 2012-06-06 13:30:25 +0000
132@@ -113,7 +113,9 @@
133 win32api.TerminateProcess(handle, 0)
134 win32api.CloseHandle(handle)
135 else:
136+ # pylint: disable=E1101
137 kill(squid_pid, signal.SIGKILL)
138+ # pylint: enable=E1101
139
140
141 def _make_random_string(count):

Subscribers

People subscribed via source and target branches

to all changes: