summaryrefslogtreecommitdiff
path: root/virtinst
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2014-02-14 11:02:35 -0500
committerCole Robinson <crobinso@redhat.com>2014-02-14 11:02:35 -0500
commitf431efc9b734c661a937d25f8af29710f9a4c578 (patch)
treeb340a5b89336b06b5a26a18a24a9f0d90bfbe72c /virtinst
parentd9d50db522e016f39e71407b5dfbf9394575ac96 (diff)
downloadvirt-manager-f431efc9b734c661a937d25f8af29710f9a4c578.tar.gz
tests: Don't overwrite mkstemp, just check environment
Since this can interfere with the initrdinject test
Diffstat (limited to 'virtinst')
-rw-r--r--virtinst/connection.py9
-rw-r--r--virtinst/urlfetcher.py11
2 files changed, 9 insertions, 11 deletions
diff --git a/virtinst/connection.py b/virtinst/connection.py
index 210d927b..66c29143 100644
--- a/virtinst/connection.py
+++ b/virtinst/connection.py
@@ -35,13 +35,6 @@ from virtinst.cli import VirtOptionString
_virtinst_uri_magic = "__virtinst_test__"
-def _fakemkstemp(prefix, *args, **kwargs):
- ignore = args
- ignore = kwargs
- filename = os.path.join(".", prefix)
- return os.open(filename, os.O_RDWR | os.O_CREAT), filename
-
-
def _sanitize_xml(xml):
import difflib
@@ -411,8 +404,6 @@ class VirtualConnection(object):
if "predictable" in opts:
opts.pop("predictable")
- import tempfile
- tempfile.mkstemp = _fakemkstemp
setattr(self, "_virtinst__fake_conn_predictable", True)
# Fake remote status
diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py
index 438c0f5b..3c273e3b 100644
--- a/virtinst/urlfetcher.py
+++ b/virtinst/urlfetcher.py
@@ -63,8 +63,15 @@ class _ImageFetcher(object):
def saveTemp(self, fileobj, prefix):
if not os.path.exists(self.scratchdir):
os.makedirs(self.scratchdir, 0750)
- (fd, fn) = tempfile.mkstemp(prefix="virtinst-" + prefix,
- dir=self.scratchdir)
+
+ prefix = "virtinst-" + prefix
+ if "VIRTINST_TEST_SUITE" in os.environ:
+ fn = os.path.join(".", prefix)
+ fd = os.open(fn, os.O_RDWR | os.O_CREAT)
+ else:
+ (fd, fn) = tempfile.mkstemp(prefix=prefix,
+ dir=self.scratchdir)
+
block_size = 16384
try:
while 1: