allankp / pytest-testrail

pytest plugin for integration with TestRail, for creating testruns and updating results
MIT License
95 stars 125 forks source link

Is Python 3 supported for this plugin? #42

Closed yishan-lin closed 6 years ago

yishan-lin commented 6 years ago

I've gotten it working with python2.7, successfully POSTing to Testrail.

But on Python3, it doesn't seem to work - the same code ends up forever hanging at the "collecting items" stage.

Am I missing something?

apallier commented 6 years ago

Hi @yishan-lin, Yes it should work with Python 3 (I use it with Python 3 :) Are you able to run pytest with --collect-only option? Maybe it's a problem with pytest version => I use Pytest 3.0.7

yishan-lin commented 6 years ago

Hey @apallier, thanks for the speedy response. I'm using Pytest 3.4.2.

The script below POSTS just fine to my trial Testrail account on Python 2.7.10, but on Python 3, it gets stuck in "collecting items" phase. Tried multiple times, each time waiting 15-30 minutes.



import pytest
import subprocess
import time

subprocess.call('pip3 install pytest-testrail', shell=True)

from pytest_testrail.plugin import testrail, pytestrail

@pytestrail.case('C1')
def test_func1():
    time.sleep(0.1)

@pytestrail.case('C2')
def test_func2():
    time.sleep(0.1)

@pytestrail.case('C3')
def test_func3():
    time.sleep(0.1)

subprocess.call('py.test test.py --testrail  --tr-url=xxxx --tr-email=xxxx --tr-password=xxxx --tr-testrun-project-id=1 --tr-testrun-suite-id=1', shell=True)
apallier commented 6 years ago

Hi @yishan-lin, Your code look a little bit "recursive", isn't it? :) I try your example and have the same behavior as you...

I advice to call pytest outside our module code. In Python when you just import a module (file), all the code will be executed, except the code inside block if __name__ == '__main__'. It seems that our code creates an infinite loop if our module test is imported by pytest (assumption).

This code works for me, but I advice you, if you can, to call pytest from a shell and not in subprocess.call:

import pytest
import subprocess
import time

from pytest_testrail.plugin import testrail, pytestrail

@pytestrail.case('C1')
def test_func1():
    time.sleep(0.1)

@pytestrail.case('C2')
def test_func2():
    time.sleep(0.1)

@pytestrail.case('C3')
def test_func3():
    time.sleep(0.1)

if __name__ == '__main__':

    # subprocess.call('pip3 install pytest-testrail', shell=True)
    subprocess.call('pytest --testrail --tr-config=testrail.cfg --tr-version=1.0.0.0 \
    --tr-plan-id=xxx test_issue_42.py'.split(), shell=True)
apallier commented 6 years ago

Hi @yishan-lin, did you resolve your problem?

apallier commented 6 years ago

@yishan-lin Feel free to reopen this issue if necessary