Пример #1
0
def suite():
    suite = unittest.TestSuite()
    php = locate("php")
    if php:
        suite.addTest(unittest.makeSuite(PhpDeuglifierTestCase, "test"))
        suite.addTest(unittest.makeSuite(PhpRendererTestCase, "test"))
    else:
        print "SKIP: mimeview/tests/php.py (php cli binary, 'php', not found)"
    return suite
Пример #2
0
 def setUp(self):
     self.env = EnvironmentStub()
     self.repos_path = tempfile.mkdtemp(prefix='trac-gitrepos')
     self.git_bin = locate('git')
     # create git repository and master branch
     self._git('init', self.repos_path)
     create_file(os.path.join(self.repos_path, '.gitignore'))
     self._git('add', '.gitignore')
     self._git('commit', '-a', '-m', 'test')
Пример #3
0
def suite():
    suite = unittest.TestSuite()
    php = locate("php")
    if php:
        suite.addTest(unittest.makeSuite(PhpDeuglifierTestCase, 'test'))
        suite.addTest(unittest.makeSuite(PhpRendererTestCase, 'test'))
    else:
        print "SKIP: mimeview/tests/php.py"
    return suite
Пример #4
0
def suite():
    suite = unittest.TestSuite()
    php = locate("php")
    if php:
        suite.addTest(unittest.makeSuite(PhpDeuglifierTestCase, 'test'))
        suite.addTest(unittest.makeSuite(PhpRendererTestCase, 'test'))
    else:
        print "SKIP: mimeview/tests/php.py"
    return suite
Пример #5
0
 def setUp(self):
     self.env = EnvironmentStub()
     self.repos_path = tempfile.mkdtemp(prefix='trac-gitrepos')
     self.git_bin = locate('git')
     # create git repository and master branch
     self._git('init', self.repos_path)
     create_file(os.path.join(self.repos_path, '.gitignore'))
     self._git('add', '.gitignore')
     self._git('commit', '-a', '-m', 'test')
Пример #6
0
Файл: php.py Проект: ohanar/trac
def suite():
    suite = unittest.TestSuite()
    php = locate("php")
    if php:
        suite.addTest(unittest.makeSuite(PhpDeuglifierTestCase, 'test'))
        suite.addTest(unittest.makeSuite(PhpRendererTestCase, 'test'))
    else:
        print("SKIP: tracopt/mimeview/tests/php.py (php cli binary, 'php', "
              "not found)")
    return suite
Пример #7
0
def suite():
    suite = unittest.TestSuite()
    php = locate("php")
    if php:
        suite.addTest(unittest.makeSuite(PhpDeuglifierTestCase, 'test'))
        suite.addTest(unittest.makeSuite(PhpRendererTestCase, 'test'))
    else:
        print("SKIP: tracopt/mimeview/tests/php.py (php cli binary, 'php', "
              "not found)")
    return suite
Пример #8
0
def suite():
    suite = unittest.TestSuite()
    git = locate("git")
    if git:
        suite.addTest(unittest.makeSuite(GitTestCase, 'test'))
        suite.addTest(unittest.makeSuite(TestParseCommit, 'test'))
    else:
        print("SKIP: tracopt/versioncontrol/git/tests/PyGIT.py (git cli "
              "binary, 'git', not found)")
    return suite
Пример #9
0
def suite():
    suite = unittest.TestSuite()
    git = locate("git")
    if git:
        suite.addTest(unittest.makeSuite(GitTestCase, 'test'))
        suite.addTest(unittest.makeSuite(TestParseCommit, 'test'))
    else:
        print("SKIP: tracopt/versioncontrol/git/tests/PyGIT.py (git cli "
              "binary, 'git', not found)")
    return suite
