Skip to content

Commit d964cac

Browse files
committed
chore(test): Replace temp._RandomNameSequence with separate function
This was a private API and not mypy compatible (not in typeshed)
1 parent 19a9f28 commit d964cac

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

libtmux/test.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import contextlib
33
import logging
44
import os
5-
import tempfile
5+
import random
66
import time
77
import warnings
8-
from typing import Callable, Optional
8+
from typing import Callable, List, Optional
99

1010
from .exc import WaitTimeout
1111

@@ -15,7 +15,19 @@
1515
RETRY_TIMEOUT_SECONDS = int(os.getenv("RETRY_TIMEOUT_SECONDS", 8))
1616
RETRY_INTERVAL_SECONDS = float(os.getenv("RETRY_INTERVAL_SECONDS", 0.05))
1717

18-
namer = tempfile._RandomNameSequence()
18+
19+
class RandomStrSequence:
20+
def __init__(self, characters: str = "abcdefghijklmnopqrstuvwxyz0123456789_"):
21+
self.characters: str = characters
22+
23+
def __iter__(self):
24+
return self
25+
26+
def __next__(self):
27+
return "".join(random.sample(self.characters, k=8))
28+
29+
30+
namer = RandomStrSequence()
1931
current_dir = os.path.abspath(os.path.dirname(__file__))
2032
example_dir = os.path.abspath(os.path.join(current_dir, "..", "examples"))
2133
fixtures_dir = os.path.realpath(os.path.join(current_dir, "fixtures"))

0 commit comments

Comments
 (0)