Skip to content

Add allure-pytest-log plugin for capture stdout content and attach to each step/test/fixture in report #263

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wuhuizuo
Copy link

@wuhuizuo wuhuizuo commented Jul 3, 2018

//: # (
. Thank you so much for sending us a pull request!
.
. Make sure you have a clear name for your pull request.
. The name should start with a capital letter and no dot is required in the end of the sentence.
. To link the request with isses use the following notation: (fixes #123, fixes #321)
.
. An example of good pull request names:
. - Add Russian translation (fixes #123)
. - Add an ability to disable default plugins
. - Support emoji in test descriptions
)

Context

Add pytest plugin: allure-pytest-log for capture stdout content and attach to allure report.

example:

# file: tests/test_hello.py
import allure
import time
import pytest

@pytest.fixture(scope='function')
def hello():
    time.sleep(1)
    print('hello')
    time.sleep(1)
    allure.attach('attach in fixture:hello', name='manual attach in fixture')
    return 'hello'

class TestXxx(object):
    class TestYyy(object):
        def test_with_steps(self, hello):
            with allure.step('step1'):
                print('step1')
            with allure.step('step2'):
                print('step2')
            with allure.step('step3'):
                print('step3')
                print(hello)

After you have installed pip: pytest-allure-log, you can run with:

pytest -s --allure-capture --alluredir=reports

Checklist

@CLAassistant
Copy link

CLAassistant commented Jul 3, 2018

CLA assistant check
All committers have signed the CLA.

@wuhuizuo wuhuizuo force-pushed the feature/allure_pytest_log-plugin branch from b0322bc to 68048d4 Compare July 3, 2018 11:49
@wuhuizuo wuhuizuo changed the title WIP: Add allure-pytest-log plugin for capture stdout content and attach to each step/test/fixture in report Add allure-pytest-log plugin for capture stdout content and attach to each step/test/fixture in report Jul 3, 2018
@wuhuizuo
Copy link
Author

wuhuizuo commented Jul 3, 2018

@sseliverstov Could you review it. Thanks

@sseliverstov
Copy link
Contributor

@wuhuizuo, at first, it is awesome pr) Thanks!
Yep, I will review it in few days.

@Sup3rGeo
Copy link
Contributor

Sup3rGeo commented Jul 7, 2018

@wuhuizuo looks nice!

Just one suggestion though: Because this seems to be already in the form of a separate plugin, couldn't it actually be packaged and distributed independently? Even uploading to PyPI to install like for example pip install allure-capture-stdout.

That way we can make this available to users to get some feedback even before needing to merge this into allure-framework repo. Then later, if it is really something to merge to allure-python, you wouldn't really need to monkey-patch anymore (e.g. listener.allure_logger) but just modify it directly to make it 100% part of allure-python.

@Sup3rGeo Sup3rGeo mentioned this pull request Jul 7, 2018
3 tasks
@wuhuizuo
Copy link
Author

wuhuizuo commented Jul 10, 2018

@Sup3rGeo thank you for your suggestion!
My idea is as follows:

  1. allure-python project contain several pip packages in separate directories.
  2. my project like a other sub project for allure-python and depend on allure-pytest.
  3. I expect this project be a part of allure-python, if all administrators aggree to include my features, i am pleasure to refactor it to become a part of allure-pytest.

@Sup3rGeo
Copy link
Contributor

I agree, so it could initially become something like allure-robotframework and allure-behave, and later on merge to allure-pytest. Let's hear from @sseliverstov

@sseliverstov
Copy link
Contributor

Hi folks,

I can't decide, what way is better, as a part of allure-pytest package or new one like a plugin.

In my opinion, separated package is preferred, because it may be more than enhancement for allure-pytest plugin. I don't know how it apply now, but reusing code in behave and robot would be great.

Current architecture is not able to provide well implemented plugin like this, you had saw that in monkey-pathched code. I need to some time for play around hooks infrastructure and implementation developer friendly decision.

@wuhuizuo , I can't estimate how long would it, and if this code is need in pypi, you can distribute it from your repo.

Btw, @Sup3rGeo's idea with log-to-step plugin might be implemented in this way.

@Kreisfahrer
Copy link

Hi all!

I just wanted to point out that this feature is present in pytest-allure-adaptor. It would be nice to have it in this package too.

@Sup3rGeo
Copy link
Contributor

I have proposed another implementation for this, which is quite simple in fact, in PR #285.

@wuhuizuo could you please take a look and check how different it is from your implementation in this PR?

@wuhuizuo
Copy link
Author

wuhuizuo commented Sep 10, 2018

@Sup3rGeo Sorry for responding late!
#285 is very awesome, my PR has differences with pr #285 :

  1. mine is separately, not to modify origin pytest-allure
  2. log capture can attach to any atomic method, like fixture/setup/teardown/test function, not only attach test log at teardown event. My origin requirement is to track every step detail(not only the test function).

@shreyashah
Copy link

@wuhuizuo : Is your code in production? Is there a seperate package we need to install?

@wuhuizuo
Copy link
Author

@wuhuizuo : Is your code in production? Is there a seperate package we need to install?

@shreyashah
yes, not public to download, you can get the src at https://github.com/wuhuizuo/allure-python/tree/feature/allure_pytest_log-plugin/allure-pytest-log.
you can publish the pip in private pip server by yourself.

@zoykhan
Copy link

zoykhan commented May 15, 2020

is this PR going to be merged?

@rafaelcs
Copy link

rafaelcs commented Jun 3, 2020

Do we have any update here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants