Pregunta

I'm writing an RSS reader, and I want to gracefully handle situations where the internet connection is unavailable. What's a good way (on linux) to test program behavior in the absence of internet without pulling the cord and/or RF-killing everything?

¿Fue útil?

Solución

As User left in a comment, you could test this by mocking your network access library. At the point the library would normally access the network, you modify the behavior to grab a local file instead. This post describes the technique more, and includes code samples for Python and urllib.

Otros consejos

From https://bbs.archlinux.org/viewtopic.php?id=83384:

ifconfig eth0 down/up? (or other interface instead of eth0)

I can't test this, as I'm at work and need the Internet for stuff currently running, but hopefulyy this at least points you in the right direction.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top