From ea9a491fb3aae3580e17a1c1ef073afe7860df0d Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 22 Sep 2015 20:24:37 +0200 Subject: [PATCH] add an acceptance test for cache write errors --- _pytest/cacheprovider.py | 2 +- testing/test_cache.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/_pytest/cacheprovider.py b/_pytest/cacheprovider.py index 6fa92e59d..e4ae64ab3 100755 --- a/_pytest/cacheprovider.py +++ b/_pytest/cacheprovider.py @@ -73,7 +73,7 @@ class Cache(object): path.dirpath().ensure_dir() except (py.error.EEXIST, py.error.EACCES): self.config.warn( - code='I9', message='cache could not create cache path %s' % (path,) + code='I9', message='could not create cache path %s' % (path,) ) return try: diff --git a/testing/test_cache.py b/testing/test_cache.py index 5205014e3..bd33c1c7d 100755 --- a/testing/test_cache.py +++ b/testing/test_cache.py @@ -32,13 +32,26 @@ class TestNewAPI: cache = config.cache cache.set('test/broken', []) - def test_cache_writefail_permissions(selfself, testdir): + def test_cache_writefail_permissions(self, testdir): testdir.makeini("[pytest]") testdir.tmpdir.ensure_dir('.cache').chmod(0) config = testdir.parseconfigure() cache = config.cache cache.set('test/broken', []) + def test_cache_failure_warns(self, testdir): + testdir.tmpdir.ensure_dir('.cache').chmod(0) + testdir.makepyfile(""" + def test_pass(): + pass + + """) + result = testdir.runpytest('-rw') + assert result.ret == 0 + result.stdout.fnmatch_lines([ + "*could not create cache path*", + "*1 pytest-warnings*", + ]) def test_config_cache(self, testdir): testdir.makeconftest("""