-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
1357 convert unittest to pytest #3931
1357 convert unittest to pytest #3931
Conversation
…ggurjar333/pudl into 1357-convert-unittest-to-pytest
For more information, see https://pre-commit.ci
…ggurjar333/pudl into 1357-convert-unittest-to-pytest
For more information, see https://pre-commit.ci
For more information, see https://pre-commit.ci
…ggurjar333/pudl into 1357-convert-unittest-to-pytest
@ggurjar333 I think you'll want to install the git pre-commit hooks locally so that all the static code analysis and formatting checks can be run before anything gets pushed. Some pointers in our docs here |
@zaneselvans I have installed pre-commit I think it is messing around here somewhere. |
It looks like there are a bunch of genuine test failures on your branch, so I think we should try and separate the errors that are due to changes from the errors that are due to environment / setup issues.
|
Explanation of the issue for the record here: Solution: |
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.
Overall this looks much nicer when we're consistently using pytest
- thank you! I do think that there are some spots where we're using the legacy setup / teardown behavior - while we're here converting everything to the new style, I think we should finish the job and convert those into pytest fixtures.
…ggurjar333/pudl into 1357-convert-unittest-to-pytest
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.
Mostly looks good, I think we should revert back to the xunit-style setup for the FERC Form 1 forest test. Everything else is non-blocking. Thanks for working on this!
@@ -37,7 +36,104 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
|
|||
class TestForestSetup(unittest.TestCase): | |||
@pytest.fixture | |||
def forest_setup(): |
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.
Pulling out just the nodes as a fixture doesn't help much, as you see you still have to unpack and add edges etc. The actual setup that has to get done for each test is "make a forest, with nodes, edges, and tags" - and each test has a slight variation on what those are. To me that means we actually want a helper function in this module that makes creating these forests a little less verbose, rather than a few fixtures.
But that involves a fair amount of restructuring of the tests, etc., and this PR has already gone on for a long time. I would just return to the xunit-style setup using the setup_method
flow you use below.
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.
@ggurjar333 I think this is the main thing I'd like to see before we merge the PR:
- undoing the structural change where you pull the nodes into a fixture
- converting the
TestPrunedNode.setUp
function into pytest using the classic xunit-style setup guide
You had mentioned wanting to spend more time learning about nx.DiGraph
s - once you feel more comfortable with those you can open up another PR that just refactors ferc1_test.py
to have a clearer/more flexible way of setting up graphs for testing.
…l_test.py by removing commented-out code
I went ahead and made the small change I requested in #4014 . Thanks for doing all this work @ggurjar333 ! |
Overview
Closes #1357.
What problem does this address?
Replacing Unittest with Pytest to standardizing the testing code.
What did you change?
I have changed Unittest based code with Pytest
Documentation
Make sure to update relevant aspects of the documentation.
Tasks
Testing
How did you make sure this worked? How can a reviewer verify this?
To-do list