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-extensions
when 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,
pytest
sweeps intyping-extensions
for 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-extensions
is unavailable in that environment?Consider: I have a core component
A
in my projectproj
. Pretty much everything inproj
depends onA
. Under the covers I have two different implementations ofA
:AwithB
if dependencyB
is found, and a reduced-functionality stand-inAwithoutB
if it is absent. (B
is an optional dependency ofproj
.) How do I go about running all the tests I have forproj
ifB
is 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.py
or a hook wrapper?Beta Was this translation helpful? Give feedback.
All reactions