# HG changeset patch # User Steve Losh # Date 1254954889 14400 # Node ID b3bae1d649d7474d8d82ed3de7bfa48fea45c67e # Parent 06d5f75cfb55f90912696c3e885c71649c122c58 Add test infrastructure for testing paths with directories. diff -r 06d5f75cfb55 -r b3bae1d649d7 review/tests/sample_data.py --- a/review/tests/sample_data.py Wed Oct 07 18:23:37 2009 -0400 +++ b/review/tests/sample_data.py Wed Oct 07 18:34:49 2009 -0400 @@ -4,5 +4,6 @@ }, { 'file_one': 'hello again\nworld\nfoo\nbar', 'file_three': 'this is a new file\nfor testing', + 'test_dir/test_file': 'this file is inside\nof a directory', }, ] \ No newline at end of file diff -r 06d5f75cfb55 -r b3bae1d649d7 review/tests/util.py --- a/review/tests/util.py Wed Oct 07 18:23:37 2009 -0400 +++ b/review/tests/util.py Wed Oct 07 18:34:49 2009 -0400 @@ -35,8 +35,20 @@ 'logfile': None, 'message': "Sandbox commit.", } for state in sample_data.log: for filename in state: + dirname, key = None, filename + + # Support one-level-deep directories in the sample data. + if '/' in filename: + dirname, _, filename = filename.partition('/') + if not os.path.exists(dirname): + os.mkdir(dirname) + os.chdir(dirname) + with open(filename, 'w') as f: - f.write(state[filename]) + f.write(state[key]) + + if dirname: + os.chdir('..') commands.commit(_ui, sandbox, **opts) def setup_reviewed_sandbox():