File tree Expand file tree Collapse file tree 1 file changed +6
-21
lines changed Expand file tree Collapse file tree 1 file changed +6
-21
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import platform
3
- import subprocess
4
3
import tarfile
5
4
from io import BytesIO
6
5
from pathlib import Path
7
6
from typing import Optional
7
+ from unittest .mock import Mock , patch
8
8
9
9
import pytest
10
10
@@ -446,29 +446,14 @@ def test_git_ls_unstaged(tmp_path):
446
446
assert {Path (x ) for x in unstaged_files } == expected_paths
447
447
448
448
449
- def test_git_command_includes_longpaths_on_windows (monkeypatch ):
450
- # GIVEN a mock for subprocess.run
451
- commands_run = []
452
-
453
- def mock_subprocess_run (args , ** kwargs ):
454
- commands_run .append (args )
455
-
456
- # Create a minimal mock result
457
- class Result :
458
- def __init__ (self ):
459
- self .stdout = b""
460
- self .stderr = b""
461
-
462
- return Result ()
463
-
464
- monkeypatch .setattr (subprocess , "run" , mock_subprocess_run )
465
-
466
- # WHEN executing any git command
449
+ @patch ("subprocess.run" , return_value = Mock (stdout = b"" ))
450
+ def test_git_command_includes_longpaths_on_windows (mock_run ):
451
+ # GIVEN any git command
467
452
git (["status" ])
453
+ mock_run .assert_called_once ()
468
454
469
455
# THEN the command includes core.longpaths=true if on Windows
470
- assert len (commands_run ) == 1
471
- command = commands_run [0 ]
456
+ command = mock_run .call_args [0 ][0 ]
472
457
longpaths_included = any (param == "core.longpaths=true" for param in command )
473
458
if platform .system () == "Windows" :
474
459
assert (
You can’t perform that action at this time.
0 commit comments