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

Conversation

shihai1991
Copy link
Member

@shihai1991 shihai1991 commented Jun 7, 2020

Add a new test.support.filesystem_helper submodule and move TESTFN to filesystem_helper.

https://bugs.python.org/issue40275

@shihai1991
Copy link
Member Author

@vstinner Hi, victor. How about this PR of fileystem_helper?

@vstinner
Copy link
Member

vstinner commented Jun 7, 2020

I would prefer to create the whole helper module at once, but then we can convert existing tests to this helper by small PR modifying a bunch of tests (not all tests at once). I proposed:

* support.file_helper: 

  * rmtree() and the related private functions
  * unlink()
  * rmdir()
  * FS_NONASCII
  * TESTFN_UNICODE, TESTFN_NONASCII, TESTFN_UNENCODABLE, TESTFN_UNDECODABLE
  * SAVEDCWD (not sure about this one)
  * TESTFN_ENCODING <= this one can be removed, it's just sys.getfilesystemencoding()
  * temp_dir()
  * change_cwd()
  * temp_cwd()
  * temp_umask()
  * create_empty_file()
  * make_bad_fd()
  * EnvironmentVarGuard (not sure about this one)
  * can_symlink(), skip_unless_symlink()
  * can_xattr(), skip_unless_xattr()
  * fs_is_case_insensitive()
  * fd_count()
  * FakePath

About the file name, there is Python/fileutils.h. Here "utils" becomes "helper". Maybe the module can be named "test.support.file_helper"? It is shorter than "filesystem_helper" and so helps to fit into 80 columns.

Another possible name is "os_helper" since the functions that I proposed are not only about files. make_bad_fd() and fd_count() are about file descriptors, not "regular (named) files".

I have a preference for "os_helper".

Moreover, maybe we should have one PR per new helper submodule, and wait until enough helper submodules are created before starting the bunch of "cleanup" changes which use helper modules rather than test.support. I'm thinking at my other propositions:

  • process_helper
  • import_helper
  • warnings_helper
  • maybe move more functions to socket_helper

See https://bugs.python.org/issue40275#msg368840

@shihai1991
Copy link
Member Author

Another possible name is "os_helper" since the functions that I proposed are not only about files. make_bad_fd() and fd_count() are about file descriptors, not "regular (named) files".

I have a preference for "os_helper".

+1, os means that it have include filesystem already.

Moreover, maybe we should have one PR per new helper submodule, and wait until enough helper submodules are created before starting the bunch of "cleanup" changes which use helper modules rather than test.support. I'm thinking at my other propositions:

  • process_helper
  • import_helper
  • warnings_helper
  • maybe move more functions to socket_helper

See https://bugs.python.org/issue40275#msg368840

make sense.

@shihai1991
Copy link
Member Author

I create an os_helper submodule in #20732, so I close this PR.

@shihai1991 shihai1991 closed this Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants