Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-shortuuid for 
openSUSE:Factory checked in at 2023-05-05 15:58:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-shortuuid (Old)
 and      /work/SRC/openSUSE:Factory/.python-shortuuid.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-shortuuid"

Fri May  5 15:58:03 2023 rev:6 rq:1084874 version:1.0.11

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-shortuuid/python-shortuuid.changes        
2022-10-08 01:26:28.486401641 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-shortuuid.new.1533/python-shortuuid.changes  
    2023-05-05 15:58:24.620471932 +0200
@@ -1,0 +2,7 @@
+Thu May  4 20:39:04 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 1.0.11:
+  * Add Type hinting
+  * add py.typed (PEP 561)
+
+-------------------------------------------------------------------

Old:
----
  shortuuid-1.0.9.tar.gz

New:
----
  shortuuid-1.0.11.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-shortuuid.spec ++++++
--- /var/tmp/diff_new_pack.gRQ7Hq/_old  2023-05-05 15:58:25.180475141 +0200
+++ /var/tmp/diff_new_pack.gRQ7Hq/_new  2023-05-05 15:58:25.188475187 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-shortuuid
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-shortuuid
-Version:        1.0.9
+Version:        1.0.11
 Release:        0
 Summary:        A generator library for concise, unambiguous and URL-safe UUIDs
 License:        BSD-3-Clause
@@ -50,12 +50,10 @@
 %install
 %python_install
 %python_clone -a %{buildroot}%{_bindir}/shortuuid
-%{python_expand rm %{buildroot}%{$python_sitelib}/shortuuid/tests.py
-%fdupes %{buildroot}%{$python_sitelib}
-}
+%python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %check
-%pytest shortuuid/tests.py
+%pytest
 
 %post
 %python_install_alternative shortuuid

++++++ shortuuid-1.0.9.tar.gz -> shortuuid-1.0.11.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/PKG-INFO 
new/shortuuid-1.0.11/PKG-INFO
--- old/shortuuid-1.0.9/PKG-INFO        2022-05-08 11:56:02.128507400 +0200
+++ new/shortuuid-1.0.11/PKG-INFO       1970-01-01 01:00:00.000000000 +0100
@@ -1,9 +1,9 @@
 Metadata-Version: 2.1
 Name: shortuuid
-Version: 1.0.9
+Version: 1.0.11
 Summary: A generator library for concise, unambiguous and URL-safe UUIDs.
 Home-page: https://github.com/skorokithakis/shortuuid/
-License: BSD
+License: License :: OSI Approved :: BSD License
 Author: Stavros Korokithakis
 Author-email: [email protected]
 Requires-Python: >=3.5
@@ -11,6 +11,12 @@
 Classifier: License :: Other/Proprietary License
 Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
 Classifier: Programming Language :: Python :: 3.10
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/pyproject.toml 
new/shortuuid-1.0.11/pyproject.toml
--- old/shortuuid-1.0.9/pyproject.toml  2022-05-08 11:54:15.201956000 +0200
+++ new/shortuuid-1.0.11/pyproject.toml 2022-11-13 23:12:07.677593700 +0100
@@ -1,8 +1,8 @@
 [tool.poetry]
 name = "shortuuid"
-version = "1.0.9"
+version = "1.0.11"
 description = "A generator library for concise, unambiguous and URL-safe 
