aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2007-12-18 00:53:27 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2007-12-18 01:12:22 -0800
commit436463e7874524b21d70bdd9bb2be8bae1d3441c (patch)
tree020b0581a4b3d2e3036131deaa41348c3f846a29
parentAdd some more testcases. (diff)
downloadgitosis-dakkar-436463e7874524b21d70bdd9bb2be8bae1d3441c.tar.gz
gitosis-dakkar-436463e7874524b21d70bdd9bb2be8bae1d3441c.tar.bz2
gitosis-dakkar-436463e7874524b21d70bdd9bb2be8bae1d3441c.zip
Add more testcases, and add coverage exclusion notations on places where we do test the the content functions already, or they interact with the system too much to test for coverage automatically.
-rw-r--r--gitosis/app.py4
-rw-r--r--gitosis/gitdaemon.py2
-rw-r--r--gitosis/gitweb.py2
-rw-r--r--gitosis/init.py6
-rw-r--r--gitosis/repository.py10
-rw-r--r--gitosis/run_hook.py4
-rw-r--r--gitosis/serve.py2
-rw-r--r--gitosis/ssh.py2
-rw-r--r--gitosis/test/test_gitweb.py30
-rw-r--r--gitosis/test/test_zzz_app.py22
-rw-r--r--gitosis/util.py2
11 files changed, 54 insertions, 32 deletions
diff --git a/gitosis/app.py b/gitosis/app.py
index ff44fed..3037923 100644
--- a/gitosis/app.py
+++ b/gitosis/app.py
@@ -81,7 +81,7 @@ class App(object):
# ignore this particular error case
raise ConfigFileDoesNotExistError(str(ex))
else:
- raise CannotReadConfigError(str(ex))
+ raise CannotReadConfigError(str(ex)) #pragma: no cover
try:
cfg.readfp(conffile)
finally:
@@ -107,7 +107,7 @@ class App(object):
else:
logging.root.setLevel(symbolic)
- def handle_args(self, parser, cfg, options, args):
+ def handle_args(self, parser, cfg, options, args): #pragma: no cover
"""Abstract method for the non-option argument handling."""
if args:
parser.error('not expecting arguments')
diff --git a/gitosis/gitdaemon.py b/gitosis/gitdaemon.py
index e529302..1e43047 100644
--- a/gitosis/gitdaemon.py
+++ b/gitosis/gitdaemon.py
@@ -82,7 +82,7 @@ def set_export_ok(config):
repositories = util.getRepositoryDir(config)
global_enable = _is_global_repo_export_ok(config)
- def _error(ex):
+ def _error(ex): #pragma: no cover
"""Ignore non-existant items."""
if ex.errno == errno.ENOENT:
pass
diff --git a/gitosis/gitweb.py b/gitosis/gitweb.py
index 723cc9c..271e1bd 100644
--- a/gitosis/gitweb.py
+++ b/gitosis/gitweb.py
@@ -136,7 +136,7 @@ def set_descriptions(config):
except (NoSectionError, NoOptionError):
continue
- if not description:
+ if not description: #pragma: no cover
continue
name = sectiontitle[1]
diff --git a/gitosis/init.py b/gitosis/init.py
index 91e986e..054bda1 100644
--- a/gitosis/init.py
+++ b/gitosis/init.py
@@ -20,7 +20,7 @@ from gitosis import app
# pylint: disable-msg=C0103
log = logging.getLogger('gitosis.init')
-def read_ssh_pubkey(fp=None):
+def read_ssh_pubkey(fp=None): #pragma: no cover
"""Read an SSH public key from stdin."""
if fp is None:
fp = sys.stdin
@@ -53,7 +53,7 @@ def initial_commit(git_dir, cfg, pubkey, user):
],
)
-def symlink_config(git_dir):
+def symlink_config(git_dir): #pragma: no cover
"""
Place a symlink for the gitosis.conf file in the homedir of the gitosis
user, to make possible to find initially.
@@ -118,7 +118,7 @@ class Main(app.App):
except app.ConfigFileDoesNotExistError:
pass
- def handle_args(self, parser, cfg, options, args):
+ def handle_args(self, parser, cfg, options, args): #pragma: no cover
"""Parse the input for this program."""
super(Main, self).handle_args(parser, cfg, options, args)
diff --git a/gitosis/repository.py b/gitosis/repository.py
index 47ebc1e..db74046 100644
--- a/gitosis/repository.py
+++ b/gitosis/repository.py
@@ -52,7 +52,7 @@ def init(
stdout=sys.stderr,
close_fds=True,
)
- if returncode != 0:
+ if returncode != 0: #pragma: no cover
raise GitInitError('exit status %d' % returncode)
@@ -108,7 +108,7 @@ data %(commit_msg_len)d
child.stdin.write('M 100644 :%d %s\n' % (index+1, path))
child.stdin.close()
returncode = child.wait()
- if returncode != 0:
+ if returncode != 0: #pragma: no cover
raise GitFastImportError(
'git fast-import failed', 'exit status %d' % returncode)
@@ -134,7 +134,7 @@ def export(git_dir, path):
],
close_fds=True,
)
- if returncode != 0:
+ if returncode != 0: #pragma: no cover
raise GitReadTreeError('exit status %d' % returncode)
# jumping through hoops to be compatible with git versions
# that don't have --work-tree=
@@ -153,7 +153,7 @@ def export(git_dir, path):
close_fds=True,
env=env,
)
- if returncode != 0:
+ if returncode != 0: #pragma: no cover
raise GitCheckoutIndexError('exit status %d' % returncode)
class GitHasInitialCommitError(GitError):
@@ -183,5 +183,5 @@ def has_initial_commit(git_dir):
return False
elif re.match('^[0-9a-f]{40}\n$', got):
return True
- else:
+ else: #pragma: no cover
raise GitHasInitialCommitError('Unknown git HEAD: %r' % got)
diff --git a/gitosis/run_hook.py b/gitosis/run_hook.py
index a1ce0ad..230eb4f 100644
--- a/gitosis/run_hook.py
+++ b/gitosis/run_hook.py
@@ -33,7 +33,7 @@ def build_reposistory_data(config):
config=config,
)
-def post_update(cfg, git_dir):
+def post_update(cfg, git_dir): #pragma: no cover
"""
post-update hook for the Gitosis admin directory.
@@ -71,7 +71,7 @@ class Main(app.App):
'Perform gitosis actions for a git hook')
return parser
- def handle_args(self, parser, cfg, options, args):
+ def handle_args(self, parser, cfg, options, args): #pragma: no cover
"""Parse the input for this program."""
try:
(hook,) = args
diff --git a/gitosis/serve.py b/gitosis/serve.py
index 3bc126a..c473de5 100644
--- a/gitosis/serve.py
+++ b/gitosis/serve.py
@@ -135,7 +135,7 @@ class Main(app.App):
'Allow restricted git operations under DIR')
return parser
- def handle_args(self, parser, cfg, options, args):
+ def handle_args(self, parser, cfg, options, args): #pragma: no cover
"""Parse the input for this program."""
try:
(user,) = args
diff --git a/gitosis/ssh.py b/gitosis/ssh.py
index f280b8b..0d2d87f 100644
--- a/gitosis/ssh.py
+++ b/gitosis/ssh.py
@@ -79,7 +79,7 @@ def writeAuthorizedKeys(path, keydir):
tmp = '%s.%d.tmp' % (path, os.getpid())
try:
in_ = file(path)
- except IOError, ex:
+ except IOError, ex: #pragma: no cover
if ex.errno == errno.ENOENT:
in_ = None
else:
diff --git a/gitosis/test/test_gitweb.py b/gitosis/test/test_gitweb.py
index 8bf6d10..e538ec7 100644
--- a/gitosis/test/test_gitweb.py
+++ b/gitosis/test/test_gitweb.py
@@ -223,22 +223,22 @@ def test_description_again():
got = readFile(os.path.join(path, 'description'))
eq(got, 'foodesc\n')
-def test_escape_filename_normal()
- i = 'abc'
- eq(gitweb._escape_filename(i), 'abc')
+def test_escape_filename_normal():
+ i = 'abc'
+ eq(gitweb._escape_filename(i), 'abc')
-def test_escape_filename_slashone()
- i = 'ab\\c'
- eq(gitweb._escape_filename(i), 'ab\\\\c')
+def test_escape_filename_slashone():
+ i = 'ab\\c'
+ eq(gitweb._escape_filename(i), 'ab\\\\c')
-def test_escape_filename_slashtwo()
- i = 'ab\\\\c'
- eq(gitweb._escape_filename(i), 'ab\\\\\\\\c')
+def test_escape_filename_slashtwo():
+ i = 'ab\\\\c'
+ eq(gitweb._escape_filename(i), 'ab\\\\\\\\c')
-def test_escape_filename_dollar()
- i = 'abc$'
- eq(gitweb._escape_filename(i), 'abc\\$')
+def test_escape_filename_dollar():
+ i = 'abc$'
+ eq(gitweb._escape_filename(i), 'abc\\$')
-def test_escape_filename_quote()
- i = 'abc"'
- eq(gitweb._escape_filename(i), 'abc\\"')
+def test_escape_filename_quote():
+ i = 'abc"'
+ eq(gitweb._escape_filename(i), 'abc\\"')
diff --git a/gitosis/test/test_zzz_app.py b/gitosis/test/test_zzz_app.py
index cb20eb6..27ba697 100644
--- a/gitosis/test/test_zzz_app.py
+++ b/gitosis/test/test_zzz_app.py
@@ -1,6 +1,9 @@
from nose.tools import eq_ as eq, assert_raises
from gitosis import app
+from gitosis import init
+from gitosis import run_hook
+from gitosis import serve
import sys
import os
@@ -70,6 +73,25 @@ def test_app_setup_logging_badname():
cfg.set('gitosis', 'loglevel', 'FOOBAR')
main.setup_logging(cfg)
+def test_appinit_create_parser():
+ main = init.Main()
+ parser = main.create_parser()
+
+def test_appinit_read_config():
+ main = init.Main()
+ cfg = main.create_config(None)
+ parser = main.create_parser()
+ (options, args) = parser.parse_args(['--config=/does/not/exist'])
+ main.read_config(options, cfg)
+
+def test_apprunhook_create_parser():
+ main = run_hook.Main()
+ parser = main.create_parser()
+
+def test_appserve_create_parser():
+ main = serve.Main()
+ parser = main.create_parser()
+
# We must call this test last
def test_zzz_app_main():
class Main(TestMain):
diff --git a/gitosis/util.py b/gitosis/util.py
index 83f66d4..2da4168 100644
--- a/gitosis/util.py
+++ b/gitosis/util.py
@@ -29,7 +29,7 @@ def _sysfunc(func, ignore, *args, **kwds):
Run the specified function, ignoring the specified errno if raised, and
raising other errors.
"""
- if not ignore:
+ if not ignore: # pragma: no cover
ignore = []
try:
func(*args, **kwds)