DataComparerLibrary 0.843__tar.gz → 0.844__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datacomparerlibrary-0.843/src/DataComparerLibrary.egg-info → datacomparerlibrary-0.844}/PKG-INFO +51 -5
- datacomparerlibrary-0.843/PKG-INFO → datacomparerlibrary-0.844/README.rst +47 -23
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/setup.py +3 -1
- datacomparerlibrary-0.843/src/DataComparerLibrary/datacomparer.py → datacomparerlibrary-0.844/src/DataComparerLibrary/arraycomparer.py +41 -214
- datacomparerlibrary-0.844/src/DataComparerLibrary/datacomparer.py +135 -0
- datacomparerlibrary-0.844/src/DataComparerLibrary/report.py +23 -0
- datacomparerlibrary-0.844/src/DataComparerLibrary/version.py +3 -0
- datacomparerlibrary-0.843/README.rst → datacomparerlibrary-0.844/src/DataComparerLibrary.egg-info/PKG-INFO +69 -3
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary.egg-info/SOURCES.txt +2 -0
- datacomparerlibrary-0.843/src/DataComparerLibrary/version.py +0 -3
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/LICENSE.txt +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/pyproject.toml +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/setup.cfg +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/__init__.py +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/datasorter.py +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/delimitertranslator.py +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/fileconverter.py +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/tools.py +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary.egg-info/dependency_links.txt +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary.egg-info/top_level.txt +0 -0
- {datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/test/test1.py +0 -0
{datacomparerlibrary-0.843/src/DataComparerLibrary.egg-info → datacomparerlibrary-0.844}/PKG-INFO
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: DataComparerLibrary
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: For comparing csv-files
|
|
3
|
+
Version: 0.844
|
|
4
|
+
Summary: For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: René Philip Zuijderduijn
|
|
7
7
|
Author-email: datacomparerlibrary@outlook.com
|
|
@@ -15,6 +15,8 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
20
|
Description-Content-Type: text/x-rst
|
|
19
21
|
License-File: LICENSE.txt
|
|
20
22
|
|
|
@@ -106,8 +108,12 @@ The DataComparerLibrary can be used for:
|
|
|
106
108
|
quotechar.
|
|
107
109
|
|
|
108
110
|
|
|
111
|
+
Comparing Data
|
|
112
|
+
--------------
|
|
113
|
+
|
|
114
|
+
|
|
109
115
|
Examples of using the DataComparerLibrary for comparing data in Python
|
|
110
|
-
|
|
116
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
111
117
|
|
|
112
118
|
Below there are some examples how to call the methods of the DataComparerLibrary in Python::
|
|
113
119
|
|
|
@@ -122,7 +128,7 @@ Below there are some examples how to call the methods of the DataComparerLibrary
|
|
|
122
128
|
|
|
123
129
|
|
|
124
130
|
Examples of using the DataComparerLibrary keywords for comparing data in Robot Framework
|
|
125
|
-
|
|
131
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
126
132
|
|
|
127
133
|
Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
|
|
128
134
|
|
|
@@ -146,7 +152,7 @@ Below there are some examples how to call the keywords of the DataComparerLibrar
|
|
|
146
152
|
|
|
147
153
|
|
|
148
154
|
Examples comparing Actual Data with Expected Data
|
|
149
|
-
|
|
155
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
150
156
|
|
|
151
157
|
Below there is an example of actual and expected data with some different cases.
|
|
152
158
|
|
|
@@ -185,6 +191,46 @@ Based on current datetime = 2023-09-06 19:04:00 (example):
|
|
|
185
191
|
+--------------+----------+--------------+---------------------------------+---------+-------------+
|
|
186
192
|
|
|
187
193
|
|
|
194
|
+
Comparing Text
|
|
195
|
+
--------------
|
|
196
|
+
|
|
197
|
+
Examples of using the DataComparerLibrary for comparing text in Python
|
|
198
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
199
|
+
|
|
200
|
+
Below there are some examples how to call the methods of the DataComparerLibrary in Python::
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
a = DataComparer
|
|
204
|
+
a.compare_text_files(self, actual_file, expected_file)
|
|
205
|
+
a.compare_text_variable_with_text_file(self, actual_text_input, expected_file)
|
|
206
|
+
a.compare_text_file_with_text_variable(self, actual_file, expected_text_input)
|
|
207
|
+
a.compare_text_variables(self, actual_text_input, expected_text_input)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Examples of using the DataComparerLibrary keywords for comparing text in Robot Framework
|
|
211
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
212
|
+
|
|
213
|
+
Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
*** Settings ***
|
|
217
|
+
Library DataComparerLibrary
|
|
218
|
+
|
|
219
|
+
*** Test Cases ***
|
|
220
|
+
Testcase_DataComparer
|
|
221
|
+
Examples
|
|
222
|
+
|
|
223
|
+
*** Keywords ***
|
|
224
|
+
Examples
|
|
225
|
+
Run Keyword And Continue On Failure DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
226
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
227
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
228
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
229
|
+
DataComparerLibrary.Compare Text Variable With File ${actual_text_input} C:\\Users\\expected.txt
|
|
230
|
+
DataComparerLibrary.Compare Text File With Text Variable C:\\Users\\actual.txt ${expected_text_input}
|
|
231
|
+
DataComparerLibrary.Compare Text Variables ${actual_text_input} ${expected_text_input}
|
|
232
|
+
|
|
233
|
+
|
|
188
234
|
|
|
189
235
|
DataSorter
|
|
190
236
|
==========
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: DataComparerLibrary
|
|
3
|
-
Version: 0.843
|
|
4
|
-
Summary: For comparing csv-files or 2d-array with csv-file.
|
|
5
|
-
Home-page:
|
|
6
|
-
Author: René Philip Zuijderduijn
|
|
7
|
-
Author-email: datacomparerlibrary@outlook.com
|
|
8
|
-
License: Apache
|
|
9
|
-
Keywords: robotframework testing test-automation datacompare
|
|
10
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
-
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
12
|
-
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Description-Content-Type: text/x-rst
|
|
19
|
-
License-File: LICENSE.txt
|
|
20
|
-
|
|
21
1
|
===================
|
|
22
2
|
DataComparerLibrary
|
|
23
3
|
===================
|
|
@@ -106,8 +86,12 @@ The DataComparerLibrary can be used for:
|
|
|
106
86
|
quotechar.
|
|
107
87
|
|
|
108
88
|
|
|
89
|
+
Comparing Data
|
|
90
|
+
--------------
|
|
91
|
+
|
|
92
|
+
|
|
109
93
|
Examples of using the DataComparerLibrary for comparing data in Python
|
|
110
|
-
|
|
94
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
111
95
|
|
|
112
96
|
Below there are some examples how to call the methods of the DataComparerLibrary in Python::
|
|
113
97
|
|
|
@@ -122,7 +106,7 @@ Below there are some examples how to call the methods of the DataComparerLibrary
|
|
|
122
106
|
|
|
123
107
|
|
|
124
108
|
Examples of using the DataComparerLibrary keywords for comparing data in Robot Framework
|
|
125
|
-
|
|
109
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
126
110
|
|
|
127
111
|
Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
|
|
128
112
|
|
|
@@ -146,7 +130,7 @@ Below there are some examples how to call the keywords of the DataComparerLibrar
|
|
|
146
130
|
|
|
147
131
|
|
|
148
132
|
Examples comparing Actual Data with Expected Data
|
|
149
|
-
|
|
133
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
150
134
|
|
|
151
135
|
Below there is an example of actual and expected data with some different cases.
|
|
152
136
|
|
|
@@ -185,6 +169,46 @@ Based on current datetime = 2023-09-06 19:04:00 (example):
|
|
|
185
169
|
+--------------+----------+--------------+---------------------------------+---------+-------------+
|
|
186
170
|
|
|
187
171
|
|
|
172
|
+
Comparing Text
|
|
173
|
+
--------------
|
|
174
|
+
|
|
175
|
+
Examples of using the DataComparerLibrary for comparing text in Python
|
|
176
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
177
|
+
|
|
178
|
+
Below there are some examples how to call the methods of the DataComparerLibrary in Python::
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
a = DataComparer
|
|
182
|
+
a.compare_text_files(self, actual_file, expected_file)
|
|
183
|
+
a.compare_text_variable_with_text_file(self, actual_text_input, expected_file)
|
|
184
|
+
a.compare_text_file_with_text_variable(self, actual_file, expected_text_input)
|
|
185
|
+
a.compare_text_variables(self, actual_text_input, expected_text_input)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
Examples of using the DataComparerLibrary keywords for comparing text in Robot Framework
|
|
189
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
190
|
+
|
|
191
|
+
Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
*** Settings ***
|
|
195
|
+
Library DataComparerLibrary
|
|
196
|
+
|
|
197
|
+
*** Test Cases ***
|
|
198
|
+
Testcase_DataComparer
|
|
199
|
+
Examples
|
|
200
|
+
|
|
201
|
+
*** Keywords ***
|
|
202
|
+
Examples
|
|
203
|
+
Run Keyword And Continue On Failure DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
204
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
205
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
206
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
207
|
+
DataComparerLibrary.Compare Text Variable With File ${actual_text_input} C:\\Users\\expected.txt
|
|
208
|
+
DataComparerLibrary.Compare Text File With Text Variable C:\\Users\\actual.txt ${expected_text_input}
|
|
209
|
+
DataComparerLibrary.Compare Text Variables ${actual_text_input} ${expected_text_input}
|
|
210
|
+
|
|
211
|
+
|
|
188
212
|
|
|
189
213
|
DataSorter
|
|
190
214
|
==========
|
|
@@ -22,7 +22,7 @@ with open(join(this_directory, 'src', 'DataComparerLibrary', 'version.py')) as f
|
|
|
22
22
|
def main():
|
|
23
23
|
setup(name='DataComparerLibrary',
|
|
24
24
|
version=VERSION,
|
|
25
|
-
description="For comparing csv-files
|
|
25
|
+
description="For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.",
|
|
26
26
|
long_description=README,
|
|
27
27
|
long_description_content_type="text/x-rst",
|
|
28
28
|
url="",
|
|
@@ -38,6 +38,8 @@ def main():
|
|
|
38
38
|
"Programming Language :: Python :: 3.9",
|
|
39
39
|
"Programming Language :: Python :: 3.10",
|
|
40
40
|
"Programming Language :: Python :: 3.11",
|
|
41
|
+
"Programming Language :: Python :: 3.12",
|
|
42
|
+
"Programming Language :: Python :: 3.13",
|
|
41
43
|
],
|
|
42
44
|
keywords='robotframework testing test-automation datacompare',
|
|
43
45
|
package_dir={'': 'src'},
|
|
@@ -1,174 +1,12 @@
|
|
|
1
|
-
# Script for comparing actual data from an output file or a SQL-query with expected data in a file.
|
|
2
|
-
#
|
|
3
|
-
from array import *
|
|
4
|
-
import csv
|
|
5
1
|
import datetime
|
|
6
2
|
import fnmatch
|
|
7
|
-
import os
|
|
8
3
|
import re
|
|
9
|
-
|
|
10
4
|
import dateutil.relativedelta
|
|
11
5
|
|
|
12
|
-
from DataComparerLibrary.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class DataComparer:
|
|
16
|
-
# Situations:
|
|
17
|
-
# Actual txt file versus expected txt file.
|
|
18
|
-
# Actual csv file versus expected csv file.
|
|
19
|
-
# Array with SQL-output expected csv file.
|
|
20
|
-
|
|
21
|
-
def compare_data_2d_array_with_file(self, actual_data, expected_file, delimiter_expected_data=",", quotechar_expected_data='"'):
|
|
22
|
-
if 'actual_data' not in locals():
|
|
23
|
-
raise Exception("Input Actual data unknown.")
|
|
24
|
-
#
|
|
25
|
-
if not os.path.exists(expected_file):
|
|
26
|
-
raise Exception("Input file doesn't exists: ", expected_file)
|
|
27
|
-
#
|
|
28
|
-
print("expected_file: ", expected_file)
|
|
29
|
-
#
|
|
30
|
-
with open(expected_file, mode='rt', encoding='utf-8') as expected_file:
|
|
31
|
-
if len(delimiter_expected_data) == 1:
|
|
32
|
-
expected_data = list(csv.reader(expected_file, delimiter=delimiter_expected_data, quotechar=quotechar_expected_data))
|
|
33
|
-
else:
|
|
34
|
-
expected_data = list(csv.reader((line.replace(delimiter_expected_data, chr(255)) for line in expected_file), delimiter=chr(255), quotechar=quotechar_expected_data))
|
|
35
|
-
#
|
|
36
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def compare_data_file_with_2d_array(self, actual_file, expected_data, delimiter_actual_data=",", quotechar_actual_data='"'):
|
|
40
|
-
if not os.path.exists(actual_file):
|
|
41
|
-
raise Exception("Input file doesn't exists: ", actual_file)
|
|
42
|
-
#
|
|
43
|
-
if 'expected_data' not in locals():
|
|
44
|
-
raise Exception("Input Expected data unknown.")
|
|
45
|
-
#
|
|
46
|
-
print("actual_file: ", actual_file)
|
|
47
|
-
#
|
|
48
|
-
with open(actual_file, mode='rt', encoding='utf-8') as actual_file:
|
|
49
|
-
if len(delimiter_actual_data) == 1:
|
|
50
|
-
actual_data = list(csv.reader(actual_file, delimiter=delimiter_actual_data, quotechar=quotechar_actual_data))
|
|
51
|
-
else:
|
|
52
|
-
actual_data = list(csv.reader((line.replace(delimiter_actual_data, chr(255)) for line in actual_file), delimiter=chr(255), quotechar=quotechar_actual_data))
|
|
53
|
-
#
|
|
54
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def compare_data_2d_arrays(self, actual_data, expected_data):
|
|
58
|
-
if 'actual_data' not in locals():
|
|
59
|
-
raise Exception("Input Actual data unknown.")
|
|
60
|
-
#
|
|
61
|
-
if 'expected_data' not in locals():
|
|
62
|
-
raise Exception("Input Expected data unknown.")
|
|
63
|
-
#
|
|
64
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def compare_data_files(self, actual_file, expected_file, delimiter_actual_data=",", delimiter_expected_data=",", quotechar_actual_data='"', quotechar_expected_data='"'):
|
|
68
|
-
for file in (actual_file, expected_file):
|
|
69
|
-
if not os.path.exists(file):
|
|
70
|
-
raise Exception("Input file doesn't exists: ", file)
|
|
71
|
-
#
|
|
72
|
-
print("actual_file: ", actual_file)
|
|
73
|
-
print("expected_file: ", expected_file)
|
|
74
|
-
#
|
|
75
|
-
with open(actual_file, mode='rt', encoding='utf-8') as actual_file, open(expected_file, mode='rt', encoding='utf-8') as expected_file:
|
|
76
|
-
if len(delimiter_actual_data) == 1:
|
|
77
|
-
actual_data = list(csv.reader(actual_file, delimiter=delimiter_actual_data, quotechar=quotechar_actual_data))
|
|
78
|
-
else:
|
|
79
|
-
actual_data = list(csv.reader((line.replace(delimiter_actual_data, chr(255)) for line in actual_file), delimiter=chr(255), quotechar=quotechar_actual_data))
|
|
80
|
-
#
|
|
81
|
-
if len(delimiter_expected_data) == 1:
|
|
82
|
-
expected_data = list(csv.reader(expected_file, delimiter=delimiter_expected_data, quotechar=quotechar_expected_data))
|
|
83
|
-
else:
|
|
84
|
-
expected_data = list(csv.reader((line.replace(delimiter_expected_data, chr(255)) for line in expected_file), delimiter=chr(255), quotechar=quotechar_expected_data))
|
|
85
|
-
#
|
|
86
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def compare_text_variable_with_text_file(self, actual_text, expected_file):
|
|
90
|
-
if 'actual_data' not in locals():
|
|
91
|
-
raise Exception("Input Actual data unknown.")
|
|
92
|
-
#
|
|
93
|
-
if not os.path.exists(expected_file):
|
|
94
|
-
raise Exception("Input file doesn't exists: ", expected_file)
|
|
95
|
-
#
|
|
96
|
-
print("expected_file: ", expected_file)
|
|
97
|
-
#
|
|
98
|
-
actual_data = []
|
|
99
|
-
for line in actual_text.split('\n'):
|
|
100
|
-
actual_data.append(line.strip('\n').split(chr(255)))
|
|
101
|
-
#
|
|
102
|
-
with open(expected_file, mode='rt', encoding='utf-8') as expected_file:
|
|
103
|
-
expected_data = []
|
|
104
|
-
for line in expected_file.readlines():
|
|
105
|
-
expected_data.append(line.strip('\n').split(chr(255)))
|
|
106
|
-
#
|
|
107
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
6
|
+
from DataComparerLibrary.report import Report
|
|
108
7
|
|
|
109
|
-
|
|
110
|
-
def
|
|
111
|
-
if not os.path.exists(actual_file):
|
|
112
|
-
raise Exception("Input file doesn't exists: ", actual_file)
|
|
113
|
-
#
|
|
114
|
-
if 'expected_text' not in locals():
|
|
115
|
-
raise Exception("Input Expected data unknown.")
|
|
116
|
-
#
|
|
117
|
-
print("actual_file: ", actual_file)
|
|
118
|
-
#
|
|
119
|
-
with open(actual_file, mode='rt', encoding='utf-8') as actual_file:
|
|
120
|
-
actual_data = []
|
|
121
|
-
for line in actual_file.readlines():
|
|
122
|
-
actual_data.append(line.strip('\n').split(chr(255)))
|
|
123
|
-
#
|
|
124
|
-
expected_data = []
|
|
125
|
-
for line in expected_text.split('\n'):
|
|
126
|
-
expected_data.append(line.strip('\n').split(chr(255)))
|
|
127
|
-
#
|
|
128
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def compare_text_variables(self, actual_text, expected_text):
|
|
132
|
-
if 'actual_data' not in locals():
|
|
133
|
-
raise Exception("Input Actual data unknown.")
|
|
134
|
-
#
|
|
135
|
-
if 'expected_data' not in locals():
|
|
136
|
-
raise Exception("Input Expected data unknown.")
|
|
137
|
-
#
|
|
138
|
-
actual_data = []
|
|
139
|
-
for line in actual_text.split('\n'):
|
|
140
|
-
actual_data.append(line.strip('\n').split(chr(255)))
|
|
141
|
-
#
|
|
142
|
-
expected_data = []
|
|
143
|
-
for line in expected_text.split('\n'):
|
|
144
|
-
expected_data.append(line.strip('\n').split(chr(255)))
|
|
145
|
-
#
|
|
146
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def compare_text_files(self, actual_file, expected_file):
|
|
150
|
-
for file in (actual_file, expected_file):
|
|
151
|
-
if not os.path.exists(file):
|
|
152
|
-
raise Exception("Input file doesn't exists: ", file)
|
|
153
|
-
#
|
|
154
|
-
print("actual_file: ", actual_file)
|
|
155
|
-
print("expected_file: ", expected_file)
|
|
156
|
-
#
|
|
157
|
-
with open(actual_file, mode='rt', encoding='utf-8') as actual_file, open(expected_file, mode='rt', encoding='utf-8') as expected_file:
|
|
158
|
-
actual_data = []
|
|
159
|
-
for line in actual_file.readlines():
|
|
160
|
-
actual_data.append(line.strip('\n').split(chr(255)))
|
|
161
|
-
# print(actual_data)
|
|
162
|
-
#
|
|
163
|
-
expected_data = []
|
|
164
|
-
for line in expected_file.readlines():
|
|
165
|
-
expected_data.append(line.strip('\n').split(chr(255)))
|
|
166
|
-
# print(expected_data)
|
|
167
|
-
#
|
|
168
|
-
DataComparer.__compare_data(self, actual_data, expected_data)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def __compare_data(self, actual_data, expected_data_including_templates):
|
|
8
|
+
class ArrayComparer:
|
|
9
|
+
def compare_data(self, actual_data, expected_data_including_templates, template_literals_dict):
|
|
172
10
|
difference_found = False
|
|
173
11
|
#
|
|
174
12
|
if actual_data and type(actual_data[0]) is not list: # only a single row
|
|
@@ -182,8 +20,8 @@ class DataComparer:
|
|
|
182
20
|
|
|
183
21
|
number_of_rows = number_of_rows_actual_data if (number_of_rows_actual_data >= number_of_rows_expected_data) else number_of_rows_expected_data
|
|
184
22
|
|
|
185
|
-
|
|
186
|
-
|
|
23
|
+
Report.show_2d_array(self, "Actual data", actual_data, 20)
|
|
24
|
+
Report.show_2d_array(self, "Expected data", expected_data_including_templates, 20)
|
|
187
25
|
|
|
188
26
|
print()
|
|
189
27
|
print("=== Overview differences between actual and expected data")
|
|
@@ -193,17 +31,17 @@ class DataComparer:
|
|
|
193
31
|
if row_nr >= number_of_rows_actual_data:
|
|
194
32
|
difference_found = True
|
|
195
33
|
if len(expected_data_including_templates[row_nr]) == 0:
|
|
196
|
-
|
|
34
|
+
Report.show_comparation_result(self, row_nr, 0, "", "", "Row actual data is not PRESENT. Row expected data is EMPTY.")
|
|
197
35
|
else:
|
|
198
|
-
|
|
36
|
+
Report.show_comparation_result(self, row_nr, 0, "", expected_data_including_templates[row_nr][0], "Row actual data is not PRESENT.")
|
|
199
37
|
continue
|
|
200
38
|
#
|
|
201
39
|
if row_nr >= number_of_rows_expected_data:
|
|
202
40
|
difference_found = True
|
|
203
41
|
if len(actual_data[row_nr]) == 0:
|
|
204
|
-
|
|
42
|
+
Report.show_comparation_result(self, row_nr, 0, "", "", "Row actual data is EMPTY. Row expected data is not PRESENT.")
|
|
205
43
|
else:
|
|
206
|
-
|
|
44
|
+
Report.show_comparation_result(self, row_nr, 0, actual_data[row_nr][0], "", "Row expected data is not PRESENT.")
|
|
207
45
|
continue
|
|
208
46
|
#
|
|
209
47
|
number_of_columns_actual_data = len(actual_data[row_nr])
|
|
@@ -218,23 +56,35 @@ class DataComparer:
|
|
|
218
56
|
#
|
|
219
57
|
if column_nr >= number_of_columns_actual_data:
|
|
220
58
|
difference_found = True
|
|
221
|
-
|
|
59
|
+
Report.show_comparation_result(self, row_nr, column_nr, "", expected_data_including_templates[row_nr][column_nr], "Column actual data is not PRESENT.")
|
|
222
60
|
continue
|
|
223
61
|
#
|
|
224
62
|
if column_nr >= number_of_columns_expected_data:
|
|
225
63
|
difference_found = True
|
|
226
|
-
|
|
64
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], "", "Column expected data is not PRESENT.")
|
|
227
65
|
continue
|
|
228
66
|
#
|
|
229
67
|
if actual_data[row_nr][column_nr] != expected_data_including_templates[row_nr][column_nr]:
|
|
68
|
+
# Replace literal templates with fixed external strings.
|
|
69
|
+
if template_literals_dict:
|
|
70
|
+
for i in range(0, len(template_literals_dict)):
|
|
71
|
+
# key = list(template_literals_dict.keys())[i]
|
|
72
|
+
# value = list(template_literals_dict.values())[i]
|
|
73
|
+
# print("key: ", key)
|
|
74
|
+
# print("value: ", value)
|
|
75
|
+
expected_data_including_templates[row_nr][column_nr] = expected_data_including_templates[row_nr][column_nr].replace(list(template_literals_dict.keys())[i], list(template_literals_dict.values())[i])
|
|
76
|
+
# print("actual_data[row_nr][column_nr]: \n", actual_data[row_nr][column_nr])
|
|
77
|
+
# print("expected_data_including_templates[row_nr][column_nr]: \n", expected_data_including_templates[row_nr][column_nr])
|
|
78
|
+
|
|
79
|
+
|
|
230
80
|
# Verify if difference is a matter of string versus integer representation.
|
|
231
81
|
if str(actual_data[row_nr][column_nr]) == str(expected_data_including_templates[row_nr][column_nr]):
|
|
232
82
|
if isinstance(actual_data[row_nr][column_nr], int) and isinstance(expected_data_including_templates[row_nr][column_nr], str):
|
|
233
83
|
difference_found = True
|
|
234
|
-
|
|
84
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "There is a difference between actual and expected data. Actual data is an integer while expected data is a string.")
|
|
235
85
|
elif isinstance(actual_data[row_nr][column_nr], str) and isinstance(expected_data_including_templates[row_nr][column_nr], int):
|
|
236
86
|
difference_found = True
|
|
237
|
-
|
|
87
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "There is a difference between actual and expected data. Actual data is a string while expected data is an integer.")
|
|
238
88
|
continue
|
|
239
89
|
#
|
|
240
90
|
# If data in actual and expected field doesn't match, check if a template has been used in expected data.
|
|
@@ -243,13 +93,13 @@ class DataComparer:
|
|
|
243
93
|
if not actual_data[row_nr][column_nr]:
|
|
244
94
|
# No data is present in actual data field.
|
|
245
95
|
difference_found = True
|
|
246
|
-
|
|
96
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "Actual data field is not PRESENT")
|
|
247
97
|
#
|
|
248
98
|
case "{EMPTY}":
|
|
249
99
|
if actual_data[row_nr][column_nr]:
|
|
250
100
|
# Actual data field is not empty.
|
|
251
101
|
difference_found = True
|
|
252
|
-
|
|
102
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "Actual data field is not EMPTY")
|
|
253
103
|
#
|
|
254
104
|
case "{INTEGER}":
|
|
255
105
|
if isinstance(actual_data[row_nr][column_nr], int):
|
|
@@ -260,7 +110,7 @@ class DataComparer:
|
|
|
260
110
|
if not actual_data[row_nr][column_nr].isdigit():
|
|
261
111
|
# Not positive integer field.
|
|
262
112
|
difference_found = True
|
|
263
|
-
|
|
113
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "Actual data field is not INTEGER.")
|
|
264
114
|
#
|
|
265
115
|
case "{SKIP}":
|
|
266
116
|
pass
|
|
@@ -292,41 +142,41 @@ class DataComparer:
|
|
|
292
142
|
matches = ["{NOW():", "{NOW()+", "{NOW()-"]
|
|
293
143
|
if all([x not in expected_data_including_templates[row_nr][column_nr].upper() for x in matches]):
|
|
294
144
|
difference_found = True
|
|
295
|
-
|
|
145
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "NOW() has been found in expected data field, but format is incorrect.")
|
|
296
146
|
continue
|
|
297
147
|
#
|
|
298
|
-
expected_data =
|
|
148
|
+
expected_data = ArrayComparer.__replace_date_template_in_expected_data(self, expected_data_including_date_template)
|
|
299
149
|
#
|
|
300
150
|
if expected_data == -1:
|
|
301
151
|
difference_found = True
|
|
302
|
-
|
|
152
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "NOW() has been found in expected data field, but format is incorrect.")
|
|
303
153
|
else:
|
|
304
154
|
if not fnmatch.fnmatch(actual_data[row_nr][column_nr], expected_data):
|
|
305
155
|
# No match despite using of wildcard(s).
|
|
306
156
|
difference_found = True
|
|
307
|
-
|
|
308
|
-
|
|
157
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "Date template format displayed. See also next message line.")
|
|
158
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data, "There is a difference between actual and expected data.")
|
|
309
159
|
continue
|
|
310
160
|
#
|
|
311
161
|
elif "{NOT(" in expected_data_including_templates[row_nr][column_nr].upper():
|
|
312
162
|
try:
|
|
313
|
-
unwanted_expected_data =
|
|
163
|
+
unwanted_expected_data = ArrayComparer.__get_unwanted_expected_data(self, expected_data_including_date_template)
|
|
314
164
|
#
|
|
315
165
|
if actual_data[row_nr][column_nr] == unwanted_expected_data:
|
|
316
166
|
# Unwanted match.
|
|
317
167
|
difference_found = True
|
|
318
|
-
|
|
319
|
-
|
|
168
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "NOT() template format displayed. See also next message line.")
|
|
169
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], unwanted_expected_data, "Actual and expected data are equal. However actual data should NOT be equal to the expected data!!!")
|
|
320
170
|
except Exception as exception_message:
|
|
321
171
|
# print(f"An exception occurred: {exception_message}")
|
|
322
172
|
difference_found = True
|
|
323
|
-
|
|
173
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "NOT() has been found in expected data field, but format is incorrect.")
|
|
324
174
|
#
|
|
325
175
|
else:
|
|
326
176
|
if not skip_exception_rule_used:
|
|
327
177
|
# No exceptions.
|
|
328
178
|
difference_found = True
|
|
329
|
-
|
|
179
|
+
Report.show_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "There is a difference between actual and expected data. No exception rule has been used.")
|
|
330
180
|
#
|
|
331
181
|
if difference_found:
|
|
332
182
|
print("\n\n\n")
|
|
@@ -347,7 +197,7 @@ class DataComparer:
|
|
|
347
197
|
# Close brace of TODAY has been found.
|
|
348
198
|
#
|
|
349
199
|
expected_datetime_template_string = expected_data_field_including_date_template[position_open_brace_today_text:position_close_brace_today_text + 1]
|
|
350
|
-
expected_datetime_string =
|
|
200
|
+
expected_datetime_string = ArrayComparer.__convert_datetime_template_to_datetime(self, expected_datetime_template_string)
|
|
351
201
|
#
|
|
352
202
|
if expected_datetime_string == -1:
|
|
353
203
|
return -1
|
|
@@ -380,7 +230,7 @@ class DataComparer:
|
|
|
380
230
|
else:
|
|
381
231
|
# Adjust date time based on current date time.
|
|
382
232
|
relative_datetime_template_string = template_datetime_string_splitted[0].replace('{NOW()', '')
|
|
383
|
-
relative_datetime =
|
|
233
|
+
relative_datetime = ArrayComparer.__convert_relative_datetime_template_to_relative_datetime(self, relative_datetime_template_string[1:len(relative_datetime_template_string)])
|
|
384
234
|
if relative_datetime == -1:
|
|
385
235
|
return -1
|
|
386
236
|
else:
|
|
@@ -433,29 +283,6 @@ class DataComparer:
|
|
|
433
283
|
return -1
|
|
434
284
|
|
|
435
285
|
|
|
436
|
-
def __print_2d_array(self, title, reader_file_list, column_width):
|
|
437
|
-
max_length_title = 30
|
|
438
|
-
title = title[0:(max_length_title - 1)]
|
|
439
|
-
length_title = len(title)
|
|
440
|
-
print("=== ", title, " ", end="")
|
|
441
|
-
print("=" * (max_length_title - length_title))
|
|
442
|
-
print()
|
|
443
|
-
#
|
|
444
|
-
for row in reader_file_list:
|
|
445
|
-
for cell_value in row:
|
|
446
|
-
#if isinstance(cell_value, str):
|
|
447
|
-
if isinstance(cell_value, str) or isinstance(cell_value, int):
|
|
448
|
-
#print('{val:{fill}{width}}'.format(val=cell_value, fill='', width=column_width), end=" ")
|
|
449
|
-
print('{val:{fill}{width}}'.format(val=cell_value, fill='', width=column_width, left_aligned=True), end=" ")
|
|
450
|
-
|
|
451
|
-
print()
|
|
452
|
-
print()
|
|
453
|
-
print()
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
def __print_comparation_result(self, row_number, column_number, actual_data, expected_data, error_message):
|
|
457
|
-
print("Row: ", row_number + 1, " Column: ", column_number + 1, " => Actual data: ", actual_data, " Expected data: ", expected_data, " Remark / Error message: ", error_message)
|
|
458
|
-
|
|
459
286
|
|
|
460
287
|
def __get_unwanted_expected_data(self, expected_data_field_including_date_template):
|
|
461
288
|
position_open_brace = expected_data_field_including_date_template.find("{NOT(")
|
|
@@ -471,7 +298,7 @@ class DataComparer:
|
|
|
471
298
|
#
|
|
472
299
|
unwanted_expected_data = expected_data_field_including_date_template[position_open_brace+5:position_close_brace]
|
|
473
300
|
#
|
|
474
|
-
if
|
|
301
|
+
if ArrayComparer.is_integer(self, unwanted_expected_data):
|
|
475
302
|
unwanted_expected_data = int(unwanted_expected_data)
|
|
476
303
|
return unwanted_expected_data
|
|
477
304
|
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Script for comparing csv-files, 2d-array with a csv-file or 2d-arrays and for comparing text-files, text variable with a text-file or text variables.
|
|
2
|
+
#
|
|
3
|
+
import csv
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from DataComparerLibrary.arraycomparer import ArrayComparer
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DataComparer:
|
|
10
|
+
def compare_data_2d_array_with_file(self, actual_data, expected_file, delimiter_expected_data=",", quotechar_expected_data='"', template_literals_dict=None):
|
|
11
|
+
self.__check_if_actual_data_is_present(actual_data)
|
|
12
|
+
self.__check_if_expected_file_is_present(expected_file)
|
|
13
|
+
#
|
|
14
|
+
expected_data = self.__open_csv_input_file(expected_file, delimiter_expected_data, quotechar_expected_data)
|
|
15
|
+
#
|
|
16
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def compare_data_file_with_2d_array(self, actual_file, expected_data, delimiter_actual_data=",", quotechar_actual_data='"', template_literals_dict=None):
|
|
20
|
+
self.__check_if_actual_file_is_present(actual_file)
|
|
21
|
+
self.__check_if_expected_data_is_present(expected_data)
|
|
22
|
+
#
|
|
23
|
+
actual_data = self.__open_csv_input_file(actual_file, delimiter_actual_data, quotechar_actual_data)
|
|
24
|
+
#
|
|
25
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def compare_data_2d_arrays(self, actual_data, expected_data, template_literals_dict=None):
|
|
29
|
+
self.__check_if_actual_data_is_present(actual_data)
|
|
30
|
+
self.__check_if_expected_data_is_present(expected_data)
|
|
31
|
+
#
|
|
32
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def compare_data_files(self, actual_file, expected_file, delimiter_actual_data=",", delimiter_expected_data=",", quotechar_actual_data='"', quotechar_expected_data='"', template_literals_dict=None):
|
|
36
|
+
self.__check_if_actual_file_is_present(actual_file)
|
|
37
|
+
self.__check_if_expected_file_is_present(expected_file)
|
|
38
|
+
#
|
|
39
|
+
actual_data = self.__open_csv_input_file(actual_file, delimiter_actual_data, quotechar_actual_data)
|
|
40
|
+
expected_data = self.__open_csv_input_file(expected_file, delimiter_expected_data, quotechar_expected_data)
|
|
41
|
+
#
|
|
42
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def compare_text_variable_with_text_file(self, actual_text, expected_file, template_literals_dict=None):
|
|
46
|
+
self.__check_if_actual_data_is_present(actual_text)
|
|
47
|
+
self.__check_if_expected_file_is_present(expected_file)
|
|
48
|
+
#
|
|
49
|
+
actual_data = self.__split_text_into_textline_array(actual_text)
|
|
50
|
+
expected_data = self.__split_textfile_into_textline_array(expected_file)
|
|
51
|
+
#
|
|
52
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def compare_text_file_with_text_variable(self, actual_file, expected_text, template_literals_dict=None):
|
|
56
|
+
self.__check_if_actual_file_is_present(actual_file)
|
|
57
|
+
self.__check_if_expected_data_is_present(expected_text)
|
|
58
|
+
#
|
|
59
|
+
actual_data = self.__split_textfile_into_textline_array(actual_file)
|
|
60
|
+
expected_data = self.__split_text_into_textline_array(expected_text)
|
|
61
|
+
#
|
|
62
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def compare_text_variables(self, actual_text, expected_text, template_literals_dict=None):
|
|
66
|
+
self.__check_if_actual_data_is_present(actual_text)
|
|
67
|
+
self.__check_if_expected_data_is_present(expected_text)
|
|
68
|
+
#
|
|
69
|
+
actual_data = self.__split_text_into_textline_array(actual_text)
|
|
70
|
+
expected_data = self.__split_text_into_textline_array(expected_text)
|
|
71
|
+
#
|
|
72
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def compare_text_files(self, actual_file, expected_file, template_literals_dict=None):
|
|
76
|
+
self.__check_if_actual_file_is_present(actual_file)
|
|
77
|
+
self.__check_if_expected_file_is_present(expected_file)
|
|
78
|
+
#
|
|
79
|
+
actual_data = self.__split_textfile_into_textline_array(actual_file)
|
|
80
|
+
expected_data = self.__split_textfile_into_textline_array(expected_file)
|
|
81
|
+
#
|
|
82
|
+
ArrayComparer.compare_data(self, actual_data, expected_data, template_literals_dict)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def __check_if_actual_data_is_present(self, data):
|
|
87
|
+
if data == None:
|
|
88
|
+
raise Exception("Actual Input data unknown.")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def __check_if_expected_data_is_present(self, data):
|
|
92
|
+
if data == None:
|
|
93
|
+
raise Exception("Expected Input data unknown.")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def __check_if_actual_file_is_present(self, file):
|
|
97
|
+
if os.path.exists(file):
|
|
98
|
+
print("actual_file: ", file)
|
|
99
|
+
else:
|
|
100
|
+
raise Exception("Actual Input file doesn't exists: ", file)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def __check_if_expected_file_is_present(self, file):
|
|
104
|
+
if os.path.exists(file):
|
|
105
|
+
print("expected_file: ", file)
|
|
106
|
+
else:
|
|
107
|
+
raise Exception("Expected Input file doesn't exists: ", file)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def __open_csv_input_file(self, input_file, delimiter_data=",", quotechar_data='"'):
|
|
111
|
+
with open(input_file, mode='rt', encoding='utf-8') as input_file:
|
|
112
|
+
if len(delimiter_data) == 1:
|
|
113
|
+
data = list(csv.reader(input_file, delimiter=delimiter_data, quotechar=quotechar_data))
|
|
114
|
+
else:
|
|
115
|
+
data = list(csv.reader((line.replace(delimiter_data, chr(255)) for line in input_file), delimiter=chr(255), quotechar=quotechar_data))
|
|
116
|
+
#
|
|
117
|
+
return data
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def __split_text_into_textline_array(self, text):
|
|
121
|
+
data = []
|
|
122
|
+
for line in text.split('\n'):
|
|
123
|
+
data.append(line.strip('\n').split(chr(255)))
|
|
124
|
+
#
|
|
125
|
+
return data
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def __split_textfile_into_textline_array(self, input_file):
|
|
129
|
+
with open(input_file, mode='rt', encoding='utf-8') as input_file:
|
|
130
|
+
data = []
|
|
131
|
+
for line in input_file.readlines():
|
|
132
|
+
data.append(line.strip('\n').split(chr(255)))
|
|
133
|
+
#
|
|
134
|
+
return data
|
|
135
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class Report:
|
|
2
|
+
def show_2d_array(self, title, reader_file_list, column_width):
|
|
3
|
+
max_length_title = 30
|
|
4
|
+
title = title[0:(max_length_title - 1)]
|
|
5
|
+
length_title = len(title)
|
|
6
|
+
print("=== ", title, " ", end="")
|
|
7
|
+
print("=" * (max_length_title - length_title))
|
|
8
|
+
print()
|
|
9
|
+
#
|
|
10
|
+
for row in reader_file_list:
|
|
11
|
+
for cell_value in row:
|
|
12
|
+
#if isinstance(cell_value, str):
|
|
13
|
+
if isinstance(cell_value, str) or isinstance(cell_value, int):
|
|
14
|
+
#print('{val:{fill}{width}}'.format(val=cell_value, fill='', width=column_width), end=" ")
|
|
15
|
+
print('{val:{fill}{width}}'.format(val=cell_value, fill='', width=column_width, left_aligned=True), end=" ")
|
|
16
|
+
|
|
17
|
+
print()
|
|
18
|
+
print()
|
|
19
|
+
print()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def show_comparation_result(self, row_number, column_number, actual_data, expected_data, error_message):
|
|
23
|
+
print("Row: ", row_number + 1, " Column: ", column_number + 1, " => Actual data: ", actual_data, " Expected data: ", expected_data, " Remark / Error message: ", error_message)
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: DataComparerLibrary
|
|
3
|
+
Version: 0.844
|
|
4
|
+
Summary: For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: René Philip Zuijderduijn
|
|
7
|
+
Author-email: datacomparerlibrary@outlook.com
|
|
8
|
+
License: Apache
|
|
9
|
+
Keywords: robotframework testing test-automation datacompare
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Description-Content-Type: text/x-rst
|
|
21
|
+
License-File: LICENSE.txt
|
|
22
|
+
|
|
1
23
|
===================
|
|
2
24
|
DataComparerLibrary
|
|
3
25
|
===================
|
|
@@ -86,8 +108,12 @@ The DataComparerLibrary can be used for:
|
|
|
86
108
|
quotechar.
|
|
87
109
|
|
|
88
110
|
|
|
111
|
+
Comparing Data
|
|
112
|
+
--------------
|
|
113
|
+
|
|
114
|
+
|
|
89
115
|
Examples of using the DataComparerLibrary for comparing data in Python
|
|
90
|
-
|
|
116
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
91
117
|
|
|
92
118
|
Below there are some examples how to call the methods of the DataComparerLibrary in Python::
|
|
93
119
|
|
|
@@ -102,7 +128,7 @@ Below there are some examples how to call the methods of the DataComparerLibrary
|
|
|
102
128
|
|
|
103
129
|
|
|
104
130
|
Examples of using the DataComparerLibrary keywords for comparing data in Robot Framework
|
|
105
|
-
|
|
131
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
106
132
|
|
|
107
133
|
Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
|
|
108
134
|
|
|
@@ -126,7 +152,7 @@ Below there are some examples how to call the keywords of the DataComparerLibrar
|
|
|
126
152
|
|
|
127
153
|
|
|
128
154
|
Examples comparing Actual Data with Expected Data
|
|
129
|
-
|
|
155
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
130
156
|
|
|
131
157
|
Below there is an example of actual and expected data with some different cases.
|
|
132
158
|
|
|
@@ -165,6 +191,46 @@ Based on current datetime = 2023-09-06 19:04:00 (example):
|
|
|
165
191
|
+--------------+----------+--------------+---------------------------------+---------+-------------+
|
|
166
192
|
|
|
167
193
|
|
|
194
|
+
Comparing Text
|
|
195
|
+
--------------
|
|
196
|
+
|
|
197
|
+
Examples of using the DataComparerLibrary for comparing text in Python
|
|
198
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
199
|
+
|
|
200
|
+
Below there are some examples how to call the methods of the DataComparerLibrary in Python::
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
a = DataComparer
|
|
204
|
+
a.compare_text_files(self, actual_file, expected_file)
|
|
205
|
+
a.compare_text_variable_with_text_file(self, actual_text_input, expected_file)
|
|
206
|
+
a.compare_text_file_with_text_variable(self, actual_file, expected_text_input)
|
|
207
|
+
a.compare_text_variables(self, actual_text_input, expected_text_input)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Examples of using the DataComparerLibrary keywords for comparing text in Robot Framework
|
|
211
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
212
|
+
|
|
213
|
+
Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
*** Settings ***
|
|
217
|
+
Library DataComparerLibrary
|
|
218
|
+
|
|
219
|
+
*** Test Cases ***
|
|
220
|
+
Testcase_DataComparer
|
|
221
|
+
Examples
|
|
222
|
+
|
|
223
|
+
*** Keywords ***
|
|
224
|
+
Examples
|
|
225
|
+
Run Keyword And Continue On Failure DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
226
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
227
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
228
|
+
DataComparerLibrary.Compare Text Files C:\\Users\\actual.txt C:\\Users\\expected.txt
|
|
229
|
+
DataComparerLibrary.Compare Text Variable With File ${actual_text_input} C:\\Users\\expected.txt
|
|
230
|
+
DataComparerLibrary.Compare Text File With Text Variable C:\\Users\\actual.txt ${expected_text_input}
|
|
231
|
+
DataComparerLibrary.Compare Text Variables ${actual_text_input} ${expected_text_input}
|
|
232
|
+
|
|
233
|
+
|
|
168
234
|
|
|
169
235
|
DataSorter
|
|
170
236
|
==========
|
{datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary.egg-info/SOURCES.txt
RENAMED
|
@@ -3,10 +3,12 @@ README.rst
|
|
|
3
3
|
pyproject.toml
|
|
4
4
|
setup.py
|
|
5
5
|
src/DataComparerLibrary/__init__.py
|
|
6
|
+
src/DataComparerLibrary/arraycomparer.py
|
|
6
7
|
src/DataComparerLibrary/datacomparer.py
|
|
7
8
|
src/DataComparerLibrary/datasorter.py
|
|
8
9
|
src/DataComparerLibrary/delimitertranslator.py
|
|
9
10
|
src/DataComparerLibrary/fileconverter.py
|
|
11
|
+
src/DataComparerLibrary/report.py
|
|
10
12
|
src/DataComparerLibrary/tools.py
|
|
11
13
|
src/DataComparerLibrary/version.py
|
|
12
14
|
src/DataComparerLibrary.egg-info/PKG-INFO
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/datasorter.py
RENAMED
|
File without changes
|
|
File without changes
|
{datacomparerlibrary-0.843 → datacomparerlibrary-0.844}/src/DataComparerLibrary/fileconverter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|