SunPowered SunPowered - 1 year ago 134
Python Question

Neo4j ImpermanentDatabase in python unittests

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

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

on a virtual environment.

There are mentionings of a java class
, 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
... or is that how it should be done?

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

>>> import neo4j
>>> print neo4j.__version__

Answer Source

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download