python unittests中的Neo4j ImpermanentDatabase [英] Neo4j ImpermanentDatabase in python unittests

查看:87
本文介绍了python unittests中的Neo4j ImpermanentDatabase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为将与Neo4j Graph数据库连接的python项目创建单元测试.

I am trying to create unit tests for a python project that will interface with a Neo4j Graph database.

当前,我正在实现嵌入式图形数据库,但是如果我选择将其部署到Web应用程序,则可能会迁移到REST接口. 我已经安装了嵌入式neo4j v1.9rc2 项目,该文件通过pip安装在虚拟环境.

Currently, I am implementing the embedded graph database, but will likely migrate to a REST interface if I choose to deploy this to a web application. I have intstalled v1.9rc2 of the embedded neo4j project, installed via pip on a virtual environment.

这里提到了Java类org.neo4j.test.TestGraphDatabaseFactory

There are mentionings of a java class org.neo4j.test.TestGraphDatabaseFactory, here, which sounds perfect for what I have in mind. I am currently reading and writing to a database on file, which is ok, but I am having trouble properly cleaning up after ech test that doesn't include a call to shutil.rmtree ... or is that how it should be done?

另一种可能的方法是通过我的TestCasesetUptearDown方法为每个测试创建和关闭数据库.

Another possible method is to create and shutdown the database for each test, via the setUp and tearDown methods of my TestCase.

>>> import neo4j
>>> print neo4j.__version__
'1.9.c2'

推荐答案

最佳实践是使用setUp/tearDown为每个测试分别创建和关闭数据库-完全如上所述.

The best practice is to create and shutdown the database individually for each test using setUp/tearDown - exactly as you've mentioned.

旁注:1.9rc2已过时,请考虑升级到最新的稳定版,因为此后已修复了一些错误.

side note: 1.9rc2 is rather outdated, consider upgrading to latest stable since couple of bugs have been fixed since then.

这篇关于python unittests中的Neo4j ImpermanentDatabase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