Skip to content

Commit

Permalink
Fix constructor test skips and imports for MacOS (#709)
Browse files Browse the repository at this point in the history
* Fix spelling of darwin

* Only import osxpkg when on MacOS

* Only import osxpkg when on MacOS

* Add missing sys import

* Skip tests containing OSX_DIR for non-osx systems

* Add placeholder for OSX_DIR

* Add comment for OSX_DIR placeholder

* Add news file

* add a few "initialize_by_default: false"

* Update news/709-test-import-fixes

Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>

---------

Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
  • Loading branch information
marcoesters and jaimergp committed Aug 15, 2023
1 parent fa82997 commit 64f681e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/customize_controls/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ specs:

register_python: False
initialize_conda: False
initialize_by_default: false
1 change: 1 addition & 0 deletions examples/osxpkg/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ channels:
- http://repo.anaconda.com/pkgs/main/

attempt_hardlinks: True
initialize_by_default: false

specs:
- python
Expand Down
1 change: 1 addition & 0 deletions examples/use_channel_remap/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ specs:
- conda

license_file: eula.txt
initialize_by_default: false
19 changes: 19 additions & 0 deletions news/709-test-import-fixes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fix imports and skips for constructor tests. (#709)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
5 changes: 3 additions & 2 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from conda.base.context import context
from conda.core.prefix_data import PrefixData

from constructor.osxpkg import calculate_install_dir
if sys.platform == "darwin":
from constructor.osxpkg import calculate_install_dir

try:
import coverage # noqa
Expand Down Expand Up @@ -349,7 +350,7 @@ def test_example_noconda(tmp_path, request):
_run_installer(input_path, installer, install_dir, request=request)


@pytest.mark.skipif(sys.platform != "Darwin", reason="macOS only")
@pytest.mark.skipif(sys.platform != "darwin", reason="macOS only")
def test_example_osxpkg(tmp_path, request):
input_path = _example_path("osxpkg")
for installer, install_dir in create_installer(input_path, tmp_path):
Expand Down
9 changes: 8 additions & 1 deletion tests/test_header.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import itertools
import subprocess
import sys
import tempfile
from functools import lru_cache
from pathlib import Path
from shutil import which

import pytest

from constructor.osxpkg import OSX_DIR
if sys.platform == "darwin":
from constructor.osxpkg import OSX_DIR
else:
# Tests with OSX_DIR are skipped, but a placeholder is needed for pytest
OSX_DIR = ""
from constructor.shar import read_header_template
from constructor.utils import preprocess

Expand Down Expand Up @@ -95,6 +100,7 @@ def test_linux_template_processing():
assert not errors


@pytest.mark.skipif(sys.platform != "darwin", reason="Only on MacOS")
@pytest.mark.parametrize("arch", ["x86_64", "arm64"])
@pytest.mark.parametrize("check_path_spaces", [False, True])
@pytest.mark.parametrize("script", sorted(Path(OSX_DIR).glob("*.sh")))
Expand All @@ -107,6 +113,7 @@ def test_osxpkg_scripts_template_processing(arch, check_path_spaces, script):
assert "#endif" not in processed


@pytest.mark.skipif(sys.platform != "darwin", reason="Only on MacOS")
@pytest.mark.skipif(available_command("shellcheck") is False, reason="requires shellcheck")
@pytest.mark.parametrize("arch", ["x86_64", "arm64"])
@pytest.mark.parametrize("check_path_spaces", [False, True])
Expand Down

0 comments on commit 64f681e

Please sign in to comment.