Skip to content

test_basic failing on Windows #448

@sygout

Description

@sygout

With master branch commit 02b3c84

When running pytest for test_basic.py on Windows, it returns an error:
==================================================================== test session starts ====================================================================
platform win32 -- Python 3.9.9, pytest-7.1.2, pluggy-1.0.0
rootdir: C:\Users\sygo\Sylvain\Codes\temporary\ontopy2\EMMO-python
collected 2 items

test_basic.py .F [100%]

========================================================================= FAILURES ==========================================================================
____________________________________________________________________ test_sync_reasoner _____________________________________________________________________

src = 'C:\Users\sygo\AppData\Local\Temp\tmpfvrqt25p', dst = 'C:\Users\sygo\AppData\Local\Temp\tmpe_8_gu75'
copy_function = <function copy2 at 0x000001CC8FCA7790>

def move(src, dst, copy_function=copy2):
    """Recursively move a file or directory to another location. This is
    similar to the Unix "mv" command. Return the file or directory's
    destination.

    If the destination is a directory or a symlink to a directory, the source
    is moved inside the directory. The destination path must not already
    exist.

    If the destination already exists but is not a directory, it may be
    overwritten depending on os.rename() semantics.

    If the destination is on our current filesystem, then rename() is used.
    Otherwise, src is copied to the destination and then removed. Symlinks are
    recreated under the new name if os.rename() fails because of cross
    filesystem renames.

    The optional `copy_function` argument is a callable that will be used
    to copy the source or it will be delegated to `copytree`.
    By default, copy2() is used, but any function that supports the same
    signature (like copy()) can be used.

    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.

    """
    sys.audit("shutil.move", src, dst)
    real_dst = dst
    if os.path.isdir(dst):
        if _samefile(src, dst):
            # We might be on a case insensitive filesystem,
            # perform the rename anyway.
            os.rename(src, dst)
            return

        # Using _basename instead of os.path.basename is important, as we must
        # ignore any trailing slash to avoid the basename returning ''
        real_dst = os.path.join(dst, _basename(src))

        if os.path.exists(real_dst):
            raise Error("Destination path '%s' already exists" % real_dst)
    try:
      os.rename(src, real_dst)

E FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\Users\sygo\AppData\Local\Temp\tmpfvrqt25p' -> 'C:\Users\sygo\AppData\Local\Temp\tmpe_8_gu75'

C:\Python\Python39\lib\shutil.py:815: FileExistsError

During handling of the above exception, another exception occurred:

testonto = get_ontology("http://emmo.info/testonto#")

def test_sync_reasoner(testonto: "Ontology") -> None:
    """Test `ontopy:Ontology.sync_reasoner()`."""
  testonto.sync_reasoner()

test_basic.py:60:


..\ontopy\ontology.py:1073: in sync_reasoner
sync(self, **kwargs)
..\ontopy\factpluspluswrapper\sync_factpp.py:80: in sync_reasoner_factpp
graph2 = FaCTPPGraph(graph1).inferred_graph()
..\ontopy\factpluspluswrapper\factppgraph.py:66: in inferred_graph
self.add_base_annotations()
..\ontopy\factpluspluswrapper\factppgraph.py:76: in add_base_annotations
inferred = self.inferred
..\ontopy\factpluspluswrapper\factppgraph.py:32: in inferred
self._inferred = self.raw_inferred_graph()
..\ontopy\factpluspluswrapper\factppgraph.py:62: in raw_inferred_graph
return OwlApiInterface().reason(self.graph)
..\ontopy\factpluspluswrapper\owlapi_interface.py:34: in reason
graph.serialize(tmpdir.name, format="xml")
C:\Users\sygo\Envs\ontopy2\lib\site-packages\rdflib\graph.py:1210: in serialize
shutil.move(name, dest)
C:\Python\Python39\lib\shutil.py:835: in move
copy_function(src, real_dst)
C:\Python\Python39\lib\shutil.py:444: in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)


src = 'C:\Users\sygo\AppData\Local\Temp\tmpfvrqt25p', dst = 'C:\Users\sygo\AppData\Local\Temp\tmpe_8_gu75'

def copyfile(src, dst, *, follow_symlinks=True):
    """Copy data from src to dst in the most efficient way possible.

    If follow_symlinks is not set and src is a symbolic link, a new
    symlink will be created instead of copying the file it points to.

    """
    sys.audit("shutil.copyfile", src, dst)

    if _samefile(src, dst):
        raise SameFileError("{!r} and {!r} are the same file".format(src, dst))

    file_size = 0
    for i, fn in enumerate([src, dst]):
        try:
            st = _stat(fn)
        except OSError:
            # File most likely does not exist
            pass
        else:
            # XXX What about other special files? (sockets, devices...)
            if stat.S_ISFIFO(st.st_mode):
                fn = fn.path if isinstance(fn, os.DirEntry) else fn
                raise SpecialFileError("`%s` is a named pipe" % fn)
            if _WINDOWS and i == 0:
                file_size = st.st_size

    if not follow_symlinks and _islink(src):
        os.symlink(os.readlink(src), dst)
    else:
        with open(src, 'rb') as fsrc:
            try:
              with open(dst, 'wb') as fdst:

E PermissionError: [Errno 13] Permission denied: 'C:\Users\sygo\AppData\Local\Temp\tmpe_8_gu75'

C:\Python\Python39\lib\shutil.py:266: PermissionError
------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
*** Prepare graph
*** Run FaCT++ reasoner (and postprocess)
================================================================== short test summary info ==================================================================
FAILED test_basic.py::test_sync_reasoner - PermissionError: [Errno 13] Permission denied: 'C:\Users\sygo\AppData\Local\Temp\tmpe_8_gu75'
================================================================ 1 failed, 1 passed in 2.18s ================================================================

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions