-
Notifications
You must be signed in to change notification settings - Fork 127
ci: enable doctests #1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: enable doctests #1991
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -943,10 +943,16 @@ def _event_context(self, event_name: str): | |
| is completed. | ||
|
|
||
| Usage: | ||
|
|
||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is private, so only someone developing Ops would see it. |
||
| >>> import ops | ||
| >>> from ops import testing | ||
| >>> harness = testing.Harness(ops.CharmBase) | ||
| >>> with harness._event_context('db-relation-changed'): | ||
| >>> print('Harness thinks it is running an event hook.') | ||
| ... # Harness thinks it is running an event hook. | ||
| ... pass | ||
| >>> with harness._event_context(''): | ||
| >>> print('harness thinks it is not running an event hook.') | ||
| ... # Harness thinks it is not running an event hook. | ||
| ... pass | ||
| """ | ||
| backend: _ModelBackend | None = self.model._backend if self.model else None | ||
| if not backend: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,13 +91,16 @@ passenv = | |
| PEBBLE | ||
| dependency_groups = unit, xdist | ||
| commands = | ||
| pytest -n auto \ | ||
| pytest --doctest-modules -n auto \ | ||
| --ignore={toxinidir}/docs \ | ||
| --ignore={toxinidir}/release.py \ | ||
| --ignore={[vars]tst_path}smoke \ | ||
| --ignore={[vars]tst_path}integration \ | ||
| --ignore={[vars]tst_path}benchmark \ | ||
| --ignore={[vars]testing_tst_path}benchmark \ | ||
| --ignore={[vars]tracing_tst_path} \ | ||
| --ignore={[vars]examples_path} \ | ||
| --ignore={[vars]tst_path}charms \ | ||
| -v --tb native \ | ||
| -W 'ignore:Harness is deprecated:PendingDeprecationWarning' {posargs} | ||
|
|
||
|
|
@@ -110,7 +113,8 @@ passenv = | |
| dependency_groups = unit, coverage | ||
| commands = | ||
| coverage run --source={[vars]src_path},{[vars]testing_src_path} \ | ||
| --branch -m pytest --ignore={[vars]tst_path}smoke \ | ||
| --branch -m pytest \ | ||
| --ignore={[vars]tst_path}smoke \ | ||
|
Comment on lines
-113
to
+117
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally had the doctests running for coverage and then changed my mind on that. However, I think it is nicer to keep the ignores on separate lines. |
||
| --ignore={[vars]tst_path}integration \ | ||
| --ignore={[vars]tst_path}benchmark \ | ||
| --ignore={[vars]testing_tst_path}benchmark \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -950,15 +950,17 @@ def charm_tracing_config( | |
| proceed with charm tracing (with or without tls, as appropriate) | ||
|
|
||
| Usage: | ||
| >>> from lib.charms.tempo_coordinator_k8s.v0.charm_tracing import trace_charm | ||
| >>> from lib.charms.tempo_coordinator_k8s.v0.tracing import charm_tracing_config | ||
| >>> @trace_charm(tracing_endpoint="my_endpoint", cert_path="cert_path") | ||
| >>> class MyCharm(...): | ||
| >>> _cert_path = "/path/to/cert/on/charm/container.crt" | ||
| >>> def __init__(self, ...): | ||
| >>> self.tracing = TracingEndpointRequirer(...) | ||
| >>> self.my_endpoint, self.cert_path = charm_tracing_config( | ||
| ... self.tracing, self._cert_path) | ||
|
|
||
| from lib.charms.tempo_coordinator_k8s.v0.charm_tracing import trace_charm | ||
| from lib.charms.tempo_coordinator_k8s.v0.tracing import charm_tracing_config | ||
| @trace_charm(tracing_endpoint="my_endpoint", cert_path="cert_path") | ||
| class MyCharm(...): | ||
| _cert_path = "/path/to/cert/on/charm/container.crt" | ||
| def __init__(self, ...): | ||
| self.tracing = TracingEndpointRequirer(...) | ||
| self.my_endpoint, self.cert_path = charm_tracing_config( | ||
| self.tracing, self._cert_path | ||
| ) | ||
|
Comment on lines
-953
to
+963
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, I should provide a clean for this upstream, but we're considering reimplementing this library rather than vendoring it, and there's the "move all the interface libraries" project as well, so it doesn't seem worth doing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My 2c:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The challenge here is that pytest's doctest integration doesn't provide much in the way of configuration (pytest-doctestplus is better, but still doesn't have exactly what we want). There's no "ignore" option so to do this we'd have to have a lot of glob statements that match the files to be tested and don't match the files to not be tested. |
||
| """ | ||
| if not endpoint_requirer.is_ready(): | ||
| return None, None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is private, so only someone developing Harness would see the change.