{"id":39042094,"url":"https://github.com/aak1247/pydatatest","last_synced_at":"2026-01-17T17:49:12.745Z","repository":{"id":62592857,"uuid":"212123756","full_name":"aak1247/pydatatest","owner":"aak1247","description":"Data driven python test framework. 数据驱动的Python测试框架","archived":false,"fork":false,"pushed_at":"2025-03-31T11:13:29.000Z","size":42,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-29T05:20:35.191Z","etag":null,"topics":["framework","python","testing","unittest"],"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/aak1247.png","metadata":{"files":{"readme":"README.en-US.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}},"created_at":"2019-10-01T14:54:42.000Z","updated_at":"2025-03-31T11:13:32.000Z","dependencies_parsed_at":"2023-02-17T22:16:13.349Z","dependency_job_id":null,"html_url":"https://github.com/aak1247/pydatatest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aak1247/pydatatest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aak1247%2Fpydatatest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aak1247%2Fpydatatest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aak1247%2Fpydatatest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aak1247%2Fpydatatest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aak1247","download_url":"https://codeload.github.com/aak1247/pydatatest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aak1247%2Fpydatatest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28513975,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["framework","python","testing","unittest"],"created_at":"2026-01-17T17:49:12.644Z","updated_at":"2026-01-17T17:49:12.722Z","avatar_url":"https://github.com/aak1247.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyDataTest\nData driven python test framework\n\n![PyPI](https://img.shields.io/pypi/v/pydatatest)\n![License](https://img.shields.io/github/license/aak1247/PyDataTest)\n\n| English | [简体中文](./README.md) |\n\n# Document\n## Introduction\n\nAim to provide a simple way to write testcase, especially when test same logic with different data input and output. So PyDataTest wrap unittest with a set of utilities to test with data.\n\n## Install\n\n```shell\npip install pydatatest # with pip\npoetry add pydatatest # or with poetry\npipenv add pydatatest # with pipenv\n```\n\n## Usage\n1. Get a runner instance\n   ```python\n    runner = pydatatest.runner()\n   ```\n2. Write a test case and inject data including input and output\n    ```python\n    data = [[\"abc\",\"123\"], ['aaa',\"000000\"]]\n\n    @inject_def(['passport', 'password'], session=True)\n    @test_with(runner) # Register this testcase, also can use runner name, eg: @test_with(\"runner1\")\n    class TestUserLogin(PyDataTestCase):\n        def setUp(self):\n        print(\"login test start\\n\")\n\n        @inject([\"abc\", \"123456\"])\n        def test_01(self):\n            self.assertEqual(self.passport, 'hitest')\n\n        @inject(data, True)\n        def test_02(self):\n            self.assertEqual(self.password, '111111')\n\n        def tearDown(self):\n            print(\"login test end\\n\")\n    ```\n3. Run with PyDataTest\n    ```python\n    runner.run()\n    ```\n\n\n\n## API\n\n`runner` \n\u003e A framework instance that will run all testcases\n\u003e \n\u003e Example:\n\u003e ```python\n\u003e r = pydatatest.runner(\"my runner\")\n\u003e r.add_test(testcase) # add a test case manually\n\u003e r.run() # start test\n\u003e ```\n\n`PyDataTestCase`\n\u003e Data test Instance\n\u003e \n\u003e Attributes:\n\u003e   - **session**: request session, can be used in many test method to share some state\n\u003e   - **injected variables**: You can access it in your test method as self.variable_name(the name is as defined in your @inject_def)\n\u003e\n\u003e Methods:\n\u003e   - **before_all**: run before all cases\n\u003e   - **after_all**: run after all cases\n\u003e   - **before_each**: run before all run of every test method\n\u003e   - **after_each**: run before all run of every test method\n\u003e   - **before_each_data**: run before every run of every test method\n\u003e   - **after_each_data**: run after every run of every test method\n\u003e   - **test****: test case method, each method will be run several times accoding to the injected data\n\u003e \n\u003e   You can also use the unittest api here, such as self.assertEqual, for more information, see [Assert methods](https://docs.python.org/3/library/unittest.html#assert-methods) and [unittest](https://docs.python.org/3/contents.html)\n\u003e\n\u003e Example:\n\u003e ```python\n\u003e @inject_def(['passport', 'password'], session=True)\n\u003e @test_with(myrunner)\n\u003e class TestUserLogin(PyDataTestCase):\n\u003e   @classmethod\n\u003e   def before_all(cls):\n\u003e       print(\"before all test\")\n\u003e \n\u003e   @classmethod\n\u003e   def after_all(cls):\n\u003e       print(\"after all test\")\n\u003e       \n\u003e   def before_each(self):\n\u003e       print(\"before_each test\")\n\u003e   \n\u003e   def after_each(self):\n\u003e       print(\"after_each test\")\n\u003e \n\u003e   def before_each_data(self):\n\u003e       print(\"before_each_data test\")\n\u003e   \n\u003e   def after_each_data(self):\n\u003e       print(\"after_each_data test\")\n\u003e \n\u003e   @inject(data[0])\n\u003e   def test_01(self):\n\u003e       self.assertEqual(self.passport, 'username')\n\u003e \n\u003e \n\u003e   @inject(data, multi=True)\n\u003e   def test_02(self): # this test will be run many times\n\u003e       print(self.passport)\n\u003e       print(self.password)\n\u003e       self.assertEqual(self.password, 'password')\n\u003e \n\u003e   @inject([\"username\", \"password1\"])\n\u003e   def test_03(self):\n\u003e       self.assertEqual(self.password, 'password')\n\u003e ```\n\n### @test_with\n\u003e Register a testcase\n\u003e \n\u003e Params:\n\u003e - ``runner``: string or runner instance, you can use runner name to avoid loop dependency\n\n### @inject_def and @inject\n\u003e Example：\n\u003e \n\u003e ```python\n\u003e @inject_def(['passport', 'password'], session=True)\n\u003e class TestCaseClass(PyDataTestCase):\n\u003e @inject([\"passport1\", \"password1\"])\n\u003e def test_01(self):\n\u003e   print(self.passport) # defined variable can be access here\n#### @inject_def\n\u003e Define inject data varibales\n\u003e Params:\n\u003e - ``variables``: injected data will be parsed according to the sequence of variables\n\u003e - ``session``: if True means that this case will use request session\n\n#### @inject\n\u003e Inject data to a test method\n\u003e \n\u003e Params:\n\u003e   - ``data``: list like data, will be parsed according to its sequence (same as ``@inject_def``)\n\u003e   - ``multi``: if true, the data will be seen as list of many groups of variables, and this test method will be run the same times as the length of the data. Each group of variable will be run once.\n# TODO\n- [ ] @depends_on: to run multicase pipeline automatically\n- [ ] @inject_yaml: to inject yaml data\n- [ ] @inject_csv: to inject csv data\n- [ ] @once: indicates that the test case should be run once\n- [ ] @expected: indicates that the test case should return expected output\n- [ ] @throws: indicates that the test case should throw specific exception\n- [ ] More corner case","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faak1247%2Fpydatatest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faak1247%2Fpydatatest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faak1247%2Fpydatatest/lists"}