comparison tests/test-util.py @ 49642:7e6f3c69c0fb

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')
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 Nov 2022 16:18:28 -0500
parents 6000f5b25c9b
children
comparison
equal deleted inserted replaced
49641:ab6151e1f468 49642:7e6f3c69c0fb
48 setattr(*args) 48 setattr(*args)
49 49
50 50
51 # attr.s default factory for util.timedstats.start binds the timer we 51 # attr.s default factory for util.timedstats.start binds the timer we
52 # need to mock out. 52 # need to mock out.
53 _start_default = (util.timedcmstats.start.default, 'factory') 53 _start_default = (util.timedcmstats.__attrs_attrs__.start.default, 'factory')
54 54
55 55
56 @contextlib.contextmanager 56 @contextlib.contextmanager
57 def capturestderr(): 57 def capturestderr():
58 """Replace utils.procutil.stderr with an io.BytesIO instance 58 """Replace utils.procutil.stderr with an io.BytesIO instance