-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checkpoint initial tests for
whl2conda build
- Loading branch information
1 parent
dd0ca59
commit 5b4f696
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% set project = load_file_data('pyproject.toml')['project'] %} | ||
|
||
package: | ||
name: simple | ||
version: {{ project['version'] }} | ||
|
||
source: | ||
- path: .. | ||
|
||
build: | ||
noarch: python | ||
script: pip install . -vv --no-deps --no-build-isolation | ||
|
||
requirements: | ||
build: | ||
- python 3.10 | ||
- hatchling | ||
|
||
run: | ||
- python {{ project['requires-python'] }} | ||
- black >=23.3 | ||
- quaternion | ||
- pytables | ||
|
||
test: | ||
requires: | ||
- pytest | ||
imports: | ||
- simple | ||
|
||
about: | ||
home: {{ project['urls']['Homepage'] }} | ||
summary: {{ project['description'] }} | ||
|
||
extra: | ||
authors: | ||
{% for author in project['authors'] %} | ||
- '{{ author['name'] }} <{{ author['email'] }}>' | ||
{% endfor %} | ||
keywords: | ||
{% for keyword in project['keywords'] %} | ||
- '{{ keyword }}' | ||
{% endfor %} | ||
classifiers: | ||
{% for classifier in project['classifiers'] %} | ||
- '{{ classifier }}' | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright 2024 Christopher Barber | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
""" | ||
Unit tests for whl2conda build subcommand. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import re | ||
from pathlib import Path | ||
|
||
# third party | ||
import pytest | ||
|
||
# this project | ||
from whl2conda.cli import main | ||
from whl2conda.cli.build import CondaBuild | ||
|
||
this_dir = Path(__file__).parent | ||
root_dir = this_dir.parent.parent | ||
test_projects = root_dir / "test-projects" | ||
|
||
|
||
class CondaBuildWhitebox(CondaBuild): | ||
def _render_recipe(self): | ||
super()._render_recipe() | ||
|
||
def _check_recipe(self) -> str: | ||
new_script = super()._check_recipe() | ||
return new_script | ||
|
||
def _build_wheel(self) -> Path: | ||
return super()._build_wheel() | ||
|
||
def _build_package(self, wheel: Path) -> Path: | ||
pkg = super()._build_package(wheel) | ||
return pkg | ||
|
||
def _test_package(self, pkg: Path) -> None: | ||
pass | ||
# super()._test_package(pkg) | ||
|
||
def _install_package(self, pkg: Path) -> None: | ||
pass | ||
|
||
def _cleanup(self) -> None: | ||
super()._cleanup() | ||
|
||
|
||
@pytest.fixture | ||
def build_whitebox( | ||
monkeypatch: pytest.MonkeyPatch, | ||
tmp_path: Path, | ||
): | ||
monkeypatch.setattr("whl2conda.cli.build.CondaBuild", CondaBuildWhitebox) | ||
|
||
|
||
def test_simple( | ||
build_whitebox, | ||
monkeypatch: pytest.MonkeyPatch, | ||
capsys: pytest.CaptureFixture, | ||
) -> None: | ||
monkeypatch.chdir(test_projects / "simple") | ||
main(["build", "conda.recipe"]) | ||
out, err = capsys.readouterr() | ||
assert not err | ||
assert re.search( | ||
r"Elapsed time: .* seconds", | ||
out, | ||
flags=re.MULTILINE, | ||
) |