Skip to content

Commit

Permalink
Merge pull request #176 from anaconda-distribution/s390x
Browse files Browse the repository at this point in the history
Miscellaneous fixes
  • Loading branch information
marcoesters authored Jan 10, 2023
2 parents be7ae0d + ceb5c6d commit 3231e22
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 4 deletions.
9 changes: 6 additions & 3 deletions anaconda_linter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,11 @@ def validate_config(config):
directly.
"""
if not isinstance(config, dict):
config = yaml.load(open(config))
with open(config) as conf:
config = yaml.load(conf.read())
fn = os.path.abspath(os.path.dirname(__file__)) + "/config.schema.yaml"
schema = yaml.load(open(fn))
with open(fn) as f:
schema = yaml.load(f.read())
validate(config, schema)


Expand All @@ -291,7 +293,8 @@ def relpath(p):
def relpath(p):
return os.path.join(os.path.dirname(path), p)

config = yaml.load(open(path))
with open(path) as conf:
config = yaml.load(conf.read())

def get_list(key):
# always return empty list, also if NoneType is defined in yaml
Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test:
commands:
- pip check
# lint_list is only an important test for development
- python -m pytest -vv tests -k 'not lint_list'
- python -m pytest -vv tests -k "not lint_list"

about:
home: https://github.com/anaconda-distribution/anaconda-linter
Expand Down
85 changes: 85 additions & 0 deletions tests/test_build_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,20 @@ def test_pip_install_args_good_missing(base_yaml):
assert len(messages) == 0


def test_pip_install_args_good_missing_file(base_yaml, recipe_dir):
yaml_str = (
base_yaml
+ """
requirements:
host:
- pip
"""
)
lint_check = "pip_install_args"
messages = check_dir(lint_check, recipe_dir.parent, yaml_str)
assert len(messages) == 0


def test_pip_install_args_good_cmd(base_yaml):
yaml_str = (
base_yaml
Expand Down Expand Up @@ -1474,6 +1488,22 @@ def test_missing_imports_or_run_test_py_good_imports(base_yaml):
assert len(messages) == 0


def test_missing_imports_or_run_test_py_good_pypi(base_yaml):
yaml_str = (
base_yaml
+ """
source:
url: https://pypi.io/packages/source/D/Django/Django-4.1.tar.gz
test:
imports:
- module
"""
)
lint_check = "missing_imports_or_run_test_py"
messages = check(lint_check, yaml_str)
assert len(messages) == 0


def test_missing_imports_or_run_test_py_good_script(base_yaml, recipe_dir):
yaml_str = (
base_yaml
Expand Down Expand Up @@ -1515,6 +1545,27 @@ def test_missing_imports_or_run_test_py_good_multi(base_yaml):
assert len(messages) == 0


def test_missing_imports_or_run_test_py_good_multi_pypi(base_yaml):
yaml_str = (
base_yaml
+ """
source:
url: https://pypi.io/packages/source/D/Django/Django-4.1.tar.gz
outputs:
- name: output1
test:
imports:
- module1
- name: output2
test:
script: test_output2.py
"""
)
lint_check = "missing_imports_or_run_test_py"
messages = check(lint_check, yaml_str)
assert len(messages) == 0


def test_missing_imports_or_run_test_py_bad(base_yaml):
yaml_str = (
base_yaml
Expand All @@ -1529,6 +1580,20 @@ def test_missing_imports_or_run_test_py_bad(base_yaml):
assert len(messages) == 1 and "Python packages require imports" in messages[0].title


def test_missing_imports_or_run_test_py_bad_pypi(base_yaml):
yaml_str = (
base_yaml
+ """
source:
url: https://pypi.io/packages/source/D/Django/Django-4.1.tar.gz
test:
"""
)
lint_check = "missing_imports_or_run_test_py"
messages = check(lint_check, yaml_str)
assert len(messages) == 1 and "Python packages require imports" in messages[0].title


def test_missing_imports_or_run_test_py_bad_multi(base_yaml):
yaml_str = (
base_yaml
Expand All @@ -1551,6 +1616,26 @@ def test_missing_imports_or_run_test_py_bad_multi(base_yaml):
)


def test_missing_imports_or_run_test_py_bad_multi_pypi(base_yaml):
yaml_str = (
base_yaml
+ """
source:
url: https://pypi.io/packages/source/D/Django/Django-4.1.tar.gz
outputs:
- name: output1
test:
- name: output2
test:
"""
)
lint_check = "missing_imports_or_run_test_py"
messages = check(lint_check, yaml_str)
assert len(messages) == 2 and all(
"Python packages require imports" in msg.title for msg in messages
)


def test_missing_pip_check_url_good(base_yaml):
yaml_str = (
base_yaml
Expand Down

0 comments on commit 3231e22

Please sign in to comment.