prettytable 3.13.0__tar.gz → 3.14.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.
- {prettytable-3.13.0 → prettytable-3.14.0}/PKG-INFO +6 -4
- {prettytable-3.13.0 → prettytable-3.14.0}/README.md +5 -3
- {prettytable-3.13.0 → prettytable-3.14.0}/src/prettytable/_version.py +2 -2
- {prettytable-3.13.0 → prettytable-3.14.0}/src/prettytable/prettytable.py +26 -17
- {prettytable-3.13.0 → prettytable-3.14.0}/tests/test_prettytable.py +152 -43
- prettytable-3.14.0/tests/test_sections.py +55 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.coveragerc +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/FUNDING.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/SECURITY.md +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/dependabot.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/labels.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/release-drafter.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/workflows/labels.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/workflows/lint.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/workflows/release-drafter.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/workflows/release.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/workflows/require-pr-label.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.github/workflows/test.yml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.gitignore +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/.pre-commit-config.yaml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/CHANGELOG.md +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/LICENSE +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/RELEASING.md +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/pyproject.toml +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/src/prettytable/__init__.py +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/src/prettytable/__main__.py +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/src/prettytable/colortable.py +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/src/prettytable/py.typed +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/tests/test_colortable.py +0 -0
- {prettytable-3.13.0 → prettytable-3.14.0}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: prettytable
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.14.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/prettytable/prettytable/releases
|
|
6
6
|
Project-URL: Funding, https://tidelift.com/subscription/pkg/pypi-prettytable?utm_source=pypi-prettytable&utm_medium=pypi
|
|
@@ -423,14 +423,15 @@ instance of the data in the `sort_by` column.
|
|
|
423
423
|
|
|
424
424
|
#### Adding sections to a table
|
|
425
425
|
|
|
426
|
-
You can divide your table into different sections using the `
|
|
427
|
-
will add a dividing line into the table under the row who has
|
|
428
|
-
set up a table like this:
|
|
426
|
+
You can divide your table into different sections using the `add_divider` method or
|
|
427
|
+
`divider` argument . This will add a dividing line into the table under the row who has
|
|
428
|
+
this field set. So we can set up a table like this:
|
|
429
429
|
|
|
430
430
|
```python
|
|
431
431
|
table = PrettyTable()
|
|
432
432
|
table.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
|
|
433
433
|
table.add_row(["Adelaide", 1295, 1158259, 600.5])
|
|
434
|
+
table.add_divider()
|
|
434
435
|
table.add_row(["Brisbane", 5905, 1857594, 1146.4])
|
|
435
436
|
table.add_row(["Darwin", 112, 120900, 1714.7])
|
|
436
437
|
table.add_row(["Hobart", 1357, 205556, 619.5], divider=True)
|
|
@@ -446,6 +447,7 @@ to get a table like this:
|
|
|
446
447
|
| City name | Area | Population | Annual Rainfall |
|
|
447
448
|
+-----------+------+------------+-----------------+
|
|
448
449
|
| Adelaide | 1295 | 1158259 | 600.5 |
|
|
450
|
+
+-----------+------+------------+-----------------+
|
|
449
451
|
| Brisbane | 5905 | 1857594 | 1146.4 |
|
|
450
452
|
| Darwin | 112 | 120900 | 1714.7 |
|
|
451
453
|
| Hobart | 1357 | 205556 | 619.5 |
|
|
@@ -391,14 +391,15 @@ instance of the data in the `sort_by` column.
|
|
|
391
391
|
|
|
392
392
|
#### Adding sections to a table
|
|
393
393
|
|
|
394
|
-
You can divide your table into different sections using the `
|
|
395
|
-
will add a dividing line into the table under the row who has
|
|
396
|
-
set up a table like this:
|
|
394
|
+
You can divide your table into different sections using the `add_divider` method or
|
|
395
|
+
`divider` argument . This will add a dividing line into the table under the row who has
|
|
396
|
+
this field set. So we can set up a table like this:
|
|
397
397
|
|
|
398
398
|
```python
|
|
399
399
|
table = PrettyTable()
|
|
400
400
|
table.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
|
|
401
401
|
table.add_row(["Adelaide", 1295, 1158259, 600.5])
|
|
402
|
+
table.add_divider()
|
|
402
403
|
table.add_row(["Brisbane", 5905, 1857594, 1146.4])
|
|
403
404
|
table.add_row(["Darwin", 112, 120900, 1714.7])
|
|
404
405
|
table.add_row(["Hobart", 1357, 205556, 619.5], divider=True)
|
|
@@ -414,6 +415,7 @@ to get a table like this:
|
|
|
414
415
|
| City name | Area | Population | Annual Rainfall |
|
|
415
416
|
+-----------+------+------------+-----------------+
|
|
416
417
|
| Adelaide | 1295 | 1158259 | 600.5 |
|
|
418
|
+
+-----------+------+------------+-----------------+
|
|
417
419
|
| Brisbane | 5905 | 1857594 | 1146.4 |
|
|
418
420
|
| Darwin | 112 | 120900 | 1714.7 |
|
|
419
421
|
| Hobart | 1357 | 205556 | 619.5 |
|
|
@@ -325,12 +325,17 @@ class PrettyTable:
|
|
|
325
325
|
"escape_data",
|
|
326
326
|
]
|
|
327
327
|
|
|
328
|
+
self._none_format: dict[str, str | None] = {}
|
|
328
329
|
self._kwargs = {}
|
|
330
|
+
if field_names:
|
|
331
|
+
self.field_names = field_names
|
|
332
|
+
else:
|
|
333
|
+
self._widths: list[int] = []
|
|
334
|
+
|
|
329
335
|
for option in self._options:
|
|
330
336
|
if option in kwargs:
|
|
331
337
|
self._validate_option(option, kwargs[option])
|
|
332
338
|
self._kwargs[option] = kwargs[option]
|
|
333
|
-
|
|
334
339
|
else:
|
|
335
340
|
kwargs[option] = None
|
|
336
341
|
self._kwargs[option] = None
|
|
@@ -339,7 +344,6 @@ class PrettyTable:
|
|
|
339
344
|
self._start = kwargs["start"] or 0
|
|
340
345
|
self._end = kwargs["end"] or None
|
|
341
346
|
self._fields = kwargs["fields"] or None
|
|
342
|
-
self._none_format: dict[str, str | None] = {}
|
|
343
347
|
|
|
344
348
|
if kwargs["header"] in (True, False):
|
|
345
349
|
self._header = kwargs["header"]
|
|
@@ -373,11 +377,6 @@ class PrettyTable:
|
|
|
373
377
|
else:
|
|
374
378
|
self._escape_header = True
|
|
375
379
|
|
|
376
|
-
if field_names:
|
|
377
|
-
self.field_names = field_names
|
|
378
|
-
else:
|
|
379
|
-
self._widths: list[int] = []
|
|
380
|
-
|
|
381
380
|
self._column_specific_args()
|
|
382
381
|
|
|
383
382
|
self._min_table_width = kwargs["min_table_width"] or None
|
|
@@ -416,14 +415,19 @@ class PrettyTable:
|
|
|
416
415
|
|
|
417
416
|
def _column_specific_args(self):
|
|
418
417
|
# Column specific arguments, use property.setters
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
418
|
+
for attr in (
|
|
419
|
+
"align",
|
|
420
|
+
"valign",
|
|
421
|
+
"max_width",
|
|
422
|
+
"min_width",
|
|
423
|
+
"int_format",
|
|
424
|
+
"float_format",
|
|
425
|
+
"custom_format",
|
|
426
|
+
"none_format",
|
|
427
|
+
):
|
|
428
|
+
setattr(
|
|
429
|
+
self, attr, (self._kwargs[attr] or {}) if attr in self._kwargs else {}
|
|
430
|
+
)
|
|
427
431
|
|
|
428
432
|
def _justify(self, text: str, width: int, align: AlignType) -> str:
|
|
429
433
|
excess = width - _str_block_width(text)
|
|
@@ -1614,6 +1618,11 @@ class PrettyTable:
|
|
|
1614
1618
|
del self._rows[row_index]
|
|
1615
1619
|
del self._dividers[row_index]
|
|
1616
1620
|
|
|
1621
|
+
def add_divider(self) -> None:
|
|
1622
|
+
"""Add a divider to the table"""
|
|
1623
|
+
if len(self._dividers) >= 1:
|
|
1624
|
+
self._dividers[-1] = True
|
|
1625
|
+
|
|
1617
1626
|
def add_column(
|
|
1618
1627
|
self,
|
|
1619
1628
|
fieldname: str,
|
|
@@ -2000,7 +2009,7 @@ class PrettyTable:
|
|
|
2000
2009
|
for row, divider in zip(formatted_rows[:-1], dividers[:-1]):
|
|
2001
2010
|
lines.append(self._stringify_row(row, options, self._hrule))
|
|
2002
2011
|
if divider:
|
|
2003
|
-
lines.append(self._stringify_hrule(options
|
|
2012
|
+
lines.append(self._stringify_hrule(options))
|
|
2004
2013
|
if formatted_rows:
|
|
2005
2014
|
lines.append(
|
|
2006
2015
|
self._stringify_row(
|
|
@@ -2867,7 +2876,7 @@ def from_html_one(html_code: str, **kwargs) -> PrettyTable:
|
|
|
2867
2876
|
|
|
2868
2877
|
def _warn_deprecation(name: str, module_globals: dict[str, Any]) -> Any:
|
|
2869
2878
|
if (val := module_globals.get(f"_DEPRECATED_{name}")) is None:
|
|
2870
|
-
msg = f"module '{__name__}' has no attribute '{name}"
|
|
2879
|
+
msg = f"module '{__name__}' has no attribute '{name}'"
|
|
2871
2880
|
raise AttributeError(msg)
|
|
2872
2881
|
module_globals[name] = val
|
|
2873
2882
|
if name in {"FRAME", "ALL", "NONE", "HEADER"}:
|
|
@@ -788,6 +788,40 @@ class TestSorting:
|
|
|
788
788
|
""".strip()
|
|
789
789
|
)
|
|
790
790
|
|
|
791
|
+
def test_sort_key_at_class_declaration(self) -> None:
|
|
792
|
+
# Test sorting by length of city name
|
|
793
|
+
def key(vals):
|
|
794
|
+
vals[0] = len(vals[0])
|
|
795
|
+
return vals
|
|
796
|
+
|
|
797
|
+
table = PrettyTable(
|
|
798
|
+
field_names=["City name", "Area", "Population", "Annual Rainfall"],
|
|
799
|
+
sortby="City name",
|
|
800
|
+
sort_key=key,
|
|
801
|
+
)
|
|
802
|
+
assert table.sort_key == key
|
|
803
|
+
table.add_row(["Adelaide", 1295, 1158259, 600.5])
|
|
804
|
+
table.add_row(["Brisbane", 5905, 1857594, 1146.4])
|
|
805
|
+
table.add_row(["Darwin", 112, 120900, 1714.7])
|
|
806
|
+
table.add_row(["Hobart", 1357, 205556, 619.5])
|
|
807
|
+
table.add_row(["Sydney", 2058, 4336374, 1214.8])
|
|
808
|
+
table.add_row(["Melbourne", 1566, 3806092, 646.9])
|
|
809
|
+
table.add_row(["Perth", 5386, 1554769, 869.4])
|
|
810
|
+
assert (
|
|
811
|
+
"""+-----------+------+------------+-----------------+
|
|
812
|
+
| City name | Area | Population | Annual Rainfall |
|
|
813
|
+
+-----------+------+------------+-----------------+
|
|
814
|
+
| Perth | 5386 | 1554769 | 869.4 |
|
|
815
|
+
| Darwin | 112 | 120900 | 1714.7 |
|
|
816
|
+
| Hobart | 1357 | 205556 | 619.5 |
|
|
817
|
+
| Sydney | 2058 | 4336374 | 1214.8 |
|
|
818
|
+
| Adelaide | 1295 | 1158259 | 600.5 |
|
|
819
|
+
| Brisbane | 5905 | 1857594 | 1146.4 |
|
|
820
|
+
| Melbourne | 1566 | 3806092 | 646.9 |
|
|
821
|
+
+-----------+------+------------+-----------------+"""
|
|
822
|
+
== table.get_string().strip()
|
|
823
|
+
)
|
|
824
|
+
|
|
791
825
|
def test_sort_slice(self) -> None:
|
|
792
826
|
"""Make sure sorting and slicing interact in the expected way"""
|
|
793
827
|
table = PrettyTable(["Foo"])
|
|
@@ -800,6 +834,37 @@ class TestSorting:
|
|
|
800
834
|
assert "10" not in oldstyle
|
|
801
835
|
assert "20" in oldstyle
|
|
802
836
|
|
|
837
|
+
def test_sortby_at_class_declaration(self) -> None:
|
|
838
|
+
"""
|
|
839
|
+
Fix #354 where initialization of a table with sortby fails
|
|
840
|
+
"""
|
|
841
|
+
table = PrettyTable(
|
|
842
|
+
field_names=["City name", "Area", "Population", "Annual Rainfall"],
|
|
843
|
+
sortby="Area",
|
|
844
|
+
)
|
|
845
|
+
assert table.sortby == "Area"
|
|
846
|
+
table.add_row(["Adelaide", 1295, 1158259, 600.5])
|
|
847
|
+
table.add_row(["Brisbane", 5905, 1857594, 1146.4])
|
|
848
|
+
table.add_row(["Darwin", 112, 120900, 1714.7])
|
|
849
|
+
table.add_row(["Hobart", 1357, 205556, 619.5])
|
|
850
|
+
table.add_row(["Sydney", 2058, 4336374, 1214.8])
|
|
851
|
+
table.add_row(["Melbourne", 1566, 3806092, 646.9])
|
|
852
|
+
table.add_row(["Perth", 5386, 1554769, 869.4])
|
|
853
|
+
assert (
|
|
854
|
+
"""+-----------+------+------------+-----------------+
|
|
855
|
+
| City name | Area | Population | Annual Rainfall |
|
|
856
|
+
+-----------+------+------------+-----------------+
|
|
857
|
+
| Darwin | 112 | 120900 | 1714.7 |
|
|
858
|
+
| Adelaide | 1295 | 1158259 | 600.5 |
|
|
859
|
+
| Hobart | 1357 | 205556 | 619.5 |
|
|
860
|
+
| Melbourne | 1566 | 3806092 | 646.9 |
|
|
861
|
+
| Sydney | 2058 | 4336374 | 1214.8 |
|
|
862
|
+
| Perth | 5386 | 1554769 | 869.4 |
|
|
863
|
+
| Brisbane | 5905 | 1857594 | 1146.4 |
|
|
864
|
+
+-----------+------+------------+-----------------+"""
|
|
865
|
+
== table.get_string().strip()
|
|
866
|
+
)
|
|
867
|
+
|
|
803
868
|
|
|
804
869
|
@pytest.fixture(scope="function")
|
|
805
870
|
def float_pt() -> PrettyTable:
|
|
@@ -2547,6 +2612,43 @@ class TestMaxTableWidth:
|
|
|
2547
2612
|
+---------+------------+---------+------------+---------+------------+""".strip()
|
|
2548
2613
|
)
|
|
2549
2614
|
|
|
2615
|
+
def test_table_minwidth_on_init_with_columns(self) -> None:
|
|
2616
|
+
table = PrettyTable(["Field 1", "Field 2"], min_width=20)
|
|
2617
|
+
table.add_row(
|
|
2618
|
+
[
|
|
2619
|
+
"Lorem",
|
|
2620
|
+
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ",
|
|
2621
|
+
]
|
|
2622
|
+
)
|
|
2623
|
+
|
|
2624
|
+
assert (
|
|
2625
|
+
table.get_string().strip()
|
|
2626
|
+
== """+----------------------+--------------------------------------------------------------------+
|
|
2627
|
+
| Field 1 | Field 2 |
|
|
2628
|
+
+----------------------+--------------------------------------------------------------------+
|
|
2629
|
+
| Lorem | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam |
|
|
2630
|
+
+----------------------+--------------------------------------------------------------------+""" # noqa: E501
|
|
2631
|
+
)
|
|
2632
|
+
|
|
2633
|
+
def test_table_min_max_width_on_init_with_columns(self) -> None:
|
|
2634
|
+
table = PrettyTable(["Field 1", "Field 2"], min_width=20, max_width=40)
|
|
2635
|
+
table.add_row(
|
|
2636
|
+
[
|
|
2637
|
+
"Lorem",
|
|
2638
|
+
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ",
|
|
2639
|
+
]
|
|
2640
|
+
)
|
|
2641
|
+
|
|
2642
|
+
assert (
|
|
2643
|
+
table.get_string().strip()
|
|
2644
|
+
== """+----------------------+------------------------------------------+
|
|
2645
|
+
| Field 1 | Field 2 |
|
|
2646
|
+
+----------------------+------------------------------------------+
|
|
2647
|
+
| Lorem | Lorem ipsum dolor sit amet, consetetur |
|
|
2648
|
+
| | sadipscing elitr, sed diam |
|
|
2649
|
+
+----------------------+------------------------------------------+"""
|
|
2650
|
+
)
|
|
2651
|
+
|
|
2550
2652
|
def test_table_float_formatting_on_init_wo_columns(self) -> None:
|
|
2551
2653
|
"""See also #243"""
|
|
2552
2654
|
table = prettytable.PrettyTable(float_format="10.2")
|
|
@@ -2673,54 +2775,61 @@ class TestMaxTableWidth:
|
|
|
2673
2775
|
)
|
|
2674
2776
|
|
|
2675
2777
|
|
|
2676
|
-
class
|
|
2677
|
-
def
|
|
2778
|
+
class TestFields:
|
|
2779
|
+
def test_fields_at_class_declaration(self) -> None:
|
|
2780
|
+
table = PrettyTable(
|
|
2781
|
+
field_names=["City name", "Area", "Population", "Annual Rainfall"],
|
|
2782
|
+
fields=["City name", "Annual Rainfall"],
|
|
2783
|
+
)
|
|
2784
|
+
table.add_row(["Adelaide", 1295, 1158259, 600.5])
|
|
2785
|
+
table.add_row(["Brisbane", 5905, 1857594, 1146.4])
|
|
2786
|
+
table.add_row(["Darwin", 112, 120900, 1714.7])
|
|
2787
|
+
table.add_row(["Hobart", 1357, 205556, 619.5])
|
|
2788
|
+
table.add_row(["Sydney", 2058, 4336374, 1214.8])
|
|
2789
|
+
table.add_row(["Melbourne", 1566, 3806092, 646.9])
|
|
2790
|
+
table.add_row(["Perth", 5386, 1554769, 869.4])
|
|
2791
|
+
assert (
|
|
2792
|
+
"""+-----------+-----------------+
|
|
2793
|
+
| City name | Annual Rainfall |
|
|
2794
|
+
+-----------+-----------------+
|
|
2795
|
+
| Adelaide | 600.5 |
|
|
2796
|
+
| Brisbane | 1146.4 |
|
|
2797
|
+
| Darwin | 1714.7 |
|
|
2798
|
+
| Hobart | 619.5 |
|
|
2799
|
+
| Sydney | 1214.8 |
|
|
2800
|
+
| Melbourne | 646.9 |
|
|
2801
|
+
| Perth | 869.4 |
|
|
2802
|
+
+-----------+-----------------+"""
|
|
2803
|
+
== table.get_string().strip()
|
|
2804
|
+
)
|
|
2805
|
+
|
|
2806
|
+
def test_fields(self) -> None:
|
|
2678
2807
|
table = PrettyTable()
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
)
|
|
2689
|
-
v += 3
|
|
2690
|
-
table.del_row(0)
|
|
2808
|
+
table.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
|
|
2809
|
+
table.fields = ["City name", "Annual Rainfall"]
|
|
2810
|
+
table.add_row(["Adelaide", 1295, 1158259, 600.5])
|
|
2811
|
+
table.add_row(["Brisbane", 5905, 1857594, 1146.4])
|
|
2812
|
+
table.add_row(["Darwin", 112, 120900, 1714.7])
|
|
2813
|
+
table.add_row(["Hobart", 1357, 205556, 619.5])
|
|
2814
|
+
table.add_row(["Sydney", 2058, 4336374, 1214.8])
|
|
2815
|
+
table.add_row(["Melbourne", 1566, 3806092, 646.9])
|
|
2816
|
+
table.add_row(["Perth", 5386, 1554769, 869.4])
|
|
2691
2817
|
assert (
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
|
2696
|
-
|
|
2697
|
-
|
|
|
2698
|
-
|
|
|
2699
|
-
|
|
2700
|
-
|
|
|
2701
|
-
|
|
2702
|
-
"""
|
|
2818
|
+
"""+-----------+-----------------+
|
|
2819
|
+
| City name | Annual Rainfall |
|
|
2820
|
+
+-----------+-----------------+
|
|
2821
|
+
| Adelaide | 600.5 |
|
|
2822
|
+
| Brisbane | 1146.4 |
|
|
2823
|
+
| Darwin | 1714.7 |
|
|
2824
|
+
| Hobart | 619.5 |
|
|
2825
|
+
| Sydney | 1214.8 |
|
|
2826
|
+
| Melbourne | 646.9 |
|
|
2827
|
+
| Perth | 869.4 |
|
|
2828
|
+
+-----------+-----------------+"""
|
|
2829
|
+
== table.get_string().strip()
|
|
2703
2830
|
)
|
|
2704
2831
|
|
|
2705
2832
|
|
|
2706
|
-
class TestClearing:
|
|
2707
|
-
def test_clear_rows(self, row_prettytable: PrettyTable) -> None:
|
|
2708
|
-
t = helper_table()
|
|
2709
|
-
t.add_row([0, "a", "b", "c"], divider=True)
|
|
2710
|
-
t.clear_rows()
|
|
2711
|
-
assert t.rows == []
|
|
2712
|
-
assert t.dividers == []
|
|
2713
|
-
assert t.field_names == ["", "Field 1", "Field 2", "Field 3"]
|
|
2714
|
-
|
|
2715
|
-
def test_clear(self, row_prettytable: PrettyTable) -> None:
|
|
2716
|
-
t = helper_table()
|
|
2717
|
-
t.add_row([0, "a", "b", "c"], divider=True)
|
|
2718
|
-
t.clear()
|
|
2719
|
-
assert t.rows == []
|
|
2720
|
-
assert t.dividers == []
|
|
2721
|
-
assert t.field_names == []
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
2833
|
class TestPreservingInternalBorders:
|
|
2725
2834
|
def test_internal_border_preserved(self) -> None:
|
|
2726
2835
|
pt = helper_table()
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from test_prettytable import helper_table
|
|
4
|
+
|
|
5
|
+
from prettytable import PrettyTable, TableStyle
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestRowEndSection:
|
|
9
|
+
EXPECTED_RESULT = """
|
|
10
|
+
┌──────────┬──────────┬──────────┐
|
|
11
|
+
│ Field 1 │ Field 2 │ Field 3 │
|
|
12
|
+
├──────────┼──────────┼──────────┤
|
|
13
|
+
│ value 4 │ value 5 │ value 6 │
|
|
14
|
+
│ value 7 │ value 8 │ value 9 │
|
|
15
|
+
├──────────┼──────────┼──────────┤
|
|
16
|
+
│ value 10 │ value 11 │ value 12 │
|
|
17
|
+
└──────────┴──────────┴──────────┘
|
|
18
|
+
""".strip()
|
|
19
|
+
|
|
20
|
+
def test_row_end_section_via_argument(self) -> None:
|
|
21
|
+
table = PrettyTable()
|
|
22
|
+
table.set_style(TableStyle.SINGLE_BORDER)
|
|
23
|
+
table.add_row(["value 4", "value 5", "value 6"])
|
|
24
|
+
table.add_row(["value 7", "value 8", "value 9"], divider=True)
|
|
25
|
+
table.add_row(["value 10", "value 11", "value 12"])
|
|
26
|
+
|
|
27
|
+
assert table.get_string().strip() == self.EXPECTED_RESULT
|
|
28
|
+
|
|
29
|
+
def test_row_end_section_via_method(self) -> None:
|
|
30
|
+
table = PrettyTable()
|
|
31
|
+
table.set_style(TableStyle.SINGLE_BORDER)
|
|
32
|
+
table.add_row(["value 4", "value 5", "value 6"])
|
|
33
|
+
table.add_row(["value 7", "value 8", "value 9"])
|
|
34
|
+
table.add_divider()
|
|
35
|
+
table.add_row(["value 10", "value 11", "value 12"])
|
|
36
|
+
|
|
37
|
+
assert table.get_string().strip() == self.EXPECTED_RESULT
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class TestClearing:
|
|
41
|
+
def test_clear_rows(self) -> None:
|
|
42
|
+
t = helper_table()
|
|
43
|
+
t.add_row([0, "a", "b", "c"], divider=True)
|
|
44
|
+
t.clear_rows()
|
|
45
|
+
assert t.rows == []
|
|
46
|
+
assert t.dividers == []
|
|
47
|
+
assert t.field_names == ["", "Field 1", "Field 2", "Field 3"]
|
|
48
|
+
|
|
49
|
+
def test_clear(self) -> None:
|
|
50
|
+
t = helper_table()
|
|
51
|
+
t.add_row([0, "a", "b", "c"], divider=True)
|
|
52
|
+
t.clear()
|
|
53
|
+
assert t.rows == []
|
|
54
|
+
assert t.dividers == []
|
|
55
|
+
assert t.field_names == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|