Failed Conditions
Pull Request — master (#1511)
by Abdeali
01:47
created

coalib.tests.coalaDbusTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %
Metric Value
dl 0
loc 13
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_main() 0 4 2
A setUp() 0 3 1
A tearDown() 0 2 1
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
Unused execute_coala imported from coalib.tests.TestUtilities
Loading history...
6
7
try:
8
    import dbus.mainloop.glib
0 ignored issues
show
Unused Code introduced by
The import dbus.mainloop.glib seems to be unused.
Loading history...
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
Coding Style introduced by
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;
Loading history...
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