{ "info": { "author": "Robert H\u00f6lzl", "author_email": "robert.hoelzl@posteo.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows", "Programming Language :: C", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Testing" ], "description": "# Headlock - Python/C Bridge for Unittesting\n\n[![buildstate](https://api.travis-ci.com/mrh1997/headlock.svg?branch=master \"Build State\")](https://travis-ci.com/mrh1997/headlock)\n[![docstate](https://readthedocs.org/projects/headlock/badge/?version=latest \"Documentation Generation State\")](https://headlock.readthedocs.io/en/latest/)\n\n## About\n\nThis is an adapter for testing C code via tests written in python.\nWhen being combined i.e. with pytest it provides a very powerful and\nconvinient way of writing (unit-/integration-) tests for C code.\n\nIn contrary to other C/Python bridges (like ctypes, cffi, swing, ...)\nthe goals of this projects are:\n\n - Run (and Compile) a piece of C code (Module Under Test)\n out of the box with as less lines of Python code as possible.\n No need to create Makefile, no need to run extra build steps.\n - Provide a simple, intuitive API for accessing C objects\n - Allow to quickly:\n - mock the underlying C modules in Python\n - work with different binaries of a Module Under Test at\n the same time.\n - testing a Module Under Test with binaries compiled with\n different preprocessor defines\n - Run the C code in a separate Address Space to avoid that a crashing\n Module Under Test crashes also the testing python code\n (Not implemented yet!).\n - Especially make it work with embedded systems, so that\n - C code can be run on *real hardware* while python tests run on PC.\n (Mainly useful for integration tests)\n This is not implemented yet!\n - C code can be run on PC instead of embedded environment.\n (Mainly useful for unittests)\n\nExplicitly Non-Goals Are:\n\n - Supporting C++ is not planned\n - Performance has a very low priority. This does not mean that it is\n slow. But if speed conflicts with one of the goals of this project,\n there will be no compromises in favour of speed.\n - Being self-contained is not planned. A C-compiler is required\n to be installed. Furthermore currently LLVM has to be installed\n at it is used for parsing the file.\n - Python < 3.6 will never be supported\n\n\n## Sample\n\nThis piece of C-code contains a macros, a struct a function\nimplementation and a function that is relying on\n(which should be mocked):\n\n```c\n#include \"underlying_module.h\"\n\nstruct ops_t\n{\n int a, b;\n} ;\n\n#define MACRO_2 (MACRO_1 + 1)\n\nint func(struct ops_t * p)\n{\n return underlying_func(p->a + p->b + MACRO_1);\n}\n```\n\nYou can access it from python through *headlock* like:\n\n```python\nfrom headlock.testsetup import TestSetup, CModule\n\n@CModule('dummy.c', MACRO_1=1)\nclass TSSample(TestSetup):\n def underlying_func_mock(self, param):\n return param.val + 4000\n\nwith TSSample() as ts:\n ops = ts.struct.ops_t(a=ts.MACRO_2, b=20)\n assert ts.func(ops.ptr).val == 4021\n```\n\nThis demonstrates how:\n * You can handle different binaries of the same C-source per .py file\n (as each one is a TestSetup derived class instead of a module)\n * Every binary can be compiled with other parameters\n (PY_MACRO can be set differently per testsetup)\n * structures/unions/enums/typedefs can be accessed from Python without\n extra declarations (```struct ops_t``` in this case).\n * You can access C-functions from Python without extra declarations\n (```func``` in this case)\n * You can access C-macros from Python without extra declarations\n (```C_MACRO``` in this case)\n * You can call python-methods from C (=mocking C functions that are\n not part of the Module Under Test;\n ```underlying_func``` in this case). It is even possible to\n dynamicially replace mocks (i.e. by unittest.mock.Mock())\n\n## Status\n\nCurrently this is alpha.\n\nFor a list of planned but not yet implemented features please refer to\n[Development Status](https://headlock.readthedocs.io/en/latest/development-status.html)\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://headlock.readthedocs.io/en/latest/index.html", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "headlock", "package_url": "https://pypi.org/project/headlock/", "platform": "", "project_url": "https://pypi.org/project/headlock/", "project_urls": { "Homepage": "https://headlock.readthedocs.io/en/latest/index.html" }, "release_url": "https://pypi.org/project/headlock/0.4.1/", "requires_dist": null, "requires_python": "", "summary": "An adapter for making C code testable from Python", "version": "0.4.1" }, "last_serial": 5898549, "releases": { "0.3.0": [ { "comment_text": "", "digests": { "md5": "0c231ed97af4993dbd08cbd5a6e4c96f", "sha256": "f3027ae9e7b0d5174d54a3ade3d12b0d3706a518093402c2b99fac197193abe6" }, "downloads": -1, "filename": "headlock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "0c231ed97af4993dbd08cbd5a6e4c96f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45147, "upload_time": "2018-07-09T01:24:18", "url": "https://files.pythonhosted.org/packages/c2/b9/06a51ac85e2919226d5bd409151730821c69ade044c3e805f98075f35e7f/headlock-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "14695d933c9dbc584764625bbc0ac882", "sha256": "a9a6d33b8fab5325e1c29dfd57064291a167d60c66fa6e85bfa1d8518d33f451" }, "downloads": -1, "filename": "headlock-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "14695d933c9dbc584764625bbc0ac882", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 77090, "upload_time": "2019-09-28T00:08:22", "url": "https://files.pythonhosted.org/packages/7f/0e/a070eb6878d31228bcbeb2bb324efaac8c81a3d9a3c2da7d3f20ce82c58f/headlock-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b65954af244ef9b7f0afad083237258a", "sha256": "56959c8cf724f936bee0b434f0b45c8a9be21fb019fb0f7494e8782ebe545b80" }, "downloads": -1, "filename": "headlock-0.4.0.tar.gz", "has_sig": false, "md5_digest": "b65954af244ef9b7f0afad083237258a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45662, "upload_time": "2018-08-01T23:55:24", "url": "https://files.pythonhosted.org/packages/42/93/5ce9536ac5ac469ca1021c360a6846d4fea836ba44a4a6a6e9cc111fa8cf/headlock-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "0e2a15ea2db60e8e10661c68a1acabf3", "sha256": "44dd06d5e73e3120b502f48f5bf9c4254c03068bd66deec2271f9cf47e0e4e74" }, "downloads": -1, "filename": "headlock-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0e2a15ea2db60e8e10661c68a1acabf3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 77088, "upload_time": "2019-09-28T00:08:27", "url": "https://files.pythonhosted.org/packages/95/40/b819cdd95c56512575aedf70f165e75a8c707f36b22ffe06be492126063b/headlock-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d26e385781f472797ee28aa30450e82d", "sha256": "16106faa67ebd8b8c3d31c149e7b2d10833a46c24b679e62fc4f0496ad24e4b5" }, "downloads": -1, "filename": "headlock-0.4.1.tar.gz", "has_sig": false, "md5_digest": "d26e385781f472797ee28aa30450e82d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 63091, "upload_time": "2019-09-28T00:09:43", "url": "https://files.pythonhosted.org/packages/f0/e4/bcb14f9a1a3f300cc3f06add3af2cf89a16155590369f271332aa8d421f5/headlock-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0e2a15ea2db60e8e10661c68a1acabf3", "sha256": "44dd06d5e73e3120b502f48f5bf9c4254c03068bd66deec2271f9cf47e0e4e74" }, "downloads": -1, "filename": "headlock-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0e2a15ea2db60e8e10661c68a1acabf3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 77088, "upload_time": "2019-09-28T00:08:27", "url": "https://files.pythonhosted.org/packages/95/40/b819cdd95c56512575aedf70f165e75a8c707f36b22ffe06be492126063b/headlock-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d26e385781f472797ee28aa30450e82d", "sha256": "16106faa67ebd8b8c3d31c149e7b2d10833a46c24b679e62fc4f0496ad24e4b5" }, "downloads": -1, "filename": "headlock-0.4.1.tar.gz", "has_sig": false, "md5_digest": "d26e385781f472797ee28aa30450e82d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 63091, "upload_time": "2019-09-28T00:09:43", "url": "https://files.pythonhosted.org/packages/f0/e4/bcb14f9a1a3f300cc3f06add3af2cf89a16155590369f271332aa8d421f5/headlock-0.4.1.tar.gz" } ] }