tractor/examples
Tyler Goodlet 96992bcbb9 Add (back) a `tractor._testing` sub-pkg
Since importing from our top level `conftest.py` is not scaleable
or as "future forward thinking" in terms of:
- LoC-wise (it's only one file),
- prevents "external" (aka non-test) example scripts from importing
  content easily,
- seemingly(?) can't be used via abs-import if using
  a `[tool.pytest.ini_options]` in a `pyproject.toml` vs.
  a `pytest.ini`, see:
  https://docs.pytest.org/en/8.0.x/reference/customize.html#pyproject-toml)

=> Go back to having an internal "testing" pkg like `trio` (kinda) does.

Deats:
- move generic top level helpers into pkg-mod including the new
  `expect_ctxc()` (which i needed in the advanced faults testing script.
- move `@tractor_test` into `._testing.pytest` sub-mod.
- adjust all the helper imports to be a `from tractor._testing import <..>`

Rework `test_ipc_channel_break_during_stream()` and backing script:
- make test(s) pull `debug_mode` from new fixture (which is now
  controlled manually from `--tpdb` flag) and drop the previous
  parametrized input.
- update logic in ^ test for "which-side-fails" cases to better match
  recently updated/stricter cancel/failure semantics in terms of
  `ClosedResouruceError` vs. `EndOfChannel` expectations.
- handle `ExceptionGroup`s with expected embedded errors in test.
- better pendantics around whether to expect a user simulated KBI.
- for `examples/advanced_faults/ipc_failure_during_stream.py` script:
  - generalize ipc breakage in new `break_ipc()` with support for diff
    internal `trio` methods and a #TODO for future disti frameworks
  - only make one sub-actor task break and the other just stream.
  - use new `._testing.expect_ctxc()` around ctx block.
  - add a bit of exception handling with `print()`s around ctxc (unused
    except if 'msg' break method is set) and eoc cases.
  - don't break parent side ipc in loop any more then once
    after first break, checked via flag var.
  - add a `pre_close: bool` flag to control whether
    `MsgStreama.aclose()` is called *before* any ipc breakage method.

Still TODO:
- drop `pytest.ini` and add the alt section to `pyproject.py`.
 -> currently can't get `--rootdir=` opt to work.. not showing in
   console header.
 -> ^ also breaks on 'tests' `enable_modules` imports in subactors
   during discovery tests?
2024-03-13 09:09:08 -04:00
..
advanced_faults Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
debugging Add a debug-mode-breakpoint-causes-hang case! 2023-06-21 14:07:31 -04:00
integration Move pydantic-click hang example to new dir, skip in test suite 2022-08-02 12:16:58 -04:00
parallelism Use built-ins for all data-structure-type annotations 2022-09-15 23:41:28 -04:00
__init__.py Make example a subpkg for `python -m <mod>` testing 2022-07-27 11:40:02 -04:00
__main__.py Use trio.run() in windows tests 2021-05-07 11:21:40 -04:00
a_trynamic_first_scene.py Drop `tractor.run()` from all examples 2021-05-07 11:21:40 -04:00
actor_spawning_and_causality.py Drop `tractor.run()` from all examples 2021-05-07 11:21:40 -04:00
actor_spawning_and_causality_with_daemon.py Drop lingering rpc_module_paths refs 2021-05-07 11:21:40 -04:00
asynchronous_generators.py Terminate async gen example caller to avoid (benign) errors in console output 2021-08-02 21:49:15 -04:00
full_fledged_streaming_service.py Type out the full-fledged streaming ex. 2023-10-18 15:36:00 -04:00
infected_asyncio_echo_server.py Add context test that opens an inter-task-channel that errors 2022-07-14 16:13:12 -04:00
multiple_streams_one_portal.py Update all examples to new streaming API 2021-04-28 12:23:08 -04:00
quick_cluster.py Drop unecessary partial 2021-11-04 10:41:25 -04:00
remote_error_propagation.py Drop lingering rpc_module_paths refs 2021-05-07 11:21:40 -04:00
rpc_bidir_streaming.py Add 2-way streaming example to readme and scripts 2021-07-31 12:10:25 -04:00
service_discovery.py Drop `tractor.run()` from all examples 2021-05-07 11:21:40 -04:00