-
Notifications
You must be signed in to change notification settings - Fork 135
Supply status for missing exit codes #432
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
Supply status for missing exit codes #432
Conversation
Following on from the work in "Handle -9 PyTest return code", discussion with @Otto-AA and @boxed revealed it would be desirable to handle missing return codes in full generality. The simplest way I could think of to _do_ that, trying to eliminate side effects, is to convert status_by_exit_code to a defaultdict, with a default value of "suspicious" - one already defined, and handled, elsewhere in the codebase.
|
Simple, but should work fine. You could test it by removing some other exit codes from the dict (eg the codes for killed) and then checking if it outputs suspicious instead of killed with the mutmut browse command. |
|
You likely also have to make |
|
I think this line should use a direct dict lookup instead of the .get method (or simply Line 1127 in 229db0f
I think with the .get() it won't use the defaultdict |
If the defaultdict value for |
Yes, it does - removing the exit code status for -9 results in that particular mutant being logged as "suspicious" instead of "segfault". |
According to https://docs.python.org/3/library/collections.html#collections.defaultdict , your reading of get() behaviour is correct. Sod it, after writing that, I'll make the change you suggested. |
Further feedback from @Otto-AA pointed out the irrelevance of the status_by_exit_code get call, now that it is a defaultdict. Thus, the lookup is changed to the direct defaultdict lookup.
|
We have following definition: exit_code_to_emoji = {
exit_code: emoji_by_status[status]
for exit_code, status in status_by_exit_code.items()
}This uses all items in Thus, I would suggest to make it a defaultdict. Though it's interesting that your testing succeeds even though this is not currently implemented yet. |
|
Using .get is an alternative to a defaultdict. It won't raise and can be supplied a default value. The advantages of a normal dict are that it's nicer to write dict literals, and that "new" keys don't take up space as they do if you use a defaultdict. In this case that doesn't matter much. |
|
None. Go ahead. |
Following on from the work in "Handle -9 PyTest return code", discussion with @Otto-AA and @boxed revealed it would be desirable to handle missing return codes in full generality.
The simplest way I could think of to do that, trying to eliminate side effects, is to convert status_by_exit_code to a defaultdict, with a default value of "suspicious" - one already defined, and handled, elsewhere in the codebase.