Move test_issue4445_cacheprovider_set into test_cache_failure_warns
Would need to be adjusted anyway non-trivially, and we can just harden `test_cache_failure_warns` instead.
This commit is contained in:
		
							parent
							
								
									02aa8adae1
								
							
						
					
					
						commit
						2b5adc88a7
					
				| 
						 | 
					@ -68,7 +68,15 @@ class TestNewAPI:
 | 
				
			||||||
            assert result.ret == 1
 | 
					            assert result.ret == 1
 | 
				
			||||||
            # warnings from nodeids, lastfailed, and stepwise
 | 
					            # warnings from nodeids, lastfailed, and stepwise
 | 
				
			||||||
            result.stdout.fnmatch_lines(
 | 
					            result.stdout.fnmatch_lines(
 | 
				
			||||||
                ["*could not create cache path*", "*3 warnings*"]
 | 
					                [
 | 
				
			||||||
 | 
					                    # Validate location/stacklevel of warning from cacheprovider.
 | 
				
			||||||
 | 
					                    "*= warnings summary =*",
 | 
				
			||||||
 | 
					                    "*/cacheprovider.py:314",
 | 
				
			||||||
 | 
					                    "  */cacheprovider.py:314: PytestCacheWarning: could not create cache path "
 | 
				
			||||||
 | 
					                    "{}/v/cache/nodeids".format(cache_dir),
 | 
				
			||||||
 | 
					                    '    config.cache.set("cache/nodeids", self.cached_nodeids)',
 | 
				
			||||||
 | 
					                    "*1 failed, 3 warnings in*",
 | 
				
			||||||
 | 
					                ]
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
 | 
					            testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -712,27 +712,6 @@ class TestStackLevel:
 | 
				
			||||||
        assert "resultlog.py" in file
 | 
					        assert "resultlog.py" in file
 | 
				
			||||||
        assert func == "pytest_configure"
 | 
					        assert func == "pytest_configure"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_issue4445_cacheprovider_set(self, testdir, capwarn):
 | 
					 | 
				
			||||||
        """#4445: Make sure the warning points to a reasonable location
 | 
					 | 
				
			||||||
        See origin of _issue_warning_captured at: _pytest.cacheprovider.py:59
 | 
					 | 
				
			||||||
        """
 | 
					 | 
				
			||||||
        testdir.tmpdir.join(".pytest_cache").write("something wrong")
 | 
					 | 
				
			||||||
        testdir.runpytest(plugins=[capwarn()])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # with stacklevel=3 the warning originates from one stacklevel above
 | 
					 | 
				
			||||||
        # _issue_warning_captured in cacheprovider.Cache.set and is thrown
 | 
					 | 
				
			||||||
        # when there are errors during cache folder creation
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # set is called twice (in module stepwise and in cacheprovider) so emits
 | 
					 | 
				
			||||||
        # two warnings when there are errors during cache folder creation. (is this intentional?)
 | 
					 | 
				
			||||||
        assert len(capwarn.captured) == 2
 | 
					 | 
				
			||||||
        warning, location = capwarn.captured.pop()
 | 
					 | 
				
			||||||
        file, lineno, func = location
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assert "could not create cache path" in str(warning.message)
 | 
					 | 
				
			||||||
        assert "cacheprovider.py" in file
 | 
					 | 
				
			||||||
        assert func == "set"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test_issue4445_issue5928_mark_generator(self, testdir):
 | 
					    def test_issue4445_issue5928_mark_generator(self, testdir):
 | 
				
			||||||
        """#4445 and #5928: Make sure the warning from an unknown mark points to
 | 
					        """#4445 and #5928: Make sure the warning from an unknown mark points to
 | 
				
			||||||
        the test file where this mark is used.
 | 
					        the test file where this mark is used.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue