flexablelib 3.7.0__tar.gz → 3.7.1__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.
- {flexablelib-3.7.0 → flexablelib-3.7.1}/CHANGELOG.md +36 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/PKG-INFO +9 -9
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_images.py +23 -7
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib.egg-info/PKG-INFO +9 -9
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib.egg-info/SOURCES.txt +1 -0
- flexablelib-3.7.1/flexablelib.egg-info/requires.txt +35 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/package.json +1 -1
- flexablelib-3.7.1/tests/test_v371_fixes.py +509 -0
- flexablelib-3.7.0/flexablelib.egg-info/requires.txt +0 -35
- {flexablelib-3.7.0 → flexablelib-3.7.1}/.coveragerc +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/LICENSE +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/MANIFEST.in +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/README.md +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/admin.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/dashboard.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/keys.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/video/demo.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/video/render.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/video/scenes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/examples/video/thumbnail.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/__init__.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_frames.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_legacy/__init__.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_legacy/screen.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_legacy/widgets.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_speedups.c +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/_width_tables.h +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/box_topology.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/cells.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/colors.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/columns.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/fast.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/identifiers.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/layout.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/merges.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/options.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/py.typed +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/readers.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/screen.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/style_compositions.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/table.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/table_strings.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/text_width.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/utils.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/widgets.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib/writers.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/pytest.ini +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/setup.cfg +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/setup.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/style_examples.md +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/conftest.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/helpers.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_align_indicators.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_box_topology.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_cells.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_columns.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_excel.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_issues.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_merge_fill.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_merges.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_public_api_edges.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_readme_examples.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_stress_matrix.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_style_line_widths.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_styles.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_text_width.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_upstream_issues.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v2021_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v210_rows_copy.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v2110_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v211_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v213_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v214_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v215_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v216_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v217_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v218_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v219_coverage.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v219_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v220_exports.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v221_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v222_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v223_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v224_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v230_none.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v231_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v232_merge_ansi.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v300_style_names.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v310_layout.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v320_tui.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v330_components.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v330_frames.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v330_layout.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v330_tui.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v331_formats.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v331_panel_width.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v331_readers_bom.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v331_readers_edges.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v331_tabs.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v340_accessibility.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v340_core.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v340_input.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v350_images.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v350_images_core.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v352_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v353_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v354_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v355_fixes.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v360_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/test_v370_features.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tests/wincon_child.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/bench_frames.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/bench_images.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/benchmark.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/gen_ascii_table.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/generate_width_tables.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/image_demo.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/pty_check.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/readme_gallery.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/stress_matrix.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/style_examples.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/text_to_png.py +0 -0
- {flexablelib-3.7.0 → flexablelib-3.7.1}/tools/wheel_check.py +0 -0
|
@@ -2,6 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.7.1] - 2026-11-16
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **`Form` at narrow widths**: with `columns` (or a tuple row) wider than
|
|
9
|
+
the form, drawing raised `ValueError: width must be >= 1`; fields that
|
|
10
|
+
do not get a cell each now stack below, and `grid_columns(width)` never
|
|
11
|
+
gives more columns than get one cell.
|
|
12
|
+
- **`CatalogGrid`** with `card_height` under 3 (0 divided by zero when a
|
|
13
|
+
height was given) or `min_width` under 1 (-1 divided by zero): a card
|
|
14
|
+
keeps its border and a line inside.
|
|
15
|
+
- **`SignatureInput`**: erasing (`x` / Delete) with the pen down and then
|
|
16
|
+
moving joined what was left of the drawing to the pen with a line nobody
|
|
17
|
+
drew; erasing now lifts the pen. `value` is a copy, so what a `Form`
|
|
18
|
+
collected (or `on_change` got) no longer changes as the user keeps
|
|
19
|
+
drawing.
|
|
20
|
+
- **`Stopwatch`** numbers its laps by lap also when `max_laps` dropped the
|
|
21
|
+
first ones (laps 8-10 were shown as 1-3).
|
|
22
|
+
- **`Menu` / `Sidebar`**: a `max_visible` larger than the height they are
|
|
23
|
+
drawn in hid the current item (the window was cut at the bottom); a
|
|
24
|
+
sidebar too short for its title and an item keeps the item.
|
|
25
|
+
- **`VStack`**: when the child holding the focus is taller than the view,
|
|
26
|
+
the focused component inside it is scrolled into view, not the child's
|
|
27
|
+
first rows; a `height` larger than the slot keeps to the slot (it was
|
|
28
|
+
cut off, losing the focus); a growing child left without rows keeps one
|
|
29
|
+
instead of vanishing while Tab could still land on it.
|
|
30
|
+
- **`DataTable`** with a `page_size` taller than its slot scrolls inside
|
|
31
|
+
the page, so the cursor row stays in view (it could be cut off).
|
|
32
|
+
- **`StatusLine`** stays on one line: line breaks and tabs in its parts
|
|
33
|
+
become spaces (a newline drew a second line). A long left text now gives
|
|
34
|
+
way (`…`) so the right one stays in view.
|
|
35
|
+
- **Image downloads with headers**: an invalid header value (a token with a
|
|
36
|
+
line break) was quoted in the error text shown on screen; now the error
|
|
37
|
+
says `cabecera no válida`, never the value, and the original exception
|
|
38
|
+
is not chained. Spaces and a trailing newline around header values (a
|
|
39
|
+
token read from a file) are trimmed.
|
|
40
|
+
|
|
5
41
|
## [3.7.0] - 2026-11-13
|
|
6
42
|
|
|
7
43
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.7.
|
|
3
|
+
Version: 3.7.1
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
|
|
|
46
46
|
Provides-Extra: html
|
|
47
47
|
Requires-Dist: lxml>=4.0; extra == "html"
|
|
48
48
|
Provides-Extra: tui
|
|
49
|
-
Requires-Dist: flexablelib-tui==3.7.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.7.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.7.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "speed"
|
|
54
54
|
Provides-Extra: images
|
|
55
55
|
Requires-Dist: Pillow>=8; extra == "images"
|
|
56
|
-
Requires-Dist: flexablelib-tui==3.7.
|
|
57
|
-
Requires-Dist: flexablelib-components==3.7.
|
|
56
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "images"
|
|
57
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "images"
|
|
58
58
|
Provides-Extra: svg
|
|
59
59
|
Requires-Dist: cairosvg>=2.5; extra == "svg"
|
|
60
60
|
Provides-Extra: all
|
|
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
|
|
|
62
62
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
63
63
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
64
64
|
Requires-Dist: Pillow>=8; extra == "all"
|
|
65
|
-
Requires-Dist: flexablelib-tui==3.7.
|
|
66
|
-
Requires-Dist: flexablelib-components==3.7.
|
|
67
|
-
Requires-Dist: flexablelib-speedups==3.7.
|
|
65
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "all"
|
|
66
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "all"
|
|
67
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "all"
|
|
68
68
|
Dynamic: author
|
|
69
69
|
Dynamic: author-email
|
|
70
70
|
Dynamic: classifier
|
|
@@ -750,22 +750,38 @@ def read_source(source, timeout=5.0, max_bytes=64 * 1024 * 1024,
|
|
|
750
750
|
return source.read(), getattr(source, 'name', None)
|
|
751
751
|
path = os.fspath(source)
|
|
752
752
|
if path.startswith(('http://', 'https://')):
|
|
753
|
+
from http.client import InvalidURL
|
|
754
|
+
from urllib.error import URLError
|
|
753
755
|
from urllib.request import Request, urlopen
|
|
754
756
|
try:
|
|
755
757
|
req = Request(path, headers={'User-Agent': 'flexablelib'})
|
|
756
758
|
for name, value in (headers or {}).items():
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
759
|
+
# A token read from a file keeps its newline: HTTP trims
|
|
760
|
+
# the spaces around a value anyway.
|
|
761
|
+
name, value = str(name).strip(), str(value).strip()
|
|
762
|
+
if name.lower() in _PRIVATE_HEADERS:
|
|
763
|
+
req.add_unredirected_header(name.capitalize(), value)
|
|
760
764
|
else:
|
|
761
|
-
req.add_header(
|
|
765
|
+
req.add_header(name, value)
|
|
762
766
|
with urlopen(req, timeout=timeout) as resp:
|
|
763
767
|
data = resp.read(max_bytes + 1)
|
|
764
768
|
except Exception as error:
|
|
765
769
|
code = getattr(error, 'code', None)
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
770
|
+
if isinstance(code, int):
|
|
771
|
+
reason = 'HTTP {0}'.format(code)
|
|
772
|
+
elif isinstance(error, URLError):
|
|
773
|
+
reason = error.reason
|
|
774
|
+
elif isinstance(error, InvalidURL):
|
|
775
|
+
reason = 'URL no válida'
|
|
776
|
+
elif isinstance(error, OSError):
|
|
777
|
+
reason = str(error) or type(error).__name__
|
|
778
|
+
elif isinstance(error, ValueError):
|
|
779
|
+
# http.client quotes the offending header (a token, say).
|
|
780
|
+
reason = 'cabecera no válida'
|
|
781
|
+
else:
|
|
782
|
+
reason = type(error).__name__
|
|
783
|
+
raise ImageError('no se pudo descargar ({0})'.format(reason)) \
|
|
784
|
+
from None
|
|
769
785
|
if len(data) > max_bytes:
|
|
770
786
|
raise ImageError('imagen demasiado grande')
|
|
771
787
|
return data, path
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.7.
|
|
3
|
+
Version: 3.7.1
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
|
|
|
46
46
|
Provides-Extra: html
|
|
47
47
|
Requires-Dist: lxml>=4.0; extra == "html"
|
|
48
48
|
Provides-Extra: tui
|
|
49
|
-
Requires-Dist: flexablelib-tui==3.7.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.7.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.7.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "speed"
|
|
54
54
|
Provides-Extra: images
|
|
55
55
|
Requires-Dist: Pillow>=8; extra == "images"
|
|
56
|
-
Requires-Dist: flexablelib-tui==3.7.
|
|
57
|
-
Requires-Dist: flexablelib-components==3.7.
|
|
56
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "images"
|
|
57
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "images"
|
|
58
58
|
Provides-Extra: svg
|
|
59
59
|
Requires-Dist: cairosvg>=2.5; extra == "svg"
|
|
60
60
|
Provides-Extra: all
|
|
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
|
|
|
62
62
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
63
63
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
64
64
|
Requires-Dist: Pillow>=8; extra == "all"
|
|
65
|
-
Requires-Dist: flexablelib-tui==3.7.
|
|
66
|
-
Requires-Dist: flexablelib-components==3.7.
|
|
67
|
-
Requires-Dist: flexablelib-speedups==3.7.
|
|
65
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "all"
|
|
66
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "all"
|
|
67
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "all"
|
|
68
68
|
Dynamic: author
|
|
69
69
|
Dynamic: author-email
|
|
70
70
|
Dynamic: classifier
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
[all]
|
|
3
|
+
pandas>=1.0
|
|
4
|
+
openpyxl>=3.0
|
|
5
|
+
lxml>=4.0
|
|
6
|
+
Pillow>=8
|
|
7
|
+
flexablelib-tui==3.7.1
|
|
8
|
+
flexablelib-components==3.7.1
|
|
9
|
+
flexablelib-speedups==3.7.1
|
|
10
|
+
|
|
11
|
+
[components]
|
|
12
|
+
flexablelib-components==3.7.1
|
|
13
|
+
|
|
14
|
+
[excel]
|
|
15
|
+
openpyxl>=3.0
|
|
16
|
+
|
|
17
|
+
[html]
|
|
18
|
+
lxml>=4.0
|
|
19
|
+
|
|
20
|
+
[images]
|
|
21
|
+
Pillow>=8
|
|
22
|
+
flexablelib-tui==3.7.1
|
|
23
|
+
flexablelib-components==3.7.1
|
|
24
|
+
|
|
25
|
+
[pandas]
|
|
26
|
+
pandas>=1.0
|
|
27
|
+
|
|
28
|
+
[speed]
|
|
29
|
+
flexablelib-speedups==3.7.1
|
|
30
|
+
|
|
31
|
+
[svg]
|
|
32
|
+
cairosvg>=2.5
|
|
33
|
+
|
|
34
|
+
[tui]
|
|
35
|
+
flexablelib-tui==3.7.1
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
"""3.7.1: fixes found testing the 3.6.0 / 3.7.0 components -- narrow forms,
|
|
2
|
+
catalog cards with small heights, the signature pad's eraser and value,
|
|
3
|
+
stopwatch lap numbers, menus and sidebars drawn shorter than max_visible,
|
|
4
|
+
VStack following the focus inside tall children, DataTable pages taller
|
|
5
|
+
than their slot, one-line status bars and image download errors that must
|
|
6
|
+
not quote a header."""
|
|
7
|
+
|
|
8
|
+
import http.server
|
|
9
|
+
import threading
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
C = pytest.importorskip('flexablelib_components')
|
|
14
|
+
|
|
15
|
+
from flexablelib import _images as I # noqa: E402
|
|
16
|
+
from flexablelib_tui import App, Key, ScrollView # noqa: E402
|
|
17
|
+
from flexablelib_tui import accessibility as a11y # noqa: E402
|
|
18
|
+
from flexablelib_tui.keys import MouseEvent # noqa: E402
|
|
19
|
+
from flexablelib.text_width import strip_ansi, visible_width # noqa: E402
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture(autouse=True)
|
|
23
|
+
def plain_a11y():
|
|
24
|
+
with a11y.configure(screen_reader=False, ascii=False, reduced_motion=False,
|
|
25
|
+
focus_marker=False):
|
|
26
|
+
yield
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def key(name):
|
|
30
|
+
if name == 'space':
|
|
31
|
+
return Key('space', ' ')
|
|
32
|
+
if len(name) == 1:
|
|
33
|
+
return Key(name, name)
|
|
34
|
+
return Key(name)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def lines(comp, width=30, height=None):
|
|
38
|
+
return strip_ansi(comp.render(width=width, height=height)).split('\n')
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def same_width(out, width):
|
|
42
|
+
return all(visible_width(line) == width for line in out)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# +---------------------------------------------------------------------------+
|
|
46
|
+
# Form at narrow widths
|
|
47
|
+
|
|
48
|
+
class TestNarrowForm:
|
|
49
|
+
def fields(self):
|
|
50
|
+
return [C.TextInput('Nombre', name='a'), C.TextInput('B', name='b'),
|
|
51
|
+
C.TextInput('C', name='c')]
|
|
52
|
+
|
|
53
|
+
@pytest.mark.parametrize('columns', [2, 3, 4])
|
|
54
|
+
@pytest.mark.parametrize('width', [1, 2, 3, 4, 5, 7])
|
|
55
|
+
def test_columns_never_fail(self, columns, width):
|
|
56
|
+
form = C.Form(self.fields(), columns=columns, use_colors=False)
|
|
57
|
+
assert same_width(lines(form, width), width)
|
|
58
|
+
row = C.Form([tuple(self.fields())], use_colors=False)
|
|
59
|
+
assert same_width(lines(row, width), width)
|
|
60
|
+
|
|
61
|
+
@pytest.mark.parametrize('width', [1, 2, 3, 5, 8])
|
|
62
|
+
def test_grid_layout_never_fails(self, width):
|
|
63
|
+
a, b, c = self.fields()
|
|
64
|
+
form = C.Form([C.FormCell(a, span=2), b, c], columns=4,
|
|
65
|
+
use_colors=False)
|
|
66
|
+
assert same_width(lines(form, width), width)
|
|
67
|
+
assert 1 <= form.grid_columns(width) <= max(1, (width + 2) // 3)
|
|
68
|
+
|
|
69
|
+
def test_fields_that_do_not_fit_stack(self):
|
|
70
|
+
form = C.Form(self.fields(), columns=3, use_colors=False)
|
|
71
|
+
out = lines(form, 7)
|
|
72
|
+
labels = [l for l in out if l.strip()[:1] in ('N', 'B', 'C')]
|
|
73
|
+
assert labels[0].split() == ['N', 'B', 'C']
|
|
74
|
+
wide = lines(form, 60)
|
|
75
|
+
assert 'Nombre' in wide[0] and 'B' in wide[0]
|
|
76
|
+
assert form.grid_columns(60) == 3 and form.grid_columns(1) == 1
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# +---------------------------------------------------------------------------+
|
|
80
|
+
# CatalogGrid with small cards
|
|
81
|
+
|
|
82
|
+
class TestCatalogSmallCards:
|
|
83
|
+
ITEMS = [{'title': 'Uno', 'price': 1}, {'title': 'Dos'},
|
|
84
|
+
{'title': 'Tres', 'subtitle': 'x'}]
|
|
85
|
+
|
|
86
|
+
@pytest.mark.parametrize('card_height', [-1, 0, 1, 2])
|
|
87
|
+
def test_tiny_card_height(self, card_height):
|
|
88
|
+
g = C.CatalogGrid(self.ITEMS, card_height=card_height, min_width=8,
|
|
89
|
+
use_colors=False)
|
|
90
|
+
assert g._card_rows() == 3
|
|
91
|
+
for height in (None, 1, 2, 5):
|
|
92
|
+
out = lines(g, 30, height)
|
|
93
|
+
assert same_width(out, 30)
|
|
94
|
+
assert any('Uno' in l for l in lines(g, 30, 3))
|
|
95
|
+
|
|
96
|
+
@pytest.mark.parametrize('min_width', [-5, -1, 0])
|
|
97
|
+
def test_non_positive_min_width(self, min_width):
|
|
98
|
+
g = C.CatalogGrid(self.ITEMS, min_width=min_width, use_colors=False)
|
|
99
|
+
assert same_width(lines(g, 20, 6), 20)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# +---------------------------------------------------------------------------+
|
|
103
|
+
# SignatureInput
|
|
104
|
+
|
|
105
|
+
class TestSignature:
|
|
106
|
+
def test_erasing_lifts_the_pen(self):
|
|
107
|
+
s = C.SignatureInput('Firma', columns=10, rows=3)
|
|
108
|
+
s.focused = True
|
|
109
|
+
for k in ['space', 'right', 'right', 'space', 'right', 'right',
|
|
110
|
+
'right', 'space']:
|
|
111
|
+
s.handle_key(key(k))
|
|
112
|
+
assert s.value == [[(0, 0), (1, 0), (2, 0)], [(5, 0)]]
|
|
113
|
+
assert s.pen_down
|
|
114
|
+
s.handle_key(key('x')) # erases the dot under the pen
|
|
115
|
+
assert not s.pen_down
|
|
116
|
+
assert s.value == [[(0, 0), (1, 0), (2, 0)]]
|
|
117
|
+
s.handle_key(key('right')) # pen up: draws nothing
|
|
118
|
+
assert s.value == [[(0, 0), (1, 0), (2, 0)]]
|
|
119
|
+
assert s.to_text()[0] == '### '
|
|
120
|
+
s.handle_key(key('space')) # down again: a new stroke
|
|
121
|
+
s.handle_key(key('right'))
|
|
122
|
+
assert s.value == [[(0, 0), (1, 0), (2, 0)], [(6, 0), (7, 0)]]
|
|
123
|
+
|
|
124
|
+
def test_erase_in_the_middle_of_a_stroke(self):
|
|
125
|
+
s = C.SignatureInput(columns=6, rows=1)
|
|
126
|
+
s.begin((0, 0))
|
|
127
|
+
s.extend((5, 0))
|
|
128
|
+
s.pen = (2, 0)
|
|
129
|
+
s.pen_down = True
|
|
130
|
+
s.erase((2, 0))
|
|
131
|
+
assert not s.pen_down
|
|
132
|
+
assert s.cells() == {(0, 0), (1, 0), (3, 0), (4, 0), (5, 0)}
|
|
133
|
+
|
|
134
|
+
def test_value_is_a_copy(self):
|
|
135
|
+
s = C.SignatureInput('Firma', columns=5, rows=2, name='firma')
|
|
136
|
+
form = C.Form([s])
|
|
137
|
+
s.begin((0, 0))
|
|
138
|
+
collected = form.values()
|
|
139
|
+
s.extend((3, 0))
|
|
140
|
+
s.begin((1, 1))
|
|
141
|
+
assert collected == {'firma': [[(0, 0)]]}
|
|
142
|
+
got = []
|
|
143
|
+
s2 = C.SignatureInput(columns=4, rows=1, on_change=got.append)
|
|
144
|
+
s2.begin((0, 0))
|
|
145
|
+
s2.extend((2, 0))
|
|
146
|
+
assert got == [[[(0, 0)]], [[(0, 0), (1, 0), (2, 0)]]]
|
|
147
|
+
v = s2.value
|
|
148
|
+
v[0].append((3, 0))
|
|
149
|
+
v.append([(9, 9)])
|
|
150
|
+
assert s2.strokes == [[(0, 0), (1, 0), (2, 0)]]
|
|
151
|
+
s2.value = [[(1, 0)]]
|
|
152
|
+
assert s2.value == [[(1, 0)]] and not s2.is_empty()
|
|
153
|
+
|
|
154
|
+
def test_submitted_snapshot(self):
|
|
155
|
+
got = []
|
|
156
|
+
s = C.SignatureInput('Firma', columns=5, rows=2, name='firma')
|
|
157
|
+
s.begin((0, 0))
|
|
158
|
+
C.Form([s], on_submit=got.append).submit()
|
|
159
|
+
s.extend((4, 1))
|
|
160
|
+
assert got == [{'firma': [[(0, 0)]]}]
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# +---------------------------------------------------------------------------+
|
|
164
|
+
# Stopwatch lap numbers
|
|
165
|
+
|
|
166
|
+
class TestStopwatchLaps:
|
|
167
|
+
def test_numbers_follow_the_laps_dropped(self):
|
|
168
|
+
now = [0.0]
|
|
169
|
+
w = C.Stopwatch('t', clock=lambda: now[0], max_laps=3,
|
|
170
|
+
use_colors=False)
|
|
171
|
+
w.start()
|
|
172
|
+
for _ in range(10):
|
|
173
|
+
now[0] += 1
|
|
174
|
+
w.lap()
|
|
175
|
+
out = [l.strip() for l in lines(w, 40)]
|
|
176
|
+
assert out[2:] == ['8. 00:00:08.0', '9. 00:00:09.0',
|
|
177
|
+
'10. 00:00:10.0']
|
|
178
|
+
w.reset()
|
|
179
|
+
now[0] += 1
|
|
180
|
+
w.lap()
|
|
181
|
+
assert [l.strip() for l in lines(w, 40)][2] == '1. 00:00:01.0'
|
|
182
|
+
|
|
183
|
+
def test_without_max_laps_shows_the_last_five(self):
|
|
184
|
+
now = [0.0]
|
|
185
|
+
w = C.Stopwatch('t', clock=lambda: now[0], use_colors=False)
|
|
186
|
+
w.start()
|
|
187
|
+
for _ in range(7):
|
|
188
|
+
now[0] += 1
|
|
189
|
+
w.lap()
|
|
190
|
+
out = [l.strip() for l in lines(w, 40)]
|
|
191
|
+
assert out[2].startswith('3. ') and out[-1].startswith('7. ')
|
|
192
|
+
w.laps = [] # set from code: numbered from 1
|
|
193
|
+
assert len(lines(w, 40)) == 2
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
# +---------------------------------------------------------------------------+
|
|
197
|
+
# Menu and Sidebar shorter than max_visible
|
|
198
|
+
|
|
199
|
+
class TestMenuWindow:
|
|
200
|
+
@pytest.mark.parametrize('height', [1, 2, 3, 4])
|
|
201
|
+
def test_current_item_stays_in_view(self, height):
|
|
202
|
+
m = C.Menu(['Op{0:02d}'.format(i) for i in range(20)], max_visible=8,
|
|
203
|
+
use_colors=False)
|
|
204
|
+
m.focused = True
|
|
205
|
+
for _ in range(13):
|
|
206
|
+
m.handle_key(key('down'))
|
|
207
|
+
out = lines(m, 20, height)
|
|
208
|
+
assert len(out) == height
|
|
209
|
+
assert any('Op13' in l for l in out)
|
|
210
|
+
if height >= 3:
|
|
211
|
+
assert out[0].startswith(' ^') and out[-1].startswith(' v')
|
|
212
|
+
|
|
213
|
+
def test_counts_add_up(self):
|
|
214
|
+
m = C.Menu(['Op{0:02d}'.format(i) for i in range(20)], max_visible=8,
|
|
215
|
+
use_colors=False)
|
|
216
|
+
m.focused = True
|
|
217
|
+
for _ in range(10):
|
|
218
|
+
m.handle_key(key('down'))
|
|
219
|
+
out = lines(m, 20, 5)
|
|
220
|
+
shown = [l for l in out if 'Op' in l]
|
|
221
|
+
above = int(out[0].split()[1])
|
|
222
|
+
below = int(out[-1].split()[1])
|
|
223
|
+
assert above + len(shown) + below == 20
|
|
224
|
+
assert m._page == 3 # a page is the window shown
|
|
225
|
+
m.render(width=20, height=5)
|
|
226
|
+
m.on_mouse(MouseEvent(0, 2, 4, True)) # the ▼ line pages down
|
|
227
|
+
assert m.index > 10
|
|
228
|
+
|
|
229
|
+
def test_max_visible_smaller_than_height(self):
|
|
230
|
+
m = C.Menu(['Op{0:02d}'.format(i) for i in range(20)], max_visible=4,
|
|
231
|
+
use_colors=False)
|
|
232
|
+
assert len(lines(m, 20, 10)) == 4
|
|
233
|
+
|
|
234
|
+
@pytest.mark.parametrize('height', [1, 2, 3])
|
|
235
|
+
def test_sidebar_short_with_title(self, height):
|
|
236
|
+
picked = []
|
|
237
|
+
sb = C.Sidebar({'Sec': ['Uno', 'Dos', 'Tres', 'Cuatro', 'Cinco']},
|
|
238
|
+
title='Menú', use_colors=False,
|
|
239
|
+
on_select=lambda i, item: picked.append(item['label']))
|
|
240
|
+
sb.focused = True
|
|
241
|
+
sb.handle_key(key('down'))
|
|
242
|
+
sb.handle_key(key('down'))
|
|
243
|
+
out = lines(sb, 12, height)
|
|
244
|
+
assert len(out) == height
|
|
245
|
+
row = [n for n, l in enumerate(out) if 'Tres' in l]
|
|
246
|
+
assert row
|
|
247
|
+
if height >= 2:
|
|
248
|
+
assert 'Menú' in out[0]
|
|
249
|
+
sb.on_mouse(MouseEvent(0, 3, row[0], True))
|
|
250
|
+
assert picked == ['Tres']
|
|
251
|
+
|
|
252
|
+
def test_sidebar_max_visible_and_height(self):
|
|
253
|
+
sb = C.Sidebar({'A': ['a{0}'.format(i) for i in range(15)]},
|
|
254
|
+
max_visible=10, use_colors=False)
|
|
255
|
+
sb.focused = True
|
|
256
|
+
sb.handle_key(key('end'))
|
|
257
|
+
out = lines(sb, 12, 5)
|
|
258
|
+
assert len(out) == 5 and 'a14' in out[-1]
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
# +---------------------------------------------------------------------------+
|
|
262
|
+
# VStack
|
|
263
|
+
|
|
264
|
+
def run_app(body, size):
|
|
265
|
+
app = App(body=body)
|
|
266
|
+
app.run(keys=[], size=size)
|
|
267
|
+
return app
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class TestVStackFocus:
|
|
271
|
+
def test_follows_the_component_inside_a_tall_child(self):
|
|
272
|
+
fields = [C.TextInput('Campo{0}'.format(i)) for i in range(4)]
|
|
273
|
+
vs = C.VStack([C.Stack(fields)])
|
|
274
|
+
app = run_app(vs, (24, 4))
|
|
275
|
+
for i in range(1, 4):
|
|
276
|
+
app.dispatch(key('tab'))
|
|
277
|
+
frame = strip_ansi(app.render(24, 4))
|
|
278
|
+
assert app.focused is fields[i]
|
|
279
|
+
assert 'Campo{0}'.format(i) in frame
|
|
280
|
+
app.dispatch(key('shift+tab'))
|
|
281
|
+
app.dispatch(key('shift+tab'))
|
|
282
|
+
assert 'Campo1' in strip_ansi(app.render(24, 4))
|
|
283
|
+
|
|
284
|
+
def test_fixed_height_taller_than_the_slot(self):
|
|
285
|
+
fields = [C.TextInput('Campo{0}'.format(i)) for i in range(3)]
|
|
286
|
+
vs = C.VStack([C.Stack(fields[:1]), C.Stack(fields[1:])], height=6)
|
|
287
|
+
app = run_app(vs, (24, 3))
|
|
288
|
+
assert vs.view_height == 3
|
|
289
|
+
while app.focused is not fields[2]:
|
|
290
|
+
app.dispatch(key('tab'))
|
|
291
|
+
assert 'Campo2' in strip_ansi(app.render(24, 3))
|
|
292
|
+
lines(vs, 24, 10)
|
|
293
|
+
assert vs.view_height == 6 # a taller slot: its own
|
|
294
|
+
|
|
295
|
+
def test_growing_child_keeps_a_row(self):
|
|
296
|
+
view = ScrollView('\n'.join('línea {0}'.format(i) for i in range(9)))
|
|
297
|
+
top = C.Stack([C.TextInput('A'), C.TextInput('B')])
|
|
298
|
+
vs = C.VStack([top, view])
|
|
299
|
+
app = run_app(vs, (24, 4))
|
|
300
|
+
assert vs.heights[1] >= 1
|
|
301
|
+
app.focus(view)
|
|
302
|
+
frame = strip_ansi(app.render(24, 4))
|
|
303
|
+
assert 'línea' in frame
|
|
304
|
+
# weights given: a child with weight keeps a row too, unless capped.
|
|
305
|
+
capped = C.VStack([C.Stack([C.TextInput('A'), C.TextInput('B')]),
|
|
306
|
+
ScrollView('x')], max_heights=[None, 0])
|
|
307
|
+
capped.render(width=20, height=4)
|
|
308
|
+
assert capped.heights[1] == 0
|
|
309
|
+
|
|
310
|
+
def test_sharing_unchanged_when_there_is_room(self):
|
|
311
|
+
a = C.DataTable(['n'], [[i] for i in range(30)], fill=True)
|
|
312
|
+
b = C.DataTable(['n'], [[i] for i in range(30)], fill=True)
|
|
313
|
+
vs = C.VStack([a, b])
|
|
314
|
+
vs.render(width=20, height=20)
|
|
315
|
+
assert vs.heights == [10, 10]
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# +---------------------------------------------------------------------------+
|
|
319
|
+
# DataTable pages taller than the slot
|
|
320
|
+
|
|
321
|
+
class TestDataTablePages:
|
|
322
|
+
def cursor_line(self, out):
|
|
323
|
+
return [l for l in out if l.startswith('>')]
|
|
324
|
+
|
|
325
|
+
@pytest.mark.parametrize('height', [4, 5, 6, 8])
|
|
326
|
+
def test_cursor_row_in_view(self, height):
|
|
327
|
+
t = C.DataTable(['id'], [[i] for i in range(23)], page_size=10,
|
|
328
|
+
fill=True, use_colors=False)
|
|
329
|
+
t.focused = True
|
|
330
|
+
for steps in (0, 7, 9, 12, 22):
|
|
331
|
+
t.cursor_row = steps
|
|
332
|
+
out = lines(t, 20, height)
|
|
333
|
+
assert len(out) == height
|
|
334
|
+
current = self.cursor_line(out)
|
|
335
|
+
assert current and current[0].split() == ['>', str(steps)] or \
|
|
336
|
+
current and current[0][1:].split() == [str(steps)]
|
|
337
|
+
assert 'pág. {0}/3'.format(steps // 10 + 1) in out[-1]
|
|
338
|
+
shown = [int(l[1:].split()[0]) for l in out[2:-1]
|
|
339
|
+
if l[1:].split() and l[1:].split()[0].isdigit()]
|
|
340
|
+
# Only rows of the current page.
|
|
341
|
+
assert all(n // 10 == steps // 10 for n in shown)
|
|
342
|
+
|
|
343
|
+
def test_page_fits_unchanged(self):
|
|
344
|
+
t = C.DataTable(['id'], [[i] for i in range(23)], page_size=5,
|
|
345
|
+
use_colors=False)
|
|
346
|
+
t.cursor_row = 7
|
|
347
|
+
out = lines(t, 20, 20)
|
|
348
|
+
assert [l.split()[0] for l in out[2:7]] == ['5', '6', '7', '8', '9']
|
|
349
|
+
assert t.top == 5 and t.visible_rows == 5
|
|
350
|
+
|
|
351
|
+
def test_height_attribute_smaller_than_page(self):
|
|
352
|
+
t = C.DataTable(['id'], [[i] for i in range(30)], page_size=10,
|
|
353
|
+
height=3, use_colors=False)
|
|
354
|
+
t.focused = True
|
|
355
|
+
t.handle_key(key('end'))
|
|
356
|
+
out = lines(t, 20)
|
|
357
|
+
assert any(l.startswith('>') and '29' in l for l in out)
|
|
358
|
+
t.handle_key(key('pageup'))
|
|
359
|
+
assert t.cursor_row == 19
|
|
360
|
+
out = lines(t, 20)
|
|
361
|
+
assert any(l.startswith('>') and '19' in l for l in out)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
# +---------------------------------------------------------------------------+
|
|
365
|
+
# StatusLine
|
|
366
|
+
|
|
367
|
+
class TestStatusLineOneLine:
|
|
368
|
+
def test_line_breaks_and_tabs(self):
|
|
369
|
+
s = C.StatusLine('a\nb', 'c\r\nd', 'e\tf', use_colors=False)
|
|
370
|
+
out = s.render(width=20)
|
|
371
|
+
assert '\n' not in out and '\t' not in out
|
|
372
|
+
assert visible_width(out) == 20
|
|
373
|
+
assert s.parts() == ('a b', 'c d', 'e f')
|
|
374
|
+
assert s.a11y_value() == 'a b · c d · e f'
|
|
375
|
+
assert C.StatusLine(lambda: 'x\u2028y').parts()[0] == 'x y'
|
|
376
|
+
|
|
377
|
+
def test_right_text_stays_in_view(self):
|
|
378
|
+
s = C.StatusLine('Guardando el archivo de clientes', '', '12/40',
|
|
379
|
+
kind='info', use_colors=False)
|
|
380
|
+
for width in (10, 12, 20, 30):
|
|
381
|
+
out = strip_ansi(s.render(width=width))
|
|
382
|
+
assert out.endswith('12/40 ') and visible_width(out) == width
|
|
383
|
+
assert '…' in out
|
|
384
|
+
assert strip_ansi(s.render(width=80)).startswith(
|
|
385
|
+
' ℹ Guardando el archivo de clientes')
|
|
386
|
+
# Too narrow for both: the left text wins, as before.
|
|
387
|
+
assert strip_ansi(s.render(width=6)).startswith(' ℹ')
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
# +---------------------------------------------------------------------------+
|
|
391
|
+
# Image download errors never quote a header
|
|
392
|
+
|
|
393
|
+
class _Handler(http.server.BaseHTTPRequestHandler):
|
|
394
|
+
seen = []
|
|
395
|
+
|
|
396
|
+
def log_message(self, *args):
|
|
397
|
+
pass
|
|
398
|
+
|
|
399
|
+
def do_GET(self):
|
|
400
|
+
_Handler.seen.append(self.headers.get('Authorization'))
|
|
401
|
+
data = I.encode_png(I.Bitmap(1, 1, b'\x00\x00\x00\xff'))
|
|
402
|
+
self.send_response(200)
|
|
403
|
+
self.send_header('Content-Type', 'image/png')
|
|
404
|
+
self.send_header('Content-Length', str(len(data)))
|
|
405
|
+
self.end_headers()
|
|
406
|
+
self.wfile.write(data)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
@pytest.fixture
|
|
410
|
+
def server():
|
|
411
|
+
_Handler.seen = []
|
|
412
|
+
srv = http.server.HTTPServer(('127.0.0.1', 0), _Handler)
|
|
413
|
+
thread = threading.Thread(target=srv.serve_forever, daemon=True)
|
|
414
|
+
thread.start()
|
|
415
|
+
yield 'http://127.0.0.1:{0}'.format(srv.server_address[1])
|
|
416
|
+
srv.shutdown()
|
|
417
|
+
srv.server_close()
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
class TestImageHeaderErrors:
|
|
421
|
+
@pytest.mark.parametrize('value', ['Bearer SECRETO\r\nX-Otro: 1',
|
|
422
|
+
'Bearer SE\nCRETO'])
|
|
423
|
+
def test_invalid_value_not_quoted(self, value):
|
|
424
|
+
with pytest.raises(I.ImageError) as info:
|
|
425
|
+
I.read_source('http://127.0.0.1:9/x.png', timeout=0.5,
|
|
426
|
+
headers={'Authorization': value})
|
|
427
|
+
assert 'SECRETO' not in str(info.value) and \
|
|
428
|
+
'CRETO' not in str(info.value)
|
|
429
|
+
assert 'cabecera no válida' in str(info.value)
|
|
430
|
+
assert info.value.__suppress_context__
|
|
431
|
+
|
|
432
|
+
def test_invalid_name_not_quoted(self):
|
|
433
|
+
with pytest.raises(I.ImageError) as info:
|
|
434
|
+
I.read_source('http://127.0.0.1:9/x.png', timeout=0.5,
|
|
435
|
+
headers={'X-SECRETO\n': 'v'})
|
|
436
|
+
assert 'SECRETO' not in str(info.value)
|
|
437
|
+
|
|
438
|
+
def test_value_with_a_trailing_newline_is_trimmed(self, server):
|
|
439
|
+
bm = I.load(server + '/x.png',
|
|
440
|
+
headers={'Authorization': 'Bearer s3cr3t\n'})
|
|
441
|
+
assert (bm.width, bm.height) == (1, 1)
|
|
442
|
+
assert _Handler.seen == ['Bearer s3cr3t']
|
|
443
|
+
|
|
444
|
+
def test_other_errors(self):
|
|
445
|
+
with pytest.raises(I.ImageError) as info:
|
|
446
|
+
I.read_source('http://127.0.0.1:9/x.png', timeout=0.5)
|
|
447
|
+
assert 'no se pudo descargar' in str(info.value)
|
|
448
|
+
with pytest.raises(I.ImageError) as info:
|
|
449
|
+
I.read_source('http://127.0.0.1:9/a b\x01.png', timeout=0.5)
|
|
450
|
+
assert 'no se pudo descargar' in str(info.value)
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
# +---------------------------------------------------------------------------+
|
|
454
|
+
# Public API branches without tests until now
|
|
455
|
+
|
|
456
|
+
class TestUncoveredBranches:
|
|
457
|
+
def test_form_and_catalog_a11y(self):
|
|
458
|
+
form = C.Form([C.TextInput('Nombre', name='n', required=True)],
|
|
459
|
+
title='Alta')
|
|
460
|
+
assert form.a11y_value() == '' and form.a11y_name() == 'Alta'
|
|
461
|
+
form.validate()
|
|
462
|
+
assert form.a11y_value() == '1 errores'
|
|
463
|
+
assert C.CatalogGrid([]).a11y_value() == 'Sin elementos'
|
|
464
|
+
g = C.CatalogGrid([{'title': 'Pan', 'price': 12.5}, {'title': 'Sal'}])
|
|
465
|
+
assert g.a11y_value() == 'Pan (1 de 2), precio 12.5'
|
|
466
|
+
g.index = 1
|
|
467
|
+
assert g.a11y_value() == 'Sal (2 de 2)'
|
|
468
|
+
|
|
469
|
+
def test_datatable_page_scrolls_back_up(self):
|
|
470
|
+
t = C.DataTable(['id'], [[i] for i in range(30)], page_size=10,
|
|
471
|
+
use_colors=False)
|
|
472
|
+
t.focused = True
|
|
473
|
+
t.cursor_row = 9
|
|
474
|
+
lines(t, 20, 5)
|
|
475
|
+
assert t.top == 8 # 2 rows fit: 8 and 9
|
|
476
|
+
t.cursor_row = 3 # above the window, same page
|
|
477
|
+
out = lines(t, 20, 5)
|
|
478
|
+
assert t.top == 3 and out[2].startswith('>')
|
|
479
|
+
|
|
480
|
+
def test_toast_and_help_close_on_click_and_key(self):
|
|
481
|
+
app = App(body=C.Stack([C.TextInput('A')]))
|
|
482
|
+
app.run(keys=[], size=(40, 10))
|
|
483
|
+
app.notify('Guardado', kind='success', seconds=60)
|
|
484
|
+
app.render(40, 10)
|
|
485
|
+
toast = [n for n in app.walk() if type(n).__name__ == '_Toast']
|
|
486
|
+
assert len(toast) == 1
|
|
487
|
+
assert not toast[0].on_mouse(MouseEvent(0, 0, 0, False))
|
|
488
|
+
assert toast[0].on_mouse(MouseEvent(0, 0, 0, True))
|
|
489
|
+
assert not [n for n in app.walk() if type(n).__name__ == '_Toast']
|
|
490
|
+
app.show_help()
|
|
491
|
+
top = app._modal()
|
|
492
|
+
assert type(top).__name__ == '_Help'
|
|
493
|
+
assert top.on_mouse(MouseEvent(0, 0, 0, True))
|
|
494
|
+
assert app._modal() is None
|
|
495
|
+
app.show_help()
|
|
496
|
+
top = app._modal()
|
|
497
|
+
assert not top.on_mouse(MouseEvent(0, 0, 0, False))
|
|
498
|
+
assert top.handle_key(key('x')) and app._modal() is None
|
|
499
|
+
|
|
500
|
+
def test_file_input_a11y_when_open(self, tmp_path):
|
|
501
|
+
(tmp_path / 'b.txt').write_text('x')
|
|
502
|
+
(tmp_path / 'a').mkdir()
|
|
503
|
+
f = C.FileInput('Archivo', directory=str(tmp_path))
|
|
504
|
+
assert 'collapsed' in f.a11y_state()
|
|
505
|
+
f.focused = True
|
|
506
|
+
f.handle_key(key('enter'))
|
|
507
|
+
assert f.open and 'expanded' in f.a11y_state()
|
|
508
|
+
assert f.a11y_value().endswith('(carpeta)') or \
|
|
509
|
+
f.a11y_value() in ('..', 'a', 'b.txt')
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[all]
|
|
3
|
-
pandas>=1.0
|
|
4
|
-
openpyxl>=3.0
|
|
5
|
-
lxml>=4.0
|
|
6
|
-
Pillow>=8
|
|
7
|
-
flexablelib-tui==3.7.0
|
|
8
|
-
flexablelib-components==3.7.0
|
|
9
|
-
flexablelib-speedups==3.7.0
|
|
10
|
-
|
|
11
|
-
[components]
|
|
12
|
-
flexablelib-components==3.7.0
|
|
13
|
-
|
|
14
|
-
[excel]
|
|
15
|
-
openpyxl>=3.0
|
|
16
|
-
|
|
17
|
-
[html]
|
|
18
|
-
lxml>=4.0
|
|
19
|
-
|
|
20
|
-
[images]
|
|
21
|
-
Pillow>=8
|
|
22
|
-
flexablelib-tui==3.7.0
|
|
23
|
-
flexablelib-components==3.7.0
|
|
24
|
-
|
|
25
|
-
[pandas]
|
|
26
|
-
pandas>=1.0
|
|
27
|
-
|
|
28
|
-
[speed]
|
|
29
|
-
flexablelib-speedups==3.7.0
|
|
30
|
-
|
|
31
|
-
[svg]
|
|
32
|
-
cairosvg>=2.5
|
|
33
|
-
|
|
34
|
-
[tui]
|
|
35
|
-
flexablelib-tui==3.7.0
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|