-
Notifications
You must be signed in to change notification settings - Fork 10
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
Execute output code in integration tests #68
Conversation
80b86e6
to
15401fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome. Eventually we can have more sophisticated behavioral assertions if we want, but this is exactly what we need right now.
module = importlib.util.module_from_spec(spec) | ||
try: | ||
spec.loader.exec_module(module) | ||
except allowed_exceptions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool.
@clavedeluna it looks like there's maybe some kind of version/compatibility issue with |
Codecov Report
@@ Coverage Diff @@
## main #68 +/- ##
=======================================
Coverage 95.86% 95.86%
=======================================
Files 46 46
Lines 1694 1694
=======================================
Hits 1624 1624
Misses 70 70 |
f7f735c
to
f380fd6
Compare
Overview
This PR implements a simple API to run during testing that will execute a codemod's output code
Description
We want to have more confidence that the code changes we make actually do work. Executing the code during integration tests will ensure not only imports work but also functions run. Some of the ramifications of that are:
open(...)...
call which we expect if we try to open a file that doesn't exist, but not catch it in other codemods in case that is a legitimate error.execute_code
in unit tests so I left its API flexible for either path or code str.