diff options
author | Gavin Mak <gavinmak@google.com> | 2023-03-11 06:46:20 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-22 17:46:28 +0000 |
commit | ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 (patch) | |
tree | dc33ba0e56825b3e007d0589891756724725a465 /tests/test_hooks.py | |
parent | 1604cf255f8c1786a23388db6d5277ac7949a24a (diff) | |
download | git-repo-ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1.tar.gz |
Format codebase with black and check formatting in CQ
Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught
by flake8. Also check black formatting in run_tests (and CQ).
Bug: b/267675342
Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
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 | ) | ||