Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH TEST] Improve compare_folders error message #918

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

NicolasGensollen
Copy link
Member

This PR proposes to improve the error message of the testing utility function compare_folders.

The function currently returns True if the two folders have the same file trees and raises a ValueError otherwise. The error message contains both trees.

It is easy to spot differences when the folders are not too large/deep, but quickly becomes difficult when they increase in size.

For instance, I'm having troubles seing the differences when non-regression tests for converters fail as the folders are quite large for these pipelines.

This PR adds a section at the end of the error message: it gives the number of lines which differ between the two trees and it prints the differences explicitly.

Here is a small example:

>>> compare_folders(out_folder, ref_folder, tmp_path)
E           ValueError: Comparison of out and ref directories shows mismatch :
E            The content of the OUT directory :
E               + subfolder1
E                   + file1.txt
E               + subfolder2
E                   + file2.xt
E               + subfolder3
E                   + file3.xt
E
E            The content of the REF directory :
E               + subfolder1
E                   + file1.txt
E               + subfolder3
E                   + file4.xt
E               + subfolder4
E                   + file2.xt
E
E            There are 4 lines with a mismatch :
E           		- subfolder2 != subfolder3
E           		- file2.xt != file4.xt
E           		- subfolder3 != subfolder4
E           		- file3.xt != file2.xt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant