summaryrefslogtreecommitdiffstats
path: root/tests/test_repo_trace.py
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2023-03-11 06:46:20 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-22 17:46:28 +0000
commitea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 (patch)
treedc33ba0e56825b3e007d0589891756724725a465 /tests/test_repo_trace.py
parent1604cf255f8c1786a23388db6d5277ac7949a24a (diff)
downloadgit-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_repo_trace.py')
-rw-r--r--tests/test_repo_trace.py68
1 files changed, 36 insertions, 32 deletions
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
22 22
23 23
24class TraceTests(unittest.TestCase): 24class TraceTests(unittest.TestCase):
25 """Check Trace behavior.""" 25 """Check Trace behavior."""
26 26
27 def testTrace_MaxSizeEnforced(self): 27 def testTrace_MaxSizeEnforced(self):
28 content = 'git chicken' 28 content = "git chicken"
29 29
30 with repo_trace.Trace(content, first_trace=True): 30 with repo_trace.Trace(content, first_trace=True):
31 pass 31 pass
32 first_trace_size = os.path.getsize(repo_trace._TRACE_FILE) 32 first_trace_size = os.path.getsize(repo_trace._TRACE_FILE)
33 33
34 with repo_trace.Trace(content): 34 with repo_trace.Trace(content):
35 pass 35 pass
36 self.assertGreater( 36 self.assertGreater(
37 os.path.getsize(repo_trace._TRACE_FILE), first_trace_size) 37 os.path.getsize(repo_trace._TRACE_FILE), first_trace_size
38 38 )
39 # Check we clear everything is the last chunk is larger than _MAX_SIZE. 39
40 with mock.patch('repo_trace._MAX_SIZE', 0): 40 # Check we clear everything is the last chunk is larger than _MAX_SIZE.
41 with repo_trace.Trace(content, first_trace=True): 41 with mock.patch("repo_trace._MAX_SIZE", 0):
42 pass 42 with repo_trace.Trace(content, first_trace=True):
43 self.assertEqual(first_trace_size, 43 pass
44 os.path.getsize(repo_trace._TRACE_FILE)) 44 self.assertEqual(
45 45 first_trace_size, os.path.getsize(repo_trace._TRACE_FILE)
46 # Check we only clear the chunks we need to. 46 )
47 repo_trace._MAX_SIZE = (first_trace_size + 1) / (1024 * 1024) 47
48 with repo_trace.Trace(content, first_trace=True): 48 # Check we only clear the chunks we need to.
49 pass 49 repo_trace._MAX_SIZE = (first_trace_size + 1) / (1024 * 1024)
50 self.assertEqual(first_trace_size * 2, 50 with repo_trace.Trace(content, first_trace=True):
51 os.path.getsize(repo_trace._TRACE_FILE)) 51 pass
52 52 self.assertEqual(
53 with repo_trace.Trace(content, first_trace=True): 53 first_trace_size * 2, os.path.getsize(repo_trace._TRACE_FILE)
54 pass 54 )
55 self.assertEqual(first_trace_size * 2, 55
56 os.path.getsize(repo_trace._TRACE_FILE)) 56 with repo_trace.Trace(content, first_trace=True):
57 pass
58 self.assertEqual(
59 first_trace_size * 2, os.path.getsize(repo_trace._TRACE_FILE)
60 )