def METHOD_NAME(self):
    with open(self.network_file, "w") as f:
        f.write(
            "some other content\n"
            "     HOSTNAME=spam   \n"
            "more content\n"
        )
    self.instance.set_permanent_hostname("foobar")
    with open(self.network_file) as f:
        self.assertEqual(
            f.read(),
            "some other content\n"
            "HOSTNAME=foobar\n"
            "more content\n"
        )