Skip to content

Commit

Permalink
Extract static pytest args into config (conda#13048)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard authored Aug 31, 2023
1 parent 5c814f9 commit 417b797
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 87 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
- '*.py'
- 'recipe/**'
- '.github/workflows/tests.yml'
- 'dev/**/setup.*'
- 'dev/**/integration.*'
- 'dev/**/unit.*'
- 'dev/**/qemu.*'
# windows test suite
windows:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ conda.tmp/
*.iws
test-report.xml

# default pytest duration files
.test_durations

# Rever
rever/
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ repos:
# lint Python codes
- id: flake8
args: [--docstring-convention=pep257]
additional_dependencies: [flake8-docstrings]
additional_dependencies: [flake8-docstrings, flake8-pyproject]
- repo: meta
# see https://pre-commit.com/#meta-hooks
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
2 changes: 0 additions & 2 deletions conda-forge.yml

This file was deleted.

8 changes: 7 additions & 1 deletion dev/linux/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@ conda info
# put temporary files on same filesystem
export TMP=$HOME/pytesttmp
mkdir -p $TMP
python -m pytest --cov=conda --store-durations --durations-path=./tools/durations/${OS}.json --splitting-algorithm=least_duration --basetemp=$TMP -m "integration" -v --splits ${TEST_SPLITS} --group=${TEST_GROUP}
python -m pytest \
--cov=conda \
--durations-path=./tools/durations/${OS}.json \
--basetemp=$TMP \
-m "integration" \
--splits=${TEST_SPLITS} \
--group=${TEST_GROUP}
python -m conda.common.io
5 changes: 4 additions & 1 deletion dev/linux/qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ sudo rm -rf /opt/conda/pkgs/*-*-*
# put temporary files on same filesystem
export TMP=$HOME/pytesttmp
mkdir -p "$TMP"
python -m pytest --cov=conda --basetemp="$TMP" -k test_DepsModifier_contract
python -m pytest \
--cov=conda \
--basetemp="$TMP" \
-k test_DepsModifier_contract
8 changes: 7 additions & 1 deletion dev/linux/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ sudo rm -rf /opt/conda/pkgs/*-*-*
# put temporary files on same filesystem
export TMP=$HOME/pytesttmp
mkdir -p $TMP
python -m pytest --cov=conda --store-durations --durations-path=./tools/durations/${OS}.json --splitting-algorithm=least_duration --basetemp=$TMP -m "not integration" -v --splits ${TEST_SPLITS} --group=${TEST_GROUP}
python -m pytest \
--cov=conda \
--durations-path=./tools/durations/${OS}.json \
--basetemp=$TMP \
-m "not integration" \
--splits=${TEST_SPLITS} \
--group=${TEST_GROUP}
7 changes: 6 additions & 1 deletion dev/macos/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ TEST_GROUP="${TEST_GROUP:-1}"

eval "$(sudo python -m conda init bash --dev)"
conda info
python -m pytest --cov=conda --store-durations --durations-path=./tools/durations/${OS}.json --splitting-algorithm=least_duration -m "integration" -v --splits ${TEST_SPLITS} --group=${TEST_GROUP}
python -m pytest \
--cov=conda \
--durations-path=./tools/durations/${OS}.json \
-m "integration" \
--splits=${TEST_SPLITS} \
--group=${TEST_GROUP}
python -m conda.common.io
7 changes: 6 additions & 1 deletion dev/macos/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ TEST_GROUP="${TEST_GROUP:-1}"

eval "$(sudo python -m conda init bash --dev)"
conda info
python -m pytest --cov=conda --store-durations --durations-path=./tools/durations/${OS}.json --splitting-algorithm=least_duration -m "not integration" -v --splits ${TEST_SPLITS} --group=${TEST_GROUP}
python -m pytest \
--cov=conda \
--durations-path=./tools/durations/${OS}.json \
-m "not integration" \
--splits=${TEST_SPLITS} \
--group=${TEST_GROUP}
7 changes: 6 additions & 1 deletion dev/windows/integration.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ CALL dev-init.bat || goto :error
CALL conda info || goto :error
:: TODO --store-durations --durations-path=.\tools\durations\Windows.json
:: --splitting-algorithm=least_duration (causes tests to fail)
CALL pytest --cov=conda -m "integration" --basetemp=C:\tmp -v --splits=%TEST_SPLITS% --group=%TEST_GROUP% || goto :error
CALL pytest ^
--cov=conda ^
-m "integration" ^
--basetemp=C:\tmp ^
--splits=%TEST_SPLITS% ^
--group=%TEST_GROUP% || goto :error
goto :EOF

:error
Expand Down
7 changes: 6 additions & 1 deletion dev/windows/unit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ pushd %TEMP% || goto :error
cd \conda_src || goto :error
CALL dev-init.bat || goto :error
CALL conda info || goto :error
CALL pytest --cov=conda --store-durations --durations-path=.\tools\durations\Windows.json --splitting-algorithm=least_duration -m "not integration" -v --splits=%TEST_SPLITS% --group=%TEST_GROUP% || goto :error
CALL pytest ^
--cov=conda ^
--durations-path=.\tools\durations\Windows.json ^
-m "not integration" ^
--splits=%TEST_SPLITS% ^
--group=%TEST_GROUP% || goto :error
goto :EOF

:error
Expand Down
105 changes: 105 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,114 @@ version-file = "conda/__version__.py"
[tool.black]
target-version = ['py38', 'py39', 'py310', 'py311']

[tool.coverage.run]
# store relative paths in coverage information
relative_files = true

[tool.coverage.report]
show_missing = true
sort = "Miss"
skip_covered = true
omit = [
"*/site-packages/*",
'*\site-packages\*',
"conda/_vendor/*",
"conda/console.py",
"conda/cli/activate.py",
"conda/cli/main_package.py",
"conda/exports.py",
"conda/gateways/connection/adapters/ftp.py",
"conda/gateways/connection/adapters/s3.py",
"conda_env/*",
"tests/*",
"utils/*",
]
exclude_lines = [
"pragma: no cover",
"pragma: py$PYTHON_MAJOR_VERSION no cover",
"pragma: $TEST_PLATFORM no cover",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"def __repr__",
'\s*\.\.\.$',
]

[tool.flake8]
# see black+flake8 config
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
max-line-length = 99
# E203 whitespace before ':'
# E402 module level import not at top of file
# E722 do not use bare 'except'
# E731 do not assign a lambda expression, use a def
# W503 line break before binary operator
# D1** Missing docstring
# D205 1 blank line required between summary line and description
# D400 First line should end with a period
# D401 First line should be in imperative mood
extend-ignore = ["E203", "E402", "E722", "E731", "W503", "D1", "D200", "D205", "D400", "D401"]
extend-select = ["D100"]
exclude = [
".asv*",
"build/*",
".tox/*",
"dev*/*",
"env/*",
"test_data/*",
"tests/*",
"ve/*",
"utils/*",
"docs/*",
"*/_vendor/*",
"conda/compat.py",
"conda/common/compat.py",
"conda_env/compat.py",
]

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
minversion = 3.0
testpaths = ["tests"]
norecursedirs = [
"tests/data/*",
"tests/integration/*",
"tests/plugins/data/*",
]
addopts = [
"--color=yes",
# "--cov=conda", # passed in test runner scripts instead (avoid debugger)
"--cov-append",
"--cov-branch",
"--cov-report=term-missing",
"--cov-report=xml",
"--durations=16",
"--junitxml=test-report.xml",
"--splitting-algorithm=least_duration",
"--store-durations",
"--strict-markers",
"--tb=native",
"--xdoctest-modules",
"--xdoctest-style=google",
"-vv",
]
doctest_optionflags = [
"NORMALIZE_WHITESPACE",
"IGNORE_EXCEPTION_DETAIL",
"ALLOW_UNICODE",
"ELLIPSIS",
]
markers = [
"integration: integration tests that usually require an internet connect",
"slow: slow running tests",
]
pythonpath = [
# faking a test-plugin to test ImportError handling
"tests/plugins/data/test-plugin",
]

