Message ID | 20210625182021.803227-2-jsnow@redhat.com |
---|---|
State | New |
Headers | show |
Series | python/iotests: Run iotest linters during Python CI | expand |
25.06.2021 21:20, John Snow wrote: > 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> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 433b732336..493dda17fb 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) as f: + with open(filepath) as f: try: first_line = f.readline() return re.match('^#!.*python', first_line) is not None
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(-)