Mercurial > hg
changeset 27785:ba427b51f1d8
util: rename ctxmanager's __call__ method to enter
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Thu, 14 Jan 2016 09:31:01 -0800 |
parents | 432242f41d9f |
children | 4a7dc29bfad8 |
files | mercurial/util.py tests/test-ctxmanager.py |
diffstat | 2 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Wed Jan 13 21:52:26 2016 -0800 +++ b/mercurial/util.py Thu Jan 14 09:31:01 2016 -0800 @@ -2655,7 +2655,7 @@ def __enter__(self): return self - def __call__(self): + def enter(self): '''Create and enter context managers in the order in which they were passed to the constructor.''' values = []
--- a/tests/test-ctxmanager.py Wed Jan 13 21:52:26 2016 -0800 +++ b/tests/test-ctxmanager.py Thu Jan 14 09:31:01 2016 -0800 @@ -45,7 +45,7 @@ trace = [] addtrace = trace.append with ctxmanager(ctxmgr('a', addtrace), ctxmgr('b', addtrace)) as c: - a, b = c() + a, b = c.enter() c.atexit(addtrace, ('atexit', 'x')) c.atexit(addtrace, ('atexit', 'y')) self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'), @@ -58,7 +58,7 @@ with self.assertRaises(ctxerror): with ctxmanager(ctxmgr('a', addtrace), lambda: raise_on_enter('b', addtrace)) as c: - c() + c.enter() addtrace('unreachable') self.assertEqual(trace, [('enter', 'a'), ('raise', 'b'), ('exit', 'a')]) @@ -68,7 +68,7 @@ with self.assertRaises(ctxerror): with ctxmanager(ctxmgr('a', addtrace), lambda: raise_on_exit('b', addtrace)) as c: - c() + c.enter() addtrace('running') self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'), 'running', ('raise', 'b'), ('exit', 'a')])