GithubHelp home page GithubHelp logo

allure-framework / allure-python Goto Github PK

View Code? Open in Web Editor NEW
690.0 45.0 227.0 780 KB

Allure integrations for Python test frameworks

Home Page: https://allurereport.org/

License: Apache License 2.0

Python 99.68% Gherkin 0.32%
allure pytest reporting behave robotframework

allure-python's Introduction

Allure Python Integrations

Build

The repository contains adapters for Python-based test frameworks.

Allure Report logo


Pytest

Release Status Downloads

Allure pytest integration. It's developed as pytest plugin and distributed via pypi.

Usage examples.

Behave

Release Status Downloads

Allure behave integration. Just external formatter that produce test results in allure2 format. This package is available on pypi.

Usage examples.

Robot Framework

Release Status Downloads

Allure RobotFramework integration. This integration is a Listener and does not require changing autotests.

Read more ....

Usage examples.

Pytest-BDD

Release Status Downloads

Allure pytest-bdd integration. It's developed as pytest plugin and distributed via pypi.

Nose2

Release Status Downloads

Allure python commons

Common engine for all modules. It is useful for make integration with your homemade frameworks.

Allure python commons test

Just pack of hamcrest matchers for validation result in allure2 json format.

allure-python's People

Contributors

baev avatar betapl3b avatar delatrie avatar dependabot-preview[bot] avatar dependabot[bot] avatar ehborisov avatar fundakol avatar i-feofilaktov avatar iamdbychkov avatar igogorek avatar jackblk avatar janxen avatar killachicken avatar mio4kon avatar missial avatar oatssss avatar opikalo avatar proserg avatar rockbomber avatar rostrovsky avatar samuraii avatar shurikmen avatar skhomuti avatar sseliverstov avatar stilver avatar sunx2ych avatar sup3rgeo avatar tetienne avatar tsbxmw avatar vgorkavenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

allure-python's Issues

Is not possible import external module in conftest.py that use allure's decorators

I'm submitting a bug report

Steps to reproduce and a minimal demo of the problem:
Create new PyTest project:
.
./mymodule
./mymodule/_init_.py
./conftest.py
./test_1.py

Content of ./mymodule/_init_.py:

import pytest

@pytest.allure.step('step one')
def step_one():
    pass

Content of ./conftest.py:

from mymodule import step_one

Content of ./test_1.py:

def test_0():
    pass

Then run it: pytest test_1.py --alluredir aresult

You will got an error:

$ pytest test_1.py --alluredir aresult
Traceback (most recent call last):
  File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/config.py", line 373, in _importconftest
    mod = conftestpath.pyimport()
  File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/py/_path/local.py", line 662, in pyimport
    __import__(modname)
  File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/assertion/rewrite.py", line 215, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/py/_builtin.py", line 221, in exec_
    exec2(obj, globals, locals)
  File "<string>", line 7, in exec2
  File "/home/asdef/Dropbox/Work/Git/PyTestError/conftest.py", line 7, in <module>
    from mymodule import step_one
  File "/home/asdef/Dropbox/Work/Git/PyTestError/mymodule/__init__.py", line 6, in <module>
    @pytest.allure.step('step one')
AttributeError: 'module' object has no attribute 'allure'
ERROR: could not load /home/asdef/Dropbox/Work/Git/PyTestError/conftest.py

Workaround: import mymodule in test_1.py

Expected behavior: successful import of mymodule in conftest.py

Environment:

Is not possible to use allure's decorators without specify --alluredir argument

I'm submitting a bug report.

Current behavior: not possible to use allure's decorators without specify --alluredir argument.

Steps to reproduce and a minimal demo of the problem: just try to use allure's decorators without specify --alluredir argument for PyTest.

Expected behavior: successful possible to use allure's decorators without specify --alluredir argument.

Environment:

Unable to start the tests with allure-pytest 2.0 from command line through python

I'm submitting a ...

  • bug report

What is the current behavior?

With allure-pytest-adaptor 1.7.7 I always started my tests from python using:

python3 -m pytest ./tests/e2e --alluredir=./report --allure-features=Setup

When I installed allure-pytest 2.0, I can no longer start my tests with the same command line. Error appears:

AttributeError: module 'pytest' has no attribute 'allure'

