Commit Graph

73 Commits

Author SHA1 Message Date
Ilya.Kazakevich
897351156c PY-25664: Search through list of all test methods, don't stop on first
Buggy logic went through list of methods failing on first that does
not start with 'test'.

It is now checks all methods.
2017-08-16 17:50:19 +03:00
Ilya.Kazakevich
e359fbe832 PY-2410: Support twisted.trial
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
2017-07-24 18:26:39 +03:00
Ilya.Kazakevich
684449b5f0 PY-25271: Do not provide pattern if checkbox disabled 2017-07-24 18:17:23 +03:00
Ilya.Kazakevich
946dd6d5ae PY-24619: emulate qname for files with dashes to support them in tests
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"
2017-07-11 00:55:14 +03:00
Ilya.Kazakevich
22fc6e1716 PY-24770: CleanUp and unify test class detection
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)
2017-07-04 19:32:23 +03:00
Ilya.Kazakevich
ca02ef0c35 PY-24407: Adjust element qname and working directory according to file imports
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"
2017-05-26 01:28:16 +03:00
Ilya.Kazakevich
ee916bd188 PY-24282: Raising SkipTest on PyCharm results in KeyError
Fixed on runners side, this commit syncs data with Leonid's runners
2017-05-22 19:24:13 +03:00
Ilya.Kazakevich
a164283b55 PY-23738: Support non-ascii chars for skipped messages
Fixed on runners side, runners are synced
2017-05-15 22:16:09 +03:00
Ilya.Kazakevich
11b93f437d PY-24047: Unittest subtest status may be Failure or Error when test failed 2017-05-10 18:29:30 +03:00
Ilya.Kazakevich
5e205485c5 PY-23821, PY-23820: Support case when "##teamcity[" messages is buried inside of line
Cases like "foo.test ##teamcity[" may lead ot https://github.com/JetBrains/teamcity-messages/issues/131
2017-05-01 21:04:40 +03:00
Ilya.Kazakevich
305820e6f5 PY-23490: suggest test configuration for folder if name contains "tests"
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.
2017-04-27 20:31:19 +03:00
Ilya.Kazakevich
778916e331 PY-14221: Do not instantiate unittest runner explicitly
See Leonid's comments on https://github.com/JetBrains/teamcity-messages/issues/135
2017-04-25 00:50:44 +03:00
Ilya.Kazakevich
56e741a29a PY-23856: Support tests with docstring and spaces in target
* Targets are trimmed
* When unittest reports test with docstring it should be part of name, but not location
2017-04-21 19:09:40 +03:00
Ilya.Kazakevich
b9d17e211d PY-23785: support unittest2, PY-23846: support dots in subtest names
Leonid's runners updated to support unittest2 and  dots in subtests
2017-04-20 22:38:57 +03:00
Ilya.Kazakevich
5f234d7a36 PY-23452: fix sys.path for runners to make same as with real runners
* 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.
2017-04-19 00:09:06 +03:00
Ilya.Kazakevich
ccbb81dc82 PY-23567: Update Leonid's runners to support time functions monkeypatching
If user monkeypatches strftime PyCharm should survive it
2017-04-17 17:09:00 +03:00
Ilya.Kazakevich
a6038b0d72 PY-23549: run files as scripts for py3 unittest (instead of "discovery" engine used for py2)
In Py3 it is possible to run script directly which is much more stable than discovery machinery
For example it supports hyphens in file names
2017-04-16 00:26:09 +03:00
Ilya.Kazakevich
8b62070a8c PY-23416: Do not provide pattern to using test for rerun
Pattern can't be used with concrete tests names are provided (as it done for rerun)
2017-04-15 22:52:03 +03:00
Ilya.Kazakevich
6b8e8e7a65 PY-20983 (partial fix): do not break if python target is module.
This fix is critical anyway, because running module as python is common
2017-04-15 22:27:56 +03:00
Ilya.Kazakevich
16bd2acc91 This commit should fix: PY-22641, PY-23303, PY-22920, PY-23613, PY-23647, PY-23733, PY-23504, PY-23678, PY-23352, PY-23333, PY-22856, PY-20983
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.
2017-04-15 01:33:38 +03:00
Ilya.Kazakevich
d54d7082d7 PY-23673: "blockClosed" can be called on setup finish, not only on subtest. 2017-04-13 00:07:29 +03:00
Ilya.Kazakevich
e55e865263 PY-23504, PY-23303, PY-23733, PY-23647, PY-23613: Root closest to file should be used as working directory at least for pytest
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
2017-04-12 20:49:57 +03:00
Ilya.Kazakevich
a9bf1c1d1f PY-23488: Special case added to unittest-based subtests 2017-03-31 18:11:41 +03:00
Ilya.Kazakevich
79275b7179 PY-23281: Support command line that starts with ! 2017-03-31 03:08:36 +03:00
Ilya.Kazakevich
00bcd070b7 PY-23279, PY-9963: Use CommandLine language to parse arguments passed as additional
* GeneralCommandLine does not support "as is" command line: it should be splitted to arguments (due to ProcessBuilder interface).
2017-03-31 02:54:43 +03:00
Ilya.Kazakevich
474ef350ba PY-22406: Report unittest as subtests
* Some issues are still missed (see my comments in issue)
* EnvTagsRequired now can be applied to method
2017-03-28 22:19:00 +03:00
Ilya.Kazakevich
21a5beb729 PY-22556, PY-23233, PY-23217: Set working directory for tests that are not in packages (expect pytest with py3):
* Useless code removed from PyQualifiedNameResolveContext
 * Logic extracted to PyTestRunnerUtils
 * Tests added
