|
3 | 3 | import json |
4 | 4 | import unittest |
5 | 5 | from pathlib import Path |
6 | | -from textwrap import dedent |
7 | 6 |
|
8 | 7 | from unittest_helpers import LIBSOLIDITY_TEST_DIR, load_fixture, load_libsolidity_test_case |
9 | 8 |
|
@@ -51,23 +50,21 @@ def test_format_report(self): |
51 | 50 | ] |
52 | 51 | ) |
53 | 52 |
|
54 | | - expected_output = dedent("""\ |
55 | | - syntaxTests/scoping/library_inherited2.sol:A <NO BYTECODE> |
56 | | - syntaxTests/scoping/library_inherited2.sol:A <NO METADATA> |
57 | | - syntaxTests/scoping/library_inherited2.sol:B <NO BYTECODE> |
58 | | - syntaxTests/scoping/library_inherited2.sol:B {"language":"Solidity"} |
59 | | - syntaxTests/scoping/library_inherited2.sol:Lib 60566050600b828282398051 |
60 | | - syntaxTests/scoping/library_inherited2.sol:Lib <NO METADATA> |
61 | | - """) |
| 53 | + expected_output = ( |
| 54 | + "syntaxTests/scoping/library_inherited2.sol:A <NO BYTECODE>\n" |
| 55 | + "syntaxTests/scoping/library_inherited2.sol:A <NO METADATA>\n" |
| 56 | + "syntaxTests/scoping/library_inherited2.sol:B <NO BYTECODE>\n" |
| 57 | + "syntaxTests/scoping/library_inherited2.sol:B {\"language\":\"Solidity\"}\n" |
| 58 | + "syntaxTests/scoping/library_inherited2.sol:Lib 60566050600b828282398051\n" |
| 59 | + "syntaxTests/scoping/library_inherited2.sol:Lib <NO METADATA>\n" |
| 60 | + ) |
62 | 61 |
|
63 | 62 | self.assertEqual(report.format_report(), expected_output) |
64 | 63 |
|
65 | 64 | def test_format_report_should_print_error_if_contract_report_list_is_missing(self): |
66 | 65 | report = FileReport(file_name=Path('file.sol'), contract_reports=None) |
67 | 66 |
|
68 | | - expected_output = dedent("""\ |
69 | | - file.sol: <ERROR> |
70 | | - """) |
| 67 | + expected_output = "file.sol: <ERROR>\n" |
71 | 68 |
|
72 | 69 | self.assertEqual(report.format_report(), expected_output) |
73 | 70 |
|
@@ -158,28 +155,28 @@ def test_parse_standard_json_output_should_report_error_if_contracts_is_empty(se |
158 | 155 | self.assertEqual(parse_standard_json_output(Path('contract.sol'), compiler_output), expected_report) |
159 | 156 |
|
160 | 157 | def test_parse_standard_json_output_should_report_error_if_every_file_has_no_contracts(self): |
161 | | - compiler_output = dedent("""\ |
162 | | - { |
163 | | - "contracts": { |
164 | | - "contract1.sol": {}, |
165 | | - "contract2.sol": {} |
166 | | - } |
167 | | - } |
168 | | - """) |
| 158 | + compiler_output = ( |
| 159 | + "{\n" |
| 160 | + " \"contracts\": {\n" |
| 161 | + " \"contract1.sol\": {},\n" |
| 162 | + " \"contract2.sol\": {}\n" |
| 163 | + " }\n" |
| 164 | + "}\n" |
| 165 | + ) |
169 | 166 |
|
170 | 167 | expected_report = FileReport(file_name=Path('contract.sol'), contract_reports=None) |
171 | 168 |
|
172 | 169 | self.assertEqual(parse_standard_json_output(Path('contract.sol'), compiler_output), expected_report) |
173 | 170 |
|
174 | 171 | def test_parse_standard_json_output_should_not_report_error_if_there_is_at_least_one_file_with_contracts(self): |
175 | | - compiler_output = dedent("""\ |
176 | | - { |
177 | | - "contracts": { |
178 | | - "contract1.sol": {"A": {}}, |
179 | | - "contract2.sol": {} |
180 | | - } |
181 | | - } |
182 | | - """) |
| 172 | + compiler_output = ( |
| 173 | + "{\n" |
| 174 | + " \"contracts\": {\n" |
| 175 | + " \"contract1.sol\": {\"A\": {}},\n" |
| 176 | + " \"contract2.sol\": {}\n" |
| 177 | + " }\n" |
| 178 | + "}\n" |
| 179 | + ) |
183 | 180 |
|
184 | 181 | expected_report = FileReport( |
185 | 182 | file_name=Path('contract.sol'), |
|
0 commit comments