aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
Diffstat (limited to 'becommands')
-rw-r--r--becommands/assign.py14
-rw-r--r--becommands/close.py11
-rw-r--r--becommands/comment.py27
-rw-r--r--becommands/diff.py12
-rw-r--r--becommands/help.py15
-rw-r--r--becommands/list.py11
-rw-r--r--becommands/merge.py50
-rw-r--r--becommands/new.py8
-rw-r--r--becommands/open.py11
-rw-r--r--becommands/remove.py8
-rw-r--r--becommands/set.py17
-rw-r--r--becommands/set_root.py19
-rw-r--r--becommands/severity.py17
-rw-r--r--becommands/show.py10
-rw-r--r--becommands/status.py17
-rw-r--r--becommands/target.py23
16 files changed, 131 insertions, 139 deletions
diff --git a/becommands/assign.py b/becommands/assign.py
index cb732b3..b00c5c2 100644
--- a/becommands/assign.py
+++ b/becommands/assign.py
@@ -18,7 +18,7 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
@@ -26,17 +26,17 @@ def execute(args):
>>> bd.bug_from_shortname("a").assigned is None
True
- >>> execute(["a"])
+ >>> execute(["a"], test=True)
>>> bd._clear_bugs()
>>> bd.bug_from_shortname("a").assigned == bd.user_id
True
- >>> execute(["a", "someone"])
+ >>> execute(["a", "someone"], test=True)
>>> bd._clear_bugs()
>>> print bd.bug_from_shortname("a").assigned
someone
- >>> execute(["a","none"])
+ >>> execute(["a","none"], test=True)
>>> bd._clear_bugs()
>>> bd.bug_from_shortname("a").assigned is None
True
@@ -44,11 +44,11 @@ def execute(args):
options, args = get_parser().parse_args(args)
assert(len(args) in (0, 1, 2))
if len(args) == 0:
- raise cmdutil.UserError("Please specify a bug id.")
+ raise cmdutil.UsageError("Please specify a bug id.")
if len(args) > 2:
help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError("Too many arguments.")
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
if len(args) == 1:
bug.assigned = bd.user_id
diff --git a/becommands/close.py b/becommands/close.py
index 8d2ccdb..d125397 100644
--- a/becommands/close.py
+++ b/becommands/close.py
@@ -18,7 +18,7 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> from libbe import bugdir
>>> import os
@@ -26,18 +26,17 @@ def execute(args):
>>> os.chdir(bd.root)
>>> print bd.bug_from_shortname("a").status
open
- >>> execute(["a"])
+ >>> execute(["a"], test=True)
>>> bd._clear_bugs()
>>> print bd.bug_from_shortname("a").status
closed
"""
options, args = get_parser().parse_args(args)
if len(args) == 0:
- raise cmdutil.UserError("Please specify a bug id.")
+ raise cmdutil.UsageError("Please specify a bug id.")
if len(args) > 1:
- help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError("Too many arguments.")
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
bug.status = "closed"
bd.save()
diff --git a/becommands/comment.py b/becommands/comment.py
index 172f818..c9c6b41 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -15,16 +15,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Add a comment to a bug"""
-from libbe import cmdutil, bugdir, utility
+from libbe import cmdutil, bugdir, editor
import os
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import time
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute(["a", "This is a comment about a"])
+ >>> execute(["a", "This is a comment about a"], test=True)
>>> bd._clear_bugs()
>>> bug = bd.bug_from_shortname("a")
>>> bug.load_comments()
@@ -41,12 +41,12 @@ def execute(args):
>>> if 'EDITOR' in os.environ:
... del os.environ["EDITOR"]
- >>> execute(["b"])
+ >>> execute(["b"], test=True)
Traceback (most recent call last):
UserError: No comment supplied, and EDITOR not specified.
>>> os.environ["EDITOR"] = "echo 'I like cheese' > "
- >>> execute(["b"])
+ >>> execute(["b"], test=True)
>>> bd._clear_bugs()
>>> bug = bd.bug_from_shortname("b")
>>> bug.load_comments()
@@ -57,10 +57,9 @@ def execute(args):
"""
options, args = get_parser().parse_args(args)
if len(args) == 0:
- raise cmdutil.UserError("Please specify a bug or comment id.")
+ raise cmdutil.UsageError("Please specify a bug or comment id.")
if len(args) > 2:
- help()
- raise cmdutil.UserError("Too many arguments.")
+ raise cmdutil.UsageError("Too many arguments.")
shortname = args[0]
if shortname.count(':') > 1:
@@ -73,20 +72,20 @@ def execute(args):
bugname = shortname
is_reply = False
- bd = bugdir.BugDir(from_disk=True)
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(bugname)
bug.load_comments()
if is_reply:
- parent = bug.comment_root.comment_from_shortname(shortname, bug_shortname=bugname)
+ parent = bug.comment_root.comment_from_shortname(shortname,
+ bug_shortname=bugname)
else:
parent = bug.comment_root
if len(args) == 1:
try:
- body = utility.editor_string("Please enter your comment above")
- except utility.CantFindEditor:
- raise cmdutil.UserError(
- "No comment supplied, and EDITOR not specified.")
+ body = editor.editor_string("Please enter your comment above")
+ except editor.CantFindEditor, e:
+ raise cmdutil.UserError, "No comment supplied, and EDITOR not specified."
if body is None:
raise cmdutil.UserError("No comment entered.")
body = body.decode('utf-8')
diff --git a/becommands/diff.py b/becommands/diff.py
index 862afc5..8714d77 100644
--- a/becommands/diff.py
+++ b/becommands/diff.py
@@ -20,7 +20,7 @@ from libbe import cmdutil, bugdir, diff
import os
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
@@ -31,7 +31,7 @@ def execute(args):
>>> changed = bd.rcs.commit("Closed bug a")
>>> os.chdir(bd.root)
>>> if bd.rcs.versioned == True:
- ... execute([original])
+ ... execute([original], test=True)
... else:
... print "a:cm: Bug A\\nstatus: open -> closed\\n"
Modified bug reports:
@@ -45,16 +45,14 @@ def execute(args):
if len(args) == 1:
revision = args[0]
if len(args) > 1:
- help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError("Too many arguments.")
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
if bd.rcs.versioned == False:
print "This directory is not revision-controlled."
else:
old_bd = bd.duplicate_bugdir(revision)
r,m,a = diff.diff(old_bd, bd)
- diff.diff_report((r,m,a), bd)
- # TODO, string return from diff report
+ print diff.diff_report((r,m,a), bd).encode(bd.encoding)
bd.remove_duplicate_bugdir()
def get_parser():
diff --git a/becommands/help.py b/becommands/help.py
index bf0b4fc..1c99af5 100644
--- a/becommands/help.py
+++ b/becommands/help.py
@@ -21,20 +21,25 @@ __desc__ = __doc__
def execute(args):
"""
Print help of specified command.
+ >>> execute(["help"])
+ Usage: be help [COMMAND]
+ <BLANKLINE>
+ Options:
+ -h, --help Print a help message
+ <BLANKLINE>
+ Print help for specified command or list of all commands.
+ <BLANKLINE>
"""
options, args = get_parser().parse_args(args)
if len(args) > 1:
- raise cmdutil.UserError("Too many arguments.")
+ raise cmdutil.UsageError("Too many arguments.")
if len(args) == 0:
print cmdutil.help()
else:
try:
print cmdutil.help(args[0])
except AttributeError:
- print "No help available"
-
- return
-
+ print "No help available"
def get_parser():
parser = cmdutil.CmdOptionParser("be help [COMMAND]")
diff --git a/becommands/list.py b/becommands/list.py
index 63e1cd6..c63039d 100644
--- a/becommands/list.py
+++ b/becommands/list.py
@@ -21,22 +21,21 @@ from libbe.bug import cmp_full, severity_values, status_values, \
import os
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute([])
+ >>> execute([], test=True)
a:om: Bug A
- >>> execute(["--status", "all"])
+ >>> execute(["--status", "all"], test=True)
a:om: Bug A
b:cm: Bug B
"""
options, args = get_parser().parse_args(args)
if len(args) > 0:
- help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError("Too many arguments.")
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bd.load_all_bugs()
# select status
if options.status != None:
diff --git a/becommands/merge.py b/becommands/merge.py
index b079f2c..d1829d6 100644
--- a/becommands/merge.py
+++ b/becommands/merge.py
@@ -19,7 +19,7 @@ from libbe import cmdutil, bugdir
import os, copy
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> from libbe import utility
>>> bd = bugdir.simple_bug_dir()
@@ -38,7 +38,7 @@ def execute(args):
>>> dummy.time = 2
>>> bd.save()
>>> os.chdir(bd.root)
- >>> execute(["a", "b"])
+ >>> execute(["a", "b"], test=True)
Merging bugs a and b
>>> bd._clear_bugs()
>>> a = bd.bug_from_shortname("a")
@@ -61,30 +61,30 @@ def execute(args):
Date: Thu, 01 Jan 1970 00:00:01 +0000
<BLANKLINE>
Testing
- --------- Comment ---------
- Name: a:2
- From: wking <wking@thor.yang.physics.drexel.edu>
- Date: Thu, 01 Jan 1970 00:00:02 +0000
+ --------- Comment ---------
+ Name: a:2
+ From: wking <wking@thor.yang.physics.drexel.edu>
+ Date: Thu, 01 Jan 1970 00:00:02 +0000
<BLANKLINE>
- Testing...
+ Testing...
--------- Comment ---------
Name: a:3
From: wking <wking@thor.yang.physics.drexel.edu>
Date: Thu, 01 Jan 1970 00:00:03 +0000
<BLANKLINE>
Merged from bug b
- --------- Comment ---------
- Name: a:4
- From: wking <wking@thor.yang.physics.drexel.edu>
- Date: Thu, 01 Jan 1970 00:00:01 +0000
+ --------- Comment ---------
+ Name: a:4
+ From: wking <wking@thor.yang.physics.drexel.edu>
+ Date: Thu, 01 Jan 1970 00:00:01 +0000
<BLANKLINE>
- 1 2
- --------- Comment ---------
- Name: a:5
- From: wking <wking@thor.yang.physics.drexel.edu>
- Date: Thu, 01 Jan 1970 00:00:02 +0000
+ 1 2
+ --------- Comment ---------
+ Name: a:5
+ From: wking <wking@thor.yang.physics.drexel.edu>
+ Date: Thu, 01 Jan 1970 00:00:02 +0000
<BLANKLINE>
- 1 2 3 4
+ 1 2 3 4
>>> b = bd.bug_from_shortname("b")
>>> b.load_comments()
>>> mergeB = b.comment_from_shortname(":3")
@@ -105,12 +105,12 @@ def execute(args):
Date: Thu, 01 Jan 1970 00:00:01 +0000
<BLANKLINE>
1 2
- --------- Comment ---------
- Name: b:2
- From: wking <wking@thor.yang.physics.drexel.edu>
- Date: Thu, 01 Jan 1970 00:00:02 +0000
+ --------- Comment ---------
+ Name: b:2
+ From: wking <wking@thor.yang.physics.drexel.edu>
+ Date: Thu, 01 Jan 1970 00:00:02 +0000
<BLANKLINE>
- 1 2 3 4
+ 1 2 3 4
--------- Comment ---------
Name: b:3
From: wking <wking@thor.yang.physics.drexel.edu>
@@ -122,12 +122,12 @@ def execute(args):
"""
options, args = get_parser().parse_args(args)
if len(args) < 2:
- raise cmdutil.UserError("Please two bug ids.")
+ raise cmdutil.UsageError("Please specify two bug ids.")
if len(args) > 2:
help()
- raise cmdutil.UserError("Too many arguments.")
+ raise cmdutil.UsageError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bugA = bd.bug_from_shortname(args[0])
bugA.load_comments()
bugB = bd.bug_from_shortname(args[1])
diff --git a/becommands/new.py b/becommands/new.py
index caa1549..bc17f83 100644
--- a/becommands/new.py
+++ b/becommands/new.py
@@ -18,14 +18,14 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os, time
>>> from libbe import bug
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
>>> bug.uuid_gen = lambda: "X"
- >>> execute (["this is a test",])
+ >>> execute (["this is a test",], test=True)
Created bug with ID X
>>> bd.load()
>>> bug = bd.bug_from_uuid("X")
@@ -40,8 +40,8 @@ def execute(args):
"""
options, args = get_parser().parse_args(args)
if len(args) != 1:
- raise cmdutil.UserError("Please supply a summary message")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError("Please supply a summary message")
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.new_bug(summary=args[0])
bd.save()
print "Created bug with ID %s" % bd.bug_shortname(bug)
diff --git a/becommands/open.py b/becommands/open.py
index 788a183..9a9667d 100644
--- a/becommands/open.py
+++ b/becommands/open.py
@@ -18,25 +18,24 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
>>> print bd.bug_from_shortname("b").status
closed
- >>> execute(["b"])
+ >>> execute(["b"], test=True)
>>> bd._clear_bugs()
>>> print bd.bug_from_shortname("b").status
open
"""
options, args = get_parser().parse_args(args)
if len(args) == 0:
- raise cmdutil.UserError("Please specify a bug id.")
+ raise cmdutil.UsageError, "Please specify a bug id."
if len(args) > 1:
- help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError, "Too many arguments."
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
bug.status = "open"
bd.save()
diff --git a/becommands/remove.py b/becommands/remove.py
index 8f7c2c6..386d9d4 100644
--- a/becommands/remove.py
+++ b/becommands/remove.py
@@ -18,7 +18,7 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> from libbe import mapfile
>>> import os
@@ -26,7 +26,7 @@ def execute(args):
>>> os.chdir(bd.root)
>>> print bd.bug_from_shortname("b").status
closed
- >>> execute (["b"])
+ >>> execute (["b"], test=True)
Removed bug b
>>> bd._clear_bugs()
>>> try:
@@ -37,8 +37,8 @@ def execute(args):
"""
options, args = get_parser().parse_args(args)
if len(args) != 1:
- raise cmdutil.UserError("Please specify a bug id.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError, "Please specify a bug id."
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
bd.remove_bug(bug)
bd.save()
diff --git a/becommands/set.py b/becommands/set.py
index 24011f0..3904262 100644
--- a/becommands/set.py
+++ b/becommands/set.py
@@ -18,25 +18,24 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute(["target"])
+ >>> execute(["target"], test=True)
None
- >>> execute(["target", "tomorrow"])
- >>> execute(["target"])
+ >>> execute(["target", "tomorrow"], test=True)
+ >>> execute(["target"], test=True)
tomorrow
- >>> execute(["target", "none"])
- >>> execute(["target"])
+ >>> execute(["target", "none"], test=True)
+ >>> execute(["target"], test=True)
None
"""
options, args = get_parser().parse_args(args)
if len(args) > 2:
- help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError, "Too many arguments"
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
if len(args) == 0:
keys = bd.settings.keys()
keys.sort()
diff --git a/becommands/set_root.py b/becommands/set_root.py
index e17bd87..11f38b9 100644
--- a/becommands/set_root.py
+++ b/becommands/set_root.py
@@ -19,7 +19,7 @@ import os.path
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> from libbe import utility, rcs
>>> import os
@@ -29,7 +29,7 @@ def execute(args):
... except bugdir.NoBugDir, e:
... True
True
- >>> execute([dir.path])
+ >>> execute([dir.path], test=True)
No revision control detected.
Directory initialized.
>>> del(dir)
@@ -40,34 +40,31 @@ def execute(args):
>>> rcs.init('.')
>>> print rcs.name
Arch
- >>> execute([])
+ >>> execute([], test=True)
Using Arch for revision control.
Directory initialized.
>>> rcs.cleanup()
>>> try:
- ... execute(['.'])
+ ... execute(['.'], test=True)
... except cmdutil.UserError, e:
... str(e).startswith("Directory already initialized: ")
True
- >>> execute(['/highly-unlikely-to-exist'])
+ >>> execute(['/highly-unlikely-to-exist'], test=True)
Traceback (most recent call last):
UserError: No such directory: /highly-unlikely-to-exist
>>> os.chdir('/')
"""
options, args = get_parser().parse_args(args)
if len(args) > 1:
- print help()
- raise cmdutil.UserError, "Too many arguments"
+ raise cmdutil.UsageError
if len(args) == 1:
basedir = args[0]
else:
basedir = "."
- if os.path.exists(basedir) == False:
- pass
- #raise cmdutil.UserError, "No such directory: %s" % basedir
try:
- bd = bugdir.BugDir(basedir, from_disk=False, sink_to_existing_root=False, assert_new_BugDir=True)
+ bd = bugdir.BugDir(basedir, from_disk=False, sink_to_existing_root=False, assert_new_BugDir=True,
+ manipulate_encodings=not test)
except bugdir.NoRootEntry:
raise cmdutil.UserError("No such directory: %s" % basedir)
except bugdir.AlreadyInitialized:
diff --git a/becommands/severity.py b/becommands/severity.py
index 3adefaa..3c856de 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -19,25 +19,24 @@ from libbe import cmdutil, bugdir
from libbe.bug import severity_values, severity_description
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute(["a"])
+ >>> execute(["a"], test=True)
minor
- >>> execute(["a", "wishlist"])
- >>> execute(["a"])
+ >>> execute(["a", "wishlist"], test=True)
+ >>> execute(["a"], test=True)
wishlist
- >>> execute(["a", "none"])
+ >>> execute(["a", "none"], test=True)
Traceback (most recent call last):
UserError: Invalid severity level: none
"""
options, args = get_parser().parse_args(args)
if len(args) not in (1,2):
- print help()
- return
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
if len(args) == 1:
print bug.severity
@@ -46,7 +45,7 @@ def execute(args):
bug.severity = args[1]
except ValueError, e:
if e.name != "severity":
- raise
+ raise e
raise cmdutil.UserError ("Invalid severity level: %s" % e.value)
bd.save()
diff --git a/becommands/show.py b/becommands/show.py
index 45cd6ad..3bd7e63 100644
--- a/becommands/show.py
+++ b/becommands/show.py
@@ -18,12 +18,12 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute (["a",])
+ >>> execute (["a",], test=True)
ID : a
Short name : a
Severity : minor
@@ -37,11 +37,11 @@ def execute(args):
"""
options, args = get_parser().parse_args(args)
if len(args) == 0:
- raise cmdutil.UserError("Please specify a bug id.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
for bugid in args:
bug = bd.bug_from_shortname(bugid)
- print bug.string(show_comments=True).encode('utf-8')
+ print bug.string(show_comments=True)
def get_parser():
parser = cmdutil.CmdOptionParser("be show BUG-ID [BUG-ID ...]")
diff --git a/becommands/status.py b/becommands/status.py
index a30b3d6..73d43f8 100644
--- a/becommands/status.py
+++ b/becommands/status.py
@@ -19,29 +19,28 @@ from libbe import cmdutil, bugdir
from libbe.bug import status_values, status_description
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute(["a"])
+ >>> execute(["a"], test=True)
open
- >>> execute(["a", "closed"])
- >>> execute(["a"])
+ >>> execute(["a", "closed"], test=True)
+ >>> execute(["a"], test=True)
closed
- >>> execute(["a", "none"])
+ >>> execute(["a", "none"], test=True)
Traceback (most recent call last):
UserError: Invalid status: none
"""
options, args = get_parser().parse_args(args)
if len(args) not in (1,2):
- print help()
- return
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
if len(args) == 1:
print bug.status
- elif len(args) == 2:
+ else:
try:
bug.status = args[1]
except ValueError, e:
diff --git a/becommands/target.py b/becommands/target.py
index dce100f..4371ef0 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -18,33 +18,32 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute(["a"])
+ >>> execute(["a"], test=True)
No target assigned.
- >>> execute(["a", "tomorrow"])
- >>> execute(["a"])
+ >>> execute(["a", "tomorrow"], test=True)
+ >>> execute(["a"], test=True)
tomorrow
- >>> execute(["a", "none"])
- >>> execute(["a"])
+ >>> execute(["a", "none"], test=True)
+ >>> execute(["a"], test=True)
No target assigned.
"""
options, args = get_parser().parse_args(args)
- assert(len(args) in (0, 1, 2))
- if len(args) == 0:
- print help()
- return
- bd = bugdir.BugDir(from_disk=True)
+ if len(args) not in (1, 2):
+ raise cmdutil.UsageError
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
if len(args) == 1:
if bug.target is None:
print "No target assigned."
else:
print bug.target
- elif len(args) == 2:
+ else:
+ assert len(args) == 2
if args[1] == "none":
bug.target = None
else: