<commit_before>#!/usr/bin/env python
from datetime import datetime
import unittest

from pyvcs.backends import get_backend
from pyvcs.exceptions import FileDoesNotExist, FolderDoesNotExist

class GitTest(unittest.TestCase):
    def setUp(self):
        git = get_backend('git')
        self.repo = git.Repository('/home/alex/django_src/')

    def test_commits(self):
        commit = self.repo.get_commit_by_id('c3699190186561d5c216b2a77ecbfc487d42a734')
        self.assert_(commit.author.startswith('ubernostrum'))
        self.assertEqual(commit.time, datetime(2009, 6, 30, 13, 40, 29))
        self.assert_(commit.message.startswith('Fixed #11357: contrib.admindocs'))
        self.assertEqual(commit.files, ['django/contrib/admindocs/views.py'])

    def test_list_directory(self):
        files, folders = self.repo.list_directory('tests/', 'c3699190186561d5c216b2a77ecbfc487d42a734')
        self.assertEqual(files, ['runtests.py', 'urls.py'])
        self.assertEqual(folders, ['modeltests', 'regressiontests', 'templates'])

    def test_file_contents(self):
        contents = self.repo.file_contents('django/db/models/fields/related.py',
            'c3699190186561d5c216b2a77ecbfc487d42a734')
        self.assertEqual(contents.splitlines()[:2], [
            'from django.db import connection, transaction',
            'from django.db.backends import util'
        ])

    def test_diffs(self):
        self.assertEqual(self.repo._diff_files(
            '35fa967a05d54d5159eb1c620544e050114ab0ed',
            'c3699190186561d5c216b2a77ecbfc487d42a734'
        ), ['django/contrib/admindocs/views.py'])
        files = [
            'AUTHORS',
            'django/contrib/gis/db/models/aggregates.py',<commit_msg>test that exception is raised<commit_after>#!/usr/bin/env python
from datetime import datetime
import unittest

from pyvcs.backends import get_backend
from pyvcs.exceptions import FileDoesNotExist, FolderDoesNotExist

class GitTest(unittest.TestCase):
    def setUp(self):
        git = get_backend('git')
        self.repo = git.Repository('/home/alex/django_src/')

    def test_commits(self):
        commit = self.repo.get_commit_by_id('c3699190186561d5c216b2a77ecbfc487d42a734')
        self.assert_(commit.author.startswith('ubernostrum'))
        self.assertEqual(commit.time, datetime(2009, 6, 30, 13, 40, 29))
        self.assert_(commit.message.startswith('Fixed #11357: contrib.admindocs'))
        self.assertEqual(commit.files, ['django/contrib/admindocs/views.py'])

    def test_list_directory(self):
        files, folders = self.repo.list_directory('tests/', 'c3699190186561d5c216b2a77ecbfc487d42a734')
        self.assertEqual(files, ['runtests.py', 'urls.py'])
        self.assertEqual(folders, ['modeltests', 'regressiontests', 'templates'])

    def test_file_contents(self):
        contents = self.repo.file_contents('django/db/models/fields/related.py',
            'c3699190186561d5c216b2a77ecbfc487d42a734')
        self.assertEqual(contents.splitlines()[:2], [
            'from django.db import connection, transaction',
            'from django.db.backends import util'
        ])
        self.assertRaises(FileDoesNotExist, self.repo.file_contents, 'django/db/models/jesus.py')

    def test_diffs(self):
        self.assertEqual(self.repo._diff_files(
            '35fa967a05d54d5159eb1c620544e050114ab0ed',
            'c3699190186561d5c216b2a77ecbfc487d42a734'
        ), ['django/contrib/admindocs/views.py'])
        files = [
            'AUTHORS',
            'django/contrib/gis/db/models/aggregates.py',
{'fraction_non_alphanumeric': 0.12072829131652661, 'fraction_numerical': 0.08851540616246499, 'mean_word_length': 3.4805520702634882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1833702', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1188, 'n_words': 164}