<commit_before>import argparse
import sys
import time
import unittest

from opentrons_sdk.drivers.motor import OpenTrons, GCodeLogger


class SerialTestCase(unittest.TestCase):

    def assertLastCommand(self, *commands, index=-1):
        lastCommand = self.motor.connection.write_buffer[index].decode("utf-8") 
        foundOne = False
        for command in commands:
            if lastCommand.startswith(command):
                foundOne = True
                break

        msg = "Expected last CNC command to be "

        if len(commands) is 1:
            msg += '"' + commands[0] + '" '
        else:
            msg += "one of: " + ", ".join(commands) + " "

        msg += "but got \"" + lastCommand.strip() + "\"."

        self.assertTrue(foundOne, msg=msg)

    def assertLastArguments(self, *arguments, index=-1):
        lastCommand = self.motor.connection.write_buffer[index].decode("utf-8") 
        for arg in arguments:
            msg = "Expected last command arguments to include " + \
                  "\"" + arg + "\" but got \"" + lastCommand.strip() +\
                  "\" instead."
            self.assertTrue(arg in lastCommand, msg=msg)


class OpenTronsTest(SerialTestCase):

    def setUp(self):

        # set this to True if testing with a robot connected
        # testing while connected allows the response handlers
        # and serial handshakes to be tested
        self.smoothie_connected = True

        self.motor = OpenTrons()

        self.smoothie_connected = False

        myport = '/dev/tty.usbmodem1421'

        if myport:
            self.smoothie_connected = True
            success = self.motor.connect(myport)
            self.assertTrue(success)
        else:
            self.motor.connection = GCodeLogger()

    def tearDown(self):
        self.motor.disconnect()

    def test_get_position(self):
        self.motor.home()
        coords = self.motor.get_position()
        if self.smoothie_connected:
            expected_coords = {
                'target':{'x':0,'y':0,'z':0,'a':0,'b':0},
                'current':{'x':0,'y':0,'z':0,'a':0,'b':0}
            }
            self.assertEquals(coords,expected_coords)
        else:
            self.assertLastCommand('M114')

    def test_halt(self):
        success = self.motor.halt()
        if self.smoothie_connected:
            self.assertTrue(success)
        else:
            self.assertLastCommand('M112')<commit_msg>removing com port from test<commit_after>import argparse
import sys
import time
import unittest

from opentrons_sdk.drivers.motor import OpenTrons, GCodeLogger


class SerialTestCase(unittest.TestCase):

    def assertLastCommand(self, *commands, index=-1):
        lastCommand = self.motor.connection.write_buffer[index].decode("utf-8") 
        foundOne = False
        for command in commands:
            if lastCommand.startswith(command):
                foundOne = True
                break

        msg = "Expected last CNC command to be "

        if len(commands) is 1:
            msg += '"' + commands[0] + '" '
        else:
            msg += "one of: " + ", ".join(commands) + " "

        msg += "but got \"" + lastCommand.strip() + "\"."

        self.assertTrue(foundOne, msg=msg)

    def assertLastArguments(self, *arguments, index=-1):
        lastCommand = self.motor.connection.write_buffer[index].decode("utf-8") 
        for arg in arguments:
            msg = "Expected last command arguments to include " + \
                  "\"" + arg + "\" but got \"" + lastCommand.strip() +\
                  "\" instead."
            self.assertTrue(arg in lastCommand, msg=msg)


class OpenTronsTest(SerialTestCase):

    def setUp(self):

        # set this to True if testing with a robot connected
        # testing while connected allows the response handlers
        # and serial handshakes to be tested
        self.smoothie_connected = True

        self.motor = OpenTrons()

        self.smoothie_connected = False

        myport = ''

        if myport:
            self.smoothie_connected = True
            success = self.motor.connect(myport)
            self.assertTrue(success)
        else:
            self.motor.connection = GCodeLogger()

    def tearDown(self):
        self.motor.disconnect()

    def test_get_position(self):
        self.motor.home()
        coords = self.motor.get_position()
        if self.smoothie_connected:
            expected_coords = {
                'target':{'x':0,'y':0,'z':0,'a':0,'b':0},
                'current':{'x':0,'y':0,'z':0,'a':0,'b':0}
            }
            self.assertEquals(coords,expected_coords)
        else:
            self.assertLastCommand('M114')

    def test_halt(self):
        success = self.motor.halt()
        if self.smoothie_connected:
            self.assertTrue(success)
        else:
            self.assertLastCommand('M112')
{'fraction_non_alphanumeric': 0.1173939766441303, 'fraction_numerical': 0.009834050399508297, 'mean_word_length': 2.043640897755611, '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': '4727819', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1349, 'n_words': 306}