4
4
import string
5
5
import pytest
6
6
7
- import canmatrix .dbc
7
+ import canmatrix .formats . dbc
8
8
9
9
10
10
def test_long_signal_name_imports ():
@@ -17,7 +17,7 @@ def test_long_signal_name_imports():
17
17
BA_ "SystemSignalLongSymbol" SG_ 1 someShortenedDummyName "{}";
18
18
''' ).format (long_signal_name ).encode ('utf-8' ))
19
19
20
- matrix = canmatrix .dbc .load (dbc )
20
+ matrix = canmatrix .formats . dbc .load (dbc )
21
21
22
22
assert matrix .frames [0 ].signals [0 ].name == long_signal_name
23
23
outdbc = io .BytesIO ()
@@ -38,19 +38,19 @@ def test_long_signal_name_imports():
38
38
39
39
def test_create_define ():
40
40
defaults = {}
41
- test_string = canmatrix .dbc .create_define ("my_data_type" , canmatrix .Define ('ENUM "A","B"' ), "BA_" , defaults )
41
+ test_string = canmatrix .formats . dbc .create_define ("my_data_type" , canmatrix .Define ('ENUM "A","B"' ), "BA_" , defaults )
42
42
assert test_string == 'BA_DEF_ BA_ "my_data_type" ENUM "A","B";\n '
43
43
44
44
45
45
def test_create_attribute_string ():
46
- test_string = canmatrix .dbc .create_attribute_string ("my_attribute" , "BO_" , "name" , "value" , True )
46
+ test_string = canmatrix .formats . dbc .create_attribute_string ("my_attribute" , "BO_" , "name" , "value" , True )
47
47
assert test_string == 'BA_ "my_attribute" BO_ name "value";\n '
48
- test_string = canmatrix .dbc .create_attribute_string ("my_attribute" , "BO_" , "name" , 1.23 , False )
48
+ test_string = canmatrix .formats . dbc .create_attribute_string ("my_attribute" , "BO_" , "name" , 1.23 , False )
49
49
assert test_string == 'BA_ "my_attribute" BO_ name 1.23;\n '
50
50
51
51
52
52
def test_create_comment_string ():
53
- test_string = canmatrix .dbc .create_comment_string ("BO_" , "ident" , "some comment" , "utf8" , "utf8" )
53
+ test_string = canmatrix .formats . dbc .create_comment_string ("BO_" , "ident" , "some comment" , "utf8" , "utf8" )
54
54
assert test_string == b'CM_ BO_ ident "some comment";\n '
55
55
56
56
@@ -64,7 +64,7 @@ def test_long_frame_name_imports():
64
64
BA_ "SystemMessageLongSymbol" BO_ 1 "{}";
65
65
''' ).format (long_frame_name ).encode ('utf-8' ))
66
66
67
- matrix = canmatrix .dbc .load (dbc )
67
+ matrix = canmatrix .formats . dbc .load (dbc )
68
68
long_name_found = False
69
69
name_found = False
70
70
@@ -93,7 +93,7 @@ def test_long_ecu_name_imports():
93
93
BA_ "SystemNodeLongSymbol" BU_ SoMEShortenedEcuName "{}";
94
94
''' ).format (long_ecu_name ).encode ('utf-8' ))
95
95
96
- matrix = canmatrix .dbc .load (dbc )
96
+ matrix = canmatrix .formats . dbc .load (dbc )
97
97
long_name_found = False
98
98
name_found = False
99
99
@@ -123,7 +123,7 @@ def test_long_envvar_name_imports():
123
123
BA_ "SystemEnvVarLongSymbol" EV_ someShortendEnvVar "{}";
124
124
''' ).format (long_envvar_name ).encode ('utf-8' ))
125
125
126
- matrix = canmatrix .dbc .load (dbc )
126
+ matrix = canmatrix .formats . dbc .load (dbc )
127
127
128
128
assert list (matrix .env_vars )[0 ] == long_envvar_name
129
129
outdbc = io .BytesIO ()
@@ -155,7 +155,7 @@ def test_enum_with_comma():
155
155
BA_DEF_DEF_ "example3" ",";
156
156
BA_DEF_DEF_ "example4" ",";
157
157
''' ).encode ('utf-8' ))
158
- matrix = canmatrix .dbc .load (dbc , dbcImportEncoding = "utf8" )
158
+ matrix = canmatrix .formats . dbc .load (dbc , dbcImportEncoding = "utf8" )
159
159
160
160
assert matrix .frame_defines [u'example1' ].values == ["Val 1" , "" , "" ] + list (" '()[]/-|{};:<>.?!@#$%^&=`~" )
161
161
assert matrix .signal_defines [u'example2' ].values == ['Val1' , ',' ]
@@ -173,7 +173,7 @@ def test_enum_with_special_character(character):
173
173
dbc = io .BytesIO (textwrap .dedent (u'''\
174
174
BA_DEF_ BO_ "example1" ENUM "Val 1","{}";
175
175
''' ).format (character [0 ]).encode ('utf-8' ))
176
- matrix = canmatrix .dbc .load (dbc , dbcImportEncoding = "utf8" )
176
+ matrix = canmatrix .formats . dbc .load (dbc , dbcImportEncoding = "utf8" )
177
177
assert matrix .frame_defines [u'example1' ].values == ["Val 1" , character [0 ]]
178
178
179
179
@@ -184,13 +184,13 @@ def test_export_of_unknown_defines():
184
184
db .add_frame_defines ("Sendable" , 'BOOL False True' )
185
185
for (dataType , define ) in db .frame_defines .items ():
186
186
orig_definition = define .definition
187
- canmatrix .dbc .check_define (define )
187
+ canmatrix .formats . dbc .check_define (define )
188
188
assert orig_definition != define .definition
189
189
190
190
db .add_signal_defines ("LongName" , 'STR' )
191
191
for (dataType , define ) in db .signal_defines .items ():
192
192
orig_definition = define .definition
193
- canmatrix .dbc .check_define (define )
193
+ canmatrix .formats . dbc .check_define (define )
194
194
assert orig_definition != define .definition
195
195
frame = canmatrix .Frame ("someFrame" )
196
196
signal = canmatrix .Signal ("SomeSignal" )
@@ -201,13 +201,13 @@ def test_export_of_unknown_defines():
201
201
db .add_ecu_defines ("someName" , 'STRING' )
202
202
for (dataType , define ) in db .ecu_defines .items ():
203
203
orig_definition = define .definition
204
- canmatrix .dbc .check_define (define )
204
+ canmatrix .formats . dbc .check_define (define )
205
205
assert orig_definition == define .definition
206
206
207
207
db .add_global_defines ("someGlobaName" , 'BOOL' )
208
208
for (dataType , define ) in db .global_defines .items ():
209
209
orig_definition = define .definition
210
- canmatrix .dbc .check_define (define )
210
+ canmatrix .formats . dbc .check_define (define )
211
211
assert orig_definition != define .definition
212
212
213
213
outdbc = io .BytesIO ()
0 commit comments