Closed vedantroy closed 5 years ago
This appears to be an issue with the upgrade from pytest 4.3.1 to 4.4.0. Downgrade and the tests pass.
@blueyed @nicoddemus I think the issue came from pytest-dev/pytest#4980 because the tests that are failing here use a fixture that uses monkeypatch.syspath_prepend
, but I'm not clear what the change was or how to go about debugging or fixing it. Can you take a look?
Does commenting https://github.com/pytest-dev/pytest/pull/4980/files#diff-1f034a0f101912ca729b09e39a3973bbR272 fix the tests then?
Yes, commenting out that line allows the tests to pass again.
Hmm.. inside of tox it passes at least, right?
And with e.g. p -k test_main_module_paths
it also passes sometimes for me?!
(Python 3.7.3, pytest-4.4.1.dev15+gbc157417)
Will look into it later..
This fixes it (for tests/test_instance_config.py::test_main_module_paths
, but not all):
diff --git i/tests/test_instance_config.py w/tests/test_instance_config.py
index bc912c64..a7b66203 100644
--- i/tests/test_instance_config.py
+++ w/tests/test_instance_config.py
@@ -26,6 +26,8 @@ def test_explicit_instance_paths(modules_tmpdir):
def test_main_module_paths(modules_tmpdir, purge_module):
app = modules_tmpdir.join('main_app.py')
+ from importlib import invalidate_caches
+ invalidate_caches()
app.write('import flask\n\napp = flask.Flask("__main__")')
purge_module('main_app')
E.g. here it is also needed, likely due to some other fixture:
diff --git i/tests/test_instance_config.py w/tests/test_instance_config.py
index bc912c64..1f2be9ce 100644
--- i/tests/test_instance_config.py
+++ w/tests/test_instance_config.py
@@ -94,6 +94,8 @@ def test_installed_package_paths(limit_loader, modules_tmpdir,
def test_prefix_package_paths(limit_loader, modules_tmpdir,
modules_tmpdir_prefix, purge_module,
site_packages):
+ from importlib import invalidate_caches
+ invalidate_caches()
app = site_packages.mkdir('site_package')
init = app.join('__init__.py')
init.write('import flask\napp = flask.Flask(__name__)')
invalidate_caches
should be called in syspath_prepend
also (only done with testdir.syspathinster
)..
Expected Behavior
The following set of commands should result in all tests being passed or skipped (no failures).
Actual Behavior
I get the following failures:
Environment
Ubuntu 18 LTS. Here's the result of
ls
in theflask
directory: