{"id":21928123,"url":"https://github.com/depp/idiotest","last_synced_at":"2026-06-17T21:31:07.400Z","repository":{"id":2171016,"uuid":"3117560","full_name":"depp/idiotest","owner":"depp","description":"Simple testing framework","archived":false,"fork":false,"pushed_at":"2012-02-01T20:01:50.000Z","size":168,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T12:18:46.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/depp.png","metadata":{"files":{"readme":"README.txt","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-06T11:37:32.000Z","updated_at":"2016-11-28T02:01:31.000Z","dependencies_parsed_at":"2022-07-21T22:33:45.116Z","dependency_job_id":null,"html_url":"https://github.com/depp/idiotest","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/depp/idiotest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fidiotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fidiotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fidiotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fidiotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/depp","download_url":"https://codeload.github.com/depp/idiotest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fidiotest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34466928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-28T22:21:18.550Z","updated_at":"2026-06-17T21:31:07.371Z","avatar_url":"https://github.com/depp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"IdioTest: A simple testing framework\n====================================\n\nIdioTest is a simple testing framework.  Tests in IdioTest run\nprograms, feed those programs input, and compare the output to the\nexpected output.  IdioTest does not know or care what language you\nwrite your programs in.  Tests in IdioTest are written in Python.\n\nIdioTest requires Python 2.5 or higher in the 2.x series.\n\nI originally made this into its own project because I had copies of it\nin three other projects.  Here are the goals of idiotest:\n\n  * IdioTest knows nothing about your development environment.  It\n    just runs programs and checks the output.\n\n  * IdioTest produces useful and informative messages when you need\n    them, and stays quiet when everything is okay.  If it expects\n    different output, IdioTest prints a diff.  If a program terminates\n    abnormally, IdioTest prints the return code or the name of the\n    signal which terminated the process.\n\n  * Writing tests is easy.\n\n  * You can hook instrumentation such as Valgrind into the programs\n    you are testing.\n\nHow to write tests\n------------------\n\nYou will need to write at least two files for your test suite: a\ndriver script and a test module.\n\nThe driver script is very simple, it imports IdioTest and calls a\nfunction, passing in the path to the test modules and the path to find\nexecutables.  Here is an example:\n\n    #!/usr/bin/env python\n    import idiotest\n    import idiotest.run, sys, os\n    idiotest.run.run(\n        os.path.join(os.path.join(sys.path[0], 'tests')),\n\t['/path/bin']\n    )\n\nIn this example, the test modules are located in the 'tests' directory\nrelative to the test driver script.  IdioTest will scan the test\ndirectory for all files ending with '.py' and try to run them as\ntests.  Modules are run in lexicographic order of pathname.\n\nThe test module can be very simple.  The following functions are\ndefined in all test modules:\n\ntest(...)\n    Register a test.  Can be used as an ordinary function or as a\n    decorator.  Tests must be callable.  As a decorator, it takes an\n    optional argument specifying the test name.  As a function, it\n    takes two parameters: a test name and the callable test object.\n    See the example test module below.  Tests are run in the order in\n    which they are registered.\n\nfail(reason=None)\n    Cause the current test to fail.\n\nskip(reason=None)\n    Cause the current test to be skipped.\n\nfail_module(reason=None)\n    Cause the entire module to fail and skip all tests in it.  May be\n    called at any time in a test module.  Note that if this is called\n    from the top level of a module, all tests will be skipped.\n\nskip_module(reason=None)\n    Casue all remaining tests in a module to be skipped, including the\n    current one, if any.  May be called at any time in a test module.\n    Note that if this is called from the top level of a module, all\n    tests will be skipped.\n\nproc.proc(self, args, executable=None, input=None,\n          cwd=None, geterror=False())\n    Create a process object for running a process.\n\n    args: Process arguments, a list.  E.g., ['cat', 'file.txt']\n    executable: Optional absolute path to executable\n    input: Program input, a string, file, or None\n    cwd: Program working directory\n    geterror: If True, stderr is captured\n\nproc.run(...)\n    Run a program.  Equivalent to calling 'proc.proc', then calling\n    'run' and 'check_exit' on the result.\n\nproc.get_output(...)\n    Get the output from running a program.  Equivalent to calling\n    'proc.run' and returning the output of the result.\n\nproc.check_output(..., output=None)\n    Verify that the program output matches the reference output.  Like\n    the program input, the output parameter can be a string, file, or\n    None.  Equivalent to calling 'proc.run' and running 'check_output'\n    on the result.\n\nExample test\n------------\n\nHere is an example test module.  This is also part of the IdioTest\nself-test, you can find it under 'selftest/demo.py'.\n\n    # This test always passes\n    @test\n    def test_1():\n        if True == False:\n            fail()\n\n    # This test is always skipped\n    @test(\"Test #2\")\n    def test_2():\n        skip()\n\n    # Any callable object can be a test\n    class MyTest(object):\n        def __init__(self, message):\n            self.message = message\n        def __call__(self):\n            fail(self.message)\n\n    test(\"Test #3\", MyTest(\"Test 3 always fails\"), fail=True)\n    test(\"Test #4\", MyTest(\"Test 4 always fails\"), fail=True)\n\n    @test\n    def test_get_output():\n        # Gets the output of 'echo'\n        abc = proc.get_output(['echo', 'abc'])\n        if abc != 'abc\\n':\n            fail()\n\n    @test\n    def test_check_output():\n        # Cat should be idempotent\n        proc.check_output(['cat', 'test1.txt'], output='@test1.txt')\n\nCommand line usage\n------------------\n\n[test.py] [OPTIONS] [TESTS]\n\nSpecifying tests:\n\nIf TESTS is present, then it specifies a list of tests or modules to\nrun.\n\nModule names are derived from their path relative to the test suite\nroot, and tests are given names based on their Python names or a name\nexplicitly specified with the 'test' function.  The components of\nthese names are joined with '.'.  For example, 'abc/test.py' is a\nmodule named 'abc.test', and if it has a test named test_1, that test\nhas the full name 'abc.test.test_1'.\n\nYou can use wildcards when specifying tests.  For example, the\nfollowing invocation will run test_1, test_get_output, and\ntest_check_output in the demo above.  Note that test_2 is actually\nnamed \"Test #2\", so it doesn't match.\n\n    [test.py] 'demo.test_*'\n\nYou can run everything in the demo module by listing it by itself, for\nexample:\n\n    [test.py] 'demo'\n\nOther options:\n\n-e, --err:  Send stderr to terminal.\n\n    Normally, get_output and check_output will store the error output\n    of the programs they run in memory.  The messages will only be\n    printed if the program fails.  If this option is specified, stderr\n    will always be sent directly to the terminal.\n\n-w CMD, --wrap CMD:  Wrap commands with CMD.\n\n    If this option is specified, all commands will be prefixed with\n    CMD.  For example, you can run valgrind with full leak checking on\n    your test suite with the following option:\n\n        [test.py] --wrap='valgrind --leak-check=full'\n\n--exec-path PATH:  Add PATH to the search path for executables.\n\n    Paths added on the command line will take precedence over paths\n    specified by the test script.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fidiotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepp%2Fidiotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fidiotest/lists"}