[pygobject] PEP8: Fix indentation
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] PEP8: Fix indentation
- Date: Fri, 22 Jun 2012 11:18:02 +0000 (UTC)
commit fb436dd6d3b40b3f2a8ba6f402e2987752ad1902
Author: Martin Pitt <martinpitt gnome org>
Date: Fri Jun 22 13:08:34 2012 +0200
PEP8: Fix indentation
Spotted by current pep8 checker.
demos/gtk-demo/demos/Entry/entry_buffer.py | 6 +-
demos/gtk-demo/demos/Entry/entry_completion.py | 6 +-
demos/gtk-demo/demos/Entry/search_entry.py | 4 +-
demos/gtk-demo/demos/appwindow.py | 2 +-
demos/gtk-demo/demos/clipboard.py | 8 ++--
demos/gtk-demo/demos/colorselector.py | 6 +-
demos/gtk-demo/demos/rotatedtext.py | 8 ++--
demos/gtk-demo/gtk-demo.py | 6 +--
examples/option.py | 29 +++++-----
examples/signal.py | 3 +-
gi/_glib/option.py | 6 +-
gi/_gobject/propertyhelper.py | 18 +++---
gi/module.py | 14 +++---
gi/overrides/GLib.py | 2 +-
gi/overrides/Gio.py | 11 +++--
gi/overrides/Gtk.py | 16 +++---
gi/pygtkcompat.py | 7 +--
gi/types.py | 17 +++---
tests/runtests.py | 2 +-
tests/test_gdbus.py | 55 +++++++++++---------
tests/test_gi.py | 15 +++--
tests/test_gobject.py | 18 +++---
tests/test_option.py | 26 +++++-----
tests/test_overrides.py | 67 ++++++++++++------------
tests/test_properties.py | 30 +++++------
tests/test_signal.py | 2 +-
tests/test_uris.py | 9 ++--
27 files changed, 200 insertions(+), 193 deletions(-)
---
diff --git a/demos/gtk-demo/demos/Entry/entry_buffer.py b/demos/gtk-demo/demos/Entry/entry_buffer.py
index 442dfa2..dc4643c 100644
--- a/demos/gtk-demo/demos/Entry/entry_buffer.py
+++ b/demos/gtk-demo/demos/Entry/entry_buffer.py
@@ -31,9 +31,9 @@ from gi.repository import Gtk
class EntryBufferApp:
def __init__(self):
self.window = Gtk.Dialog('Gtk.EntryBuffer',
- None,
- 0,
- [Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE])
+ None,
+ 0,
+ [Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE])
self.window.connect('response', self.destroy)
self.window.connect('destroy', lambda x: Gtk.main_quit())
self.window.set_resizable(False)
diff --git a/demos/gtk-demo/demos/Entry/entry_completion.py b/demos/gtk-demo/demos/Entry/entry_completion.py
index 1f00d72..c65dd98 100644
--- a/demos/gtk-demo/demos/Entry/entry_completion.py
+++ b/demos/gtk-demo/demos/Entry/entry_completion.py
@@ -32,9 +32,9 @@ from gi.repository import Gtk
class EntryBufferApp:
def __init__(self):
self.window = Gtk.Dialog('Gtk.EntryCompletion',
- None,
- 0,
- [Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE])
+ None,
+ 0,
+ [Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE])
self.window.connect('response', self.destroy)
self.window.connect('destroy', lambda x: Gtk.main_quit())
self.window.set_resizable(False)
diff --git a/demos/gtk-demo/demos/Entry/search_entry.py b/demos/gtk-demo/demos/Entry/search_entry.py
index 4e8c796..905cb0e 100644
--- a/demos/gtk-demo/demos/Entry/search_entry.py
+++ b/demos/gtk-demo/demos/Entry/search_entry.py
@@ -155,8 +155,8 @@ class SearchboxApp:
entry.set_icon_from_stock(Gtk.EntryIconPosition.PRIMARY,
Gtk.STOCK_FIND)
entry.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY,
- 'Search by name\n' +
- 'Click here to change the search type')
+ 'Search by name\n' +
+ 'Click here to change the search type')
def search_by_description(self, item, entry):
entry.set_icon_from_stock(Gtk.EntryIconPosition.PRIMARY,
diff --git a/demos/gtk-demo/demos/appwindow.py b/demos/gtk-demo/demos/appwindow.py
index 433c9b6..f8c1ab3 100644
--- a/demos/gtk-demo/demos/appwindow.py
+++ b/demos/gtk-demo/demos/appwindow.py
@@ -124,7 +124,7 @@ Boston, MA 02111-1307, USA.
transparent = pixbuf.add_alpha(True, 0xff, 0xff, 0xff)
about = Gtk.AboutDialog(parent=window,
- program_name='GTK+ Code Demos',
+ program_name='GTK+ Code Demos',
version='0.1',
copyright='(C) 2010 The PyGI Team',
license=license,
diff --git a/demos/gtk-demo/demos/clipboard.py b/demos/gtk-demo/demos/clipboard.py
index 330aa21..f7242fe 100644
--- a/demos/gtk-demo/demos/clipboard.py
+++ b/demos/gtk-demo/demos/clipboard.py
@@ -94,14 +94,14 @@ class ClipboardApp:
# make ebox a drag source
ebox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
- None, Gdk.DragAction.COPY)
+ None, Gdk.DragAction.COPY)
ebox.drag_source_add_image_targets()
ebox.connect('drag-begin', self.drag_begin, image)
ebox.connect('drag-data-get', self.drag_data_get, image)
# accept drops on ebox
ebox.drag_dest_set(Gtk.DestDefaults.ALL,
- None, Gdk.DragAction.COPY)
+ None, Gdk.DragAction.COPY)
ebox.drag_dest_add_image_targets()
ebox.connect('drag-data-received', self.drag_data_received, image)
@@ -118,14 +118,14 @@ class ClipboardApp:
# make ebox a drag source
ebox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
- None, Gdk.DragAction.COPY)
+ None, Gdk.DragAction.COPY)
ebox.drag_source_add_image_targets()
ebox.connect('drag-begin', self.drag_begin, image)
ebox.connect('drag-data-get', self.drag_data_get, image)
# accept drops on ebox
ebox.drag_dest_set(Gtk.DestDefaults.ALL,
- None, Gdk.DragAction.COPY)
+ None, Gdk.DragAction.COPY)
ebox.drag_dest_add_image_targets()
ebox.connect('drag-data-received', self.drag_data_received, image)
diff --git a/demos/gtk-demo/demos/colorselector.py b/demos/gtk-demo/demos/colorselector.py
index 3dee3d1..3ad65eb 100644
--- a/demos/gtk-demo/demos/colorselector.py
+++ b/demos/gtk-demo/demos/colorselector.py
@@ -64,9 +64,9 @@ class ColorSelectorApp:
frame.add(self.da)
alignment = Gtk.Alignment(xalign=1.0,
- yalign=0.5,
- xscale=0.0,
- yscale=0.0)
+ yalign=0.5,
+ xscale=0.0,
+ yscale=0.0)
button = Gtk.Button(label='_Change the above color',
use_underline=True)
diff --git a/demos/gtk-demo/demos/rotatedtext.py b/demos/gtk-demo/demos/rotatedtext.py
index 055e03b..36e0e0c 100644
--- a/demos/gtk-demo/demos/rotatedtext.py
+++ b/demos/gtk-demo/demos/rotatedtext.py
@@ -147,8 +147,8 @@ class RotatedTextApp:
height = da.get_allocated_height()
device_radius = min(width, height) / 2.0
cairo_ctx.translate(
- device_radius + (width - 2 * device_radius) / 2,
- device_radius + (height - 2 * device_radius) / 2)
+ device_radius + (width - 2 * device_radius) / 2,
+ device_radius + (height - 2 * device_radius) / 2)
cairo_ctx.scale(device_radius / self.RADIUS,
device_radius / self.RADIUS)
@@ -162,8 +162,8 @@ class RotatedTextApp:
# Create a PangoContext and set up our shape renderer
context = da.create_pango_context()
PangoCairo.context_set_shape_renderer(context,
- self.fancy_shape_renderer,
- None)
+ self.fancy_shape_renderer,
+ None)
# Create a PangoLayout, set the text, font, and attributes */
layout = Pango.Layout(context=context)
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index 8774685..13455ee 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -95,9 +95,7 @@ class DemoTreeStore(Gtk.TreeStore):
fullpath = os.path.join(DEMOCODEDIR, filename)
initfile = os.path.join(os.path.dirname(fullpath), '__init__.py')
- if fullpath != initfile \
- and os.path.isfile(initfile) \
- and fullpath.endswith('.py'):
+ if fullpath != initfile and os.path.isfile(initfile) and fullpath.endswith('.py'):
parentname = os.path.dirname(os.path.relpath(fullpath, DEMOCODEDIR))
if parentname:
@@ -186,7 +184,7 @@ class GtkDemoWindow(Gtk.Window):
base_file = os.path.join(dir, base)
if (GLib.file_test(logo_file, GLib.FileTest.EXISTS) and
- GLib.file_test(base_file, GLib.FileTest.EXISTS)):
+ GLib.file_test(base_file, GLib.FileTest.EXISTS)):
return base_file
else:
filename = os.path.join(DEMOCODEDIR, base)
diff --git a/examples/option.py b/examples/option.py
index 4c61602..04838b1 100644
--- a/examples/option.py
+++ b/examples/option.py
@@ -4,22 +4,21 @@
from gobject.option import OptionGroup, OptionParser, make_option
group = OptionGroup("example", "OptionGroup Example", "Shows all example options",
- option_list=[
- make_option("--example",
- action="store_true",
- dest="example",
- help="An example option."),
- ])
+ option_list=[make_option("--example",
+ action="store_true",
+ dest="example",
+ help="An example option."),
+ ])
+
parser = OptionParser("NAMES ...",
- description="A simple gobject.option example.",
- option_list=[
- make_option("--file", "-f",
- type="filename",
- action="store",
- dest="file",
- help="A filename option"),
- # ...
- ])
+ description="A simple gobject.option example.",
+ option_list=[make_option("--file", "-f",
+ type="filename",
+ action="store",
+ dest="file",
+ help="A filename option"),
+ # ...
+ ])
parser.add_option_group(group)
diff --git a/examples/signal.py b/examples/signal.py
index 057adda..9a9d00c 100644
--- a/examples/signal.py
+++ b/examples/signal.py
@@ -18,8 +18,7 @@ class D(C):
def my_signal_handler(object, arg, *extra):
- print "handler for `my_signal' called with argument", arg, \
- "and extra args", extra
+ print "handler for `my_signal' called with argument", arg, "and extra args", extra
inst = C()
inst2 = D()
diff --git a/gi/_glib/option.py b/gi/_glib/option.py
index 54e8fbb..afc13ac 100644
--- a/gi/_glib/option.py
+++ b/gi/_glib/option.py
@@ -32,7 +32,7 @@ GOptionGroup in glib.
import sys
import optparse
from optparse import OptParseError, OptionError, OptionValueError, \
- BadOptionError, OptionConflictError
+ BadOptionError, OptionConflictError
if sys.version_info >= (3, 0):
_basestring = str
@@ -201,7 +201,7 @@ class OptionGroup(optparse.OptionGroup):
raise gerror
group = _glib.OptionGroup(self.name, self.description,
- self.help_description, callback)
+ self.help_description, callback)
if self.translation_domain:
group.set_translation_domain(self.translation_domain)
@@ -305,7 +305,7 @@ class OptionParser(optparse.OptionParser):
def add_option_group(self, *args, **kwargs):
if isinstance(args[0], _basestring):
optparse.OptionParser.add_option_group(self,
- OptionGroup(self, *args, **kwargs))
+ OptionGroup(self, *args, **kwargs))
return
elif len(args) == 1 and not kwargs:
if isinstance(args[0], OptionGroup):
diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py
index 673b364..5c0bb0b 100644
--- a/gi/_gobject/propertyhelper.py
+++ b/gi/_gobject/propertyhelper.py
@@ -24,16 +24,16 @@ import sys
from . import _gobject
from .constants import \
- TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, \
- TYPE_BOOLEAN, TYPE_INT, TYPE_UINT, TYPE_LONG, \
- TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_ENUM, TYPE_FLAGS, \
- TYPE_FLOAT, TYPE_DOUBLE, TYPE_STRING, \
- TYPE_POINTER, TYPE_BOXED, TYPE_PARAM, TYPE_OBJECT, \
- TYPE_PYOBJECT, TYPE_GTYPE, TYPE_STRV
+ TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, \
+ TYPE_BOOLEAN, TYPE_INT, TYPE_UINT, TYPE_LONG, \
+ TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_ENUM, TYPE_FLAGS, \
+ TYPE_FLOAT, TYPE_DOUBLE, TYPE_STRING, \
+ TYPE_POINTER, TYPE_BOXED, TYPE_PARAM, TYPE_OBJECT, \
+ TYPE_PYOBJECT, TYPE_GTYPE, TYPE_STRV
from .constants import \
- G_MAXFLOAT, G_MAXDOUBLE, \
- G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \
- G_MAXULONG
+ G_MAXFLOAT, G_MAXDOUBLE, \
+ G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \
+ G_MAXULONG
if sys.version_info >= (3, 0):
_basestring = str
diff --git a/gi/module.py b/gi/module.py
index 26bb56a..8cd80ef 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -154,7 +154,7 @@ class IntrospectionModule(object):
if isinstance(info, ObjectInfo):
parent = get_parent_for_object(info)
interfaces = tuple(interface for interface in get_interfaces_for_object(info)
- if not issubclass(parent, interface))
+ if not issubclass(parent, interface))
bases = (parent,) + interfaces
metaclass = GObjectMeta
elif isinstance(info, CallbackInfo):
@@ -166,9 +166,9 @@ class IntrospectionModule(object):
elif isinstance(info, (StructInfo, UnionInfo)):
if g_type.is_a(_gobject.TYPE_BOXED):
bases = (Boxed,)
- elif g_type.is_a(_gobject.TYPE_POINTER) or \
- g_type == _gobject.TYPE_NONE or \
- g_type.fundamental == g_type:
+ elif (g_type.is_a(_gobject.TYPE_POINTER) or
+ g_type == _gobject.TYPE_NONE or
+ g_type.fundamental == g_type):
bases = (Struct,)
else:
raise TypeError("unable to create a wrapper for %s.%s" % (info.get_namespace(), info.get_name()))
@@ -261,9 +261,9 @@ class DynamicModule(object):
def __repr__(self):
path = repository.get_typelib_path(self._namespace)
return "<%s.%s %r from %r>" % (self.__class__.__module__,
- self.__class__.__name__,
- self._namespace,
- path)
+ self.__class__.__name__,
+ self._namespace,
+ path)
class DynamicGObjectModule(DynamicModule):
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 95c46d9..1d15aff 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -222,7 +222,7 @@ class Variant(GLib.Variant):
# tuple
if self.get_type_string().startswith('('):
res = [self.get_child_value(i).unpack()
- for i in range(self.n_children())]
+ for i in range(self.n_children())]
return tuple(res)
# dictionary
diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py
index 4a4b404..cc9cca9 100644
--- a/gi/overrides/Gio.py
+++ b/gi/overrides/Gio.py
@@ -141,14 +141,17 @@ class _DBusProxyMethodCall:
if 'result_handler' in kwargs:
# asynchronous call
user_data = (kwargs['result_handler'],
- kwargs.get('error_handler'), kwargs.get('user_data'))
+ kwargs.get('error_handler'),
+ kwargs.get('user_data'))
self.dbus_proxy.call(self.method_name, arg_variant,
- kwargs.get('flags', 0), kwargs.get('timeout', -1), None,
- self.__async_result_handler, user_data)
+ kwargs.get('flags', 0), kwargs.get('timeout', -1), None,
+ self.__async_result_handler, user_data)
else:
# synchronous call
result = self.dbus_proxy.call_sync(self.method_name, arg_variant,
- kwargs.get('flags', 0), kwargs.get('timeout', -1), None)
+ kwargs.get('flags', 0),
+ kwargs.get('timeout', -1),
+ None)
return self._unpack_result(result)
@classmethod
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index fbb5076..1960297 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -555,11 +555,11 @@ class RecentChooserDialog(Gtk.RecentChooserDialog):
**kwds):
Gtk.RecentChooserDialog.__init__(self,
- recent_manager=manager,
- title=title,
- parent=parent,
- buttons=buttons,
- **kwds)
+ recent_manager=manager,
+ title=title,
+ parent=parent,
+ buttons=buttons,
+ **kwds)
RecentChooserDialog = override(RecentChooserDialog)
__all__.append('RecentChooserDialog')
@@ -713,7 +713,7 @@ class TextIter(Gtk.TextIter):
def forward_search(self, string, flags, limit):
success, match_start, match_end = super(TextIter, self).forward_search(string,
- flags, limit)
+ flags, limit)
if success:
return (match_start, match_end)
else:
@@ -721,7 +721,7 @@ class TextIter(Gtk.TextIter):
def backward_search(self, string, flags, limit):
success, match_start, match_end = super(TextIter, self).backward_search(string,
- flags, limit)
+ flags, limit)
if success:
return (match_start, match_end)
else:
@@ -1139,7 +1139,7 @@ class TreeModelRow(object):
if len(indexList) != len(value):
raise ValueError(
"attempt to assign sequence of size %d to slice of size %d"
- % (len(value), len(indexList)))
+ % (len(value), len(indexList)))
for i, v in enumerate(indexList):
self.model.set_value(self.iter, v, value[i])
diff --git a/gi/pygtkcompat.py b/gi/pygtkcompat.py
index 9359219..550d21e 100644
--- a/gi/pygtkcompat.py
+++ b/gi/pygtkcompat.py
@@ -194,7 +194,7 @@ def enable_gtk(version='2.0'):
def set_tool_item_type(menuaction, gtype):
warnings.warn('set_tool_item_type() is not supported',
- DeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
Gtk.Action.set_tool_item_type = classmethod(set_tool_item_type)
# Alignment
@@ -312,7 +312,7 @@ def enable_gtk(version='2.0'):
def install_child_property(container, flag, pspec):
warnings.warn('install_child_property() is not supported',
- DeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
Gtk.Container.install_child_property = classmethod(install_child_property)
def new_text():
@@ -372,8 +372,7 @@ def enable_gtk(version='2.0'):
def __init__(self, req):
self.height = req.height
self.width = req.width
- UserList.__init__(self, [self.width,
- self.height])
+ UserList.__init__(self, [self.width, self.height])
return SizeRequest(orig_size_request(widget))
Gtk.Widget.size_request = size_request
Gtk.Widget.hide_all = Gtk.Widget.hide
diff --git a/gi/types.py b/gi/types.py
index 95f1059..3b94294 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -148,14 +148,15 @@ class MetaClassHelper(object):
if ambiguous_base is not None:
base_info = vfunc_info.get_container()
raise TypeError('Method %s() on class %s.%s is ambiguous '
- 'with methods in base classes %s.%s and %s.%s' %
- (vfunc_name,
- cls.__info__.get_namespace(),
- cls.__info__.get_name(),
- base_info.get_namespace(),
- base_info.get_name(),
- ambiguous_base.__info__.get_namespace(),
- ambiguous_base.__info__.get_name()))
+ 'with methods in base classes %s.%s and %s.%s' %
+ (vfunc_name,
+ cls.__info__.get_namespace(),
+ cls.__info__.get_name(),
+ base_info.get_namespace(),
+ base_info.get_name(),
+ ambiguous_base.__info__.get_namespace(),
+ ambiguous_base.__info__.get_name()
+ ))
hook_up_vfunc_implementation(vfunc_info, cls.__gtype__,
py_vfunc)
diff --git a/tests/runtests.py b/tests/runtests.py
index 4dddc72..2215196 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -22,7 +22,7 @@ os.environ['G_DEBUG'] = 'fatal-warnings fatal-criticals'
# first.
os.environ['GSETTINGS_BACKEND'] = 'memory'
os.environ['GSETTINGS_SCHEMA_DIR'] = os.environ.get('TESTS_BUILDDIR',
- os.path.dirname(__file__))
+ os.path.dirname(__file__))
# Load tests.
if 'TEST_NAMES' in os.environ:
diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py
index afd18c7..3411e48 100644
--- a/tests/test_gdbus.py
+++ b/tests/test_gdbus.py
@@ -16,22 +16,25 @@ class TestGDBusClient(unittest.TestCase):
self.bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
self.dbus_proxy = Gio.DBusProxy.new_sync(self.bus,
- Gio.DBusProxyFlags.NONE, None,
- 'org.freedesktop.DBus',
- '/org/freedesktop/DBus',
- 'org.freedesktop.DBus', None)
+ Gio.DBusProxyFlags.NONE,
+ None,
+ 'org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus',
+ None)
def test_native_calls_sync(self):
result = self.dbus_proxy.call_sync('ListNames', None,
- Gio.DBusCallFlags.NO_AUTO_START, 500, None)
+ Gio.DBusCallFlags.NO_AUTO_START,
+ 500, None)
self.assertTrue(isinstance(result, GLib.Variant))
result = result.unpack()[0] # result is always a tuple
self.assertTrue(len(result) > 1)
self.assertTrue('org.freedesktop.DBus' in result)
result = self.dbus_proxy.call_sync('GetNameOwner',
- GLib.Variant('(s)', ('org.freedesktop.DBus',)),
- Gio.DBusCallFlags.NO_AUTO_START, 500, None)
+ GLib.Variant('(s)', ('org.freedesktop.DBus',)),
+ Gio.DBusCallFlags.NO_AUTO_START, 500, None)
self.assertTrue(isinstance(result, GLib.Variant))
self.assertEqual(type(result.unpack()[0]), type(''))
@@ -39,7 +42,7 @@ class TestGDBusClient(unittest.TestCase):
# error case: invalid argument types
try:
self.dbus_proxy.call_sync('GetConnectionUnixProcessID', None,
- Gio.DBusCallFlags.NO_AUTO_START, 500, None)
+ Gio.DBusCallFlags.NO_AUTO_START, 500, None)
self.fail('call with invalid arguments should raise an exception')
except Exception as e:
self.assertTrue('InvalidArgs' in str(e))
@@ -47,8 +50,8 @@ class TestGDBusClient(unittest.TestCase):
# error case: invalid argument
try:
self.dbus_proxy.call_sync('GetConnectionUnixProcessID',
- GLib.Variant('(s)', (' unknown',)),
- Gio.DBusCallFlags.NO_AUTO_START, 500, None)
+ GLib.Variant('(s)', (' unknown',)),
+ Gio.DBusCallFlags.NO_AUTO_START, 500, None)
self.fail('call with invalid arguments should raise an exception')
except Exception as e:
self.assertTrue('NameHasNoOwner' in str(e))
@@ -56,7 +59,7 @@ class TestGDBusClient(unittest.TestCase):
# error case: unknown method
try:
self.dbus_proxy.call_sync('UnknownMethod', None,
- Gio.DBusCallFlags.NO_AUTO_START, 500, None)
+ Gio.DBusCallFlags.NO_AUTO_START, 500, None)
self.fail('call for unknown method should raise an exception')
except Exception as e:
self.assertTrue('UnknownMethod' in str(e))
@@ -71,8 +74,8 @@ class TestGDBusClient(unittest.TestCase):
main_loop = GObject.MainLoop()
data = {'main_loop': main_loop}
self.dbus_proxy.call('ListNames', None,
- Gio.DBusCallFlags.NO_AUTO_START, 500, None,
- call_done, data)
+ Gio.DBusCallFlags.NO_AUTO_START, 500, None,
+ call_done, data)
main_loop.run()
self.assertTrue(isinstance(data['result'], GLib.Variant))
@@ -93,7 +96,8 @@ class TestGDBusClient(unittest.TestCase):
main_loop = GObject.MainLoop()
data = {'main_loop': main_loop}
self.dbus_proxy.call('UnknownMethod', None,
- Gio.DBusCallFlags.NO_AUTO_START, 500, None, call_done, data)
+ Gio.DBusCallFlags.NO_AUTO_START, 500, None,
+ call_done, data)
main_loop.run()
def test_python_calls_sync(self):
@@ -113,12 +117,13 @@ class TestGDBusClient(unittest.TestCase):
# does not have any method returning multiple results, so try talking
# to notification-daemon (and don't fail the test if it does not exist)
try:
- notification_daemon = Gio.DBusProxy.new_sync(self.bus,
- Gio.DBusProxyFlags.NONE, None,
- 'org.freedesktop.Notifications',
- '/org/freedesktop/Notifications',
- 'org.freedesktop.Notifications', None)
- result = notification_daemon.GetServerInformation('()')
+ nd = Gio.DBusProxy.new_sync(self.bus,
+ Gio.DBusProxyFlags.NONE, None,
+ 'org.freedesktop.Notifications',
+ '/org/freedesktop/Notifications',
+ 'org.freedesktop.Notifications',
+ None)
+ result = nd.GetServerInformation('()')
self.assertTrue(isinstance(result, tuple))
self.assertEqual(len(result), 4)
for i in result:
@@ -162,8 +167,7 @@ class TestGDBusClient(unittest.TestCase):
main_loop = GObject.MainLoop()
data = {'main_loop': main_loop}
- self.dbus_proxy.ListNames('()', result_handler=call_done,
- user_data=data)
+ self.dbus_proxy.ListNames('()', result_handler=call_done, user_data=data)
main_loop.run()
result = data['result']
@@ -180,7 +184,7 @@ class TestGDBusClient(unittest.TestCase):
main_loop = GObject.MainLoop()
data = {'main_loop': main_loop}
self.dbus_proxy.ListNames('(s)', 'invalid_argument',
- result_handler=call_done, user_data=data)
+ result_handler=call_done, user_data=data)
main_loop.run()
self.assertTrue(isinstance(data['result'], Exception))
@@ -199,8 +203,9 @@ class TestGDBusClient(unittest.TestCase):
main_loop = GObject.MainLoop()
data = {'main_loop': main_loop}
self.dbus_proxy.ListNames('(s)', 'invalid_argument',
- result_handler=call_done, error_handler=call_error,
- user_data=data)
+ result_handler=call_done,
+ error_handler=call_error,
+ user_data=data)
main_loop.run()
self.assertTrue(isinstance(data['error'], Exception))
diff --git a/tests/test_gi.py b/tests/test_gi.py
index e314e50..4ebbd68 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1012,16 +1012,19 @@ class TestGHashTable(unittest.TestCase):
self.assertEqual({'-1': '1', '0': '0', '1': '-1', '2': '-2'}, GIMarshallingTests.ghashtable_utf8_full_out())
def test_ghashtable_utf8_none_inout(self):
+ i = {'-1': '1', '0': '0', '1': '-1', '2': '-2'}
self.assertEqual({'-1': '1', '0': '0', '1': '1'},
- GIMarshallingTests.ghashtable_utf8_none_inout({'-1': '1', '0': '0', '1': '-1', '2': '-2'}))
+ GIMarshallingTests.ghashtable_utf8_none_inout(i))
def test_ghashtable_utf8_container_inout(self):
+ i = {'-1': '1', '0': '0', '1': '-1', '2': '-2'}
self.assertEqual({'-1': '1', '0': '0', '1': '1'},
- GIMarshallingTests.ghashtable_utf8_container_inout({'-1': '1', '0': '0', '1': '-1', '2': '-2'}))
+ GIMarshallingTests.ghashtable_utf8_container_inout(i))
def test_ghashtable_utf8_full_inout(self):
+ i = {'-1': '1', '0': '0', '1': '-1', '2': '-2'}
self.assertEqual({'-1': '1', '0': '0', '1': '1'},
- GIMarshallingTests.ghashtable_utf8_full_inout({'-1': '1', '0': '0', '1': '-1', '2': '-2'}))
+ GIMarshallingTests.ghashtable_utf8_full_inout(i))
class TestGValue(unittest.TestCase):
@@ -1088,9 +1091,9 @@ class TestEnum(unittest.TestCase):
Run test under a locale which defines toupper('a') == 'a'
'''
cls.locale_dir = tempfile.mkdtemp()
- subprocess.check_call(['localedef', '-i',
- os.path.join(os.path.dirname(os.path.realpath(__file__)), 'te_ST nouppera'),
- '-c', '-f', 'UTF-8', os.path.join(cls.locale_dir, 'te_ST UTF-8 nouppera')])
+ src = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'te_ST nouppera')
+ dest = os.path.join(cls.locale_dir, 'te_ST UTF-8 nouppera')
+ subprocess.check_call(['localedef', '-i', src, '-c', '-f', 'UTF-8', dest])
os.environ['LOCPATH'] = cls.locale_dir
locale.setlocale(locale.LC_ALL, 'te_ST UTF-8 nouppera')
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index d225d50..a28a145 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -13,7 +13,7 @@ class TestGObjectAPI(unittest.TestCase):
obj = GObject.GObject()
self.assertEqual(obj.__module__,
- 'gi._gobject._gobject')
+ 'gi._gobject._gobject')
class TestReferenceCounting(unittest.TestCase):
@@ -358,7 +358,7 @@ class TestPropertyBindings(unittest.TestCase):
def testDefaultBinding(self):
binding = self.source.bind_property('int_prop', self.target, 'int_prop',
- GObject.BindingFlags.DEFAULT)
+ GObject.BindingFlags.DEFAULT)
binding = binding # PyFlakes
# Test setting value on source gets pushed to target
@@ -373,7 +373,7 @@ class TestPropertyBindings(unittest.TestCase):
def testBiDirectionalBinding(self):
binding = self.source.bind_property('int_prop', self.target, 'int_prop',
- GObject.BindingFlags.BIDIRECTIONAL)
+ GObject.BindingFlags.BIDIRECTIONAL)
binding = binding # PyFlakes
# Test setting value on source gets pushed to target
@@ -392,8 +392,8 @@ class TestPropertyBindings(unittest.TestCase):
return value * 2
binding = self.source.bind_property('int_prop', self.target, 'int_prop',
- GObject.BindingFlags.DEFAULT,
- transform_to, None, 'test-data')
+ GObject.BindingFlags.DEFAULT,
+ transform_to, None, 'test-data')
binding = binding # PyFlakes
self.source.int_prop = 1
@@ -410,8 +410,8 @@ class TestPropertyBindings(unittest.TestCase):
return value * 2
binding = self.source.bind_property('int_prop', self.target, 'int_prop',
- GObject.BindingFlags.BIDIRECTIONAL,
- None, transform_from)
+ GObject.BindingFlags.BIDIRECTIONAL,
+ None, transform_from)
binding = binding # PyFlakes
self.source.int_prop = 1
@@ -433,8 +433,8 @@ class TestPropertyBindings(unittest.TestCase):
# bidirectional bindings
binding = self.source.bind_property('int_prop', self.target, 'int_prop',
- GObject.BindingFlags.BIDIRECTIONAL,
- transform_to, transform_from, 'test-data')
+ GObject.BindingFlags.BIDIRECTIONAL,
+ transform_to, transform_from, 'test-data')
binding = binding # PyFlakes
self.source.int_prop = 1
diff --git a/tests/test_option.py b/tests/test_option.py
index 7f63173..345d0ad 100644
--- a/tests/test_option.py
+++ b/tests/test_option.py
@@ -12,7 +12,7 @@ except ImportError:
# FIXME: we need a way to import the options module from a public module
from gi._glib.option import OptionParser, OptionGroup, OptionValueError, \
- make_option, BadOptionError
+ make_option, BadOptionError
class TestOption(unittest.TestCase):
@@ -20,9 +20,9 @@ class TestOption(unittest.TestCase):
def setUp(self):
self.parser = OptionParser("NAMES...",
- description="Option unit test")
+ description="Option unit test")
self.parser.add_option("-t", "--test", help="Unit test option",
- action="store_false", dest="test", default=True)
+ action="store_false", dest="test", default=True)
self.parser.add_option("--g-fatal-warnings",
action="store_true",
dest="fatal_warnings",
@@ -36,18 +36,18 @@ class TestOption(unittest.TestCase):
"unittest", "Unit test options", "Show all unittest options",
option_list=[
make_option("-f", "-u", "--file", "--unit-file",
- type="filename",
- dest="unit_file",
- help="Unit test option"),
+ type="filename",
+ dest="unit_file",
+ help="Unit test option"),
make_option("--test-integer",
- type="int",
- dest="test_integer",
- help="Unit integer option"),
+ type="int",
+ dest="test_integer",
+ help="Unit integer option"),
make_option("--callback-failure-test",
- action="callback",
- callback=option_callback,
- dest="test_integer",
- help="Unit integer option"),
+ action="callback",
+ callback=option_callback,
+ dest="test_integer",
+ help="Unit integer option"),
])
group.add_option("-t", "--test",
action="store_false",
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index dffdd17..63eaeb8 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -204,19 +204,21 @@ class TestGLib(unittest.TestCase):
self.assertEqual(variant.unpack(), obj)
obj = {"frequency": GLib.Variant('t', 738000000),
- "hierarchy": GLib.Variant('i', 0),
- "bandwidth": GLib.Variant('x', 8),
- "code-rate-hp": GLib.Variant('d', 2.0 / 3.0),
- "constellation": GLib.Variant('s', "QAM16"),
- "guard-interval": GLib.Variant('u', 4)}
+ "hierarchy": GLib.Variant('i', 0),
+ "bandwidth": GLib.Variant('x', 8),
+ "code-rate-hp": GLib.Variant('d', 2.0 / 3.0),
+ "constellation": GLib.Variant('s', "QAM16"),
+ "guard-interval": GLib.Variant('u', 4)}
variant = GLib.Variant('a{sv}', obj)
self.assertEqual(variant.get_type_string(), 'a{sv}')
- self.assertEqual(variant.unpack(), {"frequency": 738000000,
- "hierarchy": 0,
- "bandwidth": 8,
- "code-rate-hp": 2.0 / 3.0,
- "constellation": "QAM16",
- "guard-interval": 4})
+ self.assertEqual(variant.unpack(),
+ {"frequency": 738000000,
+ "hierarchy": 0,
+ "bandwidth": 8,
+ "code-rate-hp": 2.0 / 3.0,
+ "constellation": "QAM16",
+ "guard-interval": 4
+ })
def test_gvariant_create_errors(self):
# excess arguments
@@ -258,7 +260,7 @@ class TestGLib(unittest.TestCase):
# tuple
res = GLib.Variant.new_tuple(GLib.Variant.new_int32(-1),
- GLib.Variant.new_string('hello')).unpack()
+ GLib.Variant.new_string('hello')).unpack()
self.assertEqual(res, (-1, 'hello'))
# array
@@ -294,7 +296,7 @@ class TestGLib(unittest.TestCase):
# tuple index access
v = GLib.Variant.new_tuple(GLib.Variant.new_int32(-1),
- GLib.Variant.new_string('hello'))
+ GLib.Variant.new_string('hello'))
self.assertEqual(len(v), 2)
self.assertEqual(v[0], -1)
self.assertEqual(v[1], 'hello')
@@ -351,15 +353,15 @@ class TestGLib(unittest.TestCase):
self.assertEqual(GLib.Variant.split_signature('(iso)'), ['i', 's', 'o'])
self.assertEqual(GLib.Variant.split_signature('(s(ss)i(ii))'),
- ['s', '(ss)', 'i', '(ii)'])
+ ['s', '(ss)', 'i', '(ii)'])
self.assertEqual(GLib.Variant.split_signature('(as)'), ['as'])
self.assertEqual(GLib.Variant.split_signature('(s(ss)iaiaasa(ii))'),
- ['s', '(ss)', 'i', 'ai', 'aas', 'a(ii)'])
+ ['s', '(ss)', 'i', 'ai', 'aas', 'a(ii)'])
self.assertEqual(GLib.Variant.split_signature('(a{iv}(ii)((ss)a{s(ss)}))'),
- ['a{iv}', '(ii)', '((ss)a{s(ss)})'])
+ ['a{iv}', '(ii)', '((ss)a{s(ss)})'])
def test_variant_hash(self):
v1 = GLib.Variant('s', 'somestring')
@@ -645,12 +647,12 @@ class TestGtk(unittest.TestCase):
('test-action1', None, 'Test Action 1',
None, None, test_action_callback_data),
('test-action2', Gtk.STOCK_COPY, 'Test Action 2',
- None, None, test_action_callback_data)], callback_data)
+ None, None, test_action_callback_data)], callback_data)
action_group.add_toggle_actions([
('test-toggle-action1', None, 'Test Toggle Action 1',
None, None, test_action_callback_data, False),
('test-toggle-action2', Gtk.STOCK_COPY, 'Test Toggle Action 2',
- None, None, test_action_callback_data, True)], callback_data)
+ None, None, test_action_callback_data, True)], callback_data)
action_group.add_radio_actions([
('test-radio-action1', None, 'Test Radio Action 1'),
('test-radio-action2', Gtk.STOCK_COPY, 'Test Radio Action 2')], 1,
@@ -742,8 +744,7 @@ class TestGtk(unittest.TestCase):
<signal name="test-signal" handler="on_signal_4" />
</object>
</interface>
-""",
- ['object3'])
+""", ['object3'])
# hook up signals
builder.connect_signals(signal_checker)
@@ -1212,14 +1213,14 @@ class TestGtk(unittest.TestCase):
label = 'this is row #102'
treeiter = list_store.append()
list_store.set(treeiter, (1, 0, 2, 3, 4, 5, 6, 7),
- (label,
- i,
- TestGtk.TestClass(self, i, label),
- test_pyobj,
- test_pydict,
- test_pylist,
- 0,
- False))
+ (label,
+ i,
+ TestGtk.TestClass(self, i, label),
+ test_pyobj,
+ test_pydict,
+ test_pylist,
+ 0,
+ False))
self.assertEqual(len(list_store), 103)
@@ -1274,16 +1275,16 @@ class TestGtk(unittest.TestCase):
# not sorted yet, should be original order
self.assertEqual([list(i) for i in list_store],
- [[1, 'apples'], [3, 'oranges'], [2, 'mango']])
+ [[1, 'apples'], [3, 'oranges'], [2, 'mango']])
# sort with our custom function
list_store.set_sort_column_id(2, Gtk.SortType.ASCENDING)
self.assertEqual([list(i) for i in list_store],
- [[2, 'mango'], [1, 'apples'], [3, 'oranges']])
+ [[2, 'mango'], [1, 'apples'], [3, 'oranges']])
list_store.set_sort_column_id(2, Gtk.SortType.DESCENDING)
self.assertEqual([list(i) for i in list_store],
- [[3, 'oranges'], [1, 'apples'], [2, 'mango']])
+ [[3, 'oranges'], [1, 'apples'], [2, 'mango']])
def test_list_store_signals(self):
list_store = Gtk.ListStore(int, bool)
@@ -1686,7 +1687,7 @@ class TestGtk(unittest.TestCase):
self.assertTrue(start.has_tag(tag))
self.assertRaises(ValueError, buffer.insert_with_tags_by_name,
- buffer.get_start_iter(), 'HelloHello', 'unknowntag')
+ buffer.get_start_iter(), 'HelloHello', 'unknowntag')
def test_text_iter(self):
self.assertEqual(Gtk.TextIter, overrides.Gtk.TextIter)
@@ -1757,7 +1758,7 @@ class TestGtk(unittest.TestCase):
for kl in classes:
if kl.get_name() == name:
self.assertTrue(issubclass(klass, over,),
- "%r does not inherit from override %r" % (klass, over,))
+ "%r does not inherit from override %r" % (klass, over,))
def test_editable(self):
self.assertEqual(Gtk.Editable, overrides.Gtk.Editable)
diff --git a/tests/test_properties.py b/tests/test_properties.py
index d5943bf..f81ed4f 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -6,13 +6,12 @@ import unittest
from gi.repository import GObject
from gi.repository.GObject import GType, new, PARAM_READWRITE, \
- PARAM_CONSTRUCT, PARAM_READABLE, PARAM_WRITABLE, PARAM_CONSTRUCT_ONLY
+ PARAM_CONSTRUCT, PARAM_READABLE, PARAM_WRITABLE, PARAM_CONSTRUCT_ONLY
from gi.repository.GObject import \
- TYPE_INT, TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_INT64, \
- TYPE_UINT64, TYPE_GTYPE, TYPE_INVALID, TYPE_NONE, TYPE_STRV
+ TYPE_INT, TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_INT64, \
+ TYPE_UINT64, TYPE_GTYPE, TYPE_INVALID, TYPE_NONE, TYPE_STRV
from gi.repository.GObject import \
- G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \
- G_MAXULONG
+ G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, G_MAXULONG
from gi.repository import Gio
from gi.repository import GLib
@@ -196,11 +195,11 @@ class TestProperties(unittest.TestCase):
self.assertRaises(TypeError, setattr, obj, 'flags', None)
self.assertRaises(TypeError, GObject.Property,
- type=GIMarshallingTests.Flags, default='foo')
+ type=GIMarshallingTests.Flags, default='foo')
self.assertRaises(TypeError, GObject.Property,
- type=GIMarshallingTests.Flags, default=object())
+ type=GIMarshallingTests.Flags, default=object())
self.assertRaises(TypeError, GObject.Property,
- type=GIMarshallingTests.Flags, default=None)
+ type=GIMarshallingTests.Flags, default=None)
def testGType(self):
obj = new(PropertyObject)
@@ -218,16 +217,16 @@ class TestProperties(unittest.TestCase):
# GType parameters do not support defaults in GLib
self.assertRaises(TypeError, GObject.Property, type=TYPE_GTYPE,
- default=TYPE_INT)
+ default=TYPE_INT)
# incompatible type
self.assertRaises(TypeError, setattr, obj, 'gtype', 'foo')
self.assertRaises(TypeError, setattr, obj, 'gtype', object())
self.assertRaises(TypeError, GObject.Property, type=TYPE_GTYPE,
- default='foo')
+ default='foo')
self.assertRaises(TypeError, GObject.Property, type=TYPE_GTYPE,
- default=object())
+ default=object())
# set in constructor
obj = new(PropertyObject, gtype=TYPE_UINT)
@@ -289,11 +288,11 @@ class TestProperties(unittest.TestCase):
self.assertRaises(TypeError, setattr, obj, 'strings', ['foo', 1])
self.assertRaises(TypeError, GObject.Property, type=TYPE_STRV,
- default=1)
+ default=1)
self.assertRaises(TypeError, GObject.Property, type=TYPE_STRV,
- default='foo')
+ default='foo')
self.assertRaises(TypeError, GObject.Property, type=TYPE_STRV,
- default=['hello', 1])
+ default=['hello', 1])
def testRange(self):
# kiwi code
@@ -507,8 +506,7 @@ class TestProperty(unittest.TestCase):
for gtype, min, max in types:
# Normal, everything is alright
prop = GObject.Property(type=gtype, minimum=min, maximum=max)
- subtype = type('', (GObject.GObject,),
- dict(prop=prop))
+ subtype = type('', (GObject.GObject,), dict(prop=prop))
self.assertEqual(subtype.props.prop.minimum, min)
self.assertEqual(subtype.props.prop.maximum, max)
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 66a7427..02e3b96 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -111,7 +111,7 @@ def my_accumulator(ihint, return_accu, handler_return, user_data):
class Foo(GObject.GObject):
__gsignals__ = {
'my-acc-signal': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_INT,
- (), my_accumulator, "accum data"),
+ (), my_accumulator, "accum data"),
'my-other-acc-signal': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_BOOLEAN,
(), GObject.signal_accumulator_true_handled)
}
diff --git a/tests/test_uris.py b/tests/test_uris.py
index 095a9dd..143cc7b 100644
--- a/tests/test_uris.py
+++ b/tests/test_uris.py
@@ -5,10 +5,11 @@ from gi.repository import GLib
class TestUris(unittest.TestCase):
def testExtractUris(self):
- uri_list_text = "# urn:isbn:0-201-08372-8\n" + \
- "http://www.huh.org/books/foo.html\n" + \
- "http://www.huh.org/books/foo.pdf\n" + \
- "ftp://ftp.foo.org/books/foo.txt\n"
+ uri_list_text = """# urn:isbn:0-201-08372-8
+http://www.huh.org/books/foo.html
+http://www.huh.org/books/foo.pdf
+ftp://ftp.foo.org/books/foo.txt
+"""
uri_list = GLib.uri_list_extract_uris(uri_list_text)
assert uri_list[0] == "http://www.huh.org/books/foo.html"
assert uri_list[1] == "http://www.huh.org/books/foo.pdf"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]