tests.test_PillowImage_utils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 60 %

Importance

Changes 0
Metric Value
wmc 4
eloc 23
dl 21
loc 35
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A TestPillowImageUtils.tearDown() 2 2 1
A TestPillowImageUtils.setUp() 2 2 1
A TestPillowImageUtils.test_img_adjust_rotate() 8 8 1
A TestPillowImageUtils.setUpClass() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

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
import os
2
import unittest
3
4
from looptools import Timer
5
6
from PillowImage import img_adjust
7
from tests import *
8
9
10 View Code Duplication
class TestPillowImageUtils(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
    @classmethod
12
    def setUpClass(cls):
13
        cls.img_path = IMG_PATH
14
        cls.wtrmrk_path = WTR_PATH
15
        cls.pdf = None
16
17
    def setUp(self):
18
        self.image = None
19
20
    def tearDown(self):
21
        os.remove(self.image)
22
23
    @Timer.decorator
24
    def test_img_adjust_rotate(self):
25
        """Test the function 'img_rotate.'"""
26
        self.image = img_adjust(self.wtrmrk_path, rotate=30, fit=1)
27
28
        # Assert file exists
29
        self.assertTrue(os.path.exists(self.image))
30
        return self.image
31
32
33
if __name__ == '__main__':
34
    unittest.main()
35