def METHOD_NAME(self):
    """A directory is tried to be opened without using the O_Directory flag."""
    error = sys.stderr = StringIO()
    directory = b'/etc/'
    self.assertRaises(Exception, secure_open_file, directory, os.O_RDONLY)
    secure_open_file(directory, os.O_DIRECTORY)
    SecureOSFunctions.no_secure_open_warn_once_flag = True
    self.assertTrue(
        error.getvalue() in ['WARNING: SECURITY: No secure open yet due to missing openat in python!\n', ''])