jupyter / nbgrader

A system for assigning and grading notebooks
https://nbgrader.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.28k stars 316 forks source link

posixpath != os.path errors in tests #1757

Open perllaghu opened 1 year ago

perllaghu commented 1 year ago

I'm running tests after writing an update to nbgrader code, and getting essentially the same error 4 times:

FAILED nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_fetch - AssertionError: assert False
FAILED nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_deprecated - AssertionError: assert False
FAILED nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_fetch_with_assignment_flag - AssertionError: assert False
FAILED nbgrader/tests/apps/test_nbgrader_fetchfeedback.py::TestNbGraderFetchFeedback::test_single_file - AssertionError: assert False

in details for 1:

    def test_fetch(self, exchange, course_dir):
        self._release("ps1", exchange, course_dir)
        self._fetch("ps1", exchange)
>       assert os.path.isfile(join("ps1", "p1.ipynb"))
E       AssertionError: assert False
E        +  where False = <function isfile at 0x7faa5f5de440>('ps1/p1.ipynb')
E        +    where <function isfile at 0x7faa5f5de440> = <module 'posixpath' from '/home/me/.pyenv/versions/3.10.2/lib/python3.10/posixpath.py'>.isfile
E        +      where <module 'posixpath' from '/home/me/.pyenv/versions/3.10.2/lib/python3.10/posixpath.py'> = os.path
E        +    and   'ps1/p1.ipynb' = join('ps1', 'p1.ipynb')

I'm running these using Python 3.10.2, on an Ubuntu 22:04 system..... and these errors appear on the master branch as well as my own branch.

Anyone come across them before?

tuncbkose commented 1 year ago

I've seen them only when the folders/files expected by the tests are not there because I changed something and forgot to update the tests.

perllaghu commented 1 year ago

Hmmm..... I believe these are from areas I've not played with - but I'll double-check

thanks...

perllaghu commented 1 year ago

Hmmm..... I believe these are from areas I've not played with - but I'll double-check

thanks...

brichet commented 5 months ago

@perllaghu any update on this issue ?

perllaghu commented 5 months ago

No.... and packages have moved on.

I'm back in notebook-rebuild land again, and I'll check

perllaghu commented 3 months ago

Back onto this..... [from other work] - and it's definitely affecting me.

Sitting on the main branch...

❯ pytest -vvv nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_fetch
========================================================================= test session starts =========================================================================
platform linux -- Python 3.10.2, pytest-8.2.1, pluggy-1.5.0 -- /home/kiz/development/edina/nbgrader/.direnv/python-3.10.2/bin/python
cachedir: .pytest_cache
rootdir: /home/kiz/development/edina/nbgrader
configfile: pytest.ini
plugins: nbval-0.11.0, cov-5.0.0, tornasync-0.6.0.post2, xdist-3.6.1, anyio-4.3.0, rerunfailures-14.0, requests-mock-1.12.1
collected 1 item                                                                                                                                                      

nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_fetch FAILED                                                                     [100%]

============================================================================== FAILURES ===============================================================================
____________________________________________________________________ TestNbGraderFetch.test_fetch _____________________________________________________________________

self = <nbgrader.tests.apps.test_nbgrader_fetch_assignment.TestNbGraderFetch object at 0x7fd448aa6b60>, exchange = '/tmp/tmp-exchange-ntbz6f6q'
course_dir = '/tmp/tmp-coursedir-dn3q82kp'

    def test_fetch(self, exchange, course_dir):
        self._release("ps1", exchange, course_dir)
        self._fetch("ps1", exchange)
>       assert os.path.isfile(join("ps1", "p1.ipynb"))
E       AssertionError: assert False
E        +  where False = <function isfile at 0x7fd44d456440>('ps1/p1.ipynb')
E        +    where <function isfile at 0x7fd44d456440> = <module 'posixpath' from '/home/kiz/.pyenv/versions/3.10.2/lib/python3.10/posixpath.py'>.isfile
E        +      where <module 'posixpath' from '/home/kiz/.pyenv/versions/3.10.2/lib/python3.10/posixpath.py'> = os.path
E        +    and   'ps1/p1.ipynb' = join('ps1', 'p1.ipynb')

