Skip to content

Commit 3939b45

Browse files
committed
tests: Fix coverage after recent import tweaks
We need to cleanup the c file at exit.
1 parent 424f6ff commit 3939b45

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ MANIFEST
44
dist
55
build
66
.coverage
7-
bin/bugzillac

tests/__init__.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11

2+
import atexit
23
import commands
34
import difflib
5+
import imp
46
import os
57
import shlex
68
import sys
79
import StringIO
810

911

12+
_cleanup = []
13+
14+
15+
def _import(name, path):
16+
_cleanup.append(path + "c")
17+
return imp.load_source(name, path)
18+
19+
20+
def _cleanup_cb():
21+
for f in _cleanup:
22+
if os.path.exists(f):
23+
os.unlink(f)
24+
25+
26+
atexit.register(_cleanup_cb)
27+
bugzillascript = _import("bugzillascript", "bin/bugzilla")
28+
29+
30+
1031
def diff(orig, new):
1132
"""
1233
Return a unified diff string between the passed strings
@@ -31,8 +52,6 @@ def clicomm(argv, bzinstance, returnmain=False, printcliout=False,
3152
"""
3253
Run bin/bugzilla.main() directly with passed argv
3354
"""
34-
import imp
35-
bugzillascript = imp.load_source("bugzillascript", "bin/bugzilla")
3655

3756
argv = shlex.split(argv)
3857

0 commit comments

Comments
 (0)