@@ -387,7 +387,9 @@ def __init__(self, config: Config, file: TextIO | None = None) -> None:
387
387
self .reportchars = getreportopt (config )
388
388
self .foldskipped = config .option .fold_skipped
389
389
self .hasmarkup = self ._tw .hasmarkup
390
- self .isatty = file .isatty ()
390
+ # isatty should be a method but was wrongly implemented as a boolean.
391
+ # We use _CallableBool here to support both.
392
+ self .isatty = _CallableBool (file .isatty ())
391
393
self ._progress_nodeids_reported : set [str ] = set ()
392
394
self ._timing_nodeids_reported : set [str ] = set ()
393
395
self ._show_progress_info = self ._determine_show_progress_info ()
@@ -766,7 +768,7 @@ def _width_of_current_line(self) -> int:
766
768
return self ._tw .width_of_current_line
767
769
768
770
def pytest_collection (self ) -> None :
769
- if self .isatty :
771
+ if self .isatty () :
770
772
if self .config .option .verbose >= 0 :
771
773
self .write ("collecting ... " , flush = True , bold = True )
772
774
elif self .config .option .verbose >= 1 :
@@ -779,7 +781,7 @@ def pytest_collectreport(self, report: CollectReport) -> None:
779
781
self ._add_stats ("skipped" , [report ])
780
782
items = [x for x in report .result if isinstance (x , Item )]
781
783
self ._numcollected += len (items )
782
- if self .isatty :
784
+ if self .isatty () :
783
785
self .report_collect ()
784
786
785
787
def report_collect (self , final : bool = False ) -> None :
@@ -811,7 +813,7 @@ def report_collect(self, final: bool = False) -> None:
811
813
line += f" / { skipped } skipped"
812
814
if self ._numcollected > selected :
813
815
line += f" / { selected } selected"
814
- if self .isatty :
816
+ if self .isatty () :
815
817
self .rewrite (line , bold = True , erase = True )
816
818
if final :
817
819
self .write ("\n " )
@@ -1636,3 +1638,14 @@ def _get_raw_skip_reason(report: TestReport) -> str:
1636
1638
elif reason == "Skipped" :
1637
1639
reason = ""
1638
1640
return reason
1641
+
1642
+
1643
+ class _CallableBool :
1644
+ def __init__ (self , value : bool ):
1645
+ self ._value = value
1646
+
1647
+ def __bool__ (self ):
1648
+ return self ._value
1649
+
1650
+ def __call__ (self ):
1651
+ return self ._value
0 commit comments