Trial is test framework for Twisted much like unittests.
It is fully supported on Leonid side, we only need to create wrappers.
There were too many places with framework naming code making
it pretty hard to support new frameworks.
It is now unified. Any service (except framework-specific) should work
via PyTestFrameworkService to obtain list of frameworks and its
When user clicks on some element PyCharm gets its qname and generates
test target based on it. But user may use file with dashes.
There is no qName in this case, but all test runners support such targets.
So we emulate it in "getEmulatedQNameParts"
PythonUnitTestUtil been refactored, see its doc.
Code that is not test-case specific moved to PyClassExt.kt
New logic is the following:
* UnitTest believes any TestCase inheritor is test case, so its method
is test, its parent file is test and so on.
* Other runners think that any "test_" function is test when it is located
on toplevel or in test class (see PythonUnitTestUtil)
When user creates configuration for method "foo" in file "test.py" in folder "tests" it is generally correct to run "test.foo" setting "tests" as working directory.
But once you have "from ..spam import" in "test.py" you should do folder with "spam.py" your working directory and set target to "tests.test.foo"
Since plain python can't run on folder anyway, there is nothing bad about running folder as test configuration. Most runners support tests in folder discovery.
* Python adds script folder as sys.path[0]. Since we run helper "helpers" dir is sys.path[0]. Pop it, and testrunner will patch sys.path as it is done with command line.
* Unittest is launched as module and it adds current dir -- pycharm mimics this behaviour.
Working dir fix:
* When configuration is generated -- use element dir as working dir
* When launched and working dir is not set -- use element dir as working dir
Inherited methods fix:
* When resolving element -- obey name provided by runner because it may differ from element.qname
(in case of inherited classes).
* Fix filesystem part of path making element resolvable for python, but obey element part of path
No file is reported by new runners, so we do out best to find file
* Use index to resolve element as fallback if runner reported relative path
* Resolve it against working dir and all roots
Do not import anything in python runners: importing may break Django
* Move convertion from qname to "filesystem/element name" to java side
Tests added.
If you have several roots (src, content, what ever) they all passed as sys.path. But pytest does not resolve its argument against sys.path: it uses working directory. This change does 2 things:
* If workdir not set --use closest root
* For newly created config set closest root as dir
When you want to launch test in folder "tests" which is not a package, you have several troubles:
* Python frameworks report tests relative to this folder (i.e. test_module.foo instead of tests.test_module.foo)
* You can't provide test name as tests.foo.MyTest since "tests" is not package
To solve it, we set "tests" as package. But you can't simply set deepest folder as package: it may break relative imports.
So, newly created configuration should use topmost folder which is not a package.
Consider following layout: tests ( not a package), logic (package), test_module.py
Here is: "logic.test_module" and "tests" as working directory.
On Java side, we get working dir reported by python and resolve names against it.
Several hacks like index lookup of function are not needed now.
You can use Python path like "spam.eggs" where "spam" does not have
__init__.py. This scheme is used by runners to report test names.
For Py3 it works, but not for Py2.
``_jb_runner_tools`` contains logic to workaround it
* Old logic (any class with Test in its name is test) is not ideal, but we need to reuse it to prevent regression
* PythonUnitTestUtil: do not check same class several times for each of its ancestors
PY-13833: dots in test names are escaped by TC runners now.
* Blocks temporary disabled (see comments in _jb_runner_tools.py)
* Generators/parametrized tests are always provided with parentheses
* Some tests fail. Will fix.
* py files renamed to prevent them from unexpected discovering
* "prefixes" added to tests as a way to provide different targets
* verbosity improved
* suite changed to "non leaf" since there are no suites in new runners
Default workdir for PyCharm is its installation folder. Always never should it be used as working dir for script it runs. If user does not provide working dir, we must guess it. #getWorkingDirSafe() does this guess. It takes directory for script, directory for test or simply first module root. See its javadoc and usage for details.
Nose has bug: instead of Test we are getting ContextSuite in case of error in setup class. It does not have attribute .test, so we wrap it try / except to mimic previous behavior (pre 5.0) when we simply did not check this field