
"""simple docstring"""
import unittest

from diffusers import __version__
from diffusers.utils import deprecate




class  _snake_case	(    unittest.TestCase							):
							SCREAMING_SNAKE_CASE		  =    '''.'''.join([str(int(__version__.split('''.'''							)[0]							) + 1							)] + __version__.split('''.'''							)[1:]							)
							SCREAMING_SNAKE_CASE		  =    '''0.0.1'''






							def 				__lowercase	(       self    :      int     ):






												"""simple docstring"""



												__a:    Optional[Any]		     =       {"""deprecated_arg""": 4}

												with self.assertWarns(snake_case__     ) as warning:
																	__a:    List[str]		     =       deprecate("""deprecated_arg"""    ,			self.higher_version    ,			"""message"""    ,			take_from=snake_case__     )

												assert output == 4
												assert (
												    str(warning.warning     )
												    == f"""The `deprecated_arg` argument is deprecated and will be removed in version {self.higher_version}."""
												    " message"
												)






							def 				__lowercase	(       self    :      List[Any]     ):






												"""simple docstring"""



												__a:    Optional[Any]		     =       {"""deprecated_arg""": 4}

												with self.assertWarns(snake_case__     ) as warning:
																	__a:    Optional[int]		     =       deprecate(("""deprecated_arg""", self.higher_version, """message""")    ,			take_from=snake_case__     )

												assert output == 4
												assert (
												    str(warning.warning     )
												    == f"""The `deprecated_arg` argument is deprecated and will be removed in version {self.higher_version}."""
												    " message"
												)






							def 				__lowercase	(       self    :      str     ):






												"""simple docstring"""



												__a:    Optional[int]		     =       {"""deprecated_arg_1""": 4, """deprecated_arg_2""": 8}
												with self.assertWarns(snake_case__     ) as warning:
																	__a     ,					__a:    Optional[Any]		     =       deprecate(
																	    ("""deprecated_arg_1""", self.higher_version, """Hey""")    ,			("""deprecated_arg_2""", self.higher_version, """Hey""")    ,			take_from=snake_case__    ,			)
												assert output_a == 4
												assert output_a == 8
												assert (
												    str(warning.warnings[0].message     )
												    == "The `deprecated_arg_1` argument is deprecated and will be removed in version"
												    f""" {self.higher_version}. Hey"""
												)
												assert (
												    str(warning.warnings[1].message     )
												    == "The `deprecated_arg_2` argument is deprecated and will be removed in version"
												    f""" {self.higher_version}. Hey"""
												)






							def 				__lowercase	(       self    :      Any     ):






												"""simple docstring"""



												__a:    Union[str, Any]		     =       {"""deprecated_arg""": 4}

												with self.assertRaises(snake_case__     ) as error:
																	deprecate(("""wrong_arg""", self.higher_version, """message""")    ,			take_from=snake_case__     )

												assert "test_deprecate_function_incorrect_arg in" in str(error.exception     )
												assert "line" in str(error.exception     )
												assert "got an unexpected keyword argument `deprecated_arg`" in str(error.exception     )






							def 				__lowercase	(       self    :      Union[str, Any]     ):






												"""simple docstring"""



												with self.assertWarns(snake_case__     ) as warning:
																	deprecate(("""deprecated_arg""", self.higher_version, """message""")     )

												assert (
												    str(warning.warning     )
												    == f"""`deprecated_arg` is deprecated and will be removed in version {self.higher_version}. message"""
												)






							def 				__lowercase	(       self    :      Optional[Any]     ):






												"""simple docstring"""



												with self.assertWarns(snake_case__     ) as warning:
																	deprecate(
																	    ("""deprecated_arg_1""", self.higher_version, """Hey""")    ,			("""deprecated_arg_2""", self.higher_version, """Hey""")    ,			)
												assert (
												    str(warning.warnings[0].message     )
												    == f"""`deprecated_arg_1` is deprecated and will be removed in version {self.higher_version}. Hey"""
												)
												assert (
												    str(warning.warnings[1].message     )
												    == f"""`deprecated_arg_2` is deprecated and will be removed in version {self.higher_version}. Hey"""
												)






							def 				__lowercase	(       self    :      Optional[Any]     ):






												"""simple docstring"""



												class  _snake_case	:
																			SCREAMING_SNAKE_CASE		  =    5

												with self.assertWarns(snake_case__     ) as warning:
																	__a:    Optional[int]		     =       deprecate(("""arg""", self.higher_version, """message""")    ,			take_from=Args()     )

												assert arg == 5
												assert (
												    str(warning.warning     )
												    == f"""The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message"""
												)






							def 				__lowercase	(       self    :      Dict     ):






												"""simple docstring"""



												class  _snake_case	:
																			SCREAMING_SNAKE_CASE		  =    5
																			SCREAMING_SNAKE_CASE		  =    7

												with self.assertWarns(snake_case__     ) as warning:
																	__a     ,					__a:    Dict		     =       deprecate(
																	    ("""arg""", self.higher_version, """message""")    ,			("""foo""", self.higher_version, """message""")    ,			("""does not exist""", self.higher_version, """message""")    ,			take_from=Args()    ,			)

												assert arg_a == 5
												assert arg_a == 7
												assert (
												    str(warning.warning     )
												    == f"""The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message"""
												)
												assert (
												    str(warning.warnings[0].message     )
												    == f"""The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message"""
												)
												assert (
												    str(warning.warnings[1].message     )
												    == f"""The `foo` attribute is deprecated and will be removed in version {self.higher_version}. message"""
												)






							def 				__lowercase	(       self    :      Tuple     ):






												"""simple docstring"""



												__a:    List[Any]		     =       {"""deprecated_arg""": 4}

												with self.assertRaises(snake_case__     ) as error:
																	deprecate(("""wrong_arg""", self.lower_version, """message""")    ,			take_from=snake_case__     )

												assert (
												    str(error.exception     )
												    == "The deprecation tuple ('wrong_arg', '0.0.1', 'message') should be removed since diffusers' version"
												    f""" {__version__} is >= {self.lower_version}"""
												)






							def 				__lowercase	(       self    :      Dict     ):






												"""simple docstring"""



												with self.assertWarns(snake_case__     ) as warning:
																	deprecate(("""deprecated_arg""", self.higher_version, """This message is better!!!""")    ,			standard_warn=snake_case__     )

												assert str(warning.warning     ) == "This message is better!!!"






							def 				__lowercase	(       self    :      Optional[int]     ):






												"""simple docstring"""



												with self.assertWarns(snake_case__     ) as warning:
																	deprecate(("""deprecated_arg""", self.higher_version, """This message is better!!!""")    ,			standard_warn=snake_case__     )
												assert str(warning.warning     ) == "This message is better!!!"
												assert "diffusers/tests/others/test_utils.py" in warning.filename


"""simple docstring"""
import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput




@dataclass
class  _snake_case	(    _lowercase							):
							SCREAMING_SNAKE_CASE		  =    42
							SCREAMING_SNAKE_CASE		  =    None
							SCREAMING_SNAKE_CASE		  =    None






class  _snake_case	(    unittest.TestCase							):






							def 				__lowercase	(       self    :      Optional[Any]     ):






												"""simple docstring"""



												__a:    Dict		     =       ModelOutputTest(a=3_0     )
												self.assertEqual(x.a    ,			3_0     )
												self.assertIsNone(x.b     )
												self.assertIsNone(x.c     )
												with self.assertRaises(snake_case__     ):
																	__a:    int		     =       x.d






							def 				__lowercase	(       self    :      int     ):






												"""simple docstring"""



												__a:    Tuple		     =       ModelOutputTest(a=3_0    ,			b=1_0     )
												self.assertEqual(x[0]    ,			3_0     )
												self.assertEqual(x[1]    ,			1_0     )
												self.assertEqual(x[:2]    ,			(3_0, 1_0)     )
												self.assertEqual(x[:]    ,			(3_0, 1_0)     )

												__a:    Tuple		     =       ModelOutputTest(a=3_0    ,			c=1_0     )
												self.assertEqual(x[0]    ,			3_0     )
												self.assertEqual(x[1]    ,			1_0     )
												self.assertEqual(x[:2]    ,			(3_0, 1_0)     )
												self.assertEqual(x[:]    ,			(3_0, 1_0)     )






							def 				__lowercase	(       self    :      Tuple     ):






												"""simple docstring"""



												__a:    List[str]		     =       ModelOutputTest(a=3_0    ,			b=1_0     )
												self.assertEqual(x["""a"""]    ,			3_0     )
												self.assertEqual(x["""b"""]    ,			1_0     )
												with self.assertRaises(snake_case__     ):
																	__a:    Union[str, Any]		     =       x["""c"""]

												__a:    str		     =       ModelOutputTest(a=3_0    ,			c=1_0     )
												self.assertEqual(x["""a"""]    ,			3_0     )
												self.assertEqual(x["""c"""]    ,			1_0     )
												with self.assertRaises(snake_case__     ):
																	__a:    List[str]		     =       x["""b"""]






							def 				__lowercase	(       self    :      List[str]     ):






												"""simple docstring"""



												__a:    str		     =       ModelOutputTest(a=3_0     )
												self.assertEqual(list(x.keys()     )    ,			["""a"""]     )
												self.assertEqual(list(x.values()     )    ,			[3_0]     )
												self.assertEqual(list(x.items()     )    ,			[("""a""", 3_0)]     )
												self.assertEqual(list(snake_case__     )    ,			["""a"""]     )

												__a:    Optional[Any]		     =       ModelOutputTest(a=3_0    ,			b=1_0     )
												self.assertEqual(list(x.keys()     )    ,			["""a""", """b"""]     )
												self.assertEqual(list(x.values()     )    ,			[3_0, 1_0]     )
												self.assertEqual(list(x.items()     )    ,			[("""a""", 3_0), ("""b""", 1_0)]     )
												self.assertEqual(list(snake_case__     )    ,			["""a""", """b"""]     )

												__a:    Union[str, Any]		     =       ModelOutputTest(a=3_0    ,			c=1_0     )
												self.assertEqual(list(x.keys()     )    ,			["""a""", """c"""]     )
												self.assertEqual(list(x.values()     )    ,			[3_0, 1_0]     )
												self.assertEqual(list(x.items()     )    ,			[("""a""", 3_0), ("""c""", 1_0)]     )
												self.assertEqual(list(snake_case__     )    ,			["""a""", """c"""]     )

												with self.assertRaises(snake_case__     ):
																	__a:    List[Any]		     =       x.update({"""d""": 2_0}     )
												with self.assertRaises(snake_case__     ):
																	del x["a"]
												with self.assertRaises(snake_case__     ):
																	__a:    Union[str, Any]		     =       x.pop("""a"""     )
												with self.assertRaises(snake_case__     ):
																	__a:    List[Any]		     =       x.setdefault("""d"""    ,			3_2     )






							def 				__lowercase	(       self    :      Any     ):






												"""simple docstring"""



												__a:    List[str]		     =       ModelOutputTest(a=3_0     )
												__a:    str		     =       1_0
												self.assertEqual(x.a    ,			1_0     )
												self.assertEqual(x["""a"""]    ,			1_0     )






							def 				__lowercase	(       self    :      Dict     ):






												"""simple docstring"""



												__a:    List[str]		     =       ModelOutputTest(a=3_0     )
												__a:    Any		     =       1_0
												self.assertEqual(x.a    ,			1_0     )
												self.assertEqual(x["""a"""]    ,			1_0     )






							def 				__lowercase	(       self    :      int     ):






												"""simple docstring"""



												__a:    List[Any]		     =       ModelOutputTest({"""a""": 3_0, """b""": 1_0}     )
												self.assertEqual(list(x.keys()     )    ,			["""a""", """b"""]     )
												self.assertEqual(x.a    ,			3_0     )
												self.assertEqual(x.b    ,			1_0     )






							def 				__lowercase	(       self    :      List[str]     ):






												"""simple docstring"""



												__a:    Union[str, Any]		     =       ModelOutputTest([("""a""", 3_0), ("""b""", 1_0)]     )
												self.assertEqual(list(x.keys()     )    ,			["""a""", """b"""]     )
												self.assertEqual(x.a    ,			3_0     )
												self.assertEqual(x.b    ,			1_0     )

												with self.assertRaises(snake_case__     ):
																	__a:    str		     =       ModelOutputTest([("""a""", 3_0), (1_0, 1_0)]     )

												__a:    str		     =       ModelOutputTest(a=(3_0, 3_0)     )
												self.assertEqual(list(x.keys()     )    ,			["""a"""]     )
												self.assertEqual(x.a    ,			(3_0, 3_0)     )
