1- test_that(" Path can be derived for windows Python >= 3.0" , {
2- paths_base <- with_mock (
3- " precommit:: path_derive_precommit_exec_win_python3plus_candidates" = function () {
1+ test_that(" Path can be derived for windows Python >= 3.0 (mocked) " , {
2+ local_mocked_bindings (
3+ path_derive_precommit_exec_win_python3plus_candidates = function () {
44 c(
55 fs :: path_home(" AppData/Roaming/Python/Python35" ),
66 fs :: path_home(" AppData/Roaming/Python/Python37" )
77 )
8- },
9- path_derive_precommit_exec_win_python3plus_base()
8+ }
109 )
1110
1211 expect_equal(
13- paths_base ,
12+ path_derive_precommit_exec_win_python3plus_base() ,
1413 c(
1514 fs :: path(fs :: path_home(), " AppData/Roaming/Python/Python37/Scripts" ),
1615 fs :: path(fs :: path_home(), " AppData/Roaming/Python/Python35/Scripts" )
17- )
16+ ),
17+ ignore_attr = TRUE
1818 )
19+ })
20+
21+
22+ test_that(" Path can be derived for windows Python >= 3.0 (actual)" , {
1923 skip_if(! is_windows())
2024 skip_if(! not_conda())
2125 skip_if(on_cran())
@@ -28,61 +32,63 @@ test_that("Path can be derived for windows Python >= 3.0", {
2832
2933
3034test_that(" Warns when there are multiple installations found (2x os)" , {
35+ local_mocked_bindings(
36+ path_derive_precommit_exec_path = function (candidate ) {
37+ fs :: path_home(" AppData/Roaming/Python/Python35" )
38+ },
39+ get_os = function (... ) {
40+ c(sysname = " windows" )
41+ },
42+ path_derive_precommit_exec_win = function () {
43+ c(
44+ fs :: path_home(" AppData/Roaming/Python/Python34" ),
45+ fs :: path_home(" AppData/Roaming/Python/Python37" )
46+ )
47+ }
48+ )
49+
3150 expect_warning(
32- with_mock(
33- " precommit::path_derive_precommit_exec_path" = function (candidate ) {
34- fs :: path_home(" AppData/Roaming/Python/Python35" )
35- },
36- " Sys.info" = function (... ) {
37- c(sysname = " windows" )
38- },
39- " precommit:::path_derive_precommit_exec_win" = function () {
40- c(
41- fs :: path_home(" AppData/Roaming/Python/Python34" ),
42- fs :: path_home(" AppData/Roaming/Python/Python37" )
43- )
44- },
45- path_derive_precommit_exec()
46- ),
51+ path_derive_precommit_exec(),
4752 " We detected multiple pre-commit executables"
4853 )
4954})
5055
5156test_that(" Warns when there are multiple installations found (2x path)" , {
57+ local_mocked_bindings(
58+ path_derive_precommit_exec_path = function (candidate ) {
59+ c(
60+ fs :: path_home(" AppData/Roaming/Python/Python35" ),
61+ fs :: path_home(" AppData/Roaming/Python/Python37" )
62+ )
63+ },
64+ get_os = function (... ) {
65+ c(sysname = " windows" )
66+ },
67+ path_derive_precommit_exec_win = function () {
68+ fs :: path_home(" AppData/Roaming/Python/Python34" )
69+ }
70+ )
5271 expect_warning(
53- with_mock(
54- " precommit::path_derive_precommit_exec_path" = function (candidate ) {
55- c(
56- fs :: path_home(" AppData/Roaming/Python/Python35" ),
57- fs :: path_home(" AppData/Roaming/Python/Python37" )
58- )
59- },
60- " Sys.info" = function (... ) {
61- c(sysname = " windows" )
62- },
63- " precommit:::path_derive_precommit_exec_win" = function () {
64- fs :: path_home(" AppData/Roaming/Python/Python34" )
65- },
66- path_derive_precommit_exec()
67- ),
72+ path_derive_precommit_exec(),
6873 " We detected multiple pre-commit executables"
6974 )
7075})
7176
7277test_that(" Warns when there are multiple installations found (path and os)" , {
78+ local_mocked_bindings(
79+ path_derive_precommit_exec_path = function (candidate ) {
80+ fs :: path_home(" AppData/Roaming/Python/Python35" )
81+ },
82+ path_derive_precommit_exec_win = function () {
83+ fs :: path_home(" AppData/Roaming/Python/Python34" )
84+ },
85+ get_os = function (... ) {
86+ c(sysname = " windows" )
87+ },
88+ )
89+
7390 expect_warning(
74- with_mock(
75- " precommit::path_derive_precommit_exec_path" = function (candidate ) {
76- fs :: path_home(" AppData/Roaming/Python/Python35" )
77- },
78- " Sys.info" = function (... ) {
79- c(sysname = " windows" )
80- },
81- " precommit:::path_derive_precommit_exec_win" = function () {
82- fs :: path_home(" AppData/Roaming/Python/Python34" )
83- },
84- path_derive_precommit_exec()
85- ),
91+ path_derive_precommit_exec(),
8692 " We detected multiple pre-commit executables"
8793 )
8894})
0 commit comments