Pular para o conteúdo principal
Página inicialPythonIntroduction to Testing in Python

Introduction to Testing in Python

Master Python testing: Learn methods, create checks, and ensure error-free code with pytest and unittest.

Comece O Curso Gratuitamente
4 Horas16 Videos53 Exercicios

Crie sua conta gratuita

GoogleLinkedInFacebook

ou

Ao continuar, você aceita nossos Termos de Uso, nossa Política de Privacidade e que seus dados são armazenados nos EUA.
GroupTreinar 2 ou mais pessoas?Experimente o DataCamp For Business

Amado por alunos de milhares de empresas


Descrição do Curso

Why tests?

Plenty of people write code. Some of them make it work and profitable. But sometimes, even the smartest of the best programmers makes a mistake that can cost millions of dollars. How to decrease the possibility of getting into such a fiasco? How do you ensure that you create a program that does exactly what you want? The very simple answer is: write tests!

Python testing basics

During this journey, you will learn the very basics of creating tests in Python. You will meet four types of software testing methods. You will create your own tests to check if the program or a data pipeline works as expected before it goes to production. Whether it is the unexpected null, a typo in your dataset, or mixed-up signs in the equation. You can, and you will catch those cases with the tests.

Testing with pytest and unittest

After the course completion, you will know the types of testing methods, and you will be able to choose the most suitable ones for a specific context. You also will be able to design those tests and implement them in Python using the `pytest` and the `unittest` libraries.
Para Empresas

GroupTreinar 2 ou mais pessoas?

Obtenha acesso à biblioteca completa do DataCamp, com relatórios, atribuições, projetos e muito mais centralizados
Experimente O DataCamp for BusinessPara uma solução sob medida , agende uma demonstração.

Nas seguintes faixas

Desenvolvedor Python

Ir para a trilha

Programação Python

Ir para a trilha
  1. 1

    Creating Tests with pytest

    Grátis

    Learn what a test is and how to run the first one of your own with the pytest library! You will get used to the pytest testing framework and the command-line interface. You will also learn how to process specific contexts, like "failed tests" and "skipping the test" with pytest markers.

    Reproduzir Capítulo Agora
    Introduction to Testing in Python
    50 xp
    The first test suite
    100 xp
    pytest.raises
    100 xp
    Invoking pytest from CLI
    50 xp
    Run the test!
    100 xp
    Run with the keyword
    100 xp
    Applying test markers
    50 xp
    Markers use cases
    100 xp
    Failed tests with xfail
    100 xp
    Conditional skipping
    100 xp
  2. 2

    Pytest Fixtures

    Learn what a fixture is and how to simplify your code by using it in tests. You will get familiar with the fixture @pytest.fixture decorator and the fixture tools. You will analyze your code to see the "fixture part" in it. Finally, learn how to use teardowns to prevent software failures.

    Reproduzir Capítulo Agora
  3. 3

    Basic Testing Types

    Learn what the basic testing types are and their features. Learn about test cases and how they help to implement tests. You will get more skilled with creating test functions and running pytest from CLI in IDE exercises. Finally, you will be able to differentiate the different testing types and create tests for each of them.

    Reproduzir Capítulo Agora
  4. 4

    Writing tests with unittest

    In this final chapter, you will meet the unittest framework. First, you will learn basic assertion methods, then its CLI interface, and how to use fixtures. Finally, you will put everything together in the practical examples of data pipelines.

    Reproduzir Capítulo Agora
Para Empresas

GroupTreinar 2 ou mais pessoas?

Obtenha acesso à biblioteca completa do DataCamp, com relatórios, atribuições, projetos e muito mais centralizados

Nas seguintes faixas

Desenvolvedor Python

Ir para a trilha

Programação Python

Ir para a trilha

Conjuntos De Dados

DS_salariesEnergyGames

Colaboradores

Collaborator's avatar
George Boorman
Collaborator's avatar
Arne Warnke
Collaborator's avatar
Katerina Zahradova
Alexander Levin HeadshotAlexander Levin

Senior Data Scientist

Veja Mais

O que os outros alunos têm a dizer?

Cadastre-se mais 13 milhões de alunos e comece Introduction to Testing in Python Hoje!

Crie sua conta gratuita

GoogleLinkedInFacebook

ou

Ao continuar, você aceita nossos Termos de Uso, nossa Política de Privacidade e que seus dados são armazenados nos EUA.