config: stop resolving symlinks in conftest paths
This became the wrong thing to do since
322190fd84.
			
			
This commit is contained in:
		
							parent
							
								
									d98b695fec
								
							
						
					
					
						commit
						0ef882364e
					
				| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					Symbolic link components are no longer resolved in conftest paths.
 | 
				
			||||||
 | 
					This means that if a conftest appears twice in collection tree, using symlinks, it will be executed twice.
 | 
				
			||||||
 | 
					For example, given
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    tests/real/conftest.py
 | 
				
			||||||
 | 
					    tests/real/test_it.py
 | 
				
			||||||
 | 
					    tests/link -> tests/real
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					running ``pytest tests`` now imports the conftest twice, once as ``tests/real/conftest.py`` and once as ``tests/link/conftest.py``.
 | 
				
			||||||
 | 
					This is a fix to match a similar change made to test collection itself in pytest 6.0 (see :pull:`6523` for details).
 | 
				
			||||||
| 
						 | 
					@ -592,15 +592,8 @@ class PytestPluginManager(PluginManager):
 | 
				
			||||||
    def _importconftest(
 | 
					    def _importconftest(
 | 
				
			||||||
        self, conftestpath: Path, importmode: Union[str, ImportMode], rootpath: Path
 | 
					        self, conftestpath: Path, importmode: Union[str, ImportMode], rootpath: Path
 | 
				
			||||||
    ) -> types.ModuleType:
 | 
					    ) -> types.ModuleType:
 | 
				
			||||||
        # Use a resolved Path object as key to avoid loading the same conftest
 | 
					 | 
				
			||||||
        # twice with build systems that create build directories containing
 | 
					 | 
				
			||||||
        # symlinks to actual files.
 | 
					 | 
				
			||||||
        # Using Path().resolve() is better than py.path.realpath because
 | 
					 | 
				
			||||||
        # it resolves to the correct path/drive in case-insensitive file systems (#5792)
 | 
					 | 
				
			||||||
        key = conftestpath.resolve()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        with contextlib.suppress(KeyError):
 | 
					        with contextlib.suppress(KeyError):
 | 
				
			||||||
            return self._conftestpath2mod[key]
 | 
					            return self._conftestpath2mod[conftestpath]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pkgpath = resolve_package_path(conftestpath)
 | 
					        pkgpath = resolve_package_path(conftestpath)
 | 
				
			||||||
        if pkgpath is None:
 | 
					        if pkgpath is None:
 | 
				
			||||||
| 
						 | 
					@ -616,7 +609,7 @@ class PytestPluginManager(PluginManager):
 | 
				
			||||||
        self._check_non_top_pytest_plugins(mod, conftestpath)
 | 
					        self._check_non_top_pytest_plugins(mod, conftestpath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self._conftest_plugins.add(mod)
 | 
					        self._conftest_plugins.add(mod)
 | 
				
			||||||
        self._conftestpath2mod[key] = mod
 | 
					        self._conftestpath2mod[conftestpath] = mod
 | 
				
			||||||
        dirpath = conftestpath.parent
 | 
					        dirpath = conftestpath.parent
 | 
				
			||||||
        if dirpath in self._dirpath2confmods:
 | 
					        if dirpath in self._dirpath2confmods:
 | 
				
			||||||
            for path, mods in self._dirpath2confmods.items():
 | 
					            for path, mods in self._dirpath2confmods.items():
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue