Example #1
0
 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)
Example #2
0
 def testShouldReturnLastMatchedValue(self):
     c = captor(contains("foo"))
     c.matches("foobar")
     c.matches("foobam")
     c.matches("bambaz")
     self.assertEqual("foobam", c.value)
Example #3
0
 def testShouldReturnNoneValueIfDidntMatch(self):
     c = captor(contains("foo"))
     c.matches("bar")
     self.assertEqual(None, c.value)
Example #4
0
 def testShouldReturnNoneValueByDefault(self):
     c = captor(contains("foo"))
     self.assertEqual(None, c.value)
Example #5
0
 def testShouldNotSatisfyIfInnerMatcherIsNotSatisfied(self):
     c = captor(contains("foo"))
     self.assertFalse(c.matches("barbam"))
Example #6
0
 def testShouldReturnNoneValueByDefault(self):
     c = captor(contains("foo"))
     self.assertListEqual([], c.all_values)
     with self.assertRaises(MatcherError):
         _ = c.value
Example #7
0
 def testShouldNotSatisfyIfAllOfMatchersAreNotSatisfied(self):
     self.assertFalse(
         or_(contains("bam"), contains("baz")).matches("foobar"))
Example #8
0
 def testShouldNotSatisfyIfOneOfMatchersIsNotSatisfied(self):
     self.assertFalse(
         and_(contains("foo"), contains("bam")).matches("foobar"))
Example #9
0
 def testShouldNotSatisfiyStringWhichIsNotSubstringOfGivenString(self):
     self.assertFalse(contains("barfoo").matches("foobar"))
Example #10
0
 def testShouldSatisfySameString(self):
     self.assertTrue(contains("foobar").matches("foobar"))
Example #11
0
 def testShouldSatisfiySubstringOfGivenString(self):
     self.assertTrue(contains("foo").matches("foobar"))
Example #12
0
 def testShouldNotSatisfyIfInnerMatcherIsSatisfied(self):
     self.assertFalse(not_(contains("foo")).matches("foo"))
Example #13
0
 def testShouldSatisfyIfInnerMatcherIsNotSatisfied(self):
     self.assertTrue(not_(contains("foo")).matches("bar"))
Example #14
0
 def testShouldReturnNoneValueIfDidntMatch(self):
     c = captor(contains("foo"))
     c.matches("bar")
     self.assertListEqual([], c.all_values)
     with self.assertRaises(MatcherError):
         _ = c.value
Example #15
0
    def testVerifiesUsingContainsMatcher(self):
        ourMock = mock()
        ourMock.foo("foobar")

        verify(ourMock).foo(contains("foo"))
        verify(ourMock).foo(contains("bar"))
Example #16
0
 def testShouldNotSatisfiyEmptyString(self):
     self.assertFalse(contains("").matches("foobar"))
Example #17
0
 def testShouldSatisfyIfAllMatchersAreSatisfied(self):
     self.assertTrue(
         and_(contains("foo"), contains("bar")).matches("foobar"))
Example #18
0
 def testShouldNotSatisfiyNone(self):
     self.assertFalse(contains(None).matches("foobar"))
Example #19
0
 def testShouldSatisfyIfAnyOfMatchersIsSatisfied(self):
     self.assertTrue(
         or_(contains("foo"), contains("bam")).matches("foobar"))
Example #20
0
 def testShouldSatisfyIfInnerMatcherIsSatisfied(self):
     c = captor(contains("foo"))
     self.assertTrue(c.matches("foobar"))
Example #21
0
 def test_connectingWillSpawnSSH(self):
     pexpectObject = mock()
     cli = self.createSshConnection(pexpectObject)
     when(pexpectObject).spawn(any()).thenReturn(mock())
     cli.connectWithSsh()
     verify(pexpectObject).spawn(contains('ssh'))
Example #22
0
 def testShouldSatisfyIfInnerMatcherIsSatisfied(self):
     c = captor(contains("foo"))
     self.assertTrue(c.matches("foobar"))
     self.assertListEqual([
         "foobar",
     ], c.all_values)