Archived

This forum has been archived. Please start a new discussion on GitHub.

ValueError: invalid value for argument

Hi!

Recently I have decided to start writing tests in Python instead of C++, though my services are written in C++.

To cut it short: I do always get the "ValueError: invalid value for argument 1 in operation `AddUser'" exception when trying to run my test.

The faulting ( slice definition ) function is:
int AddUser(User objUser, out long lUserId) ;

The faulting python code is:
nError, lPlayerUserId = secrt.AddUser(objUser)

I am suspecting myself in not clearly understanding how out parameters should be handled by python code.

Please, could you look into the files attached and provide a hint on what I do wrong.

----
With best regards,
Dmitry

Comments

  • mes
    mes California
    Hi Dmitry,

    This line is the problem:
    objUser = Secrt.User
    

    This does not allocate an instance of Secrt.User, but actually assigns a reference to the Secrt.User class. Here is how you should be allocating the instance:
    objUser = Secrt.User()
    

    Regards,
    Mark
  • mes wrote: »
    Hi Dmitry,

    This line is the problem:
    objUser = Secrt.User
    

    This does not allocate an instance of Secrt.User, but actually assigns a reference to the Secrt.User class. Here is how you should be allocating the instance:
    objUser = Secrt.User()
    

    Regards,
    Mark

    Yes, sir! That was the problem. Dumb me :(