-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathtest_cli_utils.py
More file actions
679 lines (543 loc) · 22.9 KB
/
test_cli_utils.py
File metadata and controls
679 lines (543 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
import os
import subprocess
import sys
import tempfile
from typing import Any, Dict
from unittest.mock import patch
import pytest
from pathspec import GitIgnoreSpec
from vectorcode import cli_utils
from vectorcode.cli_utils import (
CliAction,
Config,
FilesAction,
LockManager,
PromptCategory,
QueryInclude,
SpecResolver,
cleanup_path,
expand_envs_in_dict,
expand_globs,
expand_path,
find_project_config_dir,
find_project_root,
get_project_config,
load_config_file,
parse_cli_args,
)
@pytest.mark.asyncio
async def test_config_import_from():
with tempfile.TemporaryDirectory() as temp_dir:
db_path = os.path.join(temp_dir, "test_db")
os.makedirs(db_path, exist_ok=True)
config_dict: Dict[str, Any] = {
"db_path": db_path,
"db_url": "http://test_host:1234",
"embedding_function": "TestEmbedding",
"embedding_params": {"param1": "value1"},
"chunk_size": 512,
"overlap_ratio": 0.3,
"query_multiplier": 5,
"reranker": "TestReranker",
"reranker_params": {"reranker_param1": "reranker_value1"},
"db_settings": {"db_setting1": "db_value1"},
}
config = await Config.import_from(config_dict)
assert config.db_path == db_path
assert config.db_log_path == os.path.expanduser("~/.local/share/vectorcode/")
assert config.db_url == "http://test_host:1234"
assert config.embedding_function == "TestEmbedding"
assert config.embedding_params == {"param1": "value1"}
assert config.chunk_size == 512
assert config.overlap_ratio == 0.3
assert config.query_multiplier == 5
assert config.reranker == "TestReranker"
assert config.reranker_params == {"reranker_param1": "reranker_value1"}
assert config.db_settings == {"db_setting1": "db_value1"}
@pytest.mark.asyncio
async def test_config_import_from_invalid_path():
config_dict: Dict[str, Any] = {"db_path": "/path/does/not/exist"}
with pytest.raises(IOError):
await Config.import_from(config_dict)
@pytest.mark.asyncio
async def test_config_import_from_db_path_is_file():
with tempfile.TemporaryDirectory() as temp_dir:
db_path = os.path.join(temp_dir, "test_db_file")
with open(db_path, "w") as f:
f.write("test")
config_dict: Dict[str, Any] = {"db_path": db_path}
with pytest.raises(IOError):
await Config.import_from(config_dict)
@pytest.mark.asyncio
async def test_config_merge_from():
config1 = Config(db_url="http://host1:8001", n_result=5)
config2 = Config(db_url="http://host2:8002", query=["test"])
merged_config = await config1.merge_from(config2)
assert merged_config.db_url == "http://host2:8002"
assert merged_config.n_result == 5
assert merged_config.query == ["test"]
@pytest.mark.asyncio
async def test_config_merge_from_new_fields():
config1 = Config(db_url="http://host1:8001")
config2 = Config(query=["test"], n_result=10, recursive=True)
merged_config = await config1.merge_from(config2)
assert merged_config.db_url == "http://host1:8001"
assert merged_config.query == ["test"]
assert merged_config.n_result == 10
assert merged_config.recursive
@pytest.mark.asyncio
async def test_config_import_from_missing_keys():
config_dict: Dict[str, Any] = {} # Empty dictionary, all keys missing
config = await Config.import_from(config_dict)
# Assert that default values are used
assert config.embedding_function == "SentenceTransformerEmbeddingFunction"
assert config.embedding_params == {}
assert config.db_url == "http://127.0.0.1:8000"
assert config.db_path == os.path.expanduser("~/.local/share/vectorcode/chromadb/")
assert config.chunk_size == 2500
assert config.overlap_ratio == 0.2
assert config.query_multiplier == -1
assert config.reranker == "NaiveReranker"
assert config.reranker_params == {}
assert config.db_settings is None
def test_expand_envs_in_dict():
os.environ["TEST_VAR"] = "test_value"
d = {"key1": "$TEST_VAR", "key2": {"nested_key": "$TEST_VAR"}}
expand_envs_in_dict(d)
assert d["key1"] == "test_value"
assert d["key2"]["nested_key"] == "test_value"
d = {"key3": "$NON_EXISTENT_VAR"}
expand_envs_in_dict(d)
assert d["key3"] == "$NON_EXISTENT_VAR" # Should remain unchanged
d = {"key4": "$TEST_VAR2"}
expand_envs_in_dict(d)
assert d["key4"] == "$TEST_VAR2" # Should remain unchanged
del os.environ["TEST_VAR"] # Clean up the env
@pytest.mark.asyncio
async def test_expand_globs():
with tempfile.TemporaryDirectory() as temp_dir:
file1_path = os.path.join(temp_dir, "file1.txt")
dir1_path = os.path.join(temp_dir, "dir1")
file2_path = os.path.join(dir1_path, "file2.txt")
dir2_path = os.path.join(temp_dir, "dir2")
file3_path = os.path.join(dir2_path, "file3.txt")
os.makedirs(dir1_path, exist_ok=True)
os.makedirs(dir2_path, exist_ok=True)
with open(file1_path, "w") as f:
f.write("content")
with open(file2_path, "w") as f:
f.write("content")
with open(file3_path, "w") as f:
f.write("content")
paths = [file1_path, dir1_path]
expanded_paths = await expand_globs(paths, recursive=True)
assert len(expanded_paths) == 2
assert file1_path in expanded_paths
assert file2_path in expanded_paths
paths = [os.path.join(temp_dir, "*.txt")]
expanded_paths = await expand_globs(paths, recursive=False)
assert len(expanded_paths) == 1 # Expecting 1 file in the temp_dir
paths = [dir1_path]
expanded_paths = await expand_globs(paths, recursive=True)
assert len(expanded_paths) == 1
assert file2_path in expanded_paths
assert len(await expand_globs([os.path.join(temp_dir, "**", "*.txt")])) == 3
def test_expand_path():
path_with_user = "~/test_dir"
expanded_path = expand_path(path_with_user)
assert expanded_path == os.path.join(os.path.expanduser("~"), "test_dir")
os.environ["TEST_VAR"] = "test_value"
path_with_env = "$TEST_VAR/test_dir"
expanded_path = expand_path(path_with_env)
assert expanded_path == os.path.join("test_value", "test_dir")
abs_path = "/tmp/test_dir"
expanded_path = expand_path(abs_path)
assert expanded_path == abs_path
rel_path = "test_dir"
expanded_path = expand_path(rel_path)
assert expanded_path == rel_path
abs_path = "~/test_dir"
expanded_path = expand_path(abs_path, absolute=True)
assert expanded_path == os.path.abspath(os.path.expanduser(abs_path))
@pytest.mark.asyncio
async def test_load_config_file_invalid_json():
with tempfile.TemporaryDirectory() as temp_dir:
config_path = os.path.join(temp_dir, "config.json")
with open(config_path, "w") as f:
f.write("invalid json")
with pytest.raises(ValueError):
await load_config_file(config_path)
@pytest.mark.asyncio
async def test_load_config_file_merging():
with tempfile.TemporaryDirectory() as dummy_home:
global_config_dir = os.path.join(dummy_home, ".config", "vectorcode")
os.makedirs(global_config_dir, exist_ok=True)
with open(os.path.join(global_config_dir, "config.json"), mode="w") as fin:
fin.writelines(['{"embedding_function": "DummyEmbeddingFunction"}'])
with tempfile.TemporaryDirectory(dir=dummy_home) as proj_root:
os.makedirs(os.path.join(proj_root, ".vectorcode"), exist_ok=True)
with open(
os.path.join(proj_root, ".vectorcode", "config.json"), mode="w"
) as fin:
fin.writelines(
['{"embedding_function": "AnotherDummyEmbeddingFunction"}']
)
with patch(
"vectorcode.cli_utils.GLOBAL_CONFIG_DIR", new=str(global_config_dir)
):
assert (
await load_config_file()
).embedding_function == "DummyEmbeddingFunction"
assert (
await load_config_file(proj_root)
).embedding_function == "AnotherDummyEmbeddingFunction"
@pytest.mark.asyncio
async def test_load_config_file_with_envs():
with tempfile.TemporaryDirectory() as proj_root:
os.makedirs(os.path.join(proj_root, ".vectorcode"), exist_ok=True)
with (
open(
os.path.join(proj_root, ".vectorcode", "config.json"), mode="w"
) as fin,
):
fin.writelines(['{"embedding_function": "$DUMMY_EMBEDDING_FUNCTION"}'])
with patch.dict(
os.environ, {"DUMMY_EMBEDDING_FUNCTION": "DummyEmbeddingFunction"}
):
assert (
await load_config_file(proj_root)
).embedding_function == "DummyEmbeddingFunction"
@pytest.mark.asyncio
async def test_load_from_default_config():
for name in ("config.json5", "config.json"):
with (
tempfile.TemporaryDirectory() as fake_home,
):
os.environ.update({"HOME": fake_home})
config_path = os.path.join(fake_home, ".config", "vectorcode", name)
config_dir = os.path.join(fake_home, ".config", "vectorcode")
setattr(
cli_utils,
"GLOBAL_CONFIG_DIR",
config_dir,
)
os.makedirs(config_dir, exist_ok=True)
config_content = '{"db_url": "http://default.url:8000"}'
with open(config_path, "w") as fin:
fin.write(config_content)
config = await load_config_file()
assert config.db_url == "http://default.url:8000"
@pytest.mark.asyncio
async def test_load_config_file_invalid_config():
with tempfile.TemporaryDirectory() as temp_dir:
config_path = os.path.join(temp_dir, "config.json")
with open(config_path, "w") as f:
f.write('"hello world"')
with pytest.raises(ValueError):
await load_config_file(config_path)
@pytest.mark.asyncio
async def test_find_project_config_dir_no_anchors():
with tempfile.TemporaryDirectory() as temp_dir:
project_dir = await find_project_config_dir(temp_dir)
assert project_dir is None
@pytest.mark.asyncio
async def test_expand_globs_nonexistent_path():
expanded_paths = await expand_globs(["/path/does/not/exist"])
assert len(expanded_paths) == 0
@pytest.mark.asyncio
async def test_load_config_file_empty_file():
with tempfile.TemporaryDirectory() as temp_dir:
config_path = os.path.join(temp_dir, "config.json")
with open(config_path, "w") as f:
f.write("")
with pytest.raises(ValueError):
await load_config_file(config_path)
@pytest.mark.asyncio
async def test_find_project_config_dir_nested():
with tempfile.TemporaryDirectory() as temp_dir:
level1_dir = os.path.join(temp_dir, "level1")
level2_dir = os.path.join(level1_dir, "level2")
level3_dir = os.path.join(level2_dir, "level3")
os.makedirs(level3_dir)
# Create a .vectorcode directory in level2
vectorcode_dir = os.path.join(level2_dir, ".vectorcode")
os.makedirs(vectorcode_dir)
# Create a .git directory in level1
git_dir = os.path.join(level1_dir, ".git")
os.makedirs(git_dir)
# Test finding from level3_dir; should find .vectorcode in level2
found_dir = await find_project_config_dir(level3_dir)
assert found_dir is not None and os.path.samefile(found_dir, vectorcode_dir)
# Test finding from level2_dir; should find .vectorcode in level2
found_dir = await find_project_config_dir(level2_dir)
assert found_dir is not None and os.path.samefile(found_dir, vectorcode_dir)
# Test finding from level1_dir; should find .git in level1
found_dir = await find_project_config_dir(level1_dir)
assert found_dir is not None and os.path.samefile(found_dir, git_dir)
@pytest.mark.asyncio
async def test_expand_globs_mixed_paths():
with tempfile.TemporaryDirectory() as temp_dir:
existing_file = os.path.join(temp_dir, "existing_file.txt")
with open(existing_file, "w") as f:
f.write("content")
paths = [existing_file, "/path/does/not/exist"]
expanded_paths = await expand_globs(paths)
assert len(expanded_paths) == 1
assert existing_file in expanded_paths
@pytest.mark.asyncio
async def test_cli_arg_parser():
with patch(
"sys.argv", ["vectorcode", "query", "test_query", "-n", "5", "--absolute"]
):
config = await parse_cli_args()
assert config.action == CliAction.query
assert config.query == ["test_query"]
assert config.n_result == 5
assert config.use_absolute_path
def test_query_include_to_header():
assert QueryInclude.path.to_header() == "Path: "
assert QueryInclude.document.to_header() == "Document:\n"
def test_find_project_root():
with tempfile.TemporaryDirectory() as temp_dir:
# Test when no anchor file exists
assert find_project_root(temp_dir) is None
# Test when anchor file exists
os.makedirs(os.path.join(temp_dir, ".vectorcode"))
found_dir = find_project_root(temp_dir)
assert found_dir is not None and os.path.samefile(found_dir, temp_dir)
# Test when start_from is a file
test_file = os.path.join(temp_dir, "test_file.txt")
open(test_file, "a").close()
found_dir = find_project_root(test_file)
assert found_dir is not None and os.path.samefile(found_dir, temp_dir)
@pytest.mark.asyncio
async def test_get_project_config_no_local_config():
with tempfile.TemporaryDirectory() as temp_dir:
config = await get_project_config(temp_dir)
assert config.chunk_size == Config().chunk_size, "Should load default value."
@pytest.mark.asyncio
async def test_parse_cli_args_no_action():
with patch("sys.argv", ["vectorcode"]):
with pytest.raises(SystemExit):
await parse_cli_args()
@pytest.mark.asyncio
async def test_parse_cli_args_include_argument():
with patch(
"sys.argv",
[
"vectorcode",
"query",
"test_query",
"--include",
"path",
"document",
],
):
config = await parse_cli_args()
assert config.include == [QueryInclude.path, QueryInclude.document]
@pytest.mark.asyncio
async def test_parse_cli_args_vectorise():
with patch("sys.argv", ["vectorcode", "vectorise", "file1.txt"]):
config = await parse_cli_args()
assert config.action == CliAction.vectorise
assert config.files == ["file1.txt"]
@pytest.mark.asyncio
async def test_parse_cli_args_vectorise_encoding():
with patch(
"sys.argv", ["vectorcode", "vectorise", "file1.txt", "--encoding", "gbk"]
):
config = await parse_cli_args()
assert config.action == CliAction.vectorise
assert config.files == ["file1.txt"]
assert config.encoding == "gbk"
@pytest.mark.asyncio
async def test_parse_cli_args_vectorise_recursive_dir():
with patch("sys.argv", ["vectorcode", "vectorise", "-r", "."]):
config = await parse_cli_args()
assert config.action == CliAction.vectorise
assert config.files == ["."]
assert config.recursive is True
assert config.include_hidden is False
@pytest.mark.asyncio
async def test_parse_cli_args_vectorise_recursive_dir_include_hidden():
with patch("sys.argv", ["vectorcode", "vectorise", "-r", "."]):
config = await parse_cli_args()
assert config.action == CliAction.vectorise
assert config.files == ["."]
assert config.recursive is True
assert config.include_hidden is False
@pytest.mark.asyncio
async def test_parse_cli_args_vectorise_no_files():
with patch("sys.argv", ["vectorcode", "vectorise"]):
config = await parse_cli_args()
assert config.action == CliAction.vectorise
assert config.files == []
@pytest.mark.asyncio
async def test_get_project_config_local_config(tmp_path):
project_root = tmp_path / "project"
vectorcode_dir = project_root / ".vectorcode"
vectorcode_dir.mkdir(parents=True)
config_file = vectorcode_dir / "config.json"
config_file.write_text('{"db_url": "http://test_host:9999" }')
config = await get_project_config(project_root)
assert config.db_url == "http://test_host:9999"
@pytest.mark.asyncio
async def test_get_project_config_local_config_json5(tmp_path):
project_root = tmp_path / "project"
vectorcode_dir = project_root / ".vectorcode"
vectorcode_dir.mkdir(parents=True)
config_file = vectorcode_dir / "config.json5"
config_file.write_text('{"db_url": "http://test_host:9999" }')
config = await get_project_config(project_root)
assert config.db_url == "http://test_host:9999"
def test_find_project_root_file_input(tmp_path):
# Create a temporary file
temp_file = tmp_path / "temp_file.txt"
temp_file.write_text("test content")
# Create a .vectorcode directory in the parent directory
vectorcode_dir = tmp_path / ".vectorcode"
vectorcode_dir.mkdir()
# Call find_project_root with the temporary file path
project_root = find_project_root(temp_file)
# Assert that it returns the parent directory (tmp_path)
assert os.path.samefile(str(project_root), str(tmp_path))
@pytest.mark.asyncio
async def test_parse_cli_args_update():
with patch("sys.argv", ["vectorcode", "update"]):
config = await parse_cli_args()
assert config.action == CliAction.update
@pytest.mark.asyncio
async def test_parse_cli_args_clean():
with patch("sys.argv", ["vectorcode", "clean"]):
config = await parse_cli_args()
assert config.action == CliAction.clean
@pytest.mark.asyncio
async def test_parse_cli_args_check():
with patch("sys.argv", ["vectorcode", "check", "config"]):
config = await parse_cli_args()
assert config.action == CliAction.check
assert config.check_item == "config"
@pytest.mark.asyncio
async def test_parse_cli_args_init():
with patch("sys.argv", ["vectorcode", "init"]):
config = await parse_cli_args()
assert config.action == CliAction.init
@pytest.mark.asyncio
async def test_parse_cli_args_prompts():
with patch("sys.argv", ["vectorcode", "prompts", "ls"]):
config = await parse_cli_args()
assert config.action == CliAction.prompts
assert config.prompt_categories == [PromptCategory.ls]
@pytest.mark.asyncio
async def test_parse_cli_args_chunks():
with patch(
"sys.argv", ["vectorcode", "chunks", "file.py", "-c", "100", "-o", "0.5"]
):
config = await parse_cli_args()
assert config.action == CliAction.chunks
assert config.overlap_ratio == 0.5
assert config.chunk_size == 100
with patch("sys.argv", ["vectorcode", "chunks", "file.py"]):
config = await parse_cli_args()
assert config.action == CliAction.chunks
assert config.overlap_ratio == Config().overlap_ratio
assert config.chunk_size == Config().chunk_size
@pytest.mark.asyncio
async def test_parse_cli_args_files():
with patch("sys.argv", ["vectorcode", "files", "ls"]):
config = await parse_cli_args()
assert config.action == CliAction.files
assert config.files_action == FilesAction.ls
with patch("sys.argv", ["vectorcode", "files", "rm", "foo.txt"]):
config = await parse_cli_args()
assert config.action == CliAction.files
assert config.files_action == FilesAction.rm
assert config.rm_paths == ["foo.txt"]
@pytest.mark.asyncio
async def test_config_import_from_hnsw():
with tempfile.TemporaryDirectory() as temp_dir:
db_path = os.path.join(temp_dir, "test_db")
os.makedirs(db_path, exist_ok=True)
config_dict: Dict[str, Any] = {
"hnsw": {"space": "cosine", "ef_construction": 200, "m": 32}
}
config = await Config.import_from(config_dict)
assert config.hnsw["space"] == "cosine"
assert config.hnsw["ef_construction"] == 200
assert config.hnsw["m"] == 32
@pytest.mark.asyncio
async def test_hnsw_config_merge():
config1 = Config(hnsw={"space": "ip"})
config2 = Config(hnsw={"ef_construction": 200})
merged_config = await config1.merge_from(config2)
assert merged_config.hnsw["space"] == "ip"
assert merged_config.hnsw["ef_construction"] == 200
def test_cleanup_path():
home = os.environ.get("HOME")
if home is None:
return
assert cleanup_path(os.path.join(home, "test_path")) == os.path.join(
"~", "test_path"
)
assert cleanup_path("/etc/dir") == "/etc/dir"
def test_shtab():
for shell in ("bash", "zsh", "tcsh"):
assert (
subprocess.Popen(
[sys.executable, "-m", "vectorcode.main", "-s", shell],
stderr=subprocess.PIPE,
)
.stderr.read()
.decode()
) == ""
@pytest.mark.asyncio
async def test_filelock():
manager = LockManager()
with tempfile.TemporaryDirectory() as tmp_dir:
manager.get_lock(tmp_dir)
assert os.path.isfile(os.path.join(tmp_dir, "vectorcode.lock"))
def test_specresolver():
spec = GitIgnoreSpec.from_lines(["file1.txt"])
nested_path = "nested/file1.txt"
assert nested_path in list(
SpecResolver(spec, base_dir="nested").match([nested_path])
)
assert nested_path not in list(
SpecResolver(spec, base_dir="nested").match([nested_path], negated=True)
)
with tempfile.TemporaryDirectory() as dir:
nested_dir = os.path.join(dir, "nested")
nested_path = os.path.join(nested_dir, "file1.txt")
os.makedirs(nested_dir, exist_ok=True)
nested_path = os.path.join(dir, "nested", "file1.txt")
with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=nested_dir) as f:
f.writelines(["file1.txt"])
spec_filename = f.name
assert nested_path in list(
SpecResolver(spec_filename, base_dir=nested_dir).match([nested_path])
)
def test_specresolver_builder():
with (
patch("vectorcode.cli_utils.GitIgnoreSpec"),
patch("vectorcode.cli_utils.open"),
):
base_dir = os.path.normpath(os.path.join("foo", "bar"))
assert (
os.path.normpath(
SpecResolver.from_path(os.path.join(base_dir, ".gitignore")).base_dir
)
== base_dir
)
assert (
os.path.normpath(
SpecResolver.from_path(
os.path.join(base_dir, ".vectorcode", "vectorcode.exclude")
).base_dir
)
== base_dir
)
assert os.path.normpath(
SpecResolver.from_path(
os.path.join(base_dir, "vectorcode", "vectorcode.exclude")
).base_dir
) == os.path.normpath(".")