OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 import os | |
7 import sys | |
8 if __name__ == '__main__': | |
Dan Beam
2016/07/14 17:47:58
why do you need to do this only if __name__ == '__
| |
9 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | |
Dan Beam
2016/07/14 17:47:58
can you just do this in the other if __name__ == '
| |
10 | |
11 import unittest | |
12 import tempfile | |
Dan Beam
2016/07/14 17:47:58
nit: alpha
| |
13 | |
14 from grit import flatten_resource_runner | |
15 | |
16 | |
17 class FlattenResourceRunnerUnitest(unittest.TestCase): | |
18 | |
19 def testIf(self): | |
20 '''Tests that a -D option is correctly handled''' | |
21 with tempfile.NamedTemporaryFile() as input_file,\ | |
22 tempfile.NamedTemporaryFile() as output_file: | |
Dan Beam
2016/07/14 17:47:58
where do these get deleted?
| |
23 input_file.write('Hello <if expr="T1==1"> good</if>' | |
24 '<if expr="T2==2"> bad</if> test') | |
25 input_file.seek(0) | |
Dan Beam
2016/07/14 17:47:58
what's this seek(0) for? can we just close() inst
| |
26 flatten_resource_runner.Main(['-DT1=1', | |
27 input_file.name, | |
28 output_file.name]) | |
29 self.failUnlessEqual('Hello good test', output_file.read()) | |
30 pass | |
31 | |
32 def testInclude(self): | |
33 '''Tests that an include is correctly handled''' | |
34 with tempfile.NamedTemporaryFile() as input_file,\ | |
35 tempfile.NamedTemporaryFile() as output_file,\ | |
36 tempfile.NamedTemporaryFile() as include_file: | |
37 input_file.write('<include src="' + include_file.name + '">') | |
38 input_file.seek(0) | |
39 include_file.write('Hello included') | |
40 include_file.seek(0) | |
41 flatten_resource_runner.Main([input_file.name, output_file.name]) | |
42 self.failUnlessEqual('Hello included', output_file.read()) | |
43 pass | |
44 | |
45 | |
46 if __name__ == '__main__': | |
47 unittest.main() | |
OLD | NEW |