Skip to content

Commit

Permalink
coalaHelperTest.py: Mock the entry point
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tushar-rishav committed Aug 5, 2016
1 parent 748df2e commit 5206c9c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/coalaHelperTest.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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]
Expand All @@ -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))
Expand Down

0 comments on commit 5206c9c

Please sign in to comment.