delimiter=tdelim)
self.assertIsNotNone(re.match('([a-z]+(_|$))+', result))
+ def test_separator(self):
+ count = 3
+ result = subprocess.check_output(
+ ["python", "xkcdpass/xkcd_password.py",
+ "--count", str(count),
+ "--delimiter", "|",
+ "--separator", " "])
+ self.assertEqual(result.count(b" "), 3)
+
+ def test_separator_no_end(self):
+ "Pipe output to other program. e.g. `xkcdpass -c 1 -s "" | xsel -b`"
+ count = 1
+ result = subprocess.check_output(
+ ["python", "xkcdpass/xkcd_password.py",
+ "--count", str(count),
+ "--separator", ""])
+ self.assertEqual(result.find(b"\n"), -1)
+
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(XkcdPasswordTests)
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
+
import argparse
import math
import os
""" Generate the specified number of passwords and output them. """
count = options.count
while count > 0:
- print(generate_xkcdpassword(
- wordlist,
- interactive=options.interactive,
- numwords=options.numwords,
- acrostic=options.acrostic,
- delimiter=options.delimiter))
+ print(
+ generate_xkcdpassword(
+ wordlist,
+ interactive=options.interactive,
+ numwords=options.numwords,
+ acrostic=options.acrostic,
+ delimiter=options.delimiter
+ ),
+ end=options.separator)
count -= 1
"-d", "--delimiter",
dest="delimiter", default=" ", metavar="DELIM",
help="Separate words within a passphrase with DELIM.")
+ self.add_argument(
+ "-s", "--separator",
+ dest="separator", default="\n", metavar="SEP",
+ help="Separate generated passphrases with SEP.")
self.add_argument(
"--allow-weak-rng",
action="store_true", dest="allow_weak_rng", default=False,