Skip to content

Commit

Permalink
linting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariojmdavid committed Jun 20, 2021
1 parent 5f77c17 commit 77996d4
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions tests/unit/test_fakechroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
udocker unit tests: FakechrootEngine
"""

import sys
sys.path.append('.')
sys.path.append('../../')

from unittest import TestCase, main
from unittest.mock import patch, Mock
from udocker.config import Config
from udocker.engine.fakechroot import FakechrootEngine
try:
from unittest.mock import patch, Mock
except ImportError:
from mock import patch, Mock


class FakechrootEngineTestCase(TestCase):
Expand All @@ -27,8 +20,8 @@ def setUp(self):
Config().getconf()
Config().conf['hostauth_list'] = ("/etc/passwd", "/etc/group")
Config().conf['cmd'] = "/bin/bash"
Config().conf['cpu_affinity_exec_tools'] = (["numactl", "-C", "%s", "--", ],
["taskset", "-c", "%s", ])
Config().conf['cpu_affinity_exec_tools'] = \
(["numactl", "-C", "%s", "--", ], ["taskset", "-c", "%s", ])
Config().conf['valid_host_env'] = "HOME"
Config().conf['username'] = "user"
Config().conf['userhome'] = "/"
Expand Down Expand Up @@ -59,13 +52,11 @@ def test_01__init(self):

@patch('udocker.engine.fakechroot.sys.exit')
@patch('udocker.engine.fakechroot.OSInfo')
@patch('udocker.engine.fakechroot.Msg.err')
@patch('udocker.engine.fakechroot.os.path.realpath')
@patch('udocker.engine.fakechroot.os.path.exists')
@patch('udocker.engine.fakechroot.FileUtil')
def test_02_select_fakechroot_so(self, mock_futil, mock_exists,
mock_rpath, mock_msgerr, mock_osinfo,
mock_sysex):
mock_rpath, mock_osinfo, mock_sysex):
"""Test02 FakechrootEngine.select_fakechroot_so."""
Config().conf['fakechroot_so'] = "/s/fake1"
mock_exists.return_value = True
Expand All @@ -83,7 +74,8 @@ def test_02_select_fakechroot_so(self, mock_futil, mock_exists,
Config().conf['fakechroot_so'] = ""
mock_exists.return_value = False
mock_osinfo.return_value.arch.return_value = "amd64"
mock_osinfo.return_value.osdistribution.return_value = ("linux", "4.8.1")
mock_osinfo.return_value.osdistribution.return_value = \
("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = ""
mock_sysex.return_value = 1
ufake = FakechrootEngine(self.local, self.xmode)
Expand All @@ -94,8 +86,10 @@ def test_02_select_fakechroot_so(self, mock_futil, mock_exists,
Config().conf['fakechroot_so'] = ""
mock_exists.return_value = False
mock_osinfo.return_value.arch.return_value = "amd64"
mock_osinfo.return_value.osdistribution.return_value = ("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = "/libfakechroot.so"
mock_osinfo.return_value.osdistribution.return_value = \
("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = \
"/libfakechroot.so"
ufake = FakechrootEngine(self.local, self.xmode)
out = ufake.select_fakechroot_so()
self.assertTrue(mock_futil.called)
Expand All @@ -104,8 +98,10 @@ def test_02_select_fakechroot_so(self, mock_futil, mock_exists,
Config().conf['fakechroot_so'] = ""
mock_exists.return_value = False
mock_osinfo.return_value.arch.return_value = "i386"
mock_osinfo.return_value.osdistribution.return_value = ("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = "/libfakechroot.so"
mock_osinfo.return_value.osdistribution.return_value = \
("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = \
"/libfakechroot.so"
ufake = FakechrootEngine(self.local, self.xmode)
out = ufake.select_fakechroot_so()
self.assertTrue(mock_futil.called)
Expand All @@ -114,8 +110,10 @@ def test_02_select_fakechroot_so(self, mock_futil, mock_exists,
Config().conf['fakechroot_so'] = ""
mock_exists.return_value = False
mock_osinfo.return_value.arch.return_value = "arm64"
mock_osinfo.return_value.osdistribution.return_value = ("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = "/libfakechroot.so"
mock_osinfo.return_value.osdistribution.return_value = \
("linux", "4.8.1")
mock_futil.return_value.find_file_in_dir.return_value = \
"/libfakechroot.so"
ufake = FakechrootEngine(self.local, self.xmode)
out = ufake.select_fakechroot_so()
self.assertTrue(mock_futil.called)
Expand Down

0 comments on commit 77996d4

Please sign in to comment.