45
45
from jsonref import JsonRef
46
46
import pytest
47
47
48
- from flattentool .input import SpreadsheetInput , convert_type , WITH_CELLS
48
+ from flattentool .input import SpreadsheetInput , convert_type
49
49
from flattentool .tests .test_init import original_cell_and_row_locations , original_headings
50
50
from flattentool .schema import SchemaParser
51
+ from flattentool .exceptions import DataErrorWarning
51
52
52
53
53
54
def test_type_conversion_no_schema ():
@@ -138,7 +139,7 @@ def test_type_conversion_with_schema():
138
139
('decimal' , 'InvalidDecimal' ),
139
140
('float' , 'InvalidFloat' )]),
140
141
]
141
- with pytest .warns (UserWarning ) as type_warnings :
142
+ with pytest .warns (DataErrorWarning ) as type_warnings :
142
143
assert (expected , None , None ) == run (sheets , schema )
143
144
# check that only one warning was raised
144
145
assert len (type_warnings ) == 3
@@ -334,9 +335,8 @@ def test_merging_cols():
334
335
def test_dict (sheets , schema , expected_result , expected_cell_source_map , expected_heading_source_map ):
335
336
result , cell_source_map , heading_source_map = run (sheets , schema = schema , source_maps = True )
336
337
assert expected_result == result
337
- if WITH_CELLS :
338
- assert expected_cell_source_map == cell_source_map
339
- assert expected_heading_source_map == heading_source_map
338
+ assert expected_cell_source_map == cell_source_map
339
+ assert expected_heading_source_map == heading_source_map
340
340
341
341
342
342
test_list_of_dicts_data_result = [
@@ -486,9 +486,8 @@ def test_dict(sheets, schema, expected_result, expected_cell_source_map, expecte
486
486
def test_list_of_dicts (sheets , schema , expected_result , expected_cell_source_map , expected_heading_source_map ):
487
487
result , cell_source_map , heading_source_map = run (sheets , schema = schema , source_maps = True )
488
488
assert expected_result == result
489
- if WITH_CELLS :
490
- assert expected_cell_source_map == cell_source_map
491
- assert expected_heading_source_map == heading_source_map
489
+ assert expected_cell_source_map == cell_source_map
490
+ assert expected_heading_source_map == heading_source_map
492
491
493
492
494
493
test_list_of_dicts_with_ids_data_result = [
@@ -666,9 +665,8 @@ def test_list_of_dicts(sheets, schema, expected_result, expected_cell_source_map
666
665
def test_list_of_dicts_with_ids (sheets , schema , expected_result , expected_cell_source_map , expected_heading_source_map ):
667
666
result , cell_source_map , heading_source_map = run (sheets , schema = schema , source_maps = True )
668
667
assert expected_result == result
669
- if WITH_CELLS :
670
- assert expected_cell_source_map == cell_source_map
671
- assert expected_heading_source_map == heading_source_map
668
+ assert expected_cell_source_map == cell_source_map
669
+ assert expected_heading_source_map == heading_source_map
672
670
673
671
674
672
test_arrangement_data_sheets = (
@@ -957,11 +955,10 @@ def test_arrangement(
957
955
actual_original_cell_and_row_locations = original_cell_and_row_locations (actual_cell_source_map or {})
958
956
actual_original_heading_locations = original_headings (actual_heading_source_map or {})
959
957
assert expected_result == actual_result
960
- if WITH_CELLS :
961
- assert expected_cell_source_map == actual_cell_source_map
962
- assert expected_heading_source_map == actual_heading_source_map
963
- assert expected_original_cell_and_row_locations == actual_original_cell_and_row_locations
964
- assert expected_original_heading_locations == actual_original_heading_locations
958
+ assert expected_cell_source_map == actual_cell_source_map
959
+ assert expected_heading_source_map == actual_heading_source_map
960
+ assert expected_original_cell_and_row_locations == actual_original_cell_and_row_locations
961
+ assert expected_original_heading_locations == actual_original_heading_locations
965
962
966
963
967
964
class HeadingListInput (SpreadsheetInput ):
@@ -981,8 +978,6 @@ def read_sheets(self):
981
978
982
979
983
980
def run (sheets , schema = None , source_maps = False ):
984
- if not WITH_CELLS :
985
- source_maps = False
986
981
input_headings = OrderedDict ()
987
982
input_sheets = OrderedDict ()
988
983
for sheet in sheets :
0 commit comments