Skip to content

Commit 9f5ada9

Browse files
committed
Update docs, Taskfile
1 parent 7aabef0 commit 9f5ada9

File tree

2 files changed

+78
-5
lines changed

2 files changed

+78
-5
lines changed

README.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,67 @@
1010
- Support for `requirements()` markers
1111
- Support for test collection, with CSV export (including with xdist)
1212
- Logging utils (presets, formatters, etc.)
13-
- CLI / pre-built commands
13+
- CLI / pre-built commands (see [](./django_utils_lib/commands.py))
1414
- CLI Utils
1515

16+
1617
## Installing and Using (as a library)
1718

18-
TBD
19+
While this repo is private, you can still install it in various projects by using the git origin as the source.
20+
21+
For example, [with Poetry](https://python-poetry.org/docs/dependency-specification/#git-dependencies), you can use:
22+
23+
```bash
24+
poetry add git+https://github.com/innolitics/django-utils-lib.git#REFERENCE
25+
```
26+
27+
> [!WARNING]
28+
> Under the hood, your package manager needs to be able to authenticate against the git URL that you use. Locally, this should "Just Work", but in CI, you will need to give CI a token to access the repo (even if CI is running inside another `github.com/innolitics` repo).
29+
>
30+
> For CI purposes, you can use a read-only [GitHub deploy key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys), as an easier alternative to managing PATs or fine-grained access tokens.
31+
32+
## Pytest plugin
33+
34+
### Pytest Plugin - Discovery / Registration
35+
36+
This package is not using pytests [automated entry points](https://docs.pytest.org/en/stable/how-to/writing_plugins.html#pip-installable-plugins), instead requiring that users manually opt-in to plugin usage (since you might want other utilities in this package without enabling the pytest plugin part of it).
37+
38+
To tell Pytest to use the plugin, the easiest way is to stick this in your highest level `.conftest.py` (aka the _root_ config):
39+
40+
```py
41+
pytest_plugins = ["django_utils_lib.testing.pytest_plugin"]
42+
```
43+
44+
45+
### Pytest Plugin - Configuration
46+
47+
> [!TIP]
48+
> Note: This table was auto-generated from the source-code (and can be re-generated) via `task docs:pytest_plugin_table`
49+
50+
| Config Key | Type | Default | Help | Env Var? |
51+
|------------|------|---------|------|---------------|
52+
| `auto_debug` | `bool` | `False` | If true, the debugpy listener will be auto-invoked on the main pytest session.<br/>You can also enable this by setting `django_utils_lib_AUTO_DEBUG` as an environment variable. | `django_utils_lib_AUTO_DEBUG`: If set to any truthy value (`bool()`), will enable auto-debugging. Unless `CI` is set to `true`. |
53+
| `auto_debug_wait_for_connect` | `bool` | `False` | If true, then the auto debug feature will wait for the debugger client to connect before starting tests | `django_utils_lib_AUTO_DEBUG_WAIT_FOR_CONNECT`: If set to any truthy value (`bool()`), will enable waiting for debugger client to connect. |
54+
| `mandate_requirement_markers` | `bool` | `False` | If true, will validate that every test has a valid `pytest.mark.requirements`, and will also capture this metadata as part of the collected test data | N/A |
55+
| `reporting__csv_export_path` | `string` | `None` | If set, will save the test results to a CSV file after session completion | `django_utils_lib_REPORTING__CSV_EXPORT_PATH`: If set, will save the test results to a CSV file after session completion |
56+
| `reporting__omit_unexecuted_tests` | `bool` | `False` | If set, will exclude tests that were collected but not executed from the test report CSV | N/A |
1957

2058
## Development
2159

22-
TBD
60+
This project uses [`task` (aka `go-task`)](https://github.com/go-task/task) for developer task management and execution. [The `Taskfile.yml` file](./Taskfile.yml) serves as a way to organize these commands, as well as a form of documentation and easy entrypoint into getting started with the project.
61+
62+
You can use `task --list-all` to see all available `task` commands.
63+
64+
### Local Installation Cross-Directory
65+
66+
If you want to install a local development version of this library, in a different directory / project, you should be able to use the local path of the library in most standard Python package managers.
67+
68+
For example, this can be accomplished with Poetry with the following:
69+
70+
```bash
71+
poetry add --editable ${LOCAL_PATH_TO_THIS_DIRECTORY}
72+
```
2373

2474
### Publishing
2575

26-
TBD
76+
TBD; right now this is only available internally at Innolitics (and/or for our clients), as a private repo.

Taskfile.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,28 @@ tasks:
6868
# Run pytest
6969
poetry run pytest -n auto {{.CLI_ARGS}}
7070
#============================================================#
71-
#================= SECTION_HEADING ==========================#
71+
#================= Docs ==========================#
7272
#============================================================#
73+
docs:pytest_plugin_table:
74+
desc: Generates a Markdown table with Pytest plugin config options
75+
deps: [_verify_python_venv]
76+
cmd: |
77+
poetry run python << "EOF"
78+
from django_utils_lib.testing.pytest_plugin import PluginConfigItems
79+
80+
def generate_markdown_table(config_items):
81+
table_header = "| Config Key | Type | Default | Help | Env Var? |\n"
82+
table_header += "|------------|------|---------|------|---------------|\n"
83+
table_rows = []
84+
for key, item in config_items.items():
85+
env_override = item.get("env_var_override", None)
86+
env_override_text = f"`{env_override['name']}`: {env_override['help']}" if env_override else "N/A"
87+
help = item['help'].replace("\n", "<br/>")
88+
table_rows.append(
89+
f"| `{key}` | `{item['type']}` | `{item['default']}` | {help} | {env_override_text} |"
90+
)
91+
return table_header + "\n".join(table_rows)
92+
93+
markdown_table = generate_markdown_table(PluginConfigItems)
94+
print(markdown_table)
95+
EOF

0 commit comments

Comments
 (0)