test: Change `print_exc()` to `format_exc()`
test: Change `print_exc()` to `format_exc()`

`print_exc()` prints to given fd and returns None. `format_exc()`
returns the string, that `print_exc()` would print.

Closes #13740
moraleslazaro/cockpit,garrett/cockpit,deryni/cockpit,martinpitt/cockpit,cockpituous/cockpit,mvollmer/cockpit,martinpitt/cockpit,cockpit-project/cockpit,deryni/cockpit,cockpit-project/cockpit,cockpit-project/cockpit,cockpit-project/cockpit,cockpituous/cockpit,moraleslazaro/cockpit,deryni/cockpit,mvollmer/cockpit,cockpituous/cockpit,martinpitt/cockpit,garrett/cockpit,cockpituous/cockpit,deryni/cockpit,garrett/cockpit,cockpituous/cockpit,moraleslazaro/cockpit,moraleslazaro/cockpit,deryni/cockpit,garrett/cockpit,martinpitt/cockpit,mvollmer/cockpit,mvollmer/cockpit,garrett/cockpit,cockpituous/cockpit,moraleslazaro/cockpit,moraleslazaro/cockpit,mvollmer/cockpit,deryni/cockpit,deryni/cockpit,martinpitt/cockpit,moraleslazaro/cockpit,cockpit-project/cockpit