Running the same tests with different configurations

I have Python code abstracting a database and business logic. This code already extends to unit tests, but now I need to check this code on different databases (MySQL, SQLite, etc.)

What is the default template for passing the same test suite with different configurations? My goal is to make sure that this level of abstraction works as expected regardless of the underlying database. If this can help, I use nosetests to run tests, but it seems like it lacks the concept of package testing

Sincerely.

+3
source share
3 answers

test fixtures , . Python , . , :

db_fixtures.py:

import unittest

class BaseDB(unittest.TestCase):
  def testFirstOperation(self):
    self.db.query("Foo")
  def testSecondOperation(self):
    self.db.query("Blah")      

database_tests.py:

import db_fixtures

class SQliteTest(db_fixtures.BaseDB):
  def setUp(self):
    self.db = createSqliteconnection()

class MySQLTest(db_fixtures.BaseDB):
  def setUp(self):
    self.db = createMySQLconnection()

, BaseDB MySQL, SQlite. , db_fixtures.py , Nose.

+1

, unittest.TestSuite. , lib unittest, tesys , .

, , , , , , , .

-1

use the -attrib plugin, and in the semicolon line

1. nosetests -s -a 'sqlite'
2.nosetests -s -a 'mysql'
-1
source

Source: https://habr.com/ru/post/1794417/


All Articles