From 261be201093246ccccfc567de5facf1ad9e8a528 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 4 Mar 2024 17:09:11 +0100 Subject: [PATCH] convert tests/testcommon.py to black code format --- pyproject.toml | 1 - tests/testcommon.py | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e00ea8ba..a4b7ddbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,6 @@ force-exclude = '''( | tests/extra/manual-vmtools-test\.py | tests/gradle-release-checksums\.py | tests/openssl-version-check-test\.py - | tests/testcommon\.py | tests/valid-package-names/test\.py | tests/checkupdates\.TestCase | tests/common\.TestCase diff --git a/tests/testcommon.py b/tests/testcommon.py index 61c1a904..fe3728ba 100644 --- a/tests/testcommon.py +++ b/tests/testcommon.py @@ -20,10 +20,8 @@ import sys import tempfile -class TmpCwd(): - """Context-manager for temporarily changing the current working - directory. - """ +class TmpCwd: + """Context-manager for temporarily changing the current working directory.""" def __init__(self, new_cwd): self.new_cwd = new_cwd @@ -36,9 +34,8 @@ class TmpCwd(): os.chdir(self.orig_cwd) -class TmpPyPath(): - """Context-manager for temporarily adding a direcory to python path - """ +class TmpPyPath: + """Context-manager for temporarily adding a directory to Python path.""" def __init__(self, additional_path): self.additional_path = additional_path @@ -51,14 +48,11 @@ class TmpPyPath(): def mock_open_to_str(mock): - """ - helper function for accessing all data written into a - unittest.mock.mock_open() instance as a string. - """ + """For accessing all data written into a unittest.mock.mock_open() instance as a string.""" - return "".join([ - x.args[0] for x in mock.mock_calls if str(x).startswith("call().write(") - ]) + return "".join( + [x.args[0] for x in mock.mock_calls if str(x).startswith("call().write(")] + ) def mkdtemp():