1 | import unittest |
||
2 | from unittest.case import SkipTest |
||
3 | |||
4 | from coalib import coala_dbus |
||
5 | from coalib.tests.TestUtilities import execute_coala |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
6 | |||
7 | try: |
||
8 | import dbus.mainloop.glib |
||
0 ignored issues
–
show
|
|||
9 | from gi.repository import GLib |
||
10 | except ImportError: |
||
11 | raise SkipTest("python-gi or python-dbus not installed") |
||
12 | |||
13 | |||
14 | class GlibMainLoopTest: |
||
15 | |||
16 | def run(self): |
||
0 ignored issues
–
show
This method could be written as a function/class method.
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;
![]() |
|||
17 | raise AssertionError |
||
18 | |||
19 | |||
20 | class coalaDbusTest(unittest.TestCase): |
||
21 | |||
22 | def setUp(self): |
||
23 | self.glib_main_loop = GLib.MainLoop |
||
24 | GLib.MainLoop = GlibMainLoopTest |
||
25 | |||
26 | def tearDown(self): |
||
27 | GLib.MainLoop = self.glib_main_loop |
||
28 | |||
29 | def test_main(self): |
||
30 | # Ensure we are able to setup dbus and create a mainloop |
||
31 | with self.assertRaises(AssertionError): |
||
32 | coala_dbus.main() |
||
33 |