Lazy loading with parametrized execution based on the different bool …#102
Lazy loading with parametrized execution based on the different bool …#102Jeenashaji wants to merge 2 commits intoANCPLabOldenburg:mainfrom
Conversation
…values for lazy loadfing using pytest
erdalkaraca
left a comment
There was a problem hiding this comment.
You are properly applying fixtures to paramterize unit tests. We also need to parameterize the other existing unit tests in auto/* where datasets are loaded.
| import shutil | ||
| import tempfile | ||
|
|
||
| from numpy.testing import tempdir |
There was a problem hiding this comment.
seems to be a wrong/unused import, also clean up unused imports in general (tip: use pycharm's "Optimize Imports")
| @@ -0,0 +1,245 @@ | |||
| # Simplified parametrized test case using pytest fixtures | |||
There was a problem hiding this comment.
remove "Param_" prefix in file name
|
|
||
|
|
||
| @pytest.fixture | ||
| def dataset_options(lazy_loading_option): |
There was a problem hiding this comment.
merge this fixture with the load_dataset() fixture
| def test_loading_completes_successfully(loaded_dataset, lazy_loading_option): | ||
| """Test that both lazy and eager loading complete successfully.""" | ||
| assert loaded_dataset is not None | ||
| assert hasattr(loaded_dataset, 'files') |
There was a problem hiding this comment.
better to assert on the number of files and folders as these conditions will also pass on empty lists: how many files/folders do you expect to exist at the root of the dataset?
| file_obj = loaded_dataset.get_file(file_name) | ||
| if file_obj: # File might not exist in test dataset | ||
| contents = file_obj.contents | ||
| assert contents is not None |
There was a problem hiding this comment.
also (partially) check if the contents object contains fields that you expect should exist in the files - you may need to split into two unit tests, one for the tsv and the other for the json file
| assert contents is not None | ||
|
|
||
|
|
||
| def test_content_caching_behavior(dataset_options, lazy_loading_option): |
There was a problem hiding this comment.
if you need to have if/else here, it would make sense to split the test into 2 separate tests
…values for lazy loadfing using pytest
Lazy loading with parametrized execution based on the different bool values for lazy loadfing using pytest