Closed sfluegel05 closed 1 week ago
To run all unit tests in a specific folder using Python's unittest
framework, you can use the unittest discover
command.
python -m unittest discover -s <test_folder> -t <top-level-directory> -p "<pattern>"
-s <test_folder>
: This specifies the folder to search for test files. In our case, <test_folder>
would be the path to the directory containing the tests (e.g., tests/unit
).
-p <pattern>
: (Optional) This allows you to define a file name pattern for matching the test files. For example:
-p "*_test.py"
will match files like example_test.py
.-p "test_*.py"
will match files like test_example.py
.(files starting with
test`).**-t <top_level_directory>
: Specifies the top-level directory of the project (root). This is necessary when the tests are located in a subdirectory but need to be executed within the context of the top-level project directory. This is where Python will consider the root of the project for resolving module imports during testing.
tests/unit
Folder Example:python -m unittest discover -s G:\github-aditya0by0\python-chebai\tests\unit -t G:\github-aditya0by0\python-chebai
- Tox21MolNet:
setup_processed()
,_load_data_from_file()
The test case for above class is not added/covered in this issue, due to issue #53. It will added after completion of the issue.
The toxicity-related tests have not been merged yet. They will be included in #56 (see also issue #53)
We already have some tests for data preprocessing. However, those are more integration tests that capture the behaviour of the tool as a whole than unit tests for specific functions. In order to efficiently test the different preprocessing functionalities, we need to add some smaller-scale unit tests. Those should not include real data, but sample input values that can be generated from scratch.
Here are the classes / functions that should be covered (from the implementation in the
protein_prediction
branchreader.py
:to_data()
_read_data()
_read_data()
_read_data()
_read_data()
collate.py
:__call__()
__call__()
,process_label_rows()
datasets/base.py
_filter_labels()
get_test_split()
,get_train_val_splits_given_test()
datasets/chebi.py
_extract_class_hierarchy()
,_graph_to_raw_dataset()
,_load_dict()
,_setup_pruned_test_set()
select_classes()
extract_class_hierarchy()
term_callback()
datasets/go_uniprot.py
:_extract_class_hierarchy()
,term_callback()
,_graph_to_raw_dataset()
,_get_swiss_to_go_mapping()
,_load_dict()
select_classes()
datasets/tox21.py
:setup_processed()
,_load_data_from_file()
~setup_processed()
,_load_data_from_file()
,_load_dict()
For some functions, it is necessary to read from / write to files. Instead of real files, I would suggest to use mock objects (see e.g. this comment)