Package: pytest-glamor-allure
pytest-glamor-allurepytest plugin extending allure behaviourWhy has it been created?What is it?Why is it named "glamor"?How to install?What does it can?Fancy names for setups and teardownsHide setup and teardownDisplay 'scope' and 'autouse' parameters in fixture titleNo more '::0' in teardown titleAdd allure.step titles into loggingWhat else?Pleasant bonus 🎁How can I help?Why has it been created?Just becauseallure-pythonplugin accepts PRs very slowly. Sad but true.I want to inject more functionality into it. That's why I've decided to create this plugin.What is it?As been said it is pytest plugin (tnx captain 😄). Consider this plugin just as some extension forallure-pytest.Hopefully, they'll see this code and add some of this functionality later.Why is it named "glamor"?Because "glamor" is a synonym for "allure". Glamor does the same thing as allure-pytest does but a little more.The main idea is to just replace imports in you project: instead ofimport allureyou typeimport glamor as allureand everything works as before.How to install?pipinstallpytest-glamor-allureThat's it.What does it can?It's the most interesting part of the ReadMe.Fancy names for setups and teardownsallure-pythonprovides possibility to set title for fixture with@allure.titledecorator.But there is no chance to set different titles for setup and teardown.
Glamor does can this!importpytestimportglamorasallure@pytest.fixture@allure.title.setup('Fancy setup name')@allure.title.teardown('Fancy teardown name')deffixture():yield@allure.title('Test Title')deftest_test(fixture):withallure.step('test step'):passAnd moreover. You can dynamically change setup and teardown titles for fixtures.Only one restriction:dynamic hook must be used inside the fixture's body.importpytestimportglamorasallure@pytest.fixturedeffixture():yieldallure.dynamic.title.setup('Fancy dynamic setup name')allure.dynamic.title.teardown('Fancy dynamic teardown name')@allure.title('Test Title')deftest_test(fixture):withallure.step('test step'):passHide setup and teardownHave you ever wanted to conceal setup and/or teardown from 'allure' report?Well, now you can.importpytestimportglamorasallure@pytest.fixture@allure.title.setup(hidden=True)@allure.title.teardown('Teardown ONE')deffixture():yield@pytest.fixture@allure.title.setup('Setup TWO')deffixture2():yieldifTrue:allure.dynamic.title.teardown(hidden=True)@allure.title('Test Title')deftest_test(fixture,fixture2):withallure.step('test step'):passBut! If any exception (includingSkipped) is raised, then hidden setups and teardowns are shown forcefully.importpytestimportglamorasallure@pytest.fixture@allure.title.setup('Setup is displayed in case of failure',hidden=True)@allure.title.teardown('Teardown ONE')deffixture():withallure.step('fail step'):assertFalse,'some exception in setup'yield@pytest.fixture@allure.title.setup('Setup TWO')deffixture2():yieldifTrue:allure.dynamic.title.teardown(hidden=True)pytest.skip('we decided to skip')@allure.title('Test Title')deftest_test(fixture2,fixture):withallure.step('test step'):passDisplay 'scope' and 'autouse' fixture parameters in fixture titleSometimes it is useful to know which scope this fixture is, and was it called manually or autoused.Just call the function once per runtimeinclude_scope_in_titlebefore pytest starts execution of any hook (during modules initialization).importpytestimportglamorasallureallure.include_scope_in_title('before',autouse=True)@pytest.fixture(scope='session',autouse=True)@allure.title.setup('Fancy setup name')deffixture():yield@pytest.fixture@allure.title.setup('Setup TWO')deffixture2():yield@allure.title('Test Title')deftest_test(fixture2):withallure.step('test step'):passThe big letter is the first letter of the scope name (one of 'function', 'class', 'module', 'package', 'session'). The lower letter 'a' says that fixture was autoused.If you want to put this information to the end of the title, then just call the function asallure.include_scope_in_title('after', autouse=True)and you get:No more '::0' in teardown titleHave you noticed '::0' in raw teardown titles? No? That's because glamor strips such ending if fixture has not more than one finalizer.Add allure.step titles into loggingHave you ever tried to understand when the particular allure step started looking at tests' logs? Of course, you have!With "glamor" you can register you own logger, which is considered to print steps' titles into output.importloggingimportsysimportglamorasallure# Create loggerlogger=logging.getLogger('MyLogger')logger.setLevel(logging.INFO)fmt=logging.Formatter('[%(levelname)s]%(message)s')handler=logging.StreamHandler(stream=sys.stdout)handler.setLevel(logging.INFO)handler.setFormatter(fmt)logger.addHandler(handler)# Register logger in allureallure.logging_allure_steps(logger)# Execute tests' codelogger.info("start message")withallure.step("step message"):passlogger.error("end message")[INFO]startmessage[STEP]stepmessage[ERROR]endmessagelogging_allure_stepsshould be called only once - during modules initialization. But who am I to restrict you?If you need you can turn off this behaviour by calling the function withNoneinstead oflogging.Loggerinstance.What else?importglamorasallureallure.listener# access to AllureListener plugin instanceallure.reporter# alias for allure.listener.allure_loggerallure.pytest_config# access to pytest.Config instance. alias for allure.listener.configAlso via 'glamor' module you get direct access to many objects from:allure_commonsallure_commons._allureallure_commons.model2allure_commons.typesallure_commons.utilsallure_pytest.utilsPleasant bonus 🎁Typeimport pitest as pytestinstead ofimport pytestand get direct access to a bunch of objects frompytestand_pytestmodules.How can I help?Your contribution is highly appreciated. Please readCONTRIBUTING.mdbefore you start.