heynemann / motorengine

Motorengine is a port of MongoEngine for Tornado.
http://motorengine.readthedocs.org
204 stars 67 forks source link

@return_future is deprecated, while testing motorengine with tornado #133

Closed msudgh closed 5 years ago

msudgh commented 5 years ago

I've a database module alongside my tornado application which i've written some test case for database service with tornado testing module but i've got the following result while running the tests.

Is there any solution to fix this or unless skip the warnings?

Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/tornado/test/runtests.py", line 219, in <module>
    main()
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/tornado/test/runtests.py", line 204, in main
    tornado.testing.main(**kwargs)
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/tornado/testing.py", line 718, in main
    unittest.main(module=None, argv=argv, **kwargs)
  File "/usr/lib64/python3.7/unittest/main.py", line 100, in __init__
    self.parseArgs(argv)
  File "/usr/lib64/python3.7/unittest/main.py", line 147, in parseArgs
    self.createTests()
  File "/usr/lib64/python3.7/unittest/main.py", line 159, in createTests
    self.module)
  File "/usr/lib64/python3.7/unittest/loader.py", line 220, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib64/python3.7/unittest/loader.py", line 220, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib64/python3.7/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/home/covfefe/w/twyla/tests/db.py", line 3, in <module>
    from services.db import init
  File "/home/covfefe/w/twyla/services/db.py", line 3, in <module>
    from motorengine import connect
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/motorengine/__init__.py", line 10, in <module>
    from motorengine.document import Document  # NOQA
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/motorengine/document.py", line 6, in <module>
    from motorengine.metaclasses import DocumentMetaClass
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/motorengine/metaclasses.py", line 8, in <module>
    from motorengine.queryset import QuerySet
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/motorengine/queryset.py", line 14, in <module>
    from motorengine.aggregation.base import Aggregation
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/motorengine/aggregation/base.py", line 93, in <module>
    class Aggregation(object):
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/motorengine/aggregation/base.py", line 157, in Aggregation
    def fetch(self, callback=None, alias=None):
  File "/home/covfefe/.virtualenvs/twyla/lib/python3.7/site-packages/tornado/concurrent.py", line 521, in return_future
    DeprecationWarning)
DeprecationWarning: @return_future is deprecated, use coroutines instead
thekie commented 5 years ago

Hey @msudgh, looking at your stack trace it seems you are using python 3.7. motorengine is currently only tested with up to python 3.6.

But the deprecation warning is coming from the tornado web framework, so another guess is, that your version of tornado is not up-to-date or is as well not supporting python 3.7, yet.

So I would try to update tornado first, see if that resolves the issue, and of not downgrade python to 3.6.

Thank you!

msudgh commented 5 years ago

I've redesigned my async part of db service and currently tests works with async/await syntax.

Btw thanks for your response.

msudgh commented 5 years ago

I've redesigned my async part of db service and currently test works with async/await syntax.

Btw thanks for your response.