Ticket #6350: assertIs-v2.patch

File assertIs-v2.patch, 2.6 KB (added by Julian Berman, 9 years ago)
  • twisted/trial/_synctest.py

    diff --git a/twisted/trial/_synctest.py b/twisted/trial/_synctest.py
    index 45708eb..8d8945b 100644
    a b class _Assertions(pyunit.TestCase, object): 
    358358    failUnlessEqual = failUnlessEquals = assertEquals = assertEqual
    359359
    360360
    361     def assertIdentical(self, first, second, msg=None):
     361    def assertIs(self, first, second, msg=None):
    362362        """
    363363        Fail the test if C{first} is not C{second}.  This is an
    364364        obect-identity-equality test, not an object equality
    class _Assertions(pyunit.TestCase, object): 
    370370        if first is not second:
    371371            raise self.failureException(msg or '%r is not %r' % (first, second))
    372372        return first
    373     failUnlessIdentical = assertIdentical
     373    failUnlessIdentical = assertIdentical = assertIs
    374374
    375375
    376     def assertNotIdentical(self, first, second, msg=None):
     376    def assertIsNot(self, first, second, msg=None):
    377377        """
    378378        Fail the test if C{first} is C{second}.  This is an
    379379        obect-identity-equality test, not an object equality
    class _Assertions(pyunit.TestCase, object): 
    385385        if first is second:
    386386            raise self.failureException(msg or '%r is %r' % (first, second))
    387387        return first
    388     failIfIdentical = assertNotIdentical
     388    failIfIdentical = assertNotIdentical = assertIsNot
    389389
    390390
    391391    def assertNotEqual(self, first, second, msg=None):
  • twisted/trial/test/test_assertions.py

    diff --git a/twisted/trial/test/test_assertions.py b/twisted/trial/test/test_assertions.py
    index 788cee0..ac02c9e 100644
    a b class TestSynchronousAssertions(unittest.SynchronousTestCase): 
    507507                              self.failIfSubstring, x, z)
    508508
    509509
     510    def test_assertIs(self):
     511        """
     512        Test a true condition of L{assertIs}.
     513        """
     514        a = object()
     515        self.assertIs(a, a)
     516
     517
     518    def test_assertIsError(self):
     519        """
     520        Test an error with L{assertIs}.
     521        """
     522        a, b = object(), object()
     523        self.assertRaises(self.failureException, self.assertIs, a, b)
     524
     525
     526    def test_assertIsNot(self):
     527        """
     528        Test a true condition of L{assertIsNot}.
     529        """
     530        a, b = object(), object()
     531        self.assertIsNot(a, b)
     532
     533
     534    def test_assertIsNotError(self):
     535        """
     536        Test an error with L{assertIsNot}.
     537        """
     538        a = object()
     539        self.assertRaises(self.failureException, self.assertIsNot, a, a)
     540
     541
    510542    def test_assertIsInstance(self):
    511543        """
    512544        Test a true condition of assertIsInstance.