Skip to content Skip to sidebar Skip to footer

File Does Not Exist Error With 'w' Mode

I am encountering an odd behaviour from the file() builtin. I am using the unittest-xml-reporting Python package to generate results for my unit tests. Here are the lines that open

Solution 1:

from man 2 read

   ENOENT O_CREAT  is  not  set  and the named file does not exist.  Or, a
          directory component in pathname does not exist or is a  dangling
          symbolic link.

take your pick :)

in human terms:

  • your current working directory, ./ is removed by the time this command is ran,
  • ./TEST-cms.tests.page.NoAdminPageTests.xml exists but is a symlink pointing to nowhere
  • "w" in your open/file call is somehow messed up, e.g. if you redefined file builtin

Solution 2:

file will create a file, but not a directory. You have to create it first, as seen here


Solution 3:

It seems like the file which needed to be created was attempted to be created in a directory that has already been deleted (since the path was given as . and most probably the test directory has been deleted by that point).

I managed to fix this by supplying an absolute path to test_runner.output and the result files are successfully created now.


Post a Comment for "File Does Not Exist Error With 'w' Mode"