<commit_before>from os import path
import unittest

from binstar_client.inspect_package.ipynb import IPythonNotebook, inspect_ipynb_package


def data_path(filename):
    return path.join(path.dirname(__file__), 'data', filename)


class IPythonNotebookTestCase(unittest.TestCase):
    def test_package_name(self):
        with open(data_path('notebook.ipynb')) as fileobj:
            assert IPythonNotebook('notebook.ipynb', fileobj).name == 'notebook'

    def test_version(self):
        with open(data_path('notebook.ipynb')) as fileobj:
            self.assertIsInstance(IPythonNotebook('notebook.ipynb', fileobj).version, str)


class InspectIPYNBPackageTest(unittest.TestCase):
    def test_inspect_ipynb_package(self):<commit_msg>added tests<commit_after>
from os import path
import unittest

from binstar_client.inspect_package.ipynb import IPythonNotebook, inspect_ipynb_package
import io


def data_path(filename):
    return path.join(path.dirname(__file__), 'data', filename)


class IPythonNotebookTestCase(unittest.TestCase):
    def test_package_name(self):

        fileobj = io.StringIO()
        self.assertEqual(IPythonNotebook('notebook.ipynb', fileobj).name, 'notebook')

    def test_package_name_unicode(self):

        fileobj = io.StringIO()
        self.assertEqual(IPythonNotebook('na\xcc\x83o.ipynb', fileobj).name, 'nao')

    def test_version(self):
        with open(data_path('notebook.ipynb')) as fileobj:
            self.assertIsInstance(IPythonNotebook('notebook.ipynb', fileobj).version, str)


class InspectIPYNBPackageTest(unittest.TestCase):
    def test_inspect_ipynb_package(self):
{'fraction_non_alphanumeric': 0.10338461538461538, 'fraction_numerical': 0.0012307692307692308, 'mean_word_length': 4.934306569343065, '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': '3101517', 'n_tokens_mistral': 539, 'n_tokens_neox': 525, 'n_words': 91}