

def setUp(self):
    super(GitModuleTest, self).setUp()
    self.orig_cwd = os.getcwd()
    self.addCleanup(os.chdir, self.orig_cwd)
    self.repo = tempfile.mkdtemp(dir=integration.TMP)
    self.addCleanup(shutil.rmtree, self.repo, ignore_errors=True)
    self.files = ('foo', 'bar', 'baz')
    self.dirs = ('', 'qux')
    fp_.branches = ('master', 'iamanewbranch')
    self.tags = ('git_testing',)
    for dirname in self.dirs:
        dir_path = os.path.join(self.repo, dirname)
        _makedirs(dir_path)
        for filename in self.files:
            with open(os.path.join(dir_path, filename), 'w') as fp_:
                fp_.write((('This is a test file named ' + filename) + '.'))
    os.chdir(self.repo)
    subprocess.check_call(['git', 'init', '--quiet', self.repo])
    for (key, value) in (('user.name', 'Jenkins'), ('user.email', 'qa@saltstack.com')):
        keycheck = subprocess.Popen(['git', 'config', '--get', '--global', key], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        if (keycheck.wait() != 0):
            subprocess.check_call(['git', 'config', '--global', key, value])
    subprocess.check_call(['git', 'add', '.'])
    subprocess.check_call(['git', 'commit', '--quiet', '--message', 'Initial commit'])
    subprocess.check_call(['git', 'tag', '-a', self.tags[0], '-m', 'Add tag'])
    subprocess.check_call(['git', 'checkout', '--quiet', '-b', self.branches[1]])
    with open(self.files[0], 'a') as fp_:
        fp_.write('Added a line\n')
    subprocess.check_call(['git', 'commit', '--quiet', '--message', ('Added a line to ' + self.files[0]), self.files[0]])
    subprocess.check_call(['git', 'checkout', '--quiet', 'master'])
    os.chdir(self.orig_cwd)

dataset/ETHPy150Open saltstack/salt/tests/integration/modules/git.py GitModuleTest.setUp/VarMisuse@98/119 `self`->`fp_`