PrintMoreInfoActionTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_apply() 0 9 2
A setUp() 0 5 1
A test_is_applicable() 0 4 1
1
import unittest
2
3
from coalib.misc.ContextManagers import retrieve_stdout
4
from coalib.results.Result import Result
5
from coalib.results.result_actions.PrintMoreInfoAction import (
6
    PrintMoreInfoAction)
7
from coalib.settings.Section import Section
8
9
10
class PrintMoreInfoActionTest(unittest.TestCase):
11
12
    def setUp(self):
13
        self.uut = PrintMoreInfoAction()
14
        self.test_result = Result(
15
            "origin", "message",
16
            additional_info="A lot of additional information can be found here")
17
18
    def test_is_applicable(self):
19
        self.assertFalse(self.uut.is_applicable(1, None, None))
20
        self.assertFalse(self.uut.is_applicable(Result("o", "m"), None, None))
21
        self.assertTrue(self.uut.is_applicable(self.test_result, None, None))
22
23
    def test_apply(self):
24
        with retrieve_stdout() as stdout:
25
            self.assertEqual(self.uut.apply_from_section(self.test_result,
26
                                                         {},
27
                                                         {},
28
                                                         Section("name")),
29
                             {})
30
            self.assertEqual(stdout.getvalue(),
31
                             self.test_result.additional_info + "\n")
32