diff options
Diffstat (limited to 'tests/test_hooks.py')
-rw-r--r-- | tests/test_hooks.py | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 6632b3e5..78277128 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py | |||
@@ -17,39 +17,38 @@ | |||
17 | import hooks | 17 | import hooks |
18 | import unittest | 18 | import unittest |
19 | 19 | ||
20 | |||
20 | class RepoHookShebang(unittest.TestCase): | 21 | class RepoHookShebang(unittest.TestCase): |
21 | """Check shebang parsing in RepoHook.""" | 22 | """Check shebang parsing in RepoHook.""" |
22 | 23 | ||
23 | def test_no_shebang(self): | 24 | def test_no_shebang(self): |
24 | """Lines w/out shebangs should be rejected.""" | 25 | """Lines w/out shebangs should be rejected.""" |
25 | DATA = ( | 26 | DATA = ("", "#\n# foo\n", "# Bad shebang in script\n#!/foo\n") |
26 | '', | 27 | for data in DATA: |
27 | '#\n# foo\n', | 28 | self.assertIsNone(hooks.RepoHook._ExtractInterpFromShebang(data)) |
28 | '# Bad shebang in script\n#!/foo\n' | ||
29 | ) | ||
30 | for data in DATA: | ||
31 | self.assertIsNone(hooks.RepoHook._ExtractInterpFromShebang(data)) | ||
32 | 29 | ||
33 | def test_direct_interp(self): | 30 | def test_direct_interp(self): |
34 | """Lines whose shebang points directly to the interpreter.""" | 31 | """Lines whose shebang points directly to the interpreter.""" |
35 | DATA = ( | 32 | DATA = ( |
36 | ('#!/foo', '/foo'), | 33 | ("#!/foo", "/foo"), |
37 | ('#! /foo', '/foo'), | 34 | ("#! /foo", "/foo"), |
38 | ('#!/bin/foo ', '/bin/foo'), | 35 | ("#!/bin/foo ", "/bin/foo"), |
39 | ('#! /usr/foo ', '/usr/foo'), | 36 | ("#! /usr/foo ", "/usr/foo"), |
40 | ('#! /usr/foo -args', '/usr/foo'), | 37 | ("#! /usr/foo -args", "/usr/foo"), |
41 | ) | 38 | ) |
42 | for shebang, interp in DATA: | 39 | for shebang, interp in DATA: |
43 | self.assertEqual(hooks.RepoHook._ExtractInterpFromShebang(shebang), | 40 | self.assertEqual( |
44 | interp) | 41 | hooks.RepoHook._ExtractInterpFromShebang(shebang), interp |
42 | ) | ||
45 | 43 | ||
46 | def test_env_interp(self): | 44 | def test_env_interp(self): |
47 | """Lines whose shebang launches through `env`.""" | 45 | """Lines whose shebang launches through `env`.""" |
48 | DATA = ( | 46 | DATA = ( |
49 | ('#!/usr/bin/env foo', 'foo'), | 47 | ("#!/usr/bin/env foo", "foo"), |
50 | ('#!/bin/env foo', 'foo'), | 48 | ("#!/bin/env foo", "foo"), |
51 | ('#! /bin/env /bin/foo ', '/bin/foo'), | 49 | ("#! /bin/env /bin/foo ", "/bin/foo"), |
52 | ) | 50 | ) |
53 | for shebang, interp in DATA: | 51 | for shebang, interp in DATA: |
54 | self.assertEqual(hooks.RepoHook._ExtractInterpFromShebang(shebang), | 52 | self.assertEqual( |
55 | interp) | 53 | hooks.RepoHook._ExtractInterpFromShebang(shebang), interp |
54 | ) | ||