@@ -45,49 +45,44 @@ class TestPGNotifyConnection:
4545 'port' : 55434 ,
4646 # 'context': <psycopg.adapt.AdaptersMap object at 0x7f537f2d9f70>,
4747 'prepare_threshold' : None ,
48- 'autocommit' : True ,
4948 }
5049
5150 @pytest .fixture
5251 def mock_settings (self ):
5352 with override_settings (DATABASES = self .TEST_DATABASE_DICT , USE_TZ = False ):
5453 yield
5554
56- def _trim_python_objects (self , psycopg_params ):
57- # These remove those commented-out kwargs in PSYCOPG_KWARGS
58- psycopg_params .pop ('cursor_factory' )
59- psycopg_params .pop ('context' )
60- return psycopg_params
61-
6255 def test_default_behavior (self , mock_settings ):
63- params = self . _trim_python_objects ( get_pg_notify_params () )
56+ params = get_pg_notify_params ()
6457 assert params == self .PSYCOPG_KWARGS
6558
6659 def test_pg_notify_extra_options (self , mock_settings ):
67- params = self . _trim_python_objects ( get_pg_notify_params (application_name = 'joe_connection' ) )
60+ params = get_pg_notify_params (application_name = 'joe_connection' )
6861 expected = self .PSYCOPG_KWARGS .copy ()
6962 expected ['application_name' ] = 'joe_connection'
7063 assert params == expected
7164
7265 def test_lister_databases (self , mock_settings ):
7366 LISTENER_DATABASES = {"default" : {"HOST" : "https://foo.anotherhost.invalid" }}
7467 with override_settings (LISTENER_DATABASES = LISTENER_DATABASES ):
75- params = self . _trim_python_objects ( get_pg_notify_params () )
68+ params = get_pg_notify_params ()
7669 assert params ['host' ] == "https://foo.anotherhost.invalid"
7770
7871 def test_pg_notify_databases (self , mock_settings ):
7972 PG_NOTIFY_DATABASES = {"default" : {"HOST" : "https://foo.anotherhost2.invalid" }}
8073 with override_settings (PG_NOTIFY_DATABASES = PG_NOTIFY_DATABASES ):
81- params = self . _trim_python_objects ( get_pg_notify_params () )
74+ params = get_pg_notify_params ()
8275 assert params ['host' ] == "https://foo.anotherhost2.invalid"
8376
8477 def test_psycopg_kwargs_from_settings_dict (self ):
8578 "More of a unit test, doing the same thing"
8679 test_dict = self .TEST_DATABASE_DICT ["default" ].copy ()
8780 test_dict ['OPTIONS' ] = {'autocommit' : True }
8881 with override_settings (USE_TZ = False ):
89- psycopg_params = self ._trim_python_objects (psycopg_kwargs_from_settings_dict (test_dict ))
90- assert psycopg_params == self .PSYCOPG_KWARGS
82+ psycopg_params = psycopg_kwargs_from_settings_dict (test_dict )
83+ expected_kwargs = self .PSYCOPG_KWARGS .copy ()
84+ expected_kwargs ['autocommit' ] = True
85+ assert psycopg_params == expected_kwargs
9186
9287 def test_psycopg_kwargs_use (self ):
9388 "This assures that the data we get for the kwargs are usable, and demos how to use"
@@ -97,7 +92,7 @@ def test_psycopg_kwargs_use(self):
9792 test_dict = settings .DATABASES ['default' ].copy ()
9893 test_dict ['OPTIONS' ] = {'autocommit' : True }
9994 with override_settings (USE_TZ = False ):
100- psycopg_params = self . _trim_python_objects ( psycopg_kwargs_from_settings_dict (test_dict ) )
95+ psycopg_params = psycopg_kwargs_from_settings_dict (test_dict )
10196
10297 psycopg .connect (** psycopg_params )
10398
0 commit comments