Replies: 3 comments 2 replies
-
|
More context is needed to give a good answer, is this a tool, or just about type specs |
Beta Was this translation helpful? Give feedback.
-
|
Check this: https://youtu.be/PXu3KCMT3l4 |
Beta Was this translation helpful? Give feedback.
-
|
I suppose one answer is to refactor the implementation to enable something like dependency injection for the with- and without-optional dependency cases. Then I suppose you could use some environment-based configuration (e.g., an environment variable or some other initialization machinery) to override injecting the set of dependencies you're trying to test. But this isn't always practical, especially when inheriting a large codebase. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a package that will opportunistically take advantage of
typing-extensionswhen running in Python 3.7 if available, but will operate at reduced functionality without it. I would like to be able to run my entire battery of tests to ensure they all pass both with and withouttyping-extensions.However, as far as I can tell,
pytestsweeps intyping-extensionsfor Python 3.7. (More specifically, it requiresimportlib-metadata, which requirestyping-extensions.)How does one go about
testing code paths that are only executedrunning an entire suite of tests whentyping-extensionsis unavailable in that environment?Consider: I have a core component
Ain my projectproj. Pretty much everything inprojdepends onA. Under the covers I have two different implementations ofA:AwithBif dependencyBis found, and a reduced-functionality stand-inAwithoutBif it is absent. (Bis an optional dependency ofproj.) How do I go about running all the tests I have forprojifBis always swept in bypytest?I feel like I can't be the first person to encounter or think about this.
UPDATE: Could this be done using something akin to a context manager that temporarily sets
sys.modules['typing_extensions']toNone(e.g., something like this). Maybe I can configure that viaconftest.pyor a hook wrapper?Beta Was this translation helpful? Give feedback.
All reactions