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

In test_cbor.py TestRoot class does not have an attribute named _ld. #22

Open
mercurytoxic opened this issue Aug 19, 2023 · 1 comment

Comments

@mercurytoxic
Copy link

After successful build while running tests I get:

platform linux -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0
Using --randomly-seed=3873878859
rootdir: /home/pizzaman/Downloads/work-folder/PKGBUILDs/python-cbor/src/cbor_py-b3af679e7cf3e12d50acb83c3c591fc5db9a658d
plugins: anyio-3.7.1, xdist-3.3.1, randomly-3.13.0, cov-4.1.0, forked-1.6.0
collected 63 items                                                                                                                                                                                                                                                                                                          

cbor/tests/test_cbor.py ...............F.....................................                                                                                                                                                                                                                                         [ 84%]
cbor/tests/test_objects.py .....                                                                                                                                                                                                                                                                                      [ 92%]
cbor/tests/test_vectors.py .                                                                                                                                                                                                                                                                                          [ 93%]
cbor/tests/test_usage.py ....                                                                                                                                                                                                                                                                                         [100%]

========================================================================================================================================================= FAILURES ==========================================================================================================================================================
_____________________________________________________________________________________________________________________________________________________ TestRoot.testable _____________________________________________________________________________________________________________________________________________________

cls = <class 'cbor.tests.test_cbor.TestRoot'>

    @classmethod
    def testable(cls):
>       ok = (cls._ld[0] is not None) and (cls._ld[1] is not None) and (cls._ld[3] is not None) and (cls._ld[4] is not None)
E       AttributeError: type object 'TestRoot' has no attribute '_ld'

cbor/tests/test_cbor.py:63: AttributeError
===================================================================================================================================================== warnings summary ======================================================================================================================================================
cbor/tests/test_cbor.py::TestCBORPyC::testable
  /usr/lib/python3.11/unittest/case.py:678: DeprecationWarning: It is deprecated to return a value that is not None from a test case (<bound method TestRoot.testable of <class 'cbor.tests.test_cbor.TestCBORPyC'>>)
    return self.run(*args, **kwds)

cbor/tests/test_cbor.py::TestCPy::testable
  /usr/lib/python3.11/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cbor/tests/test_cbor.py::TestCPy::testable returned False, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(

cbor/tests/test_cbor.py::TestPyC::testable
  /usr/lib/python3.11/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cbor/tests/test_cbor.py::TestPyC::testable returned False, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(

cbor/tests/test_cbor.py::TestCC::testable
  /usr/lib/python3.11/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cbor/tests/test_cbor.py::TestCC::testable returned False, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(

cbor/tests/test_cbor.py::TestPyPy::testable
  /usr/lib/python3.11/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cbor/tests/test_cbor.py::TestPyPy::testable returned True, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(

cbor/tests/test_cbor.py::TestCBORPyPy::testable
  /usr/lib/python3.11/unittest/case.py:678: DeprecationWarning: It is deprecated to return a value that is not None from a test case (<bound method TestRoot.testable of <class 'cbor.tests.test_cbor.TestCBORPyPy'>>)
    return self.run(*args, **kwds)

cbor/tests/test_cbor.py::TestCBORCPy::testable
  /usr/lib/python3.11/unittest/case.py:678: DeprecationWarning: It is deprecated to return a value that is not None from a test case (<bound method TestRoot.testable of <class 'cbor.tests.test_cbor.TestCBORCPy'>>)
    return self.run(*args, **kwds)

cbor/tests/test_cbor.py::TestCBORCC::testable
  /usr/lib/python3.11/unittest/case.py:678: DeprecationWarning: It is deprecated to return a value that is not None from a test case (<bound method TestRoot.testable of <class 'cbor.tests.test_cbor.TestCBORCC'>>)
    return self.run(*args, **kwds)

cbor/tests/test_objects.py::TestPyPy::testable
  /usr/lib/python3.11/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cbor/tests/test_objects.py::TestPyPy::testable returned True, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================================================================================== short test summary info ==================================================================================================================================================
FAILED cbor/tests/test_cbor.py::TestRoot::testable - AttributeError: type object 'TestRoot' has no attribute '_ld'
========================================================================================================================================= 1 failed, 62 passed, 9 warnings in 0.17s ==========================================================================================================================================
==> ERROR: A failure occurred in check().
    Aborting...

@mercurytoxic
Copy link
Author

One way to fix this error would be to add an _ld attribute to the TestRoot class.

class TestRoot:
    _ld = [None, None, None, None, None]

The following patch fixes the problem.

--- a/cbor/tests/test_cbor.py	2023-08-18 10:06:40.923167800 +1000
+++ b/cbor/tests/test_cbor.py	2023-08-18 10:10:04.420155700 +1000
@@ -43,6 +43,7 @@

 class TestRoot(object):
+    _ld = [None, None, None, None, None]
     @classmethod
     def loads(cls, *args):
         return cls._ld[0](*args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant