All jobs / Automation developer

Automation developer interview question · 1–3 years

You need setup and guaranteed teardown around a block. What do you write?

The strongest answer

A context manager — @contextlib.contextmanager with a yield between setup and cleanup in a finally, or a class with __enter__ and __exit__

Why it works

Exactly, and the finally around the yield is what makes it hold on the error path.

What a good answer covers

Answers that fall short

Who gets asked this

More Automation developer questions