From 5206c9c4597e55534cbd72f71d61d022b0aacb79 Mon Sep 17 00:00:00 2001 From: Tushar Gautam Date: Sat, 23 Jul 2016 14:32:16 +0530 Subject: [PATCH] coalaHelperTest.py: Mock the entry point While collecting the CLI argument list from `default_arg_parser` it expects to have a valid entry points (sys.argv[0]). The entry points might not be available in case of testing the wrapper around default arg parser. Hence, it's essential to mock this behaviour. --- tests/coalaHelperTest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/coalaHelperTest.py b/tests/coalaHelperTest.py index e6aeac8..cecd52f 100644 --- a/tests/coalaHelperTest.py +++ b/tests/coalaHelperTest.py @@ -1,6 +1,7 @@ import json import os import shutil +import sys import unittest from coalahtml.helper import (get_file, parse_file_dict, build_file_graph, @@ -10,6 +11,8 @@ class coalaHelperTest(unittest.TestCase): def setUp(self): + self.old_argv = sys.argv + sys.argv = ['coala'] # mock the entry point self.dir_name = "someRandomName" self.test_dir_path = os.path.abspath(self.dir_name) self.file_name = self.dir_name[::2] @@ -20,6 +23,9 @@ def setUp(self): test_file_name: (test_file_content)}} self.test_file_data = {test_file_name: test_file_content} + def tearDown(self): + sys.argv = self.old_argv + def test_get_file(self): test_file_path = os.path.abspath(os.path.join(self.test_dir_path, self.file_name))