Best Python code snippet using lisa_python
test_creation.py
Source:test_creation.py
1import copy2import unittest3from django.db import DEFAULT_DB_ALIAS, connection, connections4from django.test import SimpleTestCase5@unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests")6class TestDbSignatureTests(SimpleTestCase):7 def test_custom_test_name(self):8 test_connection = copy.copy(connections[DEFAULT_DB_ALIAS])9 test_connection.settings_dict = copy.deepcopy(10 connections[DEFAULT_DB_ALIAS].settings_dict11 )12 test_connection.settings_dict["NAME"] = None13 test_connection.settings_dict["TEST"]["NAME"] = "custom.sqlite.db"14 signature = test_connection.creation_class(test_connection).test_db_signature()15 self.assertEqual(signature, (None, "custom.sqlite.db"))16 def test_get_test_db_clone_settings_name(self):17 test_connection = copy.copy(connections[DEFAULT_DB_ALIAS])18 test_connection.settings_dict = copy.deepcopy(19 connections[DEFAULT_DB_ALIAS].settings_dict,20 )21 tests = [22 ("test.sqlite3", "test_1.sqlite3"),23 ("test", "test_1"),24 ]25 for test_db_name, expected_clone_name in tests:26 with self.subTest(test_db_name=test_db_name):27 test_connection.settings_dict["NAME"] = test_db_name28 test_connection.settings_dict["TEST"]["NAME"] = test_db_name29 creation_class = test_connection.creation_class(test_connection)30 clone_settings_dict = creation_class.get_test_db_clone_settings("1")...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!