@@ -187,3 +187,73 @@ def fake_pwsh(cmd, **kwargs):
187187 assert cmds [out_idx + 1 ] == os .path .abspath (staging )
188188 assert os .path .exists (os .path .join (staging , "api.md" ))
189189 assert os .path .exists (os .path .join (staging , "azure-core_python.json" ))
190+
191+ @patch (
192+ "azpysdk.apistub.REPO_ROOT" , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , ".." ))
193+ )
194+ @patch ("azpysdk.apistub.PYTHON_VERSION_LIMIT" , (99 , 99 ))
195+ @patch ("azpysdk.apistub.get_cross_language_mapping_path" , return_value = None )
196+ @patch ("azpysdk.apistub.get_package_wheel_path" , return_value = "/fake/pkg.whl" )
197+ @patch ("azpysdk.apistub.create_package_and_install" )
198+ @patch ("azpysdk.apistub.install_into_venv" )
199+ @patch ("azpysdk.apistub.set_envvar_defaults" )
200+ def test_generate_md_adds_skip_pylint (self , _env , _install , _create , _get_whl , _get_mapping , tmp_path , monkeypatch ):
201+ """When --md is passed (generate_md=True), --skip-pylint must be in the cmds."""
202+ monkeypatch .chdir (os .getcwd ())
203+ stub = apistub ()
204+ staging = str (tmp_path / "staging" )
205+ os .makedirs (staging , exist_ok = True )
206+ fake_parsed = MagicMock ()
207+ fake_parsed .folder = str (tmp_path )
208+ fake_parsed .name = "azure-core"
209+
210+ captured_cmds = []
211+
212+ def fake_apistub_run (exe , cmds , ** kwargs ):
213+ captured_cmds .append (cmds )
214+
215+ with patch .object (stub , "get_targeted_directories" , return_value = [fake_parsed ]), patch .object (
216+ stub , "get_executable" , return_value = (sys .executable , staging )
217+ ), patch .object (stub , "install_dev_reqs" ), patch .object (stub , "pip_freeze" ), patch .object (
218+ stub , "run_venv_command" , side_effect = fake_apistub_run
219+ ):
220+ stub .run (self ._make_args (generate_md = True ))
221+
222+ assert len (captured_cmds ) == 1
223+ assert "--skip-pylint" in captured_cmds [0 ]
224+
225+ @patch (
226+ "azpysdk.apistub.REPO_ROOT" , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , ".." ))
227+ )
228+ @patch ("azpysdk.apistub.PYTHON_VERSION_LIMIT" , (99 , 99 ))
229+ @patch ("azpysdk.apistub.get_cross_language_mapping_path" , return_value = None )
230+ @patch ("azpysdk.apistub.get_package_wheel_path" , return_value = "/fake/pkg.whl" )
231+ @patch ("azpysdk.apistub.create_package_and_install" )
232+ @patch ("azpysdk.apistub.install_into_venv" )
233+ @patch ("azpysdk.apistub.set_envvar_defaults" )
234+ def test_no_generate_md_omits_skip_pylint (
235+ self , _env , _install , _create , _get_whl , _get_mapping , tmp_path , monkeypatch
236+ ):
237+ """When --md is not passed (generate_md=False), --skip-pylint must not be in the cmds."""
238+ monkeypatch .chdir (os .getcwd ())
239+ stub = apistub ()
240+ staging = str (tmp_path / "staging" )
241+ os .makedirs (staging , exist_ok = True )
242+ fake_parsed = MagicMock ()
243+ fake_parsed .folder = str (tmp_path )
244+ fake_parsed .name = "azure-core"
245+
246+ captured_cmds = []
247+
248+ def fake_apistub_run (exe , cmds , ** kwargs ):
249+ captured_cmds .append (cmds )
250+
251+ with patch .object (stub , "get_targeted_directories" , return_value = [fake_parsed ]), patch .object (
252+ stub , "get_executable" , return_value = (sys .executable , staging )
253+ ), patch .object (stub , "install_dev_reqs" ), patch .object (stub , "pip_freeze" ), patch .object (
254+ stub , "run_venv_command" , side_effect = fake_apistub_run
255+ ):
256+ stub .run (self ._make_args (generate_md = False ))
257+
258+ assert len (captured_cmds ) == 1
259+ assert "--skip-pylint" not in captured_cmds [0 ]
0 commit comments