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

1.1.1: pytest is failing in tests/tests.py::TestFunctions::test_is_file unit #115

Open
kloczek opened this issue Jan 2, 2022 · 4 comments

Comments

@kloczek
Copy link

kloczek commented Jan 2, 2022

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-polib-1.1.1-4.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-polib-1.1.1-4.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra tests/tests.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/polib-1.1.1
collected 81 items

tests/tests.py ..........F......................................................................                                                                     [100%]

================================================================================= FAILURES =================================================================================
________________________________________________________________________ TestFunctions.test_is_file ________________________________________________________________________

self = <tests.TestFunctions testMethod=test_is_file>

    def test_is_file(self):
        self.assertTrue(polib._is_file(os.path.abspath(__file__)))
        self.assertFalse(polib._is_file('This is not a file !!!!'))
>       self.assertFalse(polib._is_file(True))
E       AssertionError: True is not false

tests/tests.py:346: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED tests/tests.py::TestFunctions::test_is_file - AssertionError: True is not false
======================================================================= 1 failed, 80 passed in 0.86s =======================================================================
@rodrigoA
Copy link

Hi @kloczek,

Looks like another UT framework has been used. Here the unittest is used instead of pytest.

When, at release 1.1.1, I run them like python tests/tests.py or even runtests.sh, I get no errors.

I don't know why only this one fails with pytest.

@kloczek
Copy link
Author

kloczek commented May 29, 2022

Correctly written uniitest test suite can be used OOTB with pytest.
What is the sense to perform assertion out of fixed value?

You will never get new warnings or errors because no one is working on unittest.
At ehe moment+8/9 of all modules is using pytest.
Please try to have look on https://docs.pytest.org/en/7.0.x/reference/plugin_list.html. Maybe this will give you a clue why so many python modules are using pytest as base test suite framework ..

@kthy
Copy link
Contributor

kthy commented May 30, 2022

Correctly riyyen uniitest test suite can be used OOTB with pytest.
What is the sense to perform assertion out of fixed value?

Ironically, I assume you mean "correctly written"?

The assertion does not have a fixed value. It asserts that calling polib._is_file(True) returns False. This test guards against polib._is_file('/some/path/to.po') returning True simply because the string is truthy.

I prefer Pytest myself, but if you come barging into a FOSS project, accuse the authors of using a library incorrectly and then try to bully them into fixing your problem simply by appeal to authority, don't be surprised if the response is less than enthusiastic.

@kloczek
Copy link
Author

kloczek commented May 30, 2022

I prefer Pytest myself, but if you come barging into a FOSS project, accuse the authors of using a library incorrectly and then try to bully them into fixing your problem simply by appeal to authority, don't be surprised if the response is less than enthusiastic.

My comment was about the CODE .. not you.

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

3 participants