Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/django/core/mail/utils.py: 60%

10 statements  

« prev     ^ index     » next       coverage.py v7.0.5, created at 2023-01-17 06:13 +0000

1""" 

2Email message and email sending related helper functions. 

3""" 

4 

5import socket 

6 

7from django.utils.encoding import punycode 

8 

9 

10# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of 

11# seconds, which slows down the restart of the server. 

12class CachedDnsName: 

13 def __str__(self): 

14 return self.get_fqdn() 

15 

16 def get_fqdn(self): 

17 if not hasattr(self, "_fqdn"): 

18 self._fqdn = punycode(socket.getfqdn()) 

19 return self._fqdn 

20 

21 

22DNS_NAME = CachedDnsName()