Skip to content

Wrong method chosen if argument is passed as keyword argument #1235

@danabr

Description

@danabr

Environment

  • Pythonnet version: 2.5.0
  • Python version: 3.7
  • Operating System: Windows 10

Details

namespace Python.Test {
    public class MethodArityTest
    {
        public string Foo(int a) { return "Arity 1"; }
        public string Foo(int a, int b) { return "Arity 2"; }
    }
}
def test_keyword_arg_method_resolution():
    """Test correct method is chosen using keyword arguments"""
    from Python.Test import MethodArityTest

    ob = MethodArityTest()
    assert ob.Foo(1, b=2) == "Arity 2" 

The test above fails with:

    def test_keyword_arg_method_resolution():
        """Test correct method is chosen using keyword arguments"""
        from Python.Test import MethodArityTest

        ob = MethodArityTest()
>       assert ob.Foo(1, b=2) == "Arity 2"
E       AssertionError: assert 'Arity 1' == 'Arity 2'
E         - Arity 1
E         ?       ^
E         + Arity 2
E         ?       ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy