Skip to content

Commit

Permalink
Tests: Fix get_or_merge_testing_config cli tests
Browse files Browse the repository at this point in the history
cli.main_build.execute (et al.) call the function with **args.__dict__
with args having default values (e.g., croot=None) via parse_args.

Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed Nov 19, 2023
1 parent 3f1cecb commit 227f13f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 2 additions & 6 deletions tests/cli/test_main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: BSD-3-Clause
import os
import re
import sys
from pathlib import Path

import pytest
Expand Down Expand Up @@ -104,8 +103,7 @@ def test_build_output_build_path(
args = ["--output", testing_workdir]
main_build.execute(args)
test_path = os.path.join(
sys.prefix,
"conda-bld",
testing_config.croot,
testing_config.host_subdir,
"test_build_output_build_path-1.0-1.tar.bz2",
)
Expand All @@ -124,9 +122,7 @@ def test_build_output_build_path_multiple_recipes(

main_build.execute(args)

test_path = lambda pkg: os.path.join(
sys.prefix, "conda-bld", testing_config.host_subdir, pkg
)
test_path = lambda pkg: os.path.join(testing_config.croot, testing_config.host_subdir, pkg)
test_paths = [
test_path("test_build_output_build_path_multiple_recipes-1.0-1.tar.bz2"),
]
Expand Down
14 changes: 10 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,17 @@ def default_testing_config(testing_config, monkeypatch, request):
return

def get_or_merge_testing_config(config, variant=None, **kwargs):
merged_kwargs = {}
if not config:
merged_kwargs.update(testing_config._testing_config_kwargs)
merged_kwargs.update(kwargs)
return _get_or_merge_config(config, variant, **merged_kwargs)
# If no existing config, override kwargs that are None with testing config defaults.
# (E.g., "croot" is None if called via "(..., *args.__dict__)" in cli.main_build.)
kwargs.update(
{
key: value
for key, value in testing_config._testing_config_kwargs.items()
if kwargs.get(key) is None
}
)
return _get_or_merge_config(config, variant, **kwargs)

monkeypatch.setattr(
conda_build.config,
Expand Down

0 comments on commit 227f13f

Please sign in to comment.