Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions pytest_marker_bugzilla.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
# -*- coding: utf-8 -*-
import six
import bugzilla
import inspect
import os
import pytest
import re
import logging
from distutils.version import LooseVersion
from functools import wraps
"""This plugin integrates pytest with bugzilla

It allows the tester to mark a test with a bug id. The test will be skipped
Expand Down Expand Up @@ -57,6 +48,18 @@ def test_something():
Eric L. Sammons
Milan Falešník
"""
import inspect
import logging
import os
import re
from distutils.version import LooseVersion
from functools import wraps

import bugzilla
import pytest
import six


logger = logging.getLogger(__name__)
_bugs_pool = {} # Cache bugs for greater speed
_default_looseversion_fields = "fixed_in,target_release"
Expand Down Expand Up @@ -367,7 +370,7 @@ def pytest_collection_modifyitems(self, session, config, items):

def pytest_addoption(parser):
"""
Add a options section to py.test --help for bugzilla integration.
Add options section to py.test --help for bugzilla integration.
Parse configuration file, bugzilla.cfg and / or the command line options
passed.

Expand Down Expand Up @@ -414,6 +417,14 @@ def pytest_addoption(parser):
metavar='password',
help='Overrides the bugzilla password in bugzilla.cfg.',
)
group.addoption(
'--bugzilla-api-key',
action='store',
dest='bugzilla_api_key',
default=get_value_from_config_parser(config, 'bugzilla_api_key', ''),
metavar='api_key',
help='Overrides the bugzilla api key in bugzilla.cfg.',
)
group.addoption(
'--bugzilla-project-version',
action='store',
Expand Down Expand Up @@ -446,10 +457,19 @@ def pytest_configure(config):
"markers",
"bugzilla(*bug_ids, **guards): Bugzilla integration",
)
if config.getvalue("bugzilla") and config.getvalue('bugzilla_url'):
url = config.getvalue('bugzilla_url')
user = config.getvalue('bugzilla_username')
password = config.getvalue('bugzilla_password')

url = config.getvalue('bugzilla_url')
username = config.getvalue('bugzilla_username')
password = config.getvalue('bugzilla_password')
api_key = config.getvalue('bugzilla_api_key')
if config.getvalue("bugzilla") and url:
if username and password:
bz = bugzilla.Bugzilla(url=url, user=username, password=password)
elif api_key:
bz = bugzilla.Bugzilla(url=url, api_key=api_key)
else:
bz = bugzilla.Bugzilla(url=url)

version = config.getvalue('bugzilla_version')
loose = [
x.strip()
Expand All @@ -458,7 +478,5 @@ def pytest_configure(config):
if len(loose) == 1 and not loose[0]:
loose = []

bz = bugzilla.Bugzilla(url=url, user=user, password=password)

my = BugzillaHooks(config, bz, loose, version)
assert config.pluginmanager.register(my, "bugzilla_helper")
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python-bugzilla
pytest == 6.2.5
six