@@ -57,19 +57,24 @@ def fake_uaclient(mocker):
5757 m_uaclient = mock .Mock ()
5858
5959 sys .modules ["uaclient" ] = m_uaclient
60+ mock_exceptions_module = mock .Mock ()
6061
6162 # Exceptions
62- _exceptions = namedtuple (
63- "exceptions " ,
63+ Exceptions = namedtuple (
64+ "Exceptions " ,
6465 [
6566 "UserFacingError" ,
6667 "AlreadyAttachedError" ,
6768 ],
68- )(
69+ )
70+ mock_exceptions_module .UserFacingError = FakeUserFacingError
71+ mock_exceptions_module .AlreadyAttachedError = FakeAlreadyAttachedError
72+ sys .modules ["uaclient.api.exceptions" ] = mock_exceptions_module
73+ _exceptions = Exceptions (
6974 FakeUserFacingError ,
7075 FakeAlreadyAttachedError ,
7176 )
72- sys . modules [ "uaclient.api.exceptions" ] = _exceptions
77+ return _exceptions
7378
7479
7580@pytest .mark .usefixtures ("fake_uaclient" )
@@ -834,7 +839,7 @@ def test_handle_attach(
834839 caplog ,
835840 ):
836841 """Non-Pro schemas and instance."""
837- handle ("nomatter" , cfg = cfg , cloud = cloud , args = None )
842+ handle ("nomatter" , cfg = cfg , cloud = cloud , args = [] )
838843 for record_tuple in log_record_tuples :
839844 assert record_tuple in caplog .record_tuples
840845 if maybe_install_call_args_list is not None :
@@ -961,7 +966,7 @@ def test_handle_auto_attach_vs_attach(
961966 m_auto_attach .side_effect = auto_attach_side_effect
962967
963968 with expectation :
964- handle ("nomatter" , cfg = cfg , cloud = cloud , args = None )
969+ handle ("nomatter" , cfg = cfg , cloud = cloud , args = [] )
965970
966971 for record_tuple in log_record_tuples :
967972 assert record_tuple in caplog .record_tuples
@@ -1006,7 +1011,7 @@ def test_no_fallback_attach(
10061011 enable or disable pro auto-attach.
10071012 """
10081013 m_should_auto_attach .return_value = is_pro
1009- handle ("nomatter" , cfg = cfg , cloud = self .cloud , args = None )
1014+ handle ("nomatter" , cfg = cfg , cloud = self .cloud , args = [] )
10101015 assert not m_attach .call_args_list
10111016
10121017 @pytest .mark .parametrize (
@@ -1061,7 +1066,7 @@ def test_handle_errors(self, cfg, match):
10611066 "nomatter" ,
10621067 cfg = cfg ,
10631068 cloud = self .cloud ,
1064- args = None ,
1069+ args = [] ,
10651070 )
10661071
10671072 @mock .patch (f"{ MPATH } .subp.subp" )
@@ -1087,7 +1092,7 @@ def test_pro_config_error_invalid_url(self, m_subp, caplog):
10871092 "nomatter" ,
10881093 cfg = cfg ,
10891094 cloud = self .cloud ,
1090- args = None ,
1095+ args = [] ,
10911096 )
10921097 assert not caplog .text
10931098
@@ -1107,7 +1112,7 @@ def test_fallback_to_attach_no_token(
11071112 "nomatter" ,
11081113 cfg = cfg ,
11091114 cloud = self .cloud ,
1110- args = None ,
1115+ args = [] ,
11111116 )
11121117 assert [] == m_subp .call_args_list
11131118 assert (
0 commit comments