@@ -1285,59 +1285,6 @@ def run_query(self, query, new_line=True):
12851285 )
12861286
12871287
1288- def test_legacy_dsn_envvar_warns_and_falls_back (monkeypatch ):
1289- class Formatter :
1290- format_name = None
1291-
1292- class Logger :
1293- def debug (self , * args , ** args_dict ):
1294- pass
1295-
1296- def warning (self , * args , ** args_dict ):
1297- pass
1298-
1299- class MockMyCli :
1300- config = {
1301- 'main' : {},
1302- 'alias_dsn' : {},
1303- 'connection' : {
1304- 'default_keepalive_ticks' : 0 ,
1305- },
1306- }
1307-
1308- def __init__ (self , ** _args ):
1309- self .logger = Logger ()
1310- self .destructive_warning = False
1311- self .main_formatter = Formatter ()
1312- self .redirect_formatter = Formatter ()
1313- self .ssl_mode = 'auto'
1314- self .my_cnf = {'client' : {}, 'mysqld' : {}}
1315- self .default_keepalive_ticks = 0
1316-
1317- def connect (self , ** args ):
1318- MockMyCli .connect_args = args
1319-
1320- def run_query (self , query , new_line = True ):
1321- pass
1322-
1323- import mycli .main
1324-
1325- monkeypatch .setattr (mycli .main , 'MyCli' , MockMyCli )
1326- monkeypatch .setenv ('DSN' , 'mysql://dsn_user:dsn_passwd@dsn_host:8/dsn_database' )
1327- runner = CliRunner ()
1328-
1329- result = runner .invoke (mycli .main .click_entrypoint )
1330- assert result .exit_code == 0 , result .output + ' ' + str (result .exception )
1331- assert 'The DSN environment variable is deprecated' in result .output
1332- assert (
1333- MockMyCli .connect_args ['user' ] == 'dsn_user'
1334- and MockMyCli .connect_args ['passwd' ] == 'dsn_passwd'
1335- and MockMyCli .connect_args ['host' ] == 'dsn_host'
1336- and MockMyCli .connect_args ['port' ] == 8
1337- and MockMyCli .connect_args ['database' ] == 'dsn_database'
1338- )
1339-
1340-
13411288def test_password_flag_uses_sentinel (monkeypatch ):
13421289 class Formatter :
13431290 format_name = None
0 commit comments