<commit_before>"""
Tests for `workbench` module.
"""
import pytest
import workbench


class TestWorkbench(object):

    @classmethod
    def setup_class(cls):
        pass

    def test_something(self):
        pass

    @classmethod
    def teardown_class(cls):
        pass<commit_msg>the test now actually does something<commit_after>"""
Tests for `workbench` module.
"""
import pytest
import subprocess
import time
import zerorpc

class TestWorkbench(object):

    @classmethod
    def setup_class(cls):
        pass

    def test_workbench(self):
        # Run the workbench server
        self.server_process = self.subprocess_manager('workbench')

        # Start up workbench connection
        workbench = zerorpc.Client()
        workbench.connect('tcp://localhost:4242')

        # Get all the dynamically loaded workers
        workers = workbench.list_all_workers()
        for worker in workers:

            # Invoke worker tests
            print 'Testing %s...' % worker
            print workbench.test_worker(worker)

        # Close the workbench connection
        workbench.close()

        # Terminate the workbench server process
        print '\nShutting down the Workbench server...'
        self.server_process.terminate()
        time.sleep(3)

    @classmethod
    def teardown_class(cls):
        pass

    def subprocess_manager(self, exec_args):
        try:
            process = subprocess.Popen(exec_args.split())
        except OSError:
            raise RuntimeError('Could not run workbench server (either not installed or not in path): %s' % (exec_args))
        return process


if __name__ == '__main__':
    test = TestWorkbench()
    test.test_workbench()
{'fraction_non_alphanumeric': 0.08480565371024736, 'fraction_numerical': 0.002944640753828033, 'mean_word_length': 2.546972860125261, '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': '7354781', 'n_tokens_mistral': 482, 'n_tokens_neox': 463, 'n_words': 134}