Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_emits_no_separator_when_specified_separator_empty(self):
""" Should emit no separator when empty separator specified. """
self.options.count = 1
self.options.separator = u""
with self.stdout_patcher as mock_stdout:
xkcd_password.emit_passwords(
wordlist=self.wordlist_small,
options=self.options)
output = mock_stdout.getvalue()
unwanted_separator = "\n"
self.assertEqual(output.find(unwanted_separator), -1)
def test_emits_specified_separator_between_passwords(self):
""" Should emit specified separator text between each password. """
self.options.count = 3
self.options.separator = u"!@#$%"
with self.stdout_patcher as mock_stdout:
xkcd_password.emit_passwords(
wordlist=self.wordlist_small,
options=self.options)
output = mock_stdout.getvalue()
expected_separator = self.options.separator
expected_separator_count = self.options.count
self.assertEqual(
output.count(expected_separator), expected_separator_count)
def test_emits_specified_count_of_passwords(self):
""" Should emit passwords numbering specified `count`. """
self.options.count = 6
with self.stdout_patcher as mock_stdout:
xkcd_password.emit_passwords(
wordlist=self.wordlist_small,
options=self.options)
output = mock_stdout.getvalue()
expected_separator = self.options.separator
expected_separator_count = self.options.count
self.assertEqual(
output.count(expected_separator), expected_separator_count)