[tool.vendoring]
destination = "conda/_vendor/"
namespace = "conda._vendor"
Expand Down
76 changes: 0 additions & 76 deletions setup.cfg

This file was deleted.

10 changes: 9 additions & 1 deletion tests/cli/test_main_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

from conda.base.context import context
from conda.testing import CondaCLIFixture


Expand Down Expand Up @@ -133,10 +134,17 @@ def test_search_envs(conda_cli: CondaCLIFixture):
assert "Searching environments" in stdout
assert "conda" in stdout


@pytest.mark.integration
def test_search_envs_info(conda_cli: CondaCLIFixture):
stdout, _, _ = conda_cli("search", "--envs", "--info", "conda")
assert "Searching environments" in stdout
assert "conda" in stdout


@pytest.mark.integration
def test_search_envs_json(conda_cli: CondaCLIFixture):
stdout, _, _ = conda_cli("search", "--envs", "--json", "conda")
assert "Searching environments" not in stdout
assert "conda" in stdout
parsed = json.loads(stdout.strip())
assert parsed
2 changes: 2 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ chardet
conda
conda-content-trust
conda-forge::flake8-docstrings
conda-forge::flake8-pyproject
conda-forge::pytest-split
conda-forge::pytest-xprocess
conda-forge::xdoctest
Expand Down Expand Up @@ -42,6 +43,7 @@ responses
ruamel.yaml >=0.11.14,<0.18
setuptools >=60.0.0
setuptools_scm # needed for devenv version detection
tomli # for coverage pyproject.toml, only necessary for Python <= 3.11.0a6
toolz >=0.8.1
tqdm >=4
werkzeug >=2.2

0 comments on commit 417b797

Please sign in to comment.