Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!