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

[test] switching from nosetests to pytest? #3206

Closed
karlcow opened this issue Feb 12, 2020 · 17 comments
Closed

[test] switching from nosetests to pytest? #3206

karlcow opened this issue Feb 12, 2020 · 17 comments

Comments

@karlcow
Copy link
Contributor

@karlcow karlcow commented Feb 12, 2020

In the process of checking the coverage #3205 for our python test using coverage, I stumbled on this in the documentation.

Nose has been unmaintained for a long time. You should seriously consider adopting a different test runner.

Let's see nose documentation and code.

Nose has been in maintenance mode for the past several years and will likely cease without a new person/team to take over maintainership. New projects should consider using Nose2, py.test, or just plain unittest/unittest2.

last commit in March 2016, 4 years ago. So probably it's time for us to move on. Not urgent, but we can at least test what it would mean to switch to pytest.

@miketaylr

This comment has been minimized.

Copy link
Member

@miketaylr miketaylr commented Feb 12, 2020

One approach is to just write new tests in pytest, then open bugs for contributors to port existing tests (or one of us, if we find a few spare hours).

@miketaylr

This comment has been minimized.

Copy link
Member

@miketaylr miketaylr commented Feb 12, 2020

http://doc.pytest.org/en/latest/nose.html is good to know about.

I tried running our nose tests w/ pytest but run into the following:

🐓 pytest tests/
=================================================================================== test session starts ====================================================================================
platform darwin -- Python 3.7.4, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/miket/dev/webcompat.com
plugins: mozlog-5.0
collected 0 items / 13 errors                                                                                                                                                              

========================================================================================== ERRORS ==========================================================================================
_______________________________________________________________________ ERROR collecting tests/unit/test_api_urls.py _______________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_api_urls.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_api_urls.py:17: in <module>
    import webcompat
E   ModuleNotFoundError: No module named 'webcompat'
________________________________________________________________________ ERROR collecting tests/unit/test_config.py ________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_config.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_config.py:13: in <module>
    from config import update_status_config
E   ModuleNotFoundError: No module named 'config'
_____________________________________________________________________ ERROR collecting tests/unit/test_console_logs.py _____________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_console_logs.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_console_logs.py:18: in <module>
    from webcompat import app  # noqa
E   ModuleNotFoundError: No module named 'webcompat'
_________________________________________________________________________ ERROR collecting tests/unit/test_form.py _________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_form.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_form.py:11: in <module>
    import webcompat
E   ModuleNotFoundError: No module named 'webcompat'
_______________________________________________________________________ ERROR collecting tests/unit/test_helpers.py ________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_helpers.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_helpers.py:18: in <module>
    import webcompat
E   ModuleNotFoundError: No module named 'webcompat'
_____________________________________________________________________ ERROR collecting tests/unit/test_http_caching.py _____________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_http_caching.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_http_caching.py:15: in <module>
    import webcompat  # noqa
E   ModuleNotFoundError: No module named 'webcompat'
________________________________________________________________________ ERROR collecting tests/unit/test_issues.py ________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_issues.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_issues.py:18: in <module>
    from webcompat.issues import report_issue
E   ModuleNotFoundError: No module named 'webcompat'
______________________________________________________________________ ERROR collecting tests/unit/test_rendering.py _______________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_rendering.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_rendering.py:15: in <module>
    import webcompat  # noqa
E   ModuleNotFoundError: No module named 'webcompat'
___________________________________________________________________ ERROR collecting tests/unit/test_tools_changelog.py ____________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_tools_changelog.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_tools_changelog.py:11: in <module>
    from tools import changelog
E   ModuleNotFoundError: No module named 'tools'
_______________________________________________________________________ ERROR collecting tests/unit/test_topsites.py _______________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_topsites.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_topsites.py:14: in <module>
    from tools import topsites
E   ModuleNotFoundError: No module named 'tools'
_______________________________________________________________________ ERROR collecting tests/unit/test_uploads.py ________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_uploads.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_uploads.py:23: in <module>
    from webcompat import app  # noqa
