1 # SPDX-License-Identifier: LGPL-3-or-later
2 # See Notices.txt for copyright information
5 from pathlib
import Path
10 self
.__run
_counts
= {}
11 """dict mapping self.next() keys to the next int value returned by
15 """get a incrementing run counter for a `str` key `k`. returns an `int`."""
16 retval
= self
.__run
_counts
.get(k
, 0)
17 self
.__run
_counts
[k
] = retval
+ 1
21 """dict mapping object ids (int) to a tuple of a weakref.ref to that
22 object, and the corresponding RunCounter"""
27 t
= RunCounter
.__RUN
_COUNTERS
35 t
[k
] = weakref
.ref(obj
, on_finalize
), retval
39 def get_test_path(test_case
, base_path
):
40 """get the `Path` for a particular unittest.TestCase instance
41 (`test_case`). base_path is either a str or a path-like."""
42 count
= RunCounter
.get(test_case
).next(test_case
.id())
43 return Path(base_path
) / test_case
.id() / str(count
)