Skip to content

bpo-40275: Adding filesystem_helper submodule in test.support #20689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions Doc/library/test.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ The :mod:`test.support` module defines the following constants:
A non-ASCII character encodable by :func:`os.fsencode`.


.. data:: TESTFN

Set to a name that is safe to use as the name of a temporary file. Any
temporary file that is created should be closed and unlinked (removed).


.. data:: TESTFN_UNICODE

Set to a non-ASCII name for a temporary file.
Expand Down Expand Up @@ -1634,3 +1628,20 @@ The :mod:`test.support.threading_helper` module provides support for threading t
# (to avoid reference cycles)

.. versionadded:: 3.8


:mod:`test.support.filesystem_helper` --- Utilities for filesystem tests
========================================================================

.. module:: test.support.filesystem_helper
:synopsis: Support for filesystem tests.

The :mod:`test.support.filesystem_helper` module provides support for filesystem tests.

.. versionadded:: 3.10


.. data:: TESTFN

Set to a name that is safe to use as the name of a temporary file. Any
temporary file that is created should be closed and unlinked (removed).
14 changes: 2 additions & 12 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import unittest
import warnings

from .filesystem_helper import TESTFN
from .testresult import get_test_runner

__all__ = [
Expand All @@ -37,7 +38,7 @@
"record_original_stdout", "get_original_stdout", "captured_stdout",
"captured_stdin", "captured_stderr",
# filesystem
"TESTFN", "SAVEDCWD", "unlink", "rmtree", "temp_cwd", "findfile",
"SAVEDCWD", "unlink", "rmtree", "temp_cwd", "findfile",
"create_empty_file", "can_symlink", "fs_is_case_insensitive",
# unittest
"is_resource_enabled", "requires", "requires_freebsd_version",
Expand Down Expand Up @@ -714,17 +715,6 @@ def requires_lzma(reason='requires lzma'):
else:
unix_shell = None

# Filename used for testing
if os.name == 'java':
# Jython disallows @ in module names
TESTFN = '$test'
else:
TESTFN = '@test'

# Disambiguate TESTFN for parallel testing, while letting it remain a valid
# module name.
TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())

# Define the URL of a dedicated HTTP server for the network tests.
# The URL must use clear-text HTTP: no redirection to encrypted HTTPS.
TEST_HTTP_URL = "http://www.pythontest.net"
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/support/filesystem_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os


# Filename used for testing
if os.name == 'java':
# Jython disallows @ in module names
TESTFN = '$test'
else:
TESTFN = '@test'

# Disambiguate TESTFN for parallel testing, while letting it remain a valid
# module name.
TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())