Download testbed/django__django/tests/backends/sqlite/test_creation.py from hc99/FEA-Bench: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/django__django/tests/backends/sqlite/test_creation.py
- Command line
-
hf download hf://datasets/hc99/FEA-Bench/testbed/django__django/tests/backends/sqlite/test_creation.py
-
curl -L -o test_creation.py https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/django__django/tests/backends/sqlite/test_creation.py
2.04 kB
| import copy | |
| import multiprocessing | |
| import unittest | |
| from unittest import mock | |
| from django.db import DEFAULT_DB_ALIAS, NotSupportedError, connection, connections | |
| from django.test import SimpleTestCase | |
| class TestDbSignatureTests(SimpleTestCase): | |
| def test_custom_test_name(self): | |
| test_connection = copy.copy(connections[DEFAULT_DB_ALIAS]) | |
| test_connection.settings_dict = copy.deepcopy( | |
| connections[DEFAULT_DB_ALIAS].settings_dict | |
| ) | |
| test_connection.settings_dict["NAME"] = None | |
| test_connection.settings_dict["TEST"]["NAME"] = "custom.sqlite.db" | |
| signature = test_connection.creation_class(test_connection).test_db_signature() | |
| self.assertEqual(signature, (None, "custom.sqlite.db")) | |
| def test_get_test_db_clone_settings_name(self): | |
| test_connection = copy.copy(connections[DEFAULT_DB_ALIAS]) | |
| test_connection.settings_dict = copy.deepcopy( | |
| connections[DEFAULT_DB_ALIAS].settings_dict, | |
| ) | |
| tests = [ | |
| ("test.sqlite3", "test_1.sqlite3"), | |
| ("test", "test_1"), | |
| ] | |
| for test_db_name, expected_clone_name in tests: | |
| with self.subTest(test_db_name=test_db_name): | |
| test_connection.settings_dict["NAME"] = test_db_name | |
| test_connection.settings_dict["TEST"]["NAME"] = test_db_name | |
| creation_class = test_connection.creation_class(test_connection) | |
| clone_settings_dict = creation_class.get_test_db_clone_settings("1") | |
| self.assertEqual(clone_settings_dict["NAME"], expected_clone_name) | |
| def test_get_test_db_clone_settings_not_supported(self, *mocked_objects): | |
| msg = "Cloning with start method 'forkserver' is not supported." | |
| with self.assertRaisesMessage(NotSupportedError, msg): | |
| connection.creation.get_test_db_clone_settings(1) | |