test: skip DB-specific tests using new unimplemented_for decorator (#34749)

* test: skip DB-specific tests using new unimplemented_for decorator

* test: use unimplemented to skip tests with implementation problems

* test: update unimplemented to consider multi-DBs

* test: skip test_unbuffered_cursor using unimplemented for pg and sqlite

* test: update unimplemented wrapper
This commit is contained in:
Aarol D'Souza 2025-11-28 12:21:45 +05:30 committed by GitHub
parent b958200996
commit a7d8495d7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -3,7 +3,7 @@
import frappe
from frappe.core.doctype.data_import.importer import Importer
from frappe.tests import IntegrationTestCase
from frappe.tests.test_query_builder import db_type_is, run_only_if
from frappe.tests.test_query_builder import db_type_is, unimplemented_for
from frappe.utils import format_duration, getdate
doctype_name = "DocType for Import"
@ -78,7 +78,7 @@ class TestImporter(IntegrationTestCase):
self.assertEqual(len(preview.columns), 16)
# ignored on postgres because myisam doesn't exist on pg
@run_only_if(db_type_is.MARIADB)
@unimplemented_for(db_type_is.POSTGRES, db_type_is.SQLITE)
def test_data_import_without_mandatory_values(self):
import_file = get_import_file("sample_import_file_without_mandatory")
data_import = self.get_importer(doctype_name, import_file)

View file

@ -15,7 +15,7 @@ from frappe.database.utils import FallBackDateTimeStr
from frappe.query_builder import Field
from frappe.query_builder.functions import Concat_ws
from frappe.tests import IntegrationTestCase, timeout
from frappe.tests.test_query_builder import db_type_is, run_only_if
from frappe.tests.test_query_builder import db_type_is, run_only_if, unimplemented_for
from frappe.utils import add_days, now, random_string, set_request
from frappe.utils.data import now_datetime
from frappe.utils.testutils import clear_custom_fields
@ -1207,7 +1207,7 @@ class TestSqlIterator(IntegrationTestCase):
msg=f"{query=} results not same as iterator",
)
@run_only_if(db_type_is.MARIADB)
@unimplemented_for(db_type_is.POSTGRES, db_type_is.SQLITE)
def test_unbuffered_cursor(self):
with frappe.db.unbuffered_cursor():
self.test_db_sql_iterator()

View file

@ -26,6 +26,11 @@ def run_only_if(dbtype: db_type_is) -> Callable:
return unittest.skipIf(db_type_is(frappe.conf.db_type) != dbtype, f"Only runs for {dbtype.value}")
def unimplemented_for(*dbtypes: db_type_is) -> Callable:
current_db_type = db_type_is(frappe.conf.db_type)
return unittest.skipIf(current_db_type in dbtypes, f"Not Implemented for {current_db_type.value}")
@run_only_if(db_type_is.MARIADB)
class TestCustomFunctionsMariaDB(IntegrationTestCase):
def test_concat(self):