Esempio n. 1
0
 def test_symbol_table(self):
   symbol_table = {'nancy': Bob}
   document = dedent("""
   bill = nancy(
     hobbies=[1, 2, 3]
   )
   """)
   results = parse(parsers.python_assignments_parser(symbol_table), document)
   self.assertEqual([Bob(name='bill', hobbies=[1, 2, 3])], results)
   self.assertEqual('nancy', results[0]._asdict()['type_alias'])
Esempio n. 2
0
  def test_no_symbol_table(self):
    document = dedent("""
    from pants_test.engine.exp.test_parsers import Bob

    nancy = Bob(
      hobbies=[1, 2, 3]
    )
    """)
    results = parse(parsers.python_assignments_parser(), document)
    self.assertEqual([Bob(name='nancy', hobbies=[1, 2, 3])], results)

    # No symbol table was used so no `type_alias` plumbing can be expected.
    self.assertNotIn('type_alias', results[0]._asdict())
Esempio n. 3
0
 def test_python(self):
     graph = self.create_graph(
         build_pattern=r'.+\.BUILD.python$',
         parser=python_assignments_parser(symbol_table=self.symbol_table))
     self.do_test_codegen_simple(graph)
Esempio n. 4
0
 def test_python(self):
   graph = self.create_graph(build_pattern=r'.+\.BUILD.python$',
                             parser=python_assignments_parser(symbol_table=self.symbol_table))
   self.do_test_codegen_simple(graph)