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
24 changes: 24 additions & 0 deletions plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ def test_warning():
assert not result.stderr.lines


def test_annotation_warning_cwd(testdir: pytest.Testdir):
testdir.makepyfile(
"""
import warnings
import pytest
pytest_plugins = 'pytest_github_actions_annotate_failures'

def test_warning():
warnings.warn('beware', Warning)
assert 1
"""
)
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
testdir.monkeypatch.setenv("GITHUB_WORKSPACE", os.path.dirname(str(testdir.tmpdir)))
testdir.mkdir("foo")
testdir.makefile(".ini", pytest="[pytest]\ntestpaths=..")
result = testdir.runpytest_subprocess("--rootdir=foo")
result.stderr.fnmatch_lines(
[
"::warning file=test_annotation_warning_cwd0/test_annotation_warning_cwd.py,line=6::beware",
]
)


def test_annotation_third_party_exception(testdir: pytest.Testdir):
testdir.makepyfile(
my_module="""
Expand Down
2 changes: 1 addition & 1 deletion pytest_github_actions_annotate_failures/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def pytest_warning_recorded(
return

filesystempath = warning_message.filename
workspace = os.environ.get("GITHUB_WORKFLOW")
workspace = os.environ.get("GITHUB_WORKSPACE")

if workspace:
try:
Expand Down