Commit Graph
63 Commits
Author SHA1 Message Date
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
Ilya.Kazakevich 9aa5b6e84a Relative path supported for PY-16031 2015-05-27 00:15:40 +03:00
Ilya.Kazakevich cb1aa45d9e Real tests added for PY-14560 2015-05-21 22:26:41 +03:00
Ilya.Kazakevich ba910472db Test added for PY-15869 2015-05-18 20:21:23 +03:00
Ilya.Kazakevich 5e0305f9d3 Test stoud fixed for PY-12621 2015-05-07 14:26:46 +03:00
Dmitry Trofimov 1c224e5dfc Fix auto-broken import. 2014-08-14 12:22:08 +02:00
Dmitry Trofimov b9b8c8909f Commit missing doctest test data. 2014-08-13 10:43:35 +02:00
Dmitry Trofimov b67febc214 Move test data to community to fix tests. 2014-08-12 23:37:38 +02:00
Ekaterina Tuzova 6248e487e3 moved unittest tests to env tests 2014-03-12 19:31:59 +04:00
Dmitry Jemerov 46ac22c347 move testdata for env tests back to professional repo 2013-10-21 16:31:53 +02:00
Dmitry Jemerov eaea8dbcf6 delete accidentally checked in .class files 2013-10-18 18:48:08 +02:00