diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f63d7d..d590a10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,9 @@ -name: Build xkpassgen +name: Build xkcd_pass on: push jobs: build-n-publish: - name: Build xkpassgen + name: Build xkcd_pass runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index f6dd5c0..367f9d9 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,9 +1,9 @@ -name: Publish xkpassgen to PyPI +name: Publish xkcd_pass to PyPI on: push jobs: build-n-publish: - name: Publish xkpassgen to PyPI + name: Publish xkcd_pass to PyPI runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master @@ -25,13 +25,13 @@ jobs: --wheel --outdir dist/ . - - name: Publish xkpassgen to Test PyPI + - name: Publish xkcd_pass to Test PyPI uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ skip_existing: true - - name: Publish xkpassgen to PyPI + - name: Publish xkcd_pass to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master with: diff --git a/.gitignore b/.gitignore index aeb143b..cdeb326 100644 --- a/.gitignore +++ b/.gitignore @@ -134,4 +134,4 @@ dmypy.json # Exclusions -!src/xkpassgen/lib/ \ No newline at end of file +!src/xkcd_pass/lib/ \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index bdf8cb6..9c1b307 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -recursive-include src/xkpassgen/lib/ * -recursive-include src/xkpassgen/static/ * \ No newline at end of file +recursive-include src/xkcd_pass/lib/ * +recursive-include src/xkcd_pass/static/ * \ No newline at end of file diff --git a/README.md b/README.md index 8fee17b..b5dd4e7 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# xkpassgen -![build status](https://github.com/adambirds/xkcd-password-gen/actions/workflows/build.yml/badge.svg) -[![PyPI version](https://badge.fury.io/py/xkpassgen.svg)](https://badge.fury.io/py/xkpassgen) -[![codecov](https://codecov.io/gh/adambirds/xkcd-password-gen/branch/master/graph/badge.svg?token=4RKK2ABREH)](https://codecov.io/gh/adambirds/xkcd-password-gen) -![PyPI - Downloads](https://img.shields.io/pypi/dm/xkpassgen) +# xkcd_pass +![build status](https://github.com/adambirds/xkcd_password-gen/actions/workflows/build.yml/badge.svg) +[![PyPI version](https://badge.fury.io/py/xkcd_pass.svg)](https://badge.fury.io/py/xkcd_pass) +[![codecov](https://codecov.io/gh/adambirds/xkcd_password-gen/branch/master/graph/badge.svg?token=4RKK2ABREH)](https://codecov.io/gh/adambirds/xkcd_password-gen) +![PyPI - Downloads](https://img.shields.io/pypi/dm/xkcd_pass) A flexible and scriptable password generator which generates strong passphrases, inspired by XKCD 936 ``` -$ xkpassgen +$ xkcd_pass > HeadscarfSuddenDumping93 ``` ![](https://imgs.xkcd.com/comics/password_strength.png) ## Install -`xkpassgen` can easily be installed with the following command: +`xkcd_pass` can easily be installed with the following command: ``` -pip install xkpassgen +pip install xkcd_pass ``` or manually by: @@ -27,17 +27,17 @@ python setup.py install ``` ## Source -The source code can be found [here](https://github.com/adambirds/xkcd-password-gen). +The source code can be found [here](https://github.com/adambirds/xkcd_password-gen). Contributions welcome and gratefully appreciated! ## Requirements Python 3 (Version 3.6 or later). -## Running `xkpassgen` -`xkpassgen` can be called with no arguments with an output using the default wordfile and settings. +## Running `xkcd_pass` +`xkcd_pass` can be called with no arguments with an output using the default wordfile and settings. ``` -$ xkpassgen +$ xkcd_pass > HeadscarfSuddenDumping93 ``` The default settings return a single password made up of 3 words each having its first letter capitalized with two random digits afterwards. @@ -45,7 +45,7 @@ The default settings return a single password made up of 3 words each having its It can also be called with a mixture of multiple arguments for example: ``` -$ xkpassgen -d _ -c 5 --min 5 --max 7 --padding-digits-num 4 +$ xkcd_pass -d _ -c 5 --min 5 --max 7 --padding-digits-num 4 > Mundane_Music_Spleen1837 > Reuse_Acclaim_Clarify2492 > Wildly_Contest_Anchor1798 @@ -62,14 +62,14 @@ This will return: A full overview of the available options can be accessed by running following command: ``` -xkpassgen --help +xkcd_pass --help ``` ## Word Lists Several word lists are provided with the package. The default, eff-long, was specifically designed by the EFF for [passphrase generation](https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases) and is licensed under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/us/). As it was originally intended for use with Diceware ensure that the number of words in your passphrase is at least six when using it. Two shorter variants of that list, eff-short and eff-special, are also included. Please refer to the EFF documentation linked above for more information. -Note that `xkpassgen` can be used with any word file of the correct format: a file containing one word per line. +Note that `xkcd_pass` can be used with any word file of the correct format: a file containing one word per line. ## Changelog @@ -87,4 +87,4 @@ Note that `xkpassgen` can be used with any word file of the correct format: a fi ## License -This project is released under the [GNU GENERAL PUBLIC LICENSE v3](https://github.com/adambirds/xkcd-password-gen/blob/master/LICENSE). However the original code from [redacted/XKCD-password-generator](https://github.com/redacted/XKCD-password-generator) is licensed under the [BSD 3-Clause license](https://github.com/adambirds/xkcd-password-gen/blob/master/LICENSE.BSD). \ No newline at end of file +This project is released under the [GNU GENERAL PUBLIC LICENSE v3](https://github.com/adambirds/xkcd_password-gen/blob/master/LICENSE). However the original code from [redacted/xkcd_password-generator](https://github.com/redacted/xkcd_password-generator) is licensed under the [BSD 3-Clause license](https://github.com/adambirds/xkcd_password-gen/blob/master/LICENSE.BSD). \ No newline at end of file diff --git a/setup.py b/setup.py index b3f84fa..095bd11 100644 --- a/setup.py +++ b/setup.py @@ -4,16 +4,16 @@ long_description = fh.read() setuptools.setup( - name="xkpassgen", # Replace with your own username + name="xkcd_pass", # Replace with your own username version="1.0.5", author="Adam Birds", author_email="adam.birds@adbwebdesigns.co.uk", description="Generate secure multiword passwords/passphrases, inspired by XKCD", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/adambirds/xkcd-password-gen", + url="https://github.com/adambirds/xkcd_password-gen", project_urls={ - "Bug Tracker": "https://github.com/adambirds/xkcd-password-gen/issues", + "Bug Tracker": "https://github.com/adambirds/xkcd_password-gen/issues", }, license="LGPLv3", classifiers=[ @@ -21,7 +21,7 @@ "Programming Language :: Python :: 3", "Operating System :: OS Independent", ], - entry_points={"console_scripts": ["xkpassgen=xkpassgen.xkpassgen:main"]}, + entry_points={"console_scripts": ["xkcd_pass=xkcd_pass.xkcd_pass:main"]}, package_dir={"": "src"}, packages=setuptools.find_packages(where="src"), include_package_data=True, diff --git a/src/xkpassgen/__init__.py b/src/xkcd_pass/__init__.py similarity index 100% rename from src/xkpassgen/__init__.py rename to src/xkcd_pass/__init__.py diff --git a/src/xkpassgen/lib/__init__.py b/src/xkcd_pass/lib/__init__.py similarity index 100% rename from src/xkpassgen/lib/__init__.py rename to src/xkcd_pass/lib/__init__.py diff --git a/src/xkpassgen/lib/case.py b/src/xkcd_pass/lib/case.py similarity index 100% rename from src/xkpassgen/lib/case.py rename to src/xkcd_pass/lib/case.py diff --git a/src/xkpassgen/static/.gitignore b/src/xkcd_pass/static/.gitignore similarity index 100% rename from src/xkpassgen/static/.gitignore rename to src/xkcd_pass/static/.gitignore diff --git a/src/xkpassgen/static/eff-long b/src/xkcd_pass/static/eff-long similarity index 100% rename from src/xkpassgen/static/eff-long rename to src/xkcd_pass/static/eff-long diff --git a/src/xkpassgen/static/eff-short b/src/xkcd_pass/static/eff-short similarity index 100% rename from src/xkpassgen/static/eff-short rename to src/xkcd_pass/static/eff-short diff --git a/src/xkpassgen/static/eff-special b/src/xkcd_pass/static/eff-special similarity index 100% rename from src/xkpassgen/static/eff-special rename to src/xkcd_pass/static/eff-special diff --git a/src/xkpassgen/static/test_files/stdin_main_interactive b/src/xkcd_pass/static/test_files/stdin_main_interactive similarity index 100% rename from src/xkpassgen/static/test_files/stdin_main_interactive rename to src/xkcd_pass/static/test_files/stdin_main_interactive diff --git a/src/xkpassgen/static/test_list b/src/xkcd_pass/static/test_list similarity index 100% rename from src/xkpassgen/static/test_list rename to src/xkcd_pass/static/test_list diff --git a/src/xkpassgen/xkpassgen.py b/src/xkcd_pass/xkcd_pass.py similarity index 98% rename from src/xkpassgen/xkpassgen.py rename to src/xkcd_pass/xkcd_pass.py index d1fbb92..f5b6457 100644 --- a/src/xkpassgen/xkpassgen.py +++ b/src/xkcd_pass/xkcd_pass.py @@ -10,7 +10,7 @@ import sys from io import open -from xkpassgen.lib.case import (case_alternating, case_capitalize, +from xkcd_pass.lib.case import (case_alternating, case_capitalize, case_first_upper, case_lower, case_random, case_upper) @@ -311,11 +311,11 @@ def emit_passwords(wordlist, options): count -= 1 -class XkPassGenArgumentParser(argparse.ArgumentParser): +class xkcd_passArgumentParser(argparse.ArgumentParser): """ Command-line argument parser for this program. """ def __init__(self, *args, **kwargs): - super(XkPassGenArgumentParser, self).__init__(*args, **kwargs) + super(xkcd_passArgumentParser, self).__init__(*args, **kwargs) self._add_arguments() @@ -454,7 +454,7 @@ def main(): exit_status = 0 try: - parser = XkPassGenArgumentParser() + parser = xkcd_passArgumentParser() options = parser.parse_args() options.testing = False diff --git a/tests/test_xkpassgen.py b/tests/test_xkcd_pass.py similarity index 81% rename from tests/test_xkpassgen.py rename to tests/test_xkcd_pass.py index 2eb0fbc..70efa9c 100644 --- a/tests/test_xkpassgen.py +++ b/tests/test_xkcd_pass.py @@ -7,23 +7,23 @@ import unittest.mock as mock from subprocess import PIPE, Popen -from src.xkpassgen import xkpassgen +from src.xkcd_pass import xkcd_pass -WORDFILE = "src/xkpassgen/static/eff-long" +WORDFILE = "src/xkcd_pass/static/eff-long" -class XkPassGenTests(unittest.TestCase): +class xkcd_passTests(unittest.TestCase): def shortDescription(self): return None def setUp(self): - self.wordlist_full = xkpassgen.generate_wordlist( + self.wordlist_full = xkcd_pass.generate_wordlist( wordfile=WORDFILE, min_length=5, max_length=8, ) - self.wordlist_small = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", valid_chars="[a-z]" + self.wordlist_small = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]" ) def test_loadwordfile(self): @@ -43,7 +43,7 @@ def test_delim(self): Test delimiter is set correctly. """ tdelim = "_" - result = xkpassgen.generate_xkpassword(self.wordlist_small, delimiter=tdelim) + result = xkcd_pass.generate_xkpassword(self.wordlist_small, delimiter=tdelim) self.assertIsNotNone(re.match("([a-zA-z]+(_|)+([0-9])+)+", result)) def test_set_case(self): @@ -55,12 +55,12 @@ def test_set_case(self): results = {} - results["lower"] = xkpassgen.set_case(words, method="lower") - results["upper"] = xkpassgen.set_case(words, method="upper") - results["alternating"] = xkpassgen.set_case(words, method="alternating") - results["random"] = xkpassgen.set_case(words, method="random", testing=True) - results["first"] = xkpassgen.set_case(words, method="first") - results["capitalize"] = xkpassgen.set_case(words, method="capitalize") + results["lower"] = xkcd_pass.set_case(words, method="lower") + results["upper"] = xkcd_pass.set_case(words, method="upper") + results["alternating"] = xkcd_pass.set_case(words, method="alternating") + results["random"] = xkcd_pass.set_case(words, method="random", testing=True) + results["first"] = xkcd_pass.set_case(words, method="first") + results["capitalize"] = xkcd_pass.set_case(words, method="capitalize") words_after = set( word.lower() for group in list(results.values()) for word in group @@ -82,7 +82,7 @@ def test_set_case(self): words_extra = "this is a test also".lower().split() observed_random_result_1 = results["random"] - observed_random_result_2 = xkpassgen.set_case( + observed_random_result_2 = xkcd_pass.set_case( words_extra, method="random", testing=True ) @@ -108,8 +108,8 @@ def setUp(self): """ Set up fixtures for this test case. """ - self.wordlist_small = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", valid_chars="[a-z]" + self.wordlist_small = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]" ) self.options = argparse.Namespace( @@ -126,7 +126,7 @@ def test_interactive_initialization(self): """ self.options.testtype = "NumWords" with self.stdout_patcher as mock_stdout: - xkpassgen.initialize_interactive_run(options=self.options) + xkcd_pass.initialize_interactive_run(options=self.options) output = mock_stdout.getvalue() self.assertEqual(output.strip(), str(2)) @@ -136,7 +136,7 @@ def test_interactive_initialization_default_numwords(self): """ self.options.testtype = "NumWords0" with self.stdout_patcher as mock_stdout: - xkpassgen.initialize_interactive_run(options=self.options) + xkcd_pass.initialize_interactive_run(options=self.options) output = mock_stdout.getvalue() self.assertEqual(output.strip(), str(6)) @@ -147,7 +147,7 @@ def test_interactive_initialization_error(self): self.options.testtype = "NumWordsError" with self.assertRaises(SystemExit): with self.stdout_patcher as mock_stdout: - xkpassgen.initialize_interactive_run(options=self.options) + xkcd_pass.initialize_interactive_run(options=self.options) class TestVerboseReports(unittest.TestCase): @@ -162,8 +162,8 @@ def setUp(self): """ Set up fixtures for this test case. """ - self.wordlist_small = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", valid_chars="[a-z]" + self.wordlist_small = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]" ) self.options = argparse.Namespace( @@ -179,7 +179,7 @@ def test_verbose_output(self): """ self.options.verbose = True with self.stdout_patcher as mock_stdout: - xkpassgen.verbose_reports( + xkcd_pass.verbose_reports( wordlist=self.wordlist_small, options=self.options ) output = mock_stdout.getvalue() @@ -203,12 +203,12 @@ def setUp(self): """ Set up fixtures for this test case. """ - self.wordlist_small = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", valid_chars="[a-z]" + self.wordlist_small = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]" ) - self.wordlist_small_max_min_length = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", + self.wordlist_small_max_min_length = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]", min_length=7, max_length=6, @@ -235,7 +235,7 @@ def test_emits_specified_count_of_passwords(self) -> None: """ self.options.count = 6 with self.stdout_patcher as mock_stdout: - xkpassgen.emit_passwords(wordlist=self.wordlist_small, options=self.options) + xkcd_pass.emit_passwords(wordlist=self.wordlist_small, options=self.options) output = mock_stdout.getvalue() expected_separator = self.options.separator expected_separator_count = self.options.count @@ -248,7 +248,7 @@ def test_emits_specified_separator_between_passwords(self): self.options.count = 3 self.options.separator = u"!@#$%" with self.stdout_patcher as mock_stdout: - xkpassgen.emit_passwords(wordlist=self.wordlist_small, options=self.options) + xkcd_pass.emit_passwords(wordlist=self.wordlist_small, options=self.options) output = mock_stdout.getvalue() expected_separator = self.options.separator expected_separator_count = self.options.count @@ -261,7 +261,7 @@ def test_emits_no_separator_when_specified_separator_empty(self): self.options.count = 1 self.options.separator = u"" with self.stdout_patcher as mock_stdout: - xkpassgen.emit_passwords(wordlist=self.wordlist_small, options=self.options) + xkcd_pass.emit_passwords(wordlist=self.wordlist_small, options=self.options) output = mock_stdout.getvalue() unwanted_separator = "\n" self.assertEqual(output.find(unwanted_separator), -1) @@ -272,7 +272,7 @@ def test_emits_no_digits_when_no_padding_digits_is_true(self): """ self.options.no_padding_digits = True with self.stdout_patcher as mock_stdout: - xkpassgen.emit_passwords(wordlist=self.wordlist_small, options=self.options) + xkcd_pass.emit_passwords(wordlist=self.wordlist_small, options=self.options) output = mock_stdout.getvalue() self.assertEqual(any(map(str.isdigit, output)), False) @@ -282,7 +282,7 @@ def test_max_length_less_than_min_length(self): """ self.options.numwords = 3 with self.stdout_patcher as mock_stdout: - xkpassgen.emit_passwords( + xkcd_pass.emit_passwords( wordlist=self.wordlist_small_max_min_length, options=self.options ) output = mock_stdout.getvalue() @@ -295,7 +295,7 @@ def test_interactive_accept(self): self.options.testing = True self.options.interactive = True with self.stdout_patcher as mock_stdout: - xkpassgen.emit_passwords( + xkcd_pass.emit_passwords( wordlist=self.wordlist_small_max_min_length, options=self.options ) output = mock_stdout.getvalue() @@ -314,16 +314,16 @@ def setUp(self): """ Set up fixtures for this test case. """ - self.wordlist_small = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", valid_chars="[a-z]" + self.wordlist_small = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]" ) self.options_incorrect_length = argparse.Namespace( - max_length=6, min_length=7, wordfile="src/xkpassgen/static/test_list" + max_length=6, min_length=7, wordfile="src/xkcd_pass/static/test_list" ) self.options_incorrect_wordfile = argparse.Namespace( - max_length=7, min_length=7, wordfile="src/xkpassgen/static/test_list2" + max_length=7, min_length=7, wordfile="src/xkcd_pass/static/test_list2" ) self.options_default_wordfile = argparse.Namespace( @@ -339,7 +339,7 @@ def test_validate_options_incorrect_length(self): Testing validate options incorrect length. """ with self.stdout_patcher as mock_stdout: - xkpassgen.validate_options(options=self.options_incorrect_length) + xkcd_pass.validate_options(options=self.options_incorrect_length) output = mock_stdout.getvalue() self.assertEqual(len(output.strip()), 81) @@ -349,20 +349,20 @@ def test_validate_options_incorrect_wordfile(self): """ with self.assertRaises(SystemExit): with self.stdout_patcher as mock_stdout: - xkpassgen.validate_options(options=self.options_incorrect_wordfile) + xkcd_pass.validate_options(options=self.options_incorrect_wordfile) def test_validate_options_default_wordfile(self): """ Testing validate options default_wordfile. """ with self.stdout_patcher as mock_stdout: - xkpassgen.validate_options( + xkcd_pass.validate_options( options=self.options_default_wordfile, testing=True, ) output = mock_stdout.getvalue() self.assertEqual( - output.strip(), os.path.abspath("src/xkpassgen/static/eff-long".strip()) + output.strip(), os.path.abspath("src/xkcd_pass/static/eff-long".strip()) ) @@ -395,7 +395,7 @@ def accepted_validator(answer): sample_input.write("y") sample_input.seek(0) - output = xkpassgen.try_input( + output = xkcd_pass.try_input( prompt=self.prompt, validate=accepted_validator, testing=False, @@ -418,7 +418,7 @@ def accepted_validator(answer): sample_input.seek(0) with self.assertRaises(SystemExit): - output = xkpassgen.try_input( + output = xkcd_pass.try_input( prompt=self.prompt, validate=accepted_validator, testing=False, @@ -440,8 +440,8 @@ def setUp(self): """ Set up fixtures for this test case. """ - self.wordlist_small = xkpassgen.generate_wordlist( - wordfile="src/xkpassgen/static/test_list", valid_chars="[a-z]" + self.wordlist_small = xkcd_pass.generate_wordlist( + wordfile="src/xkcd_pass/static/test_list", valid_chars="[a-z]" ) self.args = [ @@ -456,10 +456,10 @@ def test_main(self): """ Test main function. """ - xkpassgen.DEFAULT_WORDFILE = "test_list" + xkcd_pass.DEFAULT_WORDFILE = "test_list" with mock.patch.object(sys, "argv", self.args): with self.stdout_patcher as mock_stdout: - xkpassgen.main() + xkcd_pass.main() output = mock_stdout.getvalue() self.assertEqual(len(output.strip()), 20) @@ -467,11 +467,11 @@ def test_main_verbose(self): """ Test main function. """ - xkpassgen.DEFAULT_WORDFILE = "test_list" + xkcd_pass.DEFAULT_WORDFILE = "test_list" self.args.append("-V") with mock.patch.object(sys, "argv", self.args): with self.stdout_patcher as mock_stdout: - xkpassgen.main() + xkcd_pass.main() output = mock_stdout.getvalue() self.assertEqual(len(output.strip()), 199) @@ -480,13 +480,13 @@ def test_main_interactive(self): Test main interactive. """ - sys.stdin = open("src/xkpassgen/static/test_files/stdin_main_interactive", "r") + sys.stdin = open("src/xkcd_pass/static/test_files/stdin_main_interactive", "r") - xkpassgen.DEFAULT_WORDFILE = "test_list" + xkcd_pass.DEFAULT_WORDFILE = "test_list" self.args.append("-i") with mock.patch.object(sys, "argv", self.args): with self.stdout_patcher as mock_stdout: - xkpassgen.main() + xkcd_pass.main() output = mock_stdout.getvalue() self.assertEqual(len(output.strip()), 132) @@ -498,10 +498,10 @@ def test_main_systemexit(self): "Could not find a word file, or word file does not exist.".strip() ) - xkpassgen.DEFAULT_WORDFILE = "test_list2" + xkcd_pass.DEFAULT_WORDFILE = "test_list2" with mock.patch.object(sys, "argv", self.args): with self.stdout_patcher as mock_stdout: - xkpassgen.main() + xkcd_pass.main() output = mock_stdout.getvalue() self.assertEqual(output.strip(), expected_output) @@ -529,10 +529,10 @@ def test_init(self): Test init() function. """ with mock.patch.object(sys, "argv", self.args): - with mock.patch.object(xkpassgen, "main", return_value=42): - with mock.patch.object(xkpassgen, "__name__", "__main__"): - with mock.patch.object(xkpassgen.sys, "exit") as mock_exit: - xkpassgen.init() + with mock.patch.object(xkcd_pass, "main", return_value=42): + with mock.patch.object(xkcd_pass, "__name__", "__main__"): + with mock.patch.object(xkcd_pass.sys, "exit") as mock_exit: + xkcd_pass.init() assert mock_exit.call_args[0][0] == 42 @@ -545,19 +545,19 @@ def shortDescription(self): return None @staticmethod - # def run_xkpassgen_process(*args): - # process = Popen(["xkpassgen", "-V", "-i"], stdout=PIPE, stdin=PIPE) + # def run_xkcd_pass_process(*args): + # process = Popen(["xkcd_pass", "-V", "-i"], stdout=PIPE, stdin=PIPE) # return process.communicate('\n'.join(args))[0] @staticmethod def test_entropy_printout_valid_input(self): - values = self.run_xkpassgen_process("4", "y") + values = self.run_xkcd_pass_process("4", "y") self.assertIn("A 4 word password from this list will have roughly 51", values) if __name__ == "__main__": test_cases = [ - XkPassGenTests, + xkcd_passTests, TestInteractiveInitialization, TestVerboseReports, TestValidateOptions,