def testShouldReturnLastMatchedValue(self): c = captor(contains("foo")) c.matches("foobar") c.matches("foobam") c.matches("bambaz") self.assertListEqual(["foobar", "foobam"], c.all_values) self.assertEqual("foobam", c.value)
def testShouldReturnLastMatchedValue(self): c = captor(contains("foo")) c.matches("foobar") c.matches("foobam") c.matches("bambaz") self.assertEqual("foobam", c.value)
def testShouldReturnNoneValueIfDidntMatch(self): c = captor(contains("foo")) c.matches("bar") self.assertEqual(None, c.value)
def testShouldReturnNoneValueByDefault(self): c = captor(contains("foo")) self.assertEqual(None, c.value)
def testShouldNotSatisfyIfInnerMatcherIsNotSatisfied(self): c = captor(contains("foo")) self.assertFalse(c.matches("barbam"))
def testShouldReturnNoneValueByDefault(self): c = captor(contains("foo")) self.assertListEqual([], c.all_values) with self.assertRaises(MatcherError): _ = c.value
def testShouldNotSatisfyIfAllOfMatchersAreNotSatisfied(self): self.assertFalse( or_(contains("bam"), contains("baz")).matches("foobar"))
def testShouldNotSatisfyIfOneOfMatchersIsNotSatisfied(self): self.assertFalse( and_(contains("foo"), contains("bam")).matches("foobar"))
def testShouldNotSatisfiyStringWhichIsNotSubstringOfGivenString(self): self.assertFalse(contains("barfoo").matches("foobar"))
def testShouldSatisfySameString(self): self.assertTrue(contains("foobar").matches("foobar"))
def testShouldSatisfiySubstringOfGivenString(self): self.assertTrue(contains("foo").matches("foobar"))
def testShouldNotSatisfyIfInnerMatcherIsSatisfied(self): self.assertFalse(not_(contains("foo")).matches("foo"))
def testShouldSatisfyIfInnerMatcherIsNotSatisfied(self): self.assertTrue(not_(contains("foo")).matches("bar"))
def testShouldReturnNoneValueIfDidntMatch(self): c = captor(contains("foo")) c.matches("bar") self.assertListEqual([], c.all_values) with self.assertRaises(MatcherError): _ = c.value
def testVerifiesUsingContainsMatcher(self): ourMock = mock() ourMock.foo("foobar") verify(ourMock).foo(contains("foo")) verify(ourMock).foo(contains("bar"))
def testShouldNotSatisfiyEmptyString(self): self.assertFalse(contains("").matches("foobar"))
def testShouldSatisfyIfAllMatchersAreSatisfied(self): self.assertTrue( and_(contains("foo"), contains("bar")).matches("foobar"))
def testShouldNotSatisfiyNone(self): self.assertFalse(contains(None).matches("foobar"))
def testShouldSatisfyIfAnyOfMatchersIsSatisfied(self): self.assertTrue( or_(contains("foo"), contains("bam")).matches("foobar"))
def testShouldSatisfyIfInnerMatcherIsSatisfied(self): c = captor(contains("foo")) self.assertTrue(c.matches("foobar"))
def test_connectingWillSpawnSSH(self): pexpectObject = mock() cli = self.createSshConnection(pexpectObject) when(pexpectObject).spawn(any()).thenReturn(mock()) cli.connectWithSsh() verify(pexpectObject).spawn(contains('ssh'))
def testShouldSatisfyIfInnerMatcherIsSatisfied(self): c = captor(contains("foo")) self.assertTrue(c.matches("foobar")) self.assertListEqual([ "foobar", ], c.all_values)