Example #1
0
 def check_file(self, input_file, expected_file, thing):
     expected = open(expected_file, 'r').read()
     if thing == 'm4':
         # check m4 output
         m4_output = subprocess.check_output(['m4', input_file])
         self.assertEqual(m4_output, expected)
     elif thing == 'parser':
         stream = StringIO()
         Parser(open(input_file, 'r').read()).parse(stream=stream)
         self.assertEqual(stream.getvalue(), expected)
Example #2
0
 def test_macro_args_nested_parens(self):
     p = Parser('foo(abc(xyz)abc)')
     p.define('foo', 'bar')
     self.assertEqual(self.parse(p), 'bar')
Example #3
0
 def test_define_argparse(self):
     p = Parser('define( abc, xyz)abc')
     self.assertEqual(self.parse(p), 'xyz')
Example #4
0
 def test_changequote(self):
     p = Parser("`abc'[xyz]")
     p.changequote('[', ']')
     self.assertEqual(self.parse(p), "`abc'xyz")
Example #5
0
 def test_define_recursive(self):
     p = Parser('abc')
     p.define('abc', 'xyz')
     p.define('xyz', '123')
     self.assertEqual(self.parse(p), '123')
Example #6
0
 def test_define_simple_trailing(self):
     p = Parser('abc ')
     p.define('abc', 'xyz')
     self.assertEqual(self.parse(p), 'xyz ')
Example #7
0
 def test_define_empty(self):
     p = Parser('abc')
     p.define('abc')
     self.assertEqual(self.parse(p), '')
Example #8
0
 def test_empty_string(self):
     p = Parser("`'")
     self.assertEqual(self.parse(p), '')
Example #9
0
 def test_basic(self):
     p = Parser('abc')
     self.assertEqual(self.parse(p), 'abc')