mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-37841: Do not monkeypatch prepareconfing in pytest: leads to double plugin loading.
With testdir fixture, pytest runs test under separate pytest (which may be inline or separate process). Previously we monkeypatched prepareconfig not to call it twice. But this approach fails with testdir, because same config returned twice leading to double plugin registration. See comment in YT GitOrigin-RevId: bd9f11a2a10900fa3c059791d7c0183a20b1ed70
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c4e61f6c9a
commit
ef0b36a968
@@ -12,8 +12,6 @@ from _jb_runner_tools import jb_patch_separator, jb_doc_args, JB_DISABLE_BUFFERI
|
||||
from teamcity import pytest_plugin
|
||||
|
||||
if __name__ == '__main__':
|
||||
real_prepare_config = config._prepareconfig
|
||||
|
||||
path, targets, additional_args = parse_arguments()
|
||||
sys.argv += additional_args
|
||||
joined_targets = jb_patch_separator(targets, fs_glue="/", python_glue="::", fs_to_python_glue=".py::")
|
||||
@@ -34,12 +32,10 @@ if __name__ == '__main__':
|
||||
|
||||
jb_doc_args("pytest", args)
|
||||
# We need to preparse numprocesses because user may set it using ini file
|
||||
config_result = real_prepare_config(args, plugins_to_load)
|
||||
config_result = config._prepareconfig(args, plugins_to_load)
|
||||
|
||||
if getattr(config_result.option, "numprocesses", None):
|
||||
set_parallel_mode()
|
||||
|
||||
config._prepareconfig = lambda _, __: config_result
|
||||
|
||||
start_protocol()
|
||||
pytest.main(args, plugins_to_load)
|
||||
|
||||
@@ -93,7 +93,7 @@ envs {
|
||||
"2.7.15",
|
||||
["django==1.11", "tox>=3.8.3", "nose", "pytest", "Twisted", "behave", "lettuce>=0.2.22", "unittest2", "teamcity-messages", "django-nose", "untangle"]
|
||||
+ ( Os.isFamily(Os.FAMILY_WINDOWS) ? ['pypiwin32'] : [] ), //win32api is required for pypiwin32
|
||||
"python2.7\ndjango\nnose\npytest\nbehave\nlettuce\npackaging\ntox\nunittest2\ntwisted\ndjango-nose\nuntangle",
|
||||
"python2.7\ndjango\nnose\npytest\nbehave\nlettuce\npackaging\ntox\nunittest2\ntwisted\ndjango-nose\nuntangle\nmessages",
|
||||
true)
|
||||
|
||||
createPython("py36_django22_full",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
pytest_plugins = "pytester"
|
||||
|
||||
|
||||
def test_foo(testdir):
|
||||
testdir.makefile(".py", test_bar="""
|
||||
def test_bar():pass
|
||||
""")
|
||||
res = testdir.runpytest()
|
||||
assert res.ret == 0
|
||||
@@ -153,6 +153,30 @@ public final class PythonPyTestingTest extends PyEnvTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
@EnvTestTagsRequired(tags = "-messages") //messages registered 2 times when launched with testdir plugin, should be fixed separately
|
||||
@Test
|
||||
public void testTestDirFixture() {
|
||||
runPythonTest(
|
||||
new PyProcessWithConsoleTestTask<PyTestTestProcessRunner>("/testRunner/env/pytest/testdir", SdkCreationType.EMPTY_SDK) {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyTestTestProcessRunner createProcessRunner() {
|
||||
return new PyTestTestProcessRunner("test_foo.py", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkTestResults(@NotNull final PyTestTestProcessRunner runner,
|
||||
@NotNull final String stdout,
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all, int exitCode) {
|
||||
|
||||
Assert.assertEquals(stderr, 1, runner.getAllTestsCount());
|
||||
Assert.assertEquals(stderr, 1, runner.getPassedTestsCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test name must be reported as meta info to be used as argument for "-k" for parametrized tests
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user