Skip to content

Commit

Permalink
Fix potential AttributeError (#81)
Browse files Browse the repository at this point in the history
* Added `None` default to avoid AttributeError

* Added tests
  • Loading branch information
liiight authored and lukas-bednar committed Jul 31, 2017
1 parent 5b05af2 commit 22bf4e8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pytest_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ def jira_issue(request):
https://github.com/rhevm-qe-automation/pytest_jira#fixture-usage
for more details
"""

def wrapper_jira_issue(issue_id):
jira_plugin = getattr(request.config, '_jira')
jira_plugin = getattr(request.config, '_jira', None)
if jira_plugin and jira_plugin.conn.is_connected():
return jira_plugin.is_issue_resolved(issue_id)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def assert_outcomes(
assert outcomes.get("xfailed", 0) == xfailed


def test_jira_plugin_disabled(testdir):
testdir.makepyfile("""
import pytest
@pytest.mark.jira("ORG-1382", run=True)
def test_pass():
assert True
""")
result = testdir.runpytest()
assert_outcomes(result, 1, 0, 0)


def test_jira_marker_no_args(testdir):
testdir.makeconftest(CONFTEST)
testdir.makepyfile("""
Expand Down Expand Up @@ -706,6 +717,17 @@ def test_fail():
assert_outcomes(result, passed=0, skipped=0, failed=0, error=0, xfailed=1)


def test_jira_fixture_plugin_disabled(testdir):
testdir.makepyfile("""
import pytest
def test_pass(jira_issue):
assert jira_issue("ORG-1382") is None
""")
result = testdir.runpytest()
assert_outcomes(result, 1, 0, 0)


def test_jira_fixture_run_positive(testdir):
testdir.makeconftest(CONFTEST)
testdir.makepyfile("""
Expand Down

0 comments on commit 22bf4e8

Please sign in to comment.