commit
92b436c938
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import stat
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
@ -45,26 +46,40 @@ class TestNewAPI:
|
||||||
)
|
)
|
||||||
def test_cache_writefail_permissions(self, testdir):
|
def test_cache_writefail_permissions(self, testdir):
|
||||||
testdir.makeini("[pytest]")
|
testdir.makeini("[pytest]")
|
||||||
|
cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))
|
||||||
|
mode = os.stat(cache_dir)[stat.ST_MODE]
|
||||||
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
|
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
|
||||||
config = testdir.parseconfigure()
|
try:
|
||||||
cache = config.cache
|
config = testdir.parseconfigure()
|
||||||
cache.set("test/broken", [])
|
cache = config.cache
|
||||||
|
cache.set("test/broken", [])
|
||||||
|
finally:
|
||||||
|
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows")
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows")
|
||||||
@pytest.mark.filterwarnings("default")
|
@pytest.mark.filterwarnings(
|
||||||
|
"ignore:could not create cache path:pytest.PytestWarning"
|
||||||
|
)
|
||||||
def test_cache_failure_warns(self, testdir):
|
def test_cache_failure_warns(self, testdir):
|
||||||
|
cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))
|
||||||
|
mode = os.stat(cache_dir)[stat.ST_MODE]
|
||||||
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
|
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
|
||||||
testdir.makepyfile(
|
try:
|
||||||
"""
|
testdir.makepyfile(
|
||||||
def test_error():
|
"""
|
||||||
raise Exception
|
def test_error():
|
||||||
|
raise Exception
|
||||||
|
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = testdir.runpytest("-rw")
|
result = testdir.runpytest("-rw")
|
||||||
assert result.ret == 1
|
assert result.ret == 1
|
||||||
# warnings from nodeids, lastfailed, and stepwise
|
# warnings from nodeids, lastfailed, and stepwise
|
||||||
result.stdout.fnmatch_lines(["*could not create cache path*", "*3 warnings*"])
|
result.stdout.fnmatch_lines(
|
||||||
|
["*could not create cache path*", "*3 warnings*"]
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
|
||||||
|
|
||||||
def test_config_cache(self, testdir):
|
def test_config_cache(self, testdir):
|
||||||
testdir.makeconftest(
|
testdir.makeconftest(
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -142,8 +142,6 @@ filterwarnings =
|
||||||
error
|
error
|
||||||
default:Using or importing the ABCs:DeprecationWarning:unittest2.*
|
default:Using or importing the ABCs:DeprecationWarning:unittest2.*
|
||||||
ignore:Module already imported so cannot be rewritten:pytest.PytestWarning
|
ignore:Module already imported so cannot be rewritten:pytest.PytestWarning
|
||||||
# https://github.com/pytest-dev/pytest/issues/5974
|
|
||||||
default:\(rm_rf\) error removing.*:pytest.PytestWarning
|
|
||||||
# produced by python3.6/site.py itself (3.6.7 on Travis, could not trigger it with 3.6.8).
|
# produced by python3.6/site.py itself (3.6.7 on Travis, could not trigger it with 3.6.8).
|
||||||
ignore:.*U.*mode is deprecated:DeprecationWarning:(?!(pytest|_pytest))
|
ignore:.*U.*mode is deprecated:DeprecationWarning:(?!(pytest|_pytest))
|
||||||
# produced by pytest-xdist
|
# produced by pytest-xdist
|
||||||
|
|
Loading…
Reference in New Issue