(self)
| 770 | "This is an sqlite-specific issue", |
| 771 | ) |
| 772 | def test_transaction_support(self): |
| 773 | # Assert connections mocking is appropriately applied by preventing |
| 774 | # any attempts at calling create_test_db on the global connection |
| 775 | # objects. |
| 776 | for connection in db.connections.all(): |
| 777 | create_test_db = mock.patch.object( |
| 778 | connection.creation, |
| 779 | "create_test_db", |
| 780 | side_effect=AssertionError( |
| 781 | "Global connection object shouldn't be manipulated." |
| 782 | ), |
| 783 | ) |
| 784 | create_test_db.start() |
| 785 | self.addCleanup(create_test_db.stop) |
| 786 | for option_key, option_value in ( |
| 787 | ("NAME", ":memory:"), |
| 788 | ("TEST", {"NAME": ":memory:"}), |
| 789 | ): |
| 790 | tested_connections = db.ConnectionHandler( |
| 791 | { |
| 792 | "default": { |
| 793 | "ENGINE": "django.db.backends.sqlite3", |
| 794 | option_key: option_value, |
| 795 | }, |
| 796 | "other": { |
| 797 | "ENGINE": "django.db.backends.sqlite3", |
| 798 | option_key: option_value, |
| 799 | }, |
| 800 | } |
| 801 | ) |
| 802 | with mock.patch("django.test.utils.connections", new=tested_connections): |
| 803 | other = tested_connections["other"] |
| 804 | try: |
| 805 | new_test_connections = DiscoverRunner(verbosity=0).setup_databases() |
| 806 | msg = ( |
| 807 | f"DATABASES setting '{option_key}' option set to sqlite3's " |
| 808 | "':memory:' value shouldn't interfere with transaction support " |
| 809 | "detection." |
| 810 | ) |
| 811 | # Transaction support is properly initialized for the |
| 812 | # 'other' DB. |
| 813 | self.assertTrue(other.features.supports_transactions, msg) |
| 814 | # And all the DBs report that they support transactions. |
| 815 | self.assertTrue(connections_support_transactions(), msg) |
| 816 | finally: |
| 817 | for test_connection, _, _ in new_test_connections: |
| 818 | test_connection._close() |
| 819 | |
| 820 | |
| 821 | class DummyBackendTest(unittest.TestCase): |
nothing calls this directly
no test coverage detected