Notebook functions to search for api tests
from fastai.gen_doc.nbdoc import *
from fastai.gen_doc.nbtest import *
show_test and doctest searches for any implemented tests for a given fastai class or function
For test writers:
For fastai users:
nbdoc.show_doc and nbdoc.doc.show_doc(show_test)
show_test[source][test]
show_test(elt) →str
No tests found for show_test. To contribute a test please refer to this guide and this discussion.
Show associated tests for a fastai function/class
Show tests from function
from fastai.basic_train import Learner
show_test(Learner.fit)
Show tests from a Class
from fastai.basic_data import DataBunch
show_test(DataBunch)
Tests found for DataBunch:
pytest -sv tests/test_data_block.py::test_custom_dataset [source]Direct tests:
pytest -sv tests/test_basic_data.py::test_DataBunch_show_batch [source]pytest -sv tests/test_basic_data.py::test_DataBunch_oneitem [source]pytest -sv tests/test_basic_data.py::test_DataBunch_Create [source]pytest -sv tests/test_basic_data.py::test_DataBunch_no_valid_dl [source]pytest -sv tests/test_basic_data.py::test_DataBunch_onebatch [source]To run tests please refer to this guide.
from fastai.text.data import TextList
show_test(TextList)
Above, you will see 3 different test types: This tests, Direct tests, and Related tests
This tests - Searches for function matches in test_api_db.json. This json file is populated from doctest.this_tests calls.Direct tests - Searches for any test function whose name contains the fastai function callRelated tests - Returns any test function where the fastai function in called inside the bodyshow_doc(doctest)
show_doc(find_dir_tests)
find_dir_tests[source][test]
find_dir_tests(elt) →Tuple[List[Dict[KT,VT]],List[Dict[KT,VT]]]
No tests found for find_dir_tests. To contribute a test please refer to this guide and this discussion.
Searches fastai/tests folder for any test functions related to elt
show_doc(lookup_db)
lookup_db[source][test]
lookup_db(elt) →List[Dict[KT,VT]]
No tests found for lookup_db. To contribute a test please refer to this guide and this discussion.
Finds this_test entries from test_api_db.json
show_doc(find_test_matches)
find_test_matches[source][test]
find_test_matches(elt,test_file:Path) →Tuple[List[Dict[KT,VT]],List[Dict[KT,VT]]]
No tests found for find_test_matches. To contribute a test please refer to this guide and this discussion.
Find all functions in test_file related to elt
show_doc(find_test_files)
find_test_files[source][test]
find_test_files(elt,exact_match:bool=*False*) →List[Path]
No tests found for find_test_files. To contribute a test please refer to this guide and this discussion.
Searches in fastai/tests directory for module tests
show_doc(direct_test_match)
direct_test_match[source][test]
direct_test_match(fn_name:str,lines:List[Dict[KT,VT]],rel_path:str) →List[TestFunctionMatch]
Tests found for direct_test_match:
pytest -sv tests/test_gen_doc_nbtest.py::test_direct_test_match [source]pytest -sv tests/test_gen_doc_nbtest.py::test_direct_test_match_class_methods [source]Direct tests:
pytest -sv tests/test_gen_doc_nbtest.py::test_direct_test_match [source]pytest -sv tests/test_gen_doc_nbtest.py::test_direct_test_match_class_methods [source]To run tests please refer to this guide.
Any def test_function_name(): where test name contains function/class name
show_doc(fuzzy_test_match)
fuzzy_test_match[source][test]
fuzzy_test_match(fn_name:str,lines:List[Dict[KT,VT]],rel_path:str) →List[TestFunctionMatch]
Find any lines where fn_name is invoked and return the parent test function