| Conditions | 1 | 
| Total Lines | 59 | 
| Lines | 0 | 
| Ratio | 0 % | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import os  | 
            ||
| 11 | |||
| 12 | class EscapePathArgumentTest(unittest.TestCase):  | 
            ||
| 13 | |||
| 14 | def test_escape_path_argument_linux_and_darwin(self):  | 
            ||
| 15 |         osnames = ("Linux", "Darwin") | 
            ||
| 16 | |||
| 17 | for osname in osnames:  | 
            ||
| 18 | self.assertEqual(  | 
            ||
| 19 |                 escape_path_argument("/home/usr/a-file", osname), | 
            ||
| 20 | "/home/usr/a-file")  | 
            ||
| 21 | self.assertEqual(  | 
            ||
| 22 |                 escape_path_argument("/home/usr/a-dir/", osname), | 
            ||
| 23 | "/home/usr/a-dir/")  | 
            ||
| 24 | self.assertEqual(  | 
            ||
| 25 |                 escape_path_argument("/home/us r/a-file with spaces.bla", | 
            ||
| 26 | osname),  | 
            ||
| 27 | "/home/us\\ r/a-file\\ with\\ spaces.bla")  | 
            ||
| 28 | self.assertEqual(  | 
            ||
| 29 |                 escape_path_argument("/home/us r/a-dir with spaces/x/", | 
            ||
| 30 | osname),  | 
            ||
| 31 | "/home/us\\ r/a-dir\\ with\\ spaces/x/")  | 
            ||
| 32 | self.assertEqual(  | 
            ||
| 33 | escape_path_argument(  | 
            ||
| 34 | "relative something/with cherries and/pickles.delicious",  | 
            ||
| 35 | osname),  | 
            ||
| 36 | "relative\\ something/with\\ cherries\\ and/pickles.delicious")  | 
            ||
| 37 | |||
| 38 | def test_escape_path_argument_windows(self):  | 
            ||
| 39 | osname = "Windows"  | 
            ||
| 40 | self.assertEqual(  | 
            ||
| 41 |             escape_path_argument("C:\\Windows\\has-a-weird-shell.txt", osname), | 
            ||
| 42 | "\"C:\\Windows\\has-a-weird-shell.txt\"")  | 
            ||
| 43 | self.assertEqual(  | 
            ||
| 44 |             escape_path_argument("C:\\Windows\\lolrofl\\dirs\\", osname), | 
            ||
| 45 | "\"C:\\Windows\\lolrofl\\dirs\\\"")  | 
            ||
| 46 | self.assertEqual(  | 
            ||
| 47 |             escape_path_argument("X:\\Users\\Maito Gai\\fi le.exe", osname), | 
            ||
| 48 | "\"X:\\Users\\Maito Gai\\fi le.exe\"")  | 
            ||
| 49 | self.assertEqual(  | 
            ||
| 50 |             escape_path_argument("X:\\Users\\Mai to Gai\\director y\\", | 
            ||
| 51 | osname),  | 
            ||
| 52 | "\"X:\\Users\\Mai to Gai\\director y\\\"")  | 
            ||
| 53 | self.assertEqual(  | 
            ||
| 54 |             escape_path_argument("X:\\Users\\Maito Gai\\\"seven-gates\".y", | 
            ||
| 55 | osname),  | 
            ||
| 56 | "\"X:\\Users\\Maito Gai\\^\"seven-gates^\".y\"")  | 
            ||
| 57 | self.assertEqual(  | 
            ||
| 58 |             escape_path_argument("System32\\my-custom relative tool\\", | 
            ||
| 59 | osname),  | 
            ||
| 60 | "\"System32\\my-custom relative tool\\\"")  | 
            ||
| 61 | self.assertEqual(  | 
            ||
| 62 |             escape_path_argument("System32\\illegal\" name \"\".curd", osname), | 
            ||
| 63 | "\"System32\\illegal^\" name ^\"^\".curd\"")  | 
            ||
| 64 | |||
| 65 | def test_escape_path_argument_unsupported_os(self):  | 
            ||
| 66 | osname = "INVALID"  | 
            ||
| 67 | self.assertEqual(  | 
            ||
| 68 |             escape_path_argument("/home/usr/a-file", osname), | 
            ||
| 69 | "/home/usr/a-file")  | 
            ||
| 70 | self.assertEqual(  | 
            ||
| 183 |