Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:02:20+00:00 2026-05-31T11:02:20+00:00

I work on a set of python unit tests that are currently built using

  • 0

I work on a set of python unit tests that are currently built using pythons built in testing framework. I would like to write paramaterized tests that will execute multiple times based on the set of data I give it.

ie. if my data set is [1,2,3,4] my test function would run four times using the input in my data set.

def test(data):
    if data > 0:
       #Pass the test

From my understanding this isn’t possible currently in the built in framework, unless I put a loop in my test function. I don’t want to do this because I need the test to continue executing even if one input fails.

I’ve seen that it’s possible to do using nose, or pyTest. Which is the best framework to use? Is there another framework I could use that would be better than either of these?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:02:21+00:00Added an answer on May 31, 2026 at 11:02 am

    Note that this is precisely one of the most common uses of the recent addition of funcargs in py.test.

    In your case you’d get:

    def pytest_generate_tests(metafunc):
        if 'data' in metafunc.funcargnames:
            metafunc.parametrize('data', [1,2,3,4])
    
    def test_data(data):
        assert data > 0
    

    [EDIT] I should probably add that you can also do that as simply as

    @pytest.mark.parametrize('data', [1,2,3,4])
    def test_data(data):
        assert data > 0
    

    So I’d say that py.test is a great framework for parameterized unit testing…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a set of unit tests for a Python microblogging library, and
I have a Python project building with Hudson . Most unit tests work correctly,
I have a set of work items that are completed and I am ready
Possible Duplicate: How do you generate dynamic (parameterized) unit tests in Python? I have
Say I have a regex REGEX = re.compile('.*foo{') How would you write a unit
My Python application currently uses the python-memcached API to set and get objects in
I open a file using python to find whether a predefined set of words
I am trying to run unit tests in Pydev using IronPython. When I try
I set up the Google App Engine on my computer to work with Python
I have a python generator that does work that produces a large amount of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.