diff options
author | smiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875> | 2008-07-01 20:47:46 +0000 |
---|---|---|
committer | smiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875> | 2008-07-01 20:47:46 +0000 |
commit | 807e7567d447997b0887164f36571b104af03572 (patch) | |
tree | 8953500bb91571ccce00698c7a1ae3ab1dad4ec1 /mox_test.py | |
parent | 5a84531d0e4f81fa4af078140a97b82aeca7c4c5 (diff) | |
download | pymox-807e7567d447997b0887164f36571b104af03572.tar.gz |
Add a Not comparator to compose with other comparators.
Patch by: Benoit Sigoure <benoits@google.com>
Diffstat (limited to 'mox_test.py')
-rwxr-xr-x | mox_test.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mox_test.py b/mox_test.py index be35bae..5f00f0c 100755 --- a/mox_test.py +++ b/mox_test.py @@ -159,6 +159,38 @@ class InTest(unittest.TestCase): self.assert_(mox.In("test") == {"test" : "module"}) +class NotTest(unittest.TestCase): + """Test Not correctly identifies False predicates.""" + + def testItemInList(self): + """Should return True if the item is NOT in the list.""" + self.assert_(mox.Not(mox.In(42)) == [1, 2, 3]) + + def testKeyInDict(self): + """Should return True if the item is NOT a key in a dict.""" + self.assert_(mox.Not(mox.In("foo")) == {"key" : 42}) + + def testInvalidKeyWithNot(self): + """Should return False if they key is NOT in the dict.""" + self.assert_(mox.Not(mox.ContainsKeyValue("qux", 1)) == {"key": 2}) + + +class NotTest(unittest.TestCase): + """Test Not correctly identifies False predicates.""" + + def testItemInList(self): + """Should return True if the item is NOT in the list.""" + self.assert_(mox.Not(mox.In(42)) == [1, 2, 3]) + + def testKeyInDict(self): + """Should return True if the item is NOT a key in a dict.""" + self.assert_(mox.Not(mox.In("foo")) == {"key" : 42}) + + def testInvalidKeyWithNot(self): + """Should return False if they key is NOT in the dict.""" + self.assert_(mox.Not(mox.ContainsKeyValue("qux", 1)) == {"key": 2}) + + class StrContainsTest(unittest.TestCase): """Test StrContains correctly checks for substring occurrence of a parameter. """ |