@@ -95,7 +95,7 @@ def __init__(self, config, file=None):
9595 self ._numcollected = 0
9696
9797 self .stats = {}
98- self .startdir = self . curdir = py .path .local ()
98+ self .startdir = py .path .local ()
9999 if file is None :
100100 file = sys .stdout
101101 self ._tw = self .writer = py .io .TerminalWriter (file )
@@ -111,12 +111,12 @@ def hasopt(self, char):
111111 char = {'xfailed' : 'x' , 'skipped' : 's' }.get (char , char )
112112 return char in self .reportchars
113113
114- def write_fspath_result (self , fspath , res ):
114+ def write_fspath_result (self , nodeid , res ):
115+ fspath = self .config .rootdir .join (nodeid .split ("::" )[0 ])
115116 if fspath != self .currentfspath :
116117 self .currentfspath = fspath
117- # fspath = self.startdir.bestrelpath(fspath)
118+ fspath = self .startdir .bestrelpath (fspath )
118119 self ._tw .line ()
119- #relpath = self.startdir.bestrelpath(fspath)
120120 self ._tw .write (fspath + " " )
121121 self ._tw .write (res )
122122
@@ -182,12 +182,12 @@ def pytest_deselected(self, items):
182182 def pytest_runtest_logstart (self , nodeid , location ):
183183 # ensure that the path is printed before the
184184 # 1st test of a module starts running
185- fspath = nodeid .split ("::" )[0 ]
186185 if self .showlongtestinfo :
187- line = self ._locationline (fspath , * location )
186+ line = self ._locationline (nodeid , * location )
188187 self .write_ensure_prefix (line , "" )
189188 elif self .showfspath :
190- self .write_fspath_result (fspath , "" )
189+ fsid = nodeid .split ("::" )[0 ]
190+ self .write_fspath_result (fsid , "" )
191191
192192 def pytest_runtest_logreport (self , report ):
193193 rep = report
@@ -200,7 +200,7 @@ def pytest_runtest_logreport(self, report):
200200 return
201201 if self .verbosity <= 0 :
202202 if not hasattr (rep , 'node' ) and self .showfspath :
203- self .write_fspath_result (rep .fspath , letter )
203+ self .write_fspath_result (rep .nodeid , letter )
204204 else :
205205 self ._tw .write (letter )
206206 else :
@@ -213,7 +213,7 @@ def pytest_runtest_logreport(self, report):
213213 markup = {'red' :True }
214214 elif rep .skipped :
215215 markup = {'yellow' :True }
216- line = self ._locationline (str ( rep .fspath ) , * rep .location )
216+ line = self ._locationline (rep .nodeid , * rep .location )
217217 if not hasattr (rep , 'node' ):
218218 self .write_ensure_prefix (line , word , ** markup )
219219 #self._tw.write(word, **markup)
@@ -237,7 +237,7 @@ def pytest_collectreport(self, report):
237237 items = [x for x in report .result if isinstance (x , pytest .Item )]
238238 self ._numcollected += len (items )
239239 if self .hasmarkup :
240- #self.write_fspath_result(report.fspath , 'E')
240+ #self.write_fspath_result(report.nodeid , 'E')
241241 self .report_collect ()
242242
243243 def report_collect (self , final = False ):
@@ -288,6 +288,10 @@ def pytest_sessionstart(self, session):
288288 self .write_line (line )
289289
290290 def pytest_report_header (self , config ):
291+ inifile = ""
292+ if config .inifile :
293+ inifile = config .rootdir .bestrelpath (config .inifile )
294+ lines = ["rootdir: %s, inifile: %s" % (config .rootdir , inifile )]
291295 plugininfo = config .pluginmanager ._plugin_distinfo
292296 if plugininfo :
293297 l = []
@@ -296,7 +300,8 @@ def pytest_report_header(self, config):
296300 if name .startswith ("pytest-" ):
297301 name = name [7 :]
298302 l .append (name )
299- return "plugins: %s" % ", " .join (l )
303+ lines .append ("plugins: %s" % ", " .join (l ))
304+ return lines
300305
301306 def pytest_collection_finish (self , session ):
302307 if self .config .option .collectonly :
@@ -378,19 +383,24 @@ def _report_keyboardinterrupt(self):
378383 else :
379384 excrepr .reprcrash .toterminal (self ._tw )
380385
381- def _locationline (self , collect_fspath , fspath , lineno , domain ):
386+ def _locationline (self , nodeid , fspath , lineno , domain ):
387+ def mkrel (nodeid ):
388+ line = self .config .cwd_relative_nodeid (nodeid )
389+ if domain and line .endswith (domain ):
390+ line = line [:- len (domain )]
391+ l = domain .split ("[" )
392+ l [0 ] = l [0 ].replace ('.' , '::' ) # don't replace '.' in params
393+ line += "[" .join (l )
394+ return line
382395 # collect_fspath comes from testid which has a "/"-normalized path
383- if fspath and fspath .replace ("\\ " , "/" ) != collect_fspath :
384- fspath = "%s <- %s" % (collect_fspath , fspath )
396+
385397 if fspath :
386- line = str (fspath )
387- if domain :
388- split = str (domain ).split ('[' )
389- split [0 ] = split [0 ].replace ('.' , '::' ) # don't replace '.' in params
390- line += "::" + '[' .join (split )
398+ res = mkrel (nodeid ).replace ("::()" , "" ) # parens-normalization
399+ if nodeid .split ("::" )[0 ] != fspath .replace ("\\ " , "/" ):
400+ res += " <- " + self .startdir .bestrelpath (fspath )
391401 else :
392- line = "[location]"
393- return line + " "
402+ res = "[location]"
403+ return res + " "
394404
395405 def _getfailureheadline (self , rep ):
396406 if hasattr (rep , 'location' ):
0 commit comments