Skip to content

Commit 13c72c6

Browse files
committed
Fix initialize and tests
Signed-off-by: dgzlopes <[email protected]>
1 parent 8fd3289 commit 13c72c6

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

Diff for: detect_secrets/core/baseline.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313

1414
def initialize(
15+
path,
1516
plugins,
1617
exclude_files_regex=None,
1718
exclude_lines_regex=None,
18-
path='.',
1919
scan_all_files=False,
2020
):
2121
"""Scans the entire codebase for secrets, and returns a
@@ -26,7 +26,7 @@ def initialize(
2626
2727
:type exclude_files_regex: str|None
2828
:type exclude_lines_regex: str|None
29-
:type path: str|list
29+
:type path: list
3030
:type scan_all_files: bool
3131
3232
:rtype: SecretsCollection
@@ -37,9 +37,6 @@ def initialize(
3737
exclude_lines=exclude_lines_regex,
3838
)
3939

40-
if not isinstance(path, list):
41-
path = [path]
42-
4340
files_to_scan = list()
4441
for element in path:
4542
if os.path.isdir(element):

Diff for: tests/core/baseline_test.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,26 @@ def setup(self):
3131

3232
def get_results(
3333
self,
34-
path='./test_data/files',
34+
path=['./test_data/files'],
3535
exclude_files_regex=None,
3636
scan_all_files=False,
3737
):
3838
return baseline.initialize(
39+
path,
3940
self.plugins,
40-
path=path,
4141
exclude_files_regex=exclude_files_regex,
4242
scan_all_files=scan_all_files,
4343
).json()
4444

4545
@pytest.mark.parametrize(
4646
'path',
4747
[
48-
'./test_data/files',
48+
[
49+
'./test_data/files',
4950
50-
# Test relative paths
51-
'test_data/../test_data/files/tmp/..',
51+
# Test relative paths
52+
'test_data/../test_data/files/tmp/..',
53+
],
5254
],
5355
)
5456
def test_basic_usage(self, path):
@@ -107,7 +109,7 @@ def test_no_files_in_git_repo(self):
107109
),
108110
),
109111
):
110-
results = self.get_results(path='will_be_mocked')
112+
results = self.get_results(path=['will_be_mocked'])
111113

112114
assert not results
113115

@@ -119,12 +121,12 @@ def test_single_non_tracked_git_file_should_work(self):
119121
'Super hidden value "BEEF0123456789a"',
120122
'detect_secrets.core.secrets_collection.codecs.open',
121123
):
122-
results = self.get_results('will_be_mocked')
124+
results = self.get_results(path=['will_be_mocked'])
123125

124126
assert len(results['will_be_mocked']) == 1
125127

126128
def test_scan_all_files(self):
127-
results = self.get_results(path='test_data/files', scan_all_files=True)
129+
results = self.get_results(path=['test_data/files'], scan_all_files=True)
128130
assert len(results.keys()) == 2
129131

130132

0 commit comments

Comments
 (0)