2017-03-28 13:18:31 +03:00
Ilya.Kazakevich
da2d1d3cb6 PY-22556, PY-23233, PY-23217: Set working directory for tests that are not in packages
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.
2017-03-23 01:56:17 +03:00
Ilya.Kazakevich
401a5af85d PY-23167: Support packages with out __init__.py for Py2 test runners
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
2017-03-18 04:52:35 +03:00
Ilya.Kazakevich
aa9306d06c Fixing tests (equals is deprecated in favor of equal) 2017-03-16 17:47:03 +03:00
Ilya.Kazakevich
283a3ad1bc PY-22992: Detect tests in files
* 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
2017-03-10 18:11:13 +03:00
Ilya.Kazakevich
46e3357f2f New test runners: tests added to check output 2017-02-18 02:23:57 +03:00
Ilya.Kazakevich
6539acd170 PY-22641: test added 2017-02-18 01:38:05 +03:00
Ilya.Kazakevich
b9d24eedeb PY-7856: Provide "actual" and "expected" for DocTest runner 2017-02-08 23:04:05 +03:00
Ilya.Kazakevich
1d400e409a PY-22409: TC runners how report number of tests.
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
2017-02-08 01:29:29 +03:00
Ilya.Kazakevich
0706b903f7 PY-12100: Suggest test runners for folder if it contains test files 2017-02-06 02:02:51 +03:00
Ilya.Kazakevich
f4583c27ac Tests improved: configurations are no checked in more natural way 2017-02-04 22:16:16 +03:00
Ilya.Kazakevich
ed369dc999 New test runners: tests moved to new configuration:
* 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
2017-02-01 19:40:59 +03:00
Ilya.Kazakevich
20448d2981 PY-15837: Escape "[" char in tests 2016-09-29 18:25:28 +03:00
Ilya.Kazakevich
b44bf60f0a PY-20194: Use module root or test parent directory as working dir if not set explicitly.
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.
2016-07-28 23:54:42 +03:00
Ilya.Kazakevich
afc171d39c Flaky test fixed
Due to precision sleep(1000) may actually take 998 and lead to test error.
2016-07-21 17:58:32 +03:00
Ilya.Kazakevich
5045164a0d PY-18839: Adding test 2016-07-19 17:35:10 +03:00
Ilya.Kazakevich
f46f147552 PY-20091: Report "import" and other "summary" errors.
* terminalreporter hasn't been used. It should be registered as last plugin to overwrite built-in
2016-07-18 19:39:31 +03:00
Ilya.Kazakevich
80ee4d0b71 PY-19738: test added
Run tests, then delete files, and try to rerun it. Message and exc. should be displayed
2016-06-22 22:08:59 +03:00
Dmitry Trofimov
ac0b1c357c Fix unit test runner to handle python3 relative imports (PY-17535)
(cherry picked from commit 8728f0fa138b95e6bc1892a74eb8bd595d6cb90a)
2016-06-15 18:15:20 +03:00
Ilya.Kazakevich
8bb39694b4 PY-18926: Wrapping AttributeError
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
2016-03-24 23:11:50 +03:00
Ilya.Kazakevich
42c1f49162 PY-18282 and PY-18163: adding tests and fixing same trouble for py.test 2016-01-26 22:33:02 +03:00
Ilya.Kazakevich
64b832c6d7 PY-16484 custom test suite do not have some required proprties, but still should work 2015-09-11 22:09:27 +03:00
Ilya.Kazakevich
8c4e9e1a58 PY-16170 Duration is not passed to tcmessages for pytest 2015-09-11 17:50:30 +03:00
Ilya.Kazakevich
718793cec9 "testFinished" added after "testError" and "testIngore" to fix PY-16314 and PY-16313 2015-06-26 21:14:28 +03:00