Coding⏱️ 2 min read📅 2026-05-31

How to Fix: py.test: error: unrecognized arguments: --cov=ner_brands --cov-report=term-missing --cov-config

Pytest error with coverage configuration

Quick Answer: Check pytest documentation for correct coverage configuration options and try running with --cov option followed by the package name, e.g. --cov=ner_brands

To resolve the issue of unrecognized arguments when running py.test with coverage reports, you need to understand how coverage reports work and configure them correctly.

🔍 Why This Happens

  • The error occurs because the coverage report options are not recognized by py.test. The --cov option specifies the package for which to generate a coverage report, while the --cov-report option specifies the format of the report.
  • Additionally, the --cov-config option is used to specify the configuration file for the coverage tool.

🔧 Proven Troubleshooting Steps

Method 1: Correcting the Command Line Arguments

  1. Step 1: Remove any unnecessary arguments from your command line. In this case, the --cov-report option is not needed when using the default report format.

Method 2: Configuring the Coverage Report

  1. Step 1: Create a configuration file for your coverage tool. This file should contain information about your project, such as the packages to be tested and the report format.

💡 Conclusion

By following these steps, you should be able to resolve the issue of unrecognized arguments when running py.test with coverage reports.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions