使用mongomock pymongo mongoengine的测试用例失败

时间:2019-09-10 09:48:48

标签: mongoengine pymongo-2.x mongomock

我正在尝试使用pymongo版本为2.X和mongoengine 0.10.6的mongomock运行测试用例

我试图将pymongo的版本从2.6.3更改为2.9.5,将mongoengine的版本从0.10.6更改为0.17.0。我已经尝试过从3.0.0到3.17.0的mongomock

    @classmethod
    def setUpClass(cls):
        super(MongoTestCase, cls).setUpClass()
        cls.conn = mongoengine.connect(
            settings.MONGODB_NAME,
            host=settings.MONGODB_DATABASE_HOST,
            alias="default",
            is_mock=True
        )

我希望测试用例通过当前得到的消息

======================================================================
ERROR: test_ibest_matches (packages.tests.test_utils.test_ibest_matches.TestIBestMatches)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/www/packages/tests/test_utils/test_ibest_matches.py", line 56, in test_ibest_matches
    **context))
  File "/www/packages/utils.py", line 228, in ibest_matches
    for vc in valid_contexts
  File "/www/packages/managers/base_package_manager.py", line 111, in best_matches
    for group, packages in groupby(pkgs, key=lambda k: k.group):
  File "/usr/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 97, in _iter_results
    self._populate_cache()
  File "/usr/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 116, in _populate_cache
    self._result_cache.append(self.next())
  File "/usr/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 1407, in next
    raw_doc = self._cursor.next()
  File "/usr/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 1482, in _cursor
    **self._cursor_args)
TypeError: find() got an unexpected keyword argument 'fields'

----------------------------------------------------------------------
Ran 44 tests in 3.273s

FAILED (errors=26)

0 个答案:

没有答案