Merge lp:~nataliabidart/ubuntu-sso-client/use-devtools into lp:ubuntu-sso-client
- use-devtools
- Merge into trunk
Proposed by
Natalia Bidart
on 2010-12-20
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Natalia Bidart on 2010-12-20 | ||||
| Approved revision: | 665 | ||||
| Merged at revision: | 664 | ||||
| Proposed branch: | lp:~nataliabidart/ubuntu-sso-client/use-devtools | ||||
| Merge into: | lp:ubuntu-sso-client | ||||
| Diff against target: |
640 lines (+33/-450) 14 files modified
bin/ubuntu-sso-login (+5/-3) contrib/__init__.py (+0/-18) contrib/dbus_util.py (+0/-77) contrib/test (+0/-146) contrib/testing/__init__.py (+0/-1) contrib/testing/dbus-session.conf (+0/-63) contrib/testing/testcase.py (+0/-123) run-tests (+13/-4) setup.py (+2/-3) ubuntu_sso/gtk/tests/test_gui.py (+1/-1) ubuntu_sso/tests/bin/show_gui (+7/-6) ubuntu_sso/tests/bin/show_nm_state (+3/-3) ubuntu_sso/tests/test_credentials.py (+1/-1) ubuntu_sso/tests/test_main.py (+1/-1) |
||||
| To merge this branch: | bzr merge lp:~nataliabidart/ubuntu-sso-client/use-devtools | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Manuel de la Peña (community) | Approve on 2010-12-20 | ||
| dobey (community) | 2010-12-20 | Approve on 2010-12-20 | |
|
Review via email:
|
|||
Commit Message
* Use ubuntuone-dev-tools to run the tests and the lint checker (LP: #686606).
Description of the Change
To post a comment you must log in.
| Manuel de la Peña (mandel) wrote : | # |
Tests work for me, I really do not know the diff between u1lint and pylint.
review:
Approve
lp:~nataliabidart/ubuntu-sso-client/use-devtools
updated
on 2010-12-20
- 665. By Natalia Bidart on 2010-12-20
-
u1lint will not take arguments.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'bin/ubuntu-sso-login' |
| 2 | --- bin/ubuntu-sso-login 2010-10-08 21:10:40 +0000 |
| 3 | +++ bin/ubuntu-sso-login 2010-12-20 15:43:07 +0000 |
| 4 | @@ -21,7 +21,9 @@ |
| 5 | |
| 6 | """Run the dbus service for UserManagement and ApplicationCredentials.""" |
| 7 | |
| 8 | -# import decimal even if we don't need it. |
| 9 | +# Invalid name "ubuntu-sso-login", pylint: disable=C0103 |
| 10 | + |
| 11 | +# import decimal even if we don't need it, pylint: disable=W0611 |
| 12 | import decimal |
| 13 | # This is a workaround for LP: #467397. Some module in our depency chain sets |
| 14 | # the locale and imports decimal, and that generates the following trace: |
| 15 | @@ -70,8 +72,8 @@ |
| 16 | # See the link below for info: |
| 17 | # www.listware.net/201004/gtk-devel-list/115067-unix-signals-in-glib.html |
| 18 | # |
| 19 | - # gtk.main_quit and the logger methods are safe to be called from any thread. |
| 20 | - # Just don't call other random stuff here. |
| 21 | + # gtk.main_quit and the logger methods are safe to be called from any |
| 22 | + # thread. Just don't call other random stuff here. |
| 23 | logger.info("Stoping Ubuntu SSO login manager since SIGHUP was received.") |
| 24 | gtk.main_quit() |
| 25 | |
| 26 | |
| 27 | === removed directory 'contrib' |
| 28 | === removed file 'contrib/__init__.py' |
| 29 | --- contrib/__init__.py 2010-06-22 14:18:04 +0000 |
| 30 | +++ contrib/__init__.py 1970-01-01 00:00:00 +0000 |
| 31 | @@ -1,18 +0,0 @@ |
| 32 | -# contrib - Extra required code to build/install the client |
| 33 | -# |
| 34 | -# Author: Rodney Dawes <rodney.dawes@canonical.com> |
| 35 | -# |
| 36 | -# Copyright 2009-2010 Canonical Ltd. |
| 37 | -# |
| 38 | -# This program is free software: you can redistribute it and/or modify it |
| 39 | -# under the terms of the GNU General Public License version 3, as published |
| 40 | -# by the Free Software Foundation. |
| 41 | -# |
| 42 | -# This program is distributed in the hope that it will be useful, but |
| 43 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
| 44 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 45 | -# PURPOSE. See the GNU General Public License for more details. |
| 46 | -# |
| 47 | -# You should have received a copy of the GNU General Public License along |
| 48 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 49 | -"""Extra things we need to build, test, or install the client.""" |
| 50 | |
| 51 | === removed file 'contrib/dbus_util.py' |
| 52 | --- contrib/dbus_util.py 2010-09-03 21:24:47 +0000 |
| 53 | +++ contrib/dbus_util.py 1970-01-01 00:00:00 +0000 |
| 54 | @@ -1,77 +0,0 @@ |
| 55 | -# |
| 56 | -# Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> |
| 57 | -# |
| 58 | -# |
| 59 | -# This program is free software: you can redistribute it and/or modify it |
| 60 | -# under the terms of the GNU General Public License version 3, as published |
| 61 | -# by the Free Software Foundation. |
| 62 | -# |
| 63 | -# This program is distributed in the hope that it will be useful, but |
| 64 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
| 65 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 66 | -# PURPOSE. See the GNU General Public License for more details. |
| 67 | -# |
| 68 | -# You should have received a copy of the GNU General Public License along |
| 69 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 70 | - |
| 71 | -"""Utilies to run a separated DBus session.""" |
| 72 | - |
| 73 | -import os |
| 74 | -import signal |
| 75 | -import subprocess |
| 76 | - |
| 77 | -from distutils.spawn import find_executable |
| 78 | - |
| 79 | -SRCDIR = os.environ.get('SRCDIR', os.getcwd()) |
| 80 | - |
| 81 | - |
| 82 | -class DBusLaunchError(Exception): |
| 83 | - """Error while launching dbus-daemon.""" |
| 84 | - |
| 85 | - |
| 86 | -class NotFoundError(Exception): |
| 87 | - """Not found error.""" |
| 88 | - |
| 89 | - |
| 90 | -class DBusRunner(object): |
| 91 | - """A DBus runner.""" |
| 92 | - |
| 93 | - # pylint: disable=C0103 |
| 94 | - |
| 95 | - def __init__(self): |
| 96 | - self.dbus_address = None |
| 97 | - self.dbus_pid = None |
| 98 | - self.running = False |
| 99 | - |
| 100 | - def startDBus(self): |
| 101 | - """Start our own session bus daemon for testing.""" |
| 102 | - dbus = find_executable("dbus-daemon") |
| 103 | - if not dbus: |
| 104 | - raise NotFoundError("dbus-daemon was not found.") |
| 105 | - |
| 106 | - config_file = os.path.join(os.path.abspath(SRCDIR), |
| 107 | - "contrib", "testing", |
| 108 | - "dbus-session.conf") |
| 109 | - dbus_args = ["--fork", |
| 110 | - "--config-file=" + config_file, |
| 111 | - "--print-address=1", |
| 112 | - "--print-pid=2"] |
| 113 | - p = subprocess.Popen([dbus] + dbus_args, |
| 114 | - bufsize=4096, stdout=subprocess.PIPE, |
| 115 | - stderr=subprocess.PIPE) |
| 116 | - |
| 117 | - self.dbus_address = "".join(p.stdout.readlines()).strip() |
| 118 | - self.dbus_pid = int("".join(p.stderr.readlines()).strip()) |
| 119 | - |
| 120 | - if self.dbus_address != "": |
| 121 | - os.environ["DBUS_SESSION_BUS_ADDRESS"] = self.dbus_address |
| 122 | - else: |
| 123 | - os.kill(self.dbus_pid, signal.SIGKILL) |
| 124 | - raise DBusLaunchError("There was a problem launching dbus-daemon.") |
| 125 | - self.running = True |
| 126 | - |
| 127 | - def stopDBus(self): |
| 128 | - """Stop our DBus session bus daemon.""" |
| 129 | - del os.environ["DBUS_SESSION_BUS_ADDRESS"] |
| 130 | - os.kill(self.dbus_pid, signal.SIGKILL) |
| 131 | - self.running = False |
| 132 | |
| 133 | === removed file 'contrib/test' |
| 134 | --- contrib/test 2010-09-03 21:24:47 +0000 |
| 135 | +++ contrib/test 1970-01-01 00:00:00 +0000 |
| 136 | @@ -1,146 +0,0 @@ |
| 137 | -#!/usr/bin/env python |
| 138 | -# |
| 139 | -# Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> |
| 140 | -# |
| 141 | -# Copyright 2009-2010 Canonical Ltd. |
| 142 | -# |
| 143 | -# This program is free software: you can redistribute it and/or modify it |
| 144 | -# under the terms of the GNU General Public License version 3, as published |
| 145 | -# by the Free Software Foundation. |
| 146 | -# |
| 147 | -# This program is distributed in the hope that it will be useful, but |
| 148 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
| 149 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 150 | -# PURPOSE. See the GNU General Public License for more details. |
| 151 | -# |
| 152 | -# You should have received a copy of the GNU General Public License along |
| 153 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 154 | - |
| 155 | -import os |
| 156 | -import re |
| 157 | -import signal |
| 158 | -import sys |
| 159 | -import string |
| 160 | -import subprocess |
| 161 | -import unittest |
| 162 | - |
| 163 | -sys.path.insert(0, os.path.abspath(".")) |
| 164 | - |
| 165 | -from distutils.spawn import find_executable |
| 166 | - |
| 167 | - |
| 168 | -class TestRunner(object): |
| 169 | - |
| 170 | - def _load_unittest(self, relpath): |
| 171 | - """Load unittests from a Python module with the given relative path.""" |
| 172 | - assert relpath.endswith(".py"), ( |
| 173 | - "%s does not appear to be a Python module" % relpath) |
| 174 | - modpath = relpath.replace(os.path.sep, ".")[:-3] |
| 175 | - module = __import__(modpath, None, None, [""]) |
| 176 | - |
| 177 | - # If the module has a 'suite' or 'test_suite' function, use that |
| 178 | - # to load the tests. |
| 179 | - if hasattr(module, "suite"): |
| 180 | - return module.suite() |
| 181 | - elif hasattr(module, "test_suite"): |
| 182 | - return module.test_suite() |
| 183 | - else: |
| 184 | - return unittest.defaultTestLoader.loadTestsFromModule(module) |
| 185 | - |
| 186 | - def _collect_tests(self, testpath, test_pattern): |
| 187 | - """Return the set of unittests.""" |
| 188 | - suite = unittest.TestSuite() |
| 189 | - if test_pattern: |
| 190 | - pattern = re.compile('.*%s.*' % test_pattern) |
| 191 | - else: |
| 192 | - pattern = None |
| 193 | - |
| 194 | - if testpath: |
| 195 | - module_suite = self._load_unittest(testpath) |
| 196 | - if pattern: |
| 197 | - for inner_suite in module_suite._tests: |
| 198 | - for test in inner_suite._tests: |
| 199 | - if pattern.match(test.id()): |
| 200 | - suite.addTest(test) |
| 201 | - else: |
| 202 | - suite.addTests(module_suite) |
| 203 | - return suite |
| 204 | - |
| 205 | - # We don't use the dirs variable, so ignore the warning |
| 206 | - # pylint: disable=W0612 |
| 207 | - for root, dirs, files in os.walk("ubuntu_sso"): |
| 208 | - for file in files: |
| 209 | - path = os.path.join(root, file) |
| 210 | - if file.endswith(".py") and file.startswith("test_"): |
| 211 | - module_suite = self._load_unittest(path) |
| 212 | - if pattern: |
| 213 | - for inner_suite in module_suite._tests: |
| 214 | - for test in inner_suite._tests: |
| 215 | - if pattern.match(test.id()): |
| 216 | - suite.addTest(test) |
| 217 | - else: |
| 218 | - suite.addTests(module_suite) |
| 219 | - return suite |
| 220 | - |
| 221 | - def run(self, testpath, test_pattern=None, loops=None): |
| 222 | - """run the tests. """ |
| 223 | - # install the glib2reactor before any import of the reactor to avoid |
| 224 | - # using the default SelectReactor and be able to run the dbus tests |
| 225 | - from twisted.internet import glib2reactor |
| 226 | - glib2reactor.install() |
| 227 | - from twisted.internet import reactor |
| 228 | - from twisted.trial.reporter import TreeReporter |
| 229 | - from twisted.trial.runner import TrialRunner |
| 230 | - |
| 231 | - from contrib.dbus_util import DBusRunner |
| 232 | - dbus_runner = DBusRunner() |
| 233 | - dbus_runner.startDBus() |
| 234 | - |
| 235 | - workingDirectory = os.path.join(os.getcwd(), "_trial_temp", "tmp") |
| 236 | - runner = TrialRunner(reporterFactory=TreeReporter, realTimeErrors=True, |
| 237 | - workingDirectory=workingDirectory) |
| 238 | - |
| 239 | - # setup a custom XDG_CACHE_HOME and create the logs directory |
| 240 | - xdg_cache = os.path.join(os.getcwd(), "_trial_temp", "xdg_cache") |
| 241 | - os.environ["XDG_CACHE_HOME"] = xdg_cache |
| 242 | - # setup the ROOTDIR env var |
| 243 | - os.environ['ROOTDIR'] = os.getcwd() |
| 244 | - if not os.path.exists(xdg_cache): |
| 245 | - os.makedirs(xdg_cache) |
| 246 | - success = 0 |
| 247 | - try: |
| 248 | - suite = self._collect_tests(testpath, test_pattern) |
| 249 | - if loops: |
| 250 | - old_suite = suite |
| 251 | - suite = unittest.TestSuite() |
| 252 | - for x in xrange(loops): |
| 253 | - suite.addTest(old_suite) |
| 254 | - result = runner.run(suite) |
| 255 | - success = result.wasSuccessful() |
| 256 | - finally: |
| 257 | - dbus_runner.stopDBus() |
| 258 | - if not success: |
| 259 | - sys.exit(1) |
| 260 | - else: |
| 261 | - sys.exit(0) |
| 262 | - |
| 263 | - |
| 264 | -if __name__ == '__main__': |
| 265 | - from optparse import OptionParser |
| 266 | - usage = '%prog [options] path' |
| 267 | - parser = OptionParser(usage=usage) |
| 268 | - parser.add_option("-t", "--test", dest="test", |
| 269 | - help="run specific tests, e.g: className.methodName") |
| 270 | - parser.add_option("-l", "--loop", dest="loops", type="int", default=1, |
| 271 | - help="loop selected tests LOOPS number of times", |
| 272 | - metavar="LOOPS") |
| 273 | - |
| 274 | - (options, args) = parser.parse_args() |
| 275 | - if args: |
| 276 | - testpath = args[0] |
| 277 | - if not os.path.exists(testpath): |
| 278 | - print "the path to test does not exists!" |
| 279 | - sys.exit() |
| 280 | - else: |
| 281 | - testpath = None |
| 282 | - TestRunner().run(testpath, options.test, options.loops) |
| 283 | |
| 284 | === removed directory 'contrib/testing' |
| 285 | === removed file 'contrib/testing/__init__.py' |
| 286 | --- contrib/testing/__init__.py 2010-09-02 16:41:05 +0000 |
| 287 | +++ contrib/testing/__init__.py 1970-01-01 00:00:00 +0000 |
| 288 | @@ -1,1 +0,0 @@ |
| 289 | -"""Testing utilities for Ubuntu SSO code.""" |
| 290 | |
| 291 | === removed file 'contrib/testing/dbus-session.conf' |
| 292 | --- contrib/testing/dbus-session.conf 2010-06-18 20:51:58 +0000 |
| 293 | +++ contrib/testing/dbus-session.conf 1970-01-01 00:00:00 +0000 |
| 294 | @@ -1,63 +0,0 @@ |
| 295 | -<!-- This configuration file controls our test-only session bus --> |
| 296 | - |
| 297 | -<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" |
| 298 | - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> |
| 299 | -<busconfig> |
| 300 | - <!-- We only use a session bus --> |
| 301 | - <type>session</type> |
| 302 | - |
| 303 | - <listen>unix:tmpdir=/tmp</listen> |
| 304 | - |
| 305 | - <!-- Load our own services. |
| 306 | - To make other dbus service in this session bus, just add another servicedir entry. --> |
| 307 | - <servicedir>dbus-session</servicedir> |
| 308 | - <!-- Load the standard session services --> |
| 309 | - <!--standard_session_servicedirs /--> |
| 310 | - |
| 311 | - <policy context="default"> |
| 312 | - <!-- Allow everything to be sent --> |
| 313 | - <allow send_destination="*" eavesdrop="true"/> |
| 314 | - <!-- Allow everything to be received --> |
| 315 | - <allow eavesdrop="true"/> |
| 316 | - <!-- Allow anyone to own anything --> |
| 317 | - <allow own="*"/> |
| 318 | - </policy> |
| 319 | - |
| 320 | - <!-- Config files are placed here that among other things, |
| 321 | - further restrict the above policy for specific services. --> |
| 322 | - <includedir>/etc/dbus-1/session.d</includedir> |
| 323 | - |
| 324 | - <!-- raise the service start timeout to 40 seconds as it can timeout |
| 325 | - on the live cd on slow machines --> |
| 326 | - <limit name="service_start_timeout">60000</limit> |
| 327 | - |
| 328 | - <!-- This is included last so local configuration can override what's |
| 329 | - in this standard file --> |
| 330 | - <include ignore_missing="yes">session-local.conf</include> |
| 331 | - |
| 332 | - <include ignore_missing="yes" if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include> |
| 333 | - |
| 334 | - <!-- For the session bus, override the default relatively-low limits |
| 335 | - with essentially infinite limits, since the bus is just running |
| 336 | - as the user anyway, using up bus resources is not something we need |
| 337 | - to worry about. In some cases, we do set the limits lower than |
| 338 | - "all available memory" if exceeding the limit is almost certainly a bug, |
| 339 | - having the bus enforce a limit is nicer than a huge memory leak. But the |
| 340 | - intent is that these limits should never be hit. --> |
| 341 | - |
| 342 | - <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max --> |
| 343 | - <limit name="max_incoming_bytes">1000000000</limit> |
| 344 | - <limit name="max_outgoing_bytes">1000000000</limit> |
| 345 | - <limit name="max_message_size">1000000000</limit> |
| 346 | - <limit name="service_start_timeout">120000</limit> |
| 347 | - <limit name="auth_timeout">240000</limit> |
| 348 | - <limit name="max_completed_connections">100000</limit> |
| 349 | - <limit name="max_incomplete_connections">10000</limit> |
| 350 | - <limit name="max_connections_per_user">100000</limit> |
| 351 | - <limit name="max_pending_service_starts">10000</limit> |
| 352 | - <limit name="max_names_per_connection">50000</limit> |
| 353 | - <limit name="max_match_rules_per_connection">50000</limit> |
| 354 | - <limit name="max_replies_per_connection">50000</limit> |
| 355 | - <limit name="reply_timeout">300000</limit> |
| 356 | - |
| 357 | -</busconfig> |
| 358 | |
| 359 | === removed file 'contrib/testing/testcase.py' |
| 360 | --- contrib/testing/testcase.py 2010-09-30 20:49:38 +0000 |
| 361 | +++ contrib/testing/testcase.py 1970-01-01 00:00:00 +0000 |
| 362 | @@ -1,123 +0,0 @@ |
| 363 | -# |
| 364 | -# Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> |
| 365 | -# Author: Natalia B. Bidart <natalia.bidart@canonical.com> |
| 366 | -# |
| 367 | -# Copyright 2009-2010 Canonical Ltd. |
| 368 | -# |
| 369 | -# This program is free software: you can redistribute it and/or modify it |
| 370 | -# under the terms of the GNU General Public License version 3, as published |
| 371 | -# by the Free Software Foundation. |
| 372 | -# |
| 373 | -# This program is distributed in the hope that it will be useful, but |
| 374 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
| 375 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 376 | -# PURPOSE. See the GNU General Public License for more details. |
| 377 | -# |
| 378 | -# You should have received a copy of the GNU General Public License along |
| 379 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 380 | -"""Base tests cases and test utilities.""" |
| 381 | - |
| 382 | -import logging |
| 383 | - |
| 384 | -import dbus |
| 385 | - |
| 386 | -from dbus.mainloop.glib import DBusGMainLoop |
| 387 | -from twisted.internet import defer |
| 388 | -from twisted.python import failure |
| 389 | -from twisted.trial.unittest import TestCase |
| 390 | - |
| 391 | - |
| 392 | -class DBusTestCase(TestCase): |
| 393 | - """Test the DBus event handling.""" |
| 394 | - |
| 395 | - def setUp(self): |
| 396 | - """Setup the infrastructure fo the test (dbus service).""" |
| 397 | - self.loop = DBusGMainLoop(set_as_default=True) |
| 398 | - self.bus = dbus.bus.BusConnection(mainloop=self.loop) |
| 399 | - # monkeypatch busName.__del__ to avoid errors on gc |
| 400 | - # we take care of releasing the name in shutdown |
| 401 | - dbus.service.BusName.__del__ = lambda _: None |
| 402 | - self.bus.set_exit_on_disconnect(False) |
| 403 | - self.signal_receivers = set() |
| 404 | - |
| 405 | - def tearDown(self): |
| 406 | - """Cleanup the test.""" |
| 407 | - d = self.cleanup_signal_receivers(self.signal_receivers) |
| 408 | - d.addBoth(self._tear_down) |
| 409 | - return d |
| 410 | - |
| 411 | - def _tear_down(self, _): |
| 412 | - """Shutdown.""" |
| 413 | - self.bus.flush() |
| 414 | - self.bus.close() |
| 415 | - |
| 416 | - def error_handler(self, error): |
| 417 | - """Default error handler for DBus calls.""" |
| 418 | - if isinstance(error, failure.Failure): |
| 419 | - self.fail(error.getErrorMessage()) |
| 420 | - |
| 421 | - def cleanup_signal_receivers(self, signal_receivers): |
| 422 | - """Cleanup self.signal_receivers and returns a deferred.""" |
| 423 | - deferreds = [] |
| 424 | - for match in signal_receivers: |
| 425 | - d = defer.Deferred() |
| 426 | - |
| 427 | - def callback(*args): |
| 428 | - """Callback that accepts *args.""" |
| 429 | - if not d.called: |
| 430 | - d.callback(args) |
| 431 | - |
| 432 | - self.bus.call_async(dbus.bus.BUS_DAEMON_NAME, |
| 433 | - dbus.bus.BUS_DAEMON_PATH, |
| 434 | - dbus.bus.BUS_DAEMON_IFACE, 'RemoveMatch', 's', |
| 435 | - (str(match),), callback, self.error_handler) |
| 436 | - deferreds.append(d) |
| 437 | - if deferreds: |
| 438 | - return defer.DeferredList(deferreds) |
| 439 | - else: |
| 440 | - return defer.succeed(True) |
| 441 | - |
| 442 | - |
| 443 | -class MementoHandler(logging.Handler): |
| 444 | - """A handler class which store logging records in a list.""" |
| 445 | - |
| 446 | - def __init__(self, *args, **kwargs): |
| 447 | - """Create the instance, and add a records attribute.""" |
| 448 | - logging.Handler.__init__(self, *args, **kwargs) |
| 449 | - self.records = [] |
| 450 | - |
| 451 | - def emit(self, record): |
| 452 | - """Just add the record to self.records.""" |
| 453 | - self.records.append(record) |
| 454 | - |
| 455 | - def check(self, level, *msgs): |
| 456 | - """Verifies that the msgs are logged in the specified level.""" |
| 457 | - for rec in self.records: |
| 458 | - if rec.levelno == level and all(m in rec.message for m in msgs): |
| 459 | - return True |
| 460 | - return False |
| 461 | - |
| 462 | - def check_debug(self, *msgs): |
| 463 | - """Shortcut for checking in DEBUG.""" |
| 464 | - return self.check(logging.DEBUG, *msgs) |
| 465 | - |
| 466 | - def check_info(self, *msgs): |
| 467 | - """Shortcut for checking in INFO.""" |
| 468 | - return self.check(logging.INFO, *msgs) |
| 469 | - |
| 470 | - def check_warning(self, *msgs): |
| 471 | - """Shortcut for checking in WARNING.""" |
| 472 | - return self.check(logging.WARNING, *msgs) |
| 473 | - |
| 474 | - def check_error(self, *msgs): |
| 475 | - """Shortcut for checking in ERROR.""" |
| 476 | - return self.check(logging.ERROR, *msgs) |
| 477 | - |
| 478 | - def check_exception(self, exception_class, *msgs): |
| 479 | - """Shortcut for checking exceptions.""" |
| 480 | - for rec in self.records: |
| 481 | - if rec.levelno == logging.ERROR and \ |
| 482 | - all(m in rec.exc_text for m in msgs) and \ |
| 483 | - exception_class == rec.exc_info[0]: |
| 484 | - return True |
| 485 | - return False |
| 486 | |
| 487 | === modified file 'run-tests' |
| 488 | --- run-tests 2010-09-30 20:49:38 +0000 |
| 489 | +++ run-tests 2010-12-20 15:43:07 +0000 |
| 490 | @@ -15,14 +15,23 @@ |
| 491 | # You should have received a copy of the GNU General Public License along |
| 492 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
| 493 | |
| 494 | +if [ $# -ne 0 ]; then |
| 495 | + # an extra argument was given |
| 496 | + MODULE="$@" |
| 497 | +else |
| 498 | + # run all tests, useful for tarmac and reviews |
| 499 | + MODULE="ubuntu_sso" |
| 500 | +fi |
| 501 | + |
| 502 | style_check() { |
| 503 | - pylint contrib ubuntu_sso |
| 504 | + u1lint |
| 505 | if [ -x `which pep8` ]; then |
| 506 | - pep8 --repeat bin/ contrib/ ubuntu_sso/ |
| 507 | + pep8 --repeat bin/ $MODULE |
| 508 | else |
| 509 | echo "Please install the 'pep8' package." |
| 510 | fi |
| 511 | } |
| 512 | |
| 513 | -`which xvfb-run` ./contrib/test "$@" && style_check |
| 514 | -rm -rf _trial_temp/ |
| 515 | +echo "Running test suite for ""$MODULE" |
| 516 | +`which xvfb-run` u1trial "$MODULE" && style_check |
| 517 | +rm -rf _trial_temp |
| 518 | |
| 519 | === modified file 'setup.py' |
| 520 | --- setup.py 2010-12-16 16:27:01 +0000 |
| 521 | +++ setup.py 2010-12-20 15:43:07 +0000 |
| 522 | @@ -31,16 +31,15 @@ |
| 523 | assert DistUtilsExtra.auto.__version__ >= '2.18', \ |
| 524 | 'needs DistUtilsExtra.auto >= 2.18' |
| 525 | |
| 526 | -from distutils.core import setup |
| 527 | from distutils.spawn import find_executable |
| 528 | -from distutils.command import clean, build |
| 529 | +from distutils.command import clean |
| 530 | |
| 531 | # Defining variables for various rules here, similar to a Makefile.am |
| 532 | CLEANFILES = ['data/com.ubuntu.sso.service', 'po/ubuntu-sso-client.pot', |
| 533 | 'MANIFEST'] |
| 534 | |
| 535 | |
| 536 | -# XXX: This needs some serious cleanup |
| 537 | +# This needs some serious cleanup |
| 538 | class SSOBuild(build_extra.build_extra): |
| 539 | """Class to build the extra files.""" |
| 540 | |
| 541 | |
| 542 | === modified file 'ubuntu_sso/gtk/tests/test_gui.py' |
| 543 | --- ubuntu_sso/gtk/tests/test_gui.py 2010-11-29 16:04:26 +0000 |
| 544 | +++ ubuntu_sso/gtk/tests/test_gui.py 2010-12-20 15:43:07 +0000 |
| 545 | @@ -30,8 +30,8 @@ |
| 546 | import webkit |
| 547 | |
| 548 | from twisted.trial.unittest import TestCase |
| 549 | +from ubuntuone.devtools.handlers import MementoHandler |
| 550 | |
| 551 | -from contrib.testing.testcase import MementoHandler |
| 552 | from ubuntu_sso.gtk import gui |
| 553 | from ubuntu_sso.tests import (APP_NAME, TC_URL, HELP_TEXT, CAPTCHA_ID, |
| 554 | CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, NAME, PASSWORD, RESET_PASSWORD_TOKEN) |
| 555 | |
| 556 | === modified file 'ubuntu_sso/tests/bin/show_gui' |
| 557 | --- ubuntu_sso/tests/bin/show_gui 2010-11-19 21:25:28 +0000 |
| 558 | +++ ubuntu_sso/tests/bin/show_gui 2010-12-20 15:43:07 +0000 |
| 559 | @@ -31,11 +31,12 @@ |
| 560 | 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit' \ |
| 561 | ' pulvinar tempus ut augue.' |
| 562 | |
| 563 | -main_quit = lambda *args, **kwargs: gtk.main_quit() |
| 564 | - |
| 565 | |
| 566 | if __name__ == '__main__': |
| 567 | - tc_url=TC_URL |
| 568 | + |
| 569 | + # pylint: disable=C0103, E1101 |
| 570 | + |
| 571 | + tc_url = TC_URL |
| 572 | login_only = False |
| 573 | xid = 0 |
| 574 | |
| 575 | @@ -51,7 +52,7 @@ |
| 576 | win.show() |
| 577 | xid = win.window.xid |
| 578 | |
| 579 | - UbuntuSSOClientGUI(close_callback=main_quit, app_name=APP_NAME, |
| 580 | - tc_url=tc_url, help_text=HELP_TEXT, window_id=xid, |
| 581 | - login_only=login_only) |
| 582 | + UbuntuSSOClientGUI(close_callback=lambda *args, **kwargs: gtk.main_quit(), |
| 583 | + app_name=APP_NAME, tc_url=tc_url, help_text=HELP_TEXT, |
| 584 | + window_id=xid, login_only=login_only) |
| 585 | gtk.main() |
| 586 | |
| 587 | === modified file 'ubuntu_sso/tests/bin/show_nm_state' |
| 588 | --- ubuntu_sso/tests/bin/show_nm_state 2010-09-03 21:14:00 +0000 |
| 589 | +++ ubuntu_sso/tests/bin/show_nm_state 2010-12-20 15:43:07 +0000 |
| 590 | @@ -26,7 +26,6 @@ |
| 591 | from ubuntu_sso.networkstate import NetworkManagerState, NM_STATE_NAMES |
| 592 | |
| 593 | DBusGMainLoop(set_as_default=True) |
| 594 | -loop = gobject.MainLoop() |
| 595 | |
| 596 | |
| 597 | def got_state(state): |
| 598 | @@ -34,8 +33,9 @@ |
| 599 | try: |
| 600 | print NM_STATE_NAMES[state] |
| 601 | finally: |
| 602 | - loop.quit() |
| 603 | + gobject.MainLoop().quit() |
| 604 | |
| 605 | +# pylint: disable=C0103 |
| 606 | nms = NetworkManagerState(got_state) |
| 607 | nms.find_online_state() |
| 608 | -loop.run() |
| 609 | +gobject.MainLoop().run() |
| 610 | |
| 611 | === modified file 'ubuntu_sso/tests/test_credentials.py' |
| 612 | --- ubuntu_sso/tests/test_credentials.py 2010-11-24 12:48:28 +0000 |
| 613 | +++ ubuntu_sso/tests/test_credentials.py 2010-12-20 15:43:07 +0000 |
| 614 | @@ -26,8 +26,8 @@ |
| 615 | from twisted.internet import defer |
| 616 | from twisted.internet.defer import inlineCallbacks |
| 617 | from twisted.trial.unittest import TestCase, FailTest |
| 618 | +from ubuntuone.devtools.handlers import MementoHandler |
| 619 | |
| 620 | -from contrib.testing.testcase import MementoHandler |
| 621 | from ubuntu_sso import credentials |
| 622 | from ubuntu_sso.credentials import (APP_NAME_KEY, HELP_TEXT_KEY, NO_OP, |
| 623 | PING_URL_KEY, TC_URL_KEY, UI_CLASS_KEY, UI_MODULE_KEY, WINDOW_ID_KEY, |
| 624 | |
| 625 | === modified file 'ubuntu_sso/tests/test_main.py' |
| 626 | --- ubuntu_sso/tests/test_main.py 2010-12-15 20:42:15 +0000 |
| 627 | +++ ubuntu_sso/tests/test_main.py 2010-12-20 15:43:07 +0000 |
| 628 | @@ -27,11 +27,11 @@ |
| 629 | from twisted.internet import defer |
| 630 | from twisted.internet.defer import Deferred, inlineCallbacks |
| 631 | from twisted.trial.unittest import TestCase |
| 632 | +from ubuntuone.devtools.handlers import MementoHandler |
| 633 | |
| 634 | import ubuntu_sso.keyring |
| 635 | import ubuntu_sso.main |
| 636 | |
| 637 | -from contrib.testing.testcase import MementoHandler |
| 638 | from ubuntu_sso import DBUS_CREDENTIALS_IFACE |
| 639 | from ubuntu_sso.keyring import U1_APP_NAME |
| 640 | from ubuntu_sso.main import (U1_PING_URL, blocking, except_to_errdict, |

503 - pylint contrib ubuntu_sso
504 + u1lint $MODULE
You might have noticed in running with your changes, but u1lint doesn't take arguments for what sub-directories to run the checks in. It simply checks everything.