<commit_before>import os

from unittest2 import TestCase

from chef.api import ChefAPI

TEST_ROOT = os.path.dirname(os.path.abspath(__file__))

def test_chef_api():
    return ChefAPI('https://api.opscode.com/organizations/pycheftest', os.path.join(TEST_ROOT, 'client.pem'), 'unittests')


class ChefTestCase(TestCase):
    """Base class for Chef unittests."""
    
    def setUp(self):
        super(ChefTestCase, self).setUp()
        self.api = test_chef_api
        self.api.set_default()<commit_msg>Add a method to generate random names for testing.<commit_after>import os
import random

from unittest2 import TestCase

from chef.api import ChefAPI

TEST_ROOT = os.path.dirname(os.path.abspath(__file__))

def test_chef_api():
    return ChefAPI('https://api.opscode.com/organizations/pycheftest', os.path.join(TEST_ROOT, 'client.pem'), 'unittests')


class ChefTestCase(TestCase):
    """Base class for Chef unittests."""
    
    def setUp(self):
        super(ChefTestCase, self).setUp()
        self.api = test_chef_api
        self.api.set_default()

    def random(self, length=8, alphabet='0123456789abcdef'):
        return ''.join(random.choice(alphabet) for _ in xrange(length))
{'fraction_non_alphanumeric': 0.12405699916177704, 'fraction_numerical': 0.010896898575020955, 'mean_word_length': 4.037974683544304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '622587', 'n_tokens_mistral': 412, 'n_tokens_neox': 392, 'n_words': 84}