code: def rmdir(self, target_directory, allow_symlink=False):
          
          if target_directory in (b'.', u'.'):
              error_nr = errno.EACCES if self.is_windows_fs else errno.EINVAL
              self.raise_os_error(error_nr, target_directory)
          ends_with_sep = self.ends_with_path_separator(target_directory)
          target_directory = self.absnormpath(target_directory)
          if self.confirmdir(target_directory):
              if not self.is_windows_fs and self.islink(target_directory):
                  if allow_symlink:
                      return
                  if not ends_with_sep or not self.is_macos:
                      self.raise_os_error(errno.ENOTDIR, target_directory)
  
              dir_object = self.resolve(target_directory)
              if dir_object.contents:
                  self.raise_os_error(errno.ENOTEMPTY, target_directory)
              try:
                  self.remove_object(target_directory)
              except IOError as exc:
                  self.raise_os_error(exc.errno, exc.filename)
docs: Remove a leaf Fake directory.
  
          Args:
              target_directory: (str) Name of directory to remove.
              allow_symlink: (bool) if `target_directory` is a symlink,
                  the function just returns, otherwise it raises (Posix only)
  
          Raises:
              OSError: if target_directory does not exist.
              OSError: if target_directory does not point to a directory.
              OSError: if removal failed per FakeFilesystem.RemoveObject.
                  Cannot remove '.'.