From ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Sat, 11 Mar 2023 06:46:20 +0000 Subject: 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 Tested-by: Gavin Mak Commit-Queue: Gavin Mak --- tests/test_hooks.py | 63 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'tests/test_hooks.py') 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 @@ import hooks import unittest + class RepoHookShebang(unittest.TestCase): - """Check shebang parsing in RepoHook.""" + """Check shebang parsing in RepoHook.""" - def test_no_shebang(self): - """Lines w/out shebangs should be rejected.""" - DATA = ( - '', - '#\n# foo\n', - '# Bad shebang in script\n#!/foo\n' - ) - for data in DATA: - self.assertIsNone(hooks.RepoHook._ExtractInterpFromShebang(data)) + def test_no_shebang(self): + """Lines w/out shebangs should be rejected.""" + DATA = ("", "#\n# foo\n", "# Bad shebang in script\n#!/foo\n") + for data in DATA: + self.assertIsNone(hooks.RepoHook._ExtractInterpFromShebang(data)) - def test_direct_interp(self): - """Lines whose shebang points directly to the interpreter.""" - DATA = ( - ('#!/foo', '/foo'), - ('#! /foo', '/foo'), - ('#!/bin/foo ', '/bin/foo'), - ('#! /usr/foo ', '/usr/foo'), - ('#! /usr/foo -args', '/usr/foo'), - ) - for shebang, interp in DATA: - self.assertEqual(hooks.RepoHook._ExtractInterpFromShebang(shebang), - interp) + def test_direct_interp(self): + """Lines whose shebang points directly to the interpreter.""" + DATA = ( + ("#!/foo", "/foo"), + ("#! /foo", "/foo"), + ("#!/bin/foo ", "/bin/foo"), + ("#! /usr/foo ", "/usr/foo"), + ("#! /usr/foo -args", "/usr/foo"), + ) + for shebang, interp in DATA: + self.assertEqual( + hooks.RepoHook._ExtractInterpFromShebang(shebang), interp + ) - def test_env_interp(self): - """Lines whose shebang launches through `env`.""" - DATA = ( - ('#!/usr/bin/env foo', 'foo'), - ('#!/bin/env foo', 'foo'), - ('#! /bin/env /bin/foo ', '/bin/foo'), - ) - for shebang, interp in DATA: - self.assertEqual(hooks.RepoHook._ExtractInterpFromShebang(shebang), - interp) + def test_env_interp(self): + """Lines whose shebang launches through `env`.""" + DATA = ( + ("#!/usr/bin/env foo", "foo"), + ("#!/bin/env foo", "foo"), + ("#! /bin/env /bin/foo ", "/bin/foo"), + ) + for shebang, interp in DATA: + self.assertEqual( + hooks.RepoHook._ExtractInterpFromShebang(shebang), interp + ) -- cgit v1.2.3-54-g00ecf