""" Unit test for `xkcd_password` module. """
+import subprocess
import argparse
import io
import re
words_extra = "this is a test also".lower().split()
observed_random_result_1 = results["random"]
observed_random_result_2 = xkcd_password.set_case(
- words_extra,
+ words_extra,
method="random",
testing=True
)
expected_random_result_2_py2, expected_random_result_2_py3))
-class emit_passwords_TestCase(unittest.TestCase):
+class TestEmitPasswords(unittest.TestCase):
""" Test cases for function `emit_passwords`. """
def setUp(self):
self.assertEqual(output.find(unwanted_separator), -1)
+class TestEntropyInformation(unittest.TestCase):
+ """ Test cases for function `emit_passwords`. """
+
+ @staticmethod
+ def run_xkcdpass_process():
+ test = subprocess.Popen(
+ ["xkcdpass", "-V", "-i"], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ return test.communicate()[0]
+
+ @mock.patch('__builtin__.input', side_effect=['4', 'y'])
+ def test_entropy_printout_valid_input(self, mock):
+ values = self.run_xkcdpass_process()
+ self.assertIn(
+ 'A 4 word password from this list will have roughly 51', values)
+
+
if __name__ == '__main__':
- suite = unittest.TestLoader().loadTestsFromTestCase(XkcdPasswordTests)
- unittest.TextTestRunner(verbosity=2).run(suite)
+ suites = [unittest.TestLoader().loadTestsFromTestCase(test_case) for test_case in [XkcdPasswordTests, TestEmitPasswords, TestEntropyInformation]]
+ unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(suites))