Skip to content

Commit

Permalink
Add test for zstd compression level, condagh-4649
Browse files Browse the repository at this point in the history
  • Loading branch information
mbargull committed Nov 25, 2022
1 parent add8303 commit 1753189
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from conda_build.tarcheck import TarCheck

from conda_build import api
from conda_build.config import Config
from conda_build.config import Config, zstd_compression_level_default
from conda_build.utils import get_site_packages, on_win, get_build_folders, package_has_file, tar_xf
from conda_build.conda_interface import TemporaryDirectory
from conda_build.exceptions import DependencyNeedsBuildingError
Expand Down Expand Up @@ -691,6 +691,38 @@ def test_long_test_prefix(additional_args, is_long_test_prefix):
assert config.long_test_prefix is is_long_test_prefix


@pytest.mark.parametrize(
'zstd_level_condarc, zstd_level_cli',
[
(None, None),
(1, None),
(1, 2),
],
)
def test_zstd_compression_level(testing_workdir, zstd_level_condarc, zstd_level_cli):
assert zstd_compression_level_default not in {zstd_level_condarc, zstd_level_cli}
if zstd_level_condarc:
with open(os.path.join(testing_workdir, '.condarc'), 'w') as f:
print(
'conda_build:',
f' zstd_compression_level: {zstd_level_condarc}',
sep='\n',
file=f,
)
reset_context([os.path.join(testing_workdir, '.condarc')])
args = ['non_existing_recipe']
if zstd_level_cli:
args.append(f'--zstd-compression-level={zstd_level_cli}')
parser, args = main_build.parse_args(args)
config = Config(**args.__dict__)
if zstd_level_cli:
assert config.zstd_compression_level == zstd_level_cli
elif zstd_level_condarc:
assert config.zstd_compression_level == zstd_level_condarc
else:
assert config.zstd_compression_level == zstd_compression_level_default


def test_user_warning(tmpdir, recwarn):
dir_recipe_path = tmpdir.mkdir("recipe-path")
recipe = dir_recipe_path.join("meta.yaml")
Expand Down

0 comments on commit 1753189

Please sign in to comment.