~/talk

Unit Testing with Requests

Talkat PyCon AU 2017 · 2017-08-03..08-08· [testing, python]
links:none on file
slides:none on file

A practical how-to: requests-mock gives real requests.Response objects (status, raise_for_status, cookies), matches by URL/method/headers or regex, supports queued responses, exceptions and a history you can assert against; Betamax records a requests.Session to a cassette file (first run 9s, replay 0.2s, cassette ~200K JSON), supports placeholders for tokens and record modes. Tradeoffs: mocking tests exact protocol and edge cases, cassettes capture real behavior but can go stale when remote data changes.

AI-written summary · about

  1. 0:00Introduction
  2. 0:44The challenge of API testing
  3. 1:54Core testing concepts
  4. 2:50Understanding mocking
  5. 5:03Introducing requests-mock
  6. 15:34Betamax overview
  7. 16:39Implementing Betamax
  8. 22:31Trade-offs and best practices
  9. 25:00Q&A and closing
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.