Why does my Python code fail unit testing?
<p>I have this challenge:</p>

<blockquote>
  <p>Create a function called binary_converter. Inside the function, implement an algorithm to convert decimal numbers between 0 and 255 to their binary equivalents.</p>
  
  <p>For any invalid input, return string Invalid input</p>
  
  <p>Example: For number 5 return string 101</p>
</blockquote>

<p>Unit test code is below</p>

<pre><code>import unittest


class BinaryConverterTestCases(unittest.TestCase):
  def test_conversion_one(self):
    result = binary_converter(0)
    self.assertEqual(result, '0', msg='Invalid conversion')

  def test_conversion_two(self):
    result = binary_converter(62)
    self.assertEqual(result, '111110', msg='Invalid conversion')

  def test_no_negative_numbers(self):
    result = binary_converter(-1)
    self.assertEqual(result, 'Invalid input', msg='Input below 0 not allowed')

  def test_no_numbers_above_255(self):
    result = binary_converter(300)
    self.assertEqual(result, 'Invalid input', msg='Input above 255 not allowed')
</code></pre>

<p>my code goes below</p>

<pre><code>def binary_converter(n):

    if(n==0):
        return "0"

    elif(n&gt;255):

        return "invalid input"
    elif(n &lt; 0):
        return "invalid input"
    else:
        ans=""
        while(n&gt;0):
            temp=n%2
            ans=str(temp)+ans
            n=n/2
        return ans
</code></pre>

<p>Unit test results</p>

<pre><code>Total Specs: 4 Total Failures: 2

1. test_no_negative_numbers

    `Failure in line 19, in test_no_negative_numbers self.assertEqual(result, 'Invalid input', msg='Input below 0 not allowed') AssertionError: Input below 0 not allowed`

2. test_no_numbers_above_255

    `Failure in line 23, in test_no_numbers_above_255 self.assertEqual(result, 'Invalid input', msg='Input above 255 not allowed') AssertionError: Input above 255 not allowed`
</code></pre>

<p>Comparing strings in Python cares cases.</p>

<pre><code>&gt;&gt;&gt; 'invalid input' == 'Invalid input'
False
</code></pre>

<p>You need to adjust test code or implementation code so that string literals matches exactly.</p>

<pre><code>def test_no_negative_numbers(self):
    result = binary_converter(-1)
    self.assertEqual(result, 'Invalid input', msg='Input below 0 not allowed')
                              ^--- (UPPERCASE)

...

elif(n &lt; 0):
    return "invalid input"
            ^--- (lowercase)
</code></pre>

python unit-testing