UUIDs."
-license = "BSD"
+license = "License :: OSI Approved :: BSD License"
 classifiers = [
   "License :: OSI Approved :: BSD License",
   "Programming Language :: Python",
@@ -20,7 +20,7 @@
 include = ["COPYING"]
 
 [tool.poetry.scripts]
-shortuuid = "shortuuid:cli.main"
+shortuuid = "shortuuid.cli:cli"
 
 [tool.poetry.dependencies]
 python = ">=3.5"
@@ -28,4 +28,3 @@
 [build-system]
 requires = ["poetry-core"]
 build-backend = "poetry.core.masonry.api"
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/setup.py 
new/shortuuid-1.0.11/setup.py
--- old/shortuuid-1.0.9/setup.py        2022-05-08 11:56:02.128150500 +0200
+++ new/shortuuid-1.0.11/setup.py       1970-01-01 01:00:00.000000000 +0100
@@ -8,17 +8,17 @@
 {'': ['*']}
 
 entry_points = \
-{'console_scripts': ['shortuuid = shortuuid:cli.main']}
+{'console_scripts': ['shortuuid = shortuuid.cli:cli']}
 
 setup_kwargs = {
     'name': 'shortuuid',
-    'version': '1.0.9',
+    'version': '1.0.11',
     'description': 'A generator library for concise, unambiguous and URL-safe 
UUIDs.',
     'long_description': 'Description\n===========\n\n`shortuuid` is a simple 
python library that generates concise, unambiguous, URL-safe\nUUIDs.\n\nOften, 
one needs to use non-sequential IDs in places where users will see them, but 
the\nIDs must be as concise and easy to use as possible.  `shortuuid` solves 
this problem by\ngenerating uuids using Python\'s built-in `uuid` module and 
then translating them to\nbase57 using lowercase and uppercase letters and 
digits, and removing similar-looking\ncharacters such as l, 1, I, O and 
0.\n\n[![image](https://travis-ci.org/skorokithakis/shortuuid.svg?branch=master)](https://travis-ci.org/skorokithakis/shortuuid)\n\n\nInstallation\n------------\n\nTo
 install `shortuuid` you need:\n\n-   Python 3.x.\n\nIf you have the 
dependencies, you have multiple options of installation:\n\n-   With pip 
(preferred), do `pip install shortuuid`.\n-   With setuptools, do `easy_install 
shortuuid`.\n-   To install the source, download it from\n    https://githu
 b.com/stochastic-technologies/shortuuid and run `python setup.py\n    
install`.\n\n\nUsage\n-----\n\nTo use `shortuuid`, just import it in your 
project like so:\n\n```python\n>>> import shortuuid\n```\n\nYou can then 
generate a short UUID:\n\n```python\n>>> 
shortuuid.uuid()\n\'vytxeTZskVKR7C7WgdSP3d\'\n```\n\nIf you prefer a version 5 
UUID, you can pass a name (DNS or URL) to the call and it will\nbe used as a 
namespace (`uuid.NAMESPACE_DNS` or `uuid.NAMESPACE_URL`) for the 
resulting\nUUID:\n\n```python\n>>> 
shortuuid.uuid(name="example.com")\n\'exu3DTbj2ncsn9tLdLWspw\'\n\n>>> 
shortuuid.uuid(name="<http://example.com>")\n\'shortuuid.uuid(name="<http://example.com>")\'\n```\n\nYou
 can also generate a cryptographically secure random string (using 
`os.urandom()`\ninternally) with:\n\n```python\n>>> 
shortuuid.ShortUUID().random(length=22)\n\'RaF56o2r58hTKT7AYS9doj\'\n```\n\nTo 
see the alphabet that is being used to generate new UUIDs:\n\n```python\n>>> 
shortuuid.get_alphabet()\n\'234567
 89ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\'\n```\n\nIf you want to 
use your own alphabet to generate UUIDs, use 
`set_alphabet()`:\n\n```python\n>>> 
shortuuid.set_alphabet("aaaaabcdefgh1230123")\n>>> 
shortuuid.uuid()\n\'0agee20aa1hehebcagddhedddc0d2chhab3b\'\n```\n\n`shortuuid` 
will automatically sort and remove duplicates from your alphabet to 
ensure\nconsistency:\n\n```python\n>>> 
shortuuid.get_alphabet()\n\'0123abcdefgh\'\n```\n\nIf the default 22 digits are 
too long for you, you can get shorter IDs by just\ntruncating the string to the 
desired length. The IDs won\'t be universally unique any\nlonger, but the 
probability of a collision will still be very low.\n\nTo serialize existing 
UUIDs, use `encode()` and `decode()`:\n\n```python\n>>> import uuid\n>>> u = 
uuid.uuid4()\n>>> u\nUUID(\'6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a\')\n\n>>> s = 
shortuuid.encode(u)\n>>> s\n\'MLpZDiEXM4VsUryR9oE8uc\'\n\n>>> 
shortuuid.decode(s) == u\nTrue\n\n>>> short = s[:7]\n>>> short\n\'MLpZDiE\
 '\n\n>>> h = 
shortuuid.decode(short)\nUUID(\'00000000-0000-0000-0000-009a5b27f8b9\')\n\n>>> 
shortuuid.decode(shortuuid.encode(h)) == h\nTrue\n```\n\n\nClass-based 
usage\n-----------------\n\nIf you need to have various alphabets per-thread, 
you can use the `ShortUUID` class,\nlike so:\n\n```python\n>>> su = 
shortuuid.ShortUUID(alphabet="01345678")\n>>> 
su.uuid()\n\'034636353306816784480643806546503818874456\'\n\n>>> 
su.get_alphabet()\n\'01345678\'\n\n>>> 
su.set_alphabet("21345687654123456")\n>>> 
su.get_alphabet()\n\'12345678\'\n```\n\n\nCommand-line 
usage\n------------------\n\n`shortuuid` provides a simple way to generate a 
short UUID in a terminal:\n\n```bash\n$ 
shortuuid\nfZpeF6gcskHbSpTgpQCkcJ\n```\n\n\nDjango 
field\n------------\n\n`shortuuid` includes a Django field that generates 
random short UUIDs by default, for\nyour convenience:\n\n```python\nfrom 
shortuuid.django_fields import ShortUUIDField\n\nclass MyModel(models.Model):\n 
   # A primary key ID of length 16 and a short
  alphabet.\n    id = ShortUUIDField(\n        length=16,\n        
max_length=40,\n        prefix="id_",\n        alphabet="abcdefg1234",\n        
primary_key=True,\n    )\n\n    # A short UUID of length 22 and the default 
alphabet.\n    api_key = ShortUUIDField()\n```\n\nThe field is the same as the 
`CharField`, with a `length` argument (the length of the\nID), an `alphabet` 
argument, and the `default` argument removed. Everything else is\nexactly the 
same, e.g. `index`, `help_text`, `max_length`, etc.\n\n\nCompatibility 
note\n------------------\n\nVersions of ShortUUID prior to 1.0.0 generated 
UUIDs with their MSB last, i.e. reversed.\nThis was later fixed, but if you 
have some UUIDs stored as a string with the old method,\nyou need to pass 
`legacy=True` to `decode()` when converting your strings back to UUIDs.\n\nThat 
option will go away in the future, so you will want to convert your UUIDs 
to\nstrings using the new method. This can be done like so:\n\n```python\n>>> 
new_uuid_str 
 = encode(decode(old_uuid_str, 
legacy=True))\n```\n\nLicense\n-------\n\n`shortuuid` is distributed under the 
BSD license.\n',
     'author': 'Stavros Korokithakis',
     'author_email': '[email protected]',
-    'maintainer': None,
-    'maintainer_email': None,
+    'maintainer': 'None',
+    'maintainer_email': 'None',
     'url': 'https://github.com/skorokithakis/shortuuid/',
     'packages': packages,
     'package_data': package_data,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/shortuuid/__init__.py 
new/shortuuid-1.0.11/shortuuid/__init__.py
--- old/shortuuid-1.0.9/shortuuid/__init__.py   2022-05-08 11:53:02.233916000 
+0200
+++ new/shortuuid-1.0.11/shortuuid/__init__.py  2022-11-13 23:12:17.257516600 
+0100
@@ -1,9 +1,18 @@
-from shortuuid.main import decode  # noqa
-from shortuuid.main import encode  # noqa
-from shortuuid.main import get_alphabet  # noqa
-from shortuuid.main import random  # noqa
-from shortuuid.main import set_alphabet  # noqa
-from shortuuid.main import ShortUUID  # noqa
-from shortuuid.main import uuid  # noqa
+from shortuuid.main import decode
+from shortuuid.main import encode
+from shortuuid.main import get_alphabet
+from shortuuid.main import random
+from shortuuid.main import set_alphabet
+from shortuuid.main import ShortUUID
+from shortuuid.main import uuid
 
-__version__ = "1.0.8"
+__version__ = "1.0.11"
+__all__ = [
+    "decode",
+    "encode",
+    "get_alphabet",
+    "random",
+    "set_alphabet",
+    "ShortUUID",
+    "uuid",
+]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/shortuuid/cli.py 
new/shortuuid-1.0.11/shortuuid/cli.py
--- old/shortuuid-1.0.9/shortuuid/cli.py        2022-05-08 11:53:02.233916000 
+0200
+++ new/shortuuid-1.0.11/shortuuid/cli.py       2022-11-10 20:52:50.707222200 
+0100
@@ -1,5 +1,50 @@
+import argparse
+import sys
+from typing import Any
+from uuid import UUID
+
+from .main import decode
+from .main import encode
 from .main import uuid
 
 
-def main():
-    print(uuid())
+def encode_cli(args: argparse.Namespace):
+    print(encode(args.uuid))
+
+
+def decode_cli(args: argparse.Namespace):
+    print(str(decode(args.shortuuid, legacy=args.legacy)))
+
+
+def cli(*args: Any) -> None:
+    parser = argparse.ArgumentParser(
+        description="Generate, encode and decode shortuuids",
+        epilog="top-level command generates a random shortuuid",
+    )
+
+    subparsers = parser.add_subparsers(help="sub-command help")
+
+    encode_parser = subparsers.add_parser(
+        "encode", help="Encode a UUID into a short UUID", 
description=encode.__doc__
+    )
+    encode_parser.add_argument("uuid", type=UUID, help="UUID to be encoded")
+    encode_parser.set_defaults(func=encode_cli)
+
+    decode_parser = subparsers.add_parser(
+        "decode", help="Decode a short UUID into a UUID", 
description=decode.__doc__
+    )
+    decode_parser.add_argument("shortuuid", type=str, help="Short UUID to be 
decoded")
+    decode_parser.add_argument("--legacy", action="store_true")
+    decode_parser.set_defaults(func=decode_cli)
+
+    passed_args = parser.parse_args(*args)
+
+    if hasattr(passed_args, "func"):
+        passed_args.func(passed_args)
+    else:
+        # Maintain legacy behaviour
+        print(uuid())
+
+
+if __name__ == "__main__":
+    cli(sys.argv[1:])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/shortuuid/django_fields.py 
new/shortuuid-1.0.11/shortuuid/django_fields.py
--- old/shortuuid-1.0.9/shortuuid/django_fields.py      2022-05-08 
11:53:02.233916000 +0200
+++ new/shortuuid-1.0.11/shortuuid/django_fields.py     2022-08-21 
13:04:01.945440800 +0200
@@ -1,3 +1,7 @@
+from typing import Any
+from typing import Dict
+from typing import Tuple
+
 from django.db import models
 from django.utils.translation import gettext_lazy as _
 
@@ -7,26 +11,26 @@
 class ShortUUIDField(models.CharField):
     description = _("A short UUID field.")
 
-    def __init__(self, *args, **kwargs):
-        self.length = kwargs.pop("length", 22)
-        self.prefix = kwargs.pop("prefix", "")
+    def __init__(self, *args: Tuple, **kwargs: Dict[str, Any]) -> None:
+        self.length: int = kwargs.pop("length", 22)  # type: ignore
+        self.prefix: str = kwargs.pop("prefix", "")  # type: ignore
 
         if "max_length" not in kwargs:
             # If `max_length` was not specified, set it here.
-            kwargs["max_length"] = self.length + len(self.prefix)
+            kwargs["max_length"] = self.length + len(self.prefix)  # type: 
ignore
 
-        self.alphabet = kwargs.pop("alphabet", None)
-        kwargs["default"] = self._generate_uuid
+        self.alphabet: str = kwargs.pop("alphabet", None)  # type: ignore
+        kwargs["default"] = self._generate_uuid  # type: ignore
 
         super().__init__(*args, **kwargs)
 
-    def _generate_uuid(self):
+    def _generate_uuid(self) -> str:
         """Generate a short random string."""
         return self.prefix + ShortUUID(alphabet=self.alphabet).random(
             length=self.length
         )
 
-    def deconstruct(self):
+    def deconstruct(self) -> Tuple[str, str, Tuple, Dict[str, Any]]:
         name, path, args, kwargs = super().deconstruct()
         kwargs["alphabet"] = self.alphabet
         kwargs["length"] = self.length
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/shortuuid/main.py 
new/shortuuid-1.0.11/shortuuid/main.py
--- old/shortuuid-1.0.9/shortuuid/main.py       2022-05-08 11:53:02.233916000 
+0200
+++ new/shortuuid-1.0.11/shortuuid/main.py      2022-08-21 13:04:01.945440800 
+0200
@@ -3,9 +3,13 @@
 import math
 import os
 import uuid as _uu
+from typing import List
+from typing import Optional
 
 
-def int_to_string(number, alphabet, padding=None):
+def int_to_string(
+    number: int, alphabet: List[str], padding: Optional[int] = None
+) -> str:
     """
     Convert a number to a string, using the given alphabet.
 
@@ -22,7 +26,7 @@
     return output[::-1]
 
 
-def string_to_int(string, alphabet):
+def string_to_int(string: str, alphabet: List[str]) -> int:
     """
     Convert a string to a number, using the given alphabet.
 
@@ -36,20 +40,18 @@
 
 
 class ShortUUID(object):
-    def __init__(self, alphabet=None):
+    def __init__(self, alphabet: Optional[str] = None) -> None:
         if alphabet is None:
-            alphabet = list(
-                "23456789ABCDEFGHJKLMNPQRSTUVWXYZ" "abcdefghijkmnopqrstuvwxyz"
-            )
+            alphabet = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ" 
"abcdefghijkmnopqrstuvwxyz"
 
         self.set_alphabet(alphabet)
 
     @property
-    def _length(self):
+    def _length(self) -> int:
         """Return the necessary length to fit the entire UUID given the 
current alphabet."""
-        return int(math.ceil(math.log(2 ** 128, self._alpha_len)))
+        return int(math.ceil(math.log(2**128, self._alpha_len)))
 
-    def encode(self, uuid, pad_length=None):
+    def encode(self, uuid: _uu.UUID, pad_length: Optional[int] = None) -> str:
         """
         Encode a UUID into a string (LSB first) according to the alphabet.
 
@@ -61,7 +63,7 @@
             pad_length = self._length
         return int_to_string(uuid.int, self._alphabet, padding=pad_length)
 
-    def decode(self, string, legacy=False):
+    def decode(self, string: str, legacy: bool = False) -> _uu.UUID:
         """
         Decode a string according to the current alphabet into a UUID.
 
@@ -78,7 +80,7 @@
             string = string[::-1]
         return _uu.UUID(int=string_to_int(string, self._alphabet))
 
-    def uuid(self, name=None, pad_length=None):
+    def uuid(self, name: Optional[str] = None, pad_length: Optional[int] = 
None) -> str:
         """
         Generate and return a UUID.
 
@@ -97,7 +99,7 @@
             u = _uu.uuid5(_uu.NAMESPACE_DNS, name)
         return self.encode(u, pad_length)
 
-    def random(self, length=None):
+    def random(self, length: Optional[int] = None) -> str:
         """Generate and return a cryptographically secure short random string 
of `length`."""
         if length is None:
             length = self._length
@@ -105,11 +107,11 @@
         random_num = int(binascii.b2a_hex(os.urandom(length)), 16)
         return int_to_string(random_num, self._alphabet, 
padding=length)[:length]
 
-    def get_alphabet(self):
+    def get_alphabet(self) -> str:
         """Return the current alphabet used for new UUIDs."""
         return "".join(self._alphabet)
 
-    def set_alphabet(self, alphabet):
+    def set_alphabet(self, alphabet: str) -> None:
         """Set the alphabet to be used for new UUIDs."""
         # Turn the alphabet into a set and sort it to prevent duplicates
         # and ensure reproducibility.
@@ -120,7 +122,7 @@
         else:
             raise ValueError("Alphabet with more than " "one unique symbols 
required.")
 
-    def encoded_length(self, num_bytes=16):
+    def encoded_length(self, num_bytes: int = 16) -> int:
         """Return the string length of the shortened UUID."""
         factor = math.log(256) / math.log(self._alpha_len)
         return int(math.ceil(factor * num_bytes))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/shortuuid/test_shortuuid.py 
new/shortuuid-1.0.11/shortuuid/test_shortuuid.py
--- old/shortuuid-1.0.9/shortuuid/test_shortuuid.py     1970-01-01 
01:00:00.000000000 +0100
+++ new/shortuuid-1.0.11/shortuuid/test_shortuuid.py    2022-11-10 
20:52:50.707222200 +0100
@@ -0,0 +1,224 @@
+import os
+import string
+import sys
+import unittest
+from collections import defaultdict
+from unittest.mock import patch
+from uuid import UUID
+from uuid import uuid4
+
+from shortuuid.cli import cli
+from shortuuid.main import decode
+from shortuuid.main import encode
+from shortuuid.main import get_alphabet
+from shortuuid.main import random
+from shortuuid.main import set_alphabet
+from shortuuid.main import ShortUUID
+from shortuuid.main import uuid
+
+sys.path.insert(0, os.path.abspath(__file__ + "/../.."))
+
+
+class LegacyShortUUIDTest(unittest.TestCase):
+    def test_generation(self):
+        self.assertTrue(20 < len(uuid()) < 24)
+        self.assertTrue(20 < len(uuid("http://www.example.com/";)) < 24)
+        self.assertTrue(20 < len(uuid("HTTP://www.example.com/")) < 24)
+        self.assertTrue(20 < len(uuid("example.com/")) < 24)
+
+    def test_encoding(self):
+        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+        self.assertEqual(encode(u), "CXc85b4rqinB7s5J52TRYb")
+
+    def test_decoding(self):
+        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+        self.assertEqual(decode("CXc85b4rqinB7s5J52TRYb"), u)
+
+    def test_alphabet(self):
+        backup_alphabet = get_alphabet()
+
+        alphabet = "01"
+        set_alphabet(alphabet)
+        self.assertEqual(alphabet, get_alphabet())
+
+        set_alphabet("01010101010101")
+        self.assertEqual(alphabet, get_alphabet())
+
+        self.assertEqual(set(uuid()), set("01"))
+        self.assertTrue(116 < len(uuid()) < 140)
+
+        u = uuid4()
+        self.assertEqual(u, decode(encode(u)))
+
+        u = uuid()
+        self.assertEqual(u, encode(decode(u)))
+
+        self.assertRaises(ValueError, set_alphabet, "1")
+        self.assertRaises(ValueError, set_alphabet, "1111111")
+
+        set_alphabet(backup_alphabet)
+
+        self.assertRaises(ValueError, lambda x: ShortUUID(x), "0")
+
+    def test_random(self):
+        self.assertEqual(len(random()), 22)
+        for i in range(1, 100):
+            self.assertEqual(len(random(i)), i)
+
+
+class ClassShortUUIDTest(unittest.TestCase):
+    def test_generation(self):
+        su = ShortUUID()
+        self.assertTrue(20 < len(su.uuid()) < 24)
+        self.assertTrue(20 < len(su.uuid("http://www.example.com/";)) < 24)
+        self.assertTrue(20 < len(su.uuid("HTTP://www.example.com/")) < 24)
+        self.assertTrue(20 < len(su.uuid("example.com/")) < 24)
+
+    def test_encoding(self):
+        su = ShortUUID()
+        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+        self.assertEqual(su.encode(u), "CXc85b4rqinB7s5J52TRYb")
+
+    def test_decoding(self):
+        su = ShortUUID()
+        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+        self.assertEqual(su.decode("CXc85b4rqinB7s5J52TRYb"), u)
+
+    def test_random(self):
+        su = ShortUUID()
+        for i in range(1000):
+            self.assertEqual(len(su.random()), 22)
+
+        for i in range(1, 100):
+            self.assertEqual(len(su.random(i)), i)
+
+    def test_alphabet(self):
+        alphabet = "01"
+        su1 = ShortUUID(alphabet)
+        su2 = ShortUUID()
+
+        self.assertEqual(alphabet, su1.get_alphabet())
+
+        su1.set_alphabet("01010101010101")
+        self.assertEqual(alphabet, su1.get_alphabet())
+
+        self.assertEqual(set(su1.uuid()), set("01"))
+        self.assertTrue(116 < len(su1.uuid()) < 140)
+        self.assertTrue(20 < len(su2.uuid()) < 24)
+
+        u = uuid4()
+        self.assertEqual(u, su1.decode(su1.encode(u)))
+
+        u = su1.uuid()
+        self.assertEqual(u, su1.encode(su1.decode(u)))
+
+        self.assertRaises(ValueError, su1.set_alphabet, "1")
+        self.assertRaises(ValueError, su1.set_alphabet, "1111111")
+
+    def test_encoded_length(self):
+        su1 = ShortUUID()
+        self.assertEqual(su1.encoded_length(), 22)
+
+        base64_alphabet = (
+            string.ascii_uppercase + string.ascii_lowercase + string.digits + 
"+/"
+        )
+
+        su2 = ShortUUID(base64_alphabet)
+        self.assertEqual(su2.encoded_length(), 22)
+
+        binary_alphabet = "01"
+        su3 = ShortUUID(binary_alphabet)
+        self.assertEqual(su3.encoded_length(), 128)
+
+        su4 = ShortUUID()
+        self.assertEqual(su4.encoded_length(num_bytes=8), 11)
+
+
+class ShortUUIDPaddingTest(unittest.TestCase):
+    def test_padding(self):
+        su = ShortUUID()
+        random_uid = uuid4()
+        smallest_uid = UUID(int=0)
+
+        encoded_random = su.encode(random_uid)
+        encoded_small = su.encode(smallest_uid)
+
+        self.assertEqual(len(encoded_random), len(encoded_small))
+
+    def test_decoding(self):
+        su = ShortUUID()
+        random_uid = uuid4()
+        smallest_uid = UUID(int=0)
+
+        encoded_random = su.encode(random_uid)
+        encoded_small = su.encode(smallest_uid)
+
+        self.assertEqual(su.decode(encoded_small), smallest_uid)
+        self.assertEqual(su.decode(encoded_random), random_uid)
+
+    def test_consistency(self):
+        su = ShortUUID()
+        num_iterations = 1000
+        uid_lengths = defaultdict(int)
+
+        for count in range(num_iterations):
+            random_uid = uuid4()
+            encoded_random = su.encode(random_uid)
+            uid_lengths[len(encoded_random)] += 1
+            decoded_random = su.decode(encoded_random)
+
+            self.assertEqual(random_uid, decoded_random)
+
+        self.assertEqual(len(uid_lengths), 1)
+        uid_length = next(iter(uid_lengths.keys()))  # Get the 1 value
+
+        self.assertEqual(uid_lengths[uid_length], num_iterations)
+
+
+class EncodingEdgeCasesTest(unittest.TestCase):
+    def test_decode_dict(self):
+        su = ShortUUID()
+        self.assertRaises(ValueError, su.encode, [])
+        self.assertRaises(ValueError, su.encode, {})
+        self.assertRaises(ValueError, su.decode, (2,))
+        self.assertRaises(ValueError, su.encode, 42)
+        self.assertRaises(ValueError, su.encode, 42.0)
+
+
+class DecodingEdgeCasesTest(unittest.TestCase):
+    def test_decode_dict(self):
+        su = ShortUUID()
+        self.assertRaises(ValueError, su.decode, [])
+        self.assertRaises(ValueError, su.decode, {})
+        self.assertRaises(ValueError, su.decode, (2,))
+        self.assertRaises(ValueError, su.decode, 42)
+        self.assertRaises(ValueError, su.decode, 42.0)
+
+
+class CliTest(unittest.TestCase):
+    @patch("shortuuid.cli.print")
+    def test_shortuuid_command_produces_uuid(self, mock_print):
+        # When we call the main cli function
+        cli([])
+        # Then a shortuuid is printed out
+        mock_print.assert_called()
+        terminal_output = mock_print.call_args[0][0]
+        self.assertEqual(len(terminal_output), 22)
+
+    @patch("shortuuid.cli.print")
+    def test_encode_command(self, mock_print):
+        cli(["encode", "3b1f8b40-222c-4a6e-b77e-779d5a94e21c"])
+
+        terminal_output = mock_print.call_args[0][0]
+        self.assertEqual(terminal_output, "CXc85b4rqinB7s5J52TRYb")
+
+    @patch("shortuuid.cli.print")
+    def test_decode_command(self, mock_print):
+        cli(["decode", "CXc85b4rqinB7s5J52TRYb"])
+
+        terminal_output = mock_print.call_args[0][0]
+        self.assertEqual(terminal_output, 
"3b1f8b40-222c-4a6e-b77e-779d5a94e21c")
+
+
+if __name__ == "__main__":
+    unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shortuuid-1.0.9/shortuuid/tests.py 
new/shortuuid-1.0.11/shortuuid/tests.py
--- old/shortuuid-1.0.9/shortuuid/tests.py      2022-05-08 11:53:02.233916000 
+0200
+++ new/shortuuid-1.0.11/shortuuid/tests.py     1970-01-01 01:00:00.000000000 
+0100
@@ -1,197 +0,0 @@
-import os
-import string
-import sys
-import unittest
-from collections import defaultdict
-from uuid import UUID
-from uuid import uuid4
-
-from shortuuid.main import decode
-from shortuuid.main import encode
-from shortuuid.main import get_alphabet
-from shortuuid.main import random
-from shortuuid.main import set_alphabet
-from shortuuid.main import ShortUUID
-from shortuuid.main import uuid
-
-sys.path.insert(0, os.path.abspath(__file__ + "/../.."))
-
-
-class LegacyShortUUIDTest(unittest.TestCase):
-    def test_generation(self):
-        self.assertTrue(20 < len(uuid()) < 24)
-        self.assertTrue(20 < len(uuid("http://www.example.com/";)) < 24)
-        self.assertTrue(20 < len(uuid("HTTP://www.example.com/")) < 24)
-        self.assertTrue(20 < len(uuid("example.com/")) < 24)
-
-    def test_encoding(self):
-        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
-        self.assertEqual(encode(u), "CXc85b4rqinB7s5J52TRYb")
-
-    def test_decoding(self):
-        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
-        self.assertEqual(decode("CXc85b4rqinB7s5J52TRYb"), u)
-
-    def test_alphabet(self):
-        backup_alphabet = get_alphabet()
-
-        alphabet = "01"
-        set_alphabet(alphabet)
-        self.assertEqual(alphabet, get_alphabet())
-
-        set_alphabet("01010101010101")
-        self.assertEqual(alphabet, get_alphabet())
-
-        self.assertEqual(set(uuid()), set("01"))
-        self.assertTrue(116 < len(uuid()) < 140)
-
-        u = uuid4()
-        self.assertEqual(u, decode(encode(u)))
-
-        u = uuid()
-        self.assertEqual(u, encode(decode(u)))
-
-        self.assertRaises(ValueError, set_alphabet, "1")
-        self.assertRaises(ValueError, set_alphabet, "1111111")
-
-        set_alphabet(backup_alphabet)
-
-        self.assertRaises(ValueError, lambda x: ShortUUID(x), "0")
-
-    def test_random(self):
-        self.assertEqual(len(random()), 22)
-        for i in range(1, 100):
-            self.assertEqual(len(random(i)), i)
-
-
-class ClassShortUUIDTest(unittest.TestCase):
-    def test_generation(self):
-        su = ShortUUID()
-        self.assertTrue(20 < len(su.uuid()) < 24)
-        self.assertTrue(20 < len(su.uuid("http://www.example.com/";)) < 24)
-        self.assertTrue(20 < len(su.uuid("HTTP://www.example.com/")) < 24)
-        self.assertTrue(20 < len(su.uuid("example.com/")) < 24)
-
-    def test_encoding(self):
-        su = ShortUUID()
-        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
-        self.assertEqual(su.encode(u), "CXc85b4rqinB7s5J52TRYb")
-
-    def test_decoding(self):
-        su = ShortUUID()
-        u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
-        self.assertEqual(su.decode("CXc85b4rqinB7s5J52TRYb"), u)
-
-    def test_random(self):
-        su = ShortUUID()
-        for i in range(1000):
-            self.assertEqual(len(su.random()), 22)
-
-        for i in range(1, 100):
-            self.assertEqual(len(su.random(i)), i)
-
-    def test_alphabet(self):
-        alphabet = "01"
-        su1 = ShortUUID(alphabet)
-        su2 = ShortUUID()
-
-        self.assertEqual(alphabet, su1.get_alphabet())
-
-        su1.set_alphabet("01010101010101")
-        self.assertEqual(alphabet, su1.get_alphabet())
-
-        self.assertEqual(set(su1.uuid()), set("01"))
-        self.assertTrue(116 < len(su1.uuid()) < 140)
-        self.assertTrue(20 < len(su2.uuid()) < 24)
-
-        u = uuid4()
-        self.assertEqual(u, su1.decode(su1.encode(u)))
-
-        u = su1.uuid()
-        self.assertEqual(u, su1.encode(su1.decode(u)))
-
-        self.assertRaises(ValueError, su1.set_alphabet, "1")
-        self.assertRaises(ValueError, su1.set_alphabet, "1111111")
-
-    def test_encoded_length(self):
-        su1 = ShortUUID()
-        self.assertEqual(su1.encoded_length(), 22)
-
-        base64_alphabet = (
-            string.ascii_uppercase + string.ascii_lowercase + string.digits + 
"+/"
-        )
-
-        su2 = ShortUUID(base64_alphabet)
-        self.assertEqual(su2.encoded_length(), 22)
-
-        binary_alphabet = "01"
-        su3 = ShortUUID(binary_alphabet)
-        self.assertEqual(su3.encoded_length(), 128)
-
-        su4 = ShortUUID()
-        self.assertEqual(su4.encoded_length(num_bytes=8), 11)
-
-
-class ShortUUIDPaddingTest(unittest.TestCase):
-    def test_padding(self):
-        su = ShortUUID()
-        random_uid = uuid4()
-        smallest_uid = UUID(int=0)
-
-        encoded_random = su.encode(random_uid)
-        encoded_small = su.encode(smallest_uid)
-
-        self.assertEqual(len(encoded_random), len(encoded_small))
-
-    def test_decoding(self):
-        su = ShortUUID()
-        random_uid = uuid4()
-        smallest_uid = UUID(int=0)
-
-        encoded_random = su.encode(random_uid)
-        encoded_small = su.encode(smallest_uid)
-
-        self.assertEqual(su.decode(encoded_small), smallest_uid)
-        self.assertEqual(su.decode(encoded_random), random_uid)
-
-    def test_consistency(self):
-        su = ShortUUID()
-        num_iterations = 1000
-        uid_lengths = defaultdict(int)
-
-        for count in range(num_iterations):
-            random_uid = uuid4()
-            encoded_random = su.encode(random_uid)
-            uid_lengths[len(encoded_random)] += 1
-            decoded_random = su.decode(encoded_random)
-
-            self.assertEqual(random_uid, decoded_random)
-
-        self.assertEqual(len(uid_lengths), 1)
-        uid_length = next(iter(uid_lengths.keys()))  # Get the 1 value
-
-        self.assertEqual(uid_lengths[uid_length], num_iterations)
-
-
-class EncodingEdgeCasesTest(unittest.TestCase):
-    def test_decode_dict(self):
-        su = ShortUUID()
-        self.assertRaises(ValueError, su.encode, [])
-        self.assertRaises(ValueError, su.encode, {})
-        self.assertRaises(ValueError, su.decode, (2,))
-        self.assertRaises(ValueError, su.encode, 42)
-        self.assertRaises(ValueError, su.encode, 42.0)
-
-
-class DecodingEdgeCasesTest(unittest.TestCase):
-    def test_decode_dict(self):
-        su = ShortUUID()
-        self.assertRaises(ValueError, su.decode, [])
-        self.assertRaises(ValueError, su.decode, {})
-        self.assertRaises(ValueError, su.decode, (2,))
-        self.assertRaises(ValueError, su.decode, 42)
-        self.assertRaises(ValueError, su.decode, 42.0)
-
-
-if __name__ == "__main__":
-    unittest.main()

Reply via email to