You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
748 B

4 years ago
  1. # Copyright (C) 2015 Stefan C. Mueller
  2. import unittest
  3. import ifaddr
  4. class TestIfaddr(unittest.TestCase):
  5. """
  6. Unittests for :mod:`ifaddr`.
  7. There isn't much unit-testing that can be done without making assumptions
  8. on the system or mocking of operating system APIs. So this just contains
  9. a sanity check for the moment.
  10. """
  11. def test_get_adapters_contains_localhost(self):
  12. found = False
  13. adapters = ifaddr.get_adapters()
  14. for adapter in adapters:
  15. for ip in adapter.ips:
  16. if ip.ip == "127.0.0.1":
  17. found = True
  18. self.assertTrue(found, "No adapter has IP 127.0.0.1: %s" % str(adapters))