Exemple #1
0
    def test_invalid_default(self):
        def invalid_directive(valid_arg, invalid_default=object()):
            del valid_arg
            del invalid_default
            return

        def call_invalid_directive():
            invalid_directive(1)

        node, _, _ = parser.parse_entity(call_invalid_directive)
        # Find the call to the invalid directive
        node = node.body[0].value
        with self.assertRaisesRegexp(ValueError, 'Unexpected keyword.*'):
            directives_converter._map_args(node, invalid_directive)
  def test_invalid_default(self):

    def invalid_directive(valid_arg, invalid_default=object()):
      del valid_arg
      del invalid_default
      return

    def call_invalid_directive():
      invalid_directive(1)

    node, _ = parser.parse_entity(call_invalid_directive, ())
    # Find the call to the invalid directive
    node = node.body[0].value
    with self.assertRaisesRegexp(ValueError, 'Unexpected keyword.*'):
      directives_converter._map_args(node, invalid_directive)