Sometimes you need to create valid IP addresses, which can be used without interfering running infrastructure.
The easiest thing is to take a address which is tied to localhost, so traffic
never leaves your dev machine or environment.
Every address from 127.0.0.1 up to 127.255.255.254 does so.
For IP version 4 this could be done like this:
import random # should be called once random.seed() def getLocalv4Addr(): return [127,random.randint(0,255),random.randint(0,255),random.randint(1,254)]
With IP version 6 there is only one loopback address, ::1.
So in that case you need to setup something else, e.g. you could
run your tests inside a docker container and do not expose any network to the outside.