Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
neoppod
Commits
7a75daa9
Commit
7a75daa9
authored
Dec 28, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: new --cov-unit runner option
parent
0ae3482b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
neo/scripts/runner.py
neo/scripts/runner.py
+23
-1
neo/tests/__init__.py
neo/tests/__init__.py
+19
-0
No files found.
neo/scripts/runner.py
View file @
7a75daa9
...
...
@@ -33,7 +33,8 @@ if filter(re.compile(r'--coverage$|-\w*c').match, sys.argv[1:]):
coverage.neotestrunner = []
coverage.start()
from neo.tests import getTempDirectory, __dict__ as neo_tests__dict__
from neo.tests import getTempDirectory, NeoTestBase, Patch, \
__dict__ as neo_tests__dict__
from neo.tests.benchmark import BenchmarkRunner
# list of test modules
...
...
@@ -226,6 +227,9 @@ class TestRunner(BenchmarkRunner):
def add_options(self, parser):
parser.add_option('
-
c
', '
--
coverage
', action='
store_true
',
help='
Enable
coverage
')
parser.add_option('
-
C
', '
--
cov
-
unit
', action='
store_true
',
help='
Same
as
-
c
but
output
1
file
per
test
,
'
'
in
the
temporary
test
directory
')
parser.add_option('
-
f', '
--
functional
', action='
store_true
',
help='
Functional
tests
')
parser.add_option('
-
u', '
--
unit
', action='
store_true
',
...
...
@@ -261,6 +265,8 @@ Environment Variables:
""" % neo_tests__dict__
def load_options(self, options, args):
if options.coverage and options.cov_unit:
sys.exit('
-
c
conflicts
with
-
C
')
if not (options.unit or options.functional or options.zodb):
if not args:
sys.exit('
Nothing
to
run
,
please
give
one
of
-
f
,
-
u
,
-
z
')
...
...
@@ -271,6 +277,7 @@ Environment Variables:
zodb = options.zodb,
verbosity = 2 if options.verbose else 1,
coverage = options.coverage,
cov_unit = options.cov_unit,
only = args,
)
...
...
@@ -279,6 +286,21 @@ Environment Variables:
only = config.only
# run requested tests
runner = NeoTestRunner(config.title or '
Neo
', config.verbosity)
if config.cov_unit:
from coverage import Coverage
cov_dir = runner.temp_directory + '
/
coverage
'
os.mkdir(cov_dir)
@Patch(NeoTestBase)
def setUp(orig, self):
orig(self)
self.__coverage = Coverage('
%
s
/%
s
' % (cov_dir, self.id()))
self.__coverage.start()
@Patch(NeoTestBase)
def _tearDown(orig, self, success):
self.__coverage.stop()
self.__coverage.save()
del self.__coverage
orig(self, success)
try:
if config.unit:
runner.run('
Unit
tests
', UNIT_TEST_MODULES, only)
...
...
neo/tests/__init__.py
View file @
7a75daa9
...
...
@@ -552,10 +552,29 @@ class Patch(object):
For patched callables, the new one receives the original value as first
argument.
Alternative usage:
@Patch(someObject)
def funcToPatch(orig, ...):
...
...
funcToPatch.revert()
The decorator applies the patch immediately.
"""
applied
=
False
def
__new__
(
cls
,
patched
,
**
patch
):
if
patch
:
return
object
.
__new__
(
cls
)
def
patch
(
func
):
self
=
cls
(
patched
,
**
{
func
.
__name__
:
func
})
self
.
apply
()
return
self
return
patch
def
__init__
(
self
,
patched
,
**
patch
):
(
name
,
patch
),
=
patch
.
iteritems
()
self
.
_patched
=
patched
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment