[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/16] iotests/297: modify is_python_file to work from any CWD
From: |
John Snow |
Subject: |
[PATCH v3 05/16] iotests/297: modify is_python_file to work from any CWD |
Date: |
Thu, 16 Sep 2021 00:09:44 -0400 |
Add a directory argument to is_python_file to allow it to work correctly
no matter what CWD we happen to run it from. This is done in
anticipation of running the iotests from another directory (./python/).
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/qemu-iotests/297 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
index b04cba5366..3e86f788fc 100755
--- a/tests/qemu-iotests/297
+++ b/tests/qemu-iotests/297
@@ -39,14 +39,16 @@ SKIP_FILES = (
)
-def is_python_file(filename):
- if not os.path.isfile(filename):
+def is_python_file(filename: str, directory: str = '.') -> bool:
+ filepath = os.path.join(directory, filename)
+
+ if not os.path.isfile(filepath):
return False
if filename.endswith('.py'):
return True
- with open(filename, encoding='utf-8') as f:
+ with open(filepath, encoding='utf-8') as f:
try:
first_line = f.readline()
return re.match('^#!.*python', first_line) is not None
--
2.31.1
- Re: [PATCH v3 02/16] iotests/mirror-top-perms: Adjust imports, (continued)
- [PATCH v3 01/16] python: Update for pylint 2.10, John Snow, 2021/09/16
- [PATCH v3 04/16] iotests/migrate-bitmaps-test: delint, John Snow, 2021/09/16
- [PATCH v3 03/16] iotests/migrate-bitmaps-postcopy-test: declare instance variables, John Snow, 2021/09/16
- [PATCH v3 05/16] iotests/297: modify is_python_file to work from any CWD,
John Snow <=
- [PATCH v3 06/16] iotests/297: Add get_files() function, John Snow, 2021/09/16
- [PATCH v3 07/16] iotests/297: Don't rely on distro-specific linter binaries, John Snow, 2021/09/16
- [PATCH v3 08/16] iotests/297: Create main() function, John Snow, 2021/09/16