{"id":19320445,"url":"https://github.com/aluriak/pytest-asptest","last_synced_at":"2026-06-19T00:31:24.424Z","repository":{"id":62583976,"uuid":"131353578","full_name":"Aluriak/pytest-asptest","owner":"Aluriak","description":"pytest plugin to test ASP code","archived":false,"fork":false,"pushed_at":"2018-04-28T16:18:56.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T05:35:53.854Z","etag":null,"topics":["answer-set-programming","pytest-plugin","python"],"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/Aluriak.png","metadata":{"files":{"readme":"README.mkd","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}},"created_at":"2018-04-27T23:28:49.000Z","updated_at":"2023-06-05T15:57:07.000Z","dependencies_parsed_at":"2022-11-03T20:19:37.377Z","dependency_job_id":null,"html_url":"https://github.com/Aluriak/pytest-asptest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fpytest-asptest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fpytest-asptest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fpytest-asptest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fpytest-asptest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aluriak","download_url":"https://codeload.github.com/Aluriak/pytest-asptest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240421666,"owners_count":19798616,"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":["answer-set-programming","pytest-plugin","python"],"created_at":"2024-11-10T01:28:54.817Z","updated_at":"2026-06-19T00:31:24.413Z","avatar_url":"https://github.com/Aluriak.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ASP test\n[pytest](https://docs.pytest.org) plugin to test ASP source code.\n\nThe principle is simple: you write inputs and outputs in a dedicated file, you run pytest,\npytest tells you which outputs are missing or unexpected.\n\n\n## Installation\n\n    pip install pytest-asptest\n\nObviously, in order to run ASP, a solver must be installed. The only one handled for now is [clingo](https://github.com/potassco/clingo/releases)\nfrom [potassco labs](https://potassco.org).\n\n\n## simple example\nLet's consider `dumbasp.lp`, an ASP code we want to be tested:\n\n```asp\np(1..3).\nq(X): p(X).\n```\n\nWe want to test the rule in second line. We therefore put it into a block (consecutive lines without blank lines)\nand give it a tag, `rule-q`:\n\n```asp\np(1..3).\n\n% TEST: rule-q\nq(X): p(X).\n```\n\nNow we fill `test-rule-q.lp` with multiple tests:\n\n```asp\n% INPUT\n% empty test: no input, no output\n% INSATISFIABLE\n\n% INPUT\np(1).\n% OUTPUT\nq(1).\n% OUTPUT\nq(2).  % This will lead to an error : there is no such answer set.\n```\n\nNow, we can run again asptest:\n\n    pytest dumbasp.lp\n\nIt will report the testing process, indicating which tests are passed, and which are not.\n\nMore examples are available in the [Makefile](Makefile), or in [examples/](examples/)\n\n\n\n\n## features\n- multiple files support ; tags are shared\n- handle generation of multiple answer sets, and strict keyword\n\n### strict output\nBy default, the atoms given in output parts must be a *subset* of the atoms present in the answer set.\nHowever, if you want to explicitely give *all* atoms that must appear in a given answer set,\nyou can write `% STRICT OUTPUT` instead of `% OUTPUT` in the test file.\n\n### file uid\nThe file uid is given by default to all blocks of a file, and is the basename of the file.\nYou can therefore implement `test-queens.lp` to test all the blocks found in file `queens.lp`,\nwithout having to manually tag all your blocks with it.\n\n### CLI options\nasptest add one option to pytest: `--uid-tests-dir`, allowing user to give to asptest the directory in which the `test-*.lp` files are.\nFor instance, `pytest . -vv --uid-tests-dir asp-test` would allow you to test all ASP files in the current directory, using the test files in `asp-test/` dir.\n\n## TODO\n- auto include input code into output with flag *with-output* on OUTPUT lines in test files\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faluriak%2Fpytest-asptest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faluriak%2Fpytest-asptest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faluriak%2Fpytest-asptest/lists"}