old_contents: import unittest
  
  class TestStringMethods(unittest.TestCase):
  
      def test_upper(self):
          self.assertEqual('foo'.upper(), 'FOO')
  
      def test_isupper(self):
          self.assertTrue('FOO'.isupper())
          self.assertFalse('Foo'.isupper())
  
      def test_split(self):
          s = 'hello world'
          self.assertEqual(s.split(), ['hello', 'world'])
          # check that s.split fails when the separator is not a string
          with self.assertRaises(TypeError):
              s.split(2)
  
  
  
  def map_range(x, X_min, X_max, Y_min, Y_max):
      X_range = X_max - X_min
      Y_range = Y_max - Y_min
      XY_ratio = X_range/Y_range
  
      y = ((x-X_min) / XY_ratio + Y_min) // 1
  
      return int(y)
  
  
  
  class TestMapping(unittest.TestCase):
      def test_positive(self):
          min = map_range(-100, -100, 100, 0, 1000)
          half = map_range(0, -100, 100, 0, 1000)
          max = map_range(100, -100, 100, 0, 1000)
          assert min == 0
          assert half == 500
          assert max == 1000
  
      def test_negative(self):
          ranges = (0, 100, 0, 1000)
          min = map_range(0, *ranges)
          half = map_range(50, *ranges)
          max = map_range(100, *ranges)
          assert min == 0
          assert half == 500
          assert max == 1000
  
  if __name__ == '__main__':
      unittest.main()
new_contents: import unittest
  
  class TestStringMethods(unittest.TestCase):
  
      def test_upper(self):
          self.assertEqual('foo'.upper(), 'FOO')
  
      def test_isupper(self):
          self.assertTrue('FOO'.isupper())
          self.assertFalse('Foo'.isupper())
  
      def test_split(self):
          s = 'hello world'
          self.assertEqual(s.split(), ['hello', 'world'])
          # check that s.split fails when the separator is not a string
          with self.assertRaises(TypeError):
              s.split(2)
  
  
  
  from donkey.actuators import map_range
  
  
  
  class TestMapping(unittest.TestCase):
      def test_positive(self):
          min = map_range(-100, -100, 100, 0, 1000)
          half = map_range(0, -100, 100, 0, 1000)
          max = map_range(100, -100, 100, 0, 1000)
          assert min == 0
          assert half == 500
          assert max == 1000
  
      def test_negative(self):
          ranges = (0, 100, 0, 1000)
          min = map_range(0, *ranges)
          half = map_range(50, *ranges)
          max = map_range(100, *ranges)
          assert min == 0
          assert half == 500
          assert max == 1000
  
  if __name__ == '__main__':
      unittest.main()
subject: update mapping test