-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython_test_format.txt
More file actions
169 lines (120 loc) · 5.34 KB
/
python_test_format.txt
File metadata and controls
169 lines (120 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
Going to python:
Convert the files to the JSON format (i.e. do code replacements) rather than
code generation. First method to start with is the JSON one.
***
Feature: Refunded or replaced items should be returned to stock
Scenario: Refunded items should be returned to stock
Given a customer buys a black jumper
And I have 3 black jumpers left in stock
When he returns the jumper for a refund
Then I should have 4 black jumpers in stock
Java version
add a translate reference to the inner classes, take away the error and wanring stuff.
Check what lines being added for internal class - should not be Configuration, but the one from translate.
Add data definition for all the possiblities - to show what is understood - this has been done !!
ignore # and * in filenames
Add options.txt reading for the options.
need to increment StepCount / add the new name to the list already used
Both -- replace the Log creation with a """ version
Need to do the following for Python version
Add imports of everything (all Data items to glue and tests using the package).
Can use the data array to determine this.
Add glue code import to the tests
pytest and regular test are the options
For the C# version:
Need to convert list of list to string.
step count versus stepnumber in scenarios -
<StartupObject>GherkinExecutorForCSharp.Translate</StartupObject> in the project properties
result = originalList.SequenceEqual(values, new ATest.ATestComparer()); for comparing lists
namespace instead of package.
not as picky as Java in where everything goes.
Put everything in the Test Project - will need to figure where production goes.
Just need to change Test and TestClass for NUnit version
Notes: aDD TRANLATE to the project stuff (so it can be executed)
Make sure to add C# Compiler to build option
Change other to translate every where
Here's the translated Python code:
```python
class ATest:
def __init__(self, an_int="0", a_string="^", a_double="1.2"):
self.an_int = an_int
self.a_string = a_string
self.a_double = a_double
def __eq__(self, other):
if self is other:
return True
if other is None or not isinstance(other, ATest):
return False
result = True
if self.an_int != "?DNC?" and other.an_int != "?DNC?":
if other.an_int != self.an_int:
result = False
if self.a_string != "?DNC?" and other.a_string != "?DNC?":
if other.a_string != self.a_string:
result = False
if self.a_double != "?DNC?" and other.a_double != "?DNC?":
if other.a_double != self.a_double:
result = False
return result
def __str__(self):
return f"ATest {{an_int = {self.an_int} a_string = {self.a_string} a_double = {self.a_double}}}"
def to_a_test_internal(self):
return ATestInternal(int(self.an_int), self.a_string, float(self.a_double))
class Builder:
def __init__(self):
self.an_int = "0"
self.a_string = "^"
self.a_double = "1.2"
def an_int(self, an_int):
self.an_int = an_int
return self
def a_string(self, a_string):
self.a_string = a_string
return self
def a_double(self, a_double):
self.a_double = a_double
return self
def set_compare(self):
self.an_int = "?DNC?"
self.a_string = "?DNC?"
self.a_double = "?DNC?"
return self
def build(self):
return ATest(self.an_int, self.a_string, self.a_double)
# Assuming ATestInternal class is defined elsewhere
Here's the translated Python code:
```python
import unittest
class FeatureSimpleTest(unittest.TestCase):
def test_scenario_simple(self):
feature_simple_test_glue_object = FeatureSimpleTestGlue()
object_list1 = [
ATest.Builder()
.an_int("1")
.a_string("something")
.a_double("1.2")
.build()
]
feature_simple_test_glue_object.given_table_is(object_list1)
# Assuming ATest and FeatureSimpleTestGlue classes are defined elsewhere
```
This translation assumes that `ATest` and `FeatureSimpleTestGlue` classes are defined elsewhere in your codebase. If you need any further adjustments or explanations, feel free to ask!
Here's the translated Python code:
```python
class FeatureSimpleTestGlue:
DNCString = "?DNC?"
def given_table_is(self, values):
print("--- Given_table_is")
for value in values:
print(value)
# Add calls to production code and asserts
try:
i = value.to_a_test_internal()
print(i)
except ValueError as e:
print(f"Argument Error {value} {ATestInternal.to_data_type_string()}", file=sys.stderr)
# Assuming ATest and ATestInternal classes are defined elsewhere
```
This translation assumes that `ATest` and `ATestInternal` classes are defined elsewhere in your codebase. If you need any further adjustments or explanations, feel free to ask!
```
This translation assumes that the `ATestInternal` class is defined elsewhere in your codebase. If you need any further adjustments or explanations, feel free to ask!