A mongo mocking library with an ephemeral MongoDB running in memory.
Project description
pymongo_inmemory
A mongo mocking library with an ephemeral MongoDB running in memory.
Installation
pip install pymongo-inmemory
Usage
Insert a new section to your project's setup.cfg
for the operating system and mongo
version you want to spin up:
[pymongo_inmemory]
mongo_version = 4.0
operating_system = osx
then use the pymongo_inmemory
client instead of original one:
from pymongo_inmemory import MongoClient
client = MongoClient() # No need to provide host
db = client['testdb']
collection = db['test-collection']
# etc., etc.
client.close()
# Also usable with context manager
with MongoClient() as client:
# do stuff
Supported Python version
Since pytest
uses LocalPath
for path related
operations and on python versions older than 3.6 LocalPath
does not behave well with all path
related operations, we are setting Python 3.6.10 in our development.
Technically, this also limits the minimum Python version of tested features. However theer shouldn't be a hard limitation to use Python 3.5. We recommend upgrading older Python versions than that.
Development
Project is set up to develop with poetry. We rely on pyenv to maintain the minimum supported Python version.
After installing pyenv
, poetry
, and cloning the repo, create the shell and install
all package requirements:
pyenv install --skip-existing
poetry install --no-root
poetry shell
Run the tests:
pytest
If on NIX systems you can run further tests:
bash tests/integrity/test_integrity.sh
See how you can wet your feet, check out good first issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pymongo_inmemory-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7947d41edb86a5e41e8f4c7d7009ecb0436a5d639d59c690cba9b239ee58d173 |
|
MD5 | 62995143eeff215d4af69bdb1790c1d6 |
|
BLAKE2b-256 | a2ded3a1a46f334df780e02f6cd68891a825bbcc109e6ed7cea963e576c33089 |