Skip to content
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

Post process html to include teardown in log #271

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

csm10495
Copy link
Member

I believe this would resolve #131 ... however it isn't really optimal, I didn't want to dig into the html logic, so instead just moved it to be post processed and tried to coerce the test result into what the existing code seemed to want.

@csm10495
Copy link
Member Author

Wow. Those unit tests really helped me fix a lot of things i had broken :P.

Honestly don't know if this is good enough to merge... it seems kind of sketchy... but per the tests seems to work. :)

@BeyondEvil
Copy link
Contributor

Thanks for this! @csm10495

I need some time to fully understand the problem and the fix before I can review this with confidence.

Feel free to ping me if you haven't heard anything from me in a week or so.

@csm10495
Copy link
Member Author

csm10495 commented Feb 29, 2020

Sure thing @BeyondEvil . The big thing that I want to fix is to get the teardown event in the html log:

for example:

import pytest
pytest.fixture(scope='function')
def setupAndTeardown():
    print ("setup: i am already in the html")
    yield
    print ("teardown: i am missing from the html... but added by this change!")

def test_nothing():
    print ("test_case: of course i am already in the html")

In doing that, i try to hold back from processing the reports, until we get to the pytest_sessionfinish() then basically combine the setup/testcase/teardown reports to figure out the status, etc.

@csm10495
Copy link
Member Author

@BeyondEvil reminder to check this out. Thanks.

@csm10495
Copy link
Member Author

Reminder to check this out @BeyondEvil

@dasm
Copy link

dasm commented May 5, 2020

@csm10495 @BeyondEvil I'd like to help with that functionality. Do you need anything extra?

Interesting fact. I'm able to see captured stdout teardown in HTML if teardown failed.

@Formartha
Copy link

Hi folks, any update about this one? we're waiting for it as well :).
a W/A can be provided in case you have one till it will be merged..

@dina809
Copy link

dina809 commented Jun 29, 2020

Hi @csm10495 - i have tried your code and it works good while collecting logs from teardown of a fixture and showing them in the html report,
but it is causing an issue if the fixture setup is failing (before the yield), have you checked that?

@csm10495
Copy link
Member Author

Hey @dina809 , it's been a while now since I've looked deep at this. What error are you seeing? It works if I do this:

import pytest
@pytest.fixture(scope="function")
def setupAndTeardown():
    print ("this is setup")
    assert 0
    yield
    print ("this is teardown")
def test_setup_and_teardown(setupAndTeardown):
    print ("this is the test case")

HTML:
image

@avzero07
Copy link

avzero07 commented Jul 16, 2020

Bump. Did someone get a chance to review this?

@ssbarnea ssbarnea added the bug This issue/PR relates to a bug. label Aug 24, 2020
@1Mark
Copy link

1Mark commented Sep 12, 2020

Any release date for this?

@BeyondEvil
Copy link
Contributor

Any release date for this?

I'm hoping @ssbarnea or @gnikonorov can find some time to review this?

@gnikonorov
Copy link
Member

I can take a look at this tonight, @BeyondEvil

@gnikonorov gnikonorov self-requested a review September 16, 2020 21:15
Copy link
Member

@gnikonorov gnikonorov left a comment

Choose a reason for hiding this comment

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

Overall this looks good, thank you @csm10495 and sorry for the very long delay here! I just had a few questions.

I'll be staying on top of this PR. If you haven't heard from me in a day or so, @ mention me so I see the notification

pytest_html/plugin.py Show resolved Hide resolved
pytest_html/plugin.py Show resolved Hide resolved
pytest_html/plugin.py Show resolved Hide resolved
@csm10495
Copy link
Member Author

csm10495 commented Sep 17, 2020

@gnikonorov, I made some fixes and added a comment. Tests pass feel free to merge if its good.

Also, the linting is weird since black wants something different on gh-actions vs travis... so we need to pick one or the other :P.

Though I will say that I wrote this a long time ago for a previous task, so I don't quite have the right mindset to fully test it again. Hoping the new unit tests (that i wrote back then) are good enough.

Copy link
Member

@gnikonorov gnikonorov left a comment

Choose a reason for hiding this comment

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

Thanks for the prompt update, @csm10495! I had one more batch of comments.

Once those are addressed, I'd be happy to merge assuming @ssbarnea can take a look as well and OK this.

Also, can you add a changelog entry for this under 2.1.2 (unreleased) in https://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst

pytest_html/plugin.py Show resolved Hide resolved
pytest_html/plugin.py Show resolved Hide resolved
pytest_html/plugin.py Show resolved Hide resolved
@csm10495
Copy link
Member Author

@gnikonorov , changes made. Hoping we're all good :)

gnikonorov
gnikonorov previously approved these changes Sep 17, 2020
Copy link
Member

@gnikonorov gnikonorov left a comment

Choose a reason for hiding this comment

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

@gnikonorov , changes made. Hoping we're all good :)

We are @csm10495, thank you for the prompt responses. I'll wait for @ssbarnea to take a look, but this LGTM to me

@ssbarnea ssbarnea self-assigned this Sep 17, 2020
@ssbarnea
Copy link
Member

Please rebase. I do support the change, is very useful to have teardowns with results.

@csm10495
Copy link
Member Author

Thanks @ssbarnea and @gnikonorov. Squashed things down. Should be clean for merge now.

Copy link
Member

@gnikonorov gnikonorov left a comment

Choose a reason for hiding this comment

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

LGTM, I'll leave the merge to @ssbarnea so he can take a look at the final version too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report fixture setup and teardown
9 participants