https://pantsbuild.org/ logo
#general
Title
# general
r

rapid-crayon-8232

08/09/2021, 2:44 PM
Hello, seems that I'm missing something when trying to run tests with coverage, I get the following error:
Copy code
16:41:55.24 [WARN] Completed: test - data/lib/image/tests/test_image.py failed (exit code 4).
ERROR: usage: pex [options] [file_or_dir] [file_or_dir] [...]
pex: error: unrecognized arguments: --cov-report= --cov-config=pyproject.toml --cov
  inifile: None
  rootdir: /tmp/process-executionrPt8j7
my
pants.toml
config is:
Copy code
[pytest]
version = "pytest==6.2.4"
args = ["--no-header", "-vv"]
pytest_plugins = [
  "toml",
  "pytest-icdiff",
  "pygments",
]
timeout_default = 60

[test]
use_coverage = true

[coverage-py]
interpreter_constraints = [">=3.7"]
version = "coverage[toml]==5.5"
report = ["raw", "xml", "html", "json", "console"]
config = "pyproject.toml"
👀 1
h

happy-kitchen-89482

08/09/2021, 2:58 PM
Hey! Sorry for the trouble. Which version of Pants?
r

rapid-crayon-8232

08/09/2021, 2:59 PM
latest stable 2.6.0
my full
pants.toml
:
Copy code
[GLOBAL]
pants_version = "2.6.0"


backend_packages = [
  "pants.backend.python",
  "pants.backend.codegen.protobuf.python",
  "pants.backend.python.lint.docformatter",
  "pants.backend.python.lint.black",
  "pants.backend.python.lint.bandit",
  "pants.backend.python.lint.pylint",
  "pants.backend.python.lint.isort",
  "pants.backend.python.typecheck.mypy",
]


[source]
# The Python source root is the repo root. See <https://www.pantsbuild.org/docs/source-roots>.
root_patterns = ["/"]

[python-setup]
# The default interpreter compatibility for code in this repo. Individual targets can override
#  this with the `interpreter_constraints` field. See
#  <https://www.pantsbuild.org/docs/python-interpreter-compatibility>.
interpreter_constraints = [">=3.7,<3.10"]

requirement_constraints = "constraints.txt"
# We search for interpreters on both on the $PATH and in the `$(pyenv root)/versions` folder.
#  If you're using macOS, you may want to leave off the <PATH> entry to avoid using the
#  problematic system Pythons. See
#  <https://www.pantsbuild.org/docs/python-interpreter-compatibility#changing-the-interpreter-search-path>.
interpreter_search_paths = ["<PATH>", "<PYENV>"]

# Protobuf gnrator
[python-protobuf]
mypy_plugin = true
runtime_dependencies = ["//:grpcio", "//:protobuf"]


[python-infer]
inits = true

## Lintrs and formattrs
[docformatter]
version = "docformatter==1.4"
args = ["--wrap-summaries=80", "--wrap-descriptions=80"]

[black]
version = "black==21.7b0"
config = "pyproject.toml"

[bandit]
args = ["--quiet",  "-lll"] # only higth severity errors for now

[pylint]
version = "pylint==2.9.6"
config = "pylintrc"

[isort]
version = "isort[pyproject,colors]==5.9.3"
config = "pyproject.toml"

[mypy]
version = "mypy==0.910"
config = "pyproject.toml"

[pytest]
version = "pytest==6.2.4"
args = ["--no-header", "-vv"]
pytest_plugins = [
  "toml",
  "pytest-icdiff",
  "pygments",
]
timeout_default = 60

[test]
use_coverage = true

[coverage-py]
interpreter_constraints = [">=3.7"]
version = "coverage[toml]==5.5"
report = ["console"]
config = "pyproject.toml"
h

hundreds-father-404

08/09/2021, 3:40 PM
Yes, you need to include Pytest-cov in pytest_plugins. It's there by default, but you're overriding the option I think we need a runtime warning for this, you're not alone in being confused by this
r

rapid-crayon-8232

08/09/2021, 3:43 PM
thank you 🙂
h

hundreds-father-404

08/09/2021, 6:41 PM
@rapid-crayon-8232 any opinion on whether you'd like Pants to eagerly error in this case, vs only a warning? I think that error is the right case: logs are too easy to miss, especially in CI where you're likely to use coverage. This feels like something you really want to be made aware of
r

rapid-crayon-8232

08/09/2021, 6:49 PM
why not add pytest-civ dynamically if not present and if use_coverage is set to True ? There is already quite a bit of magic going on there with deps inference 😎, this little bit won't hurt 😅
h

hundreds-father-404

08/09/2021, 6:59 PM
Interesting. Unfortunately we can't assume things like which Pytest version you're using to know which pytest-cov version should be used Also, we don't want to be installing deps for you w/o out you knowing what they are. This is especially true with the new lockfile project, where each tool (like Pytest) can pin all of the deps it uses
r

rapid-crayon-8232

08/09/2021, 7:03 PM
makes sense, then yeah totally agree with an early error, instead of just logging a warning that can be missed or not correctly interpreted by the appropriate person in an organization.
👍 1
h

hundreds-father-404

08/09/2021, 8:05 PM
https://github.com/pantsbuild/pants/pull/12534. Feedback definitely appreciated if you have suggestions @rapid-crayon-8232 on the error message wording! Thanks for the report 🙂
5 Views