pytest-parallel icon indicating copy to clipboard operation
pytest-parallel copied to clipboard

Does not work with allure-pytest

Open jmatthews79 opened this issue 6 years ago • 20 comments

When I attempt to use pytest-parallel it prevents the allure report from being generated. for instance if I run: pytest --tests-per-worker 4 --alluredir=reports/allure

no report is generated. If i take the tests per worker argument out the report works. Any idea why this would prevent the report from being saved?

jmatthews79 avatar Dec 19 '18 14:12 jmatthews79

looks like this is the same issue as the --junit one

jmatthews79 avatar Dec 19 '18 14:12 jmatthews79

Hmm, I'd understand for --workers, but I'm not sure why it's not working for --tests-per-worker

kevlened avatar Dec 19 '18 15:12 kevlened

Let me rephrase that just to be clear. It is being generated, but its showing 0 tests executed.

jmatthews79 avatar Dec 19 '18 15:12 jmatthews79

Hi @kevlened I was just curious if there was any plan to address the reporting bugs in the near future?

jmatthews79 avatar Jan 24 '19 15:01 jmatthews79

Not in the near future (probably in months, not weeks or days). I'm not focusing on Browsertron much anymore and this library was a part of that work. I'll do my best to get to them when I can. I can provide guidance for any PRs though!

kevlened avatar Jan 24 '19 16:01 kevlened

@kevlened Completely understand, I hope I didn't come off as rude. I appreciate the work you did to create this. If I knew python other than to write some Selenium tests Id love to help. :)

jmatthews79 avatar Jan 24 '19 18:01 jmatthews79

No worries (and thanks)!

kevlened avatar Jan 24 '19 18:01 kevlened

@kevlened Can you tell me your idea about a time for fix this issue (Bug) ?

SizovIgor avatar Sep 24 '19 07:09 SizovIgor

Please, look my changes, it is help me to work with allure-pytest in paralel. I'm test with --workers 2 and with 3,6,8,auto. But it is have a trouble with --tests-per-worker when it is greather than 1. It is add N identical steps, where N = tests-per-worker

index 63d4175..8e71da4 100644
--- a/pytest_parallel/__init__.py
+++ b/pytest_parallel/__init__.py
@@ -8,6 +8,7 @@ import threading
 import queue as Queue
 from py._xmlgen import raw
 from multiprocessing import Manager, Process
+from allure_pytest.plugin import pytest_configure as original_pytest_configure
 
 __version__ = '0.0.9'
 
@@ -54,6 +55,7 @@ def run_test(session, item, nextitem):
 
 
 def process_with_threads(queue, session, tests_per_worker):
+    original_pytest_configure(allur_conf)
     threads = []
     for _ in range(tests_per_worker):
         thread = ThreadWorker(queue, session)
@@ -62,6 +64,9 @@ def process_with_threads(queue, session, tests_per_worker):
     [t.join() for t in threads]
 
 
+allur_conf = None
+
+
 class ThreadWorker(threading.Thread):
     def __init__(self, queue, session):
         threading.Thread.__init__(self)
@@ -69,6 +74,7 @@ class ThreadWorker(threading.Thread):
         self.session = session
 
     def run(self):
+        original_pytest_configure(allur_conf)
         while True:
             try:
                 index = self.queue.get_nowait()
@@ -87,6 +93,8 @@ class ThreadWorker(threading.Thread):
 
 @pytest.mark.trylast
 def pytest_configure(config):
+    global allur_conf
+    allur_conf = config
     workers = parse_config(config, 'workers')
     tests_per_worker = parse_config(config, 'tests_per_worker')
     if not config.option.collectonly and (workers or tests_per_worker):

SizovIgor avatar Sep 26 '19 05:09 SizovIgor

@SizovIgor did you get any further with getting tests-per-worker to work?

pmqs avatar Mar 04 '20 15:03 pmqs

The latest (0.1.0) is quite a big change that should resolve most reporting issues. It may solve this issue as well.

kevlened avatar Apr 30 '20 18:04 kevlened

is this issue resolved? i am still facing this issue with 0.1.0

aditya123456 avatar May 11 '20 09:05 aditya123456

Hi @kevlened
Thank you for your response. I have same issue: allure-pytest==2.8.6 pytest==6.0.1 pytest-parallel==0.1.0 Do you know when it can be resolve BTW, same with report portal. Thanks!

EitanBe avatar Aug 25 '20 06:08 EitanBe

I'm facing the same issue

Any solution/workaround for this problem?

talgabza avatar Aug 26 '20 06:08 talgabza

Facing same issue.

@kevlened - If i were to try and change the current situation, do you have a recommendation for a starting point? where in the repo should i investigate?

eldbud avatar Dec 29 '20 10:12 eldbud

Thanks for the interest. Here's what I'd do:

  1. Repro
  2. Do the brief steps in CONTRIBUTING.md and make sure the existing tests were working.
  3. Write a failing test case similar to the one for pytest-html. pytest-allure needs to be added to tox.ini. I might skip this if I was unfamiliar with testing pytest plugins.
  4. I'd start by trying @SizovIgor's suggestion. The suggestion was prior to a pretty substantial change, but could be adapted.
  5. If that didn't work, I'd investigate the pytest-allure repo to determine how the reports are generated. There's probably some data that pytest-allure depends on that pytest-parallel isn't sharing across threads. All of pytest-parallel is a few hundred lines in this file.
  6. If I still couldn't figure it out, I'd open a PR with the test case (if I wrote one), so others could give it a shot.

If you try it, let me know if you run into any issues.

kevlened avatar Dec 29 '20 17:12 kevlened

Facing same issue.

Phincle avatar May 26 '21 03:05 Phincle

Facing same issue.

door7474 avatar Jul 13 '21 14:07 door7474

Any solution for this issue?

Jabyn1031 avatar Apr 28 '22 10:04 Jabyn1031

Same issue still. Any progress on this?

b0mbays avatar Sep 08 '22 16:09 b0mbays