Skip to content

feat: built-in testing module (PyNestTestingModule + TestBed) (#118) - #136

Open
ItayTheDar wants to merge 1 commit into
PythonNest:mainfrom
itay-dar-lmnd:testing-module
Open

feat: built-in testing module (PyNestTestingModule + TestBed) (#118)#136
ItayTheDar wants to merge 1 commit into
PythonNest:mainfrom
itay-dar-lmnd:testing-module

Conversation

@ItayTheDar

Copy link
Copy Markdown
Contributor

Adds nest.testing — a first-class testing toolkit modeled after @nestjs/testing and Suites:

  • PyNestTestingModule.create_testing_module(imports/controllers/providers) with fluent TestingModuleBuilder
  • override_provider(token).use_value/.use_class/.use_factory
  • override_guard(Guard).use_value/.use_class (patches applied only during route registration, restored immediately — no state leaks between tests)
  • use_auto_mock(): replaces class providers with create_autospec mocks (async methods become AsyncMocks), with exclude= and mock_factory=
  • TestingModule.get/init/close, awaitable compile(), async context manager
  • create_http_client() (httpx ASGITransport), create_test_client(), create_nest_application()
  • TestBed.solitary/sociable with .mock().using/.final and expose() for Suites-style unit tests without a container
  • PyNestContainer.replace_provider() + provider_descriptors hook
  • pynest-api[testing] extra (httpx); pytest-asyncio added to test group
  • docs/testing.md with pytest fixture patterns; 35 new tests

Closes#118

…Nest#118)
Adds nest.testing — a first-class testing toolkit modeled after
@nestjs/testing and Suites:
- PyNestTestingModule.create_testing_module(imports/controllers/providers)
with fluent TestingModuleBuilder
- override_provider(token).use_value/.use_class/.use_factory
- override_guard(Guard).use_value/.use_class (patches applied only during
route registration, restored immediately — no state leaks between tests)
- use_auto_mock(): replaces class providers with create_autospec mocks
(async methods become AsyncMocks), with exclude= and mock_factory=
- TestingModule.get/init/close, awaitable compile(), async context manager
- create_http_client() (httpx ASGITransport), create_test_client(),
create_nest_application()
- TestBed.solitary/sociable with .mock().using/.final and expose() for
Suites-style unit tests without a container
- PyNestContainer.replace_provider() + provider_descriptors hook
- pynest-api[testing] extra (httpx); pytest-asyncio added to test group
- docs/testing.md with pytest fixture patterns; 35 new tests
ClosesPythonNest#118
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Testing Module (PyNestTestingModule, mock providers, test utilities)

1 participant

@ItayTheDar