File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
src/frequenz/repo/config/nox Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,15 @@ class Config:
8484 tools invoked by the sessions.
8585 """
8686
87+ def __post_init__ (self ) -> None :
88+ """Initialize the configuration object.
89+
90+ This will add extra paths discovered in config files and other sources.
91+ """
92+ for path in util .discover_paths ():
93+ if path not in self .extra_paths :
94+ self .extra_paths .append (path )
95+
8796 def copy (self , / ) -> Self :
8897 """Create a new object as a copy of self.
8998
Original file line number Diff line number Diff line change @@ -170,3 +170,30 @@ def min_dependencies() -> list[str]:
170170 else :
171171 raise RuntimeError (f"Minimum requirement is not set: { dep } " )
172172 return min_deps
173+
174+
175+ def discover_paths () -> list [str ]:
176+ """Discover paths to check.
177+
178+ Discover the paths to check by looking into different sources, like the
179+ `pyproject.toml` file.
180+
181+ Currently the following paths are discovered:
182+
183+ - The `testpaths` option in the `tools.pytest.ini_options` section of
184+ `pyproject.toml`.
185+
186+ Returns:
187+ The discovered paths to check.
188+ """
189+ with open ("pyproject.toml" , "rb" ) as toml_file :
190+ data = tomllib .load (toml_file )
191+
192+ testpaths = (
193+ data .get ("tool" , {})
194+ .get ("pytest" , {})
195+ .get ("ini_options" , {})
196+ .get ("testpaths" , [])
197+ )
198+
199+ return testpaths
You can’t perform that action at this time.
0 commit comments