mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
make 'generate_token()' compatible with Python 3.4
This commit is contained in:
parent
1fdecfa269
commit
91308140ec
@ -18,6 +18,7 @@ import shutil
|
||||
import string
|
||||
import _string
|
||||
import sqlite3
|
||||
import binascii
|
||||
import datetime
|
||||
import operator
|
||||
import itertools
|
||||
@ -73,7 +74,8 @@ def raises(cls):
|
||||
|
||||
def generate_token(size=16):
|
||||
"""Generate a random token with hexadecimal digits"""
|
||||
return random.getrandbits(size * 8).to_bytes(size, "big").hex()
|
||||
data = random.getrandbits(size * 8).to_bytes(size, "big")
|
||||
return binascii.hexlify(data).decode()
|
||||
|
||||
|
||||
def combine_dict(a, b):
|
||||
|
@ -474,7 +474,6 @@ class TestOther(unittest.TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
func(3)
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x3050000, "missing bytes.hex()")
|
||||
def test_generate_token(self):
|
||||
tokens = set()
|
||||
for _ in range(100):
|
||||
|
Loading…
Reference in New Issue
Block a user