summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index d4010f4..2ce013f 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -40,7 +40,7 @@ __all__ = [
"is_resource_enabled", "requires", "requires_linux_version",
"requires_mac_ver", "find_unused_port", "bind_port",
"IPV6_ENABLED", "is_jython", "TESTFN", "HOST", "SAVEDCWD", "temp_cwd",
- "findfile", "sortdict", "check_syntax_error", "open_urlresource",
+ "findfile", "create_empty_file", "sortdict", "check_syntax_error", "open_urlresource",
"check_warnings", "CleanImport", "EnvironmentVarGuard", "TransientResource",
"captured_stdout", "captured_stdin", "captured_stderr", "time_out",
"socket_peer_reset", "ioerror_peer_reset", "run_with_locale", 'temp_umask',
@@ -596,6 +596,11 @@ def findfile(file, here=__file__, subdir=None):
if os.path.exists(fn): return fn
return file
+def create_empty_file(filename):
+ """Create an empty file. If the file already exists, truncate it."""
+ fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
+ os.close(fd)
+
def sortdict(dict):
"Like repr(dict), but in sorted order."
items = sorted(dict.items())