Skip to content

Commit 032efb6

Browse files
author
Philipp Loose
committed
Add test for _issue_warning_captured in cacheprovider.Cache.set
1 parent 7e5882a commit 032efb6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

testing/acceptance_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,3 +1318,17 @@ def test_dummy():
13181318
# with stacklevel=2 the warning originates from resultlog.pytest_configure
13191319
# and is thrown when --result-log is used
13201320
result.stdout.fnmatch_lines(["*resultlog.py:35*", "*--result-log is deprecated*"])
1321+
1322+
1323+
def test_issue4445_cacheprovider_set(testdir):
1324+
"""#4445: Make sure the warning points to a reasonable location
1325+
See origin of _issue_warning_captured at: _pytest.cacheprovider.py:59
1326+
"""
1327+
testdir.tmpdir.join(".pytest_cache").write("something wrong")
1328+
result = testdir.runpytest()
1329+
# with stacklevel=3 the warning originates from one stacklevel above
1330+
# _issue_warning_captured in cacheprovider.Cache.set and is thrown
1331+
# when there are errors during cache folder creation
1332+
result.stdout.fnmatch_lines(
1333+
["*cacheprovider.py:120*", "*could not create cache path*"]
1334+
)

0 commit comments

Comments
 (0)