E   ModuleNotFoundError: No module named 'webcompat'
_________________________________________________________________________ ERROR collecting tests/unit/test_urls.py _________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_urls.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_urls.py:18: in <module>
    import webcompat  # noqa
E   ModuleNotFoundError: No module named 'webcompat'
_______________________________________________________________________ ERROR collecting tests/unit/test_webhook.py ________________________________________________________________________
ImportError while importing test module '/Users/miket/dev/webcompat.com/tests/unit/test_webhook.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/test_webhook.py:17: in <module>
    import webcompat
E   ModuleNotFoundError: No module named 'webcompat'
===================================================================================== warnings summary =====================================================================================
env/lib/python3.7/site-packages/jinja2/utils.py:485
  /Users/miket/dev/webcompat.com/env/lib/python3.7/site-packages/jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import MutableMapping

env/lib/python3.7/site-packages/jinja2/runtime.py:318
  /Users/miket/dev/webcompat.com/env/lib/python3.7/site-packages/jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Mapping

-- Docs: https://docs.pytest.org/en/latest/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 13 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================== 2 warnings, 13 errors in 0.39s ==============================================================================
(

Probably some trick to fix the imports.

Maybe if we can fix this, we just start running tests via pytest, and then slowly port existing stuff to use pytest idioms.

@miketaylr

This comment has been minimized.

Copy link
Member

@miketaylr miketaylr commented Feb 12, 2020

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 12, 2020

some explorations i did in the past too.
https://github.com/karlcow/tests_explore

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 12, 2020

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

Another input point
https://flask.palletsprojects.com/en/1.1.x/testing/

In this documentation we will use the pytest package as the base framework for our tests.

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

Switching from nose to py.test at Mozilla
https://agopian.info/presentations/2015_06_djangocon_europe/

karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

This is a better documentation
https://docs.pytest.org/en/latest/goodpractices.html

In webcompat.com/setup.py

from setuptools import setup, find_packages

setup(name="WEBCOMPAT", packages=find_packages())

and then

pip install -e .

we can run the tests with pytest -x tests

It will stop at the first failure because of -x. we get

================================================================= test session starts =================================================================
platform darwin -- Python 3.7.4, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/karl/code/webcompat.com
collected 152 items                                                                                                                                   

tests/unit/test_api_urls.py ...F

====================================================================== FAILURES =======================================================================
__________________________________________________________ TestAPIURLs.test_api_patch_issue ___________________________________________________________

thing = <flask.blueprints.Blueprint object at 0x112981290>, comp = 'endpoints', import_path = 'webcompat.api.endpoints'

    def _dot_lookup(thing, comp, import_path):
        try:
>           return getattr(thing, comp)
E           AttributeError: 'Blueprint' object has no attribute 'endpoints'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1101: AttributeError

During handling of the above exception, another exception occurred:

self = <unit.test_api_urls.TestAPIURLs testMethod=test_api_patch_issue>

    def test_api_patch_issue(self):
        """Patching the issue is working only with certain circumstances."""
        with webcompat.app.app_context():
            webcompat.app.config.update(STATUSES=STATUSES)
            # Incompatible state and status
            data = {'state': 'closed', 'milestone': 2}
            patch_data = json.dumps(data)
            rv = self.app.patch('/api/issues/1/edit', data=patch_data,
                                environ_base=headers)
            self.assertEqual(rv.status_code, 403)
            # Too many elements in the JSON
            data = {'state': 'open', 'milestone': 2, 'foobar': 'z'}
            patch_data = json.dumps(data)
            rv = self.app.patch('/api/issues/1/edit', data=patch_data,
                                environ_base=headers)
            self.assertEqual(rv.status_code, 403)
            # Valid request
>           with patch('webcompat.api.endpoints.proxy_request') as github_data:

tests/unit/test_api_urls.py:175: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1257: in __enter__
    self.target = self.getter()
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1427: in <lambda>
    getter = lambda: _importer(target)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1114: in _importer
    thing = _dot_lookup(thing, comp, import_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

thing = <flask.blueprints.Blueprint object at 0x112981290>, comp = 'endpoints', import_path = 'webcompat.api.endpoints'

    def _dot_lookup(thing, comp, import_path):
        try:
            return getattr(thing, comp)
        except AttributeError:
            __import__(import_path)
>           return getattr(thing, comp)
E           AttributeError: 'Blueprint' object has no attribute 'endpoints'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1104: AttributeError
================================================================== warnings summary ===================================================================
tests/unit/test_uploads.py:45
  /Users/karl/code/webcompat.com/tests/unit/test_uploads.py:45: PytestCollectionWarning: cannot collect test class 'TestingFileStorage' because it has a __init__ constructor (from: tests/unit/test_uploads.py)
    class TestingFileStorage(FileStorage):

-- Docs: https://docs.pytest.org/en/latest/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================= 1 failed, 3 passed, 1 warning in 0.92s ========================================================
@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

if I run it on a less complicated test file such as test_urls.py

pytest -x tests/unit/test_urls.py

we get

================================================================= test session starts =================================================================
platform darwin -- Python 3.7.4, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/karl/code/webcompat.com
collected 33 items                                                                                                                                    

tests/unit/test_urls.py .................................                                                                                       [100%]

================================================================== warnings summary ===================================================================
tests/unit/test_urls.py::TestURLs::test_extracted_ga_params_end_up_as_inline_js
  /Users/karl/code/webcompat.com/env/lib/python3.7/site-packages/jinja2/lexer.py:648: DeprecationWarning: invalid escape sequence '\d'
    .decode("unicode-escape")

-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================================================ 33 passed, 1 warning in 0.98s ============================================================

which is cool!

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

And the full test suite: pytest tests

================================================================= test session starts =================================================================
platform darwin -- Python 3.7.4, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/karl/code/webcompat.com
collected 152 items                                                                                                                                   

tests/unit/test_api_urls.py ...F.....                                                                                                           [  5%]
tests/unit/test_config.py ..                                                                                                                    [  7%]
tests/unit/test_console_logs.py .....                                                                                                           [ 10%]
tests/unit/test_form.py .................                                                                                                       [ 21%]
tests/unit/test_helpers.py ............................                                                                                         [ 40%]
tests/unit/test_http_caching.py ...                                                                                                             [ 42%]
tests/unit/test_issues.py ......                                                                                                                [ 46%]
tests/unit/test_rendering.py ......                                                                                                             [ 50%]
tests/unit/test_tools_changelog.py ..                                                                                                           [ 51%]
tests/unit/test_topsites.py ...                                                                                                                 [ 53%]
tests/unit/test_uploads.py ...                                                                                                                  [ 55%]
tests/unit/test_urls.py .................................                                                                                       [ 76%]
tests/unit/test_webhook.py ...................................                                                                                  [100%]

====================================================================== FAILURES =======================================================================
__________________________________________________________ TestAPIURLs.test_api_patch_issue ___________________________________________________________

thing = <flask.blueprints.Blueprint object at 0x10d5f8250>, comp = 'endpoints', import_path = 'webcompat.api.endpoints'

    def _dot_lookup(thing, comp, import_path):
        try:
>           return getattr(thing, comp)
E           AttributeError: 'Blueprint' object has no attribute 'endpoints'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1101: AttributeError

During handling of the above exception, another exception occurred:

self = <unit.test_api_urls.TestAPIURLs testMethod=test_api_patch_issue>

    def test_api_patch_issue(self):
        """Patching the issue is working only with certain circumstances."""
        with webcompat.app.app_context():
            webcompat.app.config.update(STATUSES=STATUSES)
            # Incompatible state and status
            data = {'state': 'closed', 'milestone': 2}
            patch_data = json.dumps(data)
            rv = self.app.patch('/api/issues/1/edit', data=patch_data,
                                environ_base=headers)
            self.assertEqual(rv.status_code, 403)
            # Too many elements in the JSON
            data = {'state': 'open', 'milestone': 2, 'foobar': 'z'}
            patch_data = json.dumps(data)
            rv = self.app.patch('/api/issues/1/edit', data=patch_data,
                                environ_base=headers)
            self.assertEqual(rv.status_code, 403)
            # Valid request
>           with patch('webcompat.api.endpoints.proxy_request') as github_data:

tests/unit/test_api_urls.py:175: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1257: in __enter__
    self.target = self.getter()
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1427: in <lambda>
    getter = lambda: _importer(target)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1114: in _importer
    thing = _dot_lookup(thing, comp, import_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

thing = <flask.blueprints.Blueprint object at 0x10d5f8250>, comp = 'endpoints', import_path = 'webcompat.api.endpoints'

    def _dot_lookup(thing, comp, import_path):
        try:
            return getattr(thing, comp)
        except AttributeError:
            __import__(import_path)
>           return getattr(thing, comp)
E           AttributeError: 'Blueprint' object has no attribute 'endpoints'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py:1104: AttributeError
================================================================== warnings summary ===================================================================
tests/unit/test_uploads.py:45
  /Users/karl/code/webcompat.com/tests/unit/test_uploads.py:45: PytestCollectionWarning: cannot collect test class 'TestingFileStorage' because it has a __init__ constructor (from: tests/unit/test_uploads.py)
    class TestingFileStorage(FileStorage):

tests/unit/test_issues.py::TestIssue::test_report_issue_returns_number
  /Users/karl/code/webcompat.com/tests/unit/test_issues.py:50: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(rv.get('number'), 2)

tests/unit/test_rendering.py::TestURIContent::test_form_rendering
  /Users/karl/code/webcompat.com/env/lib/python3.7/site-packages/jinja2/lexer.py:648: DeprecationWarning: invalid escape sequence '\d'
    .decode("unicode-escape")

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================================================== 1 failed, 151 passed, 3 warnings in 1.91s ======================================================

so basically 1 fail and 3 warnings to fix.
And we could switch to pytest.

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

for Deprecation warnings see
https://docs.pytest.org/en/latest/warnings.html#deprecationwarning-and-pendingdeprecationwarning

By default pytest will display DeprecationWarning and PendingDeprecationWarning warnings from user code and third-party libraries, as recommended by PEP-0565. This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed.

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

This

tests/unit/test_rendering.py::TestURIContent::test_form_rendering
  /Users/karl/code/webcompat.com/env/lib/python3.7/site-packages/jinja2/lexer.py:648: DeprecationWarning: invalid escape sequence '\d'
    .decode("unicode-escape")

is because of

pattern='^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$') }}

karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 13, 2020

And this is a pass!

================================================================= test session starts =================================================================
platform darwin -- Python 3.7.4, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/karl/code/webcompat.com
collected 154 items                                                                                                                                   

tests/unit/test_api_urls.py ...........                                                                                                         [  7%]
tests/unit/test_config.py ..                                                                                                                    [  8%]
tests/unit/test_console_logs.py .....                                                                                                           [ 11%]
tests/unit/test_form.py .................                                                                                                       [ 22%]
tests/unit/test_helpers.py ............................                                                                                         [ 40%]
tests/unit/test_http_caching.py ...                                                                                                             [ 42%]
tests/unit/test_issues.py ......                                                                                                                [ 46%]
tests/unit/test_rendering.py ......                                                                                                             [ 50%]
tests/unit/test_tools_changelog.py ..                                                                                                           [ 51%]
tests/unit/test_topsites.py ...                                                                                                                 [ 53%]
tests/unit/test_uploads.py ...                                                                                                                  [ 55%]
tests/unit/test_urls.py .................................                                                                                       [ 77%]
tests/unit/test_webhook.py ...................................                                                                                  [100%]

================================================================== warnings summary ===================================================================
tests/unit/test_uploads.py:45
  /Users/karl/code/webcompat.com/tests/unit/test_uploads.py:45: PytestCollectionWarning: cannot collect test class 'TestingFileStorage' because it has a __init__ constructor (from: tests/unit/test_uploads.py)
    class TestingFileStorage(FileStorage):

