I'm trying to implement the pytest plugin mentioned in https://github.com/pytest-dev/pytest/issues/2039, basically this plugin will print all tests that pytest finds:
## pytest_collector.py
import sys
import pytest
class DkPytestCollector(object):
def __init__(self):
self.collected = []
def pytest_collection_modifyitems(self, items):
for item in items:
self.collected.append(item.nodeid)
if __name__ == '__main__':
dkpytest_collector = DkPytestCollector()
directory = sys.argv[1]
pytest.main(['--collect-only', directory], plugins=[dkpytest_collector])
print('\n\nfound:')
for nodeid in dkpytest_collector.collected:
print(nodeid)
however, when I run it I get:
(dk) go|c:\srv\lib\dk> python ..\dkbuild\dkbuild\pytest_collector.py \srv\lib\dk
Traceback (most recent call last):
File "..\dkbuild\dkbuild\pytest_collector.py", line 20, in <module>
pytest.main(['--collect-only', directory], plugins=[dkpytest_collector])
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 50, in main
config = _prepareconfig(args, plugins)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 160, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 617, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 196, in _multicall
gen.send(outcome)
File "c:\srv\venv\dk\lib\site-packages\_pytest\helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 77, in get_result
_reraise(*ex) # noqa
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 180, in _multicall
res = hook_impl.function(*args)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 943, in pytest_cmdline_parse
self.parse(args)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 1108, in parse
self._preparse(args, addopts=addopts)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 1071, in _preparse
self.pluginmanager.load_setuptools_entrypoints('pytest11')
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 397, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\srv\venv\dk\lib\site-packages\pkg_resources\__init__.py", line 2405, in load
return self.resolve()
File "c:\srv\venv\dk\lib\site-packages\pkg_resources\__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:\srv\venv\dk\lib\site-packages\_pytest\assertion\rewrite.py", line 212, in load_module
py.builtin.exec_(co, mod.__dict__)
File "c:\srv\venv\dk\lib\site-packages\py\_builtin.py", line 221, in exec_
exec2(obj, globals, locals)
File "<string>", line 7, in exec2
File "c:\srv\venv\dk\lib\site-packages\pytest_cov\plugin.py", line 6, in <module>
from coverage.misc import CoverageException
ImportError: No module named misc
if I pip uninstall pytest-cov everything works (well, except no coverage..)
How do I get this to work without uninstalling pytest-cov?
Related
Trying to setup pytest-testrail plugin. When I start test run using --testrail --tr-config=path/to/config.cfg param, it returns error ValueError: option names {'--testrail'} already added
im using appium+pytest+allure. It works well for me, but now im trying to add testrail integration. I setup pytest-testrail plugin correct(test run successfully created in testrail with list of my auto test), but when I add from pytest_testrail.conftest import * to my own conftest file, in return error .
I try to reinstall pytest and pytest-testrail plugin multiple times, but it doesn't help
conftest file:
import pytest
from appium import webdriver
from pytest_testrail.conftest import *
import sys
import os.path
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir))
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
#pytest.fixture
def driver_setup(request):
desired_caps = {
//desired caps for appium driver
}
url = 'http://localhost:4723/wd/hub'
request.instance.driver = webdriver.Remote(url, desired_caps)
def teardown():
request.instance.driver.quit()
request.addfinalizer(teardown)
full error description:
Traceback (most recent call last):
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 415, in _importconftest
return self._conftestpath2mod[conftestpath]
KeyError: local('/Users/anton/autotests/conftest.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pycharm/_jb_pytest_runner.py", line 31, in <module>
pytest.main(args, plugins_to_load)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 55, in main
config = _prepareconfig(args, plugins)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 200, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in _call_
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 81, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
gen.send(outcome)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
config = outcome.get_result()
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 661, in pytest_cmdline_parse
self.parse(args)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 869, in parse
self._preparse(args, addopts=addopts)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 825, in _preparse
early_config=self, args=args, parser=self._parser
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in _call_
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 81, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 724, in pytest_load_initial_conftests
self.pluginmanager._set_initial_conftests(early_config.known_args_namespace)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 364, in _set_initial_conftests
self._try_load_conftest(anchor)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 370, in _try_load_conftest
self._getconftestmodules(anchor)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 399, in _getconftestmodules
mod = self._importconftest(conftestpath.realpath())
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 449, in _importconftest
self.consider_conftest(mod)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 502, in consider_conftest
self.register(conftestmodule, name=conftestmodule.__file__)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 302, in register
ret = super().register(plugin, name)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 121, in register
hook._maybe_apply_history(hookimpl)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/hooks.py", line 336, in _maybe_apply_history
res = self._hookexec(self, [method], kwargs)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/manager.py", line 81, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/pytest_testrail/conftest.py", line 20, in pytest_addoption
help='Create and update testruns with TestRail')
File "/Users/anton/MercuryTest/mercury_env/lib/python3.6/site-packages/_pytest/config/argparsing.py", line 304, in addoption
raise ValueError("option names %s already added" % conflict)
ValueError: option names {'--testrail'} already added
here example of my test cases with all decorators:
import pytest
import allure
from pytest_testrail.plugin import pytestrail
#pytest.mark.usefixtures('driver_setup')
#allure.epic('application name ')
class Test_app_name:
#allure.feature('feature')
#pytestrail.case('C850')
#allure.title('test title')
#allure.severity(allure.severity_level.CRITICAL)
def test_case_name(self):
page = pageObjectClassWithLocatorsAndActions(self.driver)
with allure.step('step'):
page.do_something()
It maybe duplicate with issue described here Pytest Testrail Module - Post Test Results for Test Runs
If so, you don't need to import "pytest_testrail.conftest" in your own conftest
You need assert something in "page.do_something()" to testrail plugin knows the status of "test_case_name"
I am trying to run pytest on CircleCI, locally I have no issues but when I execute the shell command
PYTHONPATH=. pytest --cov-report html:$CIRCLE_ARTIFACTS/htmlcov --nomigrations
I get the following traceback:
Traceback (most recent call last):
File "/home/ubuntu/virtualenvs/venv-2.7.12/bin/pytest", line 11, in <module>
sys.exit(main())
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 49, in main
config = _prepareconfig(args, plugins)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 168, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
wrap_controller.send(call_outcome)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 280, in get_result
_reraise(*ex) # noqa
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
self.result = func()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 957, in pytest_cmdline_parse
self.parse(args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 1121, in parse
self._preparse(args, addopts=addopts)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 1092, in _preparse
args=args, parser=self._parser)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
return call_outcome.get_result()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 280, in get_result
_reraise(*ex) # noqa
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
self.result = func()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/pytest_django/plugin.py", line 244, in pytest_load_initial_conftests
dj_settings.DATABASES
File "/opt/circleci/python/2.7.12/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/pytest_django/plugin.py", line 117, in _handle_import_error
raise ImportError(msg)
ImportError: No module named test
pytest-django found a Django project in /home/ubuntu/rit-das-pdp (it contains manage.py) and added it to the Python path.
If this is wrong, add "django_find_project = false" to pytest.ini and explicitly manage your Python path.
PYTHONPATH=. pytest --cov-report html:$CIRCLE_ARTIFACTS/htmlcov --nomigrations returned exit code 1
I have no idea what the error is saying or how to debug it.
I installed Pyramid, SQLAlchemy and waitress running in virtualenv on Jython 2.7 (platform: Linux x64). Unfortunately pserve cannot start:
% pserve development.ini
Traceback (most recent call last):
File "/myapp/j1/ve/bin/pserve", line 11, in <module>
sys.exit(main())
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 60, in main
return command.run()
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 367, in run
server = self.loadserver(server_spec, name=server_name,
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 409, in loadserver
return loadserver(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 255, in loadserver
return loadobj(SERVER, uri, name=name, **kw)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 269, in loadobj
context = loadcontext(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 293, in loadcontext
return _loaders[scheme](
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 452, in get_context
context = self._context_from_use(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 475, in _context_from_use
context = self.get_context(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 404, in get_context
return loadcontext(object_type, name,
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 293, in loadcontext
return _loaders[scheme](
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 619, in get_context
entry_point, protocol, ep_name = self.find_egg_entry_point(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/myapp/j1/ve/Lib/site-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/myapp/j1/ve/Lib/site-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/myapp/j1/ve/Lib/site-packages/waitress/__init__.py", line 1, in <module>
from waitress.server import create_server
File "/myapp/j1/ve/Lib/site-packages/waitress/server.py", line 22, in <module>
from waitress.adjustments import Adjustments
File "/myapp/j1/ve/Lib/site-packages/waitress/adjustments.py", line 47, in <module>
class Adjustments(object):
File "/myapp/j1/ve/Lib/site-packages/waitress/adjustments.py", line 167, in Adjustments
socket_options = [
AttributeError: 'module' object has no attribute 'SOL_TCP'
Is there some workaround for this?
Every time I try to serve my project I get this error:
Traceback (most recent call last):
File "/usr/bin/pserve", line 9, in <module>
load_entry_point('pyramid==1.5.2', 'console_scripts', 'pserve')()
File "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 313, in run
relative_to=base, global_conf=vars)
File "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 344, in loadserver
server_spec, name=name, relative_to=relative_to, **kw)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 255, in loadserver
return loadobj(SERVER, uri, name=name, **kw)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 454, in get_context
section)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 476, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 620, in get_context
object_type, name=name)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2320, in load
return self.resolve()
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2326, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/__init__.py", line 1, in <module>
from waitress.server import create_server
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/server.py", line 23, in <module>
from waitress.channel import HTTPChannel
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py", line 28, in <module>
from waitress.task import (
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/task.py", line 53, in <module>
class ThreadedTaskDispatcher(object):
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/task.py", line 57, in ThreadedTaskDispatcher
start_new_thread = thread.start_new_thread
AttributeError: 'module' object has no attribute 'start_new_thread'
The weird thing is, the thread module has the attribute start_new_thread
>>> from waitress.compat import (thread, Empty)
>>> thread.start_new_thread
<built-in function start_new_thread>
I started this pyramid project using python 2.7, and I am trying to switch it over to python 3.4.
Things I've tried:
updating the waitress module, it's already up to date
scratching my head
I would like to run all my django tests using mercurial's precommit hook. Whenever a test fails the commit will be aborted.
The goal is to block build-breaking commits as often as possible.
edit: Ended up using the external script route. Here is the reletant portion of my hgrc:
[hooks]
precommit = python ./pinax/projects/lgr/manage.py test lgr_photos --verbosity=0 --noinput
commit = hg push
Here is my progress on the hook function:
from os.path import join, dirname
import sys
from django.core.management import call_command
def hook(ui, repo, **kwargs):
project_path = join( dirname(repo.path), 'pinax', 'projects')
sys.path.insert(0, project_path)
from lgr.manage import *
output = call_command('test', verbosity=0, interactive=False)
#ui.warn(output)
What am I doing wrong here?
PS - It's giving a HUGE error traceback, which is included in it's entirety below
jim#ubuntu:~/workspace/lgr$ hg ci -m 'testing hooks'
No username found, using 'jim#ubuntu.ubuntu-domain' instead
error: precommit hook raised an exception: '_demandmod' object is not iterable
** unknown exception encountered, details follow
** report bug details to http://mercurial.selenic.com/bts/
** or mercurial#selenic.com
** Mercurial Distributed SCM (version 1.3.1)
** Extensions loaded:
Traceback (most recent call last):
File "/usr/bin/hg", line 27, in <module>
mercurial.dispatch.run()
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 16, in run
sys.exit(dispatch(sys.argv[1:]))
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 27, in dispatch
return _runcatch(u, args)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 43, in _runcatch
return _dispatch(ui, args)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 449, in _dispatch
return runcommand(lui, repo, cmd, fullargs, ui, options, d)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 317, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 501, in _runcommand
return checkargs()
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 454, in checkargs
return cmdfunc()
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 448, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/usr/lib/pymodules/python2.6/mercurial/util.py", line 402, in check
return func(*args, **kwargs)
File "/usr/lib/pymodules/python2.6/mercurial/commands.py", line 667, in commit
node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
File "/usr/lib/pymodules/python2.6/mercurial/cmdutil.py", line 1213, in commit
return commitfunc(ui, repo, message, match(repo, pats, opts), opts)
File "/usr/lib/pymodules/python2.6/mercurial/commands.py", line 665, in commitfunc
editor=e, extra=extra)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 886, in commit
ret = self.commitctx(cctx, True)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 915, in commitctx
self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 139, in hook
return hook.hook(self.ui, self, name, throw, **args)
File "/usr/lib/pymodules/python2.6/mercurial/hook.py", line 119, in hook
r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
File "/usr/lib/pymodules/python2.6/mercurial/hook.py", line 52, in _pythonhook
r = obj(ui=ui, repo=repo, hooktype=name, **args)
here is the important part:
File "/home/jim/run_lgr_tests.py", line 11, in hook
output = call_command('test', verbosity=0, interactive=False)
and the rest:
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 213, in execute
translation.activate('en-us')
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 73, in activate
return real_activate(language)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 43, in delayed_loader
return g['real_%s' % caller](*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 205, in activate
_active[currentThread()] = translation(language)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 194, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 180, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 84, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/projects/lgr/apps/lgr_hacks.py", line 5, in <module>
User.email = models.EmailField(_('email address'), blank=True, max_length=200)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 62, in ugettext
return real_ugettext(message)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 286, in ugettext
return do_translate(message, 'ugettext')
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 276, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 194, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 180, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 84, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/apps/external_apps/djangodblog/__init__.py", line 1, in <module>
import djangodblog.admin
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 91, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/apps/external_apps/djangodblog/admin.py", line 14, in <module>
admin.site.register(ErrorBatch, ErrorBatchAdmin)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py", line 90, in register
validate(admin_class, model)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/validation.py", line 22, in validate
models.get_apps()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 100, in get_apps
self._populate()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 58, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 74, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 84, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/projects/lgr/apps/account/models.py", line 7, in <module>
from timezones.fields import TimeZoneField
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 103, in _demandimport
mod = _origimport(name, globals, locals)
File "/home/jim/workspace/lgr/pinax/apps/external_apps/timezones/fields.py", line 12, in <module>
default_tz = pytz.timezone(getattr(settings, "TIME_ZONE", "UTC"))
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 75, in __getattribute__
self._load()
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 47, in _load
mod = _origimport(head, globals, locals)
File "/home/jim/workspace/lgr/pinax/libs/external_libs/pytz-2008b/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 103, in _demandimport
mod = _origimport(name, globals, locals)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2562, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 626, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 505, in resolve
requirements = list(requirements)[::-1] # set up the stack
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2380, in parse_requirements
for line in lines:
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1814, in yield_lines
for s in yield_lines(ss):
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1813, in yield_lines
for ss in strs:
TypeError: '_demandmod' object is not iterable
It looks like Mercurial's way of importing modules is clashing with Django's somehow.
Before trying to dive in and sort that out, is there any reason to not just run the tests with the normal command?
[hooks]
precommit.runtests = python manage.py test