Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pykeepass/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def __init__(self, title=None, username=None, password=None, url=None,
expiry_time=expiry_time,
icon=icon
)
self._element.append(E.String(E.Key('Title'), E.Value(title)))
self._element.append(E.String(E.Key('UserName'), E.Value(username)))
self._element.append(E.String(E.Key('Title'), E.Value(title or "")))
self._element.append(E.String(E.Key('UserName'), E.Value(username or "")))
self._element.append(
E.String(E.Key('Password'), E.Value(password, Protected="True"))
E.String(E.Key('Password'), E.Value(password or "", Protected="True"))
)
if url:
self._element.append(E.String(E.Key('URL'), E.Value(url)))
Expand Down
13 changes: 13 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,19 @@ def test_fields(self):
self.kp.root_group
)

def test_null_values(self):
"""Set title, username, password to `None` as the docs allow"""
entry = Entry(
None,
None,
None,
kp=self.kp
)
self.assertEqual(entry.title, '')
self.assertEqual(entry.username, '')
self.assertEqual(entry.password, '')


def test_references(self):
original_entry = self.kp.find_entries(title='foobar_entry', first=True)
original_entry_duplicate = self.kp.find_entries(title='foobar_entry', first=True)
Expand Down