FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Why I Stopped Mocking 2FA in Tests (And What I Do Instead)
How-ToProgramming Languages

Why I Stopped Mocking 2FA in Tests (And What I Do Instead)

via Dev.to PythonMike Davis3h ago

I mocked OTP verification for two years. Then a bug hit production that my test suite should have caught. Here's what went wrong and how I fixed the approach. I'll start with the bug that changed my mind. Last summer, we pushed a release that broke the phone number change flow in our app. A user would enter their new number, receive an OTP, type it in — and get a 400 error. The code was correct in every way except one: someone refactored the verification endpoint and accidentally changed the OTP field name from otp_code to verification_code in the request body. The frontend still sent otp_code . The backend no longer recognized it. Our test suite had 100% coverage on this flow. Every test passed. Green across the board. Why? Because we were mocking the entire OTP layer. The Mock That Lies Here's roughly what our test setup looked like: # conftest.py — the old way @pytest.fixture def mock_otp ( monkeypatch ): """ Skip OTP verification entirely in tests. """ monkeypatch . setenv ( " SKIP

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
3 views

Related Articles

What You Need to Know About Building an Outdoor Sauna (2026)
How-To

What You Need to Know About Building an Outdoor Sauna (2026)

Wired • 3h ago

The Boring Skills That Make Developers Unstoppable in 2026
How-To

The Boring Skills That Make Developers Unstoppable in 2026

Medium Programming • 7h ago

I Installed This VS Code Extension… and My Code Got Instantly Better
How-To

I Installed This VS Code Extension… and My Code Got Instantly Better

Medium Programming • 9h ago

The Age of Personalized Software
How-To

The Age of Personalized Software

Medium Programming • 10h ago

Automating Checkout Add-On Recommendations in WordPress for WooCommerce
How-To

Automating Checkout Add-On Recommendations in WordPress for WooCommerce

Dev.to • 11h ago

Discover More Articles