Question: Testing with injector

Open
#80 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start by reviewing the documentation for with_injector and the related testing entry points. Clarify the replacement for the deprecated usage and how a test can reference a mocked service; the issue is complete when both questions have an agreed, documented answer.

Written by the indexing model from the issue text.

Description

Hi,

Thanks for this great project, it adds really nice separation to my code. But now I want to unittest everything and there are two cases:

  1. In documentation you show that we should use with_injector but it is depreciated and is spewing warnings in my tests
  2. Using with_injector I create mock service and unittest component which uses this service. But I would like to assert that mocked service was called with correct parameters. How can I obtain reference to mocked service? For now it seems I have to access self.__injector__ which seems a little hacky. Is there another way? Is there planned another way?
Dominant language
Python
Stars
1.5k
Forks
94
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-injector/injector

All issues in python-injector/injector

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.