1

I am testing my code in django and i have a case where i want to test if it is NOT equal. How can i do that ?

i am using the doc from django here : https://docs.djangoproject.com/fr/2.2/topics/testing/tools/

Another example in react we have ".not" to say not equal.

I tried with '.not'

class SimpleTest(TestCase):
    def test_details(self):
        response = self.client.get('/customer/details/')
        self.assertEqual(response.status_code, 200).not()

I expected to have one condition who test the no egality between my variable and my status code.

Thank for your help.

Valentin Garreau
  • 963
  • 1
  • 10
  • 32
  • 2
    And what happened when you used `assertNotEqual`, which is [fully documented](https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertNotEqual)? – Daniel Roseman Jun 14 '19 at 13:41
  • Working perfectly i miss spell it on my code ... thank you ! – Valentin Garreau Jun 14 '19 at 13:47
  • `assertNotEqual` will fail in some cases (at least in the future) because `==` element-wise is scheduled for [deprecation](https://stackoverflow.com/questions/44574679/python-deprecationwarning-elementwise-comparison-failed-this-will-raise-an) – NelsonGon Jan 10 '21 at 09:23

1 Answers1

0

Solution from @DanielRoseman is working. Used assertNotEqual fixed the problem

Doc: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertNotEqual

Valentin Garreau
  • 963
  • 1
  • 10
  • 32