-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Helveg/pytest
Reworked documentation and formalize test suite
- Loading branch information
Showing
11 changed files
with
149 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
import os | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def skip_if_windows(): | ||
if os.name == "nt": | ||
pytest.exit("Test suite not supported on Windows. Please use WSL.") | ||
else: | ||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_build | ||
_autosummary |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{ fullname }} | ||
{{ underline }} | ||
|
||
.. automodule:: {{ fullname }} | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
API Reference | ||
============= | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary | ||
|
||
dashing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Development | ||
----------- | ||
|
||
``dashing`` welcomes all contributions. | ||
|
||
Testing | ||
======= | ||
|
||
We use ``pytest`` for the test suite, ``pyte`` to emulate a terminal, and ``pexpect`` to spawn a process and communicate | ||
with the emulated terminal per test. ``pexpect`` does not fully support Windows, so the test suite can only run on WSL | ||
for Windows users. | ||
|
||
You can run the testsuite simply by running:: | ||
|
||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
Getting Started | ||
=============== | ||
|
||
Setting up a basic application | ||
------------------------------ | ||
|
||
Dashing lets you create elegantly tiled interfaces for your terminal application user interface (TUI). Create your TUI | ||
by constructing a suitable root :class:`.Tile`. The simplest possible example would be to create a single :class:`.Text` tile: | ||
|
||
.. code-block:: python | ||
from dashing import Text, open_terminal | ||
ui = Text(text="Hello World, this is dashing!", color=0) | ||
with open_terminal() as terminal: | ||
ui.display(terminal) | ||
input("\nPress Enter to quit") | ||
You should see the Dashing TUI open, display the application, wait for input, and then clean itself up. | ||
|
||
.. warning:: | ||
|
||
We use color ``0``, black, which might not contrast enough with your terminal's color to be visible! Try another number | ||
between 0-7 (included) if you don't see anything. | ||
|
||
|
||
.. admonition:: Note - Terminals | ||
:class: note | ||
|
||
We use the :func:`.open_terminal` helper to open an underlying Blessed terminal. If you wish to integrate Dashing into | ||
an existing Blessed application, you can simply pass an existing ``Terminal`` object. Without using a proper Terminal | ||
context, calls to ``ui.display()`` may leave the user's terminal in a messy state! | ||
|
||
The power of Dashing shines when you combine it with an event loop, and make periodic calls to ``ui.display()`` to | ||
update and redraw the screen. | ||
|
||
Let's create an application with a title, border, and 2 horizontal gauges that increment decrement for a couple of | ||
seconds: | ||
|
||
|
||
.. code-block:: python | ||
from dashing import HGauge, HSplit, Text, open_terminal | ||
ui = HSplit( | ||
HGauge(), | ||
HGauge(val=100), | ||
border_color=3, | ||
title="My First App" | ||
) | ||
with open_terminal() as terminal: | ||
for i in range(100): | ||
ui.items[0].value = i % 101 | ||
ui.items[1].value = (100 - (i % 101)) | ||
ui.display(terminal) | ||
time.sleep(1 / 25) | ||
As you can see, Dashing added a border and a title around the root tile, and periodically redraws the screen with the | ||
new values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
dashing | ||
------- | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
Overview | ||
======== | ||
getting_started | ||
developers | ||
api | ||
|
||
.. automodule:: dashing | ||
:members: | ||
Installation | ||
============ | ||
|
||
You can install the package with:: | ||
|
||
pip install dashing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters