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

        verify(ourMock).foo(contains("foo"))
        verify(ourMock).foo(contains("bar"))
示例#16
0
 def testShouldNotSatisfiyEmptyString(self):
     self.assertFalse(contains("").matches("foobar"))
示例#17
0
 def testShouldSatisfyIfAllMatchersAreSatisfied(self):
     self.assertTrue(
         and_(contains("foo"), contains("bar")).matches("foobar"))
示例#18
0
 def testShouldNotSatisfiyNone(self):
     self.assertFalse(contains(None).matches("foobar"))
示例#19
0
 def testShouldSatisfyIfAnyOfMatchersIsSatisfied(self):
     self.assertTrue(
         or_(contains("foo"), contains("bam")).matches("foobar"))
示例#20
0
 def testShouldSatisfyIfInnerMatcherIsSatisfied(self):
     c = captor(contains("foo"))
     self.assertTrue(c.matches("foobar"))
示例#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'))
示例#22
0
 def testShouldSatisfyIfInnerMatcherIsSatisfied(self):
     c = captor(contains("foo"))
     self.assertTrue(c.matches("foobar"))
     self.assertListEqual([
         "foobar",
     ], c.all_values)