Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
Python/Django - Testing against a list

I'm new to testing in python and testing in general and looking for a way to write one test function and run this function multiple times against different elements of a tuple.

More precisely, there is a tuple consisting of different database queries which i all want to test. The results of all those queries share the same pattern so i guess it's reasonable to reuse the code testing those results.

As far as i know, it is considered bad practice to pass arguments to a unittest which seems reasonable too. This leaves me a bit clueless. Writing one function for every single query would be hard to maintain, because new queries are added to this tuple constantly.
I also would like to obtain detailed results (FAIL or ok) for every single element of the tuple via python manage.py test myapp -v=2, therefore putting the complete tuple in one execution of a function seems like a bad approach too.

Like the headline suggests, my code lives in a django environment.
I'd be happy to use the django testing framwork so i can execute this test using python manage.py test.

What would be a good approach to implement this test?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

These are sometimes called parameterized tests and nose-parameterized is an awesome python package that supports it.

It allows you to define a single test function and provide a collection of parameters. It will dynamically create a named reference-able test function for each parameter provided.


How large is the tuple? Is it really necessary to test every single query in the tuple? If they share the same pattern is it sufficient to only take a subset of the queries?

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda