diff --git a/passplz/__init__.py b/passplz/__init__.py index b2f5ffe..b99c1a0 100644 --- a/passplz/__init__.py +++ b/passplz/__init__.py @@ -21,7 +21,7 @@ def generate_password(password_length=16): """Generate a random password of length ``password_length``.""" random_string = "" - while len(random_string) < password_length + 4*(password_length/16.0): - random_string += str(uuid4()) - random_password = random_string.replace('-', '')[:password_length] + while len(random_string) < password_length: + random_string += uuid4().hex + random_password = random_string[:password_length] return random_password diff --git a/passplz/tests/__init__.py b/passplz/tests/__init__.py index 7e81c5c..72d5bde 100644 --- a/passplz/tests/__init__.py +++ b/passplz/tests/__init__.py @@ -5,9 +5,9 @@ import passplz -class TestPasswordy(TestCase): +class TestPassword(TestCase): """Generate a password and make sure it has length 16.""" - def test_is_string(self): + def test_default_length(self): """ Test if the generate_password function of passplz is callable and if the returned password has length 16. @@ -15,9 +15,9 @@ def test_is_string(self): password = passplz.generate_password() self.assertEqual(16, len(password)) - def test_lengths(self): + def test_various_lengths(self): """ - Test if generation of 35 character long passwords work. + Test if generation of various character long passwords work. """ for i in range(2, 160): password = passplz.generate_password(i)