for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import unittest
from unittest.case import SkipTest
from coalib import coala_dbus
from coalib.tests.TestUtilities import execute_coala
try:
import dbus.mainloop.glib
dbus.mainloop.glib
from gi.repository import GLib
except ImportError:
raise SkipTest("python-gi or python-dbus not installed")
class GlibMainLoopTest:
def run(self):
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example
class Foo: def some_method(self, x, y): return x + y;
could be written as
class Foo: @classmethod def some_method(cls, x, y): return x + y;
raise AssertionError
class coalaDbusTest(unittest.TestCase):
def setUp(self):
self.glib_main_loop = GLib.MainLoop
GLib.MainLoop = GlibMainLoopTest
def tearDown(self):
GLib.MainLoop = self.glib_main_loop
def test_main(self):
# Ensure we are able to setup dbus and create a mainloop
with self.assertRaises(AssertionError):
coala_dbus.main()