Skip to content

Commit 3b654a7

Browse files
author
Philipp Loose
committed
Move stacklevel tests into test_warnings module
The tests are grouped in a class called TestStackLevel.
1 parent ab17a00 commit 3b654a7

File tree

2 files changed

+736
-736
lines changed

2 files changed

+736
-736
lines changed

testing/acceptance_test.py

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,97 +1238,3 @@ def test_3():
12381238
assert (
12391239
result.stdout.str().count("async def functions are not natively supported") == 1
12401240
)
1241-
1242-
1243-
def test_issue4445_rewrite(testdir):
1244-
"""#4445: Make sure the warning points to a reasonable location
1245-
See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241
1246-
"""
1247-
testdir.makepyfile(some_mod="")
1248-
testdir.makeconftest(
1249-
"""
1250-
import some_mod
1251-
import pytest
1252-
1253-
pytest.register_assert_rewrite("some_mod")
1254-
"""
1255-
)
1256-
result = testdir.runpytest()
1257-
# with stacklevel=5 the warning originates from register_assert_rewrite
1258-
# function in the created conftest.py
1259-
result.stdout.fnmatch_lines(
1260-
["*conftest.py:4*", "*Module already imported*", "*some_mod*"]
1261-
)
1262-
1263-
1264-
def test_issue4445_preparse(testdir):
1265-
"""#4445: Make sure the warning points to a reasonable location
1266-
See origin of _issue_warning_captured at: _pytest.config.__init__.py:910
1267-
"""
1268-
testdir.makeconftest(
1269-
"""
1270-
import nothing
1271-
"""
1272-
)
1273-
result = testdir.runpytest("--help")
1274-
# with stacklevel=2 the warning originates from config._preparse and is
1275-
# thrown by an errorneous conftest.py
1276-
result.stdout.fnmatch_lines_random(
1277-
[
1278-
"*config{sep}__init__.py:915*".format(sep=os.sep),
1279-
"*could not load initial conftests*",
1280-
]
1281-
)
1282-
1283-
1284-
def test_issue4445_import_plugin(testdir):
1285-
"""#4445: Make sure the warning points to a reasonable location
1286-
See origin of _issue_warning_captured at: _pytest.config.__init__.py:585
1287-
"""
1288-
testdir.makepyfile(
1289-
some_plugin="""
1290-
import pytest
1291-
pytest.skip("thing", allow_module_level=True)
1292-
"""
1293-
)
1294-
result = testdir.runpytest("-p", "some_plugin", syspathinsert=True)
1295-
# with stacklevel=2 the warning originates from
1296-
# config.PytestPluginManager.import_plugin is thrown by a skipped plugin
1297-
result.stdout.fnmatch_lines(
1298-
[
1299-
"*config{sep}__init__.py:588*".format(sep=os.sep),
1300-
"*skipped plugin 'some_plugin': thing*",
1301-
]
1302-
)
1303-
1304-
1305-
def test_issue4445_resultlog(testdir):
1306-
"""#4445: Make sure the warning points to a reasonable location
1307-
See origin of _issue_warning_captured at: _pytest.resultlog.py:35
1308-
"""
1309-
testdir.makepyfile(
1310-
"""
1311-
def test_dummy():
1312-
pass
1313-
"""
1314-
)
1315-
result = testdir.runpytest(
1316-
"--result-log={dir}".format(dir=testdir.tmpdir.join("result.log"))
1317-
)
1318-
# with stacklevel=2 the warning originates from resultlog.pytest_configure
1319-
# and is thrown when --result-log is used
1320-
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)