Skip to main content

A minimal mocking utility for C projects.

Project description

🎣 narmock

Build Status PyPI PyPI - Python Version Code style: black

A minimal mocking utility for C projects.

🚧 Work in progress 🚧

Narmock identifies the mocks being used in your tests and generates easy-to-use implementations with a slick API.

#include <time.h>

#include "__mocks__.h"
#include "narwhal.h"

TEST(example)
{
    MOCK(time)->mock_return(42);
    ASSERT_EQ(time(NULL), 42);
}

Most of the examples in this README are tests written with Narwhal but Narmock can be used with other test frameworks and anywhere in regular source code.

Installation

The package can be installed with pip.

$ pip install narmock

Getting started

The command-line utility provides three essential commands that should make it possible to integrate Narmock in any kind of build system.

$ narmock --help
usage: narmock [-h] (-g <file> | -d <file> | -f) [-p <string>] [<file>]

A minimal mocking utility for C projects.

positional arguments:
  <file>       expanded code or generated mocks

optional arguments:
  -h, --help   show this help message and exit
  -g <file>    generate mocks
  -d <file>    extract declarations
  -f           output linker flags
  -p <string>  getter prefix

TODO

Contributing

Contributions are welcome. Feel free to open issues and suggest improvements. This project uses poetry so you'll need to install it first if you want to be able to work with the project locally.

$ curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

You should now be able to install the required dependencies.

$ poetry install

The code follows the black code style.

$ poetry run black narmock

You can run the tests with poetry run make -C tests. The test suite is built with Narwhal.

$ poetry run make -C tests

License - MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

narmock-0.1.6.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

narmock-0.1.6-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file narmock-0.1.6.tar.gz.

File metadata

  • Download URL: narmock-0.1.6.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.1 Linux/4.15.0-1028-gcp

File hashes

Hashes for narmock-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c04d953d7fec2e15cb6c22b987d48cf1b423e13235ab97ceb14c65a244f0f695
MD5 8ec6fd6e08c88308be0ba080e2758e70
BLAKE2b-256 6ee88b80c92c804ec50b033f8c66bb4eb303721ef195ad1ec526408dcb8b7f51

See more details on using hashes here.

File details

Details for the file narmock-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: narmock-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.1 Linux/4.15.0-1028-gcp

File hashes

Hashes for narmock-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fa1f74068a68c4b9235ffb072e0914f1f1f93976ccf2f0ae395e793e0e164e51
MD5 520ac5b92f38ffb96b3a771b6d90bfd4
BLAKE2b-256 593bf78d866d985eb7ffade6e5d361d44f90a17d1409bf3b305131ead06b9b26

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page