Skip to content

Commit

Permalink
Merge cbffd48 into 2221bfd
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Apr 3, 2017
2 parents 2221bfd + cbffd48 commit 4d83a01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions duecredit/dueswitch.py
Expand Up @@ -73,16 +73,23 @@ def active(self):
return self.__active

@never_fail
def _dump_collector_summary(self):
def dump(self, **kwargs):
"""Dumps summary of the citations
Parameters
----------
**kwargs: dict
Passed to `CollectorSummary` constructor.
"""
from duecredit.collector import CollectorSummary
due_summary = CollectorSummary(self.__collectors[True])
due_summary = CollectorSummary(self.__collectors[True], **kwargs)
due_summary.dump()

def __prepare_exit_and_injections(self):
# Wrapper to create and dump summary... passing method doesn't work:
# probably removes instance too early

atexit.register(self._dump_collector_summary)
atexit.register(self.dump)

# Deal with injector
from .injections import DueCreditInjector
Expand All @@ -97,7 +104,7 @@ def activate(self, activate=True):
is_public = lambda x: not x.startswith('_')
# Clean up current bindings first
for k in filter(is_public, dir(self)):
if k not in ('activate', 'active'):
if k not in ('activate', 'active', 'dump'):
delattr(self, k)

new_due = self.__collectors[activate]
Expand Down
2 changes: 1 addition & 1 deletion duecredit/tests/test_dueswitch.py
Expand Up @@ -29,4 +29,4 @@ def test_dueswitch_activate(mock_register, mock_activate):
raise SkipTest("due is already active, can't test more at this point")
# was not active, so should have called activate of the injector class
mock_activate.assert_called_once_with()
mock_register.assert_called_once_with(due._dump_collector_summary)
mock_register.assert_called_once_with(due.dump)

0 comments on commit 4d83a01

Please sign in to comment.