mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00:00 
			
		
		
		
	Removed noise from pre_syncdb signal tests
Only make assertions that actually test the functionality of the change and not unrelated pieces.
This commit is contained in:
		| @@ -1,4 +1,3 @@ | |||||||
| from django.db import connections |  | ||||||
| from django.db.models import signals | from django.db.models import signals | ||||||
| from django.test import TestCase | from django.test import TestCase | ||||||
| from django.core import management | from django.core import management | ||||||
| @@ -32,7 +31,6 @@ class OneTimeReceiver(object): | |||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         self.call_counter = 0 |         self.call_counter = 0 | ||||||
|         self.call_args = None |         self.call_args = None | ||||||
|         self.tables = None  # list of tables at the time of the call |  | ||||||
|  |  | ||||||
|     def __call__(self, signal, sender, **kwargs): |     def __call__(self, signal, sender, **kwargs): | ||||||
|         # Although test runner calls syncdb for several databases, |         # Although test runner calls syncdb for several databases, | ||||||
| @@ -40,8 +38,6 @@ class OneTimeReceiver(object): | |||||||
|         if kwargs['db'] == SYNCDB_DATABASE: |         if kwargs['db'] == SYNCDB_DATABASE: | ||||||
|             self.call_counter = self.call_counter + 1 |             self.call_counter = self.call_counter + 1 | ||||||
|             self.call_args = kwargs |             self.call_args = kwargs | ||||||
|             connection = connections[SYNCDB_DATABASE] |  | ||||||
|             self.tables = connection.introspection.table_names() |  | ||||||
|             # we need to test only one call of syncdb |             # we need to test only one call of syncdb | ||||||
|             signals.pre_syncdb.disconnect(pre_syncdb_receiver, sender=models) |             signals.pre_syncdb.disconnect(pre_syncdb_receiver, sender=models) | ||||||
|  |  | ||||||
| @@ -61,7 +57,6 @@ signals.pre_syncdb.connect(pre_syncdb_receiver, sender=models) | |||||||
| class SyncdbSignalTests(TestCase): | class SyncdbSignalTests(TestCase): | ||||||
|     def test_pre_syncdb_call_time(self): |     def test_pre_syncdb_call_time(self): | ||||||
|         self.assertEqual(pre_syncdb_receiver.call_counter, 1) |         self.assertEqual(pre_syncdb_receiver.call_counter, 1) | ||||||
|         self.assertFalse(pre_syncdb_receiver.tables) |  | ||||||
|  |  | ||||||
|     def test_pre_syncdb_args(self): |     def test_pre_syncdb_args(self): | ||||||
|         r = PreSyncdbReceiver() |         r = PreSyncdbReceiver() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user