示例#1
0
 def test_symbol_table(self):
   symbol_table = {'nancy': Bob}
   document = dedent("""
   bill = nancy(
     hobbies=[1, 2, 3]
   )
   """)
   results = parsers.parse_python_assignments(document, symbol_table=symbol_table)
   self.assertEqual([Bob(name='bill', hobbies=[1, 2, 3])], results)
   self.assertEqual('nancy', results[0]._asdict()['typename'])
示例#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 = parsers.parse_python_assignments(document)
    self.assertEqual([Bob(name='nancy', hobbies=[1, 2, 3])], results)

    # No symbol table was used so no `typename` plumbing can be expected.
    self.assertNotIn('typename', results[0]._asdict())