void () { runPythonTest(new CreateConfigurationTestTask<>(PythonTestConfigurationType.getInstance().getUnitTestFactory().getName(), PyUnitTestConfiguration.class) { @NotNull @Override protected List<PsiElement> getPsiElementsToRightClickOn() { myFixture.configureByFile("testRelativeImport/src/tests/test_no_relative.py"); final PyFunction noRelativeImportFun = myFixture.findElementByText("test_no_relative", PyFunction.class); assert noRelativeImportFun != null; myFixture.configureByFile("testRelativeImport/src/tests/test_relative.py"); final PyFunction relativeImportFun = myFixture.findElementByText("test_relative", PyFunction.class); assert relativeImportFun != null; return Arrays.asList(relativeImportFun, noRelativeImportFun); } @Override protected void checkConfiguration(@NotNull PyUnitTestConfiguration configuration, @NotNull PsiElement elementToRightClickOn) { super.checkConfiguration(configuration, elementToRightClickOn); configuration.getWorkingDirectorySafe(); final PyFunction function = (PyFunction)elementToRightClickOn; if (function.getName().equals("test_relative")) { assertThat(configuration.getWorkingDirectory()) .describedAs("Wrong dir for relative import") .endsWith("testRelativeImport"); assertEquals("Bad target", "src.tests.test_relative.ModuleTest.test_relative", configuration.getTarget().getTarget()); } else if (function.getName().equals("test_no_relative")) { assertThat(configuration.getWorkingDirectory()) .describedAs("Wrong dir for non relative import") .endsWith("testRelativeImport/src/tests"); assertEquals("Bad target", "test_no_relative.ModuleTest.test_no_relative", configuration.getTarget().getTarget()); } else { throw new AssertionError("Unexpected function " + function.getName()); } } }); }