Files
edx-platform/common/lib/xmodule/xmodule/tests/helpers.py
Ned Batchelder 2a0259095d Change imports from path to use the stablest name.
The old line:

    from path import path

produced pylint errors because of the baroque way that path.py defined
"path".  We tried to get them to change how they defined it, but they
deleted the name instead: https://github.com/jaraco/path.py/issues/102

(Jason then changed his mind, but this is a better way to use path.py,
it avoids the pylint error at least.)
2015-08-27 12:59:25 -04:00

27 lines
781 B
Python

"""
Utility methods for unit tests.
"""
import filecmp
from path import Path as path
def directories_equal(directory1, directory2):
"""
Returns True if the 2 directories have equal content, else false.
"""
def compare_dirs(dir1, dir2):
""" Compare directories for equality. """
comparison = filecmp.dircmp(dir1, dir2)
if (len(comparison.left_only) > 0) or (len(comparison.right_only) > 0):
return False
if (len(comparison.funny_files) > 0) or (len(comparison.diff_files) > 0):
return False
for subdir in comparison.subdirs:
if not compare_dirs(dir1 / subdir, dir2 / subdir):
return False
return True
return compare_dirs(path(directory1), path(directory2))