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

0.50: pytest based test suite is failing #36

Open
kloczek opened this issue Mar 25, 2021 · 7 comments
Open

0.50: pytest based test suite is failing #36

kloczek opened this issue Mar 25, 2021 · 7 comments

Comments

@kloczek
Copy link

kloczek commented Mar 25, 2021

+ /usr/bin/python3 -Bm pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/tkloczko/rpmbuild/BUILD/python-meh-0.50
plugins: flaky-3.6.1, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, asyncio-0.14.0, expect-1.1.0, cov-2.11.1, mock-3.5.1, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, hypothesis-6.8.1, pyfakefs-4.4.0, freezegun-0.4.2
collected 1 item

tests/safe_string_test.py F                                                                                                                                          [100%]

================================================================================= FAILURES =================================================================================
_________________________________________________________________________ SafeStr_TestCase.runTest _________________________________________________________________________

self = <tests.safe_string_test.SafeStr_TestCase testMethod=runTest>

    def runTest(self):
        self.safestr += self.asciistr
        self.safestr += self.enc_unistr
        self.safestr += self.unistr
        self.safestr += self.bindata
        self.safestr += self.test_object
        self.safestr += self.test_object2

        self.assertIn(self.asciistr, self.safestr)

        if PY == 2:
            self.assertIn("OMITTED OBJECT WITHOUT __str__ METHOD", self.safestr)
            # should be included twice -- appended enc_unistr and unistr
            self.assertIn(str(self.enc_unistr), self.safestr)
        else:
>           self.assertIn("<safe_string_test.TestClass2 object at ", self.safestr)
E           AssertionError: '<safe_string_test.TestClass2 object at ' not found in "aaaab'\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1'áááááb'\\xff\\xff\\xfe'string representation of TestClass instance<tests.safe_string_test.TestClass2 object at 0x7fa1a6b6d7f0>"

tests/safe_string_test.py:38: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED tests/safe_string_test.py::SafeStr_TestCase::runTest - AssertionError: '<safe_string_test.TestClass2 object at ' not found in "aaaab'\\xc3\\xa1\\xc3\\xa1\\xc3\\xa...
============================================================================ 1 failed in 0.24s =============================================================================
@jkonecny12
Copy link
Member

We are not using pytest in this project. We are using python3 unittest module instead.

https://github.com/rhinstaller/python-meh/blob/master/tests/baseclass.py#L6

@kloczek
Copy link
Author

kloczek commented Mar 25, 2021

And you have no intention to put test units under pytest?

@jkonecny12
Copy link
Member

No, we don't. We don't want to introduce another dependency because of tests. I know pytest has nice benefits but I don't think it is bigger gain than using internal python library which is everywhere out of the box.

@kloczek
Copy link
Author

kloczek commented Mar 29, 2021

BTW is that error about assertion is it not sometninbg which could be fixed in the python-meh code?

@kloczek
Copy link
Author

kloczek commented Jan 22, 2023

Have side question: is that module has pypi entry? 🤔
(I would add in my packages metadata pypi page to monitor module version changes)

@kloczek
Copy link
Author

kloczek commented Jan 30, 2023

Just tested 0.51 and looks like pytest is now failing on missing report module.

collected 1 item / 1 error

==================================== ERRORS ====================================
____________________ ERROR collecting examples/meh_test.py _____________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/python-meh-python-meh-0.51/examples/meh_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
examples/meh_test.py:6: in <module>
    import meh.handler
../../BUILDROOT/python-meh-0.51-2.fc35.x86_64/usr/lib/python3.8/site-packages/meh/handler.py:23: in <module>
    import report
E   ModuleNotFoundError: No module named 'report'
=========================== short test summary info ============================
ERROR examples/meh_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.10s ===============================
Looks like that module is not maintained since 2017 https://pypi.org/project/report/ and git repo with code of that module has been deleted https://github.com/hoffmann/report 🤔 Or it is is result of missig `testpaths` in pytest setup pointing only to tests/ 🤔 ❓

@kloczek
Copy link
Author

kloczek commented Jan 30, 2023

With testpaths pointing only to tests/

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-meh-0.51-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-meh-0.51-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' tests
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-meh-python-meh-0.51
collected 1 item

tests/safe_string_test.py F                                              [100%]

=================================== FAILURES ===================================
___________________________ SafeStr_TestCase.runTest ___________________________

self = <tests.safe_string_test.SafeStr_TestCase testMethod=runTest>

    def runTest(self):
        self.safestr += self.asciistr
        self.safestr += self.enc_unistr
        self.safestr += self.unistr
        self.safestr += self.bindata
        self.safestr += self.test_object
        self.safestr += self.test_object2

        self.assertIn(self.asciistr, self.safestr)

        if PY == 2:
            self.assertIn("OMITTED OBJECT WITHOUT __str__ METHOD", self.safestr)
            # should be included twice -- appended enc_unistr and unistr
            self.assertIn(str(self.enc_unistr), self.safestr)
        else:
>           self.assertIn("<safe_string_test.TestClass2 object at ", self.safestr)
E           AssertionError: '<safe_string_test.TestClass2 object at ' not found in "aaaab'\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1'áááááb'\\xff\\xff\\xfe'string representation of TestClass instance<tests.safe_string_test.TestClass2 object at 0x7fe77ed52100>"

tests/safe_string_test.py:38: AssertionError
=========================== short test summary info ============================
FAILED tests/safe_string_test.py::SafeStr_TestCase::runTest - AssertionError:...
============================== 1 failed in 0.04s ===============================

Looks like pytest did not scanned other tests/ fieles baceuse by default it sv=cans only tests_*.py files. After specify tests/*.py pytest is able to find more units

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-meh-0.51-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-meh-0.51-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' tests/__init__.py tests/attrSkipList.py tests/baseclass.py tests/callbacks.py tests/handle_binary.py tests/handle_unicode.py tests/safe_string_test.py
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-meh-python-meh-0.51
collected 6 items

tests/attrSkipList.py ..                                                 [ 16%]
tests/callbacks.py .                                                     [ 33%]
tests/handle_binary.py .                                                 [ 50%]
tests/handle_unicode.py .                                                [ 66%]
tests/safe_string_test.py F

=================================== FAILURES ===================================
___________________________ SafeStr_TestCase.runTest ___________________________

self = <tests.safe_string_test.SafeStr_TestCase testMethod=runTest>

    def runTest(self):
        self.safestr += self.asciistr
        self.safestr += self.enc_unistr
        self.safestr += self.unistr
        self.safestr += self.bindata
        self.safestr += self.test_object
        self.safestr += self.test_object2

        self.assertIn(self.asciistr, self.safestr)

        if PY == 2:
            self.assertIn("OMITTED OBJECT WITHOUT __str__ METHOD", self.safestr)
            # should be included twice -- appended enc_unistr and unistr
            self.assertIn(str(self.enc_unistr), self.safestr)
        else:
>           self.assertIn("<safe_string_test.TestClass2 object at ", self.safestr)
E           AssertionError: '<safe_string_test.TestClass2 object at ' not found in "aaaab'\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1\\xc3\\xa1'áááááb'\\xff\\xff\\xfe'string representation of TestClass instance<tests.safe_string_test.TestClass2 object at 0x7fe31f7b0610>"

tests/safe_string_test.py:38: AssertionError
=========================== short test summary info ============================
FAILED tests/safe_string_test.py::SafeStr_TestCase::runTest - AssertionError:...
========================= 1 failed, 5 passed in 0.13s ==========================

soat least some files in tests/ needs to be renamed.

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

2 participants