tests/unit/test_rendering.py::TestURIContent::test_form_rendering
  /Users/karl/code/webcompat.com/env/lib/python3.7/site-packages/jinja2/lexer.py:648: DeprecationWarning: invalid escape sequence '\d'
    .decode("unicode-escape")

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================================== 154 passed, 2 warnings in 2.28s ===========================================================
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 13, 2020
@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 19, 2020

Same tests, not changing anything else.

nosetests

(env) ~/code/webcompat.com % nosetests
..........................................................................................................................................................
----------------------------------------------------------------------
Ran 154 tests in 3.171s

OK

pytest

================================================================= test session starts =================================================================
platform darwin -- Python 3.7.4, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/karl/code/webcompat.com
collected 154 items                                                                                                                                   

tests/unit/test_api_urls.py ...........                                                                                                         [  7%]
tests/unit/test_config.py ..                                                                                                                    [  8%]
tests/unit/test_console_logs.py .....                                                                                                           [ 11%]
tests/unit/test_form.py .................                                                                                                       [ 22%]
tests/unit/test_helpers.py ............................                                                                                         [ 40%]
tests/unit/test_http_caching.py ...                                                                                                             [ 42%]
tests/unit/test_issues.py ......                                                                                                                [ 46%]
tests/unit/test_rendering.py ......                                                                                                             [ 50%]
tests/unit/test_tools_changelog.py ..                                                                                                           [ 51%]
tests/unit/test_topsites.py ...                                                                                                                 [ 53%]
tests/unit/test_uploads.py ...                                                                                                                  [ 55%]
tests/unit/test_urls.py .................................                                                                                       [ 77%]
tests/unit/test_webhook.py ...................................                                                                                  [100%]

