Skip to content

Commit

Permalink
Fix a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHock committed Sep 20, 2018
1 parent 4ce9556 commit e4911bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions testing/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from detect_secrets.core.secrets_collection import SecretsCollection


def potential_secret_factory(type_='type', filename='filename', lineno=1, secret='secret'):
def potential_secret_factory(type_='type', filename='filename', secret='secret', lineno=1):
"""This is only marginally better than creating PotentialSecret objects directly,
because of default values.
"""
return PotentialSecret(type_, filename, lineno, secret)
return PotentialSecret(type_, filename, secret, lineno)


def secrets_collection_factory(secrets=None, plugins=(), exclude_regex=''):
Expand Down Expand Up @@ -51,7 +51,7 @@ def _add_secret(collection, type_='type', secret='secret', filename='filename',
tmp_secret = potential_secret_factory(
type_=type_,
filename=filename,
lineno=lineno,
secret=secret,
lineno=lineno,
)
collection.data[filename][tmp_secret] = tmp_secret
2 changes: 1 addition & 1 deletion tests/core/potential_secret_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class TestPotentialSecret(object):

@pytest.mark.parametrize(
'a,b,is_equal',
'a, b, is_equal',
[
(
potential_secret_factory(lineno=1),
Expand Down
6 changes: 2 additions & 4 deletions tests/core/secrets_collection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_success_multiple_plugins(self):
line_numbers = [entry.lineno for entry in logic.data['filename']]
assert set(line_numbers) == set([1, 2, 3])

def test_removal_of_password_plugin_secrets_if_reported_already(self):
def test_reporting_of_password_plugin_secrets_if_reported_already(self):
logic = secrets_collection_factory(
secrets=[
{
Expand All @@ -110,9 +110,7 @@ def test_removal_of_password_plugin_secrets_if_reported_already(self):
with mock_open('junk text here'):
logic.scan_file('filename')

# One from only the MockPluginFileValue, and one from existing secret
# This is because the MockPasswordPluginValue was not placed into data
assert len(logic.data['filename']) == 2
assert len(logic.data['filename']) == 3

line_numbers = [entry.lineno for entry in logic.data['filename']]
assert set(line_numbers) == set([2, 3])
Expand Down

0 comments on commit e4911bf

Please sign in to comment.