Add test infrastructure for testing paths with directories.
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 07 Oct 2009 18:34:49 -0400 |
parents |
06d5f75cfb55
|
children |
08528309f7cd
|
branches/tags |
(none) |
files |
review/tests/sample_data.py review/tests/util.py |
Changes
--- 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
--- 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():