-
Notifications
You must be signed in to change notification settings - Fork 21
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nameof error when running program, but not when running in debug #79
Comments
Could you share your piece of functioning code and your running environment (i.e. python version, whether code is running in a python file, REPL or jupyter)? |
The code running is unfortunately too big to share, but I can give information about its environnement: Note that I also invalidated the cache (I'm using pycharm) and it did not fix the problem. |
Is there any chance that this is related to #75 ? |
It is the same error, but the behavior I have is a bit more erratic. I've just come back from lunch, restarted the terminal and the error seems to be gone for the moment. I know Pycharm can have some performance issues at times, so maybe this is what I'm witnessing. |
I myself am not a PyCharm user, but I do see people reporting in some cases the code is executed with However, your case is a little wired as the error is not raised consistently. Let's see if we could gather more info. |
One thing I changed was to remove the |
What matters is how it's executed, rather than where it's executed. |
I guess a sketch of your code will give more help. |
def meta_tag_replacement(mocked_ileddarspapi: MagicMock) -> MagicMock:
mocked_ileddarspapi_name = nameof(mocked_ileddarspapi)
method_to_mock = {
'buildMetadataTag':
{
'buildAttributes': [100],
'buildNumber': 100,
'commitId': 100
}
}
method_list = []
[method_list.append(method) for method in dir(mocked_ileddarspapi.VersionGet_PWrap()[1]) if
method not in dir(object) if not method.startswith('__') if method not in dir(MagicMock)]
mocked_ileddarspapi.VersionGet_PWrap.return_value = (OUTPUT_STATUS, MagicMock(mocked_ileddarspapi.VersionGet_PWrap()[1]))
for method in method_list:
if method not in dir(object) and not method.startswith('__') and method not in dir(MagicMock) and method in method_to_mock.keys():
for method_to_change in method_to_mock[method].keys():
eval(mocked_ileddarspapi_name + '.' + nameof(mocked_ileddarspapi.VersionGet_PWrap) + '.' + method + '.' + method_to_change).return_value = method_to_mock[method][method_to_change]
return mocked_ileddarspapi |
I've left a single |
# your code
# ...
mocked_ileddarspapi_versionget_pwrap = nameof(mocked_ileddarspapi.VersionGet_PWrap)
for ...
if ....
for ...
eval(mocked_ileddarspapi_name + '.' + mocked_ileddarspapi_versionget_pwrap + '.' + method + '.' + method_to_change).return_value = method_to_mock[method][method_to_change]
|
I tried putting the (I'll try argname! Thanks for the tip) --> still the error remains |
For the pytest issue, see if this helps: |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi there, I've been developing a code for a couple of days and it worked seemingly well. However, today, I started seeing this error:
when running the program. However, when I break just above the problematic line and go step by step, the problem does not occur. I've also checked an no instances of pytest of any kind is running.
The text was updated successfully, but these errors were encountered: