allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
725 stars 237 forks source link

Test run to generate report using allure-pytest-bdd module return 'No module named - allure_commons.lifecycle' #451

Closed ricwal-richa closed 3 years ago

ricwal-richa commented 4 years ago

[//]: # ( . Note: for support questions, please use Stackoverflow or Gitter. . This repository's issues are reserved for feature requests and bug reports. . . In case of any problems with Allure Jenkins plugin please use the following repository . to create an issue: https://github.com/jenkinsci/allure-plugin/issues . . Make sure you have a clear name for your issue. The name should start with a capital . letter and no dot is required in the end of the sentence. An example of good issue names: . . - The report is broken in IE11 . - Add an ability to disable default plugins . - Support emoji in test descriptions )

I'm submitting a ...

What is the current behavior?

Module 'allure_commons.lifecycle' not found when running tests.

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

  1. Run pip install allure-pytest-bdd in activated conda environment (which is named '3point7' for my project)
  2. Run conda list to confirm that the module has been installed.
  3. Create an 'allureReports' directory in project folder.
  4. Run the existing pytest-bdd test using command - pytest --alluredir= <absolute path to allureReports folder> i.e. pytest --alluredir=/Users/ricagarw/PythonProject/dataTesting/allureReports
  5. Error returned - 'No module named - allure_commons.lifecycle'

What is the expected behavior?

Allure report should be generated by simply installing the module and running the test with 'allureDir' flag.

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

Bug fix

Please tell us about your environment:

Other information

Error report - (3point7) wkmca9711659:PythonProject ricagarw$ pytest --alluredir=/Users/ricagarw/PythonProject/dataTesting/allureReports Traceback (most recent call last): File "/Users/ricagarw/anaconda3/envs/3point7/bin/pytest", line 11, in <module> sys.exit(main()) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 72, in main config = _prepareconfig(args, plugins) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 223, in _prepareconfig pluginmanager=pluginmanager, args=args File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__ return self._hookexec(self, self.get_hookimpls(), kwargs) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall gen.send(outcome) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse config = outcome.get_result() File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(*args) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 793, in pytest_cmdline_parse self.parse(args) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 999, in parse self._preparse(args, addopts=addopts) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 947, in _preparse self.pluginmanager.load_setuptools_entrypoints("pytest11") File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints plugin = ep.load() File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 94, in load module = import_module(match.group('module')) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 143, in exec_module exec(co, module.__dict__) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/allure_pytest_bdd/plugin.py", line 4, in <module> from .pytest_bdd_listener import PytestBDDListener File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 143, in exec_module exec(co, module.__dict__) File "/Users/ricagarw/anaconda3/envs/3point7/lib/python3.7/site-packages/allure_pytest_bdd/pytest_bdd_listener.py", line 14, in <module> from allure_commons.lifecycle import AllureLifecycle ModuleNotFoundError: No module named 'allure_commons.lifecycle'

toolsh commented 4 years ago

allure_commons.lifecycle is missing in: https://pypi.org/project/allure-python-commons/#files

Filename, size File type Python version Upload date Hashes
allure_python_commons-2.8.6-py2.py3-none-any.whl (14.6 kB) Wheel py2.py3 Oct 8, 2019 View
allure-python-commons-2.8.6.tar.gz (10.3 kB) Source None Oct 8, 2019 View
ricwal-richa commented 4 years ago

@toolsh Thanks for the link to allure_python_commons file. I downloaded and ran pip install <absolute_path_to_.tar.gz_file> in my conda environment. After its installation, I ran pip install allure-pytest-bdd; still upon running the test, I am getting same error as earlier.

I also tried uninstalling allure-pytest-bdd and reinstalled is using .tar.gz source file for same. I can see both packages under site-packages; but still getting earlier error on test run. Am I doing something wrong here?

Screen Shot 2020-01-24 at 6 37 13 PM

Also I am unable to uninstall the allure package installed using .tar.gz and not able to run my test at all even if I do not provide --alluredir flag from cli. I still get same error of - ModuleNotFoundError: No module named 'allure_commons.lifecycle'

SavitaMaurya commented 4 years ago

Hi Team,

I am also facing the same issue ModuleNotFoundError: No module named 'allure_commons.lifecycle'.

I have installed using this command: pip install allure-pytest-bdd

and got successfully installed with this ending message.

Successfully installed allure-pytest-bdd-2.8.6b0 allure-python-commons-2.8.6

I am running tests with this configurations:

metadata: {'Python': '3.7.3', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '5.3.4', 'py': '1.8.0', 'pluggy': '0.12.0'}, 'Plugins': {'bdd': '3.1.0', 'forked': '1.1.3', 'html': '2.0.1', 'metada t

BookingFlowTestSuite>pytest --alluredir=reports/allure_reports Traceback (most recent call last): File "c:\users\su101\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\SU101\AppData\Local\Programs\Python\Python37-32\Scripts\pytest.exe__main.py", line 7, in File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\config__init.py", line 73, in main config = _prepareconfig(args, plugins) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\config\init__.py", line 224, in _prepareconfig pluginmanager=pluginmanager, args=args File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\hooks.py", line 289, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 87, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 81, in firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 203, in _multicall gen.send(outcome) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\helpconfig.py", line 89, in pytest_cmdline_parse config = outcome.get_result() File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall res = hook_impl.function(*args) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\config__init.py", line 794, in pytest_cmdline_parse self.parse(args) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\config__init.py", line 1000, in parse self._preparse(args, addopts=addopts) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\config\init.py", line 948, in _preparse self.pluginmanager.load_setuptools_entrypoints("pytest11") File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 292, in load_setuptools_entrypoints plugin = ep.load() File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\importlib_metadata\init__.py", line 90, in load module = import_module(match.group('module')) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\importlib\init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\assertion\rewrite.py", line 143, in exec_module exec(co, module.dict) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\allure_pytest_bdd\plugin.py", line 4, in from .pytest_bdd_listener import PytestBDDListener File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages_pytest\assertion\rewrite.py", line 143, in exec_module exec(co, module.dict__) File "c:\users\su101\appdata\local\programs\python\python37-32\lib\site-packages\allure_pytest_bdd\pytest_bdd_listener.py", line 14, in from allure_commons.lifecycle import AllureLifecycle ModuleNotFoundError: No module named 'allure_commons.lifecycle'

Please suggest

toolsh commented 4 years ago

https://github.com/allure-framework/allure-python/blob/master/allure-python-commons/src/lifecycle.py

just download lifecycle.py and put it at \Lib\site-packages\allure_commons\lifecycle.py

ricwal-richa commented 4 years ago

thanks @toolsh ..that worked.

sseliverstov commented 4 years ago

hope this fixed