def test_get_one_file_in_too_many(self): from check_manifest import get_one_file_in, Failure with mock.patch('os.listdir', lambda dir: ['b', 'a']): with self.assertRaises(Failure) as cm: get_one_file_in('/some/dir') self.assertEqual(str(cm.exception), "More than one file exists in /some/dir:\na\nb")
def test_get_one_file_in_empty_directory(self): from check_manifest import get_one_file_in, Failure with mock.patch('os.listdir', lambda dir: []): with self.assertRaises(Failure) as cm: get_one_file_in('/some/dir') self.assertEqual(str(cm.exception), "No files found in /some/dir")
def test_get_one_file_in(self): from check_manifest import get_one_file_in with mock.patch('os.listdir', lambda dir: ['a']): self.assertEqual(get_one_file_in(os.path.normpath('/some/dir')), os.path.normpath('/some/dir/a'))