The test passes without this change, so I am still wondering why this is needed.
Also, the commit doesn’t seem to be exhaustive. The wallet.dat/bad should be replaced as well. Also, the usages in tool_wallet.py. See the diff I used for testing:
  0diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
  1index bd1d114730..89d7325e1c 100644
  2--- a/src/wallet/db.cpp
  3+++ b/src/wallet/db.cpp
  4@@ -20,6 +20,6 @@ void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::
  5         // Normal case: Interpret wallet path as a directory path containing
  6         // data and log files.
  7         env_directory = wallet_path;
  8-        database_filename = "wallet.dat";
  9+        database_filename = "wallet_dat";
 10     }
 11 }
 12diff --git a/src/wallet/test/db_tests.cpp b/src/wallet/test/db_tests.cpp
 13index 8f0083cd2e..3489d48879 100644
 14--- a/src/wallet/test/db_tests.cpp
 15+++ b/src/wallet/test/db_tests.cpp
 16@@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(getwalletenv_file)
 17 
 18 BOOST_AUTO_TEST_CASE(getwalletenv_directory)
 19 {
 20-    std::string expected_name = "wallet.dat";
 21+    std::string expected_name = "wallet_dat";
 22     const fs::path datadir = GetDataDir();
 23 
 24     std::string filename;
 25diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp
 26index e4c72aed98..3a16cb3e75 100644
 27--- a/src/wallet/walletutil.cpp
 28+++ b/src/wallet/walletutil.cpp
 29@@ -71,11 +71,11 @@ std::vector<fs::path> ListWalletDir()
 30         // This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
 31         const fs::path path = it->path().string().substr(offset);
 32 
 33-        if (it->status().type() == fs::directory_file && IsBerkeleyBtree(it->path() / "wallet.dat")) {
 34+        if (it->status().type() == fs::directory_file && IsBerkeleyBtree(it->path() / "wallet_dat")) {
 35             // Found a directory which contains wallet.dat btree file, add it as a wallet.
 36             paths.emplace_back(path);
 37         } else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && IsBerkeleyBtree(it->path())) {
 38-            if (it->path().filename() == "wallet.dat") {
 39+            if (it->path().filename() == "wallet_dat") {
 40                 // Found top-level wallet.dat btree file, add top level directory ""
 41                 // as a wallet.
 42                 paths.emplace_back();
 43diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
 44index 100be26c59..fa72420178 100755
 45--- a/test/functional/test_framework/test_framework.py
 46+++ b/test/functional/test_framework/test_framework.py
 47@@ -103,7 +103,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
 48         self.supports_cli = True
 49         self.bind_to_localhost_only = True
 50         self.default_wallet_name = ""
 51-        self.wallet_data_filename = "wallet.dat"
 52+        self.wallet_data_filename = "wallet_dat"
 53         self.set_test_params()
 54         self.parse_args()
 55         if self.options.timeout_factor == 0 :
 56diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py
 57index ef68e224b6..8d3e7f8f62 100755
 58--- a/test/functional/tool_wallet.py
 59+++ b/test/functional/tool_wallet.py
 60@@ -73,7 +73,7 @@ class ToolWalletTest(BitcoinTestFramework):
 61         locked_dir = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets")
 62         self.assert_raises_tool_error(
 63             'Error initializing wallet database environment "{}"!'.format(locked_dir),
 64-            '-wallet=wallet.dat',
 65+            '-wallet=wallet_dat',
 66             'info',
 67         )
 68         path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "nonexistent.dat")
 69@@ -104,7 +104,7 @@ class ToolWalletTest(BitcoinTestFramework):
 70             Transactions: 0
 71             Address Book: 3
 72         ''')
 73-        self.assert_tool_output(out, '-wallet=wallet.dat', 'info')
 74+        self.assert_tool_output(out, '-wallet=wallet_dat', 'info')
 75         timestamp_after = self.wallet_timestamp()
 76         self.log.debug('Wallet file timestamp after calling info: {}'.format(timestamp_after))
 77         self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after)
 78@@ -143,7 +143,7 @@ class ToolWalletTest(BitcoinTestFramework):
 79             Transactions: 1
 80             Address Book: 3
 81         ''')
 82-        self.assert_tool_output(out, '-wallet=wallet.dat', 'info')
 83+        self.assert_tool_output(out, '-wallet=wallet_dat', 'info')
 84         shasum_after = self.wallet_shasum()
 85         timestamp_after = self.wallet_timestamp()
 86         self.log.debug('Wallet file timestamp after calling info: {}'.format(timestamp_after))
 87diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py
 88index 09581d864b..5fdabf89c8 100755
 89--- a/test/functional/wallet_dump.py
 90+++ b/test/functional/wallet_dump.py
 91@@ -203,7 +203,7 @@ class WalletDumpTest(BitcoinTestFramework):
 92         assert result['ismine']
 93 
 94         self.log.info('Check that wallet is flushed')
 95-        with self.nodes[0].assert_debug_log(['Flushing wallet.dat'], timeout=20):
 96+        with self.nodes[0].assert_debug_log(['Flushing wallet_dat'], timeout=20):
 97             self.nodes[0].getnewaddress()
 98 
 99 
100diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py
101index 7b975af065..71aa86abdb 100755
102--- a/test/functional/wallet_multiwallet.py
103+++ b/test/functional/wallet_multiwallet.py
104@@ -95,7 +95,7 @@ class MultiWalletTest(BitcoinTestFramework):
105         #   w8         - to verify existing wallet file is loaded correctly
106         #   ''         - to verify default wallet file is created correctly
107         wallet_names = ['w1', 'w2', 'w3', 'w', 'sub/w5', os.path.join(self.options.tmpdir, 'extern/w6'), 'w7_symlink', 'w8', self.default_wallet_name]
108-        extra_args = ['-nowallet'] + ['-wallet={}'.format(n) for n in wallet_names]
109+        extra_args = ['-wallet={}'.format(n) for n in wallet_names]
110         self.start_node(0, extra_args)
111         assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8'])
112 
113@@ -108,7 +108,7 @@ class MultiWalletTest(BitcoinTestFramework):
114 
115         # should not initialize if wallet path can't be created
116         exp_stderr = "boost::filesystem::create_directory:"
117-        self.nodes[0].assert_start_raises_init_error(['-wallet=wallet.dat/bad'], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
118+        self.nodes[0].assert_start_raises_init_error(['-wallet={}/bad'.format(self.wallet_data_filename)], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
119 
120         self.nodes[0].assert_start_raises_init_error(['-walletdir=wallets'], 'Error: Specified -walletdir "wallets" does not exist')
121         self.nodes[0].assert_start_raises_init_error(['-walletdir=wallets'], 'Error: Specified -walletdir "wallets" is a relative path', cwd=data_dir())