================================================================== warnings summary ===================================================================
tests/unit/test_uploads.py:45
  /Users/karl/code/webcompat.com/tests/unit/test_uploads.py:45: PytestCollectionWarning: cannot collect test class 'TestingFileStorage' because it has a __init__ constructor (from: tests/unit/test_uploads.py)
    class TestingFileStorage(FileStorage):

tests/unit/test_rendering.py::TestURIContent::test_form_rendering
  /Users/karl/code/webcompat.com/env/lib/python3.7/site-packages/jinja2/lexer.py:648: DeprecationWarning: invalid escape sequence '\d'
    .decode("unicode-escape")

-- Docs: https://docs.pytest.org/en/latest/warnings.html
========================================================== 154 passed, 2 warnings in 23.36s ===========================================================
@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 19, 2020

This is locally. On CircleCI, we get a different result.
#3209

@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 19, 2020

This

tests/unit/test_rendering.py::TestURIContent::test_form_rendering
  /Users/karl/code/webcompat.com/env/lib/python3.7/site-packages/jinja2/lexer.py:648: DeprecationWarning: invalid escape sequence '\d'
    .decode("unicode-escape")

is because of

pattern='^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$') }}

so for this one, a solution was available in
pallets/jinja#1156

we will need to figure out if it's breaking other stuff to double escape with \\d

karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 19, 2020
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 19, 2020
The reason is that the TestingFileStorage class had the string 'test'
which makes it discoverable as a test by pytest.
renaming it solves the warning.
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 19, 2020
When trying to mock the api blueprint, we enter into a name conflict
this first change is here to prepare for the necessary changes
to test that we need to do.
karlcow added a commit to karlcow/webcompat.com that referenced this issue Feb 19, 2020
Now that we change the name of the blueprint api, we do not have
a conflict name anymore.
@miketaylr miketaylr closed this in a2f7696 Feb 19, 2020
@karlcow

This comment has been minimized.

Copy link
Contributor Author

@karlcow karlcow commented Feb 20, 2020

To reinstall a clean site-packages

pip freeze | grep -v 'git+git' | xargs pip uninstall -y

Then

pip install -r config/requirements-dev.txt 

we need to update the doc too. See #3214

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.