a  ze@s~ddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddZ dd ZGd d d ejZd d ZdS)N)Message)compat32)load_package_tests)__file__cGsttjtg|RSN)rospathdirnamer)argsr L/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_email/__init__.py load_tests sr cOs.tjtjtd|}t|g|Ri|S)Ndata)rrjoinr landmarkopen)filenamer kwsrr r r openfilesrcsleZdZdZeZeZfddZe j j Z ddZ dddZddd Zd d Zd d ZddZddZZS) TestEmailBaseNcs$tj|i||t|jdSr)super__init__ZaddTypeEqualityFuncbytesassertBytesEqual)selfr kw __class__r r r!szTestEmailBase.__init__cCs<t| }tj||jdWdS1s.0YdSN)policy)remailZmessage_from_filer)rrfpr r r _msgobj(s zTestEmailBase._msgobjcCs,|dur|j}|dur|j}tj|||dSr)rmessager Zmessage_from_string)rstringr#rr r r _str_msg,s zTestEmailBase._str_msgcCs,|dur|j}|dur|j}tj|||dSr)rr#r Zmessage_from_bytes)rZ bytestringr#rr r r _bytes_msg3s zTestEmailBase._bytes_msgcCs|j|jdSr)r#r)rr r r _make_message:szTestEmailBase._make_messagecCsdd|jddDS)NcSsg|] }t|qSr )repr).0xr r r >z-TestEmailBase._bytes_repr..T)keepends) splitlines)rbr r r _bytes_repr=szTestEmailBase._bytes_reprcCs|||||dS)z@Our byte strings are really encoded strings; improve diff outputN) assertEqualr0)rfirstsecondmsgr r r r@szTestEmailBase.assertBytesEqualcCsH|t|t||tt|D] }|||||d|q"dS)Nzitem {})r1lenrangeZassertIsInstanceformat)ractualZexpectedir r r assertDefectsEqualDs z TestEmailBase.assertDefectsEqual)NN)NN)__name__ __module__ __qualname__ZmaxDiffrrrr#runittestTestCaser1ZndiffAssertEqualr"r%r&r'r0rr: __classcell__r r rr rs   rcCsi}tt}|jD]\}}|drt|dszi}|D]8}t|dsP|f}ddd|Ddd}|||<q<|}|||dd d <d |vr|| d d d  |qi}|D]}||vrt d |q|D]}||vrt d |q|jD]\}}|D]\} } | | rd|t| d} | D]N\} } t| drf|| fdd}n|| fdd}| d| }||_|||<qBqq|D]\}}t|||q|S)a2A test method parameterization class decorator. Parameters are specified as the value of a class attribute that ends with the string '_params'. Call the portion before '_params' the prefix. Then a method to be parameterized must have the same prefix, the string '_as_', and an arbitrary suffix. The value of the _params attribute may be either a dictionary or a list. The values in the dictionary and the elements of the list may either be single values, or a list. If single values, they are turned into single element tuples. However derived, the resulting sequence is passed via *args to the parameterized test function. In a _params dictionary, the keys become part of the name of the generated tests. In a _params list, the values in the list are converted into a string by joining the string values of the elements of the tuple by '_' and converting any blanks into '_'s, and this become part of the name. The full name of a generated test is a 'test_' prefix, the portion of the test function name after the '_as_' separator, plus an '_', plus the name derived as explained above. For example, if we have: count_params = range(2) def count_as_foo_arg(self, foo): self.assertEqual(foo+1, myfunc(foo)) we will get parameterized test methods named: test_foo_arg_0 test_foo_arg_1 test_foo_arg_2 Or we could have: example_params = {'foo': ('bar', 1), 'bing': ('bang', 2)} def example_as_myfunc_input(self, name, count): self.assertEqual(name+str(count), myfunc(name, count)) and get: test_myfunc_input_foo test_myfunc_input_bing Note: if and only if the generated test name is a valid identifier can it be used to select the test individually from the unittest command line. The values in the params dict can be a single value, a tuple, or a dict. If a single value of a tuple, it is passed to the test function as positional arguments. If a dict, it is a passed via **kw. Z_paramskeys__iter___css|]}t|VqdSr)str)r)vr r r r,zparameterize.. NiZ_as_rzNo tester found for {}zNo params found for {}Ztest_cSst||fi|Srgetattrrnameparamsr r r szparameterize..cSst|||SrrHrJr r r rMs) collections defaultdictlist__dict__itemsendswithhasattrrreplacesplitappend ValueErrorr7 startswithr5r;setattr)clsZ paramdictsZtestersrKattrdr*nZ testfuncsZ paramsnameZ paramsdictZ testnamerootZ paramnamerLtestZtestnamekeyvaluer r r parameterizeKsH5        rb)rr>rNr Z email.messagerZemail._policybaserZ test.supportrZtest.test_emailrrr rr?rrbr r r r s    4