繁体   English   中英

迁移期间硒 django 错误

[英]Selenium django error during migration

我正在尝试使用 selenium 来测试我的 django 应用程序

运行以下命令后:

python3 manage.py test function_test(folder)

出现以下错误:

*Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 122, in connect
    connection_created.send(sender=self.__class__, connection=self)
  File "/usr/local/lib/python3.4/dist-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/local/lib/python3.4/dist-packages/django_hstore/apps.py", line 48, in __call__
    return [x(connection) for x in handlers]
  File "/usr/local/lib/python3.4/dist-packages/django_hstore/apps.py", line 48, in <listcomp>
    return [x(connection) for x in handlers]
  File "/usr/local/lib/python3.4/dist-packages/django_hstore/apps.py", line 76, in register_hstore_handler
    register_hstore(connection.connection, globally=HSTORE_REGISTER_GLOBALLY)
  File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 775, in register_hstore
    "hstore type not found in the database. "
psycopg2.ProgrammingError: hstore type not found in the database. please install it from your 'contrib/hstore.sql' fil*e

我已经在我的主项目中安装了 hstore 并且我在 live_server_test_case 上运行测试,所以它应该不会产生问题。

有没有办法在运行 selenium 代码之前跳过迁移,因为我已经提到在 setup() 函数中创建 hstore 类型,但我无法访问代码。

运行测试时,Django 会创建一个测试数据库。 使用LiveServerTestCase意味着有一个可以被测试使用的 Django 服务器(例如 Selenium),这并不意味着它使用实时数据库。

听起来您需要创建一个迁移来安装 HStoreExtension。 Django 测试运行器将运行迁移,防止错误。 有关更多信息,请参阅文档此问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM