Last active
November 29, 2016 01:30
-
-
Save GeorgeErickson/60b72e1ab03dda8b542fb6a9feb5fc90 to your computer and use it in GitHub Desktop.
Pycharm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/pycharm/noserunner.py w/pycharm/noserunner.py | |
index ff45dba..9db9a9f 100644 | |
--- i/pycharm/noserunner.py | |
+++ w/pycharm/noserunner.py | |
@@ -85,12 +85,12 @@ def process_args(): | |
options = shlex.split(opts) | |
argv.extend(options) | |
- manager = DefaultPluginManager() | |
- manager.addPlugin(teamcity_plugin) | |
- config = MyConfig(plugins=manager) | |
- config.configure(argv) | |
+ # manager = DefaultPluginManager() | |
+ # manager.addPlugin(teamcity_plugin) | |
+ # config = MyConfig(plugins=manager) | |
+ # config.configure(argv) | |
- TestProgram(argv=argv, config=config, exit=False) | |
+ TestProgram(argv=argv, config=None, exit=False, addplugins=[teamcity_plugin]) | |
if __name__ == "__main__": | |
process_args() | |
\ No newline at end of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
helpers_dir = os.getenv("PYCHARM_HELPERS_DIR", sys.path[0]) | |
if sys.path[0] != helpers_dir: | |
sys.path.insert(0, helpers_dir) | |
from nose_utils import TeamcityPlugin | |
from pycharm_run_utils import debug, import_system_module | |
from pycharm_run_utils import adjust_sys_path | |
adjust_sys_path(False) | |
shlex = import_system_module("shlex") | |
try: | |
from nose import run_exit | |
from nose.core import TestProgram | |
from nose.config import Config | |
from nose.plugins.manager import DefaultPluginManager | |
except: | |
raise NameError("Please, install nosetests") | |
teamcity_plugin = TeamcityPlugin() | |
class MyConfig(Config): | |
def __init__(self, **kw): | |
super(MyConfig, self).__init__(**kw) | |
def __setstate__(self, state): | |
super(MyConfig, self).__setstate__(state) | |
self.plugins.addPlugin(teamcity_plugin) | |
def process_args(): | |
tests = [] | |
opts = None | |
if sys.argv[-1].startswith("-"): | |
test_names = sys.argv[1:-1] | |
opts = sys.argv[-1] | |
else: | |
test_names = sys.argv[1:] | |
for arg in test_names: | |
arg = arg.strip() | |
if len(arg) == 0: | |
return | |
a = arg.split("::") | |
if len(a) == 1: | |
# From module or folder | |
a_splitted = a[0].split(";") | |
if len(a_splitted) != 1: | |
# means we have pattern to match against | |
if a_splitted[0].endswith("/"): | |
debug("/ from folder " + a_splitted[0] + ". Use pattern: " + a_splitted[1]) | |
tests.append(a_splitted[0]) | |
else: | |
if a[0].endswith("/"): | |
debug("/ from folder " + a[0]) | |
tests.append(a[0]) | |
else: | |
debug("/ from module " + a[0]) | |
tests.append(a[0]) | |
elif len(a) == 2: | |
# From testcase | |
debug("/ from testcase " + a[1] + " in " + a[0]) | |
tests.append(a[0] + ":" + a[1]) | |
else: | |
# From method in class or from function | |
debug("/ from method " + a[2] + " in testcase " + a[1] + " in " + a[0]) | |
if a[1] == "": | |
# test function, not method | |
tests.append(a[0] + ":" + a[2]) | |
else: | |
tests.append(a[0] + ":" + a[1] + "." + a[2]) | |
argv = ['nosetests'] | |
argv.extend(tests) | |
if opts: | |
options = shlex.split(opts) | |
argv.extend(options) | |
# manager = DefaultPluginManager() | |
# manager.addPlugin(teamcity_plugin) | |
# config = MyConfig(plugins=manager) | |
# config.configure(argv) | |
TestProgram(argv=argv, config=None, exit=False, addplugins=[teamcity_plugin]) | |
if __name__ == "__main__": | |
process_args() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment