Skip to content

Commit

Permalink
[tests] further fix Tester object has no attribute '_testMethodName' (
Browse files Browse the repository at this point in the history
#35781)

* bug fix

* update with more cases

* more entries

* Fix

---------

Co-authored-by: ydshieh <[email protected]>
  • Loading branch information
faaany and ydshieh authored Jan 29, 2025
1 parent ec7790f commit f0ae65c
Show file tree
Hide file tree
Showing 57 changed files with 57 additions and 110 deletions.
3 changes: 1 addition & 2 deletions tests/models/albert/test_modeling_flax_albert.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)


class FlaxAlbertModelTester(unittest.TestCase):
class FlaxAlbertModelTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -80,7 +80,6 @@ def __init__(
self.type_sequence_label_size = type_sequence_label_size
self.initializer_range = initializer_range
self.num_choices = num_choices
super().__init__()

def prepare_config_and_inputs(self):
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
Expand Down
3 changes: 1 addition & 2 deletions tests/models/aria/test_image_processing_aria.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import torch


class AriaImageProcessingTester(unittest.TestCase):
class AriaImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -55,7 +55,6 @@ def __init__(
do_convert_rgb=True,
resample=PILImageResampling.BICUBIC,
):
super().__init__()
self.size = size if size is not None else {"longest_edge": max_resolution}
self.parent = parent
self.batch_size = batch_size
Expand Down
3 changes: 1 addition & 2 deletions tests/models/beit/test_modeling_flax_beit.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from transformers import BeitImageProcessor


class FlaxBeitModelTester(unittest.TestCase):
class FlaxBeitModelTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -79,7 +79,6 @@ def __init__(
# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
num_patches = (image_size // patch_size) ** 2
self.seq_length = num_patches + 1
super().__init__()

def prepare_config_and_inputs(self):
pixel_values = floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])
Expand Down
3 changes: 1 addition & 2 deletions tests/models/bert/test_modeling_flax_bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)


class FlaxBertModelTester(unittest.TestCase):
class FlaxBertModelTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -79,7 +79,6 @@ def __init__(
self.type_sequence_label_size = type_sequence_label_size
self.initializer_range = initializer_range
self.num_choices = num_choices
super().__init__()

def prepare_config_and_inputs(self):
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
Expand Down
3 changes: 1 addition & 2 deletions tests/models/big_bird/test_modeling_flax_big_bird.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)


class FlaxBigBirdModelTester(unittest.TestCase):
class FlaxBigBirdModelTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -90,7 +90,6 @@ def __init__(
self.use_bias = use_bias
self.block_size = block_size
self.num_random_blocks = num_random_blocks
super().__init__()

def prepare_config_and_inputs(self):
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
Expand Down
3 changes: 1 addition & 2 deletions tests/models/blip/test_image_processing_blip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from transformers import BlipImageProcessor


class BlipImageProcessingTester(unittest.TestCase):
class BlipImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -43,7 +43,6 @@ def __init__(
image_std=[0.26862954, 0.26130258, 0.27577711],
do_convert_rgb=True,
):
super().__init__()
size = size if size is not None else {"height": 20, "width": 20}
self.parent = parent
self.batch_size = batch_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from transformers import BridgeTowerImageProcessor


class BridgeTowerImageProcessingTester(unittest.TestCase):
class BridgeTowerImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -50,7 +50,6 @@ def __init__(
max_resolution=400,
num_channels=3,
):
super().__init__()
self.parent = parent
self.do_resize = do_resize
self.size = size if size is not None else {"shortest_edge": 288}
Expand Down
3 changes: 1 addition & 2 deletions tests/models/chameleon/test_image_processing_chameleon.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from transformers import ChameleonImageProcessor


class ChameleonImageProcessingTester(unittest.TestCase):
class ChameleonImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -50,7 +50,6 @@ def __init__(
image_std=[1.0, 1.0, 1.0],
do_convert_rgb=True,
):
super().__init__()
size = size if size is not None else {"shortest_edge": 18}
crop_size = crop_size if crop_size is not None else {"height": 18, "width": 18}
self.parent = parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from transformers import ChineseCLIPImageProcessor


class ChineseCLIPImageProcessingTester(unittest.TestCase):
class ChineseCLIPImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -44,7 +44,6 @@ def __init__(
image_std=[0.26862954, 0.26130258, 0.27577711],
do_convert_rgb=True,
):
super().__init__()
size = size if size is not None else {"height": 224, "width": 224}
crop_size = crop_size if crop_size is not None else {"height": 18, "width": 18}
self.parent = parent
Expand Down
3 changes: 1 addition & 2 deletions tests/models/convnext/test_image_processing_convnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from transformers import ConvNextImageProcessor


class ConvNextImageProcessingTester(unittest.TestCase):
class ConvNextImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -42,7 +42,6 @@ def __init__(
image_mean=[0.5, 0.5, 0.5],
image_std=[0.5, 0.5, 0.5],
):
super().__init__()
size = size if size is not None else {"shortest_edge": 20}
self.parent = parent
self.batch_size = batch_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from transformers import DeformableDetrImageProcessor, DeformableDetrImageProcessorFast


class DeformableDetrImageProcessingTester(unittest.TestCase):
class DeformableDetrImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -52,7 +52,6 @@ def __init__(
rescale_factor=1 / 255,
do_pad=True,
):
super().__init__()
# by setting size["longest_edge"] > max_resolution we're effectively not testing this :p
size = size if size is not None else {"shortest_edge": 18, "longest_edge": 1333}
self.parent = parent
Expand Down
3 changes: 1 addition & 2 deletions tests/models/deit/test_image_processing_deit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from transformers import DeiTImageProcessor


class DeiTImageProcessingTester(unittest.TestCase):
class DeiTImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -43,7 +43,6 @@ def __init__(
image_mean=[0.5, 0.5, 0.5],
image_std=[0.5, 0.5, 0.5],
):
super().__init__()
size = size if size is not None else {"height": 20, "width": 20}
crop_size = crop_size if crop_size is not None else {"height": 18, "width": 18}

Expand Down
3 changes: 1 addition & 2 deletions tests/models/detr/test_image_processing_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from transformers import DetrImageProcessorFast


class DetrImageProcessingTester(unittest.TestCase):
class DetrImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -54,7 +54,6 @@ def __init__(
image_std=[0.5, 0.5, 0.5],
do_pad=True,
):
super().__init__()
# by setting size["longest_edge"] > max_resolution we're effectively not testing this :p
size = size if size is not None else {"shortest_edge": 18, "longest_edge": 1333}
self.parent = parent
Expand Down
3 changes: 1 addition & 2 deletions tests/models/distilbert/test_modeling_flax_distilbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)


