Tests: Don't hardcode errno constants

The values of ENOENT and ESRCH are architecture-dependent, so don't
assume they're always 2 and 3.
This commit is contained in:
Jakub Wilk 2018-02-17 13:59:29 +01:00
parent a9017ccf19
commit e36145b4fa
4 changed files with 10 additions and 6 deletions

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import division
import errno
import os
from sys import stderr
import shutil
@ -144,7 +145,7 @@ class Hooks(object):
shutil.rmtree(self.hookdir)
except OSError as e:
# If the hookdir folder doesn't exist, no harm done and keep going
if e.errno != 2:
if e.errno != errno.ENOENT:
raise
os.mkdir(self.hookdir)
@ -258,7 +259,7 @@ class Hook(object):
try:
os.remove(file)
except OSError as e:
if e.errno == 2:
if e.errno == errno.ENOENT:
raise HookError("Hook with name {0} was not found on "
"hooks/ folder".format(file))
else: