| Total Complexity | 7 |
| Total Lines | 33 |
| Duplicated Lines | 100 % |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | # pylint: disable=attribute-defined-outside-init |
||
| 9 | View Code Duplication | class TestShowConsole: |
|
|
|
|||
| 10 | |||
| 11 | def setup_method(self, _): |
||
| 12 | _Config.indent_level = 0 |
||
| 13 | _Config.verbosity = 0 |
||
| 14 | self.file = Mock() |
||
| 15 | |||
| 16 | def test_show(self): |
||
| 17 | common.show("Hello, world!", file=self.file) |
||
| 18 | |||
| 19 | assert [ |
||
| 20 | call.write("Hello, world!"), |
||
| 21 | call.write("\n"), |
||
| 22 | ] == self.file.mock_calls |
||
| 23 | |||
| 24 | def test_show_after_indent(self): |
||
| 25 | common.indent() |
||
| 26 | common.show("|\n", file=self.file) |
||
| 27 | |||
| 28 | assert [ |
||
| 29 | call.write(" |\n"), |
||
| 30 | call.write("\n"), |
||
| 31 | ] == self.file.mock_calls |
||
| 32 | |||
| 33 | def test_show_after_1_indent_2_dedent(self): |
||
| 34 | common.indent() |
||
| 35 | common.dedent() |
||
| 36 | common.dedent() |
||
| 37 | common.show("|\n", file=self.file) |
||
| 38 | |||
| 39 | assert [ |
||
| 40 | call.write("|\n"), |
||
| 41 | call.write("\n"), |
||
| 42 | ] == self.file.mock_calls |
||
| 91 |