Skip to content

Skip test_copyfile_nonexistent_dir in AIX #92670

Closed

Description

@ayappanec

test_copyfile_nonexistent_dir fails in AIX.

======================================================================
FAIL: test_copyfile_nonexistent_dir (test.test_shutil.TestCopy)

Traceback (most recent call last):
File "/python3_work/Python-3.9.12/Lib/test/test_shutil.py", line 1276, in test_copyfile_nonexistent_dir
self.assertRaises(FileNotFoundError, shutil.copyfile, src_file, dst)
AssertionError: FileNotFoundError not raised by copyfile


From the testcase.,
def test_copyfile_nonexistent_dir(self):
# Issue 43219
src_dir = self.mkdtemp()
src_file = os.path.join(src_dir, 'foo')
dst = os.path.join(src_dir, 'does_not_exist/')
write_file(src_file, 'foo')
self.assertRaises(FileNotFoundError, shutil.copyfile, src_file, dst)

It assumes that having a trailing slash ( 'does_not_exist/' ) makes the OS to consider it as directory. It is discussed more in this issue https://bugs.python.org/issue43219 . But in AIX, it is not the case. The trailing slash has no effect. It is considered as a file and get created. That is atleast how the AIX open call behaviour is.

import os
src_dir = 'temp_dir'
src_file = os.path.join(src_dir, 'foo')
dst = os.path.join(src_dir, 'does_not_exist/')
assert not os.path.exists(dst)
with open(dst, 'wb') as fp:
fp.write(b'foo')

Running the above in AIX, it creates the file does_not_exist.

The testcase is skipped for other distros like MacOS, Solaris because of different errors thrown. For AIX also, this testcase needs to be skipped , though for a different reason.

Activity

  1. added a commit that references this issue on May 19, 2022
  2. added 2 commits that reference this issue on May 19, 2022
  3. added 2 commits that reference this issue on May 19, 2022
  4. ayappanec commented on May 19, 2022

    @ayappanec
    ContributorAuthor

    Thanks @erlend-aasland for the review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions