1 | # Generated from java by J2P
|
---|
2 | from __future__ import annotations
|
---|
3 | from decimal import Decimal
|
---|
4 | from geniusweb.inform.Inform import Inform
|
---|
5 | from geniusweb.inform.YourTurn import YourTurn
|
---|
6 | from pyson.ObjectMapper import ObjectMapper
|
---|
7 | from typing import List
|
---|
8 | from typing import Optional
|
---|
9 | from typing import cast
|
---|
10 | from unitpy.GeneralTests import GeneralTests
|
---|
11 | from unitpy.RunWith import RunWith
|
---|
12 | from unitpy.Runner import JUnit4ClassRunner
|
---|
13 | from unitpy.Runner import runTests
|
---|
14 | from unitpy.Test import Test
|
---|
15 | from unittest import TestCase
|
---|
16 | import json
|
---|
17 |
|
---|
18 |
|
---|
19 | class YourTurnAlt(YourTurn):
|
---|
20 |
|
---|
21 | #Override
|
---|
22 | def __hash__(self) -> int:
|
---|
23 | return 2
|
---|
24 |
|
---|
25 | def __init__(self):
|
---|
26 | super().__init__()
|
---|
27 | @RunWith(JUnit4ClassRunner)
|
---|
28 | class YourTurnTest(GeneralTests):
|
---|
29 |
|
---|
30 | #Override
|
---|
31 | def getGeneralTestData(self) -> Optional[List[Optional[List[Optional[YourTurn]]]]]:
|
---|
32 | return [[self.__yourturn1,self.__yourturn1b],(lambda _: _ if type(_)==list else [_])(self.__yourturnb)]
|
---|
33 |
|
---|
34 | #Override
|
---|
35 | def getGeneralTestStrings(self) -> Optional[List[Optional[str]]]:
|
---|
36 | return ["YourTurn*","YourTurn*"]
|
---|
37 |
|
---|
38 | @Test()
|
---|
39 | def testSerialize(self) -> None:
|
---|
40 | jsonstr:str = json.dumps(YourTurnTest.__jackson.toJson(self.__yourturn1),separators=(',', ':'))
|
---|
41 | # System.out.println(json);
|
---|
42 | TestCase().assertEqual(YourTurnTest.__asJson,jsonstr)
|
---|
43 |
|
---|
44 | @Test()
|
---|
45 | def testDeserialize(self) -> None:
|
---|
46 | p:YourTurn = cast(YourTurn,YourTurnTest.__jackson.parse(json.loads(YourTurnTest.__asJson, parse_float=lambda _:Decimal(_)),Inform))
|
---|
47 | # System.out.println(p);
|
---|
48 | TestCase().assertEqual(self.__yourturn1,p)
|
---|
49 |
|
---|
50 | def __init__(self):
|
---|
51 | self.__yourturn1:YourTurn = YourTurn()
|
---|
52 | self.__yourturn1b:YourTurn = YourTurn()
|
---|
53 | self.__yourturnb:YourTurn = YourTurnAlt()
|
---|
54 | super().__init__()
|
---|
55 | @staticmethod
|
---|
56 | def _static_init_():
|
---|
57 | YourTurnTest.__jackson:ObjectMapper = ObjectMapper()
|
---|
58 | YourTurnTest.__asJson:str = "{\"YourTurn\":{}}"
|
---|
59 | YourTurnTest._static_init_()
|
---|
60 |
|
---|
61 | class Test(TestCase):
|
---|
62 | def test(self):
|
---|
63 | runTests(YourTurnTest)
|
---|