frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Why your mock breaks later

https://nedbatchelder.com/blog/202511/why_your_mock_breaks_later.html
16•ingve•2h ago

Comments

gsnedders•31m ago
Arguably this is a problem in when the patch is unapplied.

Presumably in the coverage case it’s being called by a trace function, which inevitably runs during test execution — and while we want the trace function to be called during the test function, we really want it without any patches the test function is using. But this arguably requires both an ability for the trace function to opt-out of patches and for the patcher to provide a way to temporarily disable all of them.

esafak•23m ago
It is worth pointing out that you can often use containerized services as an alternative to mocking.
Izkata•18m ago
> In Why your mock doesn’t work I explained this rule of mocking:

> Mock where the object is used, not where it’s defined.

For anyone looking for generic advice, this is a quirk of python due to how imports work in that language (details in the linked post) and shouldn't be considered universal.

kaashif•14m ago
Why even mock anything in this example? You need to read the source code to work out what to mock, reaching deep inside the code to name some method to mock.

But what if you just passed in the contents of the file or something?

Edit: oh wait actually this is what the very last line in the blog post says! But I think it should be emphasized more!

lelandbatey•14m ago
I feel like the #1 reason mocks break looks nothing like this and instead looks like: you change the internal behaviors of a function/method and now the mocks interact differently with the underlying code, forcing you to change the mocks. Which highlights how awful mocking as a concept is; it is of truly limited usefulness for anything but the most brittle of tests.

Don't test the wrong things; if you care about some precondition, that should be an input. If you need to measure a side effect, that should be an output. Don't tweak global state to do your testing.

dherls•1m ago
This blog post talks as if mocking the `open` function is a good thing that people should be told how to do. If you are mocking anything in the standard library your code is probably structured poorly.

In the example the author walks through, a cleaner way would be to have the second function take the Options as a parameter and decouple those two functions. You can then test both in isolation.

The AI Scientist: Towards Automated Open-Ended Scientific Discovery

https://sakana.ai/ai-scientist/
1•azhenley•2m ago•0 comments

Nanopass Framework

https://nanopass.org
1•swatson741•7m ago•0 comments

Anthakshari AI

https://anthakshari.ai/
1•hareeshimo•8m ago•0 comments

U.S. to designate Maduro-linked Cartel de los Soles as terrorists

https://bnonews.com/index.php/2025/11/u-s-to-designate-maduro-linked-cartel-de-los-soles-as-terro...
1•wslh•9m ago•0 comments

The Optimization Trap

https://domofutu.substack.com/p/the-optimization-trap
2•domofutu•10m ago•0 comments

Building a High Performance Home

https://dan.bulwinkle.net/blog/building-a-high-performance-home/
1•pilingual•14m ago•0 comments

Sakana AI Series B Announcement

https://sakana.ai/series-b/
1•hardmaru•15m ago•1 comments

Why movies just don't feel "real" anymore

https://old.reddit.com/r/movies/comments/1oyjduk/why_movies_just_dont_feel_real_anymore/
2•Jun8•18m ago•0 comments

Scams 'Ghost broking': cut-price car insurance isn't all it seems

https://www.theguardian.com/money/2025/nov/16/ghost-broking-cut-price-car-insurance-scam-watch
2•zeristor•18m ago•0 comments

'Aristocratic Tutoring' Cannot Explain von Neumann's Success

https://greyenlightenment.com/2025/11/15/aristocratic-tutoring-cannot-explain-von-neumanns-success/
1•paulpauper•21m ago•0 comments

Show HN: AirPods Seamless-Handoff with Linux

https://github.com/xatuke/handoff
1•satuke•21m ago•0 comments

Hertfordshire police admit unlawful arrest of couple in school WhatsApp row

https://www.theguardian.com/uk-news/2025/nov/16/hertfordshire-police-admit-unlawful-arrest-of-bor...
2•zeristor•24m ago•0 comments

The weird technical restrictions of the Nintendo 64

https://www.youtube.com/watch?v=DCt7UZkS-w4
2•bane•31m ago•0 comments

Which Humans? LLMs mainly mirror WEIRD minds (Europeans?)

https://www.hks.harvard.edu/centers/cid/publications/which-humans
2•kaven1234•33m ago•1 comments

Simpler train travel London airports, tap-in, tap-out expanded across SE England

https://www.gov.uk/government/news/simpler-train-travel-to-london-airports-as-tap-in-tap-out-expa...
3•zeristor•34m ago•1 comments

Quotes from Moral Mazes (2019)

https://www.lesswrong.com/posts/45mNHCMaZgsvfDXbw/quotes-from-moral-mazes
1•jger15•36m ago•0 comments

blockchain analytics platform

https://info.arkm.com
3•salkahfi•42m ago•1 comments

Commander's Guide to Money as a Weapons System [pdf]

https://www.govinfo.gov/content/pkg/GOVPUB-D110-PURL-gpo122806/pdf/GOVPUB-D110-PURL-gpo122806.pdf
4•rglover•44m ago•0 comments

Charlie Javice Legal Bills

https://www.nytimes.com/2025/11/14/business/charlie-javice-jpmorgan-legal-bills.html
4•bmiekre•46m ago•1 comments

Show HN: CUDA, Shmuda: Fold Proteins on a MacBook

https://latentspacecraft.com/posts/mlx-protein-folding
4•geoffitect•47m ago•0 comments

I Worked All over Silicon Valley. This Is How It Lost Its Spine

https://www.nytimes.com/2025/11/12/opinion/silicon-valley-meta-apple-trump.html
6•2OEH8eoCRo0•50m ago•0 comments

A new chapter begins for EV batteries with the expiry of key LFP patents

https://www.shoosmiths.com/insights/articles/a-new-chapter-begins-for-ev-batteries-with-the-expir...
2•toomuchtodo•57m ago•0 comments

Coherent Synchrotron Radiation by Excitation of SPPs on Near-Critical CNT

https://arxiv.org/abs/2507.04561
1•westurner•58m ago•2 comments

Ask HN: LangChain for Rails, Port with AI?

1•eibrahim•58m ago•0 comments

Strandbeest Evolution 2025 [video]

https://www.youtube.com/watch?v=ANhA94ZqnEQ
1•MaysonL•1h ago•0 comments

1990 VHS • Cyberpunk 60 FPS [video]

https://archive.org/details/TheVistaGroup-Cyberpunk1990
3•petethomas•1h ago•0 comments

The Deployment Age

https://reactionwheel.net/2015/10/the-deployment-age.html
2•gmays•1h ago•0 comments

Aptronym

https://en.wikipedia.org/wiki/Aptronym
2•benbreen•1h ago•0 comments

How do we train a frontier model (small) in 2025?

https://weirdfishes.substack.com/p/how-do-we-train-a-frontier-model
3•sert_121•1h ago•0 comments

Show HN: Hirelens – AI Resume Analyzer for ESL and Global Job Seekers

https://www.hirelens.co/
1•hl_maker•1h ago•0 comments