Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup warnings when collecting tests #7914

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions monai/data/test_time_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class TestTimeAugmentation:
mode, mean, std, vvc = tt_aug(test_data)
"""

__test__ = False # indicate to pytest that this class is not intended for collection
KumoLiu marked this conversation as resolved.
Show resolved Hide resolved

def __init__(
self,
transform: InvertibleTransform,
Expand Down
1 change: 1 addition & 0 deletions tests/test_arraydataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@


class TestCompose(Compose):
__test__ = False # indicate to pytest that this class is not intended for collection

def __call__(self, input_, lazy=False):
img = self.transforms[0](input_)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_auto3dseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class TestOperations(Operations):
Test example for user operation
"""

__test__ = False # indicate to pytest that this class is not intended for collection

def __init__(self) -> None:
self.data = {"max": np.max, "mean": np.mean, "min": np.min}

Expand All @@ -132,6 +134,8 @@ class TestAnalyzer(Analyzer):
Test example for a simple Analyzer
"""

__test__ = False # indicate to pytest that this class is not intended for collection

def __init__(self, key, report_format, stats_name="test"):
self.key = key
super().__init__(stats_name, report_format)
Expand All @@ -149,6 +153,8 @@ class TestImageAnalyzer(Analyzer):
Test example for a simple Analyzer
"""

__test__ = False # indicate to pytest that this class is not intended for collection

def __init__(self, image_key="image", stats_name="test_image"):
self.image_key = image_key
report_format = {"test_stats": None}
Expand Down
1 change: 1 addition & 0 deletions tests/test_convert_data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@


class TestTensor(torch.Tensor):
__test__ = False # indicate to pytest that this class is not intended for collection
pass


Expand Down
2 changes: 2 additions & 0 deletions tests/test_handler_prob_map_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@


class TestDataset(Dataset):
__test__ = False # indicate to pytest that this class is not intended for collection

def __init__(self, name, size):
super().__init__(
Expand Down Expand Up @@ -64,6 +65,7 @@ def __getitem__(self, index):


class TestEvaluator(Evaluator):
__test__ = False # indicate to pytest that this class is not intended for collection

def _iteration(self, engine, batchdata):
return batchdata
Expand Down
1 change: 1 addition & 0 deletions tests/test_handler_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


class TestEvaluator(Evaluator):
__test__ = False # indicate to pytest that this class is not intended for collection

def _iteration(self, engine, batchdata):
engine.state.output = "called"
Expand Down
1 change: 1 addition & 0 deletions tests/test_image_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@


class TestModule(torch.nn.Module):
__test__ = False # indicate to pytest that this class is not intended for collection

def __init__(self):
super().__init__()
Expand Down
1 change: 1 addition & 0 deletions tests/test_prepare_batch_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


class TestNet(torch.nn.Module):
__test__ = False # indicate to pytest that this class is not intended for collection

def forward(self, x: torch.Tensor):
return x
Expand Down
1 change: 1 addition & 0 deletions tests/test_prepare_batch_default_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@


class TestNet(torch.nn.Module):
__test__ = False # indicate to pytest that this class is not intended for collection

def forward(self, x: torch.Tensor):
return x
Expand Down
1 change: 1 addition & 0 deletions tests/test_prepare_batch_extra_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@


class TestNet(torch.nn.Module):
__test__ = False # indicate to pytest that this class is not intended for collection

def forward(self, x: torch.Tensor, t1=None, t2=None, t3=None):
return {"x": x, "t1": t1, "t2": t2, "t3": t3}
Expand Down
1 change: 1 addition & 0 deletions tests/test_prepare_batch_hovernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


class TestNet(torch.nn.Module):
__test__ = False # indicate to pytest that this class is not intended for collection

def forward(self, x: torch.Tensor):
return {HoVerNetBranch.NP: torch.tensor([1, 2]), HoVerNetBranch.NC: torch.tensor([4, 4]), HoVerNetBranch.HV: 16}
Expand Down
1 change: 1 addition & 0 deletions tests/test_torchscript_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


class TestModule(torch.nn.Module):
__test__ = False # indicate to pytest that this class is not intended for collection

def forward(self, x):
return x + 10
Expand Down
Loading