Skip to content

Commit

Permalink
Remove EnvVarTestContext
Browse files Browse the repository at this point in the history
  • Loading branch information
agoncharov-reef committed Mar 26, 2024
1 parent 8657852 commit 78a1fdc
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions test/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import warnings
from dataclasses import dataclass
from datetime import datetime, timedelta
from os import environ, linesep, path
from os import environ, linesep
from pathlib import Path
from tempfile import mkdtemp, mktemp

Expand All @@ -47,7 +47,6 @@
InMemoryCache,
LegalHold,
RetentionMode,
SqliteAccountInfo,
fix_windows_path_limit,
)
from b2sdk.v2.exception import (
Expand Down Expand Up @@ -336,33 +335,6 @@ def read_from(self, f):
self.string = str(e)


class EnvVarTestContext:
"""
Establish config for environment variable test.
Copy the B2 credential file and rename the existing copy
"""
ENV_VAR = 'B2_ACCOUNT_INFO'

def __init__(self, account_info_file_name: str):
self.account_info_file_name = account_info_file_name
self.suffix = ''.join(RNG.choice('abcdefghijklmnopqrstuvwxyz0123456789') for _ in range(7))

def __enter__(self):
src = self.account_info_file_name
dst = path.join(mkdtemp(), 'b2_account_info')
shutil.copyfile(src, dst)
shutil.move(src, src + self.suffix)
environ[self.ENV_VAR] = dst
return dst

def __exit__(self, exc_type, exc_val, exc_tb):
os.remove(environ.get(self.ENV_VAR))
fname = self.account_info_file_name
shutil.move(fname + self.suffix, fname)
if environ.get(self.ENV_VAR) is not None:
del environ[self.ENV_VAR]


def should_equal(expected, actual):
print(' expected:')
print_json_indented(expected)
Expand Down Expand Up @@ -406,7 +378,6 @@ def __init__(
self.realm = realm
self.bucket_name_prefix = bucket_name_prefix
self.env_file_cmd_placeholder = env_file_cmd_placeholder
self.env_var_test_context = EnvVarTestContext(SqliteAccountInfo().filename)
self.api_wrapper = api_wrapper
self.b2_uri_args = b2_uri_args

Expand Down

0 comments on commit 78a1fdc

Please sign in to comment.