However If I start the tests from IDEA specifying the same attributes - it is working fine:
screen shot 2017-06-29 at 3 52 28 pm

  • Allure version: 2.0
  • Test framework: Python 3.5.1, pytest-3.1.2
  • Allure adaptor: [email protected]

Rename allure-commons-testing to allure-commons-test

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the motivation / use case for changing the behavior?

Unification

Occurs UnicodeEncodeError when failure message contains non-ascii symbols

I'm submitting a bug report

Сurrent behavior: occurs UnicodeEncodeError when failure message contains non-ascii symbols

The steps to reproduce and a minimal demo of the problem:
Create simple PyTest test:

def test_2():
    assert False, 'Большая беда'

Then run it: pytest test_2.py --alluredir aresult

You will got an error:

...
INTERNALERROR>   File "/home/bomber/.virtualenvs/autotesting/local/lib/python2.7/site-packages/allure_pytest/listener.py", line 134, in pytest_runtest_makereport
INTERNALERROR>     status_details = StatusDetails(message=str(call.excinfo.exconly()), trace=str(report.longrepr))
INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-22: ordinal not in range(128)

Expected behavior: test must fails without INTERNALERROR, allure report must contain failure message with non-ascii symbols.

Environment:

Parametrized session-scoped fixtures: KeyError in logger

Reproducing:

import pytest

@pytest.fixture(scope='session', params=['param a'])
def param(request):
    return request.param

def test_smth(param):
    with pytest.allure.step('Test {}'.format(param)):
        assert param == 'param a'

Trace:

$ py.test test.py --alluredir allure-results/
============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.4.5, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /home/igorock/Work/backend-tests, inifile: 
plugins: timeout-1.2.0, allure-adaptor-2.0.1
collected 1 items 

test.py E

=================================================================================================================== ERRORS ===================================================================================================================
____________________________________________________________________________________________________ ERROR at setup of test_smth[param b] ____________________________________________________________________________________________________

self = <allure.listener.AllureListener object at 0x7fee15ef7c50>, fixturedef = <FixtureDef name='param' scope='session' baseid='test.py' >, request = <SubRequest 'param' for <Function 'test_smth[param b]'>>

    @pytest.hookimpl(hookwrapper=True)
    def pytest_fixture_setup(self, fixturedef, request):
        uuid = uuid4()
        node_id = request.node.nodeid
        parent_uuid = self._cache.get(node_id) if fixturedef.scope == 'function' else self._cache.get(fixturedef)
        parameters = allure_parameters(fixturedef, request)
    
        # ToDo autouse fixtures
        if fixturedef.baseid and parent_uuid:
            fixture = ExecutableItem(start=now(), name=fixturedef.argname)
            self.allure_logger.start_before_fixture(parent_uuid, uuid, fixture)
    
        if parameters and parent_uuid:
            parameters = Parameter(**parameters) if parameters else []
>           self.allure_logger.update_test(self._cache.get(node_id), parameters=parameters)

/usr/lib/python3.4/site-packages/allure/listener.py:95: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.4/site-packages/allure/logger.py:57: in update_test
    self._update_item(uuid, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <allure.logger.AllureLogger object at 0x7fee15ef7c88>, uuid = None, kwargs = {'parameters': Parameter(name='param', value='param b')}

    def _update_item(self, uuid, **kwargs):
>       item = self._items[uuid]
E       KeyError: None

/usr/lib/python3.4/site-packages/allure/logger.py:18: KeyError
========================================================================================================== 1 error in 0.05 seconds ===========================================================================================================

Environment:

$ sudo pip freeze | grep pytest 
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pytest==3.0.6
pytest-allure-adaptor==2.0.1
pytest-timeout==1.2.0

P.S. allure-python2 was updated 2017.02.10 at 16:24 MSK :)

"IndexError: list index out of range" during start_step

On running the following script in pytest with "-x" flag, we see the error "IndexError: list index out of range" on running the step Cleanup

Script

#!/usr/bin/env python

import pytest                           
from allure import step                 

@pytest.fixture(scope='module')
def setup(request):                     
    def cleanup():                      
        with step('Cleanup'):
            pass                        
    request.addfinalizer(cleanup)

def test_1(setup):                      
    assert(), "Fail"                    

def test_2(setup):                      
    pass                                