Пример #10
0
class GitCommandMixin(object):

    git_bin = locate('git')

    def _git_commit(self, *args, **kwargs):
        env = kwargs.get('env') or os.environ.copy()
        if 'date' in kwargs:
            self._set_committer_date(env, kwargs.pop('date'))
        args = ('commit',) + args
        kwargs['env'] = env
        return self._git(*args, **kwargs)

    def _spawn_git(self, *args, **kwargs):
        args = map(to_utf8, (self.git_bin,) + args)
        kwargs.setdefault('stdin', PIPE)
        kwargs.setdefault('stdout', PIPE)
        kwargs.setdefault('stderr', PIPE)
        kwargs.setdefault('cwd', self.repos_path)
        return Popen(args, close_fds=close_fds, **kwargs)

    def _git(self, *args, **kwargs):
        with self._spawn_git(*args, **kwargs) as proc:
            stdout, stderr = proc.communicate()
        self.assertEqual(0, proc.returncode,
                         'git exits with %r, args %r, kwargs %r, stdout %r, '
                         'stderr %r' %
                         (proc.returncode, args, kwargs, stdout, stderr))
        return proc

    def _git_fast_import(self, data, **kwargs):
        if isinstance(data, unicode):
            data = data.encode('utf-8')
        with self._spawn_git('fast-import', stdin=PIPE, **kwargs) as proc:
            stdout, stderr = proc.communicate(input=data)
        self.assertEqual(0, proc.returncode,
                         'git exits with %r, stdout %r, stderr %r' %
                         (proc.returncode, stdout, stderr))

    def _git_date_format(self, dt):
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=utc)
        offset = dt.utcoffset()
        secs = offset.days * 3600 * 24 + offset.seconds
        hours, rem = divmod(abs(secs), 3600)
        return '%d %c%02d:%02d' % (to_timestamp(dt), '-' if secs < 0 else '+',
                                   hours, rem / 60)

    def _set_committer_date(self, env, dt):
        if not isinstance(dt, basestring):
            if dt.tzinfo is None:
                dt = dt.replace(tzinfo=utc)
            dt = self._git_date_format(dt)
        env['GIT_COMMITTER_DATE'] = dt
        env['GIT_AUTHOR_DATE'] = dt
Пример #11
0
 def setUp(self):
     self.env = EnvironmentStub()
     self.repos_path = tempfile.mkdtemp(prefix='trac-gitrepos-')
     self.git_bin = locate('git')
     # create git repository and master branch
     self._git('init', self.repos_path)
     self._git('config', 'core.quotepath', 'true')  # ticket:11198
     self._git('config', 'user.name', u"Joé")
     self._git('config', 'user.email', "*****@*****.**")
     create_file(os.path.join(self.repos_path, '.gitignore'))
     self._git('add', '.gitignore')
     self._git('commit', '-a', '-m', 'test')
Пример #12
0
 def setUp(self):
     self.env = EnvironmentStub()
     self.repos_path = tempfile.mkdtemp(prefix='trac-gitrepos')
     self.git_bin = locate('git')
     # create git repository and master branch
     self._git('init', self.repos_path)
     self._git('config', 'core.quotepath', 'true')  # ticket:11198
     self._git('config', 'user.name', u"Joé")
     self._git('config', 'user.email', "*****@*****.**")
     create_file(os.path.join(self.repos_path, '.gitignore'))
     self._git('add', '.gitignore')
     self._git('commit', '-a', '-m', 'test')
Пример #13
0
def suite():
    suite = unittest.TestSuite()
    git = locate("git")
    if git:
        suite.addTest(unittest.makeSuite(GitTestCase, 'test'))
        suite.addTest(unittest.makeSuite(TestParseCommit, 'test'))
        if os.name != 'nt':
            # Popen doesn't accept unicode path and arguments on Windows
            suite.addTest(unittest.makeSuite(UnicodeNameTestCase, 'test'))
    else:
        print("SKIP: tracopt/versioncontrol/git/tests/PyGIT.py (git cli "
              "binary, 'git', not found)")
    return suite
Пример #14
0
def suite():
    suite = unittest.TestSuite()
    git = locate("git")
    if git:
        suite.addTest(unittest.makeSuite(GitTestCase, 'test'))
        suite.addTest(unittest.makeSuite(TestParseCommit, 'test'))
        if os.name != 'nt':
            # Popen doesn't accept unicode path and arguments on Windows
            suite.addTest(unittest.makeSuite(UnicodeNameTestCase, 'test'))
    else:
        print("SKIP: tracopt/versioncontrol/git/tests/PyGIT.py (git cli "
              "binary, 'git', not found)")
    return suite
Пример #15
0
def suite():
    global repos_path, git_bin
    git_bin = locate('git')
    suite = unittest.TestSuite()
    if pygit2 and git_bin:
        repos_path = tempfile.mkdtemp(prefix='trac-gitrepos-')
        os.rmdir(repos_path)
        for case_class, suite_class in ((EmptyTestCase,
                                         EmptyGitRepositoryTestSuite),
                                        (NormalTestCase,
                                         GitRepositoryTestSuite)):
            for cached_repository in (False, True):
                prefix = ('NonCached', 'Cached')[cached_repository]
                tc = type(prefix + case_class.__name__,
                          (case_class, GitTestCaseSetup, unittest.TestCase),
                          {'cached_repository': cached_repository})
                suite.addTest(
                    unittest.makeSuite(tc, 'test', suiteClass=suite_class))
    else:
        print('SKIP: %s (no git binary installed)' % __name__)
    return suite