Skip to content

Commit c72f9ff

Browse files
Formatting
1 parent 2534a23 commit c72f9ff

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

src/tests/test_consumer.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,7 @@ def analyze_build_success(BR: BuildOutput) -> tuple[bool, str]:
279279
return True, "Build successful - no critical warnings"
280280

281281

282-
def print_final_result(
283-
BR: BuildOutput, repo_name: str, cmd: str, pytestconfig
284-
):
282+
def print_final_result(BR: BuildOutput, repo_name: str, cmd: str, pytestconfig):
285283
"""
286284
Print your existing detailed output plus a clear success/failure summary
287285
"""
@@ -332,8 +330,9 @@ def print_result_table(results: list[Result]):
332330
print(table)
333331

334332

335-
def run_cmd(cmd: str, results:list[Result], repo_name:str, local_or_git:str, pytestconfig)->tuple[list[Result], bool]:
336-
333+
def run_cmd(
334+
cmd: str, results: list[Result], repo_name: str, local_or_git: str, pytestconfig
335+
) -> tuple[list[Result], bool]:
337336
out = subprocess.run(cmd.split(), capture_output=True, text=True)
338337

339338
BR = BuildOutput(
@@ -343,9 +342,7 @@ def run_cmd(cmd: str, results:list[Result], repo_name:str, local_or_git:str, pyt
343342
)
344343
BR_parsed = parse_bazel_output(BR)
345344

346-
is_success, reason = print_final_result(
347-
BR_parsed, repo_name, cmd, pytestconfig
348-
)
345+
is_success, reason = print_final_result(BR_parsed, repo_name, cmd, pytestconfig)
349346

350347
results.append(
351348
Result(
@@ -363,24 +360,24 @@ def run_cmd(cmd: str, results:list[Result], repo_name:str, local_or_git:str, pyt
363360
def run_test_commands():
364361
pass
365362

363+
366364
def setup_test_environment(sphinx_base_dir):
367365
"""Set up the test environment and return necessary paths and metadata."""
368366
os.chdir(sphinx_base_dir)
369367
curr_path = Path(__file__).parent
370368
git_root = find_git_root(curr_path)
371-
369+
372370
if git_root is None:
373371
assert False, "Git root was none"
374-
372+
375373
# Get GitHub URL and current hash for git override
376374
gh_url = get_github_base_url(git_root)
377375
current_hash = get_current_git_commit(curr_path)
378-
376+
379377
# Create symlink for local docs-as-code
380378
docs_as_code_dest = sphinx_base_dir / "docs_as_code"
381379
docs_as_code_dest.symlink_to(git_root)
382-
383-
380+
384381
return curr_path, git_root, gh_url, current_hash
385382

386383

@@ -389,27 +386,26 @@ def prepare_repo_overrides(repo_name, git_url, current_hash, gh_url):
389386
# Clone the repository
390387
subprocess.run(["git", "clone", git_url], check=True, capture_output=True)
391388
os.chdir(repo_name)
392-
389+
393390
# Read original MODULE.bazel
394391
with open("MODULE.bazel", "r") as f:
395392
module_orig = f.read()
396-
393+
397394
# Prepare override versions
398395
module_local_override = replace_bazel_dep_with_local_override(module_orig)
399396
module_git_override = replace_bazel_dep_with_git_override(
400397
module_orig, current_hash, gh_url
401398
)
402-
403-
return module_local_override, module_git_override
404399

400+
return module_local_override, module_git_override
405401

406402

407403
# Updated version of your test loop
408404
def test_and_clone_repos_updated(sphinx_base_dir, pytestconfig):
409405
# Setting up the Test Environment
410406

411407
# This might be hacky, but currently the best way I could solve the issue of going to the right place.
412-
curr_path, git_root, gh_url, current_hash = setup_test_environment(sphinx_base_dir)
408+
curr_path, git_root, gh_url, current_hash = setup_test_environment(sphinx_base_dir)
413409

414410
overall_success = True
415411

@@ -420,8 +416,10 @@ def test_and_clone_repos_updated(sphinx_base_dir, pytestconfig):
420416
# ╭──────────────────────────────────────╮
421417
# │ Preparing the Repository for testing │
422418
# ╰──────────────────────────────────────╯
423-
module_local_override, module_git_override = prepare_repo_overrides(repo.name, repo.git_url,current_hash, gh_url )
424-
overrides = {"local":module_local_override, "git":module_git_override}
419+
module_local_override, module_git_override = prepare_repo_overrides(
420+
repo.name, repo.git_url, current_hash, gh_url
421+
)
422+
overrides = {"local": module_local_override, "git": module_git_override}
425423
for type, override_content in overrides.items():
426424
with open("MODULE.bazel", "w") as f:
427425
f.write(override_content)
@@ -433,7 +431,9 @@ def test_and_clone_repos_updated(sphinx_base_dir, pytestconfig):
433431
for cmd in repo.commands:
434432
print_running_cmd(repo.name, cmd, f"{type.upper()} OVERRIDE")
435433
# Running through all 'cmds' specified with the local override
436-
gotten_results, is_success = run_cmd(cmd, results, repo.name, type, pytestconfig)
434+
gotten_results, is_success = run_cmd(
435+
cmd, results, repo.name, type, pytestconfig
436+
)
437437
results = gotten_results
438438
if not is_success:
439439
overall_success = False
@@ -445,7 +445,9 @@ def test_and_clone_repos_updated(sphinx_base_dir, pytestconfig):
445445
# Running through all 'test cmds' specified with the local override
446446
print_running_cmd(repo.name, test_cmd, "LOCAL OVERRIDE")
447447

448-
gotten_results, is_success = run_cmd(test_cmd, results, repo.name, "local", pytestconfig)
448+
gotten_results, is_success = run_cmd(
449+
test_cmd, results, repo.name, "local", pytestconfig
450+
)
449451
results = gotten_results
450452

451453
if not is_success:

0 commit comments

Comments
 (0)