@@ -68,11 +68,9 @@ def test_migrate_to_4(self):
6868
6969class TestSqliteAccountProfileFileLocation :
7070 @pytest .fixture (autouse = True )
71- def setup (self , monkeypatch ):
71+ def setup (self , monkeypatch , fs ):
7272 monkeypatch .delenv (B2_ACCOUNT_INFO_ENV_VAR , raising = False )
7373 monkeypatch .delenv (XDG_CONFIG_HOME_ENV_VAR , raising = False )
74- if os .path .exists (os .path .expanduser (B2_ACCOUNT_INFO_DEFAULT_FILE )):
75- os .remove (os .path .expanduser (B2_ACCOUNT_INFO_DEFAULT_FILE ))
7674
7775 def test_invalid_profile_name (self ):
7876 with pytest .raises (ValueError ):
@@ -112,7 +110,10 @@ def test_env_var(self, monkeypatch):
112110 def test_default_file_if_exists (self , monkeypatch ):
113111 # ensure that XDG_CONFIG_HOME_ENV_VAR doesn't matter if default file exists
114112 monkeypatch .setenv (XDG_CONFIG_HOME_ENV_VAR , 'some' )
115- with open (os .path .expanduser (B2_ACCOUNT_INFO_DEFAULT_FILE ), 'w' ) as account_file :
113+ account_file_path = os .path .expanduser (B2_ACCOUNT_INFO_DEFAULT_FILE )
114+ parent_dir = os .path .abspath (os .path .join (account_file_path , os .pardir ))
115+ os .makedirs (parent_dir , exist_ok = True )
116+ with open (account_file_path , 'w' ) as account_file :
116117 account_file .write ('' )
117118 account_info_path = SqliteAccountInfo ._get_user_account_info_path ()
118119 assert account_info_path == os .path .expanduser (B2_ACCOUNT_INFO_DEFAULT_FILE )
0 commit comments