Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
test_utils Namespace Reference

Classes

class  FileWriter
 

Functions

 compare_trees (test, a, b)
 

Detailed Description

Test utilities.

Function Documentation

◆ compare_trees()

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))