Skip to content

Support for pytest 6 "--import-mode=importlib" #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Sep 7, 2020
Merged

Conversation

youtux
Copy link
Contributor

@youtux youtux commented Sep 6, 2020

This is a continuation of the initial fix proposed in #381:

With the pytest 6 RC, a new --import-mode=importlib was added, which uses importlib rather than sys.path hacks to import test modules

This PR fixes the issue by using inspect.stack(1).frame.f_locals to access the dictionary of the locals of the caller module and modify them.

@codecov
Copy link

codecov bot commented Sep 6, 2020

Codecov Report

Merging #384 into master will decrease coverage by 0.41%.
The diff coverage is 98.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #384      +/-   ##
==========================================
- Coverage   95.54%   95.13%   -0.42%     
==========================================
  Files          49       49              
  Lines        1683     1705      +22     
  Branches      168      169       +1     
==========================================
+ Hits         1608     1622      +14     
- Misses         43       48       +5     
- Partials       32       35       +3     
Impacted Files Coverage Δ
tests/steps/test_steps.py 100.00% <ø> (ø)
pytest_bdd/scenario.py 89.75% <92.30%> (-6.00%) ⬇️
pytest_bdd/steps.py 91.37% <100.00%> (+2.49%) ⬆️
pytest_bdd/utils.py 100.00% <100.00%> (ø)
tests/conftest.py 100.00% <100.00%> (ø)
tests/feature/test_scenario.py 100.00% <100.00%> (ø)
tests/feature/test_scenarios.py 100.00% <100.00%> (ø)
tests/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8822915...82d2b73. Read the comment docs.

@youtux youtux changed the title Work with importlib Support for pytest 6 "--import-mode=importlib" Sep 6, 2020
@youtux youtux marked this pull request as ready for review September 6, 2020 08:28
@youtux youtux requested a review from The-Compiler September 6, 2020 09:13
@youtux youtux merged commit 853c615 into master Sep 7, 2020
@olegpidsadnyi olegpidsadnyi deleted the work-with-importlib branch September 7, 2020 07:44
Sign up for free to 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.

3 participants