Skip to content

Commit

Permalink
default status code to 200
Browse files Browse the repository at this point in the history
  • Loading branch information
grizz committed Jan 1, 2018
1 parent d9516bc commit 64fa28c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Added
### Fixed
### Changed
- requests status code is optional, defaults to 200

### Deprecated
### Removed
### Security
Expand Down
9 changes: 7 additions & 2 deletions pytest_filedata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,18 @@ def callback(self, request, context):
path = urlparse.urlparse(request.url).path
path = os.path.join(test_dir, 'data', self.prefix, path.lstrip('/'))
files = get_test_files(path)

if len(files) != 1:
raise NotImplementedError("Currently there must be only one response file")

fname = files[0]

# file extension is status code
context.status_code = int(os.path.splitext(fname)[1].lstrip('.'))
try:
# file extension is status code
context.status_code = int(os.path.splitext(fname)[1].lstrip('.'))

except ValueError:
context.status_code = 200

with open(fname) as fobj:
return fobj.read()
Expand Down
File renamed without changes.

0 comments on commit 64fa28c

Please sign in to comment.