Skip to content

Commit e47cded

Browse files
[remote_ops] A problem with mktemp on Alpine Linux is fixed
Five 'X' in template is not enough - Alpine returns "mktemp: : Invalid argument" error. Six 'X' is OK.
1 parent ddcaea0 commit e47cded

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

testgres/operations/remote_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def mkdtemp(self, prefix=None):
316316
- prefix (str): The prefix of the temporary directory name.
317317
"""
318318
if prefix:
319-
command = ["mktemp", "-d", "-t", prefix + "XXXXX"]
319+
command = ["mktemp", "-d", "-t", prefix + "XXXXXX"]
320320
else:
321321
command = ["mktemp", "-d"]
322322

@@ -344,7 +344,7 @@ def mkstemp(self, prefix=None):
344344
- prefix (str): The prefix of the temporary directory name.
345345
"""
346346
if prefix:
347-
command = ["mktemp", "-t", prefix + "XXXXX"]
347+
command = ["mktemp", "-t", prefix + "XXXXXX"]
348348
else:
349349
command = ["mktemp"]
350350

tests/test_local.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
import re
66
import tempfile
7+
import logging
78

89
from ..testgres import ExecUtilException
910
from ..testgres import InvalidOperationException
@@ -18,6 +19,22 @@ class TestLocalOperations:
1819
def setup(self):
1920
self.operations = LocalOperations()
2021

22+
def test_mkdtemp__default(self):
23+
path = self.operations.mkdtemp()
24+
logging.info("Path is [{0}].".format(path))
25+
assert os.path.exists(path)
26+
os.rmdir(path)
27+
assert not os.path.exists(path)
28+
29+
def test_mkdtemp__custom(self):
30+
C_TEMPLATE = "abcdef"
31+
path = self.operations.mkdtemp(C_TEMPLATE)
32+
logging.info("Path is [{0}].".format(path))
33+
assert os.path.exists(path)
34+
assert C_TEMPLATE in os.path.basename(path)
35+
os.rmdir(path)
36+
assert not os.path.exists(path)
37+
2138
def test_exec_command_success(self):
2239
"""
2340
Test exec_command for successful command execution.

tests/test_remote.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
import re
66
import tempfile
7+
import logging
78

89
from ..testgres import ExecUtilException
910
from ..testgres import InvalidOperationException
@@ -110,6 +111,22 @@ def test_makedirs_failure(self):
110111
with pytest.raises(Exception):
111112
self.operations.makedirs(path)
112113

114+
def test_mkdtemp__default(self):
115+
path = self.operations.mkdtemp()
116+
logging.info("Path is [{0}].".format(path))
117+
assert os.path.exists(path)
118+
os.rmdir(path)
119+
assert not os.path.exists(path)
120+
121+
def test_mkdtemp__custom(self):
122+
C_TEMPLATE = "abcdef"
123+
path = self.operations.mkdtemp(C_TEMPLATE)
124+
logging.info("Path is [{0}].".format(path))
125+
assert os.path.exists(path)
126+
assert C_TEMPLATE in os.path.basename(path)
127+
os.rmdir(path)
128+
assert not os.path.exists(path)
129+
113130
def test_rmdirs(self):
114131
path = self.operations.mkdtemp()
115132
assert os.path.exists(path)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy