@@ -187,3 +187,83 @@ 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+ # Create the token JSON so the markdown generation branch can proceed
215+ out_idx = cmds .index ("--out-path" )
216+ out_dir = cmds [out_idx + 1 ]
217+ os .makedirs (out_dir , exist_ok = True )
218+ open (os .path .join (out_dir , "azure-core_python.json" ), "w" ).close ()
219+
220+ def fake_pwsh (cmd , ** kwargs ):
221+ return MagicMock (returncode = 0 , stdout = None )
222+
223+ with patch .object (stub , "get_targeted_directories" , return_value = [fake_parsed ]), patch .object (
224+ stub , "get_executable" , return_value = (sys .executable , staging )
225+ ), patch .object (stub , "install_dev_reqs" ), patch .object (stub , "pip_freeze" ), patch .object (
226+ stub , "run_venv_command" , side_effect = fake_apistub_run
227+ ), patch (
228+ "azpysdk.apistub.run" , side_effect = fake_pwsh
229+ ):
230+ stub .run (self ._make_args (generate_md = True ))
231+
232+ assert len (captured_cmds ) == 1
233+ assert "--skip-pylint" in captured_cmds [0 ]
234+
235+ @patch (
236+ "azpysdk.apistub.REPO_ROOT" , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , ".." ))
237+ )
238+ @patch ("azpysdk.apistub.PYTHON_VERSION_LIMIT" , (99 , 99 ))
239+ @patch ("azpysdk.apistub.get_cross_language_mapping_path" , return_value = None )
240+ @patch ("azpysdk.apistub.get_package_wheel_path" , return_value = "/fake/pkg.whl" )
241+ @patch ("azpysdk.apistub.create_package_and_install" )
242+ @patch ("azpysdk.apistub.install_into_venv" )
243+ @patch ("azpysdk.apistub.set_envvar_defaults" )
244+ def test_no_generate_md_omits_skip_pylint (
245+ self , _env , _install , _create , _get_whl , _get_mapping , tmp_path , monkeypatch
246+ ):
247+ """When --md is not passed (generate_md=False), --skip-pylint must not be in the cmds."""
248+ monkeypatch .chdir (os .getcwd ())
249+ stub = apistub ()
250+ staging = str (tmp_path / "staging" )
251+ os .makedirs (staging , exist_ok = True )
252+ fake_parsed = MagicMock ()
253+ fake_parsed .folder = str (tmp_path )
254+ fake_parsed .name = "azure-core"
255+
256+ captured_cmds = []
257+
258+ def fake_apistub_run (exe , cmds , ** kwargs ):
259+ captured_cmds .append (cmds )
260+
261+ with patch .object (stub , "get_targeted_directories" , return_value = [fake_parsed ]), patch .object (
262+ stub , "get_executable" , return_value = (sys .executable , staging )
263+ ), patch .object (stub , "install_dev_reqs" ), patch .object (stub , "pip_freeze" ), patch .object (
264+ stub , "run_venv_command" , side_effect = fake_apistub_run
265+ ):
266+ stub .run (self ._make_args (generate_md = False ))
267+
268+ assert len (captured_cmds ) == 1
269+ assert "--skip-pylint" not in captured_cmds [0 ]
0 commit comments