{"id":16285538,"url":"https://github.com/tonyfast/pytest-notebook-import","last_synced_at":"2025-04-09T03:20:12.382Z","repository":{"id":75804801,"uuid":"131376046","full_name":"tonyfast/pytest-notebook-import","owner":"tonyfast","description":"An example directory structure for testing notebooks with pytest coverage, benchmarking, and hypothesis using importnb.","archived":false,"fork":false,"pushed_at":"2018-04-28T16:05:11.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T21:47:13.829Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonyfast.png","metadata":{"files":{"readme":"readme.ipynb","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-04-28T05:29:51.000Z","updated_at":"2018-04-28T16:05:12.000Z","dependencies_parsed_at":"2023-03-14T15:45:42.990Z","dependency_job_id":null,"html_url":"https://github.com/tonyfast/pytest-notebook-import","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"1cb891046ab21e8a4ead2c118b0d9dfa2681a80f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyfast%2Fpytest-notebook-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyfast%2Fpytest-notebook-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyfast%2Fpytest-notebook-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyfast%2Fpytest-notebook-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonyfast","download_url":"https://codeload.github.com/tonyfast/pytest-notebook-import/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247968804,"owners_count":21025883,"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":[],"created_at":"2024-10-10T19:25:06.392Z","updated_at":"2025-04-09T03:20:12.303Z","avatar_url":"https://github.com/tonyfast.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tonyfast/pytest-notebook-import/master?urlpath=lab/tree/readme.ipynb)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Import pytest plugins for hypothesis, coverage, and benchmarking.\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"from IPython import get_ipython\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 2,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"Overwriting requirements.txt\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"%%file requirements.txt\\n\",\n    \"importnb\\n\",\n    \"pytest\\n\",\n    \"hypothesis\\n\",\n    \"pytest-cov\\n\",\n    \"pytest-benchmark\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"We can even create test fixtures in a notebook and load them into `conftest.py`\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 3,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"Overwriting conftest.py\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"%%file conftest.py\\n\",\n    \"from importnb import Notebook\\n\",\n    \"with Notebook():  \\n\",\n    \"    from fixtures import *\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 4,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"Overwriting test_py.py\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"%%file test_py.py\\n\",\n    \"def test_py(): assert True\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 5,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"def test_something_in_readme():\\n\",\n    \"    assert True\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Use the pytest api.\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 6,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"=============================== test session starts ===============================\\n\",\n      \"platform darwin -- Python 3.6.3, pytest-3.5.1, py-1.5.3, pluggy-0.6.0\\n\",\n      \"benchmark: 3.1.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)\\n\",\n      \"rootdir: /Users/tonyfast/_test, inifile:\\n\",\n      \"plugins: cov-2.5.1, benchmark-3.1.1, hypothesis-3.56.5, importnb-0.2.1\\n\",\n      \"collected 6 items\\n\",\n      \"\\n\",\n      \"readme.ipynb .                                                              [ 16%]\\n\",\n      \"test_notebook.ipynb ...                                                     [ 66%]\\n\",\n      \"test_py.py ..\\n\",\n      \"\\n\",\n      \"\\n\",\n      \"----------------------------------------------- benchmark: 1 tests -----------------------------------------------\\n\",\n      \"Name (time in ms)          Min       Max      Mean  StdDev    Median     IQR  Outliers     OPS  Rounds  Iterations\\n\",\n      \"------------------------------------------------------------------------------------------------------------------\\n\",\n      \"test_sleep            200.0932  201.0421  200.4959  0.3521  200.3819  0.3939       2;0  4.9876       5           1\\n\",\n      \"------------------------------------------------------------------------------------------------------------------\\n\",\n      \"\\n\",\n      \"Legend:\\n\",\n      \"  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.\\n\",\n      \"  OPS: Operations Per Second, computed as 1 / Mean\\n\",\n      \"============================ 6 passed in 2.78 seconds =============================\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"if __name__ == '__main__':\\n\",\n    \"    __import__('pytest').main(args=[])    \"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"User ipython to test files with magics.\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 7,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"\\u001b]0;IPython: tonyfast/_test\\u0007\\u001b[1m============================= test session starts ==============================\\u001b[0m\\n\",\n      \"platform darwin -- Python 3.6.3, pytest-3.5.1, py-1.5.3, pluggy-0.6.0\\n\",\n      \"benchmark: 3.1.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)\\n\",\n      \"rootdir: /Users/tonyfast/_test, inifile:\\n\",\n      \"plugins: cov-2.5.1, benchmark-3.1.1, hypothesis-3.56.5, importnb-0.2.1\\n\",\n      \"collected 6 items                                                              \\u001b[0m\\n\",\n      \"\\n\",\n      \"readme.ipynb .\\u001b[36m                                                           [ 16%]\\u001b[0m\\n\",\n      \"test_notebook.ipynb ...\\u001b[36m                                                  [ 66%]\\u001b[0m\\n\",\n      \"test_py.py ..\\n\",\n      \"\\n\",\n      \"\\n\",\n      \"\\u001b[33m----------------------------------------------- benchmark: 1 tests -----------------------------------------------\\u001b[0m\\n\",\n      \"Name (time in ms)          Min       Max      Mean  StdDev    Median     IQR  Outliers     OPS  Rounds  Iterations\\n\",\n      \"\\u001b[33m------------------------------------------------------------------------------------------------------------------\\u001b[0m\\n\",\n      \"test_sleep          \\u001b[1m  200.4467\\u001b[0m\\u001b[1m  204.8579\\u001b[0m\\u001b[1m  203.1205\\u001b[0m\\u001b[1m  1.9855\\u001b[0m\\u001b[1m  203.8270\\u001b[0m\\u001b[1m  3.4923\\u001b[0m       1;0\\u001b[1m  4.9232\\u001b[0m       5           1\\n\",\n      \"\\u001b[33m------------------------------------------------------------------------------------------------------------------\\u001b[0m\\n\",\n      \"\\n\",\n      \"Legend:\\n\",\n      \"  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.\\n\",\n      \"  OPS: Operations Per Second, computed as 1 / Mean\\n\",\n      \"\\u001b[32m\\u001b[1m=========================== 6 passed in 2.68 seconds ===========================\\u001b[0m\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"if __name__ == '__main__':\\n\",\n    \"    !ipython -m pytest\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Make the readme.\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 8,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"[NbConvertApp] Converting notebook readme.ipynb to markdown\\n\",\n      \"[NbConvertApp] Writing 3578 bytes to readme.md\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"if __name__ == '__main__':\\n\",\n    \"    !jupyter nbconvert --to markdown readme.ipynb\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": []\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": []\n  }\n ],\n \"metadata\": {\n  \"kernelspec\": {\n   \"display_name\": \"p6\",\n   \"language\": \"python\",\n   \"name\": \"other-env\"\n  },\n  \"language_info\": {\n   \"codemirror_mode\": {\n    \"name\": \"ipython\",\n    \"version\": 3\n   },\n   \"file_extension\": \".py\",\n   \"mimetype\": \"text/x-python\",\n   \"name\": \"python\",\n   \"nbconvert_exporter\": \"python\",\n   \"pygments_lexer\": \"ipython3\",\n   \"version\": \"3.6.3\"\n  }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyfast%2Fpytest-notebook-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonyfast%2Fpytest-notebook-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyfast%2Fpytest-notebook-import/lists"}