Skip to content

Commit

Permalink
Refine override_system_resolver coverage pragmas
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Sep 21, 2020
1 parent aca8568 commit 803ffed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dns_cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class NoExpirationPickableCache(NoExpirationCache, PickableCache):

def override_system_resolver(
resolver=None, cache=None, directory=None, min_ttl=FIVE_MINS
): # pragma: no cover
):
if not cache:
if directory:
if directory: # pragma: no cover

try:
os.makedirs(directory, exist_ok=True)
except TypeError:
Expand All @@ -60,12 +61,12 @@ def override_system_resolver(

if not resolver:
resolver = Resolver(configure=False)
try:
try: # pragma: no cover
if sys.platform == "win32":
resolver.read_registry()
else:
resolver.read_resolv_conf("/etc/resolv.conf")
except Exception:
except Exception: # pragma: no cover
resolver.nameservers = ["8.8.8.8"]

resolver.cache = cache
Expand Down

0 comments on commit 803ffed

Please sign in to comment.