cacheprovider: pytest_collection_modifyitems: copy items
This commit is contained in:
		
							parent
							
								
									e8c8559efa
								
							
						
					
					
						commit
						2d2c67d7c0
					
				| 
						 | 
					@ -258,7 +258,7 @@ class LFPlugin:
 | 
				
			||||||
            self._report_status = "no previously failed tests, "
 | 
					            self._report_status = "no previously failed tests, "
 | 
				
			||||||
            if self.config.getoption("last_failed_no_failures") == "none":
 | 
					            if self.config.getoption("last_failed_no_failures") == "none":
 | 
				
			||||||
                self._report_status += "deselecting all items."
 | 
					                self._report_status += "deselecting all items."
 | 
				
			||||||
                config.hook.pytest_deselected(items=items)
 | 
					                config.hook.pytest_deselected(items=items[:])
 | 
				
			||||||
                items[:] = []
 | 
					                items[:] = []
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self._report_status += "not deselecting items."
 | 
					                self._report_status += "not deselecting items."
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -681,11 +681,28 @@ class TestLastFailed:
 | 
				
			||||||
        result.stdout.fnmatch_lines(["*2 passed*"])
 | 
					        result.stdout.fnmatch_lines(["*2 passed*"])
 | 
				
			||||||
        result = testdir.runpytest("--lf", "--lfnf", "all")
 | 
					        result = testdir.runpytest("--lf", "--lfnf", "all")
 | 
				
			||||||
        result.stdout.fnmatch_lines(["*2 passed*"])
 | 
					        result.stdout.fnmatch_lines(["*2 passed*"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Ensure the list passed to pytest_deselected is a copy,
 | 
				
			||||||
 | 
					        # and not a reference which is cleared right after.
 | 
				
			||||||
 | 
					        testdir.makeconftest(
 | 
				
			||||||
 | 
					            """
 | 
				
			||||||
 | 
					            deselected = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            def pytest_deselected(items):
 | 
				
			||||||
 | 
					                global deselected
 | 
				
			||||||
 | 
					                deselected = items
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            def pytest_sessionfinish():
 | 
				
			||||||
 | 
					                print("\\ndeselected={}".format(len(deselected)))
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        result = testdir.runpytest("--lf", "--lfnf", "none")
 | 
					        result = testdir.runpytest("--lf", "--lfnf", "none")
 | 
				
			||||||
        result.stdout.fnmatch_lines(
 | 
					        result.stdout.fnmatch_lines(
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                "collected 2 items / 2 deselected",
 | 
					                "collected 2 items / 2 deselected",
 | 
				
			||||||
                "run-last-failure: no previously failed tests, deselecting all items.",
 | 
					                "run-last-failure: no previously failed tests, deselecting all items.",
 | 
				
			||||||
 | 
					                "deselected=2",
 | 
				
			||||||
                "* 2 deselected in *",
 | 
					                "* 2 deselected in *",
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue