...

/

Pytest Configuration

Pytest Configuration

Explore the methods to customize pytest behavior using configuration files and command-line options.

Introduction

Pytest configuration is a powerful tool that allows users to customize the behavior of pytest. With configuration files, environment variables, custom fixtures, and plugins, users can modify various aspects of pytest to fit their specific needs. In this lesson, we will deep dive into pytest command-line options and configuration files.

Command-line options

Pytest provides many command-line options that can be used to customize the behavior of pytest. These options are specified when running pytest commands, like so:

pytest [options] [file_or_directory]

Some of the most commonly used command-line options include the following:

  • -v: This increases verbosity and prints more detailed output.

  • -s: This disables the capturing of stdout/stderr. It’s useful for debugging.

  • -k: This selects tests based on their name.

  • -m: This selects tests based on their markers.

  • -x: This stops the ...

Access this course and 1400+ top-rated courses and projects.