aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-01-07 18:12:26 +0100
committerGuido Günther <agx@sigxcpu.org>2014-01-07 18:12:26 +0100
commitd93c89f081a3d8d66a46cbefee26b0bf11822c7f (patch)
tree44fb3f64a835190ed75480071f5eaf1fddd3cde5
parente876beb4461a35f1a1647bb1f24611e2016353a6 (diff)
import_orig: test error paths of find_source
-rw-r--r--gbp/scripts/import_orig.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index dbb1ce9d..aae93fab 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -121,18 +121,32 @@ def detect_name_and_version(repo, source, options):
return (sourcepackage, version)
-def find_source(options, args):
+def find_source(use_uscan, args):
"""Find the tarball to import - either via uscan or via command line argument
@return: upstream source filename or None if nothing to import
@rtype: string
@raise GbpError: raised on all detected errors
- """
- if options.uscan: # uscan mode
- uscan = Uscan()
+ >>> find_source(False, ['too', 'much'])
+ Traceback (most recent call last):
+ ...
+ GbpError: More than one archive specified. Try --help.
+ >>> find_source(False, [])
+ Traceback (most recent call last):
+ ...
+ GbpError: No archive to import specified. Try --help.
+ >>> find_source(True, ['tarball'])
+ Traceback (most recent call last):
+ ...
+ GbpError: you can't pass both --uscan and a filename.
+ >>> find_source(False, ['tarball']).path
+ 'tarball'
+ """
+ if use_uscan:
if args:
raise GbpError("you can't pass both --uscan and a filename.")
+ uscan = Uscan()
gbp.log.info("Launching uscan...")
try:
uscan.scan()
@@ -248,7 +262,7 @@ def main(argv):
return 1
try:
- source = find_source(options, args)
+ source = find_source(options.uscan, args)
if not source:
return ret