| Total Complexity | 4 |
| Total Lines | 35 |
| Duplicated Lines | 60 % |
| Changes | 0 | ||
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): |
|
|
|
|||
| 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 |