Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve testsuite #1975

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: v4.6.0
hooks:
- id: check-yaml
exclude: (tests/recipes|conda_smithy.recipe)
exclude: (tests/__snapshots__|tests/recipes|conda_smithy.recipe)
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ dependencies:
- python-build
- setuptools>=45
- setuptools_scm>=8.1
- syrupy
- tomli>=1.0.0
- pre-commit
- mock
- pytest
- pytest-mock
- pytest-cov
# Runtime dependencies
- conda >=4.2
Expand Down
25 changes: 25 additions & 0 deletions news/improve_testsuite.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**Added:**

* pytest-mock
* syrupy

**Changed:**

* Replace unittest with pytest
* Add snapshot tests

**Deprecated:**

* <news item>

**Removed:**

* unittest

**Fixed:**

* <news item>

**Security:**

* <news item>
211 changes: 211 additions & 0 deletions tests/__snapshots__/test_anaconda_token_rotation.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# serializer version: 1
# name: test_rotate_anaconda_token_notoken[False-False-False-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-False-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-False-True-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-False-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[False-True-True-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-False-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-False-True-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-False-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-False-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-False-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-False-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-False-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-True-False-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-True-False-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-True-True-False]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_notoken[True-True-True-True-True-True]
'You must have the anaconda token defined to do token rotation!'
# ---
# name: test_rotate_anaconda_token_provider_error[appveyor]
'Failed to rotate token for foo/bar-feedstock on appveyor!'
# ---
# name: test_rotate_anaconda_token_provider_error[azure]
'Failed to rotate token for foo/bar-feedstock on azure!'
# ---
# name: test_rotate_anaconda_token_provider_error[circle]
'Failed to rotate token for foo/bar-feedstock on circle!'
# ---
# name: test_rotate_anaconda_token_provider_error[drone]
'Failed to rotate token for foo/bar-feedstock on drone endpoint https://cloud.drone.io!'
# ---
# name: test_rotate_anaconda_token_provider_error[github_actions]
'Failed to rotate token for foo/bar-feedstock on github actions!'
# ---
# name: test_rotate_anaconda_token_provider_error[travis]
'Failed to rotate token for foo/bar-feedstock on travis!'
# ---
101 changes: 101 additions & 0 deletions tests/__snapshots__/test_ci_skeleton.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# serializer version: 1
# name: test_generate[CONDA_FORGE_YML]
'''
clone_depth: 0
recipe_dir: myrecipe
skip_render:
- README.md
- LICENSE.txt
- .gitattributes
- .gitignore
- build-locally.py
- LICENSE
- .github/CONTRIBUTING.md
- .github/ISSUE_TEMPLATE.md
- .github/PULL_REQUEST_TEMPLATE.md
- .github/workflows
'''
# ---
# name: test_generate[META_YML]
'''
{% set name = "my-package" %}
{% set version = environ.get('GIT_DESCRIBE_TAG', 'untagged')|string|replace('-','_') %}
{% set build_number = environ.get('GIT_DESCRIBE_NUMBER', '0') %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
git_url: {{ environ.get('FEEDSTOCK_ROOT', '..') }}

build:
# Uncomment the following line if the package is pure Python and the recipe
# is exactly the same for all platforms. It is okay if the dependencies are
# not built for all platforms/versions, although selectors are still not allowed.
# See https://conda-forge.org/docs/maintainer/knowledge_base.html#noarch-python
# for more details.
# noarch: python

number: {{ build_number }}
string: {{ [build_number, ('h' + PKG_HASH), environ.get('GIT_DESCRIBE_HASH', '')]|join('_') }}

# If the installation is complex, or different between Unix and Windows,
# use separate bld.bat and build.sh files instead of this key. By default,
# the package will be built for the Python versions supported by conda-forge
# and for all major OSs. Add the line "skip: True # [py<35]" (for example)
# to limit to Python 3.5 and newer, or "skip: True # [not win]" to limit
# to Windows.
script: "{{ PYTHON }} -m pip install . -vv"

requirements:
build:
# If your project compiles code (such as a C extension) then add the required
# compilers as separate entries here. Compilers are named 'c', 'cxx' and 'fortran'.
- {{ compiler('c') }}
host:
- python
- pip
run:
- python

test:
# Some packages might need a `test/commands` key to check CLI.
# List all the packages/modules that `run_test.py` imports.
imports:
- my_package
# Run your test commands here
commands:
- my-package --help
- pytest
# declare any test-only requirements here
requires:
- pytest
# copy over any needed test files here
source_files:
- tests/

# Uncomment and fill in my-package metadata
#about:
# home: https://github.com/conda-forge/conda-smithy
# license: BSD-3-Clause
# license_family: BSD
# license_file: LICENSE

# Uncomment the following if this will be on a forge
# Remove these lines if this is only be used for CI
#extra:
# recipe-maintainers:
# - BobaFett
# - LisaSimpson
'''
# ---
# name: test_generate[gitignore]
'''
# conda smithy ci-skeleton start
*.pyc
build_artifacts
# conda smithy ci-skeleton end

'''
# ---
Loading
Loading