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 8698141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:40:24+00:00 2026-06-13T01:40:24+00:00

I have a JSON parser library ( ijson ) with a test suite using

  • 0

I have a JSON parser library (ijson) with a test suite using unittest. The library actually has several parsing implementations — “backends” — in the form of a modules with the identical API. I want to automatically run the test suite several times for each available backend. My goals are:

  • I want to keep all tests in one place as they are backend agnostic.
  • I want the name of the currently used backend to be visible in some fashion when a test fails.
  • I want to be able to run a single TestCase or a single test, as unittest normally allows.

So what’s the best way to organize the test suite for this? Write a custom test runner? Let TestCases load backends themselves? Imperatively generate separate TestCase classes for each backend?

By the way, I’m not married to unittest library in particular and I’m open to try another one if it solves the problem. But unittest is preferable since I already have the test code in place.

  • 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-06-13T01:40:24+00:00Added an answer on June 13, 2026 at 1:40 am

    One common way is to group all your tests together in one class with an abstract method that creates an instance of the backend (if you need to create multiple instances in a test), or expects setUp to create an instance of the backend.

    You can then create subclasses that create the different backends as needed.

    If you are using a test loader that automatically detects TestCase subclasses, you’ll probably need to make one change: don’t make the common base class a subclass of TestCase: instead treat it as a mixin, and make the backend classes subclass from both TestCase and the mixin.

    For example:

    class BackendTests:
        def make_backend(self):
            raise NotImplementedError
    
        def test_one(self):
            backend = self.make_backend()
            # perform a test on the backend
    
    class FooBackendTests(unittest.TestCase, BackendTests):
        def make_backend(self):
            # Create an instance of the "foo" backend:
            return foo_backend
    
    class BarBackendTests(unittest.TestCase, BackendTests):
        def make_backend(self):
            # Create an instance of the "bar" backend:
            return bar_backend
    

    When building a test suite from the above, you will have independent test cases FooBackendTests.test_one and BarBackendTests.test_one that test the same feature on the two backends.

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

Sidebar

Related Questions

I have recently started parsing JSON documents using SBJSON Parser, and I am able
I'm using the json.org library to parse my json. But I have a field
I'm trying to parse some JSON in Grails using the grails.converters.JSON library. I have
I am parsing JSON requests using the JSON library which parses into python dictionary.
I have been using GSON library to parse all the json string and get
i have question about YAJLiOS parser... I have next json data : {{ body
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
Suppose I am using Google's Gson library to parse JSON into Java data structures.
i have a question to deserialize JSON text to an javascript object, i test
Hi i am trying to parse Json using gson library.My Json String is this

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.