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

@NicolasGensollen NicolasGensollen force-pushed the improve-compare-folders-error-message branch from d134709 to 0a66c59 Compare May 26, 2023 07:02
@github-actions github-actions bot added the Stale label Aug 25, 2023
@github-actions github-actions bot closed this Sep 8, 2023
@github-actions github-actions bot added the Stale label Dec 8, 2023
@github-actions github-actions bot closed this Dec 23, 2023
@github-actions github-actions bot removed the Stale label Dec 24, 2023
@github-actions github-actions bot added the Stale label Mar 24, 2024
@github-actions github-actions bot closed this Apr 8, 2024
@github-actions github-actions bot removed the Stale label Apr 9, 2024
@github-actions github-actions bot added the Stale label Jul 8, 2024
@github-actions github-actions bot closed this Jul 22, 2024
@github-actions github-actions bot removed the Stale label Jul 23, 2024
@github-actions github-actions bot added the Stale label Oct 21, 2024
@github-actions github-actions bot closed this Nov 4, 2024
@github-actions github-actions bot removed the Stale label Nov 5, 2024
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