Skip to content

Commit be77460

Browse files
Merge pull request #1076 from reef-technologies/pexpect
Fix pexpect issue in integration tests, lint
2 parents ed4f448 + d3ab7bf commit be77460

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ build
1313
coverage.xml
1414
dist
1515
venv
16+
.venv
1617
doc/source/main_help.rst
1718
doc/source/subcommands
1819
Dockerfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Increase terminal size window in autocomplete integration tests.

test/integration/conftest.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,12 @@ def b2_uri_args(apiver_int):
427427

428428
subfolder_list: list[str] = []
429429

430-
@pytest.fixture(scope="session")
430+
431+
@pytest.fixture(scope='session')
431432
def base_persistent_bucket(b2_api):
432433
bucket = get_or_create_persistent_bucket(b2_api)
433434
yield bucket
434-
prune_used_files(b2_api=b2_api,bucket=bucket, folders=subfolder_list)
435+
prune_used_files(b2_api=b2_api, bucket=bucket, folders=subfolder_list)
435436

436437

437438
@pytest.fixture
@@ -442,13 +443,13 @@ def unique_subfolder():
442443

443444

444445
@pytest.fixture
445-
def persistent_bucket(unique_subfolder,
446-
base_persistent_bucket) -> Generator[PersistentBucketAggregate]:
446+
def persistent_bucket(
447+
unique_subfolder, base_persistent_bucket
448+
) -> Generator[PersistentBucketAggregate]:
447449
"""
448450
Since all consumers of the `bucket_name` fixture expect a new bucket to be created,
449451
we need to mirror this behavior by appending a unique subfolder to the persistent bucket name.
450452
"""
451-
yield PersistentBucketAggregate(base_persistent_bucket.name,
452-
unique_subfolder)
453+
yield PersistentBucketAggregate(base_persistent_bucket.name, unique_subfolder)
453454

454-
logger.info("Persistent bucket aggregate finished completion.")
455+
logger.info('Persistent bucket aggregate finished completion.')

test/integration/helpers.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ def bucket_name_part(length: int) -> str:
132132
logger.info('name_part: %s', name_part)
133133
return name_part
134134

135+
135136
T = TypeVar('T')
137+
138+
136139
def wrap_iterables(generators: list[Iterable[T]]):
137140
for g in generators:
138141
yield from g
139142

143+
140144
@dataclass
141145
class Api:
142146
account_id: str
@@ -224,20 +228,26 @@ def clean_buckets(self, quick=False):
224228
TooManyRequests,
225229
max_tries=8,
226230
)
227-
def clean_bucket(self, bucket_object: Bucket | str, only_files: bool = False, only_folders: list[str] | None = None, ignore_retentions: bool = False):
231+
def clean_bucket(
232+
self,
233+
bucket_object: Bucket | str,
234+
only_files: bool = False,
235+
only_folders: list[str] | None = None,
236+
ignore_retentions: bool = False,
237+
):
228238
"""
229239
Clean contents of bucket, by default also deleting the bucket.
230240
231-
Args:
232-
bucket (Bucket | str): Bucket object or name
233-
only_files (bool): If to only delete files and not the bucket
241+
Args:
242+
bucket (Bucket | str): Bucket object or name
243+
only_files (bool): If to only delete files and not the bucket
234244
only_folders (list[str] | None): If not None, filter to only files in given folders.
235245
ignore_retentions (bool): If deletion should happen regardless of files' retention mode.
236246
"""
237247
bucket: Bucket
238248
if isinstance(bucket_object, str):
239249
bucket = self.api.get_bucket_by_name(bucket_object)
240-
else:
250+
else:
241251
bucket = bucket_object
242252

243253
if not only_files:
@@ -253,7 +263,16 @@ def clean_bucket(self, bucket_object: Bucket | str, only_files: bool = False, on
253263

254264
file_versions: Iterable[Any]
255265
if only_folders:
256-
file_versions = wrap_iterables([bucket.ls(latest_only=False, recursive=True, folder_to_list=folder,) for folder in only_folders])
266+
file_versions = wrap_iterables(
267+
[
268+
bucket.ls(
269+
latest_only=False,
270+
recursive=True,
271+
folder_to_list=folder,
272+
)
273+
for folder in only_folders
274+
]
275+
)
257276
else:
258277
file_versions = bucket.ls(latest_only=False, recursive=True)
259278

test/integration/persistent_bucket.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@ def get_or_create_persistent_bucket(b2_api: Api) -> Bucket:
6464
b2_api.bucket_name_log.append(bucket_name)
6565
return bucket
6666

67+
6768
def prune_used_files(b2_api: Api, bucket: Bucket, folders: List[str]):
68-
b2_api.clean_bucket(bucket_object=bucket, only_files=True, only_folders=folders,ignore_retentions=True)
69+
b2_api.clean_bucket(
70+
bucket_object=bucket, only_files=True, only_folders=folders, ignore_retentions=True
71+
)

test/integration/test_autocomplete.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def autocomplete_installed(env, homedir, bashrc, cli_version, cli_command, is_ru
5959
@pytest.fixture
6060
def shell(env):
6161
shell = pexpect.spawn('bash -i', env=env, maxread=1000)
62-
shell.setwinsize(100, 100) # required to see all suggestions in tests
62+
shell.setwinsize(100, 1000) # required to see all suggestions in tests
6363
yield shell
6464
shell.close()
6565

0 commit comments

Comments
 (0)