Logs

pharidos@uks2:~/$ py.test tests/test.py --tb short -x -s --alluredir ~/allure
============================ test session starts =============================
platform linux2 -- Python 2.7.9, pytest-2.9.0, py-1.4.31, pluggy-0.3.1
rootdir: /home/pharidos, inifile: pytest.ini
plugins: allure-adaptor-1.7.5, logging-2015.11.4, ordering-0.4, catchlog-1.2.2, html-1.6
collected 2 items 

tests/test.py F
!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!
Traceback (most recent call last):
  File "/usr/local/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 49, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/main.py", line 119, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/main.py", line 114, in wrap_session
    exitstatus=session.exitstatus)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/terminal.py", line 363, in pytest_sessionfinish
    outcome.get_result()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    _reraise(*ex)  # noqa
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__
    self.result = func()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/runner.py", line 56, in pytest_sessionfinish
    session._setupstate.teardown_all()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/runner.py", line 380, in teardown_all
    self._pop_and_teardown()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/runner.py", line 353, in _pop_and_teardown
    self._teardown_with_finalization(colitem)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/runner.py", line 371, in _teardown_with_finalization
    self._callfinalizers(colitem)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/runner.py", line 368, in _callfinalizers
    py.builtin._reraise(*exc)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/runner.py", line 361, in _callfinalizers
    fin()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/python.py", line 2087, in finish
    func()
  File "/home/pharidos/tests/test.py", line 9, in cleanup
    with step('Per-Module cleanup'):
  File "/usr/local/lib/python2.7/dist-packages/allure/common.py", line 34, in __enter__
    self.step = self.allure.start_step(self.title)
  File "/usr/local/lib/python2.7/dist-packages/allure/pytest_plugin.py", line 159, in start_step
    self.stack[-1].steps.append(step)
IndexError: list index out of range

User defined labels

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

user can't set label name as string because allure.label expects enum

Placeholders in step's title didn't work

Placeholders in step's title didn't work
in test:
@pytest.allure.step('{1}')
in report:
{1} [ self: <gsf.tests.am.desktop.rb_params_test.RbLandingConstructorTest object at 0x03E39230> string: получаем страницу лендинга ]

KeyError: <function uuid4 at ... >

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

allure-pytest raises KeyError in some complicated tests.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

Currently I've got 81 fixtures with different scopes so unfortunately I cannot provide any simple way to reproduce this problem as well as provide my code that belongs to my company.

Fortunately I've found possible reason of the the problem in this line: https://github.com/allure-framework/allure-python/blob/master/allure-pytest/src/listener.py#L97

What is the expected behavior?

No exception

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

$ pip freeze | grep allure
allure-pytest==2.0.0b2
allure-python-commons==2.0.0b2
platform linux -- Python 3.4.5, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/igorock/Work/backend-tests, inifile: setup.cfg
plugins: timeout-1.2.0, allure-pytest-2.0.0b2

Other information

    @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)
    
        parameters = allure_parameters(fixturedef, request)
        if parameters:
            test_uuid = self._cache.get(request._pyfuncitem.nodeid)
            parameters = Parameter(**parameters) if parameters else []
            self.allure_logger.update_test(test_uuid, parameters=parameters)
    
        yield
    
        try:
>           self.allure_logger.stop_before_fixture(before_fixture_uuid, stop=now())

/usr/lib/python3.4/site-packages/allure_pytest/listener.py:111: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.4/site-packages/allure/logger.py:48: in stop_before_fixture
    self._update_item(uuid, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <allure.logger.AllureLogger object at 0x7ff7dd6a13c8>
uuid = <function uuid4 at 0x7ff7e0f17598>, kwargs = {'stop': 1499416388625}

    def _update_item(self, uuid, **kwargs):
>       item = self._items[uuid]
E       KeyError: <function uuid4 at 0x7ff7e0f17598>

/usr/lib/python3.4/site-packages/allure/logger.py:21: KeyError

Add support for Lettuce Framework

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the motivation / use case for changing the behavior?

Lettuce is a BDD framework for python and it would be really good to have allure support that

Other information

https://github.com/gabrielfalcao/lettuce

Support 'Epic' label

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior?

@allure.epic('Epic1', 'Epic'2, ....)
def tets_...

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Other information

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.