prettytable 3.10.2__tar.gz → 3.11.0__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.
Files changed (29) hide show
  1. {prettytable-3.10.2 → prettytable-3.11.0}/.github/workflows/release.yml +9 -0
  2. {prettytable-3.10.2 → prettytable-3.11.0}/PKG-INFO +11 -1
  3. {prettytable-3.10.2 → prettytable-3.11.0}/README.md +10 -0
  4. {prettytable-3.10.2 → prettytable-3.11.0}/src/prettytable/prettytable.py +83 -14
  5. {prettytable-3.10.2 → prettytable-3.11.0}/tests/test_prettytable.py +263 -4
  6. {prettytable-3.10.2 → prettytable-3.11.0}/.coveragerc +0 -0
  7. {prettytable-3.10.2 → prettytable-3.11.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  8. {prettytable-3.10.2 → prettytable-3.11.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  9. {prettytable-3.10.2 → prettytable-3.11.0}/.github/dependabot.yml +0 -0
  10. {prettytable-3.10.2 → prettytable-3.11.0}/.github/labels.yml +0 -0
  11. {prettytable-3.10.2 → prettytable-3.11.0}/.github/release-drafter.yml +0 -0
  12. {prettytable-3.10.2 → prettytable-3.11.0}/.github/workflows/labels.yml +0 -0
  13. {prettytable-3.10.2 → prettytable-3.11.0}/.github/workflows/lint.yml +0 -0
  14. {prettytable-3.10.2 → prettytable-3.11.0}/.github/workflows/release-drafter.yml +0 -0
  15. {prettytable-3.10.2 → prettytable-3.11.0}/.github/workflows/require-pr-label.yml +0 -0
  16. {prettytable-3.10.2 → prettytable-3.11.0}/.github/workflows/test.yml +0 -0
  17. {prettytable-3.10.2 → prettytable-3.11.0}/.gitignore +0 -0
  18. {prettytable-3.10.2 → prettytable-3.11.0}/.pre-commit-config.yaml +0 -0
  19. {prettytable-3.10.2 → prettytable-3.11.0}/CHANGELOG.md +0 -0
  20. {prettytable-3.10.2 → prettytable-3.11.0}/CODE_OF_CONDUCT.md +0 -0
  21. {prettytable-3.10.2 → prettytable-3.11.0}/CONTRIBUTING.md +0 -0
  22. {prettytable-3.10.2 → prettytable-3.11.0}/LICENSE +0 -0
  23. {prettytable-3.10.2 → prettytable-3.11.0}/RELEASING.md +0 -0
  24. {prettytable-3.10.2 → prettytable-3.11.0}/pyproject.toml +0 -0
  25. {prettytable-3.10.2 → prettytable-3.11.0}/src/prettytable/__init__.py +0 -0
  26. {prettytable-3.10.2 → prettytable-3.11.0}/src/prettytable/colortable.py +0 -0
  27. {prettytable-3.10.2 → prettytable-3.11.0}/src/prettytable/py.typed +0 -0
  28. {prettytable-3.10.2 → prettytable-3.11.0}/tests/test_colortable.py +0 -0
  29. {prettytable-3.10.2 → prettytable-3.11.0}/tox.ini +0 -0
@@ -17,6 +17,10 @@ jobs:
17
17
  if: github.repository_owner == 'jazzband'
18
18
  runs-on: ubuntu-latest
19
19
 
20
+ permissions:
21
+ attestations: write
22
+ id-token: write
23
+
20
24
  steps:
21
25
  - uses: actions/checkout@v4
22
26
  with:
@@ -39,6 +43,11 @@ jobs:
39
43
  python -m build
40
44
  twine check --strict dist/*
41
45
 
46
+ - name: Attest build provenance
47
+ uses: actions/attest-build-provenance@v1
48
+ with:
49
+ subject-path: "dist/*"
50
+
42
51
  - name: Upload packages to Jazzband
43
52
  if: github.event.action == 'published'
44
53
  uses: pypa/gh-action-pypi-publish@release/v1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prettytable
3
- Version: 3.10.2
3
+ Version: 3.11.0
4
4
  Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
5
5
  Project-URL: Changelog, https://github.com/jazzband/prettytable/releases
6
6
  Project-URL: Homepage, https://github.com/jazzband/prettytable
@@ -707,6 +707,16 @@ will print:
707
707
  </table>
708
708
  ```
709
709
 
710
+ #### Setting HTML escaping
711
+
712
+ By default, PrettyTable will escape the data contained in the header and data fields
713
+ when sending output to HTML. This can be disabled by setting the `escape_header` and
714
+ `escape_data` to false. For example:
715
+
716
+ ```python
717
+ print(table.get_html_string(escape_header=False, escape_data=False))
718
+ ```
719
+
710
720
  ### Miscellaneous things
711
721
 
712
722
  #### Copying a table
@@ -675,6 +675,16 @@ will print:
675
675
  </table>
676
676
  ```
677
677
 
678
+ #### Setting HTML escaping
679
+
680
+ By default, PrettyTable will escape the data contained in the header and data fields
681
+ when sending output to HTML. This can be disabled by setting the `escape_header` and
682
+ `escape_data` to false. For example:
683
+
684
+ ```python
685
+ print(table.get_html_string(escape_header=False, escape_data=False))
686
+ ```
687
+
678
688
  ### Miscellaneous things
679
689
 
680
690
  #### Copying a table
@@ -188,6 +188,8 @@ class PrettyTable:
188
188
  "max_width",
189
189
  "min_width",
190
190
  "none_format",
191
+ "escape_header",
192
+ "escape_data",
191
193
  ]
192
194
  for option in self._options:
193
195
  if option in kwargs:
@@ -224,6 +226,14 @@ class PrettyTable:
224
226
  self._reversesort = False
225
227
  self._sort_key = kwargs["sort_key"] or (lambda x: x)
226
228
 
229
+ if kwargs["escape_data"] in (True, False):
230
+ self._escape_data = kwargs["escape_data"]
231
+ else:
232
+ self._escape_data = True
233
+ if kwargs["escape_header"] in (True, False):
234
+ self._escape_header = kwargs["escape_header"]
235
+ else:
236
+ self._escape_header = True
227
237
  # Column specific arguments, use property.setters
228
238
  self.align = kwargs["align"] or {}
229
239
  self.valign = kwargs["valign"] or {}
@@ -380,6 +390,8 @@ class PrettyTable:
380
390
  "xhtml",
381
391
  "print_empty",
382
392
  "oldsortslice",
393
+ "escape_header",
394
+ "escape_data",
383
395
  ):
384
396
  self._validate_true_or_false(option, val)
385
397
  elif option == "header_style":
@@ -1252,6 +1264,26 @@ class PrettyTable:
1252
1264
  self._validate_option("oldsortslice", val)
1253
1265
  self._oldsortslice = val
1254
1266
 
1267
+ @property
1268
+ def escape_header(self):
1269
+ """Escapes the text within a header (True or False)"""
1270
+ return self._escape_header
1271
+
1272
+ @escape_header.setter
1273
+ def escape_header(self, val):
1274
+ self._validate_option("escape_header", val)
1275
+ self._escape_header = val
1276
+
1277
+ @property
1278
+ def escape_data(self):
1279
+ """Escapes the text within a data field (True or False)"""
1280
+ return self._escape_data
1281
+
1282
+ @escape_data.setter
1283
+ def escape_data(self, val):
1284
+ self._validate_option("escape_data", val)
1285
+ self._escape_data = val
1286
+
1255
1287
  ##############################
1256
1288
  # OPTION MIXER #
1257
1289
  ##############################
@@ -2087,8 +2119,20 @@ class PrettyTable:
2087
2119
  csv_writer = csv.writer(csv_buffer, **csv_options)
2088
2120
 
2089
2121
  if options.get("header"):
2090
- csv_writer.writerow(self._field_names)
2091
- for row in self._get_rows(options):
2122
+ if options["fields"]:
2123
+ csv_writer.writerow(
2124
+ [f for f in self._field_names if f in options["fields"]]
2125
+ )
2126
+ else:
2127
+ csv_writer.writerow(self._field_names)
2128
+
2129
+ rows = self._get_rows(options)
2130
+ if options["fields"]:
2131
+ rows = [
2132
+ [d for f, d in zip(self._field_names, row) if f in options["fields"]]
2133
+ for row in rows
2134
+ ]
2135
+ for row in rows:
2092
2136
  csv_writer.writerow(row)
2093
2137
 
2094
2138
  return csv_buffer.getvalue()
@@ -2112,12 +2156,26 @@ class PrettyTable:
2112
2156
  json_options.update(
2113
2157
  {key: value for key, value in kwargs.items() if key not in options}
2114
2158
  )
2115
- objects = []
2159
+ objects: list[list[str] | dict[str, Any]] = []
2116
2160
 
2117
2161
  if options.get("header"):
2118
- objects.append(self.field_names)
2119
- for row in self._get_rows(options):
2120
- objects.append(dict(zip(self._field_names, row)))
2162
+ if options["fields"]:
2163
+ objects.append([f for f in self._field_names if f in options["fields"]])
2164
+ else:
2165
+ objects.append(self.field_names)
2166
+ rows = self._get_rows(options)
2167
+ if options["fields"]:
2168
+ for row in rows:
2169
+ objects.append(
2170
+ {
2171
+ f: d
2172
+ for f, d in zip(self._field_names, row)
2173
+ if f in options["fields"]
2174
+ }
2175
+ )
2176
+ else:
2177
+ for row in rows:
2178
+ objects.append(dict(zip(self._field_names, row)))
2121
2179
 
2122
2180
  return json.dumps(objects, **json_options)
2123
2181
 
@@ -2136,6 +2194,7 @@ class PrettyTable:
2136
2194
  end - index of last data row to include in output PLUS ONE (list slice style)
2137
2195
  fields - names of fields (columns) to include
2138
2196
  header - print a header showing field names (True or False)
2197
+ escape_header - escapes the text within a header (True or False)
2139
2198
  border - print a border around the table (True or False)
2140
2199
  preserve_internal_border - print a border inside the table even if
2141
2200
  border is disabled (True or False)
@@ -2156,6 +2215,7 @@ class PrettyTable:
2156
2215
  <table> tag
2157
2216
  format - Controls whether or not HTML tables are formatted to match
2158
2217
  styling options (True or False)
2218
+ escape_data - escapes the text within a data field (True or False)
2159
2219
  xhtml - print <br/> tags if True, <br> tags if False"""
2160
2220
 
2161
2221
  options = self._get_options(kwargs)
@@ -2197,11 +2257,13 @@ class PrettyTable:
2197
2257
  for field in self._field_names:
2198
2258
  if options["fields"] and field not in options["fields"]:
2199
2259
  continue
2260
+ if options["escape_header"]:
2261
+ field = escape(field)
2262
+
2200
2263
  lines.append(
2201
- " <th>{}</th>".format(
2202
- escape(field).replace("\n", linebreak)
2203
- )
2264
+ " <th>{}</th>".format(field.replace("\n", linebreak))
2204
2265
  )
2266
+
2205
2267
  lines.append(" </tr>")
2206
2268
  lines.append(" </thead>")
2207
2269
 
@@ -2214,10 +2276,11 @@ class PrettyTable:
2214
2276
  for field, datum in zip(self._field_names, row):
2215
2277
  if options["fields"] and field not in options["fields"]:
2216
2278
  continue
2279
+ if options["escape_data"]:
2280
+ datum = escape(datum)
2281
+
2217
2282
  lines.append(
2218
- " <td>{}</td>".format(
2219
- escape(datum).replace("\n", linebreak)
2220
- )
2283
+ " <td>{}</td>".format(datum.replace("\n", linebreak))
2221
2284
  )
2222
2285
  lines.append(" </tr>")
2223
2286
  lines.append(" </tbody>")
@@ -2273,9 +2336,12 @@ class PrettyTable:
2273
2336
  for field in self._field_names:
2274
2337
  if options["fields"] and field not in options["fields"]:
2275
2338
  continue
2339
+ if options["escape_header"]:
2340
+ field = escape(field)
2341
+
2276
2342
  lines.append(
2277
2343
  ' <th style="padding-left: %dem; padding-right: %dem; text-align: center">%s</th>' # noqa: E501
2278
- % (lpad, rpad, escape(field).replace("\n", linebreak))
2344
+ % (lpad, rpad, field.replace("\n", linebreak))
2279
2345
  )
2280
2346
  lines.append(" </tr>")
2281
2347
  lines.append(" </thead>")
@@ -2300,6 +2366,9 @@ class PrettyTable:
2300
2366
  ):
2301
2367
  if options["fields"] and field not in options["fields"]:
2302
2368
  continue
2369
+ if options["escape_data"]:
2370
+ datum = escape(datum)
2371
+
2303
2372
  lines.append(
2304
2373
  ' <td style="padding-left: %dem; padding-right: %dem; text-align: %s; vertical-align: %s">%s</td>' # noqa: E501
2305
2374
  % (
@@ -2307,7 +2376,7 @@ class PrettyTable:
2307
2376
  rpad,
2308
2377
  align,
2309
2378
  valign,
2310
- escape(datum).replace("\n", linebreak),
2379
+ datum.replace("\n", linebreak),
2311
2380
  )
2312
2381
  )
2313
2382
  lines.append(" </tr>")
@@ -40,7 +40,7 @@ def test_version() -> None:
40
40
  assert prettytable.__version__[-1].isdigit()
41
41
 
42
42
 
43
- def helper_table(rows: int = 3) -> PrettyTable:
43
+ def helper_table(*, rows: int = 3) -> PrettyTable:
44
44
  table = PrettyTable(["", "Field 1", "Field 2", "Field 3"])
45
45
  v = 1
46
46
  for row in range(rows):
@@ -1021,6 +1021,30 @@ class TestJSONOutput:
1021
1021
  "Field 2": "value8",
1022
1022
  "Field 3": "value9"
1023
1023
  }
1024
+ ]""".strip()
1025
+ )
1026
+ options = {"fields": ["Field 1", "Field 3"]}
1027
+ result = t.get_json_string(**options)
1028
+ assert (
1029
+ result.strip()
1030
+ == """
1031
+ [
1032
+ [
1033
+ "Field 1",
1034
+ "Field 3"
1035
+ ],
1036
+ {
1037
+ "Field 1": "value 1",
1038
+ "Field 3": "value3"
1039
+ },
1040
+ {
1041
+ "Field 1": "value 4",
1042
+ "Field 3": "value6"
1043
+ },
1044
+ {
1045
+ "Field 1": "value 7",
1046
+ "Field 3": "value9"
1047
+ }
1024
1048
  ]""".strip()
1025
1049
  )
1026
1050
 
@@ -1195,6 +1219,234 @@ class TestHtmlOutput:
1195
1219
  </tr>
1196
1220
  </tbody>
1197
1221
  </table>
1222
+ """.strip() # noqa: E501
1223
+ )
1224
+
1225
+ def test_html_output_without_escaped_header(self) -> None:
1226
+ t = helper_table(rows=0)
1227
+ t.field_names = ["", "Field 1", "<em>Field 2</em>", "<a href='#'>Field 3</a>"]
1228
+ result = t.get_html_string(escape_header=False)
1229
+ assert (
1230
+ result.strip()
1231
+ == """
1232
+ <table>
1233
+ <thead>
1234
+ <tr>
1235
+ <th></th>
1236
+ <th>Field 1</th>
1237
+ <th><em>Field 2</em></th>
1238
+ <th><a href='#'>Field 3</a></th>
1239
+ </tr>
1240
+ </thead>
1241
+ <tbody>
1242
+ </tbody>
1243
+ </table>
1244
+ """.strip()
1245
+ )
1246
+
1247
+ def test_html_output_without_escaped_data(self) -> None:
1248
+ t = helper_table(rows=0)
1249
+ t.add_row(
1250
+ [
1251
+ 1,
1252
+ "<b>value 1</b>",
1253
+ "<span style='text-decoration: underline;'>value2</span>",
1254
+ "<a href='#'>value3</a>",
1255
+ ]
1256
+ )
1257
+ result = t.get_html_string(escape_data=False)
1258
+ assert (
1259
+ result.strip()
1260
+ == """
1261
+ <table>
1262
+ <thead>
1263
+ <tr>
1264
+ <th></th>
1265
+ <th>Field 1</th>
1266
+ <th>Field 2</th>
1267
+ <th>Field 3</th>
1268
+ </tr>
1269
+ </thead>
1270
+ <tbody>
1271
+ <tr>
1272
+ <td>1</td>
1273
+ <td><b>value 1</b></td>
1274
+ <td><span style='text-decoration: underline;'>value2</span></td>
1275
+ <td><a href='#'>value3</a></td>
1276
+ </tr>
1277
+ </tbody>
1278
+ </table>
1279
+ """.strip()
1280
+ )
1281
+
1282
+ def test_html_output_with_escaped_header(self) -> None:
1283
+ t = helper_table(rows=0)
1284
+ t.field_names = ["", "Field 1", "<em>Field 2</em>", "<a href='#'>Field 3</a>"]
1285
+ result = t.get_html_string(escape_header=True)
1286
+ assert (
1287
+ result.strip()
1288
+ == """
1289
+ <table>
1290
+ <thead>
1291
+ <tr>
1292
+ <th></th>
1293
+ <th>Field 1</th>
1294
+ <th>&lt;em&gt;Field 2&lt;/em&gt;</th>
1295
+ <th>&lt;a href=&#x27;#&#x27;&gt;Field 3&lt;/a&gt;</th>
1296
+ </tr>
1297
+ </thead>
1298
+ <tbody>
1299
+ </tbody>
1300
+ </table>
1301
+ """.strip()
1302
+ )
1303
+
1304
+ def test_html_output_with_escaped_data(self) -> None:
1305
+ t = helper_table(rows=0)
1306
+ t.add_row(
1307
+ [
1308
+ 1,
1309
+ "<b>value 1</b>",
1310
+ "<span style='text-decoration: underline;'>value2</span>",
1311
+ "<a href='#'>value3</a>",
1312
+ ]
1313
+ )
1314
+ result = t.get_html_string(escape_data=True)
1315
+ assert (
1316
+ result.strip()
1317
+ == """
1318
+ <table>
1319
+ <thead>
1320
+ <tr>
1321
+ <th></th>
1322
+ <th>Field 1</th>
1323
+ <th>Field 2</th>
1324
+ <th>Field 3</th>
1325
+ </tr>
1326
+ </thead>
1327
+ <tbody>
1328
+ <tr>
1329
+ <td>1</td>
1330
+ <td>&lt;b&gt;value 1&lt;/b&gt;</td>
1331
+ <td>&lt;span style=&#x27;text-decoration: underline;&#x27;&gt;value2&lt;/span&gt;</td>
1332
+ <td>&lt;a href=&#x27;#&#x27;&gt;value3&lt;/a&gt;</td>
1333
+ </tr>
1334
+ </tbody>
1335
+ </table>
1336
+ """.strip() # noqa: E501
1337
+ )
1338
+
1339
+ def test_html_output_formatted_without_escaped_header(self) -> None:
1340
+ t = helper_table(rows=0)
1341
+ t.field_names = ["", "Field 1", "<em>Field 2</em>", "<a href='#'>Field 3</a>"]
1342
+ result = t.get_html_string(escape_header=False, format=True)
1343
+ assert (
1344
+ result.strip()
1345
+ == """
1346
+ <table frame="box" rules="cols">
1347
+ <thead>
1348
+ <tr>
1349
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
1350
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
1351
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"><em>Field 2</em></th>
1352
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"><a href='#'>Field 3</a></th>
1353
+ </tr>
1354
+ </thead>
1355
+ <tbody>
1356
+ </tbody>
1357
+ </table>
1358
+ """.strip() # noqa: E501
1359
+ )
1360
+
1361
+ def test_html_output_formatted_without_escaped_data(self) -> None:
1362
+ t = helper_table(rows=0)
1363
+ t.add_row(
1364
+ [
1365
+ 1,
1366
+ "<b>value 1</b>",
1367
+ "<span style='text-decoration: underline;'>value2</span>",
1368
+ "<a href='#'>value3</a>",
1369
+ ]
1370
+ )
1371
+ result = t.get_html_string(escape_data=False, format=True)
1372
+ assert (
1373
+ result.strip()
1374
+ == """
1375
+ <table frame="box" rules="cols">
1376
+ <thead>
1377
+ <tr>
1378
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
1379
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
1380
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 2</th>
1381
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 3</th>
1382
+ </tr>
1383
+ </thead>
1384
+ <tbody>
1385
+ <tr>
1386
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">1</td>
1387
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top"><b>value 1</b></td>
1388
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top"><span style='text-decoration: underline;'>value2</span></td>
1389
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top"><a href='#'>value3</a></td>
1390
+ </tr>
1391
+ </tbody>
1392
+ </table>
1393
+ """.strip() # noqa: E501
1394
+ )
1395
+
1396
+ def test_html_output_formatted_with_escaped_header(self) -> None:
1397
+ t = helper_table(rows=0)
1398
+ t.field_names = ["", "Field 1", "<em>Field 2</em>", "<a href='#'>Field 3</a>"]
1399
+ result = t.get_html_string(escape_header=True, format=True)
1400
+ assert (
1401
+ result.strip()
1402
+ == """
1403
+ <table frame="box" rules="cols">
1404
+ <thead>
1405
+ <tr>
1406
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
1407
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
1408
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">&lt;em&gt;Field 2&lt;/em&gt;</th>
1409
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">&lt;a href=&#x27;#&#x27;&gt;Field 3&lt;/a&gt;</th>
1410
+ </tr>
1411
+ </thead>
1412
+ <tbody>
1413
+ </tbody>
1414
+ </table>
1415
+ """.strip() # noqa: E501
1416
+ )
1417
+
1418
+ def test_html_output_formatted_with_escaped_data(self) -> None:
1419
+ t = helper_table(rows=0)
1420
+ t.add_row(
1421
+ [
1422
+ 1,
1423
+ "<b>value 1</b>",
1424
+ "<span style='text-decoration: underline;'>value2</span>",
1425
+ "<a href='#'>value3</a>",
1426
+ ]
1427
+ )
1428
+ result = t.get_html_string(escape_data=True, format=True)
1429
+ assert (
1430
+ result.strip()
1431
+ == """
1432
+ <table frame="box" rules="cols">
1433
+ <thead>
1434
+ <tr>
1435
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
1436
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
1437
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 2</th>
1438
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 3</th>
1439
+ </tr>
1440
+ </thead>
1441
+ <tbody>
1442
+ <tr>
1443
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">1</td>
1444
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">&lt;b&gt;value 1&lt;/b&gt;</td>
1445
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">&lt;span style=&#x27;text-decoration: underline;&#x27;&gt;value2&lt;/span&gt;</td>
1446
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">&lt;a href=&#x27;#&#x27;&gt;value3&lt;/a&gt;</td>
1447
+ </tr>
1448
+ </tbody>
1449
+ </table>
1198
1450
  """.strip() # noqa: E501
1199
1451
  )
1200
1452
 
@@ -1522,6 +1774,13 @@ class TestCsvOutput:
1522
1774
  "4,value 4,value5,value6\r\n"
1523
1775
  "7,value 7,value8,value9\r\n"
1524
1776
  )
1777
+ options = {"fields": ["Field 1", "Field 3"]}
1778
+ assert t.get_csv_string(**options) == (
1779
+ "Field 1,Field 3\r\n"
1780
+ "value 1,value3\r\n"
1781
+ "value 4,value6\r\n"
1782
+ "value 7,value9\r\n"
1783
+ )
1525
1784
 
1526
1785
 
1527
1786
  class TestLatexOutput:
@@ -2221,7 +2480,7 @@ class TestClearing:
2221
2480
 
2222
2481
  class TestPreservingInternalBorders:
2223
2482
  def test_internal_border_preserved(self) -> None:
2224
- pt = helper_table(3)
2483
+ pt = helper_table()
2225
2484
  pt.border = False
2226
2485
  pt.preserve_internal_border = True
2227
2486
 
@@ -2237,7 +2496,7 @@ class TestPreservingInternalBorders:
2237
2496
  )
2238
2497
 
2239
2498
  def test_internal_border_preserved_latex(self) -> None:
2240
- pt = helper_table(3)
2499
+ pt = helper_table()
2241
2500
  pt.border = False
2242
2501
  pt.format = True
2243
2502
  pt.preserve_internal_border = True
@@ -2252,7 +2511,7 @@ class TestPreservingInternalBorders:
2252
2511
  )
2253
2512
 
2254
2513
  def test_internal_border_preserved_html(self) -> None:
2255
- pt = helper_table(3)
2514
+ pt = helper_table()
2256
2515
  pt.format = True
2257
2516
  pt.border = False
2258
2517
  pt.preserve_internal_border = True
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes