Completed
Pull Request — master (#2081)
by Abdeali
02:15
created

PrintMoreInfoActionTest.test_apply()   A

Complexity

Conditions 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
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):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable unittest does not seem to be defined.
Loading history...
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))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
22
23
    def test_apply(self):
24
        with retrieve_stdout() as stdout:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable stdout does not seem to be defined.
Loading history...
25
            self.assertEqual(self.uut.apply_from_section(self.test_result,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
26
                                                         {},
27
                                                         {},
28
                                                         Section("name")),
29
                             {})
30
            self.assertEqual(stdout.getvalue(),
31
                             self.test_result.additional_info + "\n")
32