tests: update test-util.py for modern attrs package
authorMatt Harbison <matt_harbison@yahoo.com>
Mon, 21 Nov 2022 16:18:28 -0500
changeset 49642 7e6f3c69c0fb
parent 49640 ab6151e1f468
child 49643 e1c586b9a43c
tests: update test-util.py for modern attrs package When updating to 22.1.0, this test started failing: Traceback (most recent call last): File "/tmp/mercurial-ci/tests/test-util.py", line 53, in <module> _start_default = (util.timedcmstats.start.default, 'factory') AttributeError: type object 'timedcmstats' has no attribute 'start' Poking around in `hg debugshell`, the attribute is indeed missing, but looks to be attached to `__attrs_attrs__` in both the currently vendored and the modern version of attrs. The old attrs packages will print the same for both accesses, so fingers crossed... >>> print((util.timedcmstats.start.default, 'factory')) (Factory(factory=<function timedcmstats.<lambda> at 0x000001EFDF0F21F0>, takes_self=False), 'factory') >>> print((util.timedcmstats.__attrs_attrs__.start.default, 'factory')) (Factory(factory=<function timedcmstats.<lambda> at 0x000001EFDF0F21F0>, takes_self=False), 'factory')
tests/test-util.py
--- a/tests/test-util.py	Tue Nov 15 01:52:46 2022 +0100
+++ b/tests/test-util.py	Mon Nov 21 16:18:28 2022 -0500
@@ -50,7 +50,7 @@
 
 # attr.s default factory for util.timedstats.start binds the timer we
 # need to mock out.
-_start_default = (util.timedcmstats.start.default, 'factory')
+_start_default = (util.timedcmstats.__attrs_attrs__.start.default, 'factory')
 
 
 @contextlib.contextmanager