class FlaxDistilBertModelTester(unittest.TestCase):
class FlaxDistilBertModelTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -79,7 +79,6 @@ def __init__(
self.type_sequence_label_size = type_sequence_label_size
self.initializer_range = initializer_range
self.num_choices = num_choices
super().__init__()

def prepare_config_and_inputs(self):
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
Expand Down
3 changes: 1 addition & 2 deletions tests/models/donut/test_image_processing_donut.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from transformers import DonutImageProcessor


class DonutImageProcessingTester(unittest.TestCase):
class DonutImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -51,7 +51,6 @@ def __init__(
image_mean=[0.5, 0.5, 0.5],
image_std=[0.5, 0.5, 0.5],
):
super().__init__()
self.parent = parent
self.batch_size = batch_size
self.num_channels = num_channels
Expand Down
3 changes: 1 addition & 2 deletions tests/models/dpt/test_image_processing_dpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from transformers import DPTImageProcessor


class DPTImageProcessingTester(unittest.TestCase):
class DPTImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -50,7 +50,6 @@ def __init__(
image_std=[0.5, 0.5, 0.5],
do_reduce_labels=False,
):
super().__init__()
size = size if size is not None else {"height": 18, "width": 18}
self.parent = parent
self.batch_size = batch_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from transformers import EfficientNetImageProcessor


class EfficientNetImageProcessorTester(unittest.TestCase):
class EfficientNetImageProcessorTester:
def __init__(
self,
parent,
Expand All @@ -43,7 +43,6 @@ def __init__(
image_mean=[0.5, 0.5, 0.5],
image_std=[0.5, 0.5, 0.5],
):
super().__init__()
size = size if size is not None else {"height": 18, "width": 18}
self.parent = parent
self.batch_size = batch_size
Expand Down
3 changes: 1 addition & 2 deletions tests/models/electra/test_modeling_flax_electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)


class FlaxElectraModelTester(unittest.TestCase):
class FlaxElectraModelTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -67,7 +67,6 @@ def __init__(
self.type_sequence_label_size = type_sequence_label_size
self.initializer_range = initializer_range
self.num_choices = num_choices
super().__init__()

def prepare_config_and_inputs(self):
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
Expand Down
3 changes: 1 addition & 2 deletions tests/models/flava/test_image_processing_flava.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
FLAVA_IMAGE_MEAN = FLAVA_IMAGE_STD = FLAVA_CODEBOOK_MEAN = FLAVA_CODEBOOK_STD = None


class FlavaImageProcessingTester(unittest.TestCase):
class FlavaImageProcessingTester:
def __init__(
self,
parent,
Expand Down Expand Up @@ -76,7 +76,6 @@ def __init__(
codebook_image_mean=FLAVA_CODEBOOK_MEAN,
codebook_image_std=FLAVA_CODEBOOK_STD,
):
super().__init__()
size = size if size is not None else {"height": 224, "width": 224}
crop_size = crop_size if crop_size is not None else {"height": 224, "width": 224}
codebook_size = codebook_size if codebook_size is not None else {"height": 112, "width": 112}
Expand Down
3 changes: 1 addition & 2 deletions tests/models/glpn/test_image_processing_glpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from transformers import GLPNImageProcessor


class GLPNImageProcessingTester(unittest.TestCase):
class GLPNImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -46,7 +46,6 @@ def __init__(
size_divisor=32,
do_rescale=True,
):
super().__init__()
self.parent = parent
self.batch_size = batch_size
self.num_channels = num_channels
Expand Down
3 changes: 1 addition & 2 deletions tests/models/idefics3/test_image_processing_idefics3.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import torch


class Idefics3ImageProcessingTester(unittest.TestCase):
class Idefics3ImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -58,7 +58,6 @@ def __init__(
do_image_splitting=True,
resample=PILImageResampling.LANCZOS,
):
super().__init__()
self.size = size if size is not None else {"longest_edge": max_resolution}
self.parent = parent
self.batch_size = batch_size
Expand Down
3 changes: 1 addition & 2 deletions tests/models/imagegpt/test_image_processing_imagegpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from transformers import ImageGPTImageProcessor


class ImageGPTImageProcessingTester(unittest.TestCase):
class ImageGPTImageProcessingTester:
def __init__(
self,
parent,
Expand All @@ -51,7 +51,6 @@ def __init__(
size=None,
do_normalize=True,
):
super().__init__()
size = size if size is not None else {"height": 18, "width": 18}
self.parent = parent
self.batch_size = batch_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from transformers import InstructBlipVideoImageProcessor


class InstructBlipVideoProcessingTester(unittest.TestCase):
class InstructBlipVideoProcessingTester:
def __init__(
self,
parent,
Expand All @@ -50,7 +50,6 @@ def __init__(
do_convert_rgb=True,
frames=4,
):
super().__init__()
size = size if size is not None else {"height": 18, "width": 18}
self.parent = parent
self.batch_size = batch_size
Expand Down
Loading

0 comments on commit f0ae65c

Please sign in to comment.