Add a __main__ to cubicweb
This avoids calling cubicweb-ctl relatively in tests and could be useful
in virtualenv.
This is just a copy of bin/cubicweb-ctl file, which should probably be
generated from a setuptools entry points.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/__main__.py Fri Jan 29 17:22:25 2016 +0100
@@ -0,0 +1,4 @@
+from cubicweb.cwctl import run
+import sys
+
+run(sys.argv[1:])
--- a/cubicweb/devtools/test/unittest_devctl.py Fri Feb 05 16:49:22 2016 +0100
+++ b/cubicweb/devtools/test/unittest_devctl.py Fri Jan 29 17:22:25 2016 +0100
@@ -17,7 +17,6 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""unit tests for cubicweb-ctl commands from devtools"""
-import os.path as osp
import sys
import tempfile
import shutil
@@ -29,12 +28,9 @@
"""test case for devtools commands"""
def test_newcube(self):
- cwctl = osp.abspath(osp.join(osp.dirname(__file__),
- '../../../bin/cubicweb-ctl'))
-
tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube")
try:
- cmd = [sys.executable, cwctl, 'newcube',
+ cmd = [sys.executable, '-m', 'cubicweb', 'newcube',
'--directory', tmpdir, 'foo']
proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
stdout, _ = proc.communicate(b'short_desc\n')
--- a/cubicweb/devtools/test/unittest_i18n.py Fri Feb 05 16:49:22 2016 +0100
+++ b/cubicweb/devtools/test/unittest_i18n.py Fri Jan 29 17:22:25 2016 +0100
@@ -62,11 +62,10 @@
else:
env['PYTHONPATH'] = ''
env['PYTHONPATH'] += DATADIR
- cwctl = osp.abspath(osp.join(osp.dirname(__file__),
- '../../../bin/cubicweb-ctl'))
with open(os.devnull, 'w') as devnull:
- subprocess.check_call([sys.executable, cwctl, 'i18ncube', 'i18ntestcube'],
- env=env, stdout=devnull)
+ subprocess.check_call(
+ [sys.executable, '-m', 'cubicweb', 'i18ncube', 'i18ntestcube'],
+ env=env, stdout=devnull)
cube = osp.join(DATADIR, 'cubes', 'i18ntestcube')
msgs = load_po(osp.join(cube, 'i18n', 'en.po.ref'))
newmsgs = load_po(osp.join(cube, 'i18n', 'en.po'))