<commit_before>import pickle
import unittest

from opentrons import containers, instruments
from opentrons import Robot


class PicklingRobotTestCase(unittest.TestCase):
    def setUp(self):
        Robot.reset_for_tests()
        self.robot = Robot()

    def test_pickling_unconfigured_robot(self):
        robot_as_bytes = self.robot.pickle()
        self.assertIsInstance(robot_as_bytes, bytes)
        reconstructed_robot = pickle.loads(robot_as_bytes)

    # def test_pickling_configured_robot(self):
    #     plate = containers.load('96-flat', 'A1')
    #     p200 = instruments.Pipette(axis='b', max_volume=200)
    #
    #     for well in plate:
    #         p200.aspirate(well).delay(5).dispense(well)
    #
    #     cmd_cnts = len(self.robot.commands())
    #     robot_as_bytes = self.robot.pickle()
    #     self.assertIsInstance(robot_as_bytes, bytes)
    #     reconstructed_robot = pickle.loads(robot_as_bytes)
    #
    #     reconstructed_robot_cmd_cnts = len(reconstructed_robot.commands())<commit_msg>adds tests for configured robot pickle<commit_after>import pickle
import unittest

from opentrons import containers, instruments
from opentrons import Robot


class PicklingRobotTestCase(unittest.TestCase):
    def setUp(self):
        Robot.reset_for_tests()
        self.robot = Robot()

    def test_pickling_unconfigured_robot(self):
        robot_as_bytes = self.robot.pickle()
        self.assertIsInstance(robot_as_bytes, bytes)
        reconstructed_robot = pickle.loads(robot_as_bytes)

    def test_pickling_configured_robot(self):
        plate = containers.load('96-flat', 'A1')
        p200 = instruments.Pipette(axis='b', max_volume=200)

        for well in plate:
            p200.aspirate(well).delay(5).dispense(well)

        cmd_cnts = len(self.robot.commands())
        print(self.robot._driver)
        robot_as_bytes = self.robot.pickle()
        print(self.robot._driver)
        self.assertIsInstance(robot_as_bytes, bytes)
        reconstructed_robot = pickle.loads(robot_as_bytes)

        reconstructed_robot_cmd_cnts = len(reconstructed_robot.commands())
{'fraction_non_alphanumeric': 0.09724857685009487, 'fraction_numerical': 0.012333965844402278, 'mean_word_length': 3.39375, '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': '4884726', 'n_tokens_mistral': 725, 'n_tokens_neox': 709, 'n_words': 108}