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.4.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

narmock-0.1.4-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: narmock-0.1.4.tar.gz
  • Upload date:
  • Size: 9.7 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.4.tar.gz
Algorithm Hash digest
SHA256 48bf71e3969fe8e00b0897623e5d34f93f803cc52acc49722b19f61dfe8a4547
MD5 a09f43328c0597f8ccfee7b07003e5aa
BLAKE2b-256 ea38d6235a5eea768f99e92f2fe4a6c6c8c470c8d3cf687e557f108ea40e23cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: narmock-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 57aa174ba800b6bbcc3c176fcc277466ee22d3cde1d886a6ce2695f4f8a26488
MD5 230fd51fe774ed222f140807be853021
BLAKE2b-256 ccff7f6ee84c41c604b47a4f546ddac93008bdf99dcd45df5f343eff7913cd8e

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