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_repo_trace.py | 68 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'tests/test_repo_trace.py') diff --git a/tests/test_repo_trace.py b/tests/test_repo_trace.py index 5faf2938..e4aeb5de 100644 --- a/tests/test_repo_trace.py +++ b/tests/test_repo_trace.py @@ -22,35 +22,39 @@ import repo_trace class TraceTests(unittest.TestCase): - """Check Trace behavior.""" - - def testTrace_MaxSizeEnforced(self): - content = 'git chicken' - - with repo_trace.Trace(content, first_trace=True): - pass - first_trace_size = os.path.getsize(repo_trace._TRACE_FILE) - - with repo_trace.Trace(content): - pass - self.assertGreater( - os.path.getsize(repo_trace._TRACE_FILE), first_trace_size) - - # Check we clear everything is the last chunk is larger than _MAX_SIZE. - with mock.patch('repo_trace._MAX_SIZE', 0): - with repo_trace.Trace(content, first_trace=True): - pass - self.assertEqual(first_trace_size, - os.path.getsize(repo_trace._TRACE_FILE)) - - # Check we only clear the chunks we need to. - repo_trace._MAX_SIZE = (first_trace_size + 1) / (1024 * 1024) - with repo_trace.Trace(content, first_trace=True): - pass - self.assertEqual(first_trace_size * 2, - os.path.getsize(repo_trace._TRACE_FILE)) - - with repo_trace.Trace(content, first_trace=True): - pass - self.assertEqual(first_trace_size * 2, - os.path.getsize(repo_trace._TRACE_FILE)) + """Check Trace behavior.""" + + def testTrace_MaxSizeEnforced(self): + content = "git chicken" + + with repo_trace.Trace(content, first_trace=True): + pass + first_trace_size = os.path.getsize(repo_trace._TRACE_FILE) + + with repo_trace.Trace(content): + pass + self.assertGreater( + os.path.getsize(repo_trace._TRACE_FILE), first_trace_size + ) + + # Check we clear everything is the last chunk is larger than _MAX_SIZE. + with mock.patch("repo_trace._MAX_SIZE", 0): + with repo_trace.Trace(content, first_trace=True): + pass + self.assertEqual( + first_trace_size, os.path.getsize(repo_trace._TRACE_FILE) + ) + + # Check we only clear the chunks we need to. + repo_trace._MAX_SIZE = (first_trace_size + 1) / (1024 * 1024) + with repo_trace.Trace(content, first_trace=True): + pass + self.assertEqual( + first_trace_size * 2, os.path.getsize(repo_trace._TRACE_FILE) + ) + + with repo_trace.Trace(content, first_trace=True): + pass + self.assertEqual( + first_trace_size * 2, os.path.getsize(repo_trace._TRACE_FILE) + ) -- cgit v1.2.3-54-g00ecf