Skip to content

Commit e40fc2c

Browse files
committed
Use TemporaryFile as a context manager
(This also uses assertRaises as a context manager, but that is just for improved clarity.)
1 parent afa5754 commit e40fc2c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Diff for: test/test_git.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,9 @@ def test_it_ignores_false_kwargs(self, git):
260260
self.assertTrue("pass_this_kwarg" not in git.call_args[1])
261261

262262
def test_it_raises_proper_exception_with_output_stream(self):
263-
tmp_file = TemporaryFile()
264-
self.assertRaises(
265-
GitCommandError,
266-
self.git.checkout,
267-
"non-existent-branch",
268-
output_stream=tmp_file,
269-
)
263+
with TemporaryFile() as tmp_file:
264+
with self.assertRaises(GitCommandError):
265+
self.git.checkout("non-existent-branch", output_stream=tmp_file)
270266

271267
def test_it_accepts_environment_variables(self):
272268
filename = fixture_path("ls_tree_empty")

0 commit comments

Comments
 (0)