Skip to content

GH-103804: Add test for dis.disco #103901

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

Merged
merged 6 commits into from
Apr 28, 2023
Merged

Conversation

jkchandalia
Copy link
Contributor

@jkchandalia jkchandalia commented Apr 26, 2023

PR to test dis.disco

Fixes #103804

@jkchandalia
Copy link
Contributor Author

FYI @nanjekyejoannah @iritkatriel

@gaogaotiantian
Copy link
Member

dis.disco is an alias of dis.disassemble for backward compatibility. Your test basically testing that those two functions will generate the same result. You might as well test self.assertIs(dis.disco, dis.disassemble) to make sure they are the same function - this is a stronger test than testing their behavior and at this point I believe that's the expected behavior(being an alias instead of having the same functionality)

@iritkatriel
Copy link
Member

If we decide to deprecate disco then we will turn it into a function that issues a deprecation warning and calls disassemble. Then the test that they are the same function would no longer be correct.

@gaogaotiantian
Copy link
Member

If we decide to deprecate disco then we will turn it into a function that issues a deprecation warning and calls disassemble. Then the test that they are the same function would no longer be correct.

Hmm, that makes sense as dis.disco will output warning on stderr.

with contextlib.redirect_stdout(disco_output):
dis.disco(func.__code__)
self.assertEqual(disassemble_output, disco_output.getvalue())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, instead of adding this test, add a check in do_disassembly_test that disco gives the expected output as well. That would cover more cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iritkatriel I've updated the PR to reflect your suggestion. Please let me know if you have any other suggestions.

@iritkatriel iritkatriel merged commit 81387fe into python:main Apr 28, 2023
@jkchandalia jkchandalia deleted the test_disco branch April 29, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing tests to the dis module
4 participants