magnet-cl / django-project-template

A project template for Django in python 3
MIT License
14 stars 8 forks source link

Add test coverage reporting #119

Closed nstuardod closed 2 years ago

nstuardod commented 2 years ago

Se reemplaza el clásico manage.py test por pytest y se agrega test coverage en CircleCI.

wooo- commented 2 years ago

No están pasando los tests con pytest

> pytest
======================================== test session starts ========================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/wooo/.cache/pypoetry/virtualenvs/django-project-template-8zXZtD0D-py3.8/bin/python
cachedir: .pytest_cache
django: settings: project.settings (from ini)
rootdir: /mnt/magnet/repos/nstuardod-dpt, configfile: pytest.ini
plugins: cov-3.0.0, django-4.4.0
collected 7 items                                                                                   

base/tests.py::UrlsTest::test_responses FAILED                                                [ 14%]
base/tests.py::CheckErrorPages::test_404 PASSED                                               [ 28%]
base/tests.py::CronTests::test_cron_classes_to_run PASSED                                     [ 42%]
parameters/tests.py::ParameterTestCase::test_create_all_parammeters PASSED                    [ 57%]
regions/tests.py::SimpleTest::test_basic_addition PASSED                                      [ 71%]
users/tests.py::UserTests::test_force_logout PASSED                                           [ 85%]
users/tests.py::UserTests::test_lower_case_emails PASSED                                      [100%]

============================================= FAILURES ==============================================
______________________________________ UrlsTest.test_responses ______________________________________
Traceback (most recent call last):
  File "/mnt/magnet/repos/nstuardod-dpt/base/tests.py", line 238, in test_responses
    test_url_patterns(urlpatterns)
  File "/mnt/magnet/repos/nstuardod-dpt/base/tests.py", line 236, in test_url_patterns
    test_url_patterns(pattern.url_patterns, pattern.namespace)
  File "/mnt/magnet/repos/nstuardod-dpt/base/tests.py", line 231, in test_url_patterns
    self.assertIn(
  File "/usr/lib/python3.8/unittest/case.py", line 1179, in assertIn
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/lib/python3.8/unittest/case.py", line 753, in fail
    raise self.failureException(msg)
AssertionError: 404 not found in (200, 302, 403, 405) : url "/__debug__/render_panel/" (render_panel)returned 404
--------------------------------------- Captured stdout setup ---------------------------------------
Installed 362 object(s) from 1 fixture(s)

--------------------------------------- Captured stderr setup ---------------------------------------
Creating test database for alias 'default'...
========================================= warnings summary ==========================================
base/tests.py::UrlsTest::test_responses
  /home/wooo/.cache/pypoetry/virtualenvs/django-project-template-8zXZtD0D-py3.8/lib/python3.8/site-packages/pypugjs/runtime.py:12: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    from collections import Mapping as MappingType

-- Docs: https://docs.pytest.org/en/stable/warnings.html
------------ generated xml file: /mnt/magnet/repos/nstuardod-dpt/test-results/pytest.xml ------------

====================================== short test summary info ======================================
FAILED base/tests.py::UrlsTest::test_responses - AssertionError: 404 not found in (200, 302, 403, ...
============================== 1 failed, 6 passed, 1 warning in 3.91s ===============================

Pero los antiguos sí pasan... ¿Qué puede ser @nstuardod ?

> python manage.py test
Creating test database for alias 'default'...
Installed 362 object(s) from 1 fixture(s)
System check identified no issues (0 silenced).
.......
----------------------------------------------------------------------
Ran 7 tests in 6.566s

OK
Destroying test database for alias 'default'...