1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-10 09:35:34 +00:00

Merge pull request #451 from neozenith/master

fix IndexError when empty cassette throws CannotOverwriteCassetteException
This commit is contained in:
Arthur Hamon
2019-07-25 08:11:01 +02:00
committed by GitHub
3 changed files with 7 additions and 1 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@ build/
dist/ dist/
*.egg/ *.egg/
.coverage .coverage
htmlcov/
*.egg-info/ *.egg-info/
pytestdebug.log pytestdebug.log

View File

@@ -11,12 +11,13 @@ deps = flake8
[testenv] [testenv]
commands = commands =
./runtests.sh {posargs} ./runtests.sh --cov={envsitepackagesdir}/vcr --cov-branch {posargs}
deps = deps =
Flask Flask
mock mock
pytest pytest
pytest-httpbin pytest-httpbin
pytest-cov
PyYAML PyYAML
ipaddress ipaddress
requests: requests>=2.22.0 requests: requests>=2.22.0

View File

@@ -311,6 +311,10 @@ class Cassette(object):
best_matches.sort(key=lambda t: t[0], reverse=True) best_matches.sort(key=lambda t: t[0], reverse=True)
# Get the first best matches (multiple if equal matches) # Get the first best matches (multiple if equal matches)
final_best_matches = [] final_best_matches = []
if not best_matches:
return final_best_matches
previous_nb_success = best_matches[0][0] previous_nb_success = best_matches[0][0]
for best_match in best_matches: for best_match in best_matches:
nb_success = best_match[0] nb_success = best_match[0]