Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Running Tests Confidently | Organizing and Running Tests
Python Unit Testing Fundamentals

bookRunning Tests Confidently

Свайпніть щоб показати меню

Running Python tests is usually done from the command line, giving you quick feedback on the state of your code. The built-in unittest module lets you easily discover and run tests directly from the terminal.

# To run all tests in the current directory and its subdirectories using unittest:
python -m unittest discover

When you run tests, Python shows the results in the terminal. A dot (.) means a test passed, F indicates a failure, and E indicates an error. At the end, you’ll see a summary with the total number of tests and details about any issues.

To run a specific test file, provide its path and filename. This is helpful when you want to focus on a particular module or test set.

# To run a single test file named test_math.py:
python -m unittest test_math.py
Note
Note

Integrating test runs into your daily workflow is essential. You can automate test execution with scripts or continuous integration tools to ensure that your code remains reliable as it evolves.

question mark

How can you run all tests in a directory using unittest?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 2

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 4. Розділ 2
some-alt