Skip to content
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

Test file mode on Windows #84828

Closed
scrool mannequin opened this issue May 16, 2020 · 2 comments
Closed

Test file mode on Windows #84828

scrool mannequin opened this issue May 16, 2020 · 2 comments
Labels
3.10 only security fixes OS-windows tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@scrool
Copy link
Mannequin

scrool mannequin commented May 16, 2020

BPO 40648
Nosy @pfmoore, @tjguk, @zware, @zooba, @scrool
PRs
  • bpo-40648: Test modes that file can get with chmod() on Windows #20130
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-05-16.15:47:26.080>
    labels = ['type-feature', 'tests', '3.10', 'OS-windows']
    title = 'Test file mode on Windows'
    updated_at = <Date 2020-05-23.04:11:36.850>
    user = 'https://github.com/scrool'

    bugs.python.org fields:

    activity = <Date 2020-05-23.04:11:36.850>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests', 'Windows']
    creation = <Date 2020-05-16.15:47:26.080>
    creator = 'scrool'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40648
    keywords = ['patch']
    message_count = 1.0
    messages = ['369056']
    nosy_count = 5.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'steve.dower', 'scrool']
    pr_nums = ['20130']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40648'
    versions = ['Python 3.10']

    @scrool
    Copy link
    Mannequin Author

    scrool mannequin commented May 16, 2020

    From what I can tell only place where file mode is tested is test_mode() method of class TestFilemode in test_stat.py. Relevant section for Windows (os.name != 'posix'):

    with open(TESTFN, 'w'):
      pass

    ...

    os.chmod(TESTFN, 0o700)
    st_mode, modestr = self.get_mode()
    self.assertEqual(modestr[:3], '-rw')
    self.assertS_IS("REG", st_mode)
    self.assertEqual(self.statmod.S_IFMT(st_mode),
                     self.statmod.S_IFREG)

    Doesn't test that files under Windows can have only two modes:

    • 0o444 - If os.chmod() is missing stat.S_IWRITE. Effectively readonly.
    • 0o666 - Regular file by default.

    On the top of that I believe last two assertions are equivalent - test file is regular. But that would be for a different issue, I guess.

    @scrool scrool mannequin added 3.9 only security fixes tests Tests in the Lib/test dir type-feature A feature request or enhancement labels May 16, 2020
    @terryjreedy terryjreedy added OS-windows 3.10 only security fixes and removed 3.9 only security fixes labels May 23, 2020
    @terryjreedy terryjreedy changed the title File mode is not tested on Windows Test file mode on Windows May 23, 2020
    @terryjreedy terryjreedy changed the title File mode is not tested on Windows Test file mode on Windows May 23, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution @scrool.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes OS-windows tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants