Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda