Source

pmxbot / tests / conftest.py

The default branch has multiple heads

Diff from to

tests/conftest.py

 import functools
 
 import pytest
+from jaraco.test import services
 
 import pmxbot.util
 
 def pytest_runtest_setup(item):
 	if 'slow' in item.keywords and not item.config.getvalue("runslow"):
 		pytest.skip("need --runslow option to run")
+
+def mongodb_instance():
+	try:
+		import pymongo
+		instance = services.MongoDBInstance()
+		instance.log_root = ''
+		instance.start()
+		pymongo.Connection(instance.get_connect_hosts())
+	except Exception:
+		return None
+	return instance
+
+def pytest_funcarg__mongodb_uri(request):
+	instance = request.cached_setup(setup=mongodb_instance, scope='session',
+		teardown=lambda instance: instance.stop() if instance else None)
+	if not instance:
+		pytest.skip("MongoDB not available")
+	return 'mongodb://' + ','.join(instance.get_connect_hosts())