Index: grit/format/html_inline_unittest.py |
diff --git a/grit/format/html_inline_unittest.py b/grit/format/html_inline_unittest.py |
index 7d546a5eab0c4ae0f56bbeeecac66cbaeda417d3..c869a422b71e930518bbc3b538b7fe866297cb8c 100755 |
--- a/grit/format/html_inline_unittest.py |
+++ b/grit/format/html_inline_unittest.py |
@@ -202,6 +202,49 @@ class HtmlInlineUnittest(unittest.TestCase): |
self.failUnlessEqual(expected_inlined, |
util.FixLineEnd(result.inlined_data, '\n')) |
+ def testFilenameVariableExpansion(self): |
+ '''Tests that variables are expanded in filenames before inlining.''' |
+ |
+ files = { |
+ 'index.html': ''' |
+ <html> |
+ <head> |
+ <link rel="stylesheet" href="style[WHICH].css"> |
+ </head> |
+ <include src="tmpl[WHICH].html"> |
+ </html> |
+ ''', |
+ 'style1.css': '''h1 {}''', |
+ 'tmpl1.html': '''<h1></h1>''', |
+ } |
+ |
+ expected_inlined = ''' |
+ <html> |
+ <head> |
+ <style>h1 {}</style> |
+ </head> |
+ <h1></h1> |
+ </html> |
+ ''' |
+ |
+ source_resources = set() |
+ tmp_dir = util.TempDir(files) |
+ for filename in files: |
+ source_resources.add(tmp_dir.GetPath(filename)) |
+ |
+ def replacer(var, repl): |
+ return lambda filename: filename.replace('[%s]' % var, repl) |
+ |
+ result = html_inline.DoInline( |
+ tmp_dir.GetPath('index.html'), |
+ None, |
+ filename_expansion_function=replacer('WHICH', '1')) |
+ resources = result.inlined_files |
+ resources.add(tmp_dir.GetPath('index.html')) |
+ self.failUnlessEqual(resources, source_resources) |
flackr
2013/06/06 14:07:19
It might be worth adding a test which calls DoInli
dconnelly
2013/06/07 09:10:38
Done.
|
+ self.failUnlessEqual(expected_inlined, |
+ util.FixLineEnd(result.inlined_data, '\n')) |
+ |
if __name__ == '__main__': |
unittest.main() |