Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests do not run on pytest 7.3.1: TestCase.run() got an unexpected keyword argument 'result' #555

Closed
zhiayang opened this issue May 17, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@zhiayang
Copy link

zhiayang commented May 17, 2023

Describe the bug
Tests cannot be run on pyobjc-framework-Cocoa.

Error reproduced below:

self = <PyObjCTest.test_appcategories.TestAppKitCategories testMethod=testAnimationContext>, args = (), kwds = {'result': <TestCaseFunction testAnimationContext>}

    def __call__(self, *args, **kwds):
>       return self.run(*args, **kwds)
E       TypeError: TestCase.run() got an unexpected keyword argument 'result'

/opt/pacman/usr/lib/python3.11/unittest/case.py:678: TypeError

Platform information

  • Python 3.11.3, PyTest 7.3.1, PyObjC 9.1.1
  • Custom python install (built from source)
  • macOS 13.3.1

To Reproduce

  1. Download a copies of pyobjc-core and pyobjc-framework-Cocoa
  2. Install pyobjc-core (default installation)
  3. Run tests on pyobjc-framework-Cocoa -- pytest -vv
  4. Tests do not run

Expected behavior
The test should at least start to run (regardless of whether it passes or fails)

** Additional Info **

Build script for pyobjc-core:

build() {
  cd pyobjc-core-${pkgver}
  python -m build -wn
}

check() {
  cd pyobjc-core-${pkgver}
  PYTHONPATH="${PWD}/build/lib.macosx-${MACOS_MAJOR}.${MACOS_MINOR}-${CARCH}-cpython-311/:${PYTHONPATH}" \
    python -m pytest -vv \
      --deselect 'Examples/NonFunctional/RemotePyInterpreter/test_client.py'
}

for framework-Cocoa:

build() {
  cd pyobjc-framework-cocoa-${pkgver}
  python -m build -wn
}

check() {
  cd pyobjc-framework-cocoa-${pkgver}
  PYTHONPATH="${PWD}/build/lib.macosx-${MACOS_MAJOR}.${MACOS_MINOR}-${CARCH}-cpython-311/:${PYTHONPATH}" \
    python -m pytest -vvv -x \
      --deselect 'PyObjCTest/test_cfrunloop.py::TestRunLoop::testFunctions10_7' \
      -W "ignore::pytest.PytestCollectionWarning"
}

The following patch appears to make things work:

--- a/Lib/PyObjCTools/TestSupport.py    2023-05-17 21:15:07.467208571 +0800
+++ b/Lib/PyObjCTools/TestSupport.py    2023-05-17 21:15:16.653886363 +0800
@@ -1337,7 +1337,7 @@
         else:
             self._skip_usepool = False

-    def run(self, *args):
+    def run(self, *args, **kwargs):
         """
         Run the test, same as unittest.TestCase.run, but every test is
         run with a fresh autorelease pool.
@@ -1348,7 +1348,7 @@
             p = 1

         try:
-            _unittest.TestCase.run(self, *args)
+            _unittest.TestCase.run(self, *args, **kwargs)
         finally:
             _gc.collect()
             del p
@zhiayang zhiayang added the bug Something isn't working label May 17, 2023
@ronaldoussoren
Copy link
Owner

I'll look into the proposed patch, but the correct way to run tests is using "python setup.py test".

@zhiayang
Copy link
Author

ah okay, that's my bad — the tests seem to work running them like that. Sort of new to the python stuff, just sorta assumed pytest would work everywhere.

@ronaldoussoren
Copy link
Owner

This issue will be fixed in PyObjC 10 (to be released this autumn around the official release of macOS 14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants