Avoided transaction.set_autocommit in tests.

It doesn't work as one might expect on a certain database backend where
autocommits_when_autocommit_is_off = True. That backend happens to be
popular for running tests.

Backport of 38bc581bc02d83ecab6d19514ac51b57f0e11866 from master.
Fixed #20724 -- Test failure on SQLite.

This test failure happened if the connection's NAME was set to a file
system path, and its TEST_NAME wasn't.

Thanks Claude for the report.

Conflicts:
	tests/transactions_regress/tests.py

Backport of 404870ee1f0d15f6b81d0e0b059068b1f020b2f1 from master.