/home/kiz/development/edina/nbgrader/nbgrader/tests/apps/test_nbgrader_fetch_assignment.py:64: AssertionError
------------------------------------------------------------------------ Captured stderr call -------------------------------------------------------------------------
[ReleaseAssignmentApp | WARNING] Permissions for exchange directory (/tmp/tmp-exchange-ntbz6f6q) are invalid, changing them from 0o700 to 0o777
[ReleaseAssignmentApp | INFO] Source: /tmp/tmp-coursedir-dn3q82kp/release/./ps1
[ReleaseAssignmentApp | INFO] Destination: /tmp/tmp-exchange-ntbz6f6q/abc101/outbound/ps1
[ReleaseAssignmentApp | INFO] Released as: abc101 ps1
[FetchAssignmentApp | INFO] Source: /tmp/tmp-exchange-ntbz6f6q/abc101/outbound/ps1
[FetchAssignmentApp | INFO] Destination: /tmp/tmp-cwd-m2gmyf01/abc101/ps1
[FetchAssignmentApp | INFO] Fetched as: abc101 ps1
========================================================================== warnings summary ===========================================================================
nbgrader/api.py:994
  /home/kiz/development/edina/nbgrader/nbgrader/api.py:994: SADeprecationWarning: User-placed attribute Grade.max_score on Mapper[Grade(grade)] is replacing an existing class-bound attribute of the same name.  Behavior is not fully defined in this case.  This use is deprecated and will raise an error in a future release
    Grade.max_score = column_property(func.coalesce(Grade.max_score_gradecell, Grade.max_score_taskcell, 0.0), deferred=True)

nbgrader/api.py:1013
  /home/kiz/development/edina/nbgrader/nbgrader/api.py:1013: SADeprecationWarning: User-placed attribute Grade.cell_type on Mapper[Grade(grade)] is replacing an existing class-bound attribute of the same name.  Behavior is not fully defined in this case.  This use is deprecated and will raise an error in a future release
    Grade.cell_type = column_property(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================= short test summary info =======================================================================
FAILED nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_fetch - AssertionError: assert False
 +  where False = <function isfile at 0x7fd44d456440>('ps1/p1.ipynb')
 +    where <function isfile at 0x7fd44d456440> = <module 'posixpath' from '/home/kiz/.pyenv/versions/3.10.2/lib/python3.10/posixpath.py'>.isfile
 +      where <module 'posixpath' from '/home/kiz/.pyenv/versions/3.10.2/lib/python3.10/posixpath.py'> = os.path
 +    and   'ps1/p1.ipynb' = join('ps1', 'p1.ipynb')
==================================================================== 1 failed, 2 warnings in 0.16s ====================================================================

Can someone else verify - I'm running ubuntu 22.04, python as given in the output

brichet commented 3 months ago

I can't reproduce it with the same settings (ubuntu 22.04 and python 3.10.2)

perllaghu commented 3 months ago

Darn.... OK, I'll try a complete fresh clone....

perllaghu commented 3 months ago

Still happening with a fresh clone of the repo.

I'll see if I can find a different machine to test on.....

self = <nbgrader.tests.apps.test_nbgrader_fetch_assignment.TestNbGraderFetch object at 0x7fe98110a210>, exchange = '/tmp/tmp-exchange-sjg55toa', course_dir = '/tmp/tmp-coursedir-asnwg998'

    def test_fetch(self, exchange, course_dir):
        self._release("ps1", exchange, course_dir)
        self._fetch("ps1", exchange)
>       assert os.path.isfile(join("ps1", "p1.ipynb"))
E       AssertionError: assert False
E        +  where False = <function isfile at 0x7fe98b367ba0>('ps1/p1.ipynb')
E        +    where <function isfile at 0x7fe98b367ba0> = <module 'posixpath' (frozen)>.isfile
E        +      where <module 'posixpath' (frozen)> = os.path
E        +    and   'ps1/p1.ipynb' = join('ps1', 'p1.ipynb')

/home/kiz/development/perllaghu/nbgrader/nbgrader/tests/apps/test_nbgrader_fetch_assignment.py:64: AssertionError

(and for clarity:

$development/perllaghu/nbgrader > which python
/home/kiz/development/perllaghu/nbgrader/.direnv/python-3.11.0/bin/python

)

brichet commented 3 months ago

Can you check if the test should pass ? I mean if you have all the files and directories created ? Commenting the code that removes the working directory could help: https://github.com/jupyter/nbgrader/blob/5b3fe5ebfbffab6e14ffc92bf1eb30981c411af5/nbgrader/tests/apps/conftest.py#L32

After running pytest -vvv nbgrader/tests/apps/test_nbgrader_fetch_assignment.py::TestNbGraderFetch::test_fetch, there should be a directory /tmp/tmp-cwd-XXXXXX. You can check there if the assignment ps1 has been fetched. If not you could do the same for the exchange and course_dir fixtures, to check manually if one command fails.