Flutter Engine
The Flutter Engine
Classes | Functions
test_utils Namespace Reference

Classes

class  FileWriter
 

Functions

def compare_trees (test, a, b)
 

Function Documentation

◆ compare_trees()

def test_utils.compare_trees (   test,
  a,
  b 
)
Compare two directory trees, assert if any differences.

Definition at line 46 of file test_utils.py.

46def compare_trees(test, a, b):
47 """Compare two directory trees, assert if any differences."""
48 def _cmp(prefix, dcmp):
49 # Verify that the file and directory names are the same.
50 test.assertEqual(len(dcmp.left_only), 0)
51 test.assertEqual(len(dcmp.right_only), 0)
52 test.assertEqual(len(dcmp.diff_files), 0)
53 test.assertEqual(len(dcmp.funny_files), 0)
54
55 # Verify that the files are identical.
56 for f in dcmp.common_files:
57 pathA = os.path.join(a, prefix, f)
58 pathB = os.path.join(b, prefix, f)
59 test.assertTrue(filecmp.cmp(pathA, pathB, shallow=False))
60 statA = os.stat(pathA)
61 statB = os.stat(pathB)
62 test.assertEqual(statA.st_mode, statB.st_mode)
63 with open(pathA, 'rb') as f:
64 contentsA = f.read()
65 with open(pathB, 'rb') as f:
66 contentsB = f.read()
67 test.assertEqual(contentsA, contentsB)
68
69 # Recurse on subdirectories.
70 for prefix, obj in dcmp.subdirs.items():
71 _cmp(prefix, obj)
72
73 _cmp('', filecmp.dircmp(a, b))
def compare_trees(test, a, b)
Definition: test_utils.py:46