<commit_before>import os
import unittest

from attributes.unit_test import main
from tests import REPOS_PATH


class MainTestCase(unittest.TestCase):
    def test_main(self):
        # Test: Project using Mocha
        (result, value) = main.run(
            0, os.path.join(REPOS_PATH, 'superagent'), MockCursor()
        )
        self.assertTrue(result)
        self.assertLess(0, value)

        # Test: Project with no unit tests (when these tests were written)
        (result, value) = main.run(
            0, os.path.join(REPOS_PATH, 'javascript'), MockCursor()
        )
        self.assertFalse(result)
        self.assertEqual(-1, value)


class MockCursor(object):
    def __init__(self):
        super(MockCursor, self).__init__()
        self.record = None

    def execute(self, string):
        pass

    def fetchone(self):
        return ['JavaScript']

    def close(self):
        pass
<commit_msg>Skip test if repositories are not present<commit_after>import os
import unittest

from attributes.unit_test import main
from tests import REPOS_PATH


class MainTestCase(unittest.TestCase):
    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_main(self):
        # Test: Project using Mocha
        (result, value) = main.run(
            0, os.path.join(REPOS_PATH, 'superagent'), MockCursor()
        )
        self.assertTrue(result)
        self.assertLess(0, value)

        # Test: Project with no unit tests (when these tests were written)
        (result, value) = main.run(
            0, os.path.join(REPOS_PATH, 'javascript'), MockCursor()
        )
        self.assertFalse(result)
        self.assertEqual(-1, value)


class MockCursor(object):
    def __init__(self):
        super(MockCursor, self).__init__()
        self.record = None

    def execute(self, string):
        pass

    def fetchone(self):
        return ['JavaScript']

    def close(self):
        pass

{'fraction_non_alphanumeric': 0.1056701030927835, 'fraction_numerical': 0.004123711340206186, 'mean_word_length': 2.5226860254083485, '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': '4485316', 'n_tokens_mistral': 578, 'n_tokens_neox': 561, 'n_words': 151}