{"id":16576517,"url":"https://github.com/wideopensource/ctdd","last_synced_at":"2026-04-16T16:03:38.982Z","repository":{"id":161160589,"uuid":"635908118","full_name":"wideopensource/ctdd","owner":"wideopensource","description":"C test-driven development framework implemented in Python. pip install ctdd.","archived":false,"fork":false,"pushed_at":"2023-08-25T13:22:15.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T07:13:16.362Z","etag":null,"topics":["c","tdd"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wideopensource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-03T18:02:35.000Z","updated_at":"2023-05-08T01:15:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d6912af-79f9-49d2-a68f-4c793a7612e8","html_url":"https://github.com/wideopensource/ctdd","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"ca133f332602dac0bea814151607621d872cb373"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fctdd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fctdd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fctdd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fctdd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wideopensource","download_url":"https://codeload.github.com/wideopensource/ctdd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242097388,"owners_count":20071251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","tdd"],"created_at":"2024-10-11T22:08:25.280Z","updated_at":"2026-04-16T16:03:38.874Z","avatar_url":"https://github.com/wideopensource.png","language":"Python","readme":"# ctdd\n\n## tl:dr\n\nC test-driven development framework implemented in Python.\n\n## Info\n\nThe testing framework is Python's native unittest, with a few extra asserts ans stuff provided by John. The tester looks for a .c and .h pair with the same name as the .py test file. It builds them into a Python extension using Crelm (which in turn uses cffi) and runs the Python tests as if it were testing Python code. C callbacks are mocked in Python (demo to follow..), meaning that there is exactly zero C code involved in the testing.\n\n## Example\n\nThere is a demo of a TDD'd `add3` function in \\_\\_main\\_\\_.py, \\_\\_main\\_\\_.c and \\_\\_main\\_\\_.h in the root of the repo, run with `python3 .`. The silly filenames are to suit the Python auto-run mechanism.\n\nThe files are reproduced here (possibly out of date) with original filenames:\n\n__add3.py__\n\n```\nfrom ctdd import Tester\n\nclass Add3Tests(Tester):\n\n    def test_sut_compiles(self):\n        with self.assertDoesNotRaise():\n            self.sut\n\n    def test_takes_three_f(self):\n        with self.assertDoesNotRaise():\n            self.sut.add3(0, 0, 0)\n\n    def test_return_zero_for_zeros(self):\n        expected = 0\n\n        actual = self.sut.add3(0, 0, 0)\n\n        self.assertEqual(expected, actual)\n\n    def test_returns_sum(self):\n        expected = 14\n\n        actual = self.sut.add3(1, 4, 9)\n\n        self.assertEqual(expected, actual)\n\nTester.go()\n```\n\n__add3.h__\n```\n#pragma once\n\nint add3(int a, int b, int c);\n```\n\n__add3.c__\n```\n#include \"__main__.h\"\n\nint add3(int a, int b, int c)\n{\n    return a + b + c;\n}\n```\n\nTo use this in real life install the package with `pip install ctdd` (in a virtualenv if you prefer), and run `python add3.py` after each add test or add code iteration.\n\nTest output is exactly what unittest said (with distutils deprecation warning removed):\n\n```\n...........\n----------------------------------------------------------------------\nRan 11 tests in 2.104s\n\nOK\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwideopensource%2Fctdd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwideopensource%2Fctdd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwideopensource%2Fctdd/lists"}