Closed destrex271 closed 8 months ago
But would it do anything beyond what os.path.isfile(path)
does? To simply wrap a one line function in another function is not that helpful.
I was thinking more on the lines of using wildcards and eliminating the need for using os directly in the tests. It will be a small function that would take a list of filenames(also wildcard entries) and just return a true or false status. Might help in getting rid of a few extra lines of code just to check if certain files are present or not.
wildcard matching can be done simply with
if not glob.glob(<pattern>)
or indeed using fnmatch
or the new pathlib.Path(<directory>).glob(<pattern>)
Oh Ok! This makes much more sense. Thanks!
I was in the process of writing some tests for a job. I noticed that we have a function called
file_contains
to check if a file contains certain content. It might be helpful to have another function that checks if some specific files exist.For example, let's say I have a job that generates files with similar names (like abc_12.txt, abc_13.txt, etc.). One step of a unit test could be to verify if these output files were generated by my job. Such a function would be a nice utility to have.
I will also like to work on this issue.