<commit_before>import os
from getgist import Gist
from re import search
from unittest import TestCase
try:
    from urllib2 import urlopen
except ImportError:
    from urllib.request import urlopen

test_user = 'cuducos'
test_gist = '.vimrc'


class TestAPI(TestCase):

    def setUp(self):
        self.gist = Gist(test_user, test_gist)

    def test_id(self):
        self.assertTrue(search(r'[\w\d]{16,}', self.gist.id))

    def test_raw_url(self):
        request = urlopen(self.gist.raw_url)
        self.assertEqual(request.getcode(), 200)


class TestDownload(TestCase):

    def setUp(self):
        self.gist = Gist(test_user, test_gist, True)

    def tearDown(self):
        for file_name in os.listdir(self.gist.local_dir):
            if search(r'^({})(\.bkp(.\d)?)?$'.format(test_gist), file_name):
                os.remove(os.path.join(self.gist.local_dir, file_name))

    def test_local_dir(self):
        self.assertTrue(os.path.exists(self.gist.local_dir))
        self.assertTrue(os.path.isdir(self.gist.local_dir))

    def test_download(self):
        self.gist.save()
        self.assertTrue(os.path.exists(self.gist.local_path))
<commit_msg>Use Python3 import<commit_after>from __future__ import absolute_import

import os
from .getgist import Gist
from re import search
from unittest import TestCase

try:
    from urllib2 import urlopen
except ImportError:
    from urllib.request import urlopen

test_user = 'cuducos'
test_gist = '.vimrc'


class TestAPI(TestCase):

    def setUp(self):
        self.gist = Gist(test_user, test_gist)

    def test_id(self):
        self.assertTrue(search(r'[\w\d]{16,}', self.gist.id))

    def test_raw_url(self):
        request = urlopen(self.gist.raw_url)
        self.assertEqual(request.getcode(), 200)


class TestDownload(TestCase):

    def setUp(self):
        self.gist = Gist(test_user, test_gist, True)

    def tearDown(self):
        for file_name in os.listdir(self.gist.local_dir):
            if search(r'^({})(\.bkp(.\d)?)?$'.format(test_gist), file_name):
                os.remove(os.path.join(self.gist.local_dir, file_name))

    def test_local_dir(self):
        self.assertTrue(os.path.exists(self.gist.local_dir))
        self.assertTrue(os.path.isdir(self.gist.local_dir))

    def test_download(self):
        self.gist.save()
        self.assertTrue(os.path.exists(self.gist.local_path))

{'fraction_non_alphanumeric': 0.12809743805123897, 'fraction_numerical': 0.005459890802183957, 'mean_word_length': 3.223404255319149, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '993660', 'n_tokens_mistral': 862, 'n_tokens_neox': 835, 'n_words': 152}