class TestSwiftLMDetect(unittest.TestCase): def setUp(self): self.testdir = tempfile.mkdtemp() self.detect = SwiftLMDetect(self.testdir) def tearDown(self): rmtree(self.testdir, ignore_errors=True) def _test_detect(self, service): self.detect.SWIFTLM_DIR = self.testdir conf_file = service + '.conf' conf_path = os.path.join(self.testdir, conf_file) with open(conf_path, 'wb'): self.detect._detect() self.assertTrue(self.detect.available) def test_detect_server(self): self._test_detect('swiftlm-scan') def test_detect_none(self): self.detect.SWIFT_DIR = self.testdir self.detect._detect() self.assertFalse(self.detect.available)
def setUp(self): self.testdir = tempfile.mkdtemp() self.detect = SwiftLMDetect(self.testdir)