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

Allure throws AttributeError when using @pytest.fixture with yield statement #282

Closed
1 task done
grmmvv opened this issue Aug 6, 2018 · 2 comments
Closed
1 task done

Comments

@grmmvv
Copy link

grmmvv commented Aug 6, 2018

I'm submitting a ...

  • bug report

What is the current behavior?

Running tests with using @pytest.fixture with yield always throws AttributeError exception

Reproduction

Run code code below with argument --alluredir=allure-results

import pytest
@pytest.fixture
def fixture_name():
    yield True
def test_error(fixture_name):
    assert 1

Trace

(venv) PS C:\GIT\allure_error> pytest --alluredir=allure-results
============================= test session starts =============================
platform win32 -- Python 2.7.15, pytest-3.7.1, py-1.5.4, pluggy-0.7.1
rootdir: C:\GIT\allure_error, inifile:
plugins: allure-pytest-2.5.0
collected 1 item

test_allure.py E                                                         [100%]

=================================== ERRORS ====================================
________________________ ERROR at setup of test_error _________________________

self = <allure_pytest.listener.AllureListener object at 0x0665A530>
fixturedef = <FixtureDef name='fixture_name' scope='function' baseid='test_allure.py' >
request = <SubRequest 'fixture_name' for <Function 'test_error'>>

    @pytest.hookimpl(hookwrapper=True)
    def pytest_fixture_setup(self, fixturedef, request):
        fixture_name = fixturedef.argname

        container_uuid = self._cache.get(fixturedef)

        if not container_uuid:
            container_uuid = self._cache.set(fixturedef)
            container = TestResultContainer(uuid=container_uuid)
            self.allure_logger.start_group(container_uuid, container)

        self.allure_logger.update_group(container_uuid, start=now())

        before_fixture_uuid = uuid4()
        before_fixture = TestBeforeResult(name=fixture_name, start=now())
        self.allure_logger.start_before_fixture(container_uuid, before_fixture_uuid, before_fixture)

        outcome = yield

        self.allure_logger.stop_before_fixture(before_fixture_uuid,
                                               stop=now(),
                                               status=get_outcome_status(outcome),
                                               statusDetails=get_outcome_status_details(outcome))

        finalizers = getattr(fixturedef, '_finalizers', [])
        for index, finalizer in enumerate(finalizers):
>           name = '{fixture}::{finalizer}'.format(fixture=fixturedef.argname, finalizer=finalizer.__name__)
E           AttributeError: 'functools.partial' object has no attribute '__name__'

venv\lib\site-packages\allure_pytest\listener.py:136: AttributeError
=========================== 1 error in 0.11 seconds ===========================

Please tell us about your environment:

Other information

@gdemchenko
Copy link

Can confirm, I am expiriencing exact same problem
except on python 3.6.4

@pchernyshev
Copy link

It is probably same as #278

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

No branches or pull requests

3 participants