Skip to content

add option to raise an exception if vcr is used and it's not needed#7

Merged
barsch merged 1 commit intomasterfrom
raise_if_not_needed
Apr 1, 2017
Merged

add option to raise an exception if vcr is used and it's not needed#7
barsch merged 1 commit intomasterfrom
raise_if_not_needed

Conversation

@megies
Copy link
Member

@megies megies commented Apr 1, 2017

This way it becomes more obvious if decorator is used where it should not be.. otherwise it's sometimes hard to know why tape files are not generated for decorated functions when the warning message is suppressed..

In obspy this can then look like:

$ obspy-runtests clients.fdsn --vcr-record
Running /home/megies/git/obspy-master/obspy/scripts/runtests.py, ObsPy version '1.0.3.post0+1008.g2485130a56.dirty.obspy.vcr'
...............E........................................................

======================================================================
ERROR: test_manually_deactivate_single_service (obspy.clients.fdsn.tests.test_client.ClientTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<decorator-gen-54>", line 2, in test_manually_deactivate_single_service
  File "/home/megies/git/obspy-master/obspy/core/util/decorator.py", line 87, in vcr
    decorated_func=func, raise_if_not_needed=True)(*args, **kwargs)
  File "/home/megies/git/vcr/vcr/core.py", line 498, in _vcr_inner
    raise Exception(msg)
Exception: no socket activity - @vcr decorator unneeded for test_manually_deactivate_single_service

----------------------------------------------------------------------
Ran 72 tests in 94.194s

FAILED (errors=1)
Do you want to report this to tests.obspy.org? [n]: 

Otherwise test passes without a VCR tape generated and it's not immediately obvious what's going wrong..

@megies megies requested a review from barsch April 1, 2017 11:34
barsch added a commit that referenced this pull request Apr 1, 2017
@megies megies force-pushed the raise_if_not_needed branch from fa32289 to b784c4f Compare April 1, 2017 11:44
this way it becomes more obvious if decorator is used where it shouldnt
be..
@megies megies force-pushed the raise_if_not_needed branch from b784c4f to 08b9f72 Compare April 1, 2017 11:58
Copy link
Member

@barsch barsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@barsch barsch merged commit 2482ade into master Apr 1, 2017
@barsch barsch deleted the raise_if_not_needed branch April 1, 2017 12:30
barsch added a commit that referenced this